const defaults = { apiBase: `${window.location.origin}/api/v1`, gatewayBase: `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/gateway`, token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidHlwZSI6MSwiaWF0IjoxNjUwODQzMjY1LCJleHAiOjE2NTEwMTYwNjV9.ssu-MlMkwKQOcP5nmJ98KbqudcGW5XBYPc_d6et4oxo" }; const dummyProvider = { _store: {}, getItem(key) { return this._store[key]; }, setItem(key, value) { this._store[key] = value; } }; function getProvider() { return window.localStorage || dummyProvider; } export function getItem(key) { return getProvider().getItem(key); } export function setItem(key, value) { return getProvider().setItem(key, value); } export function getAuthToken() { return getItem("token"); } export function setAuthToken(value) { return setItem("token", value); } export function apiRoute(fragment) { return `${getItem("apiBase")}/${fragment}`; } export function setItemIfNull(key, value) { const provider = getProvider(); if (!provider.getItem(key)) { provider.setItem(key, value); return true; } return false; } export function initStorageDefaults() { for (const [k, v] of Object.entries(defaults)) { setItemIfNull(k, v); } }