@lunora/studio 1.0.0-alpha.183 → 1.0.0-alpha.184

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 (63) hide show
  1. package/dist/standalone/{chunk-KX3YZ3TC.js → chunk-26L63KFY.js} +1 -1
  2. package/dist/standalone/{chunk-3PZNTIBM.js → chunk-2KM4MU7U.js} +1 -1
  3. package/dist/standalone/{chunk-IP7YCJUN.js → chunk-37CLUREK.js} +1 -1
  4. package/dist/standalone/{chunk-XKP3TSCE.js → chunk-3GJKDNXE.js} +1 -1
  5. package/dist/standalone/{chunk-FI6N7XWP.js → chunk-4P4DE3XL.js} +1 -1
  6. package/dist/standalone/{chunk-H43JNQM6.js → chunk-4PLYQWKJ.js} +1 -1
  7. package/dist/standalone/{chunk-TIIEZS24.js → chunk-4X5HAX5N.js} +1 -1
  8. package/dist/standalone/{chunk-QQ3CS3FX.js → chunk-55K64SUB.js} +1 -1
  9. package/dist/standalone/{chunk-5XRNQ732.js → chunk-56XCNBO4.js} +1 -1
  10. package/dist/standalone/{chunk-DAD33Q2T.js → chunk-5AQVGRDR.js} +1 -1
  11. package/dist/standalone/{chunk-I6FR5UAK.js → chunk-5TV5EBCO.js} +1 -1
  12. package/dist/standalone/{chunk-JYT34NQM.js → chunk-6VNVVY4F.js} +1 -1
  13. package/dist/standalone/{chunk-VWXJAY7R.js → chunk-724ZBLVZ.js} +1 -1
  14. package/dist/standalone/{chunk-AULH6SZB.js → chunk-75OWNJEY.js} +2 -2
  15. package/dist/standalone/{chunk-TTIBDOV6.js → chunk-7E4PCEOO.js} +1 -1
  16. package/dist/standalone/{chunk-KIW73EIK.js → chunk-7MF5C3Z6.js} +1 -1
  17. package/dist/standalone/{chunk-SDHFSBNM.js → chunk-7TRN7FQ4.js} +1 -1
  18. package/dist/standalone/{chunk-BAAPQWFF.js → chunk-AO5ROTB4.js} +1 -1
  19. package/dist/standalone/{chunk-A6S4TULR.js → chunk-BMVSHGFK.js} +1 -1
  20. package/dist/standalone/{chunk-B3JY36UV.js → chunk-CLELTQYS.js} +1 -1
  21. package/dist/standalone/{chunk-AX24JD2G.js → chunk-CZIPGHIR.js} +1 -1
  22. package/dist/standalone/{chunk-5LZJ5JBB.js → chunk-DVXDMRWA.js} +1 -1
  23. package/dist/standalone/{chunk-B6RRRJP5.js → chunk-EAQZEXBX.js} +1 -1
  24. package/dist/standalone/{chunk-IXNOQYEE.js → chunk-ETHN2RZR.js} +1 -1
  25. package/dist/standalone/{chunk-CBNGOAD4.js → chunk-FAFNOIJX.js} +1 -1
  26. package/dist/standalone/{chunk-ITMXIPQ7.js → chunk-FDB7QVEC.js} +1 -1
  27. package/dist/standalone/{chunk-GZAXFXZE.js → chunk-FGMA2GGM.js} +1 -1
  28. package/dist/standalone/{chunk-GAPFZFIL.js → chunk-FRMJ5VVM.js} +1 -1
  29. package/dist/standalone/{chunk-5MKG6RW3.js → chunk-FZ45WJQK.js} +1 -1
  30. package/dist/standalone/{chunk-2Y6PXGIS.js → chunk-GETL6R4M.js} +14 -14
  31. package/dist/standalone/{chunk-3TXB4AKZ.js → chunk-GKUDJ3RC.js} +1 -1
  32. package/dist/standalone/{chunk-AODYDAXY.js → chunk-HATH336U.js} +1 -1
  33. package/dist/standalone/{chunk-D4ZGY3II.js → chunk-IYUIJLIW.js} +1 -1
  34. package/dist/standalone/{chunk-66Z7ZIZZ.js → chunk-J6JOGFVB.js} +1 -1
  35. package/dist/standalone/{chunk-Y2I6GYEG.js → chunk-JM6U3CQE.js} +1 -1
  36. package/dist/standalone/{chunk-QWJQUQY3.js → chunk-JP6RVFCJ.js} +1 -1
  37. package/dist/standalone/{chunk-PGMASM2T.js → chunk-JYVJ2OWH.js} +1 -1
  38. package/dist/standalone/{chunk-DI34YDBW.js → chunk-LP7ELDUL.js} +1 -1
  39. package/dist/standalone/{chunk-L2CWAQUO.js → chunk-M3ANC2JI.js} +1 -1
  40. package/dist/standalone/{chunk-PZVVEPIN.js → chunk-MKRJGSYF.js} +1 -1
  41. package/dist/standalone/{chunk-URBHAYYZ.js → chunk-MWSNVNHE.js} +1 -1
  42. package/dist/standalone/{chunk-E2X625P3.js → chunk-N6LSV246.js} +1 -1
  43. package/dist/standalone/{chunk-RM4TNBYG.js → chunk-NRZ5MBPS.js} +1 -1
  44. package/dist/standalone/{chunk-4PRXEO3C.js → chunk-O337Z6XI.js} +1 -1
  45. package/dist/standalone/{chunk-WRZTTZFV.js → chunk-PVAE535J.js} +1 -1
  46. package/dist/standalone/{chunk-AFSPF2R4.js → chunk-PVV6LALL.js} +1 -1
  47. package/dist/standalone/{chunk-GZ6GAFM2.js → chunk-QZHPUFML.js} +1 -1
  48. package/dist/standalone/{chunk-MH2NGGUC.js → chunk-SDBOAPOT.js} +1 -1
  49. package/dist/standalone/{chunk-HGT5U6GD.js → chunk-SGL3ZV4P.js} +1 -1
  50. package/dist/standalone/{chunk-INXSZE5I.js → chunk-T57JAZCX.js} +1 -1
  51. package/dist/standalone/{chunk-WIXX2VWE.js → chunk-UZHJM2CX.js} +1 -1
  52. package/dist/standalone/{chunk-GP2GJRJ3.js → chunk-VCOPIBKL.js} +1 -1
  53. package/dist/standalone/{chunk-V7G6YTQ5.js → chunk-VG34EBBT.js} +1 -1
  54. package/dist/standalone/{chunk-QDHXQ56K.js → chunk-VICAUTXQ.js} +1 -1
  55. package/dist/standalone/{chunk-WD4WHTAV.js → chunk-WDJ4CHIO.js} +1 -1
  56. package/dist/standalone/{chunk-EBU3TTYR.js → chunk-XBKABVCJ.js} +1 -1
  57. package/dist/standalone/{chunk-NVKY4CIW.js → chunk-Y6SKU4M7.js} +1 -1
  58. package/dist/standalone/{chunk-5B6TTEP6.js → chunk-YBZYUPAG.js} +1 -1
  59. package/dist/standalone/{chunk-Z2XS4ZOO.js → chunk-Z2CLSELV.js} +1 -1
  60. package/dist/standalone/{chunk-J3LCGEBD.js → chunk-ZGMGMEFM.js} +1 -1
  61. package/dist/standalone/{chunk-TXHTSFLO.js → chunk-ZWJGQACG.js} +1 -1
  62. package/dist/standalone/studio.js +1 -1
  63. package/package.json +6 -6
@@ -1,15 +1,15 @@
1
- import{a}from"./chunk-YKXDMIHQ.js";var r="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",n="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"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},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` to `emailGate(...)` (`@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_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"},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"},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"},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_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"},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(t=>Object.hasOwn(l,t)?l[t]:void 0,"h");var E=[{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
- `),header:"Row too large for the storage engine",id:"lunora-row-too-big",test:a(t=>_.test(t),"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
- `),header:"No Lunora schema found",id:"lunora-schema-missing",test:a(t=>t.includes("defineSchema() not found")||t.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
- `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:a(t=>t.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 reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
5
- `),header:"Table name is reserved",id:"lunora-table-reserved",test:a(t=>t.includes("is reserved")&&t.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
6
- `),header:"Duplicate table name",id:"lunora-table-duplicate",test:a(t=>t.includes("already exists")&&t.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
7
- `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:a(t=>t.includes("unknown jurisdiction")||t.includes("jurisdiction")&&t.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
8
- `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(t=>t.includes("must be a literal")&&t.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
9
- `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(t=>t.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
10
- `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(t=>t.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
11
- `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(t=>t.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:r,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:r,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:r,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:r,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:r,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:r,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:r,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=a(t=>t!==void 0&&t>="0"&&t<="9","l"),T=a((t,e)=>{for(let o=t.indexOf(e);o!==-1;o=t.indexOf(e,o+e.length))if(!u(t[o-1])&&!u(t[o+e.length]))return!0;return!1},"E"),g=a((t,e)=>{for(let o of[`error ${e}`,`error: ${e}`])for(let i=t.indexOf(o);i!==-1;i=t.indexOf(o,i+o.length))if(!u(t[i+o.length]))return!0;return!1},"f"),A=/error|cloudflare/iu,m=a(t=>({body:[t.summary,"",`**Likely cause:** ${t.causes}.`,"",`**Fix:** ${t.fix}.`,"",`See [Cloudflare's ${t.family} error docs](${t.docsUrl}).`].join(`
12
- `),header:`Cloudflare Error ${t.code}: ${t.title}`,id:`cloudflare-error-${t.code}`}),"c"),p=a(t=>{if(!A.test(t))return;let e=t.toLowerCase(),o=e.includes("error"),i=e.includes("cloudflare");if(o){for(let s of d)if(g(e,s.code))return m(s)}if(i){for(let s of d)if(T(e,s.code))return m(s)}},"T"),O=a(t=>(typeof t=="string"?t:t.join(`
1
+ import{a}from"./chunk-YKXDMIHQ.js";var r="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",n="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"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},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` to `emailGate(...)` (`@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"},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"},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_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"},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 p=[{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
+ `),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
+ `),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
+ `),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 reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
5
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:a(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
6
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:a(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
7
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:a(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
8
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
9
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
10
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
11
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:r,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:r,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:r,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:r,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:r,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:r,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:r,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=a(e=>e!==void 0&&e>="0"&&e<="9","l"),T=a((e,t)=>{for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+t.length))if(!u(e[o-1])&&!u(e[o+t.length]))return!0;return!1},"_"),g=a((e,t)=>{for(let o of[`error ${t}`,`error: ${t}`])for(let i=e.indexOf(o);i!==-1;i=e.indexOf(o,i+o.length))if(!u(e[i+o.length]))return!0;return!1},"f"),A=/error|cloudflare/iu,m=a(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
12
+ `),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),E=a(e=>{if(!A.test(e))return;let t=e.toLowerCase(),o=t.includes("error"),i=t.includes("cloudflare");if(o){for(let s of d)if(g(t,s.code))return m(s)}if(i){for(let s of d)if(T(t,s.code))return m(s)}},"T"),O=a(e=>(typeof e=="string"?e:e.join(`
13
13
  `)).split(`
14
- `).filter(e=>!e.startsWith("```")).join(`
15
- `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"N"),f=a(t=>{for(let e of E)if(e.test(t))return{body:e.body,header:e.header,id:e.id}},"d"),N=a(t=>f(t)??p(t),"g");var h=class extends Error{static{a(this,"l")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(e,o,i={}){let s=c(e);super(o??e,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??s?.hint,this.title=i.title??s?.title,this.loc=i.location,this.code=e,this.status=i.status??s?.status??500,this.docsUrl=i.docsUrl??s?.docsUrl,this.data=i.data}};export{l as a,O as b,N as c,h as d};
14
+ `).filter(t=>!t.startsWith("```")).join(`
15
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"A"),f=a(e=>{for(let t of p)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"d"),N=a(e=>f(e)??E(e),"N");var h=class extends Error{static{a(this,"l")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(t,o,i={}){let s=c(t);super(o??t,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??s?.hint,this.title=i.title??s?.title,this.loc=i.location,this.code=t,this.status=i.status??s?.status??500,this.docsUrl=i.docsUrl??s?.docsUrl,this.data=i.data}};export{l as a,O as b,N as c,h as d};
@@ -1 +1 @@
1
- import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",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:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(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:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
1
+ import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as ae}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",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:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(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:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
@@ -1,3 +1,3 @@
1
- import{b as Se,c as Ie}from"./chunk-YOB2X3FZ.js";import{a as we}from"./chunk-EA2JKR5D.js";import{a as ye}from"./chunk-PD6WIDY6.js";import{a as Ne}from"./chunk-2DX5MROH.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as he}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{d as ge}from"./chunk-SDHFSBNM.js";import{f as xe}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import{d as se}from"./chunk-2Y6PXGIS.js";import{a as ne,e as ie}from"./chunk-WUWBZPUK.js";import{d as be,f as ce,g as de,h as ee,o as me}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Ce,f as Te,g as Ee}from"./chunk-YKXDMIHQ.js";var ve=le(Te(),1);var g=le(Ce(),1);var r=le(Ee(),1);var Ae=ce(H.exportShard),Oe=ce(H.importShard),Le=s(x=>x.map(e=>JSON.stringify(Se(e))).join(`
1
+ import{b as Se,c as Ie}from"./chunk-YOB2X3FZ.js";import{a as we}from"./chunk-EA2JKR5D.js";import{a as ye}from"./chunk-PD6WIDY6.js";import{a as Ne}from"./chunk-2DX5MROH.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as he}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{d as ge}from"./chunk-7TRN7FQ4.js";import{f as xe}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import{d as se}from"./chunk-GETL6R4M.js";import{a as ne,e as ie}from"./chunk-WUWBZPUK.js";import{d as be,f as ce,g as de,h as ee,o as me}from"./chunk-FODLDLE2.js";import{a as s,d as le,e as Ce,f as Te,g as Ee}from"./chunk-YKXDMIHQ.js";var ve=le(Te(),1);var g=le(Ce(),1);var r=le(Ee(),1);var Ae=ce(H.exportShard),Oe=ce(H.importShard),Le=s(x=>x.map(e=>JSON.stringify(Se(e))).join(`
2
2
  `),"Ce"),Je=s(x=>{let e=[],te=x.split(`
3
3
  `);for(let[n,N]of te.entries()){let t=N.trim();if(t==="")continue;let o=Ie(JSON.parse(t));if(typeof o!="object"||o===null)throw new se("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);let b=o;if(typeof b.table!="string"||typeof b.doc!="object"||b.doc===null||Array.isArray(b.doc))throw new se("INTERNAL",`line ${(n+1).toString()}: expected a { table, doc } object`);e.push(b)}return e},"Te"),He=s(x=>{let e=(0,ve.c)(94),{initialShardKey:te}=x,n=xe(),N=ge(),t=be(),[o,b]=(0,g.useState)(te??""),[a,fe]=(0,g.useState)(""),[d,K]=(0,g.useState)(!1),[Q,M]=(0,g.useState)(null),[i,re]=(0,g.useState)(null),[y,ue]=(0,g.useState)(null),V;e[0]!==n||e[1]!==o?(V=s(async()=>{K(!0),M(null),re(null);try{let c=await n.query(Ae,{},de(o));pe(o),fe(Le(c.rows)),ue(c.rows.length)}catch(c){M(ee(c))}K(!1)},"G"),e[0]=n,e[1]=o,e[2]=V):V=e[2];let z=V,W;e[3]!==n||e[4]!==N||e[5]!==a||e[6]!==o||e[7]!==t?(W=s(async()=>{K(!0),M(null),re(null),ue(null);let c;try{c=Je(a)}catch(l){M(t("Invalid NDJSON: {message}",{message:ee(l)})),K(!1);return}try{let l=await n.query(Oe,{rows:c},de(o));pe(o),re(l),N(H.readTablePage),N(H.listTables)}catch(l){M(ee(l))}K(!1)},"Q"),e[3]=n,e[4]=N,e[5]=a,e[6]=o,e[7]=t,e[8]=W):W=e[8];let G=W,w,S,I,m,v,p,f,j,C,u,T;if(e[9]!==d||e[10]!==y||e[11]!==z||e[12]!==i||e[13]!==G||e[14]!==a||e[15]!==o||e[16]!==t){let c=i===null?0:Object.values(i.inserted).reduce(_e,0),l;e[28]!==z?(l=s(()=>{me(z())},"o"),e[28]=z,e[29]=l):l=e[29];let oe=l,Y;e[30]!==G?(Y=s(()=>{me(G())},"Y"),e[30]=G,e[31]=Y):Y=e[31];let ae=Y,Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=s(h=>{fe(h.target.value)},"Z"),e[32]=Z):Z=e[32];let je=Z;T="flex flex-col gap-4",I="lunora-export-import";let L;e[33]!==t?(L=t("Export"),e[33]=t,e[34]=L):L=e[34];let J;e[35]!==L?(J=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:L})}),e[35]=L,e[36]=J):J=e[36];let _;e[37]!==o?(_=(0,r.jsx)(Ne,{onChange:b,testId:"ei-shard-input",value:o}),e[37]=o,e[38]=_):_=e[38];let $;e[39]!==t?($=t("Export"),e[39]=t,e[40]=$):$=e[40];let k;e[41]!==d||e[42]!==oe||e[43]!==$?(k=(0,r.jsx)(he,{"data-testid":"ei-export",disabled:d,onClick:oe,type:"button",children:$}),e[41]=d,e[42]=oe,e[43]=$,e[44]=k):k=e[44];let D;e[45]!==_||e[46]!==k?(D=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,k]}),e[45]=_,e[46]=k,e[47]=D):D=e[47];let q;e[48]!==y||e[49]!==t?(q=y!==null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:t("Exported {count} rows.",{count:y})}),e[48]=y,e[49]=t,e[50]=q):q=e[50];let B;e[51]!==D||e[52]!==q?(B=(0,r.jsxs)(ie,{className:"flex flex-col gap-3 p-4",children:[D,q]}),e[51]=D,e[52]=q,e[53]=B):B=e[53],e[54]!==J||e[55]!==B?(m=(0,r.jsxs)(ne,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",children:[J,B]}),e[54]=J,e[55]=B,e[56]=m):m=e[56],S=ne,C="gap-0 py-0 rounded-xl border border-border bg-card shadow-xs";let P;e[57]!==t?(P=t("Import"),e[57]=t,e[58]=P):P=e[58],e[59]!==P?(u=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:P})}),e[59]=P,e[60]=u):u=e[60],w=ie,v="flex flex-col gap-3 p-4",e[61]!==a?(p=(0,r.jsx)(we,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:je,placeholder:'{"table":"messages","doc":{\u2026}}',value:a}),e[61]=a,e[62]=p):p=e[62];let R;e[63]!==t?(R=t("Import (writes rows)?"),e[63]=t,e[64]=R):R=e[64];let U;e[65]!==d||e[66]!==a?(U=d||a.trim()==="",e[65]=d,e[66]=a,e[67]=U):U=e[67];let F;e[68]!==t?(F=t("Import"),e[68]=t,e[69]=F):F=e[69],e[70]!==ae||e[71]!==R||e[72]!==U||e[73]!==F?(f=(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,r.jsx)(ye,{confirmLabel:R,disabled:U,onConfirm:ae,testId:"ei-import",children:F})}),e[70]=ae,e[71]=R,e[72]=U,e[73]=F,e[74]=f):f=e[74],j=i!==null&&(0,r.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:i.conflicts,errors:i.errors.length,inserted:c})}),i.errors.length>0&&(0,r.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:i.errors.map(h=>(0,r.jsx)("li",{className:"text-xs text-destructive",children:t("line {line} ({table}): {message}",{line:h.line,message:h.message,table:h.table})},`${h.table}-${h.line.toString()}`))})]}),e[9]=d,e[10]=y,e[11]=z,e[12]=i,e[13]=G,e[14]=a,e[15]=o,e[16]=t,e[17]=w,e[18]=S,e[19]=I,e[20]=m,e[21]=v,e[22]=p,e[23]=f,e[24]=j,e[25]=C,e[26]=u,e[27]=T}else w=e[17],S=e[18],I=e[19],m=e[20],v=e[21],p=e[22],f=e[23],j=e[24],C=e[25],u=e[26],T=e[27];let E;e[75]!==w||e[76]!==v||e[77]!==p||e[78]!==f||e[79]!==j?(E=(0,r.jsxs)(w,{className:v,children:[p,f,j]}),e[75]=w,e[76]=v,e[77]=p,e[78]=f,e[79]=j,e[80]=E):E=e[80];let A;e[81]!==S||e[82]!==E||e[83]!==C||e[84]!==u?(A=(0,r.jsxs)(S,{className:C,children:[u,E]}),e[81]=S,e[82]=E,e[83]=C,e[84]=u,e[85]=A):A=e[85];let O;e[86]!==Q?(O=Q!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:Q}),e[86]=Q,e[87]=O):O=e[87];let X;return e[88]!==I||e[89]!==m||e[90]!==A||e[91]!==O||e[92]!==T?(X=(0,r.jsxs)("div",{className:T,"data-testid":I,children:[m,A,O]}),e[88]=I,e[89]=m,e[90]=A,e[91]=O,e[92]=T,e[93]=X):X=e[93],X},"Ue");function _e(x,e){return x+e}s(_e,"Ae");export{He as ExportImportPanel};
@@ -1 +1 @@
1
- import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as M}from"./chunk-FKVZRPV5.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HEAQVSNS.js";import{a as z,e as D}from"./chunk-WUWBZPUK.js";import{d as F,r as O}from"./chunk-FODLDLE2.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-YKXDMIHQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
1
+ import{W as k}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as j}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as M}from"./chunk-FKVZRPV5.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HEAQVSNS.js";import{a as z,e as D}from"./chunk-WUWBZPUK.js";import{d as F,r as O}from"./chunk-FODLDLE2.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-YKXDMIHQ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
@@ -1 +1 @@
1
- import{b as g}from"./chunk-AX24JD2G.js";import"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
1
+ import{b as g}from"./chunk-CZIPGHIR.js";import"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import"./chunk-HEAQVSNS.js";import"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as r,d as h,f as S,g as A}from"./chunk-YKXDMIHQ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
@@ -1 +1 @@
1
- import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-5MKG6RW3.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-SDHFSBNM.js";import{f as V}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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:a("Actions")})}),(0,t.jsxs)(W,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
1
+ import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-FZ45WJQK.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-7TRN7FQ4.js";import{f as V}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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:a("Actions")})}),(0,t.jsxs)(W,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:ie.map(([w,B])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
@@ -1,4 +1,4 @@
1
- import{a as nt,b as rt}from"./chunk-5B6TTEP6.js";import{c as tt}from"./chunk-M4POCI2J.js";import{a as et}from"./chunk-PZVVEPIN.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-URBHAYYZ.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-PD6WIDY6.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as Ce,e as Ee,f as Le,g as He}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as qe}from"./chunk-4ZEL6BYL.js";import"./chunk-SDHFSBNM.js";import{f as Ie}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as Se,g as Ne,h as Ge,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as Be,e as St,f as Nt,g as qt,i as me}from"./chunk-YKXDMIHQ.js";var G=Be(Nt(),1);var j=Be(St(),1);var u=Be(qt(),1);var Ct="x",ot=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
1
+ import{a as nt,b as rt}from"./chunk-YBZYUPAG.js";import{c as tt}from"./chunk-M4POCI2J.js";import{a as et}from"./chunk-MKRJGSYF.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-MWSNVNHE.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-PD6WIDY6.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as Ce,e as Ee,f as Le,g as He}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as qe}from"./chunk-4ZEL6BYL.js";import"./chunk-7TRN7FQ4.js";import{f as Ie}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as Se,g as Ne,h as Ge,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as Be,e as St,f as Nt,g as qt,i as me}from"./chunk-YKXDMIHQ.js";var G=Be(Nt(),1);var j=Be(St(),1);var u=Be(qt(),1);var Ct="x",ot=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
2
2
  `;)n+=1;return n},"tt"),dt=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"nt"),ut=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=kt[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(ot,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(ot,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(Ct,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
3
3
  `&&(e[t]=`
4
4
  `);return e.join("")},"st"),Tt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Rt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,_t=/^\w+/u,It=/;\s*$/u,Et=/\s/u,mt=l(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Et.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ct(s,e);else if(n==="/"&&s[e+1]==="*"){let t=dt(s,e);if(t===-1)break;e=t}else break}return e},"ot"),Lt=l(s=>{let e=mt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(ut(n)??n).replace(It,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let a="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Tt.test(o))return{code:"SQL_NOT_READONLY",length:_t.exec(o)?.[0].length??1,message:a,offset:e};let c=Rt.exec(o);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${a} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},"Ot"),Ot=/^explain\b/iu,At=l(s=>Ot.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Mt"),Qe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Lt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"We"),ft=l(s=>{let e=ut(s);if(e===void 0)return Qe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Qe(s.slice(t,o),t)),t=o+1);return n},"lt"),Dt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Mt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],De=String.fromCodePoint(0),$t=new RegExp(`${De}${String.raw`(\d+)`}${De}`,"gu"),Ft=Dt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),zt=Mt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
@@ -1 +1 @@
1
- import{W as K}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{f as z}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as W}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as L,d as f,e as c,f as d}from"./chunk-HEAQVSNS.js";import{a as I,e as j}from"./chunk-WUWBZPUK.js";import{d as F,h as S,n as Z,o as V}from"./chunk-FODLDLE2.js";import{a as h,d as C,e as U,f as G,g as J}from"./chunk-YKXDMIHQ.js";var A=C(G(),1);var n=C(U(),1);var e=C(J(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=z(),a=F(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,$]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,H=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"Q"),O=h(t=>{D(t.target.value)},"$"),P=h(async()=>{let t=b.trim();if(!(N===null||t==="")){$(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}$(!1)}},"A"),R=h(()=>{V(P())},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(L,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:H,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(K,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:O,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(Q,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:R,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":Z(t.metadata)})]},t.id))})]})})})]})]})},"se");export{se as VectorBrowser};
1
+ import{W as K}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{f as z}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as W}from"./chunk-FKVZRPV5.js";import{a as q,b as B,c as L,d as f,e as c,f as d}from"./chunk-HEAQVSNS.js";import{a as I,e as j}from"./chunk-WUWBZPUK.js";import{d as F,h as S,n as Z,o as V}from"./chunk-FODLDLE2.js";import{a as h,d as C,e as U,f as G,g as J}from"./chunk-YKXDMIHQ.js";var A=C(G(),1);var n=C(U(),1);var e=C(J(),1);var X=10,g=h(v=>{let l=(0,A.c)(7),{label:m,value:a}=v,r;l[0]!==m?(r=(0,e.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:m}),l[0]=m,l[1]=r):r=l[1];let p=a??"\u2014",s;l[2]!==p?(s=(0,e.jsx)("span",{className:"font-mono text-sm",children:p}),l[2]=p,l[3]=s):s=l[3];let u;return l[4]!==r||l[5]!==s?(u=(0,e.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,s]}),l[4]=r,l[5]=s,l[6]=u):u=l[6],u},"g"),se=h(({loadIndexes:v,runQuery:l}={})=>{let m=z(),a=F(),[r,p]=(0,n.useState)(null),[s,u]=(0,n.useState)(null),[N,E]=(0,n.useState)(null),[b,D]=(0,n.useState)(""),[x,y]=(0,n.useState)(null),[M,w]=(0,n.useState)(null),[T,$]=(0,n.useState)(!1);(0,n.useEffect)(()=>{let t={cancelled:!1};return V((async()=>{try{let i=await(v??(()=>m.listVectorIndexes()))();t.cancelled||(p(i),u(null),E(k=>k??i[0]?.name??null))}catch(i){t.cancelled||(p(null),u(S(i)))}})()),()=>{t.cancelled=!0}},[m,v]);let o=r?.find(t=>t.name===N)??null,H=h(t=>{E(t.currentTarget.dataset.index??null),y(null),w(null)},"Q"),O=h(t=>{D(t.target.value)},"$"),P=h(async()=>{let t=b.trim();if(!(N===null||t==="")){$(!0),w(null);try{let i=await(l??(k=>m.queryVectorIndex(k)))({name:N,text:t,topK:X});y(i)}catch(i){y(null),w(S(i))}$(!1)}},"A"),R=h(()=>{V(P())},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[s!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:s}),r!==null&&r.length===0&&(0,e.jsx)(W,{description:a("Indexes declared with .vectorize() or defineVectorIndex() appear here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:a("No vector indexes.")}),r!==null&&r.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-table",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("name")}),(0,e.jsx)(c,{children:a("table")}),(0,e.jsx)(c,{children:a("dimensions")}),(0,e.jsx)(c,{children:a("metric")}),(0,e.jsx)(c,{children:a("vectors")})]})}),(0,e.jsx)(L,{children:r.map(t=>(0,e.jsxs)(f,{className:t.name===N?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":t.name,"data-testid":`vector-row-${t.name}`,onClick:H,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.table}),(0,e.jsx)(d,{className:"tabular-nums",children:t.dimensions??"\u2014"}),(0,e.jsx)(d,{children:t.metric??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:t.vectorsCount??"\u2014"})]},t.name))})]})})}),o!==null&&(0,e.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,e.jsx)(g,{label:a("field"),value:o.field}),(0,e.jsx)(g,{label:a("dimensions"),value:o.dimensions}),(0,e.jsx)(g,{label:a("metric"),value:o.metric}),(0,e.jsx)(g,{label:a("vectors"),value:o.vectorsCount})]}),o.metadata!==void 0&&o.metadata.length>0&&(0,e.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[a("metadata"),": ",(0,e.jsx)("span",{className:"font-mono",children:o.metadata.join(", ")})]}),(0,e.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,e.jsx)(K,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:O,placeholder:a("Search by similarity\u2026"),value:b}),(0,e.jsx)(Q,{"data-testid":"vector-search",disabled:T||b.trim()==="",onClick:R,children:a(T?"Searching\u2026":"Search")})]}),M!==null&&(0,e.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:M}),x!==null&&x.length===0&&(0,e.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:a("No matches.")}),x!==null&&x.length>0&&(0,e.jsx)(I,{className:"mt-3 overflow-hidden py-0",children:(0,e.jsx)(j,{className:"px-0",children:(0,e.jsxs)(q,{"data-testid":"vector-matches",children:[(0,e.jsx)(B,{children:(0,e.jsxs)(f,{children:[(0,e.jsx)(c,{children:a("id")}),(0,e.jsx)(c,{children:a("score")}),(0,e.jsx)(c,{children:a("metadata")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(f,{"data-testid":`vector-match-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.id}),(0,e.jsx)(d,{className:"tabular-nums",children:t.score.toFixed(4)}),(0,e.jsx)(d,{className:"max-w-md truncate font-mono text-xs",children:t.metadata===void 0?"\u2014":Z(t.metadata)})]},t.id))})]})})})]})]})},"se");export{se as VectorBrowser};
@@ -1 +1 @@
1
- import{b as u}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as y}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as N}from"./chunk-4ZEL6BYL.js";import{c as v}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as g}from"./chunk-FKVZRPV5.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-HEAQVSNS.js";import{a as f,e as x}from"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as n,d as R,g as T}from"./chunk-YKXDMIHQ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),U=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=p(),{data:l,error:E,errorSource:A,liveError:I}=v(N.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(g,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(x,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=U(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(u,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
1
+ import{b as u}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as y}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as N}from"./chunk-4ZEL6BYL.js";import{c as v}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as g}from"./chunk-FKVZRPV5.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-HEAQVSNS.js";import{a as f,e as x}from"./chunk-WUWBZPUK.js";import{d as p}from"./chunk-FODLDLE2.js";import{a as n,d as R,g as T}from"./chunk-YKXDMIHQ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),U=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=p(),{data:l,error:E,errorSource:A,liveError:I}=v(N.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(g,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(f,{className:"overflow-hidden py-0",children:(0,e.jsx)(x,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=U(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(u,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
@@ -1 +1 @@
1
- import{a as q}from"./chunk-66UGPQVC.js";import{a as F}from"./chunk-S3CRZLGS.js";import{a as D}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as L}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as $}from"./chunk-FKVZRPV5.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HEAQVSNS.js";import{a as M,e as T}from"./chunk-WUWBZPUK.js";import{d as A,m as E}from"./chunk-FODLDLE2.js";import{a as N,d as j,f as H,g as U}from"./chunk-YKXDMIHQ.js";var R=j(H(),1);var t=j(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=A(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(D,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)($,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)(M,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};
1
+ import{a as q}from"./chunk-66UGPQVC.js";import{a as F}from"./chunk-S3CRZLGS.js";import{a as D}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as L}from"./chunk-FDB7QVEC.js";import"./chunk-ULIQFBZU.js";import"./chunk-2KM4MU7U.js";import"./chunk-35DM4JJG.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-7TRN7FQ4.js";import"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as $}from"./chunk-FKVZRPV5.js";import{a as O,b as P,c as W,d as C,e as h,f as p}from"./chunk-HEAQVSNS.js";import{a as M,e as T}from"./chunk-WUWBZPUK.js";import{d as A,m as E}from"./chunk-FODLDLE2.js";import{a as N,d as j,f as H,g as U}from"./chunk-YKXDMIHQ.js";var R=j(H(),1);var t=j(U(),1);var J=80,Z=N(a=>{if(a===void 0)return"";let e=JSON.stringify(a,E);return e.length>J?`${e.slice(0,J)}\u2026`:e},"G"),z=N(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"J"),w=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),ce=N(a=>{let e=(0,R.c)(22),{initialShardKey:r}=a,n=A(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:G}=_(B.listSubscriptions,f,b);q(G,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:z(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(D,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(S,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(S,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)($,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)(M,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(C,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(W,{children:k.map(y=>{let{subscription:I}=y,K=Z(I?.args);return(0,t.jsxs)(C,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&(0,t.jsx)(S,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??w}),(0,t.jsx)(p,{children:I?.table??w}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||w})]},y.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"ae");export{ce as default};