/**
 * StorageService - Unified localStorage management for widget
 *
 * Consolidates all widget localStorage into a single key: marketrix_chat_context
 * Contains: chat_id, messages, widget state, and config
 */
import type { ChatMessage, InstructionType, MarketrixConfig, TaskProgress } from '../types';
/**
 * Serializable version of ChatMessage (timestamp as string, no videoStream)
 */
type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
    timestamp: string;
};
/**
 * Unified storage structure for all widget data
 */
export interface MarketrixChatContext {
    chat_id: string | null;
    messages: StoredMessage[];
    isTaskRunning: boolean;
    activeTaskId: string | null;
    taskProgress: TaskProgress[];
    currentMode: InstructionType;
    isOpen: boolean;
    isMinimized: boolean;
    isLoading: boolean;
    config: MarketrixConfig | null;
    timestamp: number;
}
declare class StorageService {
    private static instance;
    private context;
    private constructor();
    static getInstance(): StorageService;
    /**
     * Load context from localStorage
     */
    private loadContext;
    /**
     * Save context to localStorage
     */
    private saveContext;
    /**
     * Get the full context
     */
    getContext(): MarketrixChatContext;
    /**
     * Update context with partial data
     */
    updateContext(updates: Partial<MarketrixChatContext>): void;
    /**
     * Check if a string is a valid chat_id
     */
    private isValidChatId;
    /**
     * Get chat_id with window.name fallback for cross-page navigation
     * Priority: window.name (if valid) -> localStorage
     */
    getChatId(): string | null;
    /**
     * Set chat_id in both localStorage and window.name.
     * Dispatches a 'marketrix:chatid' event so other services (e.g. SessionRecorder) can react.
     */
    setChatId(chatId: string | null): void;
    getMessages(): StoredMessage[];
    setMessages(messages: StoredMessage[]): void;
    getChatState(): Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'taskProgress' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>;
    setChatState(state: Partial<Pick<MarketrixChatContext, 'isTaskRunning' | 'activeTaskId' | 'taskProgress' | 'currentMode' | 'isOpen' | 'isMinimized' | 'isLoading'>>): void;
    getConfig(): MarketrixConfig | null;
    setConfig(config: MarketrixConfig | null): void;
    clear(): void;
    /**
     * Check if context exists and has a valid chat_id
     */
    hasValidContext(): boolean;
}
export declare const storageService: StorageService;
export {};
//# sourceMappingURL=StorageService.d.ts.map