@lunora/studio 1.0.0-alpha.225 → 1.0.0-alpha.227

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/standalone/{chunk-CGBR52EF.js → chunk-23SFT2CI.js} +1 -1
  2. package/dist/standalone/{chunk-IDGVZH7L.js → chunk-2V35H4JV.js} +1 -1
  3. package/dist/standalone/{chunk-SX43GWLQ.js → chunk-3EQVJ5SQ.js} +1 -1
  4. package/dist/standalone/{chunk-FYTLD6ZB.js → chunk-3I7EESH6.js} +1 -1
  5. package/dist/standalone/{chunk-46EQO6E7.js → chunk-3PWB52UO.js} +1 -1
  6. package/dist/standalone/{chunk-6JJLA4DT.js → chunk-4PBNO4Q3.js} +1 -1
  7. package/dist/standalone/{chunk-VCJJ6V4Q.js → chunk-53KDWFYV.js} +1 -1
  8. package/dist/standalone/{chunk-FJ33XGJ2.js → chunk-56GQRRBV.js} +1 -1
  9. package/dist/standalone/{chunk-J7PUQPIK.js → chunk-57L2DM4H.js} +1 -1
  10. package/dist/standalone/{chunk-7FZPPR6U.js → chunk-57XP5MZR.js} +1 -1
  11. package/dist/standalone/{chunk-CEWWYWDH.js → chunk-6WONKHEK.js} +1 -1
  12. package/dist/standalone/{chunk-RHCY7FOG.js → chunk-7BJGFDVG.js} +1 -1
  13. package/dist/standalone/{chunk-CFZF73E5.js → chunk-A3G6E5U2.js} +1 -1
  14. package/dist/standalone/{chunk-5ITJRE7T.js → chunk-AZ4CIFUE.js} +1 -1
  15. package/dist/standalone/{chunk-JBFHGYJ7.js → chunk-BSNHEJP3.js} +1 -1
  16. package/dist/standalone/{chunk-2ABVDLD3.js → chunk-C5CNJIVE.js} +1 -1
  17. package/dist/standalone/{chunk-X4WJS7OY.js → chunk-CBTT4FMH.js} +1 -1
  18. package/dist/standalone/{chunk-NAABU3WM.js → chunk-DAFY42M2.js} +1 -1
  19. package/dist/standalone/{chunk-LGHZBMSX.js → chunk-DCDNW7DR.js} +2 -2
  20. package/dist/standalone/{chunk-RWYC2UZQ.js → chunk-DTTTM3CW.js} +1 -1
  21. package/dist/standalone/{chunk-XUH4K2HN.js → chunk-ELWVLXCM.js} +1 -1
  22. package/dist/standalone/{chunk-FZ5ZSUA2.js → chunk-ERHFRNCL.js} +1 -1
  23. package/dist/standalone/{chunk-EN3YBGYA.js → chunk-EY6WHXDO.js} +1 -1
  24. package/dist/standalone/{chunk-N3N44LM3.js → chunk-F2RMCBTB.js} +1 -1
  25. package/dist/standalone/{chunk-IVHSLEDF.js → chunk-FZ5SSAZU.js} +1 -1
  26. package/dist/standalone/{chunk-WH5TVSUG.js → chunk-GCHHYR6O.js} +1 -1
  27. package/dist/standalone/{chunk-ZVJOW25X.js → chunk-GOSWKLMM.js} +1 -1
  28. package/dist/standalone/{chunk-LWS3QK2Z.js → chunk-HGP7GH2M.js} +1 -1
  29. package/dist/standalone/{chunk-A2XTI2C3.js → chunk-ICOTONE3.js} +1 -1
  30. package/dist/standalone/{chunk-OYO24LYQ.js → chunk-IGPZHAPG.js} +1 -1
  31. package/dist/standalone/{chunk-VELEXXBI.js → chunk-JKH4TDU3.js} +1 -1
  32. package/dist/standalone/{chunk-RBESZ4U6.js → chunk-JTAVWGVE.js} +1 -1
  33. package/dist/standalone/{chunk-43HEY5SJ.js → chunk-KCEEZ6OU.js} +1 -1
  34. package/dist/standalone/{chunk-NMS7725B.js → chunk-KDR232YC.js} +1 -1
  35. package/dist/standalone/{chunk-7JR5NBZT.js → chunk-L5XAH44R.js} +1 -1
  36. package/dist/standalone/{chunk-5ICUJ4IA.js → chunk-LCXKALTS.js} +1 -1
  37. package/dist/standalone/{chunk-XEW4IUTU.js → chunk-LMXRQ3KJ.js} +1 -1
  38. package/dist/standalone/{chunk-E34I2O2H.js → chunk-MZ3WS2FG.js} +1 -1
  39. package/dist/standalone/{chunk-SEQJ26SP.js → chunk-NOCFO4AL.js} +1 -1
  40. package/dist/standalone/{chunk-XBSC4FT4.js → chunk-O6AGWZVF.js} +1 -1
  41. package/dist/standalone/{chunk-6SG5Y2X3.js → chunk-PPKKM57M.js} +1 -1
  42. package/dist/standalone/{chunk-CCHE3AP7.js → chunk-QNXB7FVQ.js} +1 -1
  43. package/dist/standalone/chunk-R4WRHIAN.js +9 -0
  44. package/dist/standalone/{chunk-HSWCIY4E.js → chunk-RBWXVBJ2.js} +1 -1
  45. package/dist/standalone/{chunk-YQ7E3R3D.js → chunk-S2MXXVBU.js} +1 -1
  46. package/dist/standalone/{chunk-T7TBRE7I.js → chunk-SI7I47IC.js} +1 -1
  47. package/dist/standalone/{chunk-UKEPEJQE.js → chunk-SSPIY6CR.js} +1 -1
  48. package/dist/standalone/{chunk-IOZMKJXM.js → chunk-SXDNBAX2.js} +1 -1
  49. package/dist/standalone/{chunk-GC7R2JNV.js → chunk-T6GZ5GL5.js} +1 -1
  50. package/dist/standalone/{chunk-WSZOB3GK.js → chunk-T7QKUVSO.js} +1 -1
  51. package/dist/standalone/{chunk-AHIYIRQJ.js → chunk-TKKZSWPP.js} +1 -1
  52. package/dist/standalone/{chunk-YU2KFHL7.js → chunk-TVCRAKIF.js} +1 -1
  53. package/dist/standalone/{chunk-4QWQLDFZ.js → chunk-U7KL6DNA.js} +1 -1
  54. package/dist/standalone/{chunk-CGWLZBB7.js → chunk-USB6LW3F.js} +1 -1
  55. package/dist/standalone/{chunk-MTPPT5DN.js → chunk-UT4XQHNK.js} +1 -1
  56. package/dist/standalone/{chunk-B5757NYK.js → chunk-VEDBBYTH.js} +1 -1
  57. package/dist/standalone/{chunk-PGX7ADT3.js → chunk-WYI7FXBH.js} +1 -1
  58. package/dist/standalone/{chunk-OGFGCB3X.js → chunk-X32ZF36V.js} +1 -1
  59. package/dist/standalone/{chunk-Y5PCZUGU.js → chunk-XKMLLTFP.js} +1 -1
  60. package/dist/standalone/{chunk-OQQ3KQUW.js → chunk-YAP3UGFR.js} +1 -1
  61. package/dist/standalone/{chunk-FFHEYNCC.js → chunk-YKW7BL5H.js} +1 -1
  62. package/dist/standalone/studio.js +1 -1
  63. package/package.json +6 -6
  64. package/dist/standalone/chunk-PG7XHMUR.js +0 -9
@@ -1,4 +1,4 @@
1
- import{a}from"./chunk-YKXDMIHQ.js";var n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",r="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",_=/string or blob too big/iu,l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},RUN_KIND_FORBIDDEN:{status:500,title:"Function kind may not be composed from a query"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},SHARD_TIMEOUT:{status:504,title:"Shard timeout"},SHARD_HTTP_ERROR:{status:502,title:"Shard HTTP error"},SUBSCRIPTION_PERSIST_FAILED:{status:500,title:"Subscription persist failed"},TOO_MANY_SUBSCRIPTIONS:{status:429,title:"Too many subscriptions"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},IDENTITY_MISMATCH:{hint:["A write queued offline was replayed on a session that now belongs to someone else (a sign-out, or another user's sign-in, while it waited), so the worker refused it rather than commit it as them.","","`@lunora/client` re-resolves the session on this refusal and settles the write itself. If every replay is refused while the same user stays signed in, your worker's `resolveIdentity` returns a different `userId` than better-auth's `user.id`, or the RPC request carries no session cookie."],status:409,title:"Session changed since the write was queued"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},JURISDICTION_MOVE:{hint:["The schema declares `.jurisdiction(...)` and the project has DO-backed auth (`.auth({ namespace })`). Pinning the auth object to the jurisdiction resolves it to a new, empty one: every user, account and session stays in the unpinned object until copied across. Voice sessions are pinned without an acknowledgement: they store nothing, and their transcripts are rows in the already-pinned shards.","",'Acknowledge with `.jurisdiction("eu", { pinAuth: true })` and deploy, then copy the auth tables across with the `__lunora_admin__:copyAuthToJurisdiction` admin op and, once the counts check out, purge the unpinned copy with `__lunora_admin__:purgeUnpinnedAuth` (see [Pinning auth and voice](/docs/concepts/data-residency#pinning-auth-and-voice)). For D1-mode auth the acknowledgement changes nothing.'],status:422,title:"Unacknowledged jurisdiction move"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` in the `EmailGateConfig` you hand `assertEmailAllowed` / `classifyEmail` / `emailGateMiddleware` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},CONFIG_INVALID:{internal:!0,status:500,title:"Payment configuration invalid"},CURRENCY_MISMATCH:{status:400,title:"Currency mismatch"},PROVIDER_ERROR:{status:502,title:"Payment provider error"},WEBHOOK_EVENT_ID_MISSING:{status:400,title:"Webhook event id missing"},WEBHOOK_SIGNATURE_INVALID:{status:400,title:"Webhook signature invalid"},WEBHOOK_TIMESTAMP_INVALID:{status:400,title:"Webhook timestamp outside tolerance"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_MIGRATOR_UNSUPPORTED:{hint:["better-auth migrates only through its Kysely adapter, so `ensureMigrated` / `compileMigrationsSql` need the raw D1 binding as `database` \u2014 a custom adapter (`lunoraD1Adapter`, `lunoraAuthAdapter`, `lunoraDoAdapter`) cannot be migrated through, and neither can an absent `database`.","","Build a SECOND, migration-only instance over the raw binding \u2014 `createAuth({ ...options, database: env.DB })` \u2014 and hand that one to `ensureMigrated`. Keep the adapter on the instance that serves requests: the adapter exists to dodge a dev-runner hang in `$context`, which the migration instance never resolves.","","To compile the SQL off-platform (`compileMigrationsSql`), diff against an empty local database \u2014 `new DatabaseSync(':memory:')` from `node:sqlite` \u2014 rather than passing no `database` at all."],status:500,title:"Auth migrator cannot drive the configured database"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},BACKUP_RETENTION_NOT_CONFIGURED:{hint:["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.","","Nothing was deleted. A default is deliberately not invented here \u2014 retention deleting on its own is exactly what this command exists to replace."],status:400,title:"Backup retention window not configured"},BACKUP_TOO_LARGE:{hint:["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.","","The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.","","Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help \u2014 every run is a full snapshot."],status:507,title:"Backup too large to assemble in a Worker"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},EXPORT_SHARD_FAILED:{hint:["One or more shards failed to export, so the snapshot would have been short. Nothing is written when this fires \u2014 a partial export must never be mistaken for a complete one.","","The message names each failed shard key and its error. Re-run the export once those shards are reachable; a shard that fails repeatedly is usually over the per-request memory budget, which `backupTables` narrows."],status:502,title:"Export failed on one or more shards"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},ID_COLLISION:{hint:["The imported row carries an `_id` that is already held by a DIFFERENT table in this shard. Ids are per-table, so inserting it would leave two tables claiming one id and make a later lookup resolve to whichever one it reached first.","","This is reported per row rather than aborting the import: the remaining rows still apply. Re-mint the id on the source side, or import that table into a shard that does not already hold it."],status:409,title:"Document id already belongs to another table"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_CHECKSUM_MISMATCH:{hint:["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written \u2014 this check fails closed.","","Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."],status:400,title:"Storage checksum mismatch"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_DOWNLOAD_NOT_CONFIGURED:{hint:["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` \u2014 forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.","","Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."],status:400,title:"Storage download not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_OBJECT_NOT_FOUND:{status:404,title:"Storage object not found"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},RAG_DIMENSION_MISMATCH:{hint:["A stored vector and the query embedding have different widths, so they cannot be compared.","","This is what changing a RAG index's `embeddingModel` (or a provider's `dimensions` option) without reindexing looks like. Either put the previous model back, or reindex the namespace under the new one \u2014 bump `embeddingModelVersion` so the index rebuilds instead of mixing widths."],status:409,title:"Embedding dimension mismatch"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},AUTH_MOVE_NOT_CONFIGURED:{hint:"The copy needs DO-backed auth (`.auth({ namespace })`) pinned with `.jurisdiction(\u2026, { pinAuth: true })`, and the auth object's `internalSecret` set.",status:400,title:"Auth jurisdiction move not configured"},AUTH_MOVE_TARGET_NOT_EMPTY:{hint:"The pinned auth object holds users the copy did not write (someone signed up there), so copying into it would merge two user bases. Pass `force: true` to copy anyway: a copied row that collides with one of the pinned object's rows is left out and counted under `conflicts`.",status:409,title:"Pinned auth object is not empty"},AUTH_MOVE_CONFLICT:{hint:"A copied row has the same key or unique value (such as an email) as a row the pinned auth object holds on its own, or the pinned object changed a row the source changed too. Nothing from that page was written. Pass `force: true` to keep the pinned object's rows and count the collisions under `conflicts`.",status:409,title:"Auth copy conflict"},AUTH_MOVE_SOURCE_CHANGED:{hint:"The un-pinned auth object changed after the copy read it (an update, a delete, or a new row), for example during a gradual rollout or a rollback. Run the copy again: it reconciles the changed tables. Then purge.",status:409,title:"Un-pinned auth object changed since the copy"},AUTH_MOVE_SOURCE_PURGED:{hint:"The un-pinned auth object was already purged. Its tables may exist again (a rollback served requests there), but they hold only rows written since, so the copy refuses rather than read them as deletions and remove the pinned object's users. Nothing is left to copy.",status:409,title:"Un-pinned auth object already purged"},AUTH_MOVE_INCOMPLETE:{hint:"Run `__lunora_admin__:copyAuthToJurisdiction` until it answers `done: true`, check the per-table counts, then purge.",status:409,title:"Auth copy not finished"},AUTH_MOVE_FAILED:{hint:"The message names the step, the table and the class of the SQLite error; the auth object's log has the full error. The copy resumes where it stopped once the cause is fixed.",status:500,title:"Auth jurisdiction move failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_BINDING:{status:500,title:"Duplicate agent binding"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},DISPATCH_UNAUTHENTICATED:{hint:"The scheduler could not authenticate to the worker. Check that `LUNORA_SCHEDULER_SECRET` matches on both sides, or that `LUNORA_ADMIN_TOKEN` is set and current.",status:403,title:"Dispatch caller not authenticated"},DISPATCH_IN_PROGRESS:{hint:"A dispatch with this idempotency id is still running on the shard. Retry it; once the first attempt settles the same id is served from the replay cache.",status:409,title:"Dispatch already in progress"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},GLOBAL_SEARCH_SCORES_UNSUPPORTED:{status:400,title:"collectWithScores() is unsupported on a global table"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},INVALID_SCHEDULE_ID:{status:400,title:"Invalid schedule id"},RATE_LIMITED:{status:429,title:"Rate limited"},REPLICA_NOT_READY:{status:421,title:"Replica not caught up"},REPLICA_READ_ONLY:{status:421,title:"Replica is read-only"},SEARCH_INDEX_BUILDING:{status:503,title:"Search index is still building"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_MEMORY_TABLE:{status:400,title:"Shape over a memory table is unsupported"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},WIRE_DECODE_FAILED:{status:502,title:"Could not decode a server frame"},WIRE_ENCODE_FAILED:{status:500,title:"Could not encode a return value"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},CDC_LOG_TRIMMED:{status:409,title:"CDC log trimmed"},CDC_TIMELINE_FORKED:{status:409,title:"CDC timeline forked"},CDC_PAYLOAD_COMPACTED:{status:409,title:"CDC payloads compacted"},EXPIRED:{status:404,title:"Session expired"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SHAPE_REQUIRES_CDC:{status:409,title:"Shape requires change-data-capture"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},STREAM_ID_IN_USE:{status:409,title:"Stream id already in use"},STREAM_INTERRUPTED:{status:503,title:"Durable stream interrupted"},STREAM_TOO_LONG:{status:507,title:"Durable stream exceeded its chunk ceiling"},TOKEN_EXPIRED:{status:401,title:"Authentication token expired"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},TOO_MANY_WHISPER_TOPICS:{hint:"Reuse a stable set of whisper topic names, or reconnect \u2014 the per-socket verdict memo is in-memory, so a new connection starts empty. Leaving a topic does not free its entry.",status:429,title:"Too many whisper topics"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},RELAY_SHAPE_UNROUTABLE:{status:500,title:"Relay shape unroutable"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"},LOCAL_DEPENDENCY_MISSING:{hint:["The command Lunora tried to run is not on your PATH, so nothing ran.","","Install it (or put it on PATH) and retry \u2014 `wrangler` ships as a dependency of a Lunora app, so `pnpm install` usually fixes that one; `git` and `docker` are installed separately."],status:500,title:"Required local tool not found"}},c=a(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["A single row exceeded the storage engine's per-row ceiling \u2014 2 MB on a Durable Object's SQLite, and 2,000,000 bytes on D1.","","The limit is on the STORED bytes, which are UTF-8: a document of multi-byte text (CJK, emoji) costs up to 3x its character count. `v.bytes()` and `v.bigint()` columns cost more again on a shard-local table, where the row stores both a SQL-comparable projection and the original.","","Keep the large payload out of the row and store a reference to it:","","```ts","const key = `uploads/${crypto.randomUUID()}`;","await ctx.storage.uploads.put(key, bytes);",'await ctx.db.insert("documents", { storageKey: key, title });',"```","","R2 has no practical object-size ceiling, and the row stays small enough to read, index, and replicate."].join(`
1
+ import{a}from"./chunk-YKXDMIHQ.js";var n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",r="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",_=/string or blob too big/iu,l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},RUN_KIND_FORBIDDEN:{status:500,title:"Function kind may not be composed from a query"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},SHARD_TIMEOUT:{status:504,title:"Shard timeout"},SHARD_HTTP_ERROR:{status:502,title:"Shard HTTP error"},SUBSCRIPTION_PERSIST_FAILED:{status:500,title:"Subscription persist failed"},TOO_MANY_SUBSCRIPTIONS:{status:429,title:"Too many subscriptions"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},IDENTITY_MISMATCH:{hint:["A write queued offline was replayed on a session that now belongs to someone else (a sign-out, or another user's sign-in, while it waited), so the worker refused it rather than commit it as them.","","`@lunora/client` re-resolves the session on this refusal and settles the write itself. If every replay is refused while the same user stays signed in, your worker's `resolveIdentity` returns a different `userId` than better-auth's `user.id`, or the RPC request carries no session cookie."],status:409,title:"Session changed since the write was queued"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},JURISDICTION_MOVE:{hint:["The schema declares `.jurisdiction(...)` and the project has DO-backed auth (`.auth({ namespace })`). Pinning the auth object to the jurisdiction resolves it to a new, empty one: every user, account and session stays in the unpinned object until copied across. Voice sessions are pinned without an acknowledgement: they store nothing, and their transcripts are rows in the already-pinned shards.","",'Acknowledge with `.jurisdiction("eu", { pinAuth: true })` and deploy, then copy the auth tables across with the `__lunora_admin__:copyAuthToJurisdiction` admin op and, once the counts check out, purge the unpinned copy with `__lunora_admin__:purgeUnpinnedAuth` (see [Pinning auth and voice](/docs/concepts/data-residency#pinning-auth-and-voice)). For D1-mode auth the acknowledgement changes nothing.'],status:422,title:"Unacknowledged jurisdiction move"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` in the `EmailGateConfig` you hand `assertEmailAllowed` / `classifyEmail` / `emailGateMiddleware` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},CONFIG_INVALID:{internal:!0,status:500,title:"Payment configuration invalid"},CURRENCY_MISMATCH:{status:400,title:"Currency mismatch"},PROVIDER_ERROR:{status:502,title:"Payment provider error"},WEBHOOK_EVENT_ID_MISSING:{status:400,title:"Webhook event id missing"},WEBHOOK_SIGNATURE_INVALID:{status:400,title:"Webhook signature invalid"},WEBHOOK_TIMESTAMP_INVALID:{status:400,title:"Webhook timestamp outside tolerance"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_MIGRATOR_UNSUPPORTED:{hint:["better-auth migrates only through its Kysely adapter, so `ensureMigrated` / `compileMigrationsSql` need the raw D1 binding as `database` \u2014 a custom adapter (`lunoraD1Adapter`, `lunoraAuthAdapter`, `lunoraDoAdapter`) cannot be migrated through, and neither can an absent `database`.","","Build a SECOND, migration-only instance over the raw binding \u2014 `createAuth({ ...options, database: env.DB })` \u2014 and hand that one to `ensureMigrated`. Keep the adapter on the instance that serves requests: the adapter exists to dodge a dev-runner hang in `$context`, which the migration instance never resolves.","","To compile the SQL off-platform (`compileMigrationsSql`), diff against an empty local database \u2014 `new DatabaseSync(':memory:')` from `node:sqlite` \u2014 rather than passing no `database` at all."],status:500,title:"Auth migrator cannot drive the configured database"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},BACKUP_RETENTION_NOT_CONFIGURED:{hint:["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.","","Nothing was deleted. A default is deliberately not invented here \u2014 retention deleting on its own is exactly what this command exists to replace."],status:400,title:"Backup retention window not configured"},BACKUP_TOO_LARGE:{hint:["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.","","The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.","","Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help \u2014 every run is a full snapshot."],status:507,title:"Backup too large to assemble in a Worker"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},EXPORT_SHARD_FAILED:{hint:["One or more shards failed to export, so the snapshot would have been short. Nothing is written when this fires \u2014 a partial export must never be mistaken for a complete one.","","The message names each failed shard key and its error. Re-run the export once those shards are reachable; a shard that fails repeatedly is usually over the per-request memory budget, which `backupTables` narrows."],status:502,title:"Export failed on one or more shards"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},ID_COLLISION:{hint:["The imported row carries an `_id` that is already held by a DIFFERENT table in this shard. Ids are per-table, so inserting it would leave two tables claiming one id and make a later lookup resolve to whichever one it reached first.","","This is reported per row rather than aborting the import: the remaining rows still apply. Re-mint the id on the source side, or import that table into a shard that does not already hold it."],status:409,title:"Document id already belongs to another table"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_CHECKSUM_MISMATCH:{hint:["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written \u2014 this check fails closed.","","Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."],status:400,title:"Storage checksum mismatch"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_DOWNLOAD_NOT_CONFIGURED:{hint:["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` \u2014 forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.","","Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."],status:400,title:"Storage download not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_OBJECT_NOT_FOUND:{status:404,title:"Storage object not found"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},RAG_DIMENSION_MISMATCH:{hint:["A stored vector and the query embedding have different widths, so they cannot be compared.","","This is what changing a RAG index's `embeddingModel` (or a provider's `dimensions` option) without reindexing looks like. Either put the previous model back, or reindex the namespace under the new one \u2014 bump `embeddingModelVersion` so the index rebuilds instead of mixing widths."],status:409,title:"Embedding dimension mismatch"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},AUTH_MOVE_NOT_CONFIGURED:{hint:"The copy needs DO-backed auth (`.auth({ namespace })`) pinned with `.jurisdiction(\u2026, { pinAuth: true })`, and the auth object's `internalSecret` set.",status:400,title:"Auth jurisdiction move not configured"},AUTH_MOVE_TARGET_NOT_EMPTY:{hint:"The pinned auth object holds users the copy did not write (someone signed up there), so copying into it would merge two user bases. Pass `force: true` to copy anyway: a copied row that collides with one of the pinned object's rows is left out and counted under `conflicts`.",status:409,title:"Pinned auth object is not empty"},AUTH_MOVE_CONFLICT:{hint:"A copied row has the same key or unique value (such as an email) as a row the pinned auth object holds on its own, or the pinned object changed a row the source changed too. Nothing from that page was written. Pass `force: true` to keep the pinned object's rows and count the collisions under `conflicts`.",status:409,title:"Auth copy conflict"},AUTH_MOVE_SOURCE_CHANGED:{hint:"The un-pinned auth object changed after the copy read it (an update, a delete, or a new row), for example during a gradual rollout or a rollback. Run the copy again: it reconciles the changed tables. Then purge.",status:409,title:"Un-pinned auth object changed since the copy"},AUTH_MOVE_SOURCE_PURGED:{hint:"The un-pinned auth object was already purged. Its tables may exist again (a rollback served requests there), but they hold only rows written since, so the copy refuses rather than read them as deletions and remove the pinned object's users. Nothing is left to copy.",status:409,title:"Un-pinned auth object already purged"},AUTH_MOVE_INCOMPLETE:{hint:"Run `__lunora_admin__:copyAuthToJurisdiction` until it answers `done: true`, check the per-table counts, then purge.",status:409,title:"Auth copy not finished"},AUTH_MOVE_FAILED:{hint:"The message names the step, the table and the class of the SQLite error; the auth object's log has the full error. The copy resumes where it stopped once the cause is fixed.",status:500,title:"Auth jurisdiction move failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_BINDING:{status:500,title:"Duplicate agent binding"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},DISPATCH_UNAUTHENTICATED:{hint:"The scheduler could not authenticate to the worker. Check that `LUNORA_SCHEDULER_SECRET` matches on both sides, or that `LUNORA_ADMIN_TOKEN` is set and current.",status:403,title:"Dispatch caller not authenticated"},DISPATCH_IN_PROGRESS:{hint:"A dispatch with this idempotency id is still running on the shard. Retry it; once the first attempt settles the same id is served from the replay cache.",status:409,title:"Dispatch already in progress"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},GLOBAL_SEARCH_SCORES_UNSUPPORTED:{status:400,title:"collectWithScores() is unsupported on a global table"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},INVALID_SCHEDULE_ID:{status:400,title:"Invalid schedule id"},RATE_LIMITED:{status:429,title:"Rate limited"},REPLICA_NOT_READY:{status:421,title:"Replica not caught up"},REPLICA_READ_ONLY:{status:421,title:"Replica is read-only"},SEARCH_INDEX_BUILDING:{status:503,title:"Search index is still building"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_MEMORY_TABLE:{status:400,title:"Shape over a memory table is unsupported"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},WIRE_DECODE_FAILED:{status:502,title:"Could not decode a server frame"},WIRE_ENCODE_FAILED:{status:500,title:"Could not encode a return value"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},CDC_LOG_TRIMMED:{status:409,title:"CDC log trimmed"},CDC_TIMELINE_FORKED:{status:409,title:"CDC timeline forked"},CDC_PAYLOAD_COMPACTED:{status:409,title:"CDC payloads compacted"},EXPIRED:{status:404,title:"Session expired"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SHAPE_REQUIRES_CDC:{status:409,title:"Shape requires change-data-capture"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},STREAM_ID_IN_USE:{status:409,title:"Stream id already in use"},STREAM_INTERRUPTED:{status:503,title:"Durable stream interrupted"},STREAM_TOO_LONG:{status:507,title:"Durable stream exceeded its chunk ceiling"},TOKEN_EXPIRED:{hint:["The caller's credential verified but its expiry has passed. The worker refuses an HTTP call with this code before it runs; a shard drops a socket with close code `4001` and the same code.","","It is a refusal of the credential, not of the call: `@lunora/client` holds a queued write, fires `onTokenExpired`, and re-sends it after `setAuthToken`. The worker can only tell expired from anonymous if your `resolveIdentity` returns the identity with its past `exp` (or `expiresAtMs`), or throws a `LunoraError` with this code. Returning `null` runs the call anonymous."],status:401,title:"Authentication token expired"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},TOO_MANY_WHISPER_TOPICS:{hint:"Reuse a stable set of whisper topic names, or reconnect \u2014 the per-socket verdict memo is in-memory, so a new connection starts empty. Leaving a topic does not free its entry.",status:429,title:"Too many whisper topics"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},RELAY_SHAPE_UNROUTABLE:{status:500,title:"Relay shape unroutable"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"},LOCAL_DEPENDENCY_MISSING:{hint:["The command Lunora tried to run is not on your PATH, so nothing ran.","","Install it (or put it on PATH) and retry \u2014 `wrangler` ships as a dependency of a Lunora app, so `pnpm install` usually fixes that one; `git` and `docker` are installed separately."],status:500,title:"Required local tool not found"}},c=a(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["A single row exceeded the storage engine's per-row ceiling \u2014 2 MB on a Durable Object's SQLite, and 2,000,000 bytes on D1.","","The limit is on the STORED bytes, which are UTF-8: a document of multi-byte text (CJK, emoji) costs up to 3x its character count. `v.bytes()` and `v.bigint()` columns cost more again on a shard-local table, where the row stores both a SQL-comparable projection and the original.","","Keep the large payload out of the row and store a reference to it:","","```ts","const key = `uploads/${crypto.randomUUID()}`;","await ctx.storage.uploads.put(key, bytes);",'await ctx.db.insert("documents", { storageKey: key, title });',"```","","R2 has no practical object-size ceiling, and the row stays small enough to read, index, and replicate."].join(`
2
2
  `),header:"Row too large for the storage engine",id:"lunora-row-too-big",test:a(e=>_.test(e),"test")},{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
3
3
  `),header:"No Lunora schema found",id:"lunora-schema-missing",test:a(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
4
4
  `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:a(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a `ctx.db` member (the error names the one it hit) \u2014 e.g. `userAccounts` instead of `insert`, or `pageViews` instead of `count`."].join(`
@@ -1,4 +1,4 @@
1
- import{a as fn,b as $e,e as Br,f as Gr}from"./chunk-AANB526D.js";import{a as Hr,b as bt,c as jr,d as pn}from"./chunk-EN3YBGYA.js";import{a as mn}from"./chunk-MXLAOCAN.js";import{b as dn}from"./chunk-CMA4PTV7.js";import{d as qr}from"./chunk-UYEZR3BI.js";import{a as un}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as mo,b as go,c as gn,d as Lr}from"./chunk-YOB2X3FZ.js";import{a as cn}from"./chunk-3FBLWUXD.js";import{a as Bt}from"./chunk-XZMOZFE6.js";import{a as co}from"./chunk-IMOHEGMV.js";import{a as an}from"./chunk-UXXDN6Z3.js";import{a as $r}from"./chunk-66UGPQVC.js";import{b as Mr,c as lo}from"./chunk-6DAD3RFX.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as uo}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as io}from"./chunk-NFS7FTAR.js";import{a as Tr}from"./chunk-EJSI4PMU.js";import{a as Nr,b as Dr}from"./chunk-OGUKYRFM.js";import{c as vr,d as yr,e as Rr}from"./chunk-6D6Z2KXU.js";import{b as kr,c as Pr,f as so}from"./chunk-OKG3HWSJ.js";import{W as Ir}from"./chunk-PLHA3OWK.js";import{b as vi}from"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as rn}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as _e}from"./chunk-4ZEL6BYL.js";import{b as ro,c as dt}from"./chunk-FZ5ZSUA2.js";import{f as rt}from"./chunk-PG7XHMUR.js";import"./chunk-FSRSK4LY.js";import"./chunk-5ICUJ4IA.js";import{a as ln}from"./chunk-FKVZRPV5.js";import{a as Ar,b as Or,c as Er,d as ao,e as Vr,f as zr}from"./chunk-HEAQVSNS.js";import{d as oe,f as Ve,g as ze,h as jt,m as oo,n as sn,o as Oe,p as re,t as Fr}from"./chunk-PTZD7RUZ.js";import{a as o,d as Re,e as ut,f as Ht,g as Lt,i as pt}from"./chunk-YKXDMIHQ.js";var Ua=Re(Ht(),1);var Ot=Re(ut(),1);var ht=Re(Ht(),1);var Y=Re(Lt(),1),Le=Re(ut(),1);function We(t){let e=(0,ht.c)(2),n=(0,Le.useRef)(t),l;return e[0]!==t?(l=o(()=>{n.current=t},"r"),e[0]=t,e[1]=l):l=e[1],(0,Le.useEffect)(l),n}o(We,"te");var yi=2166136261,Ri=16777619,Ii=o((t,e=yi)=>{let n=e;for(let l=0;l<t.length;l+=1)n^=t.charCodeAt(l),n=Math.imul(n,Ri);return(n>>>0).toString(16).padStart(8,"0")},"V"),Fi=/([a-z\d])([A-Z])/gu,Mi=/[\s_-]+/u,ki=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),Pi=o(t=>{let e=t.replaceAll(Fi,"$1 $2").split(Mi).map(l=>l.toLowerCase()).filter(l=>l.length>0),n=new Set(e);for(let l=0;l<e.length-1;l+=1){let r=e[l],s=e[l+1];r===void 0||s===void 0||(n.add(`${r}${s}`),n.add(`${r}_${s}`))}return[...n]},"ae"),Kr="\u2022\u2022\u2022",Yr=o((t,e)=>{try{return e==="redact"?null:e==="hash"?t==null?t:Ii(typeof t=="bigint"?t.toString():typeof t=="string"?t:JSON.stringify(t)):Kr}catch{return Kr}},"W"),Ur=o((t,e)=>{let n=new Map;for(let l of t)l.table===e&&n.set(l.column,l.strategy);return n},"z"),Ni=o(t=>{for(let e of Pi(t))if(ki.has(e))return!0;return!1},"ce"),Jr=o((t,e)=>{let n=e.filter(r=>!t.has(r)&&Ni(r));if(n.length===0)return t;let l=new Map(t);for(let r of n)l.set(r,"redact");return l},"B"),Gt=o((t,e,n)=>{if(!n.enabled)return t;let l=n.columns.get(e);return l===void 0?t:Yr(t,l)},"Ce"),bn=o((t,e)=>{if(!e.enabled||e.columns.size===0)return t;let n={...t};for(let[l,r]of e.columns)l in n&&(n[l]=Yr(n[l],r));return n},"ie"),hn=o((t,e)=>!e.enabled||e.columns.size===0?t:t.map(n=>bn(n,e)),"Fe"),Wr=o(t=>t==null?"\u2205":t===""?"(empty)":Oe(t),"P"),Di=o(t=>{let e=(0,ht.c)(32),{column:n,onFacetFilter:l,state:r}=t,s=oe(),a;e[0]!==n||e[1]!==l||e[2]!==r.result?.values?(a=o(w=>{let _=Number(w.currentTarget.dataset.index),S=r.result?.values[_];S!==void 0&&l(n,S.value)},"x"),e[0]=n,e[1]=l,e[2]=r.result?.values,e[3]=a):a=e[3];let c=a,u=`db-facet-${n}`,i;e[4]!==n?(i=(0,Y.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=i):i=e[5];let d;e[6]!==r.loading||e[7]!==r.result||e[8]!==s?(d=r.loading&&r.result===null&&(0,Y.jsx)("span",{className:"text-muted-foreground",children:s("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=s,e[9]=d):d=e[9];let m;e[10]!==r.error?(m=r.error!==null&&(0,Y.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=m):m=e[11];let g;e[12]!==r.result?.values?(g=r.result?.values??[],e[12]=r.result?.values,e[13]=g):g=e[13];let b;if(e[14]!==n||e[15]!==c||e[16]!==g){let w;e[18]!==n||e[19]!==c?(w=o((_,S)=>(0,Y.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":S,"data-testid":`db-facet-value-${n}`,onClick:c,type:"button",children:[(0,Y.jsx)("span",{className:"truncate",children:Wr(_.value)}),(0,Y.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:_.count})]},Wr(_.value)),"c"),e[18]=n,e[19]=c,e[20]=w):w=e[20],b=g.map(w),e[14]=n,e[15]=c,e[16]=g,e[17]=b}else b=e[17];let f;e[21]!==n||e[22]!==r.result||e[23]!==s?(f=r.result?.truncated===!0&&(0,Y.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:s("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=s,e[24]=f):f=e[24];let h;return e[25]!==u||e[26]!==i||e[27]!==d||e[28]!==m||e[29]!==b||e[30]!==f?(h=(0,Y.jsxs)("section",{className:"flex flex-col gap-1","data-testid":u,children:[i,d,m,b,f]}),e[25]=u,e[26]=i,e[27]=d,e[28]=m,e[29]=b,e[30]=f,e[31]=h):h=e[31],h},"ue"),wn=o(t=>{let e=(0,ht.c)(44),{columns:n,facets:l,mask:r,onFacetFilter:s,onToggleFacet:a}=t,c=oe(),u;e[0]!==a?(u=o(v=>{let{column:M}=v.currentTarget.dataset;M!==void 0&&a(M)},"o"),e[0]=a,e[1]=u):u=e[1];let i=u,d;e[2]!==r?(d=o(v=>r.enabled&&r.columns.has(v),"a"),e[2]=r,e[3]=d):d=e[3];let m=d,g,b,f,h,w,_,S,y;if(e[4]!==n||e[5]!==l||e[6]!==m||e[7]!==c||e[8]!==i){y=Symbol.for("react.early_return_sentinel");e:{let v;e[17]!==m?(v=o(N=>!m(N),"y"),e[17]=m,e[18]=v):v=e[18];let M=n.filter(v),F;if(e[19]!==l||e[20]!==m?(F=Object.entries(l).filter(N=>{let[T]=N;return!m(T)}),e[19]=l,e[20]=m,e[21]=F):F=e[21],g=F,M.length===0){y=null;break e}_="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",S="db-facets",h="flex flex-col gap-1.5";let P;e[22]!==c?(P=c("Facets"),e[22]=c,e[23]=P):P=e[23],e[24]!==P?(w=(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:P}),e[24]=P,e[25]=w):w=e[25],b="flex flex-wrap gap-1";let k;e[26]!==l||e[27]!==i?(k=o(N=>(0,Y.jsx)("button",{"aria-pressed":N in l,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:i,type:"button",children:N},N),"A"),e[26]=l,e[27]=i,e[28]=k):k=e[28],f=M.map(k)}e[4]=n,e[5]=l,e[6]=m,e[7]=c,e[8]=i,e[9]=g,e[10]=b,e[11]=f,e[12]=h,e[13]=w,e[14]=_,e[15]=S,e[16]=y}else g=e[9],b=e[10],f=e[11],h=e[12],w=e[13],_=e[14],S=e[15],y=e[16];if(y!==Symbol.for("react.early_return_sentinel"))return y;let I;e[29]!==b||e[30]!==f?(I=(0,Y.jsx)("div",{className:b,children:f}),e[29]=b,e[30]=f,e[31]=I):I=e[31];let C;e[32]!==I||e[33]!==h||e[34]!==w?(C=(0,Y.jsxs)("div",{className:h,children:[w,I]}),e[32]=I,e[33]=h,e[34]=w,e[35]=C):C=e[35];let R;e[36]!==s||e[37]!==g?(R=g.map(v=>{let[M,F]=v;return(0,Y.jsx)(Di,{column:M,onFacetFilter:s,state:F},M)}),e[36]=s,e[37]=g,e[38]=R):R=e[38];let x;return e[39]!==C||e[40]!==R||e[41]!==_||e[42]!==S?(x=(0,Y.jsxs)("aside",{className:_,"data-testid":S,children:[C,R]}),e[39]=C,e[40]=R,e[41]=_,e[42]=S,e[43]=x):x=e[43],x},"_e"),xn=o(()=>{let[t,e]=(0,Le.useState)({}),n=We(t),l=(0,Le.useRef)({}),r=o(async(s,a)=>{let c=(l.current[s]??0)+1;l.current[s]=c,e(u=>s in u?{...u,[s]:{error:null,loading:!0,result:u[s]?.result??null}}:u);try{let u=await a(s);if(l.current[s]!==c)return;e(i=>s in i?{...i,[s]:{error:null,loading:!1,result:u}}:i)}catch(u){if(l.current[s]!==c)return;e(i=>s in i?{...i,[s]:{error:jt(u),loading:!1,result:null}}:i)}},"n");return{clearFacets:o(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:o(s=>{for(let a of Object.keys(n.current))re(r(a,s))},"refetchFacets"),toggleFacet:o((s,a)=>{if(s in n.current){e(c=>Object.fromEntries(Object.entries(c).filter(([u])=>u!==s)));return}e(c=>({...c,[s]:{error:null,loading:!0,result:null}})),a!==null&&re(r(s,a))},"toggleFacet")}},"Me"),Ti=[],Ai=o(()=>{let t=(0,ht.c)(1),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let{data:n}=dt(_e.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:Ti},"fe"),Sn=o(t=>{let e=(0,ht.c)(16),{columns:n,selectedTable:l}=t,r=Ai(),[s,a]=(0,Le.useState)(!0),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=o(()=>{a(Oi)},"g"),e[0]=c):c=e[0];let u=c,i;if(e[1]!==n||e[2]!==r||e[3]!==l){let h=Ur(r,l??"");i=Jr(h,n),e[1]=n,e[2]=r,e[3]=l,e[4]=i}else i=e[4];let d=i,m;e[5]!==s||e[6]!==r?(m=o((h,w)=>({columns:Jr(Ur(r,h),w),enabled:s}),"l"),e[5]=s,e[6]=r,e[7]=m):m=e[7];let g=m,b;e[8]!==d||e[9]!==s?(b={columns:d,enabled:s},e[8]=d,e[9]=s,e[10]=b):b=e[10];let f;return e[11]!==d||e[12]!==s||e[13]!==g||e[14]!==b?(f={maskColumns:d,maskOn:s,maskView:b,maskViewFor:g,onToggleMask:u},e[11]=d,e[12]=s,e[13]=g,e[14]=b,e[15]=f):f=e[15],f},"$e");function Oi(t){return!t}o(Oi,"me");var Qr=34,Xr=600,Ei=o(t=>{let e=(0,ht.c)(21),{item:n,onSelect:l,prefix:r,selected:s,start:a}=t,c;e[0]!==n.name||e[1]!==l?(c=o(()=>{l(n.name)},"g"),e[0]=n.name,e[1]=l,e[2]=c):c=e[2];let u=c,i=`translateY(${String(a)}px)`,d;e[3]!==i?(d={insetInline:0,position:"absolute",top:0,transform:i},e[3]=i,e[4]=d):d=e[4];let m=d,g=s?"bg-accent font-medium text-accent-foreground":"text-foreground",b;e[5]!==g?(b=pt("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",g),e[5]=g,e[6]=b):b=e[6];let f=`${r}-table-${n.name}`,h;e[7]!==n.name?(h=(0,Y.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=h):h=e[8];let w;e[9]!==n.rowCount?(w=(0,Y.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let _;e[11]!==u||e[12]!==s||e[13]!==b||e[14]!==f||e[15]!==h||e[16]!==w?(_=(0,Y.jsxs)("button",{"aria-pressed":s,className:b,"data-testid":f,onClick:u,type:"button",children:[h,w]}),e[11]=u,e[12]=s,e[13]=b,e[14]=f,e[15]=h,e[16]=w,e[17]=_):_=e[17];let S;return e[18]!==m||e[19]!==_?(S=(0,Y.jsx)("li",{style:m,children:_}),e[18]=m,e[19]=_,e[20]=S):S=e[20],S},"ge"),_n=o(({header:t,onReload:e,onSelect:n,prefix:l,reloadLabel:r,selected:s,tables:a})=>{let c=oe(),[u,i]=(0,Le.useState)(""),d=(0,Le.useRef)(null),m=o(h=>{i(h.target.value)},"l"),g=(0,Le.useMemo)(()=>{let h=u.trim().toLowerCase();return h===""?a:a.filter(w=>w.name.toLowerCase().includes(h))},[u,a]),b=dn({count:g.length,estimateSize:o(()=>Qr,"estimateSize"),getScrollElement:o(()=>d.current,"getScrollElement"),initialRect:{height:Xr,width:240},observeElementRect:o((h,w)=>mn(h,w,Xr),"observeElementRect"),overscan:12}).getVirtualItems(),f={height:g.length*Qr};return(0,Y.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${l}-table-list`,children:[t,(0,Y.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Tables")}),e!==void 0&&(0,Y.jsx)("button",{"aria-label":r??c("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${l}-load-tables`,onClick:e,title:r??c("Refresh"),type:"button",children:(0,Y.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,Y.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,Y.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,Y.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${l}-table-search`,onChange:m,placeholder:c("search table\u2026"),type:"search",value:u})}),(0,Y.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${l}-table-list-rows`,ref:d,children:[(0,Y.jsx)("li",{"aria-hidden":"true",style:f}),b.map(h=>{let w=g[h.index];return w===void 0?null:(0,Y.jsx)(Ei,{item:w,onSelect:n,prefix:l,selected:s===w.name,start:h.start},w.name)})]})]})},"Te");var q=Re(Ht(),1);var D=Re(ut(),1);var p=Re(Lt(),1);var Zr=Re(ut(),1);function Vi(t){return zi(t)||typeof t=="function"||$i(t)}o(Vi,"isReactComponent");function zi(t){return typeof t=="function"&&(()=>{let e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}o(zi,"isClassComponent");function $i(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}o($i,"isExoticComponent");function wt(t,e){return t==null?null:Vi(t)?Zr.default.createElement(t,e):t}o(wt,"flexRender");function fo(t){if("cell"in t&&t.cell){let e=t.cell,n=e.column.columnDef,l=e,r=n;return l.getIsAggregated?.()?wt(r.aggregatedCell??n.cell,e.getContext()):l.getIsPlaceholder?.()?null:wt(n.cell,e.getContext())}return"header"in t&&t.header?wt(t.header.column.columnDef.header,t.header.getContext()):"footer"in t&&t.footer?wt(t.footer.column.columnDef.footer,t.footer.getContext()):null}o(fo,"FlexRender");function el({update:t,notify:e,unwatched:n}){return{link:l,unlink:r,propagate:s,checkDirty:a,shallowPropagate:c};function l(i,d,m){let g=d.depsTail;if(g!==void 0&&g.dep===i)return;let b=g!==void 0?g.nextDep:d.deps;if(b!==void 0&&b.dep===i){b.version=m,d.depsTail=b;return}let f=i.subsTail;if(f!==void 0&&f.version===m&&f.sub===d)return;let h=d.depsTail=i.subsTail={version:m,dep:i,sub:d,prevDep:g,nextDep:b,prevSub:f,nextSub:void 0};b!==void 0&&(b.prevDep=h),g!==void 0?g.nextDep=h:d.deps=h,f!==void 0?f.nextSub=h:i.subs=h}function r(i,d=i.sub){let m=i.dep,g=i.prevDep,b=i.nextDep,f=i.nextSub,h=i.prevSub;return b!==void 0?b.prevDep=g:d.depsTail=g,g!==void 0?g.nextDep=b:d.deps=b,f!==void 0?f.prevSub=h:m.subsTail=h,h!==void 0?h.nextSub=f:(m.subs=f)===void 0&&n(m),b}function s(i){let d=i.nextSub,m;e:do{let g=i.sub,b=g.flags;if(b&60?b&12?b&4?!(b&48)&&u(i,g)?(g.flags=b|40,b&=1):b=0:g.flags=b&-9|32:b=0:g.flags=b|32,b&2&&e(g),b&1){let f=g.subs;if(f!==void 0){let h=(i=f).nextSub;h!==void 0&&(m={value:d,prev:m},d=h);continue}}if((i=d)!==void 0){d=i.nextSub;continue}for(;m!==void 0;)if(i=m.value,m=m.prev,i!==void 0){d=i.nextSub;continue e}break}while(!0)}function a(i,d){let m,g=0,b=!1;e:do{let f=i.dep,h=f.flags;if(d.flags&16)b=!0;else if((h&17)===17){if(t(f)){let w=f.subs;w.nextSub!==void 0&&c(w),b=!0}}else if((h&33)===33){(i.nextSub!==void 0||i.prevSub!==void 0)&&(m={value:i,prev:m}),i=f.deps,d=f,++g;continue}if(!b){let w=i.nextDep;if(w!==void 0){i=w;continue}}for(;g--;){let w=d.subs,_=w.nextSub!==void 0;if(_?(i=m.value,m=m.prev):i=w,b){if(t(d)){_&&c(w),d=i.sub;continue}b=!1}else d.flags&=-33;d=i.sub;let S=i.nextDep;if(S!==void 0){i=S;continue e}}return b}while(!0)}function c(i){do{let d=i.sub,m=d.flags;(m&48)===32&&(d.flags=m|16,(m&6)===2&&e(d))}while((i=i.nextSub)!==void 0)}function u(i,d){let m=d.depsTail;for(;m!==void 0;){if(m===i)return!0;m=m.prevDep}return!1}}o(el,"createReactiveSystem");function ol(t,e,n){let l=typeof t=="object",r=l?t:void 0;return{next:(l?t.next:t)?.bind(r),error:(l?t.error:e)?.bind(r),complete:(l?t.complete:n)?.bind(r)}}o(ol,"toObserver");var po=[],vn=0,{link:tl,unlink:Hi,propagate:Li,checkDirty:rl,shallowPropagate:nl}=el({update(t){return t._update()},notify(t){po[bo++]=t,t.flags&=-3},unwatched(t){t.depsTail!==void 0&&(t.depsTail=void 0,t.flags=17,yn(t))}}),Cn=0,bo=0,Qe,ho=0;function wo(t){try{++ho,t()}finally{--ho||xo()}}o(wo,"batch");function yn(t){let e=t.depsTail,n=e!==void 0?e.nextDep:t.deps;for(;n!==void 0;)n=Hi(n,t)}o(yn,"purgeDeps");function xo(){if(!(ho>0)){for(;Cn<bo;){let t=po[Cn];po[Cn++]=void 0,t.notify()}Cn=0,bo=0}}o(xo,"flush");function So(t,e){let n=typeof t=="function",l=t,r={_snapshot:n?void 0:t,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?0:1,get(){return Qe!==void 0&&tl(r,Qe,vn),r._snapshot},subscribe(s){let a=ol(s),c={current:!1},u=ji(()=>{r.get(),c.current?a.next?.(r._snapshot):c.current=!0});return{unsubscribe:o(()=>{u.stop()},"unsubscribe")}},_update(s){let a=Qe,c=e?.compare??Object.is;if(n)Qe=r,++vn,r.depsTail=void 0;else if(s===void 0)return!1;n&&(r.flags=5);try{let u=r._snapshot,i=typeof s=="function"?s(u):s===void 0&&n?l(u):s;return u===void 0||!c(u,i)?(r._snapshot=i,!0):!1}finally{Qe=a,n&&(r.flags&=-5),yn(r)}}};return n?(r.flags=17,r.get=function(){let s=r.flags;if(s&16||s&32&&rl(r.deps,r)){if(r._update()){let a=r.subs;a!==void 0&&nl(a)}}else s&32&&(r.flags=s&-33);return Qe!==void 0&&tl(r,Qe,vn),r._snapshot}):r.set=function(s){if(r._update(s)){let a=r.subs;a!==void 0&&(Li(a),nl(a),xo())}},r}o(So,"createAtom");function ji(t){let e=o(()=>{let l=Qe;Qe=n,++vn,n.depsTail=void 0,n.flags=6;try{return t()}finally{Qe=l,n.flags&=-5,yn(n)}},"run"),n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let l=this.flags;l&16||l&32&&rl(this.deps,this)?e():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,yn(this)}};return e(),n}o(ji,"effect");function lt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(let[l,r]of t)if(!e.has(l)||!Object.is(r,e.get(l)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(let l of t)if(!e.has(l))return!1;return!0}if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();let n=ll(t);if(n.length!==ll(e).length)return!1;for(let l=0;l<n.length;l++)if(!Object.prototype.hasOwnProperty.call(e,n[l])||!Object.is(t[n[l]],e[n[l]]))return!1;return!0}o(lt,"shallow");function ll(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}o(ll,"getOwnKeys");var _o=Re(ut(),1),sl=Re(vi(),1);function Bi(t,e){return t===e}o(Bi,"defaultCompare");function qt(t,e=l=>l,n){let l=n?.compare??Bi,r=(0,_o.useCallback)(a=>{let{unsubscribe:c}=t.subscribe(a);return c},[t]),s=(0,_o.useCallback)(()=>t.get(),[t]);return(0,sl.useSyncExternalStoreWithSelector)(r,s,s,e,l)}o(qt,"useSelector");function al(t){let e=qt(t.source,t.selector,{compare:lt});return typeof t.children=="function"?t.children(e):t.children}o(al,"Subscribe");function il(t){let e=t;return Object.defineProperty(t,"state",{get(){return t.get()}}),"set"in t&&(e.setState=t.set.bind(t)),e}o(il,"atomToStore");function Co(t){let{createAtom:e,batch:n}=t,l=e(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"addSubscription"),unmount:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"unmount"),schedule:t.schedule??(r=>queueMicrotask(r)),batch:n,untrack:o(r=>r(),"untrack"),createReadonlyAtom:o((r,s)=>{let a=s?.compare??Object.is,c=!1,u,i=o(()=>{let m=r();return(!c||!a(u,m))&&(u=m,c=!0),u},"getSnapshot"),d=e(()=>(l.get(),i()),{compare:a});return{get:i,subscribe:d.subscribe.bind(d)}},"createReadonlyAtom"),createWritableAtom:o((r,s)=>e(r,{compare:s?.compare}),"createWritableAtom"),commit:o(()=>{l.set(r=>r+1)},"commit")}}o(Co,"renderPhaseReactivity");function vo(t,e=Object.is){let n=!1,l;return{get:t.get,markCommitted:o(r=>{l=r,n=!0},"markCommitted"),subscribe:o(r=>t.subscribe(s=>{(!n||!e(l,s))&&r(s)}),"subscribe")}}o(vo,"createRenderPhaseSource");function cl(){return Co({createAtom:So,batch:wo})}o(cl,"reactReactivity");function Ft(t,e){return typeof t=="function"?t(e):t}o(Ft,"functionalUpdate");function ae(t){if(Array.isArray(t))return t.map(ae);if(t&&typeof t=="object"){let e=Object.getPrototypeOf(t);if(e!==Object.prototype&&e!==null)return t;let n=e===null?H():{},l=Object.keys(t);for(let r=0;r<l.length;r++){let s=l[r];Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:ae(t[s]),writable:!0})}return n}return t}o(ae,"cloneState");function Rn(t,e){let n=Object.keys(e),l=t;for(let r=0;r<n.length;r++){let s=n[r];!s.startsWith("_memo_")&&s!=="_cellsCache"&&(l[s]=e[s])}return t}o(Rn,"copyInstancePropertiesWithoutMemos");function H(){return Object.create(null)}o(H,"makeObjectMap");function je(t,e){return Object.prototype.hasOwnProperty.call(t,e)}o(je,"hasOwn");function Be(t,e){return n=>{(e.options.atoms?.[t]??e.baseAtoms[t]).set(l=>Ft(n,l))}}o(Be,"makeStateUpdater");function ul(t){if(typeof t!="object"||t===null)return!1;if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}o(ul,"isPlainContainer");function dl(t){return Reflect.ownKeys(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}o(dl,"getEnumerableOwnKeys");var Gi=3;function qi(t,e){return ml(t,e,Gi)}o(qi,"stateSlicesEqual");function ml(t,e,n){if(Object.is(t,e))return!0;if(n<=0||!ul(t)||!ul(e)||(Array.isArray(t)||Array.isArray(e))&&(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length))return!1;let l=dl(t),r=dl(e);if(l.length!==r.length)return!1;let s=t,a=e;for(let c=0;c<l.length;c++){let u=l[c];if(!Object.prototype.propertyIsEnumerable.call(e,u)||!ml(s[u],a[u],n-1))return!1}return!0}o(ml,"stateSlicesEqualAtDepth");function He(t,e,n,l=qi){let r=`on${e.charAt(0).toUpperCase()}${e.slice(1)}Change`,s=t.options[r];s&&s(a=>{let c=Ft(n,a);return l(a,c)?a:c})}o(He,"setStateSlice");function gl(t){return t instanceof Function}o(gl,"isFunction");function fl(t,e){let n=[],l=o(r=>{r.forEach(s=>{n.push(s);let a=e(s);a.length&&l(a)})},"recurse");return l(t),n}o(fl,"flattenBy");var Ki=o(({fn:t,memoDeps:e,onAfterCompare:n,onAfterUpdate:l,onBeforeCompare:r,onBeforeUpdate:s})=>{let a=[],c;return o(i=>{r?.();let d=e?.(i),m=!d||d.length!==a?.length;if(!m&&d){for(let g=0;g<d.length;g++)if(d[g]!==a[g]){m=!0;break}}return n?.(m),m&&(a=d,s?.(),c=t(...d??[]),l?.(c)),c},"memoizedFn")},"memo");function In(t){let e=!1;return()=>{if(!e){e=!0;return}t()}}o(In,"skipFirstRun");var Ui=o((t,e)=>{for(t=String(t);t.length<e;)t=" "+t;return t},"pad");function Mt({feature:t,fnName:e,objectId:n,onAfterUpdate:l,table:r,...s}){let a,c,u=0,i;function d(b,f){let h=u===0?"(1st run)":f?"(rerun #"+u+")":"(cache)";u++,console.groupCollapsed(`%c\u23F1 ${Ui(`${b.toFixed(1)} ms`,12)} %c${h}%c ${e}%c ${n?`(${e.split(".")[0]}Id: ${n})`:""}`,`font-size: .6rem; font-weight: bold; ${f?`color: hsl(
1
+ import{a as fn,b as $e,e as Br,f as Gr}from"./chunk-AANB526D.js";import{a as Hr,b as bt,c as jr,d as pn}from"./chunk-EY6WHXDO.js";import{a as mn}from"./chunk-MXLAOCAN.js";import{b as dn}from"./chunk-CMA4PTV7.js";import{d as qr}from"./chunk-UYEZR3BI.js";import{a as un}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as mo,b as go,c as gn,d as Lr}from"./chunk-YOB2X3FZ.js";import{a as cn}from"./chunk-3FBLWUXD.js";import{a as Bt}from"./chunk-XZMOZFE6.js";import{a as co}from"./chunk-IMOHEGMV.js";import{a as an}from"./chunk-UXXDN6Z3.js";import{a as $r}from"./chunk-66UGPQVC.js";import{b as Mr,c as lo}from"./chunk-6DAD3RFX.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as uo}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as io}from"./chunk-NFS7FTAR.js";import{a as Tr}from"./chunk-EJSI4PMU.js";import{a as Nr,b as Dr}from"./chunk-OGUKYRFM.js";import{c as vr,d as yr,e as Rr}from"./chunk-6D6Z2KXU.js";import{b as kr,c as Pr,f as so}from"./chunk-OKG3HWSJ.js";import{W as Ir}from"./chunk-PLHA3OWK.js";import{b as vi}from"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as rn}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as _e}from"./chunk-4ZEL6BYL.js";import{b as ro,c as dt}from"./chunk-ERHFRNCL.js";import{f as rt}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as ln}from"./chunk-FKVZRPV5.js";import{a as Ar,b as Or,c as Er,d as ao,e as Vr,f as zr}from"./chunk-HEAQVSNS.js";import{d as oe,f as Ve,g as ze,h as jt,m as oo,n as sn,o as Oe,p as re,t as Fr}from"./chunk-PTZD7RUZ.js";import{a as o,d as Re,e as ut,f as Ht,g as Lt,i as pt}from"./chunk-YKXDMIHQ.js";var Ua=Re(Ht(),1);var Ot=Re(ut(),1);var ht=Re(Ht(),1);var Y=Re(Lt(),1),Le=Re(ut(),1);function We(t){let e=(0,ht.c)(2),n=(0,Le.useRef)(t),l;return e[0]!==t?(l=o(()=>{n.current=t},"r"),e[0]=t,e[1]=l):l=e[1],(0,Le.useEffect)(l),n}o(We,"te");var yi=2166136261,Ri=16777619,Ii=o((t,e=yi)=>{let n=e;for(let l=0;l<t.length;l+=1)n^=t.charCodeAt(l),n=Math.imul(n,Ri);return(n>>>0).toString(16).padStart(8,"0")},"V"),Fi=/([a-z\d])([A-Z])/gu,Mi=/[\s_-]+/u,ki=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),Pi=o(t=>{let e=t.replaceAll(Fi,"$1 $2").split(Mi).map(l=>l.toLowerCase()).filter(l=>l.length>0),n=new Set(e);for(let l=0;l<e.length-1;l+=1){let r=e[l],s=e[l+1];r===void 0||s===void 0||(n.add(`${r}${s}`),n.add(`${r}_${s}`))}return[...n]},"ae"),Kr="\u2022\u2022\u2022",Yr=o((t,e)=>{try{return e==="redact"?null:e==="hash"?t==null?t:Ii(typeof t=="bigint"?t.toString():typeof t=="string"?t:JSON.stringify(t)):Kr}catch{return Kr}},"W"),Ur=o((t,e)=>{let n=new Map;for(let l of t)l.table===e&&n.set(l.column,l.strategy);return n},"z"),Ni=o(t=>{for(let e of Pi(t))if(ki.has(e))return!0;return!1},"ce"),Jr=o((t,e)=>{let n=e.filter(r=>!t.has(r)&&Ni(r));if(n.length===0)return t;let l=new Map(t);for(let r of n)l.set(r,"redact");return l},"B"),Gt=o((t,e,n)=>{if(!n.enabled)return t;let l=n.columns.get(e);return l===void 0?t:Yr(t,l)},"Ce"),bn=o((t,e)=>{if(!e.enabled||e.columns.size===0)return t;let n={...t};for(let[l,r]of e.columns)l in n&&(n[l]=Yr(n[l],r));return n},"ie"),hn=o((t,e)=>!e.enabled||e.columns.size===0?t:t.map(n=>bn(n,e)),"Fe"),Wr=o(t=>t==null?"\u2205":t===""?"(empty)":Oe(t),"P"),Di=o(t=>{let e=(0,ht.c)(32),{column:n,onFacetFilter:l,state:r}=t,s=oe(),a;e[0]!==n||e[1]!==l||e[2]!==r.result?.values?(a=o(w=>{let _=Number(w.currentTarget.dataset.index),S=r.result?.values[_];S!==void 0&&l(n,S.value)},"x"),e[0]=n,e[1]=l,e[2]=r.result?.values,e[3]=a):a=e[3];let c=a,u=`db-facet-${n}`,i;e[4]!==n?(i=(0,Y.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=i):i=e[5];let d;e[6]!==r.loading||e[7]!==r.result||e[8]!==s?(d=r.loading&&r.result===null&&(0,Y.jsx)("span",{className:"text-muted-foreground",children:s("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=s,e[9]=d):d=e[9];let m;e[10]!==r.error?(m=r.error!==null&&(0,Y.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=m):m=e[11];let g;e[12]!==r.result?.values?(g=r.result?.values??[],e[12]=r.result?.values,e[13]=g):g=e[13];let b;if(e[14]!==n||e[15]!==c||e[16]!==g){let w;e[18]!==n||e[19]!==c?(w=o((_,S)=>(0,Y.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":S,"data-testid":`db-facet-value-${n}`,onClick:c,type:"button",children:[(0,Y.jsx)("span",{className:"truncate",children:Wr(_.value)}),(0,Y.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:_.count})]},Wr(_.value)),"c"),e[18]=n,e[19]=c,e[20]=w):w=e[20],b=g.map(w),e[14]=n,e[15]=c,e[16]=g,e[17]=b}else b=e[17];let f;e[21]!==n||e[22]!==r.result||e[23]!==s?(f=r.result?.truncated===!0&&(0,Y.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:s("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=s,e[24]=f):f=e[24];let h;return e[25]!==u||e[26]!==i||e[27]!==d||e[28]!==m||e[29]!==b||e[30]!==f?(h=(0,Y.jsxs)("section",{className:"flex flex-col gap-1","data-testid":u,children:[i,d,m,b,f]}),e[25]=u,e[26]=i,e[27]=d,e[28]=m,e[29]=b,e[30]=f,e[31]=h):h=e[31],h},"ue"),wn=o(t=>{let e=(0,ht.c)(44),{columns:n,facets:l,mask:r,onFacetFilter:s,onToggleFacet:a}=t,c=oe(),u;e[0]!==a?(u=o(v=>{let{column:M}=v.currentTarget.dataset;M!==void 0&&a(M)},"o"),e[0]=a,e[1]=u):u=e[1];let i=u,d;e[2]!==r?(d=o(v=>r.enabled&&r.columns.has(v),"a"),e[2]=r,e[3]=d):d=e[3];let m=d,g,b,f,h,w,_,S,y;if(e[4]!==n||e[5]!==l||e[6]!==m||e[7]!==c||e[8]!==i){y=Symbol.for("react.early_return_sentinel");e:{let v;e[17]!==m?(v=o(N=>!m(N),"y"),e[17]=m,e[18]=v):v=e[18];let M=n.filter(v),F;if(e[19]!==l||e[20]!==m?(F=Object.entries(l).filter(N=>{let[T]=N;return!m(T)}),e[19]=l,e[20]=m,e[21]=F):F=e[21],g=F,M.length===0){y=null;break e}_="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",S="db-facets",h="flex flex-col gap-1.5";let P;e[22]!==c?(P=c("Facets"),e[22]=c,e[23]=P):P=e[23],e[24]!==P?(w=(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:P}),e[24]=P,e[25]=w):w=e[25],b="flex flex-wrap gap-1";let k;e[26]!==l||e[27]!==i?(k=o(N=>(0,Y.jsx)("button",{"aria-pressed":N in l,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:i,type:"button",children:N},N),"A"),e[26]=l,e[27]=i,e[28]=k):k=e[28],f=M.map(k)}e[4]=n,e[5]=l,e[6]=m,e[7]=c,e[8]=i,e[9]=g,e[10]=b,e[11]=f,e[12]=h,e[13]=w,e[14]=_,e[15]=S,e[16]=y}else g=e[9],b=e[10],f=e[11],h=e[12],w=e[13],_=e[14],S=e[15],y=e[16];if(y!==Symbol.for("react.early_return_sentinel"))return y;let I;e[29]!==b||e[30]!==f?(I=(0,Y.jsx)("div",{className:b,children:f}),e[29]=b,e[30]=f,e[31]=I):I=e[31];let C;e[32]!==I||e[33]!==h||e[34]!==w?(C=(0,Y.jsxs)("div",{className:h,children:[w,I]}),e[32]=I,e[33]=h,e[34]=w,e[35]=C):C=e[35];let R;e[36]!==s||e[37]!==g?(R=g.map(v=>{let[M,F]=v;return(0,Y.jsx)(Di,{column:M,onFacetFilter:s,state:F},M)}),e[36]=s,e[37]=g,e[38]=R):R=e[38];let x;return e[39]!==C||e[40]!==R||e[41]!==_||e[42]!==S?(x=(0,Y.jsxs)("aside",{className:_,"data-testid":S,children:[C,R]}),e[39]=C,e[40]=R,e[41]=_,e[42]=S,e[43]=x):x=e[43],x},"_e"),xn=o(()=>{let[t,e]=(0,Le.useState)({}),n=We(t),l=(0,Le.useRef)({}),r=o(async(s,a)=>{let c=(l.current[s]??0)+1;l.current[s]=c,e(u=>s in u?{...u,[s]:{error:null,loading:!0,result:u[s]?.result??null}}:u);try{let u=await a(s);if(l.current[s]!==c)return;e(i=>s in i?{...i,[s]:{error:null,loading:!1,result:u}}:i)}catch(u){if(l.current[s]!==c)return;e(i=>s in i?{...i,[s]:{error:jt(u),loading:!1,result:null}}:i)}},"n");return{clearFacets:o(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:o(s=>{for(let a of Object.keys(n.current))re(r(a,s))},"refetchFacets"),toggleFacet:o((s,a)=>{if(s in n.current){e(c=>Object.fromEntries(Object.entries(c).filter(([u])=>u!==s)));return}e(c=>({...c,[s]:{error:null,loading:!0,result:null}})),a!==null&&re(r(s,a))},"toggleFacet")}},"Me"),Ti=[],Ai=o(()=>{let t=(0,ht.c)(1),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let{data:n}=dt(_e.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:Ti},"fe"),Sn=o(t=>{let e=(0,ht.c)(16),{columns:n,selectedTable:l}=t,r=Ai(),[s,a]=(0,Le.useState)(!0),c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=o(()=>{a(Oi)},"g"),e[0]=c):c=e[0];let u=c,i;if(e[1]!==n||e[2]!==r||e[3]!==l){let h=Ur(r,l??"");i=Jr(h,n),e[1]=n,e[2]=r,e[3]=l,e[4]=i}else i=e[4];let d=i,m;e[5]!==s||e[6]!==r?(m=o((h,w)=>({columns:Jr(Ur(r,h),w),enabled:s}),"l"),e[5]=s,e[6]=r,e[7]=m):m=e[7];let g=m,b;e[8]!==d||e[9]!==s?(b={columns:d,enabled:s},e[8]=d,e[9]=s,e[10]=b):b=e[10];let f;return e[11]!==d||e[12]!==s||e[13]!==g||e[14]!==b?(f={maskColumns:d,maskOn:s,maskView:b,maskViewFor:g,onToggleMask:u},e[11]=d,e[12]=s,e[13]=g,e[14]=b,e[15]=f):f=e[15],f},"$e");function Oi(t){return!t}o(Oi,"me");var Qr=34,Xr=600,Ei=o(t=>{let e=(0,ht.c)(21),{item:n,onSelect:l,prefix:r,selected:s,start:a}=t,c;e[0]!==n.name||e[1]!==l?(c=o(()=>{l(n.name)},"g"),e[0]=n.name,e[1]=l,e[2]=c):c=e[2];let u=c,i=`translateY(${String(a)}px)`,d;e[3]!==i?(d={insetInline:0,position:"absolute",top:0,transform:i},e[3]=i,e[4]=d):d=e[4];let m=d,g=s?"bg-accent font-medium text-accent-foreground":"text-foreground",b;e[5]!==g?(b=pt("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",g),e[5]=g,e[6]=b):b=e[6];let f=`${r}-table-${n.name}`,h;e[7]!==n.name?(h=(0,Y.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=h):h=e[8];let w;e[9]!==n.rowCount?(w=(0,Y.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let _;e[11]!==u||e[12]!==s||e[13]!==b||e[14]!==f||e[15]!==h||e[16]!==w?(_=(0,Y.jsxs)("button",{"aria-pressed":s,className:b,"data-testid":f,onClick:u,type:"button",children:[h,w]}),e[11]=u,e[12]=s,e[13]=b,e[14]=f,e[15]=h,e[16]=w,e[17]=_):_=e[17];let S;return e[18]!==m||e[19]!==_?(S=(0,Y.jsx)("li",{style:m,children:_}),e[18]=m,e[19]=_,e[20]=S):S=e[20],S},"ge"),_n=o(({header:t,onReload:e,onSelect:n,prefix:l,reloadLabel:r,selected:s,tables:a})=>{let c=oe(),[u,i]=(0,Le.useState)(""),d=(0,Le.useRef)(null),m=o(h=>{i(h.target.value)},"l"),g=(0,Le.useMemo)(()=>{let h=u.trim().toLowerCase();return h===""?a:a.filter(w=>w.name.toLowerCase().includes(h))},[u,a]),b=dn({count:g.length,estimateSize:o(()=>Qr,"estimateSize"),getScrollElement:o(()=>d.current,"getScrollElement"),initialRect:{height:Xr,width:240},observeElementRect:o((h,w)=>mn(h,w,Xr),"observeElementRect"),overscan:12}).getVirtualItems(),f={height:g.length*Qr};return(0,Y.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${l}-table-list`,children:[t,(0,Y.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Tables")}),e!==void 0&&(0,Y.jsx)("button",{"aria-label":r??c("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${l}-load-tables`,onClick:e,title:r??c("Refresh"),type:"button",children:(0,Y.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,Y.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,Y.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,Y.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${l}-table-search`,onChange:m,placeholder:c("search table\u2026"),type:"search",value:u})}),(0,Y.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${l}-table-list-rows`,ref:d,children:[(0,Y.jsx)("li",{"aria-hidden":"true",style:f}),b.map(h=>{let w=g[h.index];return w===void 0?null:(0,Y.jsx)(Ei,{item:w,onSelect:n,prefix:l,selected:s===w.name,start:h.start},w.name)})]})]})},"Te");var q=Re(Ht(),1);var D=Re(ut(),1);var p=Re(Lt(),1);var Zr=Re(ut(),1);function Vi(t){return zi(t)||typeof t=="function"||$i(t)}o(Vi,"isReactComponent");function zi(t){return typeof t=="function"&&(()=>{let e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}o(zi,"isClassComponent");function $i(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}o($i,"isExoticComponent");function wt(t,e){return t==null?null:Vi(t)?Zr.default.createElement(t,e):t}o(wt,"flexRender");function fo(t){if("cell"in t&&t.cell){let e=t.cell,n=e.column.columnDef,l=e,r=n;return l.getIsAggregated?.()?wt(r.aggregatedCell??n.cell,e.getContext()):l.getIsPlaceholder?.()?null:wt(n.cell,e.getContext())}return"header"in t&&t.header?wt(t.header.column.columnDef.header,t.header.getContext()):"footer"in t&&t.footer?wt(t.footer.column.columnDef.footer,t.footer.getContext()):null}o(fo,"FlexRender");function el({update:t,notify:e,unwatched:n}){return{link:l,unlink:r,propagate:s,checkDirty:a,shallowPropagate:c};function l(i,d,m){let g=d.depsTail;if(g!==void 0&&g.dep===i)return;let b=g!==void 0?g.nextDep:d.deps;if(b!==void 0&&b.dep===i){b.version=m,d.depsTail=b;return}let f=i.subsTail;if(f!==void 0&&f.version===m&&f.sub===d)return;let h=d.depsTail=i.subsTail={version:m,dep:i,sub:d,prevDep:g,nextDep:b,prevSub:f,nextSub:void 0};b!==void 0&&(b.prevDep=h),g!==void 0?g.nextDep=h:d.deps=h,f!==void 0?f.nextSub=h:i.subs=h}function r(i,d=i.sub){let m=i.dep,g=i.prevDep,b=i.nextDep,f=i.nextSub,h=i.prevSub;return b!==void 0?b.prevDep=g:d.depsTail=g,g!==void 0?g.nextDep=b:d.deps=b,f!==void 0?f.prevSub=h:m.subsTail=h,h!==void 0?h.nextSub=f:(m.subs=f)===void 0&&n(m),b}function s(i){let d=i.nextSub,m;e:do{let g=i.sub,b=g.flags;if(b&60?b&12?b&4?!(b&48)&&u(i,g)?(g.flags=b|40,b&=1):b=0:g.flags=b&-9|32:b=0:g.flags=b|32,b&2&&e(g),b&1){let f=g.subs;if(f!==void 0){let h=(i=f).nextSub;h!==void 0&&(m={value:d,prev:m},d=h);continue}}if((i=d)!==void 0){d=i.nextSub;continue}for(;m!==void 0;)if(i=m.value,m=m.prev,i!==void 0){d=i.nextSub;continue e}break}while(!0)}function a(i,d){let m,g=0,b=!1;e:do{let f=i.dep,h=f.flags;if(d.flags&16)b=!0;else if((h&17)===17){if(t(f)){let w=f.subs;w.nextSub!==void 0&&c(w),b=!0}}else if((h&33)===33){(i.nextSub!==void 0||i.prevSub!==void 0)&&(m={value:i,prev:m}),i=f.deps,d=f,++g;continue}if(!b){let w=i.nextDep;if(w!==void 0){i=w;continue}}for(;g--;){let w=d.subs,_=w.nextSub!==void 0;if(_?(i=m.value,m=m.prev):i=w,b){if(t(d)){_&&c(w),d=i.sub;continue}b=!1}else d.flags&=-33;d=i.sub;let S=i.nextDep;if(S!==void 0){i=S;continue e}}return b}while(!0)}function c(i){do{let d=i.sub,m=d.flags;(m&48)===32&&(d.flags=m|16,(m&6)===2&&e(d))}while((i=i.nextSub)!==void 0)}function u(i,d){let m=d.depsTail;for(;m!==void 0;){if(m===i)return!0;m=m.prevDep}return!1}}o(el,"createReactiveSystem");function ol(t,e,n){let l=typeof t=="object",r=l?t:void 0;return{next:(l?t.next:t)?.bind(r),error:(l?t.error:e)?.bind(r),complete:(l?t.complete:n)?.bind(r)}}o(ol,"toObserver");var po=[],vn=0,{link:tl,unlink:Hi,propagate:Li,checkDirty:rl,shallowPropagate:nl}=el({update(t){return t._update()},notify(t){po[bo++]=t,t.flags&=-3},unwatched(t){t.depsTail!==void 0&&(t.depsTail=void 0,t.flags=17,yn(t))}}),Cn=0,bo=0,Qe,ho=0;function wo(t){try{++ho,t()}finally{--ho||xo()}}o(wo,"batch");function yn(t){let e=t.depsTail,n=e!==void 0?e.nextDep:t.deps;for(;n!==void 0;)n=Hi(n,t)}o(yn,"purgeDeps");function xo(){if(!(ho>0)){for(;Cn<bo;){let t=po[Cn];po[Cn++]=void 0,t.notify()}Cn=0,bo=0}}o(xo,"flush");function So(t,e){let n=typeof t=="function",l=t,r={_snapshot:n?void 0:t,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?0:1,get(){return Qe!==void 0&&tl(r,Qe,vn),r._snapshot},subscribe(s){let a=ol(s),c={current:!1},u=ji(()=>{r.get(),c.current?a.next?.(r._snapshot):c.current=!0});return{unsubscribe:o(()=>{u.stop()},"unsubscribe")}},_update(s){let a=Qe,c=e?.compare??Object.is;if(n)Qe=r,++vn,r.depsTail=void 0;else if(s===void 0)return!1;n&&(r.flags=5);try{let u=r._snapshot,i=typeof s=="function"?s(u):s===void 0&&n?l(u):s;return u===void 0||!c(u,i)?(r._snapshot=i,!0):!1}finally{Qe=a,n&&(r.flags&=-5),yn(r)}}};return n?(r.flags=17,r.get=function(){let s=r.flags;if(s&16||s&32&&rl(r.deps,r)){if(r._update()){let a=r.subs;a!==void 0&&nl(a)}}else s&32&&(r.flags=s&-33);return Qe!==void 0&&tl(r,Qe,vn),r._snapshot}):r.set=function(s){if(r._update(s)){let a=r.subs;a!==void 0&&(Li(a),nl(a),xo())}},r}o(So,"createAtom");function ji(t){let e=o(()=>{let l=Qe;Qe=n,++vn,n.depsTail=void 0,n.flags=6;try{return t()}finally{Qe=l,n.flags&=-5,yn(n)}},"run"),n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:6,notify(){let l=this.flags;l&16||l&32&&rl(this.deps,this)?e():this.flags=2},stop(){this.flags=0,this.depsTail=void 0,yn(this)}};return e(),n}o(ji,"effect");function lt(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(let[l,r]of t)if(!e.has(l)||!Object.is(r,e.get(l)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(let l of t)if(!e.has(l))return!1;return!0}if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();let n=ll(t);if(n.length!==ll(e).length)return!1;for(let l=0;l<n.length;l++)if(!Object.prototype.hasOwnProperty.call(e,n[l])||!Object.is(t[n[l]],e[n[l]]))return!1;return!0}o(lt,"shallow");function ll(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}o(ll,"getOwnKeys");var _o=Re(ut(),1),sl=Re(vi(),1);function Bi(t,e){return t===e}o(Bi,"defaultCompare");function qt(t,e=l=>l,n){let l=n?.compare??Bi,r=(0,_o.useCallback)(a=>{let{unsubscribe:c}=t.subscribe(a);return c},[t]),s=(0,_o.useCallback)(()=>t.get(),[t]);return(0,sl.useSyncExternalStoreWithSelector)(r,s,s,e,l)}o(qt,"useSelector");function al(t){let e=qt(t.source,t.selector,{compare:lt});return typeof t.children=="function"?t.children(e):t.children}o(al,"Subscribe");function il(t){let e=t;return Object.defineProperty(t,"state",{get(){return t.get()}}),"set"in t&&(e.setState=t.set.bind(t)),e}o(il,"atomToStore");function Co(t){let{createAtom:e,batch:n}=t,l=e(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"addSubscription"),unmount:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"unmount"),schedule:t.schedule??(r=>queueMicrotask(r)),batch:n,untrack:o(r=>r(),"untrack"),createReadonlyAtom:o((r,s)=>{let a=s?.compare??Object.is,c=!1,u,i=o(()=>{let m=r();return(!c||!a(u,m))&&(u=m,c=!0),u},"getSnapshot"),d=e(()=>(l.get(),i()),{compare:a});return{get:i,subscribe:d.subscribe.bind(d)}},"createReadonlyAtom"),createWritableAtom:o((r,s)=>e(r,{compare:s?.compare}),"createWritableAtom"),commit:o(()=>{l.set(r=>r+1)},"commit")}}o(Co,"renderPhaseReactivity");function vo(t,e=Object.is){let n=!1,l;return{get:t.get,markCommitted:o(r=>{l=r,n=!0},"markCommitted"),subscribe:o(r=>t.subscribe(s=>{(!n||!e(l,s))&&r(s)}),"subscribe")}}o(vo,"createRenderPhaseSource");function cl(){return Co({createAtom:So,batch:wo})}o(cl,"reactReactivity");function Ft(t,e){return typeof t=="function"?t(e):t}o(Ft,"functionalUpdate");function ae(t){if(Array.isArray(t))return t.map(ae);if(t&&typeof t=="object"){let e=Object.getPrototypeOf(t);if(e!==Object.prototype&&e!==null)return t;let n=e===null?H():{},l=Object.keys(t);for(let r=0;r<l.length;r++){let s=l[r];Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:ae(t[s]),writable:!0})}return n}return t}o(ae,"cloneState");function Rn(t,e){let n=Object.keys(e),l=t;for(let r=0;r<n.length;r++){let s=n[r];!s.startsWith("_memo_")&&s!=="_cellsCache"&&(l[s]=e[s])}return t}o(Rn,"copyInstancePropertiesWithoutMemos");function H(){return Object.create(null)}o(H,"makeObjectMap");function je(t,e){return Object.prototype.hasOwnProperty.call(t,e)}o(je,"hasOwn");function Be(t,e){return n=>{(e.options.atoms?.[t]??e.baseAtoms[t]).set(l=>Ft(n,l))}}o(Be,"makeStateUpdater");function ul(t){if(typeof t!="object"||t===null)return!1;if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}o(ul,"isPlainContainer");function dl(t){return Reflect.ownKeys(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}o(dl,"getEnumerableOwnKeys");var Gi=3;function qi(t,e){return ml(t,e,Gi)}o(qi,"stateSlicesEqual");function ml(t,e,n){if(Object.is(t,e))return!0;if(n<=0||!ul(t)||!ul(e)||(Array.isArray(t)||Array.isArray(e))&&(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length))return!1;let l=dl(t),r=dl(e);if(l.length!==r.length)return!1;let s=t,a=e;for(let c=0;c<l.length;c++){let u=l[c];if(!Object.prototype.propertyIsEnumerable.call(e,u)||!ml(s[u],a[u],n-1))return!1}return!0}o(ml,"stateSlicesEqualAtDepth");function He(t,e,n,l=qi){let r=`on${e.charAt(0).toUpperCase()}${e.slice(1)}Change`,s=t.options[r];s&&s(a=>{let c=Ft(n,a);return l(a,c)?a:c})}o(He,"setStateSlice");function gl(t){return t instanceof Function}o(gl,"isFunction");function fl(t,e){let n=[],l=o(r=>{r.forEach(s=>{n.push(s);let a=e(s);a.length&&l(a)})},"recurse");return l(t),n}o(fl,"flattenBy");var Ki=o(({fn:t,memoDeps:e,onAfterCompare:n,onAfterUpdate:l,onBeforeCompare:r,onBeforeUpdate:s})=>{let a=[],c;return o(i=>{r?.();let d=e?.(i),m=!d||d.length!==a?.length;if(!m&&d){for(let g=0;g<d.length;g++)if(d[g]!==a[g]){m=!0;break}}return n?.(m),m&&(a=d,s?.(),c=t(...d??[]),l?.(c)),c},"memoizedFn")},"memo");function In(t){let e=!1;return()=>{if(!e){e=!0;return}t()}}o(In,"skipFirstRun");var Ui=o((t,e)=>{for(t=String(t);t.length<e;)t=" "+t;return t},"pad");function Mt({feature:t,fnName:e,objectId:n,onAfterUpdate:l,table:r,...s}){let a,c,u=0,i;function d(b,f){let h=u===0?"(1st run)":f?"(rerun #"+u+")":"(cache)";u++,console.groupCollapsed(`%c\u23F1 ${Ui(`${b.toFixed(1)} ms`,12)} %c${h}%c ${e}%c ${n?`(${e.split(".")[0]}Id: ${n})`:""}`,`font-size: .6rem; font-weight: bold; ${f?`color: hsl(
2
2
  ${Math.max(0,Math.min(120-Math.log10(b)*60,120))}deg 100% 31%);`:""} `,`color: ${u<2?"#FF00FF":"#FF1493"}`,"color: #666","color: #87CEEB"),console.info({feature:t,state:r.store.state,deps:s.memoDeps?.toString()}),console.trace(),console.groupEnd()}o(d,"logTime");let m=o(()=>{if(!l)return;let{schedule:b,untrack:f}=r._reactivity;b(()=>f(()=>l()))},"onAfterUpdateHandler");return Ki({...s,...{onAfterUpdate:o(()=>{m()},"onAfterUpdate")}})}o(Mt,"tableMemo");function pl(t,e="_"){let[n,l]=t.split(e);return{fnKey:l,fnName:`${n}.${l}`,parentName:n}}o(pl,"getFunctionNameInfo");function pe(t,e,n){for(let[l,{fn:r,memoDeps:s}]of Object.entries(n)){let{fnKey:a,fnName:c}=pl(l);e[a]=s?Mt({memoDeps:s,fn:r,fnName:c,table:e,feature:t}):r}}o(pe,"assignTableAPIs");function ue(t,e,n,l){for(let[r,{fn:s,memoDeps:a}]of Object.entries(l)){let{fnKey:c,fnName:u}=pl(r);if(a){let i=`_memo_${c}`;e[c]=function(...d){if(!this[i]){let m=this;this[i]=Mt({memoDeps:o(g=>a(m,g),"memoDeps"),fn:o((...g)=>s(m,...g),"fn"),fnName:u,objectId:m.id,table:n,feature:t})}return this[i](...d)}}else e[c]=function(...i){return s(this,...i)}}}o(ue,"assignPrototypeAPIs");function V(t,e,n,...l){return t[e]?.(...l)??n(t,...l)}o(V,"callMemoOrStaticFn");function bl(t){return t.row.getValue(t.column.id)}o(bl,"cell_getValue");function hl(t){return t.getValue()??t.table.options.renderFallbackValue}o(hl,"cell_renderValue");function wl(t){return{table:t.table,column:t.column,row:t.row,cell:t,getValue:o(()=>t.getValue(),"getValue"),renderValue:o(()=>t.renderValue(),"renderValue")}}o(wl,"cell_getContext");var xl={assignCellPrototype:o((t,e)=>{ue("coreCellsFeature",t,e,{cell_getValue:{fn:o(n=>bl(n),"fn")},cell_renderValue:{fn:o(n=>hl(n),"fn")},cell_getContext:{fn:o(n=>wl(n),"fn"),memoDeps:o(n=>[n],"memoDeps")}})},"assignCellPrototype")};function Ji(t){if(!t._headerPrototype){t._headerPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignHeaderPrototype?.(t._headerPrototype,t)}return t._headerPrototype}o(Ji,"getHeaderPrototype");function yo(t,e,n){let l=Ji(t),r=Object.create(l);r.colSpan=0,r.column=e,r.depth=n.depth,r.headerGroup=null,r.id=n.id??e.id,r.index=n.index,r.isPlaceholder=!!n.isPlaceholder,r.placeholderId=n.placeholderId,r.rowSpan=0,r.subHeaders=[];let s=t._headerInstanceInitFns;for(let a=0;a<s.length;a++)s[a](r);return r}o(yo,"constructHeader");function Xe(){return{start:[],end:[]}}o(Xe,"getDefaultColumnPinningState");function Sl(t){let e=t.getAllColumns(),n=t.getAllLeafColumnsById(),{start:l}=t.atoms.columnPinning?.get()??Xe(),r=[];for(let s=0;s<l.length;s++){let a=n[l[s]];a&&V(a,"getIsVisible",de)&&r.push(a)}return St(e,r,t,"start")}o(Sl,"table_getStartHeaderGroups");function _l(t){let e=t.getAllColumns(),n=t.getAllLeafColumnsById(),{end:l}=t.atoms.columnPinning?.get()??Xe(),r=[];for(let s=0;s<l.length;s++){let a=n[l[s]];a&&V(a,"getIsVisible",de)&&r.push(a)}return St(e,r,t,"end")}o(_l,"table_getEndHeaderGroups");function Cl(t){let e=t.getAllColumns(),n=V(t,"getVisibleLeafColumns",xt),{start:l,end:r}=t.atoms.columnPinning?.get()??Xe();if(l.length||r.length){let s=[...l,...r];n=n.filter(a=>!s.includes(a.id))}return St(e,n,t,"center")}o(Cl,"table_getCenterHeaderGroups");function Wi(t){let{start:e}=t.atoms.columnPinning?.get()??Xe(),n=t.getAllLeafColumnsById(),l=[];for(let r=0;r<e.length;r++){let s=n[e[r]];s&&l.push(s)}return l}o(Wi,"table_getStartLeafColumns");function Qi(t){let{end:e}=t.atoms.columnPinning?.get()??Xe(),n=t.getAllLeafColumnsById(),l=[];for(let r=0;r<e.length;r++){let s=n[e[r]];s&&l.push(s)}return l}o(Qi,"table_getEndLeafColumns");function Xi(t){let{start:e,end:n}=t.atoms.columnPinning?.get()??Xe();if(!e.length&&!n.length)return t.getAllLeafColumns();let l=[...e,...n];return t.getAllLeafColumns().filter(r=>!l.includes(r.id))}o(Xi,"table_getCenterLeafColumns");function Yi(t){return V(t,"getStartLeafColumns",Wi).filter(e=>V(e,"getIsVisible",de))}o(Yi,"table_getStartVisibleLeafColumns");function Zi(t){return V(t,"getEndLeafColumns",Qi).filter(e=>V(e,"getIsVisible",de))}o(Zi,"table_getEndVisibleLeafColumns");function ec(t){return V(t,"getCenterLeafColumns",Xi).filter(e=>V(e,"getIsVisible",de))}o(ec,"table_getCenterVisibleLeafColumns");function Ge(t,e){return e?e==="start"?V(t,"getStartVisibleLeafColumns",Yi):e==="end"?V(t,"getEndVisibleLeafColumns",Zi):V(t,"getCenterVisibleLeafColumns",ec):V(t,"getVisibleLeafColumns",xt)}o(Ge,"table_getPinnedVisibleLeafColumns");function vl(){return H()}o(vl,"getDefaultColumnVisibilityState");function Io(t,e){Kt(t)&&Ut(t.table,n=>{let l=Object.assign(H(),n),r=e??!V(t,"getIsVisible",de),s=t.getLeafColumns();for(let a=0;a<s.length;a++){let c=s[a];Kt(c)&&(l[c.id]=r)}return l})}o(Io,"column_toggleVisibility");function de(t){let e=t.table.atoms.columnVisibility?.get();if(!e)return!0;let n=t.columns;return n.length?n.some(l=>V(l,"getIsVisible",de)):(je(e,t.id)?e[t.id]:void 0)??!0}o(de,"column_getIsVisible");function Kt(t){return(t.columnDef.enableHiding??!0)&&(t.table.options.enableHiding??!0)}o(Kt,"column_getCanHide");function yl(t){return e=>{Io(t,e.target.checked)}}o(yl,"column_getToggleVisibilityHandler");function Ro(t){let e=t.getAllCells(),n=[];for(let i=0;i<e.length;i++){let d=e[i];V(d.column,"getIsVisible",de)&&n.push(d)}let{start:l,end:r}=t.table.atoms.columnPinning?.get()??Xe();if(!l.length&&!r.length)return n;let s=V(t,"getVisibleCellsByColumnId",Fn),a=[];for(let i=0;i<l.length;i++){let d=s[l[i]];d&&a.push(d)}let c=[];for(let i=0;i<r.length;i++){let d=s[r[i]];d&&c.push(d)}let u=[];for(let i=0;i<n.length;i++){let d=n[i],m=d.column.id;!l.includes(m)&&!r.includes(m)&&u.push(d)}return[...a,...u,...c]}o(Ro,"row_getVisibleCells");function Fn(t){let e=H(),n=t.getAllCells();for(let l=0;l<n.length;l++){let r=n[l];V(r.column,"getIsVisible",de)&&(e[r.column.id]=r)}return e}o(Fn,"row_getVisibleCellsByColumnId");function Rl(t){return t.getAllFlatColumns().filter(e=>V(e,"getIsVisible",de))}o(Rl,"table_getVisibleFlatColumns");function xt(t){return t.getAllLeafColumns().filter(e=>V(e,"getIsVisible",de))}o(xt,"table_getVisibleLeafColumns");function Ut(t,e){He(t,"columnVisibility",e)}o(Ut,"table_setColumnVisibility");function Il(t,e){Ut(t,e?H():Object.assign(H(),ae(t.initialState.columnVisibility??{})))}o(Il,"table_resetColumnVisibility");function Fo(t,e){e=e??!Mo(t);let n=H(),l=t.getAllLeafColumns();for(let r=0;r<l.length;r++){let s=l[r];n[s.id]=e||!Kt(s)}Ut(t,n)}o(Fo,"table_toggleAllColumnsVisible");function Mo(t){return!t.getAllLeafColumns().some(e=>!V(e,"getIsVisible",de))}o(Mo,"table_getIsAllColumnsVisible");function Fl(t){return t.getAllLeafColumns().some(e=>V(e,"getIsVisible",de))}o(Fl,"table_getIsSomeColumnsVisible");function Ml(t){return e=>{Fo(t,e.target.checked)}}o(Ml,"table_getToggleAllColumnsVisibilityHandler");function kl(t,e=1){let n=e;for(let l=0;l<t.length;l++){let r=t[l];V(r,"getIsVisible",de)&&r.columns.length&&(n=Math.max(n,kl(r.columns,e+1)))}return n}o(kl,"getMaxHeaderDepth");function tc(t,e){return t?`${t}_${e}`:String(e)}o(tc,"formatHeaderGroupId");function nc(t,e,n,l){let r=t??"";return e&&(r=r?`${r}_${e}`:String(e)),n&&(r=r?`${r}_${n}`:n),l&&(r=r?`${r}_${l}`:l),r}o(nc,"formatHeaderId");function oc(t,e){let n=0;for(let l=0;l<t.length;l++)t[l].column===e&&n++;return n}o(oc,"countPendingHeadersForColumn");function Pl(t,e,n,l,r,s){let a={depth:e,id:tc(l,e),headers:[]},c=[];for(let u=0;u<t.length;u++){if(!(u in t))continue;let i=t[u],d=c[c.length-1],m=i.column.depth===a.depth,g,b=!1;if(m&&i.column.parent?g=i.column.parent:(g=i.column,b=!0),d&&d.column===g)d.subHeaders.push(i);else{let f=yo(n,g,{id:nc(l,e,g.id,i.id),isPlaceholder:b,placeholderId:b?String(oc(c,g)):void 0,depth:e,index:c.length});f.subHeaders.push(i),c.push(f)}a.headers.push(i),i.headerGroup=a}for(let u=0;u<s.length;u++)s[u](a);r.push(a),e>0&&Pl(c,e-1,n,l,r,s)}o(Pl,"constructHeaderGroup");function Nl(t){for(let e=0;e<t.length;e++){let n=t[e];if(!V(n.column,"getIsVisible",de))continue;let l=0;if(n.subHeaders.length){Nl(n.subHeaders);for(let r=0;r<n.subHeaders.length;r++){let s=n.subHeaders[r];V(s.column,"getIsVisible",de)&&(l+=s.colSpan)}}else l=1;if(n.colSpan=l,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let r=1,s=n.subHeaders[0];for(;s;)s.rowSpan=0,r++,s=s.subHeaders.length===1&&s.subHeaders[0].column===n.column?s.subHeaders[0]:void 0;n.rowSpan=r}else n.rowSpan=1}}o(Nl,"updateHeaderSpans");function St(t,e,n,l){let r=kl(t),s=[],a=n._headerGroupInstanceInitFns,c=new Array(e.length);for(let u=0;u<e.length;u++)u in e&&(c[u]=yo(n,e[u],{depth:r,index:u}));return Pl(c,r-1,n,l,s,a),s.reverse(),Nl(s[0]?.headers??[]),s}o(St,"buildHeaderGroups");function rc(t){if(!t._columnPrototype){t._columnPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignColumnPrototype?.(t._columnPrototype,t)}return t._columnPrototype}o(rc,"getColumnPrototype");function Dl(t,e,n,l){let r={...t.getDefaultColumnDef(),...e},s=r.accessorKey,a=s===void 0?void 0:String(s),c=r.id??a?.replaceAll(".","_")??(typeof r.header=="string"?r.header:void 0),u;if(r.accessorFn)u=r.accessorFn;else if(s!==void 0)if(typeof s=="string"&&s.includes(".")){let g=s.split(".");u=o(b=>{let f=b;for(let h=0;h<g.length;h++){let w=g[h];f=f?.[w]}return f},"accessorFn")}else u=o(g=>g[r.accessorKey],"accessorFn");if(!c)throw new Error;let i=rc(t),d=Object.create(i);d.accessorFn=u,d.columnDef=r,d.columns=[],d.depth=n,d.id=`${String(c)}`,d.parent=l;let m=t._columnInstanceInitFns;for(let g=0;g<m.length;g++)m[g](d);return d}o(Dl,"constructColumn");function Tl(){return[]}o(Tl,"getDefaultColumnOrderState");function ko(t){let e=o(n=>{let l=H();for(let r=0;r<n.length;r++)l[n[r].id]=r;return l},"buildIndexes");return{all:e(Ge(t)),center:e(Ge(t,"center")),start:e(Ge(t,"start")),end:e(Ge(t,"end"))}}o(ko,"table_getColumnIndexes");function Al(t,e){return V(t.table,"getColumnIndexes",ko)[e==="start"?"start":e==="end"?"end":e==="center"?"center":"all"][t.id]??-1}o(Al,"column_getIndex");function Ol(t,e){return Ge(t.table,e)[0]?.id===t.id}o(Ol,"column_getIsFirstColumn");function El(t,e){let n=Ge(t.table,e);return n[n.length-1]?.id===t.id}o(El,"column_getIsLastColumn");function Po(t,e){He(t,"columnOrder",e)}o(Po,"table_setColumnOrder");function Vl(t,e){Po(t,e?[]:ae(t.initialState.columnOrder??[]))}o(Vl,"table_resetColumnOrder");function Jt(t){let e=t.atoms.columnOrder?.get();return n=>{let l=[];if(!e?.length)l=n;else{let r=new Map;for(let s=0;s<n.length;s++){let a=n[s];r.set(a.id,a)}for(let s=0;s<e.length;s++){let a=e[s],c=r.get(a);c&&(l.push(c),r.delete(a))}for(let s=0;s<n.length;s++){let a=n[s];r.has(a.id)&&l.push(a)}}return lc(t,l)}}o(Jt,"table_getOrderColumnsFn");function lc(t,e){let n=t.atoms.grouping?.get()??[],{groupedColumnMode:l}=t.options;if(!n.length||!l)return e;let r=e.filter(c=>!n.includes(c.id));if(l==="remove")return r;let s=new Map;for(let c=0;c<e.length;c++){let u=e[c];s.set(u.id,u)}let a=[];for(let c=0;c<n.length;c++){let u=s.get(n[c]);u&&a.push(u)}return[...a,...r]}o(lc,"orderColumns");function zl(t){return[t,...t.columns.flatMap(e=>e.getFlatColumns())]}o(zl,"column_getFlatColumns");function $l(t){if(t.columns.length){let e=t.columns.flatMap(n=>n.getLeafColumns());return V(t.table,"getOrderColumns",Jt)(e)}return[t]}o($l,"column_getLeafColumns");function Hl(t){return{header:o(e=>{let n=e.header.column.columnDef;return n.accessorKey?n.accessorKey:n.accessorFn?n.id:null},"header"),cell:o(e=>e.renderValue()?.toString?.()??null,"cell"),...Object.values(t._features).reduce((e,n)=>Object.assign(e,n.getDefaultColumnDef?.()),{}),...t.options.defaultColumn}}o(Hl,"table_getDefaultColumnDef");function Ll(t,e,n,l=0){let r=new Array(e.length);for(let s=0;s<e.length;s++){if(!(s in e))continue;let a=e[s],c=Dl(t,a,l,n),u=a;c.columns=u.columns?Ll(t,u.columns,c,l+1):[],r[s]=c}return r}o(Ll,"constructColumns");function jl(t){return Ll(t,t.options.columns)}o(jl,"table_getAllColumns");function Bl(t){return t.getAllColumns().flatMap(e=>e.getFlatColumns())}o(Bl,"table_getAllFlatColumns");function Gl(t){let e=H(),n=t.getAllFlatColumns();for(let l=0;l<n.length;l++){let r=n[l];e[r.id]=r}return e}o(Gl,"table_getAllFlatColumnsById");function ql(t){let e=t.getAllColumns().flatMap(n=>n.getLeafColumns());return V(t,"getOrderColumns",Jt)(e)}o(ql,"table_getAllLeafColumns");function Kl(t){let e=H(),n=t.getAllLeafColumns();for(let l=0;l<n.length;l++){let r=n[l];e[r.id]=r}return e}o(Kl,"table_getAllLeafColumnsById");function Ul(t,e){return t.getAllFlatColumnsById()[e]}o(Ul,"table_getColumn");var Jl={assignColumnPrototype:o((t,e)=>{ue("coreColumnsFeature",t,e,{column_getFlatColumns:{fn:o(n=>zl(n),"fn"),memoDeps:o(n=>[n.table.options.columns],"memoDeps")},column_getLeafColumns:{fn:o(n=>$l(n),"fn"),memoDeps:o(n=>[n.table.atoms.columnOrder?.get(),n.table.atoms.grouping?.get(),n.table.options.columns,n.table.options.groupedColumnMode],"memoDeps")}})},"assignColumnPrototype"),constructTableAPIs:o(t=>{pe("coreColumnsFeature",t,{table_getDefaultColumnDef:{fn:o(()=>Hl(t),"fn"),memoDeps:o(()=>[t.options.defaultColumn],"memoDeps")},table_getAllColumns:{fn:o(()=>jl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllFlatColumns:{fn:o(()=>Bl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllFlatColumnsById:{fn:o(()=>Gl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllLeafColumns:{fn:o(()=>ql(t),"fn"),memoDeps:o(()=>[t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_getAllLeafColumnsById:{fn:o(()=>Kl(t),"fn"),memoDeps:o(()=>[t.getAllLeafColumns()],"memoDeps")},table_getColumn:{fn:o(e=>Ul(t,e),"fn")}})},"constructTableAPIs")};function Wl(t,e){for(let n=0;n<t.subHeaders.length;n++)Wl(t.subHeaders[n],e);e.push(t)}o(Wl,"collectLeafHeaders");function Ql(t){let e=[];return Wl(t,e),e}o(Ql,"header_getLeafHeaders");function Xl(t){return{column:t.column,header:t,table:t.column.table}}o(Xl,"header_getContext");function Yl(t){let{start:e,end:n}=t.atoms.columnPinning?.get()??Xe(),l=t.getAllColumns(),r=V(t,"getVisibleLeafColumns",xt);if(!e.length&&!n.length)return St(l,r,t);let s=t.getAllLeafColumnsById(),a=[];for(let i=0;i<e.length;i++){let d=s[e[i]];d&&V(d,"getIsVisible",de)&&a.push(d)}let c=[];for(let i=0;i<n.length;i++){let d=s[n[i]];d&&V(d,"getIsVisible",de)&&c.push(d)}let u=r.filter(i=>!e.includes(i.id)&&!n.includes(i.id));return St(l,[...a,...u,...c],t)}o(Yl,"table_getHeaderGroups");function Zl(t){return[...t.getHeaderGroups()].reverse()}o(Zl,"table_getFooterGroups");function es(t){let e=t.getHeaderGroups(),n=[];for(let l=0;l<e.length;l++){let r=e[l].headers;for(let s=0;s<r.length;s++)n.push(r[s])}return n}o(es,"table_getFlatHeaders");function ts(t){let e=t.getHeaderGroups()[0]?.headers??[],n=[];for(let l=0;l<e.length;l++){let r=e[l].getLeafHeaders();for(let s=0;s<r.length;s++)n.push(r[s])}return n}o(ts,"table_getLeafHeaders");var ns={assignHeaderPrototype:o((t,e)=>{ue("coreHeadersFeature",t,e,{header_getLeafHeaders:{fn:o(n=>Ql(n),"fn"),memoDeps:o(n=>[n.column.table.options.columns],"memoDeps")},header_getContext:{fn:o(n=>Xl(n),"fn"),memoDeps:o(n=>[n.column.table.options.columns],"memoDeps")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{pe("coreHeadersFeature",t,{table_getHeaderGroups:{fn:o(()=>Yl(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.options.groupedColumnMode],"memoDeps")},table_getFooterGroups:{fn:o(()=>Zl(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")},table_getFlatHeaders:{fn:o(()=>es(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")},table_getLeafHeaders:{fn:o(()=>ts(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")}})},"constructTableAPIs")};function sc(t){if(!t._rowPrototype){t._rowPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignRowPrototype?.(t._rowPrototype,t)}return t._rowPrototype}o(sc,"getRowPrototype");var os=o((t,e,n,l,r,s,a)=>{let c=sc(t),u=Object.create(c);u._displayIndexCache=-1,u._uniqueValuesCache=H(),u._valuesCache=H(),u.depth=r,u.id=e,u.index=l,u.original=n,u.parentId=a,u.subRows=s??[];let i=t._rowInstanceInitFns;for(let d=0;d<i.length;d++)i[d](u);return u},"constructRow");var Do=/([0-9]+)/gm;function _t(t){let e=Object.assign((n,l,r)=>{let s=n.getValue(r),a=l.getValue(r),c=e.resolveDataValue;return c&&(s=c(s),a=c(a)),e.sort(s,a,n,l,r)},t);return e}o(_t,"constructSortFn");var To=_t({resolveDataValue:o(t=>kn(t).toLowerCase(),"resolveDataValue"),sort:o((t,e)=>ss(t,e),"sort")}),ac=_t({resolveDataValue:o(t=>kn(t),"resolveDataValue"),sort:o((t,e)=>ss(t,e),"sort")}),Ao=_t({resolveDataValue:o(t=>kn(t).toLowerCase(),"resolveDataValue"),sort:o((t,e)=>Eo(t,e),"sort")}),ic=_t({resolveDataValue:o(t=>kn(t),"resolveDataValue"),sort:o((t,e)=>Eo(t,e),"sort")}),Oo=_t({resolveDataValue:o(t=>cc(t),"resolveDataValue"),sort:o((t,e)=>t>e?1:t<e?-1:0,"sort")}),kt=_t({sort:o((t,e)=>Eo(t,e),"sort")});function Eo(t,e){return t===e?0:t>e?1:-1}o(Eo,"compareBasic");function cc(t){return t instanceof Date?t.getTime():t}o(cc,"toDateSortValue");function kn(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}o(kn,"toString");function ss(t,e){let n=0,l=0,r=t.length,s=e.length;for(;n<r&&l<s;){let a=Mn(t.charCodeAt(n)),c=Mn(e.charCodeAt(l)),u=No(t,n,a),i=No(e,l,c);if(!a&&!c){let m=uc(t,n,u,e,l,i);if(m)return m;n=u,l=i;continue}if(a!==c)return a?1:-1;let d=dc(t,n,u,e,l,i);if(d)return d;n=u,l=i}return ls(t,n)-ls(e,l)}o(ss,"compareAlphanumeric");function Mn(t){return t>=48&&t<=57}o(Mn,"isDigit");function No(t,e,n){let l=e+1;for(;l<t.length&&Mn(t.charCodeAt(l))===n;)l++;return l}o(No,"findChunkEnd");function uc(t,e,n,l,r,s){let a=n-e,c=s-r,u=a<c?a:c;for(let i=0;i<u;i++){let d=t.charCodeAt(e+i),m=l.charCodeAt(r+i);if(d>m)return 1;if(m>d)return-1}return a>c?1:c>a?-1:0}o(uc,"compareStringChunks");function dc(t,e,n,l,r,s){let a=e;for(;a<n&&t.charCodeAt(a)===48;)a++;let c=r;for(;c<s&&l.charCodeAt(c)===48;)c++;let u=n-a,i=s-c;if(u===0&&i===0)return 0;if(u<=15&&i<=15){let g=rs(t,a,n),b=rs(l,c,s);return g>b?1:b>g?-1:0}let d=parseInt(t.slice(e,n),10),m=parseInt(l.slice(r,s),10);return d>m?1:m>d?-1:0}o(dc,"compareNumericChunks");function rs(t,e,n){let l=0;for(let r=e;r<n;r++)l=l*10+t.charCodeAt(r)-48;return l}o(rs,"parseSmallInt");function ls(t,e){let n=0,l=e;for(;l<t.length;)n++,l=No(t,l,Mn(t.charCodeAt(l)));return n}o(ls,"countRemainingChunks");function as(){return[]}o(as,"getDefaultCellSelectionState");function mc(t,e){He(t,"cellSelection",e?as():ae(t.initialState.cellSelection)??as())}o(mc,"table_resetCellSelection");function is(t){t.atoms.cellSelection&&(t.options.autoResetAll??t.options.autoResetCellSelection??!0)&&t._reactivity.schedule(()=>mc(t))}o(is,"table_autoResetCellSelection");function cs(t){t.atoms.expanded&&(t.options.autoResetAll??t.options.autoResetExpanded??!t.options.manualExpanding)&&t._reactivity.schedule(()=>gc(t))}o(cs,"table_autoResetExpanded");function gc(t,e){let n=t.initialState.expanded;He(t,"expanded",e?H():n===!0?!0:Object.assign(H(),ae(n??{})))}o(gc,"table_resetExpanded");var Pn=0;function Nn(t){if(t.options.autoResetAll??t.options.autoResetPageIndex??!t.options.manualPagination){if((t.atoms.pagination?.get()?.pageIndex??Pn)===Pn)return;bc(t,!0)}}o(Nn,"table_autoResetPageIndex");function fc(t,e){He(t,"pagination",e)}o(fc,"table_setPagination");function pc(t,e){fc(t,n=>{let l=Ft(e,n.pageIndex),r=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return l=Math.max(0,Math.min(l,r)),{...n,pageIndex:l}})}o(pc,"table_setPageIndex");function bc(t,e){pc(t,e?Pn:t.initialState.pagination?.pageIndex??Pn)}o(bc,"table_resetPageIndex");function us(){return[]}o(us,"getDefaultSortingState");function Qt(t,e){He(t,"sorting",e)}o(Qt,"table_setSorting");function Vo(t,e){Qt(t,e?[]:ae(t.initialState.sorting??[]))}o(Vo,"table_resetSorting");function ds(t){t.atoms.sorting&&(t.options.autoResetAll??t.options.autoResetSorting??!1)&&Vo(t)}o(ds,"table_autoResetSorting");function zo(t){let e=t.table._rowModelFns.sortFns,n=t.table.getFilteredRowModel().flatRows.slice(0,10),l,r=!1;for(let s=0;s<n.length;s++){let a=n[s].getValue(t.id);if(Object.prototype.toString.call(a)==="[object Date]"){l="datetime";break}if(typeof a=="string"&&(r=!0,a.split(Do).length>1)){l="alphanumeric";break}}if(!l&&r&&(l="text"),l){let s=e?.[l];if(s||l==="alphanumeric"&&(s=e?.text),s)return s}return kt}o(zo,"column_getAutoSortFn");function $o(t){let e=t.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n<e.length;n++){let l=e[n].getValue(t.id);if(l!=null)return typeof l=="string"?"asc":"desc"}return"desc"}o($o,"column_getAutoSortDir");function Dn(t){let e=t.table._rowModelFns.sortFns;return gl(t.columnDef.sortFn)?t.columnDef.sortFn:t.columnDef.sortFn==="auto"?zo(t):e?.[t.columnDef.sortFn]??kt}o(Dn,"column_getSortFn");function Ho(t,e,n){let l=jo(t,n&&Wt(t)),r=typeof e<"u";Qt(t.table,s=>{let a=s.findIndex(g=>g.id===t.id),c=a===-1?void 0:s[a],u=[],i,d=r?e:l==="desc",m=!!(s.length&&Wt(t)&&n);return m?c?i="toggle":i="add":c?i="toggle":i="replace",i==="toggle"&&(r||l||(i="remove")),i==="add"?(u=[...s,{id:t.id,desc:d}],u.splice(0,u.length-(t.table.options.maxMultiSortColCount??Number.MAX_SAFE_INTEGER))):i==="toggle"?u=m?s.map(g=>g.id===t.id?{...g,desc:d}:g):[{id:t.id,desc:d}]:i==="remove"?u=m?s.filter(g=>g.id!==t.id):[]:u=[{id:t.id,desc:d}],u})}o(Ho,"column_toggleSorting");function Lo(t){return t.columnDef.sortDescFirst??t.table.options.sortDescFirst??$o(t)==="desc"?"desc":"asc"}o(Lo,"column_getFirstSortDir");function jo(t,e){let n=Lo(t),l=Bo(t);return l?l!==n&&(t.table.options.enableSortingRemoval??!0)&&(!e||(t.table.options.enableMultiRemove??!0))?!1:l==="desc"?"asc":"desc":n}o(jo,"column_getNextSortingOrder");function Xt(t){return(t.columnDef.enableSorting??!0)&&(t.table.options.enableSorting??!0)&&!!t.accessorFn}o(Xt,"column_getCanSort");function Wt(t){return t.columnDef.enableMultiSort??t.table.options.enableMultiSort??!!t.accessorFn}o(Wt,"column_getCanMultiSort");function Bo(t){let e=t.table.atoms.sorting?.get()?.find(n=>n.id===t.id);return e?e.desc?"desc":"asc":!1}o(Bo,"column_getIsSorted");function ms(t){return t.table.atoms.sorting?.get()?.findIndex(e=>e.id===t.id)??-1}o(ms,"column_getSortIndex");function gs(t){Qt(t.table,e=>e.length?e.filter(n=>n.id!==t.id):[])}o(gs,"column_clearSorting");function fs(t){let e=Xt(t);return n=>{e&&Ho(t,void 0,Wt(t)?t.table.options.isMultiSortEvent?.(n):!1)}}o(fs,"column_getToggleSortingHandler");function ps(){return t=>Mt({feature:"coreRowModelsFeature",table:t,fnName:"table.getCoreRowModel",memoDeps:o(()=>[t.options.data],"memoDeps"),fn:o(()=>hc(t,t.options.data),"fn"),onAfterUpdate:In(()=>{cs(t),Nn(t),ds(t),is(t)})})}o(ps,"createCoreRowModel");function bs(t,e,n,l=0,r){let s=[];for(let a=0;a<n.length;a++){let c=n[a],u=os(t,t.getRowId(c,a,r),c,a,l,void 0,r?.id);e.flatRows.push(u),e.rowsById[u.id]=u,s.push(u),t.options.getSubRows&&(u.originalSubRows=t.options.getSubRows(c,a),u.originalSubRows?.length&&(u.subRows=bs(t,e,u.originalSubRows,l+1,u)))}return s}o(bs,"accessRows");function hc(t,e){let n={rows:[],flatRows:[],rowsById:H()};return n.rows=bs(t,n,e),n}o(hc,"_createCoreRowModel");function hs(t){return t._rowModels.coreRowModel||(t._rowModels.coreRowModel=t.options.features.coreRowModel?.(t)??ps()(t)),t._rowModels.coreRowModel()}o(hs,"table_getCoreRowModel");function ws(t){return t.getCoreRowModel()}o(ws,"table_getPreFilteredRowModel");function xs(t){return t._rowModels.filteredRowModel||(t._rowModels.filteredRowModel=t.options.features.filteredRowModel?.(t)),t.options.manualFiltering||!t._rowModels.filteredRowModel?t.getPreFilteredRowModel():t._rowModels.filteredRowModel()}o(xs,"table_getFilteredRowModel");function Ss(t){return t.getFilteredRowModel()}o(Ss,"table_getPreGroupedRowModel");function _s(t){return t._rowModels.groupedRowModel||(t._rowModels.groupedRowModel=t.options.features.groupedRowModel?.(t)),t.options.manualGrouping||!t._rowModels.groupedRowModel?t.getPreGroupedRowModel():t._rowModels.groupedRowModel()}o(_s,"table_getGroupedRowModel");function Cs(t){return t.getGroupedRowModel()}o(Cs,"table_getPreSortedRowModel");function vs(t){return t._rowModels.sortedRowModel||(t._rowModels.sortedRowModel=t.options.features.sortedRowModel?.(t)),t.options.manualSorting||!t._rowModels.sortedRowModel?t.getPreSortedRowModel():t._rowModels.sortedRowModel()}o(vs,"table_getSortedRowModel");function ys(t){return t.getSortedRowModel()}o(ys,"table_getPreExpandedRowModel");function Rs(t){return t._rowModels.expandedRowModel||(t._rowModels.expandedRowModel=t.options.features.expandedRowModel?.(t)),t.options.manualExpanding||!t._rowModels.expandedRowModel?t.getPreExpandedRowModel():t._rowModels.expandedRowModel()}o(Rs,"table_getExpandedRowModel");function Is(t){return t.getExpandedRowModel()}o(Is,"table_getPrePaginatedRowModel");function Fs(t){return t._rowModels.paginatedRowModel||(t._rowModels.paginatedRowModel=t.options.features.paginatedRowModel?.(t)),t.options.manualPagination||!t._rowModels.paginatedRowModel?t.getPrePaginatedRowModel():t._rowModels.paginatedRowModel()}o(Fs,"table_getPaginatedRowModel");function Ms(t){return t.getPaginatedRowModel()}o(Ms,"table_getRowModel");var ks={constructTableAPIs:o(t=>{pe("coreRowModelsFeature",t,{table_getCoreRowModel:{fn:o(()=>hs(t),"fn")},table_getPreFilteredRowModel:{fn:o(()=>ws(t),"fn")},table_getFilteredRowModel:{fn:o(()=>xs(t),"fn")},table_getPreGroupedRowModel:{fn:o(()=>Ss(t),"fn")},table_getGroupedRowModel:{fn:o(()=>_s(t),"fn")},table_getPreSortedRowModel:{fn:o(()=>Cs(t),"fn")},table_getSortedRowModel:{fn:o(()=>vs(t),"fn")},table_getPreExpandedRowModel:{fn:o(()=>ys(t),"fn")},table_getExpandedRowModel:{fn:o(()=>Rs(t),"fn")},table_getPrePaginatedRowModel:{fn:o(()=>Is(t),"fn")},table_getPaginatedRowModel:{fn:o(()=>Fs(t),"fn")},table_getRowModel:{fn:o(()=>Ms(t),"fn")}})},"constructTableAPIs")};function wc(t){if(!t._cellPrototype){t._cellPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignCellPrototype?.(t._cellPrototype,t)}return t._cellPrototype}o(wc,"getCellPrototype");function Ps(t,e,n){let l=wc(n),r=Object.create(l);r.column=t,r.id=`${e.id}_${t.id}`,r.row=e;let s=n._cellInstanceInitFns;for(let a=0;a<s.length;a++)s[a](r);return r}o(Ps,"constructCell");function Ns(t){let e=t.table.getRowsInDisplayOrder(),n=t._displayIndexCache;return e[n]===t?n:-1}o(Ns,"row_getDisplayIndex");function Ds(t){let e=t.getPrePaginatedRowModel().rows;if(t.options.paginateExpandedRows===!1){let n=[],l=o(r=>{r._displayIndexCache=n.length,n.push(r),r.subRows.length&&r.getIsExpanded?.()&&r.subRows.forEach(l)},"handleRow");return e.forEach(l),n}for(let n=0;n<e.length;n++)e[n]._displayIndexCache=n;return e}o(Ds,"table_getRowsInDisplayOrder");function Ts(t,e){if(je(t._valuesCache,e))return t._valuesCache[e];let n=t.table.getColumn(e);if(n?.accessorFn)return t._valuesCache[e]=n.accessorFn(t.original,t.index),t._valuesCache[e]}o(Ts,"row_getValue");function As(t,e){if(je(t._uniqueValuesCache,e))return t._uniqueValuesCache[e];let n=t.table.getColumn(e);if(n?.accessorFn)return n.columnDef.getUniqueValues?(t._uniqueValuesCache[e]=n.columnDef.getUniqueValues(t.original,t.index),t._uniqueValuesCache[e]):(t._uniqueValuesCache[e]=[t.getValue(e)],t._uniqueValuesCache[e])}o(As,"row_getUniqueValues");function Os(t,e){return t.getValue(e)??t.table.options.renderFallbackValue}o(Os,"row_renderValue");function Es(t){return fl(t.subRows,e=>e.subRows)}o(Es,"row_getLeafRows");function Vs(t){let e=t.getCoreRowModel().flatRows,n=0;for(let l=0;l<e.length;l++)n=Math.max(n,e[l].depth);return n}o(Vs,"table_getMaxSubRowDepth");function zs(t){if(t.parentId)return t.table.getCoreRowModel().rowsById[t.parentId]??t.table.getRow(t.parentId,!0)}o(zs,"row_getParentRow");function $s(t){let e=[],n=t;for(;;){let l=n.getParentRow();if(!l)break;e.push(l),n=l}return e.reverse()}o($s,"row_getParentRows");function Hs(t){let e=t.table.getAllLeafColumns(),n=t._cellsCache;n||(n=t._cellsCache=new WeakMap);let l=new Array(e.length);for(let r=0;r<e.length;r++){let s=e[r],a=n.get(s);a||(a=Ps(s,t,t.table),n.set(s,a)),l[r]=a}return l}o(Hs,"row_getAllCells");function Ls(t){let e=H(),n=t.getAllCells();for(let l=0;l<n.length;l++){let r=n[l];e[r.column.id]=r}return e}o(Ls,"row_getAllCellsByColumnId");function js(t,e,n,l){return e.options.getRowId?.(t,n,l)??(l?`${l.id}.${n}`:String(n))}o(js,"table_getRowId");function Bs(t,e,n){let l=(n?t.getPrePaginatedRowModel():t.getRowModel()).rowsById[e];if(!l&&(l=t.getCoreRowModel().rowsById[e],!l))throw new Error;return l}o(Bs,"table_getRow");var Gs={assignRowPrototype:o((t,e)=>{ue("coreRowsFeature",t,e,{row_getDisplayIndex:{fn:o(n=>Ns(n),"fn")},row_getAllCellsByColumnId:{fn:o(n=>Ls(n),"fn"),memoDeps:o(n=>[n.getAllCells()],"memoDeps")},row_getAllCells:{fn:o(n=>Hs(n),"fn"),memoDeps:o(n=>[n.table.getAllLeafColumns()],"memoDeps")},row_getLeafRows:{fn:o(n=>Es(n),"fn"),memoDeps:o(n=>[n.subRows],"memoDeps")},row_getParentRow:{fn:o(n=>zs(n),"fn")},row_getParentRows:{fn:o(n=>$s(n),"fn")},row_getUniqueValues:{fn:o((n,l)=>As(n,l),"fn")},row_getValue:{fn:o((n,l)=>Ts(n,l),"fn")},row_renderValue:{fn:o((n,l)=>Os(n,l),"fn")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{pe("coreRowsFeature",t,{table_getRowsInDisplayOrder:{fn:o(()=>Ds(t),"fn"),memoDeps:o(()=>[t.getPrePaginatedRowModel().rows,t.options.paginateExpandedRows,t.options.paginateExpandedRows===!1?t.atoms.expanded?.get():void 0],"memoDeps")},table_getRowId:{fn:o((e,n,l)=>js(e,t,n,l),"fn")},table_getRow:{fn:o((e,n)=>Bs(t,e,n),"fn")},table_getMaxSubRowDepth:{fn:o(()=>Vs(t),"fn"),memoDeps:o(()=>[t.getCoreRowModel()],"memoDeps")}})},"constructTableAPIs")};function Tn(t,e,n=(l,r)=>l===r){let l=e===void 0?t.options.state:e;t._reactivity.batch(()=>{if(l)for(let r in l){let s=t.baseAtoms[r];if(!s)continue;let a=l[r],c=a===void 0?t.initialState[r]:a;n(t._reactivity.untrack(()=>s.get()),c)||s.set(()=>c)}})}o(Tn,"table_syncExternalStateToBaseAtoms");function An(t,e,n=(l,r)=>l===r){t._reactivity.batch(()=>{Tn(t,e,n),t._reactivity.commit?.()})}o(An,"table_publishExternalState");function Go(t){let e=ae(t.initialState);t._reactivity.batch(()=>{let l=Object.keys(e);for(let r=0;r<l.length;r++){let s=l[r];t.baseAtoms[s].set(e[s])}});let n=Object.values(t._features);for(let l=0;l<n.length;l++)n[l].resetTableInstanceData?.(t)}o(Go,"table_reset");function qs(t,e){let{features:n,atoms:l,initialState:r}=t.options;if(!t.options.mergeOptions)return{...t.options,...e,features:n,atoms:l,initialState:r};let s=t.options.mergeOptions(t.options,e),a={...Object.getOwnPropertyDescriptors(s)};return Object.defineProperties(Object.create(Object.getPrototypeOf(s)),{...a,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:l,enumerable:!0,configurable:!0,writable:!0},initialState:{value:r,enumerable:!0,configurable:!0,writable:!0}})}o(qs,"table_mergeOptions");function Yt(t,e,n){let l=qs(t,Ft(e,t.options));t.optionsStore?t.optionsStore.set(()=>l):t.options=l,n?.syncExternalState!==!1&&An(t,l.state??null)}o(Yt,"table_setOptions");var Ks={constructTableAPIs:o(t=>{pe("coreTablesFeature",t,{table_reset:{fn:o(()=>Go(t),"fn")},table_setOptions:{fn:o(e=>Yt(t,e),"fn")}})},"constructTableAPIs")};var Us={coreCellsFeature:xl,coreColumnsFeature:Jl,coreHeadersFeature:ns,coreRowModelsFeature:ks,coreRowsFeature:Gs,coreTablesFeature:Ks};function Js(t,e={}){return Object.values(t).forEach(n=>{e=n.getInitialState?.(e)??e}),ae(e)}o(Js,"getInitialTableState");function qo(t){let e=t.features.coreReactivityFeature,{aggregationFns:n,columnMeta:l,coreRowModel:r,expandedRowModel:s,facetedMinMaxValues:a,facetedRowModel:c,facetedUniqueValues:u,filterFns:i,filterMeta:d,filteredRowModel:m,groupedRowModel:g,paginatedRowModel:b,sortFns:f,sortedRowModel:h,tableMeta:w,..._}=t.features,S={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...Us,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:e,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:i,sortFns:f},_rowModels:{},atoms:{},baseAtoms:{}},y=Object.values(S._features),I={...y.reduce((R,x)=>Object.assign(R,x.getDefaultTableOptions?.(S)),{}),...t};if(e.wrapExternalAtoms&&I.atoms)for(let[R,x]of Object.entries(I.atoms)){let v=x,M=e.createWritableAtom(v.get(),{debugName:`externalAtom/${R}`});I.atoms[R]=M;let F=!1,P=v.subscribe(N=>{F||M.set(N)}),k=M.subscribe(N=>{F=!0,v.set(N),F=!1});e.addSubscription(P),e.addSubscription(k)}e.createOptionsStore?(S.optionsStore=e.createWritableAtom(I,{debugName:"table/optionsStore"}),Object.defineProperty(S,"options",{configurable:!0,enumerable:!0,get(){return S.optionsStore.get()},set(R){S.optionsStore.set(()=>R)}})):S.options=I,S.initialState=Js(S._features,S.options.initialState);let C=Object.keys(S.initialState);for(let R=0;R<C.length;R++){let x=C[R];S.baseAtoms[x]=e.createWritableAtom(S.initialState[x],{debugName:`table/baseAtoms/${x}`}),S.atoms[x]=e.createReadonlyAtom(()=>{let v=S.options,M=v.atoms?.[x],F=M?M.get():S.baseAtoms[x].get();if(M)return F;let P=v.state;if(P&&je(P,x)){let k=P[x];return k===void 0?S.initialState[x]:k}return F},{debugName:`table/atoms/${x}`})}Tn(S),S.store=il(e.createReadonlyAtom(()=>{let R={};for(let x=0;x<C.length;x++){let v=C[x];R[v]=S.atoms[v].get()}return R},{compare:lt,debugName:"table/store"}));for(let R=0;R<y.length;R++){let x=y[R];x.initTableInstanceData?.(S),x.initCellInstanceData&&S._cellInstanceInitFns.push(x.initCellInstanceData.bind(x)),x.initColumnInstanceData&&S._columnInstanceInitFns.push(x.initColumnInstanceData.bind(x)),x.initHeaderGroupInstanceData&&S._headerGroupInstanceInitFns.push(x.initHeaderGroupInstanceData.bind(x)),x.initHeaderInstanceData&&S._headerInstanceInitFns.push(x.initHeaderInstanceData.bind(x)),x.initRowInstanceData&&S._rowInstanceInitFns.push(x.initRowInstanceData.bind(x)),x.constructTableAPIs?.(S)}return S}o(qo,"constructTable");var Ko={getInitialState:o(t=>({columnOrder:Tl(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onColumnOrderChange:Be("columnOrder",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ue("columnOrderingFeature",t,e,{column_getIndex:{fn:o((n,l)=>Al(n,l),"fn")},column_getIsFirstColumn:{fn:o((n,l)=>Ol(n,l),"fn")},column_getIsLastColumn:{fn:o((n,l)=>El(n,l),"fn")}})},"assignColumnPrototype"),constructTableAPIs:o(t=>{pe("columnOrderingFeature",t,{table_getColumnIndexes:{fn:o(()=>ko(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnOrder?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")},table_setColumnOrder:{fn:o(e=>Po(t,e),"fn")},table_resetColumnOrder:{fn:o(e=>Vl(t,e),"fn")},table_getOrderColumnsFn:{fn:o(()=>Jt(t),"fn"),memoDeps:o(()=>[t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")}})},"constructTableAPIs")};function Ws(){return H()}o(Ws,"getDefaultColumnSizingState");function Uo(){return{size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER}}o(Uo,"getDefaultColumnSizingColumnDef");function Pt(t){let e=Uo(),n=t.table.atoms.columnSizing?.get(),l=n&&je(n,t.id)?n[t.id]:void 0;return Math.min(Math.max(t.columnDef.minSize??e.minSize,l??t.columnDef.size??e.size),t.columnDef.maxSize??e.maxSize)}o(Pt,"column_getSize");function On(t){let e=H(),n=H(),l=new Array(t.length),r=0;for(let a=0;a<t.length;a++){let c=t[a],u=V(c,"getSize",Pt);l[a]=u,e[c.id]=r,r+=u}let s=0;for(let a=t.length-1;a>=0;a--)n[t[a].id]=s,s+=l[a];return{starts:e,afters:n}}o(On,"buildColumnOffsets");function En(t){return{all:On(Ge(t)),center:On(Ge(t,"center")),start:On(Ge(t,"start")),end:On(Ge(t,"end"))}}o(En,"table_getColumnOffsets");function Qs(t){return t==="start"?"start":t==="end"?"end":t==="center"?"center":"all"}o(Qs,"toOffsetsKey");function Xs(t,e){return V(t.table,"getColumnOffsets",En)[Qs(e)].starts[t.id]??0}o(Xs,"column_getStart");function Ys(t,e){return V(t.table,"getColumnOffsets",En)[Qs(e)].afters[t.id]??0}o(Ys,"column_getAfter");function Zs(t){Nt(t.table,e=>{let n=H(),l=Object.keys(e);for(let r=0;r<l.length;r++){let s=l[r];s!==t.id&&(n[s]=e[s])}return n})}o(Zs,"column_resetSize");function ea(t){if(!t.subHeaders.length)return Pt(t.column);let e=0;for(let n=0;n<t.subHeaders.length;n++)e+=ea(t.subHeaders[n]);return e}o(ea,"sumHeaderSize");function st(t){return ea(t)}o(st,"header_getSize");function Jo(t){if(t.index>0){let e=t.headerGroup?.headers[t.index-1];if(e)return V(e,"getStart",Jo)+V(e,"getSize",st)}return 0}o(Jo,"header_getStart");function Nt(t,e){t.options.onColumnSizingChange?.(e)}o(Nt,"table_setColumnSizing");function ta(t,e){Nt(t,e?H():Object.assign(H(),ae(t.initialState.columnSizing??{})))}o(ta,"table_resetColumnSizing");function na(t){return t.getHeaderGroups()[0]?.headers.reduce((e,n)=>e+st(n),0)??0}o(na,"table_getTotalSize");function oa(t){return V(t,"getStartHeaderGroups",Sl)[0]?.headers.reduce((e,n)=>e+st(n),0)??0}o(oa,"table_getStartTotalSize");function ra(t){return V(t,"getCenterHeaderGroups",Cl)[0]?.headers.reduce((e,n)=>e+st(n),0)??0}o(ra,"table_getCenterTotalSize");function la(t){return V(t,"getEndHeaderGroups",_l)[0]?.headers.reduce((e,n)=>e+st(n),0)??0}o(la,"table_getEndTotalSize");function zn(){return{startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}}o(zn,"getDefaultColumnResizingState");function Qo(t){return(t.columnDef.enableResizing??!0)&&(t.table.options.enableColumnResizing??!0)}o(Qo,"column_getCanResize");function sa(t){return t.table.atoms.columnResizing?.get()?.isResizingColumn===t.id}o(sa,"column_getIsResizing");function aa(t,e){let n=t.table.getColumn(t.column.id),l=Qo(n);return r=>{if(!l||Wo(r)&&r.touches.length>1)return;let s=st(t),a=t.getLeafHeaders().map(C=>[C.column.id,Pt(C.column)]),c=Wo(r)?Math.round(r.touches[0].clientX):r.clientX,u=H(),i=o((C,R)=>{if(typeof R!="number")return;let x=n.table,v=x.options.columnResizeMode==="onChange"||C==="end";x._reactivity.batch(()=>{Dt(x,M=>{let F=x.options.columnResizeDirection==="rtl"?-1:1,P=(R-(M.startOffset??0))*F,k=M.startSize??0,N=Math.max(k>0?P/k:0,-.999999);if(v){let T=M.columnSizingStart;for(let z=0;z<T.length;z++){let A=T[z],$=A[1];u[A[0]]=Math.round(Math.max($>0?$+$*N:P/T.length,0)*100)/100}}return{...M,deltaOffset:P,deltaPercentage:N}}),v&&Nt(x,M=>Object.assign(H(),M,u))})},"updateOffset"),d=null,m=!1,g,b=o(()=>{m?(m=!1,i("move",g),d=requestAnimationFrame(b)):d=null},"flushMove"),f=o(C=>{if(g=C,typeof requestAnimationFrame!="function"){i("move",C);return}if(d!==null){m=!0;return}i("move",C),d=requestAnimationFrame(b)},"onMove"),h=o(C=>{d!==null&&(cancelAnimationFrame(d),d=null,m=!1),n.table._reactivity.batch(()=>{i("end",C??g),Dt(n.table,R=>({...R,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))})},"onEnd"),w=e||(typeof document<"u"?document:null),_={moveHandler:o(C=>f(C.clientX),"moveHandler"),upHandler:o(C=>{w?.removeEventListener("mousemove",_.moveHandler),w?.removeEventListener("mouseup",_.upHandler),h(C.clientX)},"upHandler")},S={moveHandler:o(C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),f(C.touches[0].clientX),!1),"moveHandler"),upHandler:o(C=>{y(),C.cancelable&&(C.preventDefault(),C.stopPropagation()),h(C.touches[0]?.clientX)},"upHandler"),cancelHandler:o(()=>{y(),h()},"cancelHandler")},y=o(()=>{w?.removeEventListener("touchmove",S.moveHandler),w?.removeEventListener("touchend",S.upHandler),w?.removeEventListener("touchcancel",S.cancelHandler)},"removeTouchEvents"),I=xc()?{passive:!1}:!1;Wo(r)?(w?.addEventListener("touchmove",S.moveHandler,I),w?.addEventListener("touchend",S.upHandler,I),w?.addEventListener("touchcancel",S.cancelHandler,I)):(w?.addEventListener("mousemove",_.moveHandler,I),w?.addEventListener("mouseup",_.upHandler,I)),Dt(n.table,C=>({...C,startOffset:c,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:n.id}))}}o(aa,"header_getResizeHandler");function Dt(t,e){t.options.onColumnResizingChange?.(e)}o(Dt,"table_setColumnResizing");function ia(t,e){Dt(t,e?zn():ae(t.initialState.columnResizing??zn()))}o(ia,"table_resetHeaderSizeInfo");var Vn=null;function xc(){if(typeof Vn=="boolean")return Vn;let t=!1;try{let e={get passive(){return t=!0,!1}},n=o(()=>{},"noop");window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return Vn=t,Vn}o(xc,"passiveEventSupported");function Wo(t){return t.type==="touchstart"}o(Wo,"isTouchStartEvent");var Xo={getInitialState:o(t=>({columnResizing:zn(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnResizingChange:Be("columnResizing",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ue("columnResizingFeature",t,e,{column_getCanResize:{fn:o(n=>Qo(n),"fn")},column_getIsResizing:{fn:o(n=>sa(n),"fn")}})},"assignColumnPrototype"),assignHeaderPrototype:o((t,e)=>{ue("columnResizingFeature",t,e,{header_getResizeHandler:{fn:o((n,l)=>aa(n,l),"fn")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{pe("columnResizingFeature",t,{table_setColumnResizing:{fn:o(e=>Dt(t,e),"fn")},table_resetHeaderSizeInfo:{fn:o(e=>ia(t,e),"fn")}})},"constructTableAPIs")};var Yo={getInitialState:o(t=>({columnSizing:Ws(),...t}),"getInitialState"),getDefaultColumnDef:o(()=>Uo(),"getDefaultColumnDef"),getDefaultTableOptions:o(t=>({onColumnSizingChange:Be("columnSizing",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ue("columnSizingFeature",t,e,{column_getSize:{fn:o(n=>Pt(n),"fn"),memoDeps:o(n=>[e.options.columns,e.atoms.columnSizing?.get()?.[n.id]],"memoDeps")},column_getStart:{fn:o((n,l)=>Xs(n,l),"fn")},column_getAfter:{fn:o((n,l)=>Ys(n,l),"fn")},column_resetSize:{fn:o(n=>Zs(n),"fn")}})},"assignColumnPrototype"),assignHeaderPrototype:o((t,e)=>{ue("columnSizingFeature",t,e,{header_getSize:{fn:o(n=>st(n),"fn"),memoDeps:o(n=>[e.options.columns,n.column.columns.length>0?e.atoms.columnSizing?.get():e.atoms.columnSizing?.get()?.[n.column.id]],"memoDeps")},header_getStart:{fn:o(n=>Jo(n),"fn"),memoDeps:o(()=>[e.options.columns,e.atoms.columnSizing?.get(),e.atoms.columnOrder?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode],"memoDeps")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{pe("columnSizingFeature",t,{table_getColumnOffsets:{fn:o(()=>En(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnSizing?.get(),t.atoms.columnOrder?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")},table_setColumnSizing:{fn:o(e=>Nt(t,e),"fn")},table_resetColumnSizing:{fn:o(e=>ta(t,e),"fn")},table_getTotalSize:{fn:o(()=>na(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getStartTotalSize:{fn:o(()=>oa(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getCenterTotalSize:{fn:o(()=>ra(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getEndTotalSize:{fn:o(()=>la(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")}})},"constructTableAPIs")};var Zo={getInitialState:o(t=>({columnVisibility:vl(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onColumnVisibilityChange:Be("columnVisibility",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ue("columnVisibilityFeature",t,e,{column_getIsVisible:{fn:o(n=>de(n),"fn"),memoDeps:o(n=>[e.options.columns,e.atoms.columnVisibility?.get(),n.columns],"memoDeps")},column_getCanHide:{fn:o(n=>Kt(n),"fn")},column_getToggleVisibilityHandler:{fn:o(n=>yl(n),"fn")},column_toggleVisibility:{fn:o((n,l)=>Io(n,l),"fn")}})},"assignColumnPrototype"),assignRowPrototype:o((t,e)=>{ue("columnVisibilityFeature",t,e,{row_getVisibleCells:{fn:o(n=>Ro(n),"fn"),memoDeps:o(n=>[n.getAllCells(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get()],"memoDeps")},row_getVisibleCellsByColumnId:{fn:o(n=>Fn(n),"fn"),memoDeps:o(n=>[n.getAllCells(),e.atoms.columnVisibility?.get()],"memoDeps")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{pe("columnVisibilityFeature",t,{table_getVisibleFlatColumns:{fn:o(()=>Rl(t),"fn"),memoDeps:o(()=>[t.atoms.columnVisibility?.get(),t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_getVisibleLeafColumns:{fn:o(()=>xt(t),"fn"),memoDeps:o(()=>[t.atoms.columnVisibility?.get(),t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_setColumnVisibility:{fn:o(e=>Ut(t,e),"fn")},table_resetColumnVisibility:{fn:o(e=>Il(t,e),"fn")},table_toggleAllColumnsVisible:{fn:o(e=>Fo(t,e),"fn")},table_getIsAllColumnsVisible:{fn:o(()=>Mo(t),"fn")},table_getIsSomeColumnsVisible:{fn:o(()=>Fl(t),"fn")},table_getToggleAllColumnsVisibilityHandler:{fn:o(()=>Ml(t),"fn")}})},"constructTableAPIs")};function ca(){return H()}o(ca,"getDefaultRowSelectionState");function Ct(t,e){t.options.onRowSelectionChange?.(e)}o(Ct,"table_setRowSelection");function ua(t,e){t._lastSelectedRowId=null,Ct(t,e?H():Object.assign(H(),ae(t.initialState.rowSelection??{})))}o(ua,"table_resetRowSelection");function er(t,e,n){t._lastSelectedRowId=null,Ct(t,l=>{if(e=typeof e<"u"?e:!V(t,"getIsAllRowsSelected",or),n?.deselectAll&&!e)return H();let r=Object.assign(H(),l),s=t.getPreGroupedRowModel().flatRows;if(e){let a=new Map;s.forEach(c=>{$n(c,a)&&(r[c.id]=!0)})}else s.forEach(a=>{Ye(a)&&delete r[a.id]});return r})}o(er,"table_toggleAllRowsSelected");function tr(t,e,n){t._lastSelectedRowId=null,Ct(t,l=>{let r=typeof e<"u"?e:!V(t,"getIsAllPageRowsSelected",rr);if(n?.deselectAll&&!r)return H();let s=Object.assign(H(),l);return t.getRowModel().rows.forEach(a=>{jn(s,a.id,r,!0,t,!0)}),s})}o(tr,"table_toggleAllPageRowsSelected");function da(t){return t.getCoreRowModel()}o(da,"table_getPreSelectedRowModel");function ma(t){let e=t.getCoreRowModel();return V(t,"getIsSomeRowsSelected",Zt)?ar(e,t):{rows:[],flatRows:[],rowsById:H()}}o(ma,"table_getSelectedRowModel");function ga(t){let e=t.getFilteredRowModel();return V(t,"getIsSomeRowsSelected",Zt)?ar(e,t):{rows:[],flatRows:[],rowsById:H()}}o(ga,"table_getFilteredSelectedRowModel");function fa(t){let e=t.getSortedRowModel();return V(t,"getIsSomeRowsSelected",Zt)?ar(e,t):{rows:[],flatRows:[],rowsById:H()}}o(fa,"table_getGroupedSelectedRowModel");function nr(t){return Object.keys(t.atoms.rowSelection?.get()??{})}o(nr,"table_getSelectedRowIds");function or(t){let e=t.getFilteredRowModel().flatRows,n=t.atoms.rowSelection?.get()??{},l=!!(e.length&&Object.keys(n).length);if(l){let r=new Map;e.some(s=>!en(s,n)&&$n(s,r))&&(l=!1)}return l}o(or,"table_getIsAllRowsSelected");function rr(t){let e=t.getPaginatedRowModel().flatRows,n=t.atoms.rowSelection?.get()??{},l=new Map,r=!1;for(let s=0;s<e.length;s++){let a=e[s];if(en(a,n))!r&&$n(a,l)&&(r=!0);else if($n(a,l))return!1}return r}o(rr,"table_getIsAllPageRowsSelected");function Zt(t){return V(t,"getSelectedRowIds",nr).length>0}o(Zt,"table_getIsSomeRowsSelected");function pa(t){return t.getPaginatedRowModel().flatRows.filter(e=>Ye(e)).some(e=>Hn(e)||V(e,"getIsSomeSelected",sr))}o(pa,"table_getIsSomePageRowsSelected");function ba(t){return e=>{er(t,e.target.checked)}}o(ba,"table_getToggleAllRowsSelectedHandler");function ha(t){return e=>{tr(t,e.target.checked)}}o(ha,"table_getToggleAllPageRowsSelectedHandler");function lr(t,e,n){let l=Hn(t);Ct(t.table,r=>{e=typeof e<"u"?e:!l;let s=Object.assign(H(),r);return jn(s,t.id,e,(n?.selectChildren??!0)&&mt(t),t.table),!e&&n?.deselectParents&&Sa(s,t),s})}o(lr,"row_toggleSelected");function Hn(t){return en(t,t.table.atoms.rowSelection?.get()??{})}o(Hn,"row_getIsSelected");function sr(t){return ir(t)==="some"}o(sr,"row_getIsSomeSelected");function wa(t){return ir(t)==="all"}o(wa,"row_getIsAllSubRowsSelected");function Ye(t){let e=t.table.options;return typeof e.enableRowSelection=="function"?e.enableRowSelection(t):e.enableRowSelection??!0}o(Ye,"row_getCanSelect");function Ln(t){let e=t.table.options;return typeof e.enableSubRowSelection=="function"?e.enableSubRowSelection(t):e.enableSubRowSelection??!0}o(Ln,"row_getCanSelectSubRows");function mt(t){let e=t.table.options;return typeof e.enableMultiRowSelection=="function"?e.enableMultiRowSelection(t):e.enableMultiRowSelection??!0}o(mt,"row_getCanMultiSelect");function xa(t,e){let n=Ye(t);return l=>{if(!n)return;let r=l,s=t.table,a=r.target.checked,c=s._lastSelectedRowId;(!(s.options.enableRowRangeSelection!==!1&&c!==null&&mt(t)&&(s.options.isRowRangeSelectionEvent?.(l)??!1))||!Sc(t,c,a,e))&&lr(t,a,e),s._lastSelectedRowId=t.id}}o(xa,"row_getToggleSelectedHandler");function Sc(t,e,n,l){let r=l?.selectChildren??!0,s=t.table,a=s.getRowsInDisplayOrder(),c=s.getPrePaginatedRowModel().rowsById[e]??s.getCoreRowModel().rowsById[e];if(!c)return!1;let u=c.getDisplayIndex(),i=t.getDisplayIndex(),d=a[u],m=a[i];if(u<0||i<0||u>=a.length||i>=a.length||d?.id!==c.id||m?.id!==t.id||!mt(c)||!mt(t))return!1;let g=Math.min(u,i),b=Math.max(u,i);return Ct(s,f=>{let h=Object.assign(H(),f);for(let w=g;w<=b;w++){let _=a[w];!Ye(_)||!mt(_)||(jn(h,_.id,n,r,s),!n&&l?.deselectParents&&Sa(h,_))}return h}),!0}o(Sc,"selectRowRange");function jn(t,e,n,l,r,s){let a=r.getRow(e,!0);n?(mt(a)||Object.keys(t).forEach(c=>delete t[c]),Ye(a)&&(t[e]=!0)):(!s||Ye(a))&&delete t[e],l&&a.subRows.length&&Ln(a)&&a.subRows.forEach(c=>jn(t,c.id,n,l,r,s))}o(jn,"mutateRowIsSelected");function $n(t,e){if(!Ye(t))return!1;let n=t.table;if(n.options.enableSubRowSelection===!0)return!0;let l=t.parentId;if(l===void 0)return!0;let r=e.get(l);if(r!==void 0)return r;let s=n.getCoreRowModel().rowsById,a=[],c=!0,u=l;for(;u!==void 0;){let i=e.get(u);if(i!==void 0){c=i;break}a.push(u);let d=s[u]??n.getRow(u,!0);if(!Ln(d)){c=!1;break}u=d.parentId}return a.forEach(i=>e.set(i,c)),c}o($n,"isRowSelectableInSelectAll");function Sa(t,e){let n=e.table.getCoreRowModel().rowsById,l=e.parentId;for(;l!==void 0;)delete t[l],l=(n[l]??e.table.getRow(l,!0)).parentId}o(Sa,"pruneAncestorRowIds");function _a(t,e,n,l){let r=[];for(let s=0;s<t.length;s++){let a=t[s],c=en(a,e);if(c&&(n.push(a),l[a.id]=a),a.subRows.length){let u=_a(a.subRows,e,n,l);if(c){let i=Object.create(Object.getPrototypeOf(a));Rn(i,a),i.subRows=u,r.push(i)}}else c&&r.push(a)}return r}o(_a,"selectRowsRecursively");function ar(t,e){let n=[],l=H(),r=e.atoms.rowSelection?.get()??{};return{rows:_a(t.rows,r,n,l),flatRows:n,rowsById:l}}o(ar,"selectRowsFn");function en(t,e){return!!(je(e,t.id)&&e[t.id])}o(en,"isRowSelected");function ir(t){if(!t.subRows.length)return!1;let e=t.table.atoms.rowSelection?.get()??{},n=!1,l=!0,r=!1;for(let s=0;s<t.subRows.length;s++){let a=t.subRows[s];if(n&&!l)break;if(Ye(a)&&(r=!0,en(a,e)?n=!0:l=!1),a.subRows.length){let c=ir(a);c==="all"?(n=!0,r=!0):c==="some"?(n=!0,l=!1,r=!0):l=!1}}return r?l?"all":n?"some":!1:!1}o(ir,"isSubRowSelected");var cr={initTableInstanceData:o(t=>{t._lastSelectedRowId=null},"initTableInstanceData"),resetTableInstanceData:o(t=>{t._lastSelectedRowId=null},"resetTableInstanceData"),getInitialState:o(t=>({rowSelection:ca(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onRowSelectionChange:Be("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:o(e=>{let n=e;return!!(n.shiftKey||n.nativeEvent?.shiftKey)},"isRowRangeSelectionEvent")}),"getDefaultTableOptions"),assignRowPrototype:o((t,e)=>{ue("rowSelectionFeature",t,e,{row_toggleSelected:{fn:o((n,l,r)=>lr(n,l,r),"fn")},row_getIsSelected:{fn:o(n=>Hn(n),"fn")},row_getIsSomeSelected:{fn:o(n=>sr(n),"fn"),memoDeps:o(n=>[n.subRows,n.table.atoms.rowSelection?.get(),n.table.options.enableRowSelection],"memoDeps")},row_getIsAllSubRowsSelected:{fn:o(n=>wa(n),"fn"),memoDeps:o(n=>[n.subRows,n.table.atoms.rowSelection?.get(),n.table.options.enableRowSelection],"memoDeps")},row_getCanSelect:{fn:o(n=>Ye(n),"fn")},row_getCanSelectSubRows:{fn:o(n=>Ln(n),"fn")},row_getCanMultiSelect:{fn:o(n=>mt(n),"fn")},row_getToggleSelectedHandler:{fn:o((n,l)=>xa(n,l),"fn")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{pe("rowSelectionFeature",t,{table_setRowSelection:{fn:o(e=>Ct(t,e),"fn")},table_resetRowSelection:{fn:o(e=>ua(t,e),"fn")},table_toggleAllRowsSelected:{fn:o((e,n)=>er(t,e,n),"fn")},table_toggleAllPageRowsSelected:{fn:o((e,n)=>tr(t,e,n),"fn")},table_getPreSelectedRowModel:{fn:o(()=>da(t),"fn")},table_getSelectedRowModel:{fn:o(()=>ma(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getCoreRowModel()],"memoDeps")},table_getFilteredSelectedRowModel:{fn:o(()=>ga(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getFilteredRowModel()],"memoDeps")},table_getGroupedSelectedRowModel:{fn:o(()=>fa(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getSortedRowModel()],"memoDeps")},table_getSelectedRowIds:{fn:o(()=>nr(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get()],"memoDeps")},table_getIsAllRowsSelected:{fn:o(()=>or(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getFilteredRowModel(),t.options.enableRowSelection,t.options.enableSubRowSelection],"memoDeps")},table_getIsAllPageRowsSelected:{fn:o(()=>rr(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getPaginatedRowModel(),t.options.enableRowSelection,t.options.enableSubRowSelection],"memoDeps")},table_getIsSomeRowsSelected:{fn:o(()=>Zt(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get()],"memoDeps")},table_getIsSomePageRowsSelected:{fn:o(()=>pa(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getPaginatedRowModel(),t.options.enableRowSelection],"memoDeps")},table_getToggleAllRowsSelectedHandler:{fn:o(()=>ba(t),"fn")},table_getToggleAllPageRowsSelectedHandler:{fn:o(()=>ha(t),"fn")}})},"constructTableAPIs")};var ur={getInitialState(t){return{sorting:us(),...t}},getDefaultColumnDef(){return{sortFn:"auto",sortUndefined:1}},getDefaultTableOptions(t){return{autoResetSorting:!1,onSortingChange:Be("sorting",t),isMultiSortEvent:o(e=>e.shiftKey,"isMultiSortEvent")}},assignColumnPrototype(t,e){ue("rowSortingFeature",t,e,{column_getAutoSortFn:{fn:o(n=>zo(n),"fn")},column_getAutoSortDir:{fn:o(n=>$o(n),"fn")},column_getSortFn:{fn:o(n=>Dn(n),"fn")},column_toggleSorting:{fn:o((n,l,r)=>Ho(n,l,r),"fn")},column_getFirstSortDir:{fn:o(n=>Lo(n),"fn")},column_getNextSortingOrder:{fn:o((n,l)=>jo(n,l),"fn")},column_getCanSort:{fn:o(n=>Xt(n),"fn")},column_getCanMultiSort:{fn:o(n=>Wt(n),"fn")},column_getIsSorted:{fn:o(n=>Bo(n),"fn")},column_getSortIndex:{fn:o(n=>ms(n),"fn")},column_clearSorting:{fn:o(n=>gs(n),"fn")},column_getToggleSortingHandler:{fn:o(n=>fs(n),"fn")}})},constructTableAPIs(t){pe("rowSortingFeature",t,{table_setSorting:{fn:o(e=>Qt(t,e),"fn")},table_resetSorting:{fn:o(e=>Vo(t,e),"fn")}})}};function dr(){return t=>{let e=t;return Mt({feature:"rowSortingFeature",table:e,fnName:"table.getSortedRowModel",memoDeps:o(()=>[e.atoms.sorting?.get(),e.getPreSortedRowModel()],"memoDeps"),fn:o(()=>_c(e),"fn"),onAfterUpdate:In(()=>Nn(e))})}}o(dr,"createSortedRowModel");function _c(t){let e=t.getPreSortedRowModel(),n=t.atoms.sorting?.get();if(!e.rows.length||!n?.length)return e;let l=[],r=n.filter(u=>{let i=t.getColumn(u.id);return i?Xt(i):!1});if(!r.length)return e;let s=[];for(let u=0;u<r.length;u++){let i=r[u],d=t.getColumn(i.id);d&&s.push({id:i.id,desc:i.desc,sortUndefined:d.columnDef.sortUndefined,invertSorting:d.columnDef.invertSorting,sortFn:Dn(d)})}let a=o((u,i)=>{for(let d=0;d<s.length;d++){let m=s[d],g=m.sortUndefined,b=m.desc,f=0;if(g){let h=u.getValue(m.id),w=i.getValue(m.id),_=h===void 0,S=w===void 0;if(_&&S)continue;if(_||S){if(g==="first")return _?-1:1;if(g==="last")return _?1:-1;f=_?g:-g}}if(f===0&&(f=m.sortFn(u,i,m.id)),f!==0)return b&&(f*=-1),m.invertSorting&&(f*=-1),f}return u.index-i.index},"compareRows"),c=o(u=>{let i=u.slice();i.sort(a);let d=!1;for(let m=0;m<i.length;m++){let g=i[m];g!==u[m]&&(d=!0);let b=l.length;if(l.push(g),g.subRows.length){let f=c(g.subRows);if(f.changed){let h=Object.create(Object.getPrototypeOf(g));Rn(h,g),h.subRows=f.rows,i[m]=h,l[b]=h,d=!0}}}return{rows:i,changed:d}},"sortData");return{rows:c(e.rows).rows,flatRows:l,rowsById:e.rowsById}}o(_c,"_createSortedRowModel");var gt=Re(ut(),1);var Cc=typeof window>"u"?gt.useEffect:gt.useLayoutEffect;function mr(t,e){let[{table:n,rootSource:l}]=(0,gt.useState)(()=>{let u=qo({...t,features:{coreReactivityFeature:cl(),...t.features}});return u.Subscribe=(i=>al({...i,source:i.source??u.store})),u.FlexRender=fo,{table:u,rootSource:vo(u.store,lt)}}),r=n;Yt(r,u=>({...u,...t}),{syncExternalState:!1});let s=r.options.state,a=l.get(),c=qt(l,e,{compare:lt});return Cc(()=>{l.markCommitted(a),An(r,s??null,lt)}),(0,gt.useMemo)(()=>({...n,options:t,state:c}),[n,t,c])}o(mr,"useTable");var va=Re(Ht(),1),ya=Re(ut(),1),Ie=Re(Lt(),1);var vc=[{label:"=",value:"eq"},{label:"\u2260",value:"ne"},{label:"<",value:"lt"},{label:"\u2264",value:"lte"},{label:">",value:"gt"},{label:"\u2265",value:"gte"},{label:"contains",value:"contains"}],yc=o(t=>{let e=t.trim(),n=Number(e);return e!==""&&Number.isFinite(n)&&String(n)===e?n:t},"$"),Rc=o(t=>t.operator==="contains"?t.value==="":t.operator!=="eq"&&t.operator!=="ne"&&t.literal===void 0&&t.value.trim()==="","z"),Ze=o(t=>t.filter(e=>e.column!==""&&!Rc(e)).map(e=>e.operator==="contains"?{column:e.column,operator:e.operator,value:e.value}:{column:e.column,operator:e.operator,value:e.literal===void 0?yc(e.value):e.literal[0]}),"L"),Ca=o((t,e)=>({column:t.column,operator:t.operator,value:t.value,...e}),"P"),Ra=o(t=>{let e=(0,va.c)(44),{columns:n,filters:l,onAskAi:r,onFiltersChange:s,onSearchChange:a,search:c}=t,[u,i]=(0,ya.useState)(""),d;e[0]!==n[0]||e[1]!==l||e[2]!==s?(d=o(()=>{s([...l,{column:n[0]??"",operator:"eq",value:""}])},"N"),e[0]=n[0],e[1]=l,e[2]=s,e[3]=d):d=e[3];let m=d,g;e[4]!==l||e[5]!==s?(g=o(F=>{let P=Number(F.currentTarget.dataset.index);s(l.filter((k,N)=>N!==P))},"T"),e[4]=l,e[5]=s,e[6]=g):g=e[6];let b=g,f;e[7]!==l||e[8]!==s?(f=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;s(l.map((N,T)=>T===P?Ca(N,{column:k}):N))},"y"),e[7]=l,e[8]=s,e[9]=f):f=e[9];let h=f,w;e[10]!==l||e[11]!==s?(w=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;s(l.map((N,T)=>T===P?{...N,operator:k}:N))},"S"),e[10]=l,e[11]=s,e[12]=w):w=e[12];let _=w,S;e[13]!==l||e[14]!==s?(S=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;s(l.map((N,T)=>T===P?Ca(N,{value:k}):N))},"k"),e[13]=l,e[14]=s,e[15]=S):S=e[15];let y=S,I;e[16]!==a||e[17]!==c?(I=(0,Ie.jsx)("input",{"aria-label":"Search rows","data-testid":"db-filter",onChange:a,placeholder:"search table\u2026",value:c}),e[16]=a,e[17]=c,e[18]=I):I=e[18];let C;e[19]!==m?(C=(0,Ie.jsx)("button",{"data-testid":"db-add-filter",onClick:m,type:"button",children:"Add filter"}),e[19]=m,e[20]=C):C=e[20];let R;e[21]!==u||e[22]!==r?(R=r!==void 0&&(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)("input",{"aria-label":"Describe a filter","data-testid":"db-ai-prompt",onChange:o(F=>{i(F.target.value)},"onChange"),onKeyDown:o(F=>{F.key==="Enter"&&u.trim()!==""&&(F.preventDefault(),r(u.trim()))},"onKeyDown"),placeholder:"describe a filter\u2026",value:u}),(0,Ie.jsx)("button",{"data-testid":"db-ai-filter",disabled:u.trim()==="",onClick:o(()=>{r(u.trim())},"onClick"),type:"button",children:"Suggest"})]}),e[21]=u,e[22]=r,e[23]=R):R=e[23];let x;e[24]!==I||e[25]!==C||e[26]!==R?(x=(0,Ie.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[I,C,R]}),e[24]=I,e[25]=C,e[26]=R,e[27]=x):x=e[27];let v;if(e[28]!==h||e[29]!==_||e[30]!==y||e[31]!==n||e[32]!==l||e[33]!==b){let F;e[35]!==h||e[36]!==_||e[37]!==y||e[38]!==n||e[39]!==b?(F=o((P,k)=>(0,Ie.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-filter-row",children:[(0,Ie.jsx)("select",{"aria-label":"Filter column","data-index":k,"data-testid":"db-filter-column",onChange:h,value:P.column,children:n.map(Ic)}),(0,Ie.jsx)("select",{"aria-label":"Filter operator","data-index":k,"data-testid":"db-filter-operator",onChange:_,value:P.operator,children:vc.map(Fc)}),(0,Ie.jsx)("input",{"aria-label":"Filter value","data-index":k,"data-testid":"db-filter-value",onChange:y,placeholder:"value",value:P.value}),(0,Ie.jsx)("button",{"aria-label":"Remove filter","data-index":k,"data-testid":"db-filter-remove",onClick:b,type:"button",children:"\u2715"})]},k),"a"),e[35]=h,e[36]=_,e[37]=y,e[38]=n,e[39]=b,e[40]=F):F=e[40],v=l.map(F),e[28]=h,e[29]=_,e[30]=y,e[31]=n,e[32]=l,e[33]=b,e[34]=v}else v=e[34];let M;return e[41]!==v||e[42]!==x?(M=(0,Ie.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"db-filters",children:[x,v]}),e[41]=v,e[42]=x,e[43]=M):M=e[43],M},"M");function Ic(t){return(0,Ie.jsx)("option",{value:t,children:t},t)}o(Ic,"B");function Fc(t){return(0,Ie.jsx)("option",{value:t.value,children:t.label},t.value)}o(Fc,"G");var Mc=o(t=>({tables:Object.entries(t).map(([e,n])=>({fields:n.map(l=>l.name),indexes:[],name:e,relations:n.filter(l=>l.ref!==void 0).map(l=>({field:l.name,kind:"one",name:l.name,onDelete:l.onDelete,references:l.ref,table:e}))}))}),"No"),kc=o(t=>{let e=new Map,n=new Set;for(let l of t.tables)for(let r of l.relations){if(r.kind!=="one"||r.onDelete==="set null")continue;let s=r.references,a=`${s}\0${l.name}\0${r.field}`;if(n.has(a))continue;n.add(a);let c=e.get(s)??[];c.push({...r,table:l.name}),e.set(s,c)}return e},"So"),Pc=o((t,e)=>{let n=[],l=[t];for(;l.length>0;){let r=l.shift();if(r===void 0)break;e(r)&&n.push(r);for(let s of r.children)l.push(s)}return n},"ko"),Ia=o((t,e)=>{let n=[];for(let[l,r]of Object.entries(e))for(let s of r)s.ref===t&&n.push({column:s.name,table:l});return n.sort((l,r)=>l.table.localeCompare(r.table)||l.column.localeCompare(r.column)),n},"qt"),hr=o(t=>`${t.table}.${t.column}`,"It"),Nc=o(t=>{let e=(0,q.c)(111),{columns:n,onApply:l,onClose:r,shardKey:s,table:a,total:c,uniqueColumns:u}=t,i=oe(),[d,m]=(0,D.useState)(n[0]??""),[g,b]=(0,D.useState)(""),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=o(ye=>{m(ye.target.value)},"u"),e[0]=f):f=e[0];let h=f,w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=o(ye=>{b(ye.target.value)},"h"),e[1]=w):w=e[1];let _=w,S;e[2]!==g?(S=g.trim(),e[2]=g,e[3]=S):S=e[3];let y=S==="",I,C;if(e[4]!==y||e[5]!==i||e[6]!==g){if(!y)try{C=gn(JSON.parse(g))}catch(ye){I=i("Invalid JSON: {message}",{message:ye.message})}e[4]=y,e[5]=i,e[6]=g,e[7]=I,e[8]=C}else I=e[7],C=e[8];let R;e[9]!==d||e[10]!==c||e[11]!==u?(R=u.has(d)&&c>1,e[9]=d,e[10]=c,e[11]=u,e[12]=R):R=e[12];let x=R,v=d!==""&&!y&&I===void 0&&!x,M;e[13]!==v||e[14]!==d||e[15]!==l||e[16]!==r||e[17]!==C?(M=o(()=>{v&&(l({[d]:C}),r())},"T"),e[13]=v,e[14]=d,e[15]=l,e[16]=r,e[17]=C,e[18]=M):M=e[18];let F=M,P;e[19]!==i?(P=i("Set a column on matching rows"),e[19]=i,e[20]=P):P=e[20];let k;e[21]!==i?(k=i("Set a column on matching rows"),e[21]=i,e[22]=k):k=e[22];let N;e[23]!==k?(N=(0,p.jsx)("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:k}),e[23]=k,e[24]=N):N=e[24];let T;e[25]!==i||e[26]!==a||e[27]!==c?(T=i("Writes {total} rows of {table} through the schema-aware writer \u2014 validators and indexes apply, exactly like a mutation.",{table:a,total:c.toString()}),e[25]=i,e[26]=a,e[27]=c,e[28]=T):T=e[28];let z;e[29]!==T?(z=(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:T}),e[29]=T,e[30]=z):z=e[30];let A;e[31]!==s||e[32]!==i?(A=s===""?i("Shard: root"):i("Shard: {shardKey} \u2014 rows in other shards are not touched.",{shardKey:s}),e[31]=s,e[32]=i,e[33]=A):A=e[33];let $;e[34]!==A?($=(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=$):$=e[35];let K;e[36]!==z||e[37]!==$||e[38]!==N?(K=(0,p.jsxs)("div",{className:"flex flex-col gap-0.5",children:[N,z,$]}),e[36]=z,e[37]=$,e[38]=N,e[39]=K):K=e[39];let U;e[40]!==i?(U=i("Close"),e[40]=i,e[41]=U):U=e[41];let O;e[42]!==r||e[43]!==U?(O=(0,p.jsx)(rn,{"data-testid":"bulk-patch-close",onClick:r,size:"xs",variant:"ghost",children:U}),e[42]=r,e[43]=U,e[44]=O):O=e[44];let Q;e[45]!==K||e[46]!==O?(Q=(0,p.jsxs)("div",{className:"flex items-start justify-between",children:[K,O]}),e[45]=K,e[46]=O,e[47]=Q):Q=e[47];let J;e[48]!==i?(J=i("Column"),e[48]=i,e[49]=J):J=e[49];let Z;e[50]!==J?(Z=(0,p.jsx)(co,{htmlFor:"bulk-patch-column",children:J}),e[50]=J,e[51]=Z):Z=e[51];let ne;e[52]!==i?(ne=i("Column"),e[52]=i,e[53]=ne):ne=e[53];let te;e[54]!==n?(te=n.map(Dc),e[54]=n,e[55]=te):te=e[55];let se;e[56]!==d||e[57]!==ne||e[58]!==te?(se=(0,p.jsx)("select",{"aria-label":ne,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:h,value:d,children:te}),e[56]=d,e[57]=ne,e[58]=te,e[59]=se):se=e[59];let me;e[60]!==i?(me=i("Value"),e[60]=i,e[61]=me):me=e[61];let be;e[62]!==me?(be=(0,p.jsx)(co,{htmlFor:"bulk-patch-value",children:me}),e[62]=me,e[63]=be):be=e[63];let Ce;e[64]!==g?(Ce=(0,p.jsx)(Ir,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:_,placeholder:"true",value:g}),e[64]=g,e[65]=Ce):Ce=e[65];let xe;e[66]!==Z||e[67]!==se||e[68]!==be||e[69]!==Ce?(xe=(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[Z,se,be,Ce]}),e[66]=Z,e[67]=se,e[68]=be,e[69]=Ce,e[70]=xe):xe=e[70];let Se;e[71]!==I?(Se=I!==void 0&&(0,p.jsx)("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:I}),e[71]=I,e[72]=Se):Se=e[72];let ve;e[73]!==d||e[74]!==i||e[75]!==c||e[76]!==x?(ve=x&&(0,p.jsx)("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index \u2014 the same value cannot be set on {total} rows.",{column:d,total:c.toString()})}),e[73]=d,e[74]=i,e[75]=c,e[76]=x,e[77]=ve):ve=e[77];let L;e[78]!==y||e[79]!==i||e[80]!==x?(L=y&&!x&&(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value \u2014 for example true, 0, null, or "done".')}),e[78]=y,e[79]=i,e[80]=x,e[81]=L):L=e[81];let X;e[82]!==v||e[83]!==d||e[84]!==g?(X=v&&(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${d} = ${g.trim()}`}),e[82]=v,e[83]=d,e[84]=g,e[85]=X):X=e[85];let le;e[86]!==i?(le=i("Cancel"),e[86]=i,e[87]=le):le=e[87];let Fe;e[88]!==r||e[89]!==le?(Fe=(0,p.jsx)(rn,{"data-testid":"bulk-patch-cancel",onClick:r,size:"xs",variant:"outline",children:le}),e[88]=r,e[89]=le,e[90]=Fe):Fe=e[90];let De=!v,ge;e[91]!==i||e[92]!==c?(ge=i("Set on {total} rows",{total:c.toString()}),e[91]=i,e[92]=c,e[93]=ge):ge=e[93];let ee;e[94]!==F||e[95]!==De||e[96]!==ge?(ee=(0,p.jsx)(rn,{"data-testid":"bulk-patch-apply",disabled:De,onClick:F,size:"xs",children:ge}),e[94]=F,e[95]=De,e[96]=ge,e[97]=ee):ee=e[97];let B;e[98]!==Fe||e[99]!==ee?(B=(0,p.jsxs)("div",{className:"flex justify-end gap-2",children:[Fe,ee]}),e[98]=Fe,e[99]=ee,e[100]=B):B=e[100];let Te;return e[101]!==r||e[102]!==Q||e[103]!==xe||e[104]!==Se||e[105]!==ve||e[106]!==L||e[107]!==X||e[108]!==B||e[109]!==P?(Te=(0,p.jsxs)(Bt,{label:P,onClose:r,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[Q,xe,Se,ve,L,X,B]}),e[101]=r,e[102]=Q,e[103]=xe,e[104]=Se,e[105]=ve,e[106]=L,e[107]=X,e[108]=B,e[109]=P,e[110]=Te):Te=e[110],Te},"To");function Dc(t){return(0,p.jsx)("option",{value:t,children:t},t)}o(Dc,"Eo");var Fa=6,Gn=100,Tc=o(t=>({paddingLeft:t*16}),"_o"),Ac=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-restrict-${n}`,r;return e[0]!==l?(r=(0,p.jsx)("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":l,children:"restrict \u2014 will block delete"}),e[0]=l,e[1]=r):r=e[1],r},"Ro"),Oc=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-cascade-${n}`,r;return e[0]!==l?(r=(0,p.jsx)("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":l,children:"cascade"}),e[0]=l,e[1]=r):r=e[1],r},"$o"),Ec=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-undeclared-${n}`,r;return e[0]!==l?(r=(0,p.jsx)("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":l,children:"references \u2014 no delete action declared"}),e[0]=l,e[1]=r):r=e[1],r},"Do"),Vc=o(t=>t.relation===void 0||t.relation.onDelete==="cascade"?(0,p.jsx)(Oc,{table:t.table}):t.isRestrict?(0,p.jsx)(Ac,{table:t.table}):(0,p.jsx)(Ec,{table:t.table}),"Po"),Ea=o(t=>{let e=(0,q.c)(35),{depth:n,node:l}=t,r=`cascade-row-${l.table}`,s;e[0]!==n?(s=Tc(n),e[0]=n,e[1]=s):s=e[1];let a;e[2]!==n?(a=n>0&&(0,p.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2514"}),e[2]=n,e[3]=a):a=e[3];let c;e[4]!==l.table?(c=(0,p.jsx)("span",{className:"font-medium text-foreground",children:l.table}),e[4]=l.table,e[5]=c):c=e[5];let u;e[6]!==l.relation||e[7]!==l.table?(u=l.relation!==void 0&&(0,p.jsxs)("span",{className:"text-muted-foreground","data-testid":`cascade-col-${l.table}-${l.relation.field}`,children:["via ",l.relation.field]}),e[6]=l.relation,e[7]=l.table,e[8]=u):u=e[8];let i;e[9]!==l.rowCount?(i=l.rowCount.toString(),e[9]=l.rowCount,e[10]=i):i=e[10];let d;e[11]!==i?(d=(0,p.jsxs)("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==l?(m=Vc(l),e[13]=l,e[14]=m):m=e[14];let g;e[15]!==l.capNote||e[16]!==l.table?(g=l.capNote!==void 0&&(0,p.jsxs)("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${l.table}`,children:["(",l.capNote,")"]}),e[15]=l.capNote,e[16]=l.table,e[17]=g):g=e[17];let b;e[18]!==r||e[19]!==s||e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==d||e[24]!==m||e[25]!==g?(b=(0,p.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":r,style:s,children:[a,c,u,d,m,g]}),e[18]=r,e[19]=s,e[20]=a,e[21]=c,e[22]=u,e[23]=d,e[24]=m,e[25]=g,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==l.children){let w;e[30]!==n?(w=o((_,S)=>(0,p.jsx)(Ea,{depth:n+1,node:_},`${_.table}-${_.relation?.field??"root"}-${S.toString()}`),"h"),e[30]=n,e[31]=w):w=e[31],f=l.children.map(w),e[27]=n,e[28]=l.children,e[29]=f}else f=e[29];let h;return e[32]!==b||e[33]!==f?(h=(0,p.jsxs)(p.Fragment,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=h):h=e[34],h},"sn"),zc=o(t=>{let e=t._id??t.id??t.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},"Ao"),$c=o(async(t,e,n,l)=>{try{let r=await l(t,e,n),s=r.rows.flatMap(c=>zc(c)||[]).slice(0,Gn),a=r.total??0;return{capNote:a>Gn?`showing first ${Gn.toString()} of ${a.toString()}`:void 0,rowCount:a,rowIds:s}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},"Io"),Va=o(async(t,e,n,l,r,s,a)=>{let{capNote:c,rowCount:u,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await $c(t,n.field,e,a),d=n?.onDelete==="restrict",m=[],g=`${t}:${e}`,b=s>=Fa;if(!r.has(g)&&!b){r.add(g);let h=l.get(t)??[];for(let w of h)for(let _ of i.slice(0,10)){let S=await Va(w.table,_,w,l,r,s+1,a);(S.rowCount>0||s===0)&&m.push(S)}r.delete(g)}let f=c;if(b){let h=`depth capped at ${Fa.toString()}`;f=c===void 0?h:`${c}; ${h}`}return{capNote:f,children:m,isRestrict:d,relation:n,rowCount:u,rowIds:i,table:t}},"ln"),Hc=o(({onClose:t,onConfirm:e,readPage:n,rowId:l,schema:r,table:s})=>{let a=oe(),[c,u]=(0,D.useState)(!0),[i,d]=(0,D.useState)(null),[m,g]=(0,D.useState)(null);(0,D.useEffect)(()=>{let h=!1;return re((async()=>{try{u(!0),g(null);let w=kc(r);if(!((w.get(s)??[]).length>0)){h||(d({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[l],table:s}),u(!1));return}let _=await Va(s,l,void 0,w,new Set,0,n);h||(d(_),u(!1))}catch(w){h||(g(w.message),u(!1))}})()),()=>{h=!0}},[l,s]);let b=i!==null&&Pc(i,h=>h.isRestrict).length>0,f=o(()=>{e(),t()},"u");return(0,p.jsxs)(Bt,{label:"Cascade impact preview",onClose:t,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[(0,p.jsxs)("div",{className:"flex items-start justify-between",children:[(0,p.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,p.jsx)("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:a("Cascade impact")}),(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:a("Delete preview \u2014 rows that would cascade or be blocked")})]}),(0,p.jsx)("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:t,type:"button",children:a("Close")})]}),c&&(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:a("Loading\u2026")}),m!==null&&(0,p.jsx)("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!c&&i!==null&&(0,p.jsx)("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:(0,p.jsx)(Ea,{depth:0,node:i})}),!c&&i!==null&&i.children.length===0&&(0,p.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:a("No related rows found.")}),b&&(0,p.jsx)("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:a("Restrict relations will block this delete.")}),(0,p.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,p.jsx)("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:t,type:"button",children:a("Cancel")}),(0,p.jsx)("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:c,onClick:f,type:"button",children:a("Delete")})]})]})},"Fo"),Lc=o((t,e,n,l,r=300)=>{if(l<=0)return{ids:new Set(t.map(m=>m.id)),leadPx:0,tailPx:0};let s=n-r,a=n+l+r,c=new Set,u=0,i=0,d=0;for(let m of t){let g=m.getSize(),b=e.has(m.id),f=u+g>s&&u<a;b||f?c.add(m.id):u<s?i+=g:d+=g,u+=g}return{ids:c,leadPx:i,tailPx:d}},"Oo"),jc=o((t,e)=>{let n=new Map,l=0;for(let r of t)e.has(r.id)&&(n.set(r.id,l),l+=r.getSize());return n},"Mo"),Bc={columnOrderingFeature:Ko,columnResizingFeature:Xo,columnSizingFeature:Yo,columnVisibilityFeature:Zo,rowSelectionFeature:cr,rowSortingFeature:ur,sortedRowModel:dr(),sortFns:{alphanumeric:To,basic:kt,datetime:Oo,text:Ao}},Gc=o(()=>{let t=(0,q.c)(12),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let[n,l]=(0,D.useState)(e),r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=o((h,w,_)=>{l(S=>({...S,[h]:{...S[h],[w]:_}}))},"t"),t[1]=r):r=t[1];let s=r,a;t[2]===Symbol.for("react.memo_cache_sentinel")?(a=o(()=>{l({})},"l"),t[2]=a):a=t[2];let c=a,u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=o((h,w)=>{l(_=>{let S=_[h];if(S===void 0)return _;let y=Object.fromEntries(Object.entries(S).filter(I=>{let[C,R]=I;return!(C in w)||!Object.is(R,w[C])}));return Object.keys(y).length===0?Object.fromEntries(Object.entries(_).filter(I=>{let[C]=I;return C!==h})):{..._,[h]:y}})},"a"),t[3]=u):u=t[3];let i=u,d;t[4]!==n?(d=o((h,w)=>{let _=n[h];return _!==void 0&&w in _?{value:_[w]}:void 0},"f"),t[4]=n,t[5]=d):d=t[5];let m=d,g;t[6]!==n?(g=Object.values(n).reduce(Kc,0),t[6]=n,t[7]=g):g=t[7];let b=g,f;return t[8]!==b||t[9]!==n||t[10]!==m?(f={clear:c,count:b,drop:i,stage:s,staged:n,stagedValue:m},t[8]=b,t[9]=n,t[10]=m,t[11]=f):f=t[11],f},"Vo"),za=o((t,e)=>{if(typeof e=="number"){let n=Number(t);return t.trim()===""||Number.isNaN(n)?t:n}if(typeof e=="boolean"){if(t==="true")return!0;if(t==="false")return!1}return t},"rn"),qc=o(t=>{let e=(0,q.c)(29),{changes:n,committing:l,onCommit:r,onDiscard:s}=t,a=oe(),c;e[0]!==n.length||e[1]!==a?(c=a("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=a,e[2]=c):c=e[2];let u;e[3]!==c?(u=(0,p.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:c}),e[3]=c,e[4]=u):u=e[4];let i;e[5]!==l||e[6]!==a?(i=a(l?"Committing\u2026":"Commit"),e[5]=l,e[6]=a,e[7]=i):i=e[7];let d;e[8]!==l||e[9]!==r||e[10]!==i?(d=(0,p.jsx)("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:l,onClick:r,type:"button",children:i}),e[8]=l,e[9]=r,e[10]=i,e[11]=d):d=e[11];let m;e[12]!==a?(m=a("Discard"),e[12]=a,e[13]=m):m=e[13];let g;e[14]!==l||e[15]!==s||e[16]!==m?(g=(0,p.jsx)("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:l,onClick:s,type:"button",children:m}),e[14]=l,e[15]=s,e[16]=m,e[17]=g):g=e[17];let b;e[18]!==u||e[19]!==d||e[20]!==g?(b=(0,p.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,d,g]}),e[18]=u,e[19]=d,e[20]=g,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(Uc),e[22]=n,e[23]=f):f=e[23];let h;e[24]!==f?(h=(0,p.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=h):h=e[25];let w;return e[26]!==b||e[27]!==h?(w=(0,p.jsxs)("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,h]}),e[26]=b,e[27]=h,e[28]=w):w=e[28],w},"Bo");function Kc(t,e){return t+Object.keys(e).length}o(Kc,"jo");function Uc(t){return(0,p.jsxs)("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[(0,p.jsxs)("span",{className:"text-muted-foreground",children:[t.rowId,".",t.column]}),(0,p.jsx)("span",{className:"text-destructive line-through",children:Oe(t.oldValue)}),(0,p.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2192"}),(0,p.jsx)("span",{className:"text-foreground",children:Oe(t.newValue)})]},`${t.rowId}:${t.column}`)}o(Uc,"zo");var Ma=400,Jc=36,Wc={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Qc={width:"100%"},Xc=/\n$/u,Yc={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Zc={display:"flex",width:"100%"},ka={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},eu="2.5rem",$a={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},wr=o(t=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${t.toString()}px`}),"Ft"),Ha=o((t,e)=>({...wr(t),left:`calc(${eu} + ${e.toString()}px)`,position:"sticky",zIndex:2}),"cn"),gr="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",tu=o((t,e,n)=>e.enabled&&e.columns.has(n)?void 0:t,"Qo"),br="__back__:",nu=o(t=>`${br}${t.table}.${t.column}`,"Yo"),ou=o(t=>{let e=(0,q.c)(3),{counts:n,rowId:l}=t;if(n===void 0){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,p.jsx)("span",{className:"text-muted-foreground/50",children:"\u2014"}),e[0]=a):a=e[0],a}let r=n[l]??0,s;return e[1]!==r?(s=(0,p.jsx)("span",{className:"tabular-nums",children:r}),e[1]=r,e[2]=s):s=e[2],s},"Xo"),et=o(t=>{for(let e of["id","__id__","_id"]){let n=t[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},"Pe"),ru=o((t,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(t)||t===""&&e.nullable===!0?{value:t===""?null:t}:void 0;if(e.type==="boolean")return t==="true"||t==="false"?{value:t==="true"}:void 0;if(e.type==="number"){let n=Number(t);return t.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:t}},"Zo"),lu=o((t,e,n)=>{if(n!==void 0&&n.type!=="any")return ru(t,n);let l=za(t,e);return typeof e=="number"&&typeof l!="number"?void 0:{value:l}},"es"),su=o(({anchor:t,columnIds:e,columnMeta:n,editableColumn:l,rows:r,text:s})=>{let a=s.replaceAll(`\r
3
3
  `,`
4
4
  `).replace(Xc,"").split(`
@@ -1 +1 @@
1
- import{c as Ce}from"./chunk-YOB2X3FZ.js";import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as $}from"./chunk-IMOHEGMV.js";import{a as Se}from"./chunk-Z5O2NQAV.js";import{a as be}from"./chunk-EJSI4PMU.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as M}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as E}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as F}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ve}from"./chunk-ZVJOW25X.js";import"./chunk-ULIQFBZU.js";import"./chunk-46EQO6E7.js";import"./chunk-35DM4JJG.js";import{a as X}from"./chunk-4ZEL6BYL.js";import{c as ae}from"./chunk-FZ5ZSUA2.js";import{f as oe}from"./chunk-PG7XHMUR.js";import"./chunk-FSRSK4LY.js";import"./chunk-5ICUJ4IA.js";import{a as de}from"./chunk-FKVZRPV5.js";import{a as Ne,b as ke,c as we,d as ce,e as re,f as le}from"./chunk-HEAQVSNS.js";import{a as se,b as me,c as fe,d as ue,e as ne}from"./chunk-WUWBZPUK.js";import{d as V,f as he,g as xe,h as ye,m as ge,p as te}from"./chunk-PTZD7RUZ.js";import{a as n,d as ie,e as Re,f as Te,g as Fe}from"./chunk-YKXDMIHQ.js";var f=ie(Re(),1);var pe=ie(Te(),1);var t=ie(Fe(),1);var Ie=["read","insert","update","delete"],Ee=n((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"Ie"),$e=n(e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,"Re"),ze=n(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:d}=i.metadata;typeof d=="string"&&d!==""&&a.add(d)}return a},"Fe"),De=n((e,a,i)=>{let d=new Map,r=n(s=>{let o=d.get(s);if(o!==void 0)return o;let m={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:s,uncovered:i.has(s)};return d.set(s,m),m},"r");for(let s of e)r(s.table).cells[s.on]={path:$e(s),procedure:s.procedure};for(let s of a)r(s.table).maskedColumns.add(s.column);for(let s of i)r(s);return[...d.values()].toSorted((s,o)=>s.table.localeCompare(o.table))},"Oe"),Oe=n(e=>{let a=(0,pe.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:d}=i,r=V(),s,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(s={},o={live:!0},a[2]=s,a[3]=o):(s=a[2],o=a[3]);let m=ae(X.rlsPolicies,s,o),l;a[4]===Symbol.for("react.memo_cache_sentinel")?(l={},a[4]=l):l=a[4];let g=ae(X.maskPolicies,l),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let b=ae(X.getAdvisories,h),v;if(a[6]!==b.data||a[7]!==g.data||a[8]!==d||a[9]!==m||a[10]!==r){let N=null;m.data!==void 0&&(N=Array.isArray(m.data.policies)?m.data.policies:[]);let z=Array.isArray(g.data?.columns)?g.data.columns:[],j=b.data??null,{error:C,errorSource:k,liveError:I}=m,R=N===null?[]:De(N,z,ze(j)),w;a[12]!==I?(w=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Se,{message:I,prefix:"pm"})}),a[12]=I,a[13]=w):w=a[13];let u;a[14]!==C||a[15]!==k?(u=C!==null&&(0,t.jsx)(ve,{error:k,testId:"pm-error"}),a[14]=C,a[15]=k,a[16]=u):u=a[16],v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[w,u,N!==null&&R.length===0?(0,t.jsx)(de,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ke,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(re,{children:r("Table")}),Ie.map(p=>(0,t.jsx)(re,{children:Ee(r,p)},p)),(0,t.jsx)(re,{children:r("Masked columns")})]})}),(0,t.jsx)(we,{children:R.map(p=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${p.table}`,children:[(0,t.jsx)(le,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[p.table,p.uncovered&&(0,t.jsx)(F,{"data-testid":`pm-uncovered-${p.table}`,title:r("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:r("Uncovered \u2014 reachable without a policy")})]})}),Ie.map(_=>{let x=p.cells[_];return(0,t.jsx)(le,{"data-testid":`pm-cell-${p.table}-${_}`,children:x.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(F,{variant:"secondary",children:r("Covered by {procedure}",{procedure:x.procedure})}),d!==void 0&&(0,t.jsx)(E,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${p.table}-${_}`,onClick:n(()=>{d(p.table,_,x.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},_)}),(0,t.jsx)(le,{children:p.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...p.maskedColumns].map(Le)})})]},p.table))})]})]}),a[6]=b.data,a[7]=g.data,a[8]=d,a[9]=m,a[10]=r,a[11]=v}else v=a[11];return v},"De");function Le(e){return(0,t.jsx)(F,{variant:"outline",children:e},e)}n(Le,"Le");var je=he(X.runAs),Me=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Ue=n(e=>{let a=e?.code;return typeof a=="string"?a:void 0},"Me"),qe=n(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:d="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let s=je;try{return{kind:"allowed",value:await e.query(s,{args:a,functionPath:i,userId:r},xe(d))}}catch(o){let m=o instanceof Error?o.message:String(o),l=Ue(o);return l!==void 0&&Me.has(l)?{kind:"denied",message:m}:{kind:"errored",message:m}}}},"ze"),Je=n(e=>e===void 0?"undefined":JSON.stringify(e,ge,2),"je"),We=n(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let d=oe(),r=V(),s=qe(),[o,m]=(0,f.useState)(null),[l,g]=(0,f.useState)(null),h=e??o??[],[b,v]=(0,f.useState)(""),[N,z]=(0,f.useState)("{}"),[j,C]=(0,f.useState)(""),[k,I]=(0,f.useState)(""),[R,w]=(0,f.useState)(!1),[u,p]=(0,f.useState)(null),[_,x]=(0,f.useState)(null),T=(0,f.useRef)(-1),P=(0,f.useRef)(0);(0,f.useEffect)(()=>{if(e!==void 0)return;let c=!1;return d.listFunctions().then(y=>(c||m(y),y)).catch(y=>{c||g(ye(y))}),()=>{c=!0}},[d,e]),(0,f.useEffect)(()=>{if(a===void 0||T.current===a.nonce)return;T.current=a.nonce,P.current+=1;let c=a.functionPath;queueMicrotask(()=>{v(c),p(null)})},[a]);let S=b===""?h[0]?.path??"":b,D=n(async()=>{if(S==="")return;let c;try{c=N.trim()===""?{}:Ce(JSON.parse(N))}catch(A){x(r("Invalid JSON args: {message}",{message:A.message})),p(null);return}P.current+=1;let y=P.current;x(null),w(!0);try{let A=await s({args:c,functionPath:S,shardKey:j.trim(),userId:k.trim()});y===P.current&&p(A)}finally{w(!1)}},"F"),Q=n(()=>{te(D())},"K"),O=n(c=>{v(c.target.value)},"O"),L=n(c=>{z(c.target.value)},"D"),G=n(c=>{I(c.target.value)},"Y");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&(0,t.jsx)(de,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-function",children:r("Function")}),(0,t.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:O,value:S,children:h.map(c=>(0,t.jsxs)("option",{value:c.path,children:[c.path," (",c.kind,")"]},c.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-args",children:r("Arguments")}),(0,t.jsx)(Pe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:N})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:j}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-user",children:r("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:G,placeholder:r("Required \u2014 the identity to probe as"),value:k})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(E,{"data-testid":"pp-run",disabled:!i||R||S==="",onClick:Q,type:"button",children:r(R?"Probing\u2026":"Run probe")}),k.trim()!==""&&(0,t.jsx)(F,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),u!==null&&u.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(F,{variant:"secondary",children:r("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Je(u.value)})]}),u!==null&&u.kind==="invalid"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[(0,t.jsx)(F,{variant:"outline",children:r("Not run")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:u.message})]}),u!==null&&u.kind==="errored"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[(0,t.jsx)(F,{variant:"outline",children:r("Errored")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:u.message})]}),u!==null&&u.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(F,{variant:"destructive",children:r("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:u.message})]})]})},"qe"),Be="/__lunora/policy-scaffold",He={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ke=n(async e=>{let a=await fetch(Be,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let d=i.error;return{kind:"error",message:d===void 0?`policy scaffold failed (${String(a.status)})`:He[d]??d}},"Qe"),_e={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Qe=n(()=>{let e=(0,pe.c)(69),a=V(),[i,d]=(0,f.useState)(null),[r,s]=(0,f.useState)(!1),[o,m]=(0,f.useState)(null),[l,g]=(0,f.useState)(_e),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n(ee=>{let K=ee.target.name,{value:Y}=ee.target;g(Ae=>({...Ae,[K]:Y}))},"u"),e[0]=h):h=e[0];let b=h,v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=n(()=>{d(null),g(_e)},"v"),e[1]=v):v=e[1];let N=v,z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z=n(async ee=>{s(!0),m(null);try{let K=await Ke(ee);m(K),K.kind==="ok"&&N()}catch(K){let Y=K;m({kind:"error",message:Y instanceof Error?Y.message:String(Y)})}s(!1)},"R"),e[2]=z):z=e[2];let j=z,C;e[3]!==l.policyName||e[4]!==l.tableName?(C=n(()=>{te(j({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},"P"),e[3]=l.policyName,e[4]=l.tableName,e[5]=C):C=e[5];let k=C,I;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(I=n(()=>{te(j({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},"A"),e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=I):I=e[9];let R=I,w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=n(()=>{m(null),d("scaffold")},"S"),e[10]=w):w=e[10];let u=w,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n(()=>{m(null),d("wire")},"m"),e[11]=p):p=e[11];let _=p,x;e[12]!==a?(x=a("Scaffold access rules"),e[12]=a,e[13]=x):x=e[13];let T;e[14]!==x?(T=(0,t.jsx)(fe,{children:x}),e[14]=x,e[15]=T):T=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let S;e[18]!==P?(S=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=S):S=e[19];let D;e[20]!==S||e[21]!==T?(D=(0,t.jsxs)(me,{children:[T,S]}),e[20]=S,e[21]=T,e[22]=D):D=e[22];let Q=i==="scaffold"?"default":"outline",O;e[23]!==a?(O=a("New policy file"),e[23]=a,e[24]=O):O=e[24];let L;e[25]!==Q||e[26]!==O?(L=(0,t.jsx)(E,{"data-testid":"policy-scaffolder-new",onClick:u,size:"xs",type:"button",variant:Q,children:O}),e[25]=Q,e[26]=O,e[27]=L):L=e[27];let G=i==="wire"?"default":"outline",c;e[28]!==a?(c=a("Wire into a procedure"),e[28]=a,e[29]=c):c=e[29];let y;e[30]!==G||e[31]!==c?(y=(0,t.jsx)(E,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:G,children:c}),e[30]=G,e[31]=c,e[32]=y):y=e[32];let A;e[33]!==L||e[34]!==y?(A=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,y]}),e[33]=L,e[34]=y,e[35]=A):A=e[35];let U;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==k||e[41]!==a?(U=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),(0,t.jsx)(E,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")}),(0,t.jsx)(E,{onClick:N,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=k,e[41]=a,e[42]=U):U=e[42];let q;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==R||e[49]!==a?(q=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),(0,t.jsx)(E,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:R,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(E,{onClick:N,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=R,e[49]=a,e[50]=q):q=e[50];let J;e[51]!==o?(J=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=J):J=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ge)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let H;e[59]!==A||e[60]!==U||e[61]!==q||e[62]!==J||e[63]!==W||e[64]!==B?(H=(0,t.jsxs)(ne,{children:[A,U,q,J,W,B]}),e[59]=A,e[60]=U,e[61]=q,e[62]=J,e[63]=W,e[64]=B,e[65]=H):H=e[65];let Z;return e[66]!==D||e[67]!==H?(Z=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[D,H]}),e[66]=D,e[67]=H,e[68]=Z):Z=e[68],Z},"He");function Ge(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}n(Ge,"Je");var ft=n(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let d=V(),[r,s]=(0,f.useState)(void 0),o=n((m,l,g)=>{g!==""&&s(h=>({functionPath:g,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Permissions")})}),(0,t.jsx)(Oe,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:d("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(We,{functions:e,prefill:r,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Qe,{})})]})},"ut");export{ft as PermissionsPanel};
1
+ import{c as Ce}from"./chunk-YOB2X3FZ.js";import{a as Pe}from"./chunk-EA2JKR5D.js";import{a as $}from"./chunk-IMOHEGMV.js";import{a as Se}from"./chunk-Z5O2NQAV.js";import{a as be}from"./chunk-EJSI4PMU.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as M}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as E}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as F}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ve}from"./chunk-GOSWKLMM.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PWB52UO.js";import"./chunk-35DM4JJG.js";import{a as X}from"./chunk-4ZEL6BYL.js";import{c as ae}from"./chunk-ERHFRNCL.js";import{f as oe}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as de}from"./chunk-FKVZRPV5.js";import{a as Ne,b as ke,c as we,d as ce,e as re,f as le}from"./chunk-HEAQVSNS.js";import{a as se,b as me,c as fe,d as ue,e as ne}from"./chunk-WUWBZPUK.js";import{d as V,f as he,g as xe,h as ye,m as ge,p as te}from"./chunk-PTZD7RUZ.js";import{a as n,d as ie,e as Re,f as Te,g as Fe}from"./chunk-YKXDMIHQ.js";var f=ie(Re(),1);var pe=ie(Te(),1);var t=ie(Fe(),1);var Ie=["read","insert","update","delete"],Ee=n((e,a)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[a],"Ie"),$e=n(e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,"Re"),ze=n(e=>{let a=new Set;for(let i of e?.advisories??[])if(i.name==="rls_uncovered_table"){let{table:d}=i.metadata;typeof d=="string"&&d!==""&&a.add(d)}return a},"Fe"),De=n((e,a,i)=>{let d=new Map,r=n(s=>{let o=d.get(s);if(o!==void 0)return o;let m={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:s,uncovered:i.has(s)};return d.set(s,m),m},"r");for(let s of e)r(s.table).cells[s.on]={path:$e(s),procedure:s.procedure};for(let s of a)r(s.table).maskedColumns.add(s.column);for(let s of i)r(s);return[...d.values()].toSorted((s,o)=>s.table.localeCompare(o.table))},"Oe"),Oe=n(e=>{let a=(0,pe.c)(17),i;a[0]!==e?(i=e===void 0?{}:e,a[0]=e,a[1]=i):i=a[1];let{onProbe:d}=i,r=V(),s,o;a[2]===Symbol.for("react.memo_cache_sentinel")?(s={},o={live:!0},a[2]=s,a[3]=o):(s=a[2],o=a[3]);let m=ae(X.rlsPolicies,s,o),l;a[4]===Symbol.for("react.memo_cache_sentinel")?(l={},a[4]=l):l=a[4];let g=ae(X.maskPolicies,l),h;a[5]===Symbol.for("react.memo_cache_sentinel")?(h={},a[5]=h):h=a[5];let b=ae(X.getAdvisories,h),v;if(a[6]!==b.data||a[7]!==g.data||a[8]!==d||a[9]!==m||a[10]!==r){let N=null;m.data!==void 0&&(N=Array.isArray(m.data.policies)?m.data.policies:[]);let z=Array.isArray(g.data?.columns)?g.data.columns:[],j=b.data??null,{error:C,errorSource:k,liveError:I}=m,R=N===null?[]:De(N,z,ze(j)),w;a[12]!==I?(w=(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)(Se,{message:I,prefix:"pm"})}),a[12]=I,a[13]=w):w=a[13];let u;a[14]!==C||a[15]!==k?(u=C!==null&&(0,t.jsx)(ve,{error:k,testId:"pm-error"}),a[14]=C,a[15]=k,a[16]=u):u=a[16],v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[w,u,N!==null&&R.length===0?(0,t.jsx)(de,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):(0,t.jsxs)(Ne,{"data-testid":"pm-table",children:[(0,t.jsx)(ke,{children:(0,t.jsxs)(ce,{children:[(0,t.jsx)(re,{children:r("Table")}),Ie.map(p=>(0,t.jsx)(re,{children:Ee(r,p)},p)),(0,t.jsx)(re,{children:r("Masked columns")})]})}),(0,t.jsx)(we,{children:R.map(p=>(0,t.jsxs)(ce,{"data-testid":`pm-row-${p.table}`,children:[(0,t.jsx)(le,{className:"font-mono text-xs",children:(0,t.jsxs)("span",{className:"flex items-center gap-1.5",children:[p.table,p.uncovered&&(0,t.jsx)(F,{"data-testid":`pm-uncovered-${p.table}`,title:r("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:r("Uncovered \u2014 reachable without a policy")})]})}),Ie.map(_=>{let x=p.cells[_];return(0,t.jsx)(le,{"data-testid":`pm-cell-${p.table}-${_}`,children:x.procedure===void 0?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):(0,t.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,t.jsx)(F,{variant:"secondary",children:r("Covered by {procedure}",{procedure:x.procedure})}),d!==void 0&&(0,t.jsx)(E,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${p.table}-${_}`,onClick:n(()=>{d(p.table,_,x.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},_)}),(0,t.jsx)(le,{children:p.maskedColumns.size===0?(0,t.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)("span",{className:"flex flex-wrap gap-1",children:[...p.maskedColumns].map(Le)})})]},p.table))})]})]}),a[6]=b.data,a[7]=g.data,a[8]=d,a[9]=m,a[10]=r,a[11]=v}else v=a[11];return v},"De");function Le(e){return(0,t.jsx)(F,{variant:"outline",children:e},e)}n(Le,"Le");var je=he(X.runAs),Me=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Ue=n(e=>{let a=e?.code;return typeof a=="string"?a:void 0},"Me"),qe=n(()=>{let e=oe();return async({args:a,functionPath:i,shardKey:d="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let s=je;try{return{kind:"allowed",value:await e.query(s,{args:a,functionPath:i,userId:r},xe(d))}}catch(o){let m=o instanceof Error?o.message:String(o),l=Ue(o);return l!==void 0&&Me.has(l)?{kind:"denied",message:m}:{kind:"errored",message:m}}}},"ze"),Je=n(e=>e===void 0?"undefined":JSON.stringify(e,ge,2),"je"),We=n(({functions:e,prefill:a,runAsIdentity:i=!1}={})=>{let d=oe(),r=V(),s=qe(),[o,m]=(0,f.useState)(null),[l,g]=(0,f.useState)(null),h=e??o??[],[b,v]=(0,f.useState)(""),[N,z]=(0,f.useState)("{}"),[j,C]=(0,f.useState)(""),[k,I]=(0,f.useState)(""),[R,w]=(0,f.useState)(!1),[u,p]=(0,f.useState)(null),[_,x]=(0,f.useState)(null),T=(0,f.useRef)(-1),P=(0,f.useRef)(0);(0,f.useEffect)(()=>{if(e!==void 0)return;let c=!1;return d.listFunctions().then(y=>(c||m(y),y)).catch(y=>{c||g(ye(y))}),()=>{c=!0}},[d,e]),(0,f.useEffect)(()=>{if(a===void 0||T.current===a.nonce)return;T.current=a.nonce,P.current+=1;let c=a.functionPath;queueMicrotask(()=>{v(c),p(null)})},[a]);let S=b===""?h[0]?.path??"":b,D=n(async()=>{if(S==="")return;let c;try{c=N.trim()===""?{}:Ce(JSON.parse(N))}catch(A){x(r("Invalid JSON args: {message}",{message:A.message})),p(null);return}P.current+=1;let y=P.current;x(null),w(!0);try{let A=await s({args:c,functionPath:S,shardKey:j.trim(),userId:k.trim()});y===P.current&&p(A)}finally{w(!1)}},"F"),Q=n(()=>{te(D())},"K"),O=n(c=>{v(c.target.value)},"O"),L=n(c=>{z(c.target.value)},"D"),G=n(c=>{I(c.target.value)},"Y");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[l!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:l}),!i&&(0,t.jsx)(de,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-function",children:r("Function")}),(0,t.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:O,value:S,children:h.map(c=>(0,t.jsxs)("option",{value:c.path,children:[c.path," (",c.kind,")"]},c.path))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-args",children:r("Arguments")}),(0,t.jsx)(Pe,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:L,value:N})]}),(0,t.jsx)(be,{onChange:C,testId:"pp-shard",value:j}),(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)($,{htmlFor:"pp-user",children:r("Run as (userId)")}),(0,t.jsx)(M,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:G,placeholder:r("Required \u2014 the identity to probe as"),value:k})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(E,{"data-testid":"pp-run",disabled:!i||R||S==="",onClick:Q,type:"button",children:r(R?"Probing\u2026":"Run probe")}),k.trim()!==""&&(0,t.jsx)(F,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:k.trim()})})]})]}),_!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:_}),u!==null&&u.kind==="allowed"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[(0,t.jsx)(F,{variant:"secondary",children:r("Allowed")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:Je(u.value)})]}),u!==null&&u.kind==="invalid"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[(0,t.jsx)(F,{variant:"outline",children:r("Not run")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:u.message})]}),u!==null&&u.kind==="errored"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[(0,t.jsx)(F,{variant:"outline",children:r("Errored")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:u.message})]}),u!==null&&u.kind==="denied"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[(0,t.jsx)(F,{variant:"destructive",children:r("Denied")}),(0,t.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:u.message})]})]})},"qe"),Be="/__lunora/policy-scaffold",He={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ke=n(async e=>{let a=await fetch(Be,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await a.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(a.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};let d=i.error;return{kind:"error",message:d===void 0?`policy scaffold failed (${String(a.status)})`:He[d]??d}},"Qe"),_e={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Qe=n(()=>{let e=(0,pe.c)(69),a=V(),[i,d]=(0,f.useState)(null),[r,s]=(0,f.useState)(!1),[o,m]=(0,f.useState)(null),[l,g]=(0,f.useState)(_e),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=n(ee=>{let K=ee.target.name,{value:Y}=ee.target;g(Ae=>({...Ae,[K]:Y}))},"u"),e[0]=h):h=e[0];let b=h,v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=n(()=>{d(null),g(_e)},"v"),e[1]=v):v=e[1];let N=v,z;e[2]===Symbol.for("react.memo_cache_sentinel")?(z=n(async ee=>{s(!0),m(null);try{let K=await Ke(ee);m(K),K.kind==="ok"&&N()}catch(K){let Y=K;m({kind:"error",message:Y instanceof Error?Y.message:String(Y)})}s(!1)},"R"),e[2]=z):z=e[2];let j=z,C;e[3]!==l.policyName||e[4]!==l.tableName?(C=n(()=>{te(j({kind:"scaffoldPolicy",name:l.policyName.trim(),table:l.tableName.trim()}))},"P"),e[3]=l.policyName,e[4]=l.tableName,e[5]=C):C=e[5];let k=C,I;e[6]!==l.exportName||e[7]!==l.filePath||e[8]!==l.policies?(I=n(()=>{te(j({exportName:l.exportName.trim(),filePath:l.filePath.trim(),kind:"wireRls",policies:l.policies.trim()}))},"A"),e[6]=l.exportName,e[7]=l.filePath,e[8]=l.policies,e[9]=I):I=e[9];let R=I,w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=n(()=>{m(null),d("scaffold")},"S"),e[10]=w):w=e[10];let u=w,p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=n(()=>{m(null),d("wire")},"m"),e[11]=p):p=e[11];let _=p,x;e[12]!==a?(x=a("Scaffold access rules"),e[12]=a,e[13]=x):x=e[13];let T;e[14]!==x?(T=(0,t.jsx)(fe,{children:x}),e[14]=x,e[15]=T):T=e[15];let P;e[16]!==a?(P=a("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=a,e[17]=P):P=e[17];let S;e[18]!==P?(S=(0,t.jsx)(ue,{children:P}),e[18]=P,e[19]=S):S=e[19];let D;e[20]!==S||e[21]!==T?(D=(0,t.jsxs)(me,{children:[T,S]}),e[20]=S,e[21]=T,e[22]=D):D=e[22];let Q=i==="scaffold"?"default":"outline",O;e[23]!==a?(O=a("New policy file"),e[23]=a,e[24]=O):O=e[24];let L;e[25]!==Q||e[26]!==O?(L=(0,t.jsx)(E,{"data-testid":"policy-scaffolder-new",onClick:u,size:"xs",type:"button",variant:Q,children:O}),e[25]=Q,e[26]=O,e[27]=L):L=e[27];let G=i==="wire"?"default":"outline",c;e[28]!==a?(c=a("Wire into a procedure"),e[28]=a,e[29]=c):c=e[29];let y;e[30]!==G||e[31]!==c?(y=(0,t.jsx)(E,{"data-testid":"policy-scaffolder-wire",onClick:_,size:"xs",type:"button",variant:G,children:c}),e[30]=G,e[31]=c,e[32]=y):y=e[32];let A;e[33]!==L||e[34]!==y?(A=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,y]}),e[33]=L,e[34]=y,e[35]=A):A=e[35];let U;e[36]!==r||e[37]!==l.policyName||e[38]!==l.tableName||e[39]!==i||e[40]!==k||e[41]!==a?(U=i==="scaffold"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-name",children:a("Policy name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:b,value:l.policyName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-table",children:a("Table name")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:b,value:l.tableName})]}),(0,t.jsx)(E,{"data-testid":"policy-scaffolder-create",disabled:r||l.policyName.trim()===""||l.tableName.trim()==="",onClick:k,size:"xs",type:"button",children:a(r?"Creating\u2026":"Create policy file")}),(0,t.jsx)(E,{onClick:N,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[36]=r,e[37]=l.policyName,e[38]=l.tableName,e[39]=i,e[40]=k,e[41]=a,e[42]=U):U=e[42];let q;e[43]!==r||e[44]!==l.exportName||e[45]!==l.filePath||e[46]!==l.policies||e[47]!==i||e[48]!==R||e[49]!==a?(q=i==="wire"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-file",children:a("Procedure file path")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:b,value:l.filePath})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-export",children:a("Exported procedure")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:b,value:l.exportName})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)($,{htmlFor:"policy-scaffolder-policies",children:a("Policy set identifier")}),(0,t.jsx)(M,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:b,value:l.policies})]}),(0,t.jsx)(E,{"data-testid":"policy-scaffolder-apply",disabled:r||l.filePath.trim()===""||l.exportName.trim()===""||l.policies.trim()==="",onClick:R,size:"xs",type:"button",children:a(r?"Wiring\u2026":"Wire RLS")}),(0,t.jsx)(E,{onClick:N,size:"xs",type:"button",variant:"ghost",children:a("Cancel")})]}),e[43]=r,e[44]=l.exportName,e[45]=l.filePath,e[46]=l.policies,e[47]=i,e[48]=R,e[49]=a,e[50]=q):q=e[50];let J;e[51]!==o?(J=o?.kind==="error"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:o.message}),e[51]=o,e[52]=J):J=e[52];let W;e[53]!==o?.kind||e[54]!==a?(W=o?.kind==="needs-manual-edit"&&(0,t.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:a("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),e[53]=o?.kind,e[54]=a,e[55]=W):W=e[55];let B;e[56]!==o||e[57]!==a?(B=o?.kind==="ok"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,t.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:a("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:o.label})}),o.diagnostics.length>0&&(0,t.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:o.diagnostics.map(Ge)})]}),e[56]=o,e[57]=a,e[58]=B):B=e[58];let H;e[59]!==A||e[60]!==U||e[61]!==q||e[62]!==J||e[63]!==W||e[64]!==B?(H=(0,t.jsxs)(ne,{children:[A,U,q,J,W,B]}),e[59]=A,e[60]=U,e[61]=q,e[62]=J,e[63]=W,e[64]=B,e[65]=H):H=e[65];let Z;return e[66]!==D||e[67]!==H?(Z=(0,t.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[D,H]}),e[66]=D,e[67]=H,e[68]=Z):Z=e[68],Z},"He");function Ge(e){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}n(Ge,"Je");var ft=n(({functions:e,runAsIdentity:a=!1,schemaEditable:i=!1}={})=>{let d=V(),[r,s]=(0,f.useState)(void 0),o=n((m,l,g)=>{g!==""&&s(h=>({functionPath:g,nonce:(h?.nonce??0)+1}))},"o");return(0,t.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Permissions")})}),(0,t.jsx)(Oe,{onProbe:o})]}),(0,t.jsx)("section",{className:"flex flex-col gap-3",children:(0,t.jsxs)(se,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Probe")})}),(0,t.jsxs)(ne,{className:"px-4 py-4",children:[(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:d("Pick a function and an identity, then run it to see the access outcome.")}),(0,t.jsx)(We,{functions:e,prefill:r,runAsIdentity:a})]})]})}),i&&(0,t.jsx)("section",{className:"flex flex-col gap-2",children:(0,t.jsx)(Qe,{})})]})},"ut");export{ft as PermissionsPanel};