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AAM,KAAA,EACL,QAAA,WAAmB,MAAA,EAAQ,OAAA,CAAQ,QAAA,EAAU,OAAO,QAAA,IAAY,SAAA,EAAW,QAAA,EAAU,EAAA;AACtF,IAAA,MAAM,MAAA,EAAQ,YAAA,CAAa,IAAA,CAAK,IAAI,CAAA;AACpC,IAAA,GAAA,CAAI,KAAA,EAAO,OAAO,EAAE,MAAA,EAAQ,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG,IAAA,EAAM,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,EAAE,CAAA;AACrE,IAAA,QAAA,EAAU,QAAA,WAAmB,MAAA,EAAS,OAAA,CAAgC,MAAA,EAAQ,IAAA;AAAA,EAC/E;AACA,EAAA,OAAO,IAAA;AACR;AAGO,IAAM,kBAAA,EAAoB,2DAAA;AAG1B,IAAM,wBAAA,EAA0B,gBAAA;ADnCvC;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yfAAC","file":"/home/runner/work/kora/kora/packages/store/dist/chunk-XTGUCA5Y.cjs","sourcesContent":[null,"/**\n * The schema-version ceiling (RT-109): a build never runs against a database a newer\n * build already migrated.\n *\n * `generateFullDDL` emits `--kora:schema-ceiling <version>` right after `_kora_meta`, before\n * any other DDL. It is a SQL comment; Kora's DDL executors (the native adapter, the SQLite\n * WASM worker, the test bridge) stop there with {@link schemaAheadMessage} when the\n * database's stored schema version is newer, so not even this build's additive DDL touches\n * it. The store then maps the failure to `SchemaVersionAheadError` and checks again after\n * every open (adapters that restore data after their DDL, such as the IndexedDB fallback).\n *\n * No imports: the SQLite WASM worker bundles this file.\n */\n\nconst DIRECTIVE = /^--kora:schema-ceiling (\\d+)$/\nconst AHEAD = /KORA_SCHEMA_VERSION_AHEAD stored=(\\d+) code=(\\d+)/\n\n/** The version a `--kora:schema-ceiling <version>` DDL statement names, or null. */\nexport function parseSchemaCeiling(sql: string): number | null {\n\tconst match = DIRECTIVE.exec(sql.trim())\n\treturn match ? Number(match[1]) : null\n}\n\n/** The stored version from a `_kora_meta` row read, or 0 when none is stored. */\nexport function storedSchemaVersion(rows: ReadonlyArray<{ value: unknown }>): number {\n\tconst value = Number(rows[0]?.value ?? 0)\n\treturn Number.isFinite(value) ? value : 0\n}\n\n/** The message a DDL executor throws when the database is ahead (parsed back by the store). */\nexport function schemaAheadMessage(stored: number, code: number): string {\n\treturn `KORA_SCHEMA_VERSION_AHEAD stored=${stored} code=${code}: the database was migrated by a newer build (schema version ${stored}); this build's schema version is ${code}.`\n}\n\n/** The versions in an error raised by {@link schemaAheadMessage}, wherever it was wrapped. */\nexport function parseSchemaAhead(error: unknown): { stored: number; code: number } | null {\n\tconst seen = new Set<unknown>()\n\tlet current: unknown = error\n\twhile (current !== null && current !== undefined && !seen.has(current)) {\n\t\tseen.add(current)\n\t\tconst text =\n\t\t\tcurrent instanceof Error ? current.message : typeof current === 'string' ? current : ''\n\t\tconst match = AHEAD.exec(text)\n\t\tif (match) return { stored: Number(match[1]), code: Number(match[2]) }\n\t\tcurrent = current instanceof Error ? (current as { cause?: unknown }).cause : null\n\t}\n\treturn null\n}\n\n/** Query the stored schema version through a synchronous runner (DDL executors). */\nexport const STORED_SCHEMA_VERSION_SQL = \"SELECT value FROM _kora_meta WHERE key = 'schema_version'\"\n\nconst FORMAT_DIRECTIVE = /^--kora:format-ceiling (\\d+)$/\nconst FORMAT_AHEAD = /KORA_STORAGE_FORMAT_AHEAD stored=(\\d+) code=(\\d+)/\n\n/** The format a `--kora:format-ceiling <format>` DDL statement names, or null. */\nexport function parseFormatCeiling(sql: string): number | null {\n\tconst match = FORMAT_DIRECTIVE.exec(sql.trim())\n\treturn match ? Number(match[1]) : null\n}\n\n/** The message a DDL executor throws when the stored storage format is newer. */\nexport function formatAheadMessage(stored: number, code: number): string {\n\treturn `KORA_STORAGE_FORMAT_AHEAD stored=${stored} code=${code}: the database was opened by a build with a newer Kora storage format (${stored}); this build's format is ${code}.`\n}\n\n/** The formats in an error raised by {@link formatAheadMessage}, wherever it was wrapped. */\nexport function parseFormatAhead(error: unknown): { stored: number; code: number } | null {\n\tconst seen = new Set<unknown>()\n\tlet current: unknown = error\n\twhile (current !== null && current !== undefined && !seen.has(current)) {\n\t\tseen.add(current)\n\t\tconst text =\n\t\t\tcurrent instanceof Error ? current.message : typeof current === 'string' ? current : ''\n\t\tconst match = FORMAT_AHEAD.exec(text)\n\t\tif (match) return { stored: Number(match[1]), code: Number(match[2]) }\n\t\tcurrent = current instanceof Error ? (current as { cause?: unknown }).cause : null\n\t}\n\treturn null\n}\n\n/** Query the stored Kora storage format (version gate); no row means format 0 (pre-gate). */\nexport const STORED_FORMAT_SQL = \"SELECT value FROM _kora_meta WHERE key = 'storage_format'\"\n\n/** The `_kora_meta` key the storage format is stored under. */\nexport const STORAGE_FORMAT_META_KEY = 'storage_format'\n"]}