const STORAGE_PREFIX = 'cmpp-platform-v2'; export function readLocalData(key: string, fallback: T): T { if (typeof window === 'undefined') { return fallback; } const rawValue = window.localStorage.getItem(`${STORAGE_PREFIX}:${key}`); if (!rawValue) { return fallback; } try { return JSON.parse(rawValue) as T; } catch { return fallback; } } export function writeLocalData(key: string, value: T) { if (typeof window === 'undefined') { return; } window.localStorage.setItem(`${STORAGE_PREFIX}:${key}`, JSON.stringify(value)); } export function resetLocalData(key: string) { if (typeof window === 'undefined') { return; } window.localStorage.removeItem(`${STORAGE_PREFIX}:${key}`); }