/**
 * Synchronous SQLite shim.
 *
 * Both Bun and Node 24+ ship a built-in synchronous SQLite binding,
 * but they live at different module specifiers and expose slightly
 * different constructor names:
 *
 *   - **Bun**:  `import { Database } from 'bun:sqlite'`
 *   - **Node 24+**: `import { DatabaseSync } from 'node:sqlite'`
 *     (marked experimental in 24.x; stable surface)
 *
 * The lowest-common-denominator surface (constructor + `prepare()` +
 * statement-level `.run()` / `.get()` / `.all()` / `.exec()` /
 * `.close()`) behaves identically across both implementations, so
 * call sites that program against this module's `Database` type get a
 * single migration target.
 *
 * Note: this shim is **not** part of the trivial-helpers-to-inline
 * group. It survives Phase 5 cleanup because the per-runtime module
 * specifier and constructor name genuinely differ.
 */
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
    if (typeof path === "string" && /^\.\.?\//.test(path)) {
        return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
            return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
        });
    }
    return path;
};
import { runtimeKind } from "./runtime-info.js";
export async function openDatabase(filename, opts) {
    if (runtimeKind() === 'bun') {
        // Stash the specifier in a const so tsc doesn't try to resolve
        // `bun:sqlite` at type-check time — we don't ship `bun-types` in
        // the cli's prod tsconfig anymore. The dynamic import is also
        // guarded at runtime by the runtimeKind() check above, so Node
        // never hits this branch.
        const spec = 'bun:sqlite';
        const mod = (await import(__rewriteRelativeImportExtension(spec)));
        const bunOpts = opts?.readonly ? { readonly: true } : undefined;
        return new mod.Database(filename, bunOpts);
    }
    const mod = (await import('node:sqlite'));
    const nodeOpts = opts?.readonly ? { readOnly: true } : undefined;
    return new mod.DatabaseSync(filename, nodeOpts);
}
//# sourceMappingURL=sqlite.js.map