/** Client-side preferences (no server counterpart — these style the local browser only). The reference app keeps them in `Settings` via shared_preferences; here they live in localStorage. */ import { writable, type Writable } from 'svelte/store'; export type StyleTheme = 'frosthaven' | 'gloomhaven' | 'original'; const STYLE_KEY = 'x-haven-style'; function initialStyle(): StyleTheme { try { const stored = window.localStorage.getItem(STYLE_KEY); if (stored === 'frosthaven' || stored === 'gloomhaven' || stored === 'original') { return stored; } } catch { /* private browsing / disabled storage */ } return 'frosthaven'; } /** The visual style theme (PLAN.md Phase 3: the three style themes). */ export const styleTheme: Writable = writable(initialStyle()); styleTheme.subscribe((value) => { try { window.localStorage.setItem(STYLE_KEY, value); } catch { /* ignore */ } });