import PocketBase from "pocketbase";

export const pb = new PocketBase("http://localhost:8090");

let user = $state(pb.authStore.model);

if (user) {
  await pb.collection("users").authRefresh();
  console.log("refresh");
}

pb.authStore.onChange(() => {
  user = pb.authStore.model;
});

export let getUser = () => user;
