import PocketBase from 'pocketbase';
import { browser } from '$app/environment';

const PB_URL = 'https://api.checkflo.de';

export const pb = new PocketBase(PB_URL);

// Auth-State nur im Browser persistieren
if (browser) {
	pb.authStore.loadFromCookie(document.cookie);
	pb.authStore.onChange(() => {
		document.cookie = pb.authStore.exportToCookie({ httpOnly: false });
	});
}
