/**
 * Minimal type declarations for sql.js (WebAssembly SQLite).
 * Only the API surface used by WebMailxDB is typed.
 */

declare module "sql.js" {
    interface SqlJsStatic {
        Database: new (data?: ArrayLike<number>) => Database;
    }

    interface Database {
        run(sql: string, params?: any[]): Database;
        exec(sql: string, params?: any[]): QueryExecResult[];
        export(): Uint8Array;
        close(): void;
    }

    interface QueryExecResult {
        columns: string[];
        values: any[][];
    }

    function initSqlJs(config?: {
        locateFile?: (file: string) => string;
    }): Promise<SqlJsStatic>;

    export default initSqlJs;
    export type { Database, SqlJsStatic, QueryExecResult };
}
