// Demo-grade host bootstrap. Real auth would replace this entirely; for now // we upsert by email and stash the host id in localStorage. interface User { id: string email: string name: string } const STORAGE_KEY = 'gg.host' export function useHost() { const host = useState('gg-host', () => null) if (import.meta.client && !host.value) { const raw = window.localStorage.getItem(STORAGE_KEY) if (raw) { try { host.value = JSON.parse(raw) } catch { window.localStorage.removeItem(STORAGE_KEY) } } } async function bootstrap(email: string, name: string) { const u = await useApi('/users', { method: 'POST', body: { email, name }, }) host.value = u if (import.meta.client) { window.localStorage.setItem(STORAGE_KEY, JSON.stringify(u)) } return u } function clear() { host.value = null if (import.meta.client) window.localStorage.removeItem(STORAGE_KEY) } return { host, bootstrap, clear } }