const STORAGE_KEY = 'pn-marketweb-header:menu-mode';
/**
 * Returns the previously selected menu mode from localStorage.
 *
 * Returns null if:
 * - nothing is stored
 * - value is invalid
 * - storage is unavailable
 */
export function getStoredHeaderMenuMode() {
    if (typeof window === 'undefined') {
        return null;
    }
    try {
        const value = window.localStorage.getItem(STORAGE_KEY);
        if (value == null) {
            return null;
        }
        const parsed = Number(value);
        if (Number.isInteger(parsed) && parsed >= 0) {
            return parsed;
        }
    }
    catch {
        // intentionally ignored
    }
    return null;
}
/**
 * Persists the selected menu mode in localStorage.
 *
 * Storage failures are intentionally ignored.
 */
export function storeHeaderMenuMode(mode) {
    if (typeof window === 'undefined') {
        return;
    }
    try {
        window.localStorage.setItem(STORAGE_KEY, String(mode));
    }
    catch {
        // intentionally ignored
    }
}
/**
 * Resolves the effective initial menu mode.
 *
 * Priority:
 * 1. Stored user preference
 * 2. Server-provided initial mode
 * 3. Fallback to first mode (index 0)
 */
export function resolveInitialHeaderMenuMode(hasMenuSwitching, initialActiveMenuMode) {
    if (!hasMenuSwitching) {
        return 0;
    }
    const storedMode = getStoredHeaderMenuMode();
    if (typeof storedMode === 'number') {
        return storedMode;
    }
    return initialActiveMenuMode ?? 0;
}
//# sourceMappingURL=header-toggle-menu.storage.js.map
