// src/stores.js import { writable, type Writable } from 'svelte/store'; import { browser } from '$app/environment'; // Initialize the store with a boolean value from local storage export const location: Writable = writable(fromLocalStorage('location', false)); toLocalStorage(location, 'location'); function fromLocalStorage(storageKey: string, fallback: boolean): boolean { if (browser) { const storedValue = localStorage.getItem(storageKey); if (storedValue !== null && storedValue !== 'undefined') { return storedValue === 'true'; } } return fallback; } function toLocalStorage(store: Writable, storageKey: string) { if (browser) { store.subscribe((value: boolean) => { localStorage.setItem(storageKey, String(value)); }); } }