// ============================================
// Storage Service Interface
// Abstract interface for data persistence
// ============================================

/**
 * Abstract storage interface for data persistence.
 * Allows swapping between localStorage, IndexedDB, or API backends.
 */
export interface StorageService {
    /**
     * Get a value from storage
     * @param key Storage key
     * @returns The stored value or null if not found
     */
    get<T>(key: string): T | null;

    /**
     * Set a value in storage
     * @param key Storage key
     * @param value Value to store (will be serialized)
     */
    set<T>(key: string, value: T): void;

    /**
     * Remove a value from storage
     * @param key Storage key
     */
    remove(key: string): void;

    /**
     * Check if a key exists in storage
     * @param key Storage key
     */
    has(key: string): boolean;

    /**
     * Clear all stored data (use with caution)
     */
    clear(): void;
}

/**
 * Storage keys used throughout the application
 * Centralized to prevent typos and enable easy refactoring
 */
export const STORAGE_KEYS = {
    EDITOR_AUTOSAVE: 'kuldvillak-editor-autosave',
    GAMES_LIST: 'kuldvillak-games',
    GAME_PREFIX: 'kuldvillak-game-',
    GAME_SESSION: 'kuldvillak-game-session',
    THEME: 'kuldvillak-theme',
    AUDIO: 'kuldvillak-audio',
} as const;

export type StorageKey = typeof STORAGE_KEYS[keyof typeof STORAGE_KEYS];
