import { EventBus } from '../core/EventBus';
export type SaveSlotType = 'manual' | 'auto' | 'checkpoint' | 'quick';
export type SaveConflictStrategy = 'local-wins' | 'remote-wins' | 'newest-wins' | 'merge' | 'prompt-user';
export type SaveStorageBackend = 'indexeddb' | 'localstorage' | 'filesystem' | 'cloud';
export type MigrationDirection = 'up' | 'down';
export interface SaveSlotMeta {
    slotId: string;
    type: SaveSlotType;
    label: string;
    schemaVersion: number;
    createdAt: number;
    updatedAt: number;
    playtimeMs: number;
    /** Scene/level the player was in */
    location: string;
    /** Preview thumbnail (data URL) */
    thumbnail?: string;
    /** Compressed size in bytes */
    sizeBytes: number;
    /** CRC32 checksum */
    checksum: number;
    /** Cloud sync status */
    cloudSynced: boolean;
    cloudTimestamp?: number;
    /** Custom tags for filtering */
    tags: string[];
}
export interface SaveData {
    meta: SaveSlotMeta;
    payload: Record<string, unknown>;
}
export interface SaveMigration {
    fromVersion: number;
    toVersion: number;
    description: string;
    /** Transform the payload from one version to the next */
    migrate: (payload: Record<string, unknown>) => Record<string, unknown>;
    /** Optional rollback */
    rollback?: (payload: Record<string, unknown>) => Record<string, unknown>;
}
export interface CloudSyncConfig {
    enabled: boolean;
    endpoint?: string;
    apiKey?: string;
    conflictStrategy: SaveConflictStrategy;
    syncIntervalMs: number;
    maxCloudSlots: number;
}
export interface AutoSaveConfig {
    enabled: boolean;
    intervalMs: number;
    maxAutoSaves: number;
    /** Only auto-save when game state is "safe" (not in combat, etc.) */
    requireSafeState: boolean;
}
export interface SaveSystemConfig {
    schemaVersion: number;
    storageBackend: SaveStorageBackend;
    storageKey: string;
    maxSlots: number;
    compressionEnabled: boolean;
    autoSave: AutoSaveConfig;
    cloud: CloudSyncConfig;
}
export declare const DEFAULT_SAVE_CONFIG: SaveSystemConfig;
export interface SaveConflict {
    slotId: string;
    localMeta: SaveSlotMeta;
    remoteMeta: SaveSlotMeta;
    resolvedWith?: SaveConflictStrategy;
}
export interface SaveResult {
    success: boolean;
    slotId: string;
    sizeBytes: number;
    compressed: boolean;
    error?: string;
}
/** Simple compression for JSON save data (dictionary-based) */
export declare function compressSaveData(json: string): Uint8Array;
/** Decompress save data */
export declare function decompressSaveData(data: Uint8Array): string;
export declare function crc32(data: Uint8Array): number;
export declare class MigrationEngine {
    private migrations;
    register(migration: SaveMigration): void;
    /** Migrate payload from fromVersion to toVersion */
    migrate(payload: Record<string, unknown>, fromVersion: number, toVersion: number): {
        payload: Record<string, unknown>;
        applied: string[];
    };
    getRegistered(): readonly SaveMigration[];
    canMigrate(from: number, to: number): boolean;
}
export declare class SaveSystemV2 {
    private config;
    private migrationEngine;
    private eventBus;
    private slots;
    private autoSaveTimer;
    private autoSaveCounter;
    private safeToSave;
    constructor(eventBus: EventBus, config?: Partial<SaveSystemConfig>);
    private setupEventHandlers;
    /** Register a schema migration */
    registerMigration(migration: SaveMigration): void;
    /** Save game state to a slot */
    save(slotId: string, payload: Record<string, unknown>, options?: {
        type?: SaveSlotType;
        label?: string;
        location?: string;
        thumbnail?: string;
        tags?: string[];
    }): SaveResult;
    /** Load game state from a slot */
    load(slotId: string): {
        payload: Record<string, unknown>;
        meta: SaveSlotMeta;
        migrated: boolean;
    } | null;
    /** Delete a save slot */
    delete(slotId: string): boolean;
    /** List all save slot metadata (sorted by updatedAt desc) */
    listSlots(): SaveSlotMeta[];
    /** Get slot metadata without loading payload */
    getSlotMeta(slotId: string): SaveSlotMeta | null;
    /** Check if a slot exists */
    hasSlot(slotId: string): boolean;
    /** Start auto-save timer */
    startAutoSave(getPayload: () => Record<string, unknown>, getLocation: () => string): void;
    /** Stop auto-save */
    stopAutoSave(): void;
    /** Quick save (overwriting the single quick save slot) */
    quickSave(payload: Record<string, unknown>, location: string): SaveResult;
    /** Quick load */
    quickLoad(): ReturnType<SaveSystemV2['load']>;
    /** Sync local saves to cloud (stub — needs actual endpoint) */
    syncToCloud(): Promise<{
        synced: string[];
        conflicts: SaveConflict[];
    }>;
    /** Resolve a cloud sync conflict */
    resolveConflict(conflict: SaveConflict, strategy: SaveConflictStrategy): SaveSlotMeta;
    private persistSlot;
    private removeFromStorage;
    /** Load all slots from storage backend */
    loadFromStorage(): Promise<number>;
    /** Export all saves as a downloadable blob */
    exportAll(): Blob;
    /** Import saves from a blob */
    importAll(blob: Blob): Promise<number>;
    getConfig(): Readonly<SaveSystemConfig>;
    getMigrationEngine(): MigrationEngine;
    destroy(): void;
}
