@lunora/studio 1.0.0-alpha.100 → 1.0.0-alpha.102

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 (113) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/packem_chunks/LogsPanel.js +1 -1
  3. package/dist/packem_chunks/MetricsPanel.js +1 -1
  4. package/dist/packem_chunks/traces-panel.js +1 -1
  5. package/dist/packem_shared/log-line-CmtmbZNE.js +1 -0
  6. package/dist/packem_shared/trace-handoff-D7j9TjUT.js +1 -0
  7. package/dist/packem_shared/use-open-trace-D9XDDHHS.js +1 -0
  8. package/dist/standalone/chunk-22SUVVIR.js +1 -0
  9. package/dist/standalone/{chunk-C2OHUG2J.js → chunk-35SAF2LS.js} +1 -1
  10. package/dist/standalone/chunk-37PXYIVK.js +1 -0
  11. package/dist/standalone/{chunk-JN2Y24PY.js → chunk-3DH35OZ5.js} +1 -1
  12. package/dist/standalone/chunk-3RC2X4I2.js +1 -0
  13. package/dist/standalone/chunk-4KPBTODU.js +1 -0
  14. package/dist/standalone/{chunk-EALHAMLB.js → chunk-4PDTGZDC.js} +2 -2
  15. package/dist/standalone/{chunk-MQ2GKKQ6.js → chunk-4V4RO52I.js} +1 -1
  16. package/dist/standalone/{chunk-FMM3XUZH.js → chunk-5BEGIQM7.js} +1 -1
  17. package/dist/standalone/chunk-5HMBKUFH.js +1 -0
  18. package/dist/standalone/chunk-6C6FRIYD.js +1 -0
  19. package/dist/standalone/{chunk-322ZP3GW.js → chunk-6IZBFC3G.js} +1 -1
  20. package/dist/standalone/{chunk-BUVIRYQM.js → chunk-6THGMZNI.js} +1 -1
  21. package/dist/standalone/chunk-7AY2447G.js +1 -0
  22. package/dist/standalone/{chunk-5NCGZJ55.js → chunk-7GNNMMT4.js} +1 -1
  23. package/dist/standalone/chunk-7MT6C3FS.js +1 -0
  24. package/dist/standalone/chunk-A3DCTWSA.js +1 -0
  25. package/dist/standalone/{chunk-M43KO276.js → chunk-APBWFKW5.js} +1 -1
  26. package/dist/standalone/chunk-B5FMYLVA.js +1 -0
  27. package/dist/standalone/chunk-BB7WLC24.js +1 -0
  28. package/dist/standalone/{chunk-Y7XGNPT6.js → chunk-BCMLQ3LV.js} +1 -1
  29. package/dist/standalone/{chunk-55PVLIN3.js → chunk-BIVP5DZB.js} +1 -1
  30. package/dist/standalone/{chunk-DGRAPESO.js → chunk-DBAMCESO.js} +1 -1
  31. package/dist/standalone/{chunk-GGADAESO.js → chunk-DC23USXJ.js} +1 -1
  32. package/dist/standalone/chunk-DJZYD5I5.js +1 -0
  33. package/dist/standalone/chunk-DSDJ3QRD.js +1 -0
  34. package/dist/standalone/chunk-DY34ZZ5K.js +1 -0
  35. package/dist/standalone/chunk-ELI5HREQ.js +2 -0
  36. package/dist/standalone/{chunk-XAEG372C.js → chunk-ELJZNBBJ.js} +1 -1
  37. package/dist/standalone/{chunk-RTMMB3OY.js → chunk-EWGPDRH3.js} +1 -1
  38. package/dist/standalone/chunk-G6VZTEGG.js +1 -0
  39. package/dist/standalone/{chunk-4KIQ5RLS.js → chunk-GG6PIGQO.js} +1 -1
  40. package/dist/standalone/{chunk-MZ2JNVMR.js → chunk-GRRBUXEI.js} +1 -1
  41. package/dist/standalone/{chunk-F7IRBXWY.js → chunk-GSQDZMV5.js} +1 -1
  42. package/dist/standalone/{chunk-NE4N6I57.js → chunk-IID7VT2A.js} +1 -1
  43. package/dist/standalone/{chunk-PVF5J5UD.js → chunk-IRXDBOOU.js} +1 -1
  44. package/dist/standalone/chunk-K2E4OECF.js +1 -0
  45. package/dist/standalone/chunk-LKBKYLWK.js +1 -0
  46. package/dist/standalone/{chunk-UF6XZKV3.js → chunk-LPBWDHKM.js} +1 -1
  47. package/dist/standalone/{chunk-M3NGYXDR.js → chunk-LYVP5PT6.js} +1 -1
  48. package/dist/standalone/chunk-LZFOZFYW.js +1 -0
  49. package/dist/standalone/{chunk-WMLKVJUX.js → chunk-MRK53LUL.js} +1 -1
  50. package/dist/standalone/chunk-MWIKAR7F.js +1 -0
  51. package/dist/standalone/{chunk-5GQFG6QI.js → chunk-NH4HJFG3.js} +1 -1
  52. package/dist/standalone/chunk-NLHEYDAA.js +1 -0
  53. package/dist/standalone/{chunk-GVSKCIJR.js → chunk-NLWDTGEP.js} +1 -1
  54. package/dist/standalone/chunk-OHOWUEQ3.js +1 -0
  55. package/dist/standalone/chunk-ORNIQZ2P.js +1 -0
  56. package/dist/standalone/chunk-PCAI3G4M.js +1 -0
  57. package/dist/standalone/{chunk-V76WCOMM.js → chunk-QJW2Z3SI.js} +1 -1
  58. package/dist/standalone/{chunk-MKYEFQCA.js → chunk-RA5DW5MU.js} +1 -1
  59. package/dist/standalone/chunk-RO6LEET3.js +1 -0
  60. package/dist/standalone/chunk-RTXAZLAE.js +1 -0
  61. package/dist/standalone/{chunk-AB5WGAX6.js → chunk-SBZXUGZ7.js} +1 -1
  62. package/dist/standalone/chunk-T6YGEL6X.js +1 -0
  63. package/dist/standalone/chunk-TFSGDOCG.js +1 -0
  64. package/dist/standalone/{chunk-FKAUVTSS.js → chunk-TQEVFVNP.js} +1 -1
  65. package/dist/standalone/{chunk-JXF2J6QZ.js → chunk-U4THUBUT.js} +1 -1
  66. package/dist/standalone/{chunk-4HNNNIDW.js → chunk-U62QRT34.js} +1 -1
  67. package/dist/standalone/chunk-UALL2OBT.js +1 -0
  68. package/dist/standalone/{chunk-BQNVN2OD.js → chunk-UP7OTXKF.js} +1 -1
  69. package/dist/standalone/chunk-VITTPKH5.js +1 -0
  70. package/dist/standalone/{chunk-CJLOWFCK.js → chunk-W3VOX7VR.js} +1 -1
  71. package/dist/standalone/chunk-W3XKLUWQ.js +1 -0
  72. package/dist/standalone/{chunk-6UPCJAAI.js → chunk-WMBDXCYL.js} +1 -1
  73. package/dist/standalone/{chunk-6V27P65N.js → chunk-WPK2Q33V.js} +1 -1
  74. package/dist/standalone/{chunk-YC52XCPK.js → chunk-X7B6PLEW.js} +4 -4
  75. package/dist/standalone/chunk-Y32QIKBS.js +1 -0
  76. package/dist/standalone/{chunk-K3PSOZXH.js → chunk-YZ7OINPX.js} +1 -1
  77. package/dist/standalone/{chunk-HGSIVV32.js → chunk-ZMDNTTAC.js} +1 -1
  78. package/dist/standalone/{chunk-P4BOVBMR.js → chunk-ZNNKWEH5.js} +1 -1
  79. package/dist/standalone/studio.js +1 -1
  80. package/dist/styles.css +1 -1
  81. package/package.json +6 -6
  82. package/dist/packem_shared/log-fields-CoL3hsIQ.js +0 -1
  83. package/dist/packem_shared/trace-handoff-CuZ6WGgo.js +0 -1
  84. package/dist/standalone/chunk-5PQCUZIE.js +0 -1
  85. package/dist/standalone/chunk-6UPIWTCN.js +0 -1
  86. package/dist/standalone/chunk-7LJL6UC2.js +0 -1
  87. package/dist/standalone/chunk-APXXEXIX.js +0 -1
  88. package/dist/standalone/chunk-AREBQI6D.js +0 -1
  89. package/dist/standalone/chunk-DB2D42KJ.js +0 -1
  90. package/dist/standalone/chunk-DBCMZ4NF.js +0 -1
  91. package/dist/standalone/chunk-EIK3BLGV.js +0 -1
  92. package/dist/standalone/chunk-EV2NKHXP.js +0 -1
  93. package/dist/standalone/chunk-F6W6WUAJ.js +0 -1
  94. package/dist/standalone/chunk-FXCBF4XT.js +0 -1
  95. package/dist/standalone/chunk-GRTTHN6U.js +0 -1
  96. package/dist/standalone/chunk-IVQUDVQV.js +0 -1
  97. package/dist/standalone/chunk-JYYXXMLM.js +0 -1
  98. package/dist/standalone/chunk-KESD5PH6.js +0 -1
  99. package/dist/standalone/chunk-LUIZB427.js +0 -1
  100. package/dist/standalone/chunk-PKEBAPJY.js +0 -1
  101. package/dist/standalone/chunk-PKSAWP56.js +0 -1
  102. package/dist/standalone/chunk-QC2SRHZV.js +0 -1
  103. package/dist/standalone/chunk-QNWJ5Q2O.js +0 -1
  104. package/dist/standalone/chunk-QWGT25SE.js +0 -1
  105. package/dist/standalone/chunk-QZFRZEDN.js +0 -1
  106. package/dist/standalone/chunk-UETRSNZI.js +0 -2
  107. package/dist/standalone/chunk-UF7QFJ65.js +0 -1
  108. package/dist/standalone/chunk-VC4WBYE6.js +0 -1
  109. package/dist/standalone/chunk-VJHQW5X5.js +0 -1
  110. package/dist/standalone/chunk-W25EQ7YQ.js +0 -1
  111. package/dist/standalone/chunk-WGEZGQZ5.js +0 -1
  112. package/dist/standalone/chunk-XHMHOSGK.js +0 -1
  113. package/dist/standalone/chunk-Z6CJGUSL.js +0 -1
package/dist/index.d.ts CHANGED
@@ -339,6 +339,8 @@ interface LogEntry {
339
339
  level: LogLevel;
340
340
  message: string;
341
341
  timestamp: number;
342
+ /** Trace the line was emitted under; absent outside a dispatch (container lifecycle, hibernation-path errors) and on any worker predating the field. The key the Logs panel's Trace link and the Traces panel's correlated logs both join on. */
343
+ traceId?: string;
342
344
  }
343
345
  /** Payload of a `__lunora_admin__:getLogs` call: the buffered entries, newest first. */
344
346
  interface LogsResult {
@@ -1373,7 +1375,7 @@ declare const useDebounced: <T>(value: T, delayMs?: number, resetKey?: unknown)
1373
1375
  * sibling catalog (for example `de.ts`) mapping each id to its translation and
1374
1376
  * register it via `createStudioI18n(locale, { en: enMessages, de: deMessages })`.
1375
1377
  */
1376
- declare const MESSAGE_IDS: readonly ["Agents", "Agent", "Threads", "Timeline", "Messages", "Tokens", "Updated", "Content", "Tool", "Usage", "Approval", "Score your app's advisor findings: a grade, the coverage split, and every procedure ranked worst-first.", "Health score", "Rules fired", "Procedure", "Score", "Kind", "clean", "warned", "failing", "exempt", "sensitive", "no reason given", "Schema & config", "Inspect agent threads, message timelines, tool calls, and token usage.", "Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.", "No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents.", "No agents configured", "No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here.", "No agent threads yet", "This thread has no messages yet.", "Bindings", "KV Namespaces", "R2 Buckets", "Vectorize Indexes", "{count} bindings", "1 binding", "Lunora AI rules aren't installed.", "lets your coding agent use Lunora correctly.", "Dismiss", ", changed", "(no subject)", "(root)", "{count} active", "{count} calls", "{count} failed", "{total} total", "No subscriptions yet", "No payments configured", "No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions.", "Payments", "Plan", "Provider", "Recent webhook events", "Renews", "State", "Subscriptions", "Synced customers, subscriptions, and webhook events.", "{count} messages", "{count} pending changes", "{count} running", "{name} ({rowCount})", "{rangeStart}-{rangeEnd} of {total}", "{rate} ({count} entries)", "{reachable} reachable", "{reachable} reachable, {failed} unreachable", "{status} — processed", "{title} failed", "Actions", "Actions have no React hook — call them through the client.", "Add a widget to chart a saved SQL query on this browser.", "Add index on {table}", "Add row", "Add widget", "admin token", "Aggregating…", "all", "All shards", "API", "API reference unavailable", "API resources", "API usage snippets", "API view", "Arguments", "Auth", "Auth failures", "Auth failures over time", "Cache hit rate", "Call this {kind} from your app.", "Cancel", "Cancel job?", "Cc", "changed", "Chart widgets backed by saved read-only SQL queries.", "Lunora surfaces slow functions, error spikes, and cache problems here.", "Clear", "Clear inbox", "Columns unavailable", "CLI", "Client", "collecting samples…", "Combined cache hit rate", "Commit", "Committing…", "Breadcrumb", "Confirm", "Connect", "Connect to Lunora Studio", "Connected", "Connecting…", "Enter your admin token to access the studio.", "From your worker's LUNORA_ADMIN_TOKEN — your project's .dev.vars in dev, or a deployment secret in production.", "Local", "Not connected", "content-type", "Copy", "Copy link", "Copy-paste snippets for calling your functions and tables.", "created", "Cron triggers", "Dashboards", "Data", "Data migrations you run against this shard will be tracked here.", "Data model", "Database", "Database size", "db size", "Instruments", "Instruments unavailable: {error}", "Counter", "Gauge", "Histogram", "count", "range", "trend", "trace", "{name} trend", "Open the exemplar trace {trace}", "Delete", "Delete saved query {name}", "Delete?", "direction", "Direction", "Discard", "down", "Dry run", "Dry run: ", "Edit", "Edit widget", "email", "Email preview", "Email your app sends in dev is captured here — nothing is delivered.", "Email your app sent, captured in dev.", "Enter a migration id", "error", "Error rate", "errors", "Errors", "Errors over time", "expires", "Export", "PNG", "SVG", "Export / Import", "Exported {count} rows.", "Facets", "file:function", "Files", "Filter messages", "Filter tables", "Find table…", "Foreign key", "From", "function", "Function", "Function path", "Functions", "Functions by error rate", "Graph", "Headers", "Health", "Indexes", "Hide", "HTML", "id", "Idle", "Import", "Import (writes rows)?", "Inserted {inserted}, {conflicts} conflicts, {errors} errors.", "Interactive OpenAPI reference and copy-paste snippets for your functions.", "Invalid JSON args: {message}", "Invalid JSON: {message}", "Invalid NDJSON: {message}", "ip", "Jobs queued with runAfter / runAt will appear here.", "JSON", "key", "Key prefix", "key prefix (optional)", "Level filter", "line {line} ({table}): {message}", "List", "Live", "Live — changes stream in automatically", "Live unavailable", "Live unavailable: {liveError}", "Live: on", "Load", "Load more", "Load tables", "Logic", "Logs", "Mail", "Mask sensitive columns", "Metrics", "migration id", "Migration id", "Migrations", "Missing index", "name", "Next", "no", "No active sessions.", "no cache configured", "No captured email.", "No cron triggers.", "No function activity yet.", "No functions or tables to document yet.", "No global tables.", "No headers.", "No HTML body.", "No logs.", "Archive", "Log archive not configured", "Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here.", "No archived logs.", "No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2.", "Function path prefix", "function path…", "user id…", "Minimum level", "min level", "Time", "Level", "Trace", "User", "No migrations have run on this shard.", "No objects.", "No recent errors.", "No scheduled jobs.", "No tables to graph.", "No tables match your filter.", "No text body.", "No users.", "No widgets yet", "Objects you upload to your R2 buckets will appear here.", "Observability", "of {pages}", "off", "Offline", "ok", "OK", "on", "Open {target} {id}", "Open in new tab", "Outcome filter", "Page", "Plain text", "Prefill", "Previous", "Primary key", "processed", "React", "Read and write this table through the typed data model.", "Recent errors", "Recent logs", "Recently visited shards — click to switch", "Refresh", "Reload tables", "Remove widget", "RLS Policies", "Policies", "No policies defined", "No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows.", "Read", "Insert", "Update", "Guarded by", "Guarded", "Roles", "No roles defined", "No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks.", "Permissions", "Run as identity (userId)", "Leave empty to run as admin", "Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.", "as {userId}", "No policy", "Covered by {procedure}", "Uncovered — reachable without a policy", "Masked columns", "No tables in this deployment's schema.", "Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix.", "Pick a function and an identity, then run it to see the access outcome.", "Probe", "Probe this", "Run as (userId)", "Identity (userId) to run as", "Run probe", "Allowed", "Denied", "Probing…", "Set `runAsIdentity` to forge an identity and probe access.", "Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS.", "Inspect access policies per table, and probe a function as any identity.", "Scaffold access rules", "Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.", "New policy file", "Wire into a procedure", "Policy name", "Create policy file", "Procedure file path", "Exported procedure", "Policy set identifier", "Wire RLS", "Creating…", "Wiring…", "Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.", "This change must be made by hand — the scaffolder only adds new, deny-by-default rules.", "requests", "Requests", "Requests / interval", "Requests over time", "Requests per interval over time", "Row actions", "Row document JSON", "Rows per page", "Run", "Run migration", "Run migration?", "Running…", "Query name", "Save", "Save query", "Save widget", "Saved", "schedule", "target", "workflow", "Run now", "Run now?", "Running…", "ran", "attempts", "backlog", "Dead letter", "Drop", "Drop job?", "in flight", "Jobs that exhaust their retry budget are parked here instead of being dropped.", "last tried", "max concurrency", "No dead-letter jobs.", "No workpools.", "pool", "Pools", "pools", "Pools created with createWorkpool appear here once they have activity.", "queued", "Retry", "Schedule view", "Scheduled", "scheduled for", "Scheduled jobs", "Scheduler backlog", "Schema", "Schema graph", "Schema view", "search message", "Search messages", "Search rows", "search table…", "Search…", "Select a function or table to see how to call it from your app.", "Select all rows", "Select row", "Send test", "Sent", "Service level", "Sessions", "Sessions for {userId}", "shard", "Shard", "Shard key", "shard key (optional)", "Shard key (optional)", "Shards", "Shards seen", "Signature", "size", "Snippet flavour", "State-changing admin operations are recorded here.", "status", "Storage", "Storage tier", "Storage tiers", "Studio", "Studio areas", "Studio failed", "Switch to dark theme", "Switch to light theme", "Table", "Table list", "Table touched", "Tables", "To", "Token rides the WebSocket URL — it can surface in browser DevTools and server logs. Use a dev-only token.", "Total database size", "Total errors", "Total requests", "Triggers declared with the cronJobs() builder appear here.", "Try again", "unreachable", "up", "updated", "Uptime", "user agent", "User id", "userId", "Users", "Users who sign up to your app will appear here.", "verified", "Widget title", "yes", "A live stream of recent function logs.", "Browse and edit rows across your shard and global tables.", "Browse auth users and their active sessions.", "Browse objects in your R2 storage buckets.", "Export a shard to NDJSON, or import rows from it.", "At-a-glance connection, error, and shard signals.", "Inspect and cancel scheduled jobs.", "Inspect each table and its columns.", "Inspect row-level-security policies and roles, per table.", "Per-shard health and aggregate metrics.", "Review migration status and run them.", "Run registered queries, mutations, and actions.", "Global tables (D1)", "Shard tables", "{shard} tables", "Tables marked .global() (D1-backed, region-replicated) will appear here.", "Select a table to browse its rows.", "Shared across every tenant, stored once in D1. Includes auth tables.", "Partitioned per shard key into separate Durable Objects — scoped to the shard above.", "avg", "calls", "conflicts", "kind", "last error", "last run", "max", "Most called", "No functions have run on this shard yet.", "Recent", "Slowest", "Insights", "Surface slow functions, error spikes, and cache problems.", "No issues detected.", "Low cache hit rate", "High cache eviction rate", "Slow function", "High error rate", "High write contention", "{rate} hit rate over recent traffic.", "{count} entries evicted recently.", "Slowest call took {duration}.", "Slowest call took {duration} — it full-scanned {tables} with no index.", "{rate} of calls failed.", "{rate} of calls hit a write conflict — consider sharding to cut contention.", "Home", "Reports", "SQL / Functions", "Table editor", "Connection, health, and advisor summary for your deployment.", "Collapse sidebar", "Expand sidebar", "SQL editor", "Run read-only SQL against a shard.", "Run", "SQL query", "SQL problems", "Operation console", "Suggest chart", "Describe the query you want", "Draft SQL", "Thinking…", "Fix this", "Related", "p50", "p95", "showing a capped set", "Statements executed in the selected window appear here, with throughput and latency over time.", "No queries in this window.", "Throughput", "Mean latency (ms)", "Schema versions", "Data migrations", "{count} pushes", "live", "Show in console", "Every admin call this studio makes is recorded here.", "{count} rows", "Filter", "Each distinct schema shape this shard runs is recorded here, so you can see what changed and when.", "No schema versions recorded yet.", "First recorded version — every table is new.", "{count} change(s)", "change", "Diagram", "Changes", "added", "changed", "removed", "schema", "{count} columns", "changes", "tables", "{count} breaking", "breaking", "safe", "{count} rows", "Showing the first {max} of {count} rows.", "Showing the {n} most common values.", "No rows returned.", "Private", "Reference", "Search queries…", "New query", "Untitled query", "Delete query", "No saved queries yet — they save to this browser as you type.", "Results", "Explain", "Chart", "Split editor and results", "History", "Format", "Clear history", "No numeric column to chart.", "Click Run to execute your query.", "Untitled", "New tab", "Close tab", "Tab title", "Double-click to rename", "Discard?", "Discard changes", "Keep editing", "Close other tabs", "Close tabs to the right", "Close all tabs", "Discard unsaved tabs?", "column", "keyword", "Columns", "Show all", "Hide all", "Transpose", "Swap rows and columns", "Field", "Row {n}", "Loading…", "No matching row.", "CSV", "SQL", "{count} selected", "Delete {count}", "Delete {count} rows?", "Copy", "Copied", "Cell value", "Close", "Form", "Invalid JSON", "Command palette", "No results.", "Quick links", "Security findings", "Performance issues", "View", "All clear", "No data yet", "Get connected", "No issues found", "No security or performance issues detected.", "Client SDK", "React", "CLI", "Connect an AI agent", "Drive this deployment from an AI agent over the Model Context Protocol — it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in.", "Copy MCP config", "Copy agent prompt", "Advisors", "Security", "Performance", "Warnings", "Info", "Issue type", "Entity/item", "Description", "{count} errors", "{count} warnings", "{count} suggestions", "No errors detected", "No warnings detected", "No suggestions", "Nothing to report for this deployment.", "Security and performance findings for your deployment.", "Review admin gates, credentials, and log redaction.", "Lunora checks admin-token strength, the live-subscription gate, and request-log redaction here.", "No security issues detected.", "Weak admin token", "Weak auth secret", "Session cookies are not Secure", "Wildcard CORS with credentials", "CSRF/origin guard is off", "Security headers are off", "Live admin subscriptions are ungated", "Request log keeps un-redacted args", "Unknown security finding", "Update your worker to a version of Lunora that describes this finding.", "Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.", "Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.", "BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production.", "LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *.", "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.", "LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production.", "Apply index", "Apply index on {table}", "Apply?", "CREATE INDEX SQL copied to clipboard.", "LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.", "This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy.", "Audit", "A durable log of admin state-changing operations.", "Filter audit log", "filter op, table, id", "No audit entries.", "Notifications", "Registered push devices — endpoint, kind, last-send status, and delivery errors.", "Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...).", "No registered devices.", "Filter devices", "filter endpoint, user", "{count} devices", "endpoint", "last seen", "n/a", "time", "op", "table", "detail", "Auth audit", "Authentication and security events — sign-ins, MFA, and session changes.", "Filter security events", "filter event, actor, IP", "Authentication and security events are recorded here.", "No security events.", "event", "actor", "ip / user agent", "outcome", "success", "failure", "Settings", "Deployment", "Read-only deployment config — vars, secrets, and bindings.", "Environment & bindings", "No environment variables or bindings.", "Open in Cloudflare", "Remove filter", "View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard.", "URL", "Environment", "Version", "value", "Cascade impact", "Delete preview — rows that would cascade or be blocked", "No related rows found.", "Restrict relations will block this delete.", "Generate rows", "Generate dummy rows", "Seed {table} with Faker-generated rows. Existing rows are not affected.", "Row count", "(max {max})", "Columns to seed", "FK: no rows in {ref} — will skip", "→ {ref}", "No rows generated — all columns were skipped.", "Inserted {count} rows. Skipped FK columns: {cols}", "Inserted {count} rows successfully.", "Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.", "Generate & insert", "Inserting…", "Time Travel", "Restore a shard to a point in the last 30 days.", "root", "In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.", "Current bookmark", "Restore", "Time (ISO or epoch-ms, last 30 days)", "Preview", "Bookmark for that time", "Or an explicit bookmark (wins over time)", "bookmark string", "Restart the shard now so recovery applies immediately", "Confirm restore", "restarted now", "on next restart", "Restore armed", "Restored to", "Undo bookmark", "Confirm undo", "Undo restore", "role", "Role", "Role (optional)", "Active", "Banned", "unverified", "Manage", "New user", "Create", "Create user", "Creating…", "Password (optional)", "Search users", "Search by email or name…", "Filter by role", "Set role", "Ban user", "Ban reason (optional)", "Days", "Unban", "New password", "Set password", "Impersonate", "Impersonation token", "Revoke", "Revoke all sessions", "Delete user", "Confirm delete", "User details", "Fields", "Linked accounts", "No linked accounts.", "provider", "Unlink", "Security", "Disable two-factor", "No passkeys.", "Operations", "Organizations", "slug", "Members", "Invitations", "Remove", "No organizations.", "Select an organization to view its members and invitations.", "Organizations are not enabled.", "Enable the organization() plugin in your auth config to manage organizations here.", "Browse and manage organizations, members, and invitations.", "Reload", "Manage auth users — roles, bans, sessions, and identity.", "Auth config", "Configuration", "Enabled plugins and session config (read-only).", "Enabled capabilities", "Loading auth configuration…", "Accounts", "Admin", "Passkeys", "Two-factor", "Enabled", "Disabled", "OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.", "Sessions", "Browse and revoke active sessions across all users.", "user", "impersonated by", "Log drains", "Forward logs to Logpush, Tail Workers, or a webhook collector.", "Cloudflare destinations", "Lunora does not ship logs itself — forwarding is handled by Cloudflare. Configure a destination below, then test your collector.", "Logpush", "Stream every request log to R2, a SIEM, or a third-party log service.", "Tail Workers", "Send logs programmatically to a Worker for custom capture and forwarding.", "Workers Logs", "Retain and query recent request logs directly in Cloudflare's dashboard.", "Webhook test", "POST a sample Lunora request-log envelope to your collector to confirm it is reachable.", "https://example.com/logs", "Send test event", "Delivered — status {status} in {latency}ms", "Failed: {message}", "fetch is unavailable in this environment.", "Realtime", "Active WebSocket subscriptions on this shard.", "{count} connections", "{count} subscriptions", "This Studio session's sync client", "Reading the sync client's state…", "Sync client", "{count} pending writes", "Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there.", "No shard connection has been opened yet.", "No shards", "Shard", "Socket", "Confirmed watermark", "(default)", "This client holds no live queries or shapes.", "No subscriptions", "Subscription", "Kind", "Acked", "Cursor", "Pending overlays", "No active subscriptions.", "Connection", "admin", "Folder path", "Grid", "Sort", "Name", "Type", "Modified", "Toggle sort direction", "Thumbnail size", "Link expiry", "15m", "1h", "24h", "7d", "Upload", "Uploading…", "Copy URL", "Download", "Delete object?", "Uploaded {key}", "Deleted {key}", "Summary", "Time range", "All time", "Last 5m", "Last 15m", "Last hour", "filter path", "By level", "By function", "Count", "{count} entries", "Snippets", "Couldn't load the OpenAPI spec: {message}", "No OpenAPI spec configured", "Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here.", "API operations", "Filter operations", "No operations match your filter.", "Try it", "Request arguments", "Response body", "Response", "application/json", "Arguments (JSON)", "Send", "Sending…", "Send a request to see the response.", "No example for this response.", "Error", "{ms} ms", "Range", "Value in", "relation", "API spec format", "OpenAPI", "OpenRPC", "Params", "Result", "Field", "Required", "JSON-RPC request", "Couldn't load the OpenRPC spec: {message}", "No OpenRPC spec configured", "Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here.", "used by", "Orphan", "1 record", "{count} records", "References shard", "Which shard's records are checked for references to these files. Empty = root shard.", "Orphaned objects", "Find records whose file reference points at an object the bucket no longer has.", "Check for orphans", "Checking…", "No dangling references.", "Every record's file reference points at an object that exists in the bucket.", "Missing object", "→", "Showing the first {count} dangling references — the scan was truncated.", "Per-function call counts, error rates, and latency land here after your first request.", "Function and request logs for this shard show up here as your app handles traffic.", "No tables in this shard.", "Browse Vectorize indexes and run similarity searches.", "dimensions", "field", "Indexes declared with .vectorize() or defineVectorIndex() appear here.", "metadata", "metric", "No matches.", "No vector indexes.", "score", "Search", "Search by similarity…", "Searching…", "vectors", "Vectors", "Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed.", "Browse and edit key-value pairs in your Workers KV namespaces.", "Deleting…", "Expiration", "Filter", "Filter by prefix…", "Filter keys by prefix", "Key is absent or has no value.", "KV", "KV value", "Copy key", "Copy value", "Create key", "Failed to delete {count} keys.", "Format JSON", "Key name", "Expires after", "TTL unit", "TTL must be at least 60 seconds.", "seconds", "minutes", "hours", "days", "Leave blank to keep the current expiration.", "Metadata (JSON)", "Metadata must be valid JSON.", "New key", "No expiration", "Select all", "Select {name}", "Metadata", "Namespace", "No keys.", "No KV namespaces.", "Saving…", "vs. prev.", "Top functions", "No functions called yet.", "Calls", "Avg", "Err", "Avg latency", "cache hit", "Live connections", "sockets", "active subscriptions", "Recent activity", "No recent activity.", "last interval", "{rate} error rate", "cache entries", "Critical", "Degraded", "All systems healthy", "One or more service levels are breached.", "Some service levels need attention.", "All service levels are within target.", "Showing a partial request/error history — one or more shards have more data than the trend chart can display.", "Analytics", "Analytics is not configured.", "Hot shards", "Latency p50 / p95 per function", "No data points yet.", "Request volume per function", "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels.", "Usage and latency from Analytics Engine — request volume, p50/p95, and hot shards.", "(whole bucket)", "Access Rules", "Bucket", "Inspect storage access rules — per bucket, operation, and key prefix.", "No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix.", "No storage rules defined", "Operation", "Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only.", "Write", "Queues", "Queue", "Mode", "Dead-letter", "No queues defined", "Inspect declared Cloudflare Queues — their producer bindings, consumer mode, and dead-letter queue.", "No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue.", "Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker.", "No dead-letter queue on {queues}.", "Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.", "1 message was recently dead-lettered.", "{count} messages were recently dead-lettered.", "Batch mode needs a JSON array body — each element is enqueued as one message.", "Body", "Body must be valid JSON.", "Captured", "Clear log", "Clear {count} messages?", "Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth.", "Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured.", "Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message.", "Declared", "Delay must be a non-negative number of seconds.", "Delay (s)", "Delay (seconds)", "DLQ", "Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it.", "Message", "Message body (JSON)", "Messages", "No consumed messages yet.", "No queues to send to", "Outcome", "Replay", "Replaying…", "Send as batch (JSON array)", "Send message", "Flags", "Inspect feature flags and their live evaluation under a targeting context.", "Feature flags are read in code with ctx.flags.<type>(\"key\", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.", "Targeting context (JSON)", "Targeting context must be a JSON object.", "Targeting context is not valid JSON.", "Live updates unavailable; showing the last evaluation.", "No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags.", "No flags provider configured", "A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean(\"key\", false) in a query, mutation, or action.", "No flags read", "Key", "Value", "Reason", "Variant", "Workflows", "Inspect declared Cloudflare Workflows and their bindings.", "Binding", "Class", "No workflows defined", "No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow.", "Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. This view is read-only.", "Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.", "Start instance", "Starting…", "Workflow", "Instance id", "Instance id (optional)", "Params (JSON)", "Params (JSON, optional)", "Params must be valid JSON", "Instances", "Status", "Output", "Refresh", "Refreshing…", "Instance history", "Filter by status", "All statuses", "Workflow inspection not configured", "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history.", "No instances", "No instances match this filter for the selected workflow.", "Created", "Ended", "Steps", "Step", "Attempts", "Started", "This instance has no recorded steps yet.", "pause", "resume", "terminate", ">100ms avg execution", "50–100ms avg execution", "<50ms avg execution", "{count} tracked statements", "Avg time", "avg", "avg time", "avgTime", "Critical queries", "Exec count", "exec count", "execCount", "Execution count", "Fast queries", "Full statement", "Moderate queries", "No query insights yet", "Overview", "P90 latency", "P95 latency", "Query insights", "Query insights appear once statements are executed against this shard.", "Query leaderboard", "Rows read", "Rows written", "rowsRead", "Slow queries sorted by {sortField}", "Sort by", "Sort queries by", "Statements", "total", "Total time", "total time", "totalTime", "Edit schema", "Add table", "Add column", "Add index", "Rename / drop / change type…", "Table name", "Column name", "Column type", "Index name", "Index fields (comma-separated)", "Optional", "Unique", "Cancel", "Apply", "Applying…", "This edit changes stored data and must go through a migration. Review the migration before applying.", "Open Migrations", "Schema updated.", "Codegen reported diagnostics:", "Editing the schema is only available in local dev.", "Adds a table, column, or index to lunora/schema.ts and reruns codegen.", "Theme", "Dark theme", "Light theme", "System theme", "Integrity", "Fan-out", "auto-scaled: {relayCount}/{maxRelays} relays", "auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)", "Realtime fan-out cost and per-topic subscriber counts for this shard.", "No fan-out activity yet.", "peak {count} subscribers", "Hot topics", "Topic", "Kind", "Subscribers", "Fan-out cost since this instance woke", "Shape pokes", "Whisper broadcasts", "Passes", "Sockets iterated", "Delivered", "Peak width", "Max time", "Containers", "Container", "Instance", "Last event", "Detail", "Exit", "When", "No container activity", "Live Cloudflare Containers — current lifecycle state per instance from the log stream.", "Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream.", "No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error.", "Traces", "Recent ctx.trace waterfalls for this shard — the drill-down from a log line.", "Search traces", "search trace or function", "Recent traces", "Trace waterfall", "Errored span", "{count} spans", "starts {offset} in, runs {duration}", "Showing the {shown} most recent of {total} traces in the buffer.", "No traces", "Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates.", "Issues", "Issue", "Source", "Events", "First seen", "Last seen", "No issues", "Grouped error triage — Worker throws and container crashes folded by fingerprint.", "No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here.", "Severity", "Assignee", "Set severity", "Unassigned", "Resolve", "Ignore", "Reopen", "All", "Open", "Resolved", "Ignored", "—", "Toggle issue details", "Suggested fix", "No known fix for this error yet.", "Explain in plain language", "Explaining…", "AI explanation", "Generated by {model}", "No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available.", "The AI model could not explain this error right now. The suggested fix above still applies.", "No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.", "optional", "required", "unique", "Plugin fields", "New organization", "Edit organization", "Delete organization", "Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone.", "Slug (optional — derived from name)", "Logo URL (optional)", "Owner user id (optional)", "Metadata (JSON, optional)", "Add member", "Invite member", "Send invitation", "Change member role", "Change role", "New team", "Rename team", "Rename", "Delete team", "Delete this team and its memberships? This cannot be undone.", "Add team member", "Team members", "No members.", "No teams.", "No team members.", "Teams", "New role", "Edit role", "Delete role", "Delete this custom role? Members keeping it will lose its grants.", "No custom roles.", "Role name", "Permission", "Permission (JSON, e.g. {\"project\":[\"create\",\"update\"]})", "Plugins", "No plugins enabled.", "Sign-in methods", "Email & password", "Social providers", "None", "Custom roles", "Session policy", "Expires in", "Refresh after", "Fresh window", "Cookie cache", "Rate limit", "Max requests", "Window", "Plugin user fields", "Deployment health", "Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint.", "Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it.", "Liveness", "Readiness", "Ready", "Not ready", "Healthy", "Unhealthy", "Checked", "Subsystem checks", "No checks reported.", "Up", "Down", "Health endpoint unavailable", "The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public.", "Couldn't reach the health endpoint: {message}", "no response"];
1378
+ declare const MESSAGE_IDS: readonly ["Agents", "Agent", "Threads", "Timeline", "Messages", "Tokens", "Updated", "Content", "Tool", "Usage", "Approval", "Score your app's advisor findings: a grade, the coverage split, and every procedure ranked worst-first.", "Health score", "Rules fired", "Procedure", "Score", "Kind", "clean", "warned", "failing", "exempt", "sensitive", "no reason given", "Schema & config", "Inspect agent threads, message timelines, tool calls, and token usage.", "Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.", "No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents.", "No agents configured", "No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here.", "No agent threads yet", "This thread has no messages yet.", "Bindings", "KV Namespaces", "R2 Buckets", "Vectorize Indexes", "{count} bindings", "1 binding", "Lunora AI rules aren't installed.", "lets your coding agent use Lunora correctly.", "Dismiss", ", changed", "(no subject)", "(root)", "{count} active", "{count} calls", "{count} failed", "{total} total", "No subscriptions yet", "No payments configured", "No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, …) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions.", "Payments", "Plan", "Provider", "Recent webhook events", "Renews", "State", "Subscriptions", "Synced customers, subscriptions, and webhook events.", "{count} messages", "{count} pending changes", "{count} running", "{name} ({rowCount})", "{rangeStart}-{rangeEnd} of {total}", "{rate} ({count} entries)", "{reachable} reachable", "{reachable} reachable, {failed} unreachable", "{status} — processed", "{title} failed", "Actions", "Actions have no React hook — call them through the client.", "Add a widget to chart a saved SQL query on this browser.", "Add index on {table}", "Add row", "Add widget", "admin token", "Aggregating…", "all", "All shards", "API", "API reference unavailable", "API resources", "API usage snippets", "API view", "Arguments", "Auth", "Auth failures", "Auth failures over time", "Cache hit rate", "Call this {kind} from your app.", "Cancel", "Cancel job?", "Cc", "changed", "Chart widgets backed by saved read-only SQL queries.", "Lunora surfaces slow functions, error spikes, and cache problems here.", "Clear", "Clear inbox", "Columns unavailable", "CLI", "Client", "collecting samples…", "Combined cache hit rate", "Commit", "Committing…", "Breadcrumb", "Confirm", "Connect", "Connect to Lunora Studio", "Connected", "Connecting…", "Enter your admin token to access the studio.", "From your worker's LUNORA_ADMIN_TOKEN — your project's .dev.vars in dev, or a deployment secret in production.", "Local", "Not connected", "content-type", "Copy", "Copy link", "Copy-paste snippets for calling your functions and tables.", "created", "Cron triggers", "Dashboards", "Data", "Data migrations you run against this shard will be tracked here.", "Data model", "Database", "Database size", "db size", "Instruments", "Instruments unavailable: {error}", "Counter", "Gauge", "Histogram", "count", "range", "trend", "trace", "{name} trend", "Open the exemplar trace {trace}", "Delete", "Delete saved query {name}", "Delete?", "direction", "Direction", "Discard", "down", "Dry run", "Dry run: ", "Edit", "Edit widget", "email", "Email preview", "Email your app sends in dev is captured here — nothing is delivered.", "Email your app sent, captured in dev.", "Enter a migration id", "error", "Error rate", "errors", "Errors", "Errors over time", "expires", "Export", "PNG", "SVG", "Export / Import", "Exported {count} rows.", "Facets", "file:function", "Files", "Filter messages", "Filter tables", "Find table…", "Foreign key", "From", "function", "Function", "Function path", "Functions", "Functions by error rate", "Graph", "Headers", "Health", "Indexes", "Hide", "HTML", "id", "Idle", "Import", "Import (writes rows)?", "Inserted {inserted}, {conflicts} conflicts, {errors} errors.", "Interactive OpenAPI reference and copy-paste snippets for your functions.", "Invalid JSON args: {message}", "Invalid JSON: {message}", "Invalid NDJSON: {message}", "ip", "Jobs queued with runAfter / runAt will appear here.", "JSON", "key", "Key prefix", "key prefix (optional)", "Level filter", "line {line} ({table}): {message}", "List", "Live", "Live — changes stream in automatically", "Live unavailable", "Live unavailable: {liveError}", "Live: on", "Load", "Load more", "Load tables", "Logic", "Logs", "Mail", "Mask sensitive columns", "Metrics", "migration id", "Migration id", "Migrations", "Missing index", "name", "Next", "no", "No active sessions.", "no cache configured", "No captured email.", "No cron triggers.", "No function activity yet.", "No functions or tables to document yet.", "No global tables.", "No headers.", "No HTML body.", "No logs.", "Archive", "Log archive not configured", "Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here.", "No archived logs.", "No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2.", "Function path prefix", "function path…", "user id…", "Minimum level", "min level", "Time", "Level", "Trace", "User", "No migrations have run on this shard.", "No objects.", "No recent errors.", "No scheduled jobs.", "No tables to graph.", "No tables match your filter.", "No text body.", "No users.", "No widgets yet", "Objects you upload to your R2 buckets will appear here.", "Observability", "of {pages}", "off", "Offline", "ok", "OK", "on", "Open {target} {id}", "Open in new tab", "Outcome filter", "Page", "Plain text", "Prefill", "Previous", "Primary key", "processed", "React", "Read and write this table through the typed data model.", "Recent errors", "Recent logs", "Recently visited shards — click to switch", "Refresh", "Reload tables", "Remove widget", "RLS Policies", "Policies", "No policies defined", "No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows.", "Read", "Insert", "Update", "Guarded by", "Guarded", "Roles", "No roles defined", "No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks.", "Permissions", "Run as identity (userId)", "Leave empty to run as admin", "Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.", "as {userId}", "No policy", "Covered by {procedure}", "Uncovered — reachable without a policy", "Masked columns", "No tables in this deployment's schema.", "Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix.", "Pick a function and an identity, then run it to see the access outcome.", "Probe", "Probe this", "Run as (userId)", "Identity (userId) to run as", "Run probe", "Allowed", "Denied", "Probing…", "Set `runAsIdentity` to forge an identity and probe access.", "Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS.", "Inspect access policies per table, and probe a function as any identity.", "Scaffold access rules", "Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only.", "New policy file", "Wire into a procedure", "Policy name", "Create policy file", "Procedure file path", "Exported procedure", "Policy set identifier", "Wire RLS", "Creating…", "Wiring…", "Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.", "This change must be made by hand — the scaffolder only adds new, deny-by-default rules.", "requests", "Requests", "Requests / interval", "Requests over time", "Requests per interval over time", "Row actions", "Row document JSON", "Rows per page", "Run", "Run migration", "Run migration?", "Running…", "Query name", "Save", "Save query", "Save widget", "Saved", "schedule", "target", "workflow", "Run now", "Run now?", "Running…", "ran", "attempts", "backlog", "Dead letter", "Drop", "Drop job?", "in flight", "Jobs that exhaust their retry budget are parked here instead of being dropped.", "last tried", "max concurrency", "No dead-letter jobs.", "No workpools.", "pool", "Pools", "pools", "Pools created with createWorkpool appear here once they have activity.", "queued", "Retry", "Schedule view", "Scheduled", "scheduled for", "Scheduled jobs", "Scheduler backlog", "Schema", "Schema graph", "Schema view", "search message", "Search messages", "Search rows", "search table…", "Search…", "Select a function or table to see how to call it from your app.", "Select all rows", "Select row", "Send test", "Sent", "Service level", "Sessions", "Sessions for {userId}", "shard", "Shard", "Shard key", "shard key (optional)", "Shard key (optional)", "Shards", "Shards seen", "Signature", "size", "Snippet flavour", "State-changing admin operations are recorded here.", "status", "Storage", "Storage tier", "Storage tiers", "Studio", "Studio areas", "Studio failed", "Switch to dark theme", "Switch to light theme", "Table", "Table list", "Table touched", "Tables", "To", "Token rides the WebSocket URL — it can surface in browser DevTools and server logs. Use a dev-only token.", "Total database size", "Total errors", "Total requests", "Triggers declared with the cronJobs() builder appear here.", "Try again", "unreachable", "up", "updated", "Uptime", "user agent", "User id", "userId", "Users", "Users who sign up to your app will appear here.", "verified", "Widget title", "yes", "A live stream of recent function logs.", "Browse and edit rows across your shard and global tables.", "Browse auth users and their active sessions.", "Browse objects in your R2 storage buckets.", "Export a shard to NDJSON, or import rows from it.", "At-a-glance connection, error, and shard signals.", "Inspect and cancel scheduled jobs.", "Inspect each table and its columns.", "Inspect row-level-security policies and roles, per table.", "Per-shard health and aggregate metrics.", "Review migration status and run them.", "Run registered queries, mutations, and actions.", "Global tables (D1)", "Shard tables", "{shard} tables", "Tables marked .global() (D1-backed, region-replicated) will appear here.", "Select a table to browse its rows.", "Shared across every tenant, stored once in D1. Includes auth tables.", "Partitioned per shard key into separate Durable Objects — scoped to the shard above.", "avg", "calls", "conflicts", "kind", "last error", "last run", "max", "Most called", "No functions have run on this shard yet.", "Recent", "Slowest", "Insights", "Surface slow functions, error spikes, and cache problems.", "No issues detected.", "Low cache hit rate", "High cache eviction rate", "Slow function", "High error rate", "High write contention", "{rate} hit rate over recent traffic.", "{count} entries evicted recently.", "Slowest call took {duration}.", "Slowest call took {duration} — it full-scanned {tables} with no index.", "{rate} of calls failed.", "{rate} of calls hit a write conflict — consider sharding to cut contention.", "Home", "Reports", "SQL / Functions", "Table editor", "Connection, health, and advisor summary for your deployment.", "Collapse sidebar", "Expand sidebar", "SQL editor", "Run read-only SQL against a shard.", "Run", "SQL query", "SQL problems", "Operation console", "Suggest chart", "Describe the query you want", "Draft SQL", "Thinking…", "Fix this", "Related", "p50", "p95", "showing a capped set", "Statements executed in the selected window appear here, with throughput and latency over time.", "No queries in this window.", "Throughput", "Mean latency (ms)", "Schema versions", "Data migrations", "{count} pushes", "live", "Show in console", "Every admin call this studio makes is recorded here.", "{count} rows", "Filter", "Each distinct schema shape this shard runs is recorded here, so you can see what changed and when.", "No schema versions recorded yet.", "First recorded version — every table is new.", "{count} change(s)", "change", "Diagram", "Changes", "added", "changed", "removed", "schema", "{count} columns", "changes", "tables", "{count} breaking", "breaking", "safe", "{count} rows", "Showing the first {max} of {count} rows.", "Showing the {n} most common values.", "No rows returned.", "Private", "Reference", "Search queries…", "New query", "Untitled query", "Delete query", "No saved queries yet — they save to this browser as you type.", "Results", "Explain", "Chart", "Split editor and results", "History", "Format", "Clear history", "No numeric column to chart.", "Click Run to execute your query.", "Untitled", "New tab", "Close tab", "Tab title", "Double-click to rename", "Discard?", "Discard changes", "Keep editing", "Close other tabs", "Close tabs to the right", "Close all tabs", "Discard unsaved tabs?", "column", "keyword", "Columns", "Show all", "Hide all", "Transpose", "Swap rows and columns", "Field", "Row {n}", "Loading…", "No matching row.", "CSV", "SQL", "{count} selected", "Delete {count}", "Delete {count} rows?", "Copy", "Copied", "Cell value", "Close", "Form", "Invalid JSON", "Command palette", "No results.", "Quick links", "Security findings", "Performance issues", "View", "All clear", "No data yet", "Get connected", "No issues found", "No security or performance issues detected.", "Client SDK", "React", "CLI", "Connect an AI agent", "Drive this deployment from an AI agent over the Model Context Protocol — it can list functions and tables, read schemas, and run read-only queries. Writes stay off unless you opt in.", "Copy MCP config", "Copy agent prompt", "Advisors", "Security", "Performance", "Warnings", "Info", "Issue type", "Entity/item", "Description", "{count} errors", "{count} warnings", "{count} suggestions", "No errors detected", "No warnings detected", "No suggestions", "Nothing to report for this deployment.", "Security and performance findings for your deployment.", "Review admin gates, credentials, and log redaction.", "Lunora checks admin-token strength, the live-subscription gate, and request-log redaction here.", "No security issues detected.", "Weak admin token", "Weak auth secret", "Session cookies are not Secure", "Wildcard CORS with credentials", "CSRF/origin guard is off", "Security headers are off", "Live admin subscriptions are ungated", "Request log keeps un-redacted args", "Unknown security finding", "Update your worker to a version of Lunora that describes this finding.", "Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.", "Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.", "BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production.", "LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *.", "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.", "LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production.", "Apply index", "Apply index on {table}", "Apply?", "CREATE INDEX SQL copied to clipboard.", "LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.", "This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy.", "Audit", "A durable log of admin state-changing operations.", "Filter audit log", "filter op, table, id", "No audit entries.", "Notifications", "Registered push devices — endpoint, kind, last-send status, and delivery errors.", "Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...).", "No registered devices.", "Filter devices", "filter endpoint, user", "{count} devices", "endpoint", "last seen", "n/a", "time", "op", "table", "detail", "Auth audit", "Authentication and security events — sign-ins, MFA, and session changes.", "Filter security events", "filter event, actor, IP", "Authentication and security events are recorded here.", "No security events.", "event", "actor", "ip / user agent", "outcome", "success", "failure", "Settings", "Deployment", "Read-only deployment config — vars, secrets, and bindings.", "Environment & bindings", "No environment variables or bindings.", "Open in Cloudflare", "Remove filter", "View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard.", "URL", "Environment", "Version", "value", "Cascade impact", "Delete preview — rows that would cascade or be blocked", "No related rows found.", "Restrict relations will block this delete.", "Generate rows", "Generate dummy rows", "Seed {table} with Faker-generated rows. Existing rows are not affected.", "Row count", "(max {max})", "Columns to seed", "FK: no rows in {ref} — will skip", "→ {ref}", "No rows generated — all columns were skipped.", "Inserted {count} rows. Skipped FK columns: {cols}", "Inserted {count} rows successfully.", "Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.", "Generate & insert", "Inserting…", "Time Travel", "Restore a shard to a point in the last 30 days.", "root", "In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.", "Current bookmark", "Restore", "Time (ISO or epoch-ms, last 30 days)", "Preview", "Bookmark for that time", "Or an explicit bookmark (wins over time)", "bookmark string", "Restart the shard now so recovery applies immediately", "Confirm restore", "restarted now", "on next restart", "Restore armed", "Restored to", "Undo bookmark", "Confirm undo", "Undo restore", "role", "Role", "Role (optional)", "Active", "Banned", "unverified", "Manage", "New user", "Create", "Create user", "Creating…", "Password (optional)", "Search users", "Search by email or name…", "Filter by role", "Set role", "Ban user", "Ban reason (optional)", "Days", "Unban", "New password", "Set password", "Impersonate", "Impersonation token", "Revoke", "Revoke all sessions", "Delete user", "Confirm delete", "User details", "Fields", "Linked accounts", "No linked accounts.", "provider", "Unlink", "Security", "Disable two-factor", "No passkeys.", "Operations", "Organizations", "slug", "Members", "Invitations", "Remove", "No organizations.", "Select an organization to view its members and invitations.", "Organizations are not enabled.", "Enable the organization() plugin in your auth config to manage organizations here.", "Browse and manage organizations, members, and invitations.", "Reload", "Manage auth users — roles, bans, sessions, and identity.", "Auth config", "Configuration", "Enabled plugins and session config (read-only).", "Enabled capabilities", "Loading auth configuration…", "Accounts", "Admin", "Passkeys", "Two-factor", "Enabled", "Disabled", "OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.", "Sessions", "Browse and revoke active sessions across all users.", "user", "impersonated by", "Log drains", "Forward logs to Logpush, Tail Workers, or a webhook collector.", "Cloudflare destinations", "Lunora does not ship logs itself — forwarding is handled by Cloudflare. Configure a destination below, then test your collector.", "Logpush", "Stream every request log to R2, a SIEM, or a third-party log service.", "Tail Workers", "Send logs programmatically to a Worker for custom capture and forwarding.", "Workers Logs", "Retain and query recent request logs directly in Cloudflare's dashboard.", "Webhook test", "POST a sample Lunora request-log envelope to your collector to confirm it is reachable.", "https://example.com/logs", "Send test event", "Delivered — status {status} in {latency}ms", "Failed: {message}", "fetch is unavailable in this environment.", "Realtime", "Active WebSocket subscriptions on this shard.", "{count} connections", "{count} subscriptions", "This Studio session's sync client", "Reading the sync client's state…", "Sync client", "{count} pending writes", "Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there.", "No shard connection has been opened yet.", "No shards", "Shard", "Socket", "Confirmed watermark", "(default)", "This client holds no live queries or shapes.", "No subscriptions", "Subscription", "Kind", "Acked", "Cursor", "Pending overlays", "No active subscriptions.", "Connection", "admin", "Folder path", "Grid", "Sort", "Name", "Type", "Modified", "Toggle sort direction", "Thumbnail size", "Link expiry", "15m", "1h", "24h", "7d", "Upload", "Uploading…", "Copy URL", "Download", "Delete object?", "Uploaded {key}", "Deleted {key}", "Summary", "Time range", "All time", "Last 5m", "Last 15m", "Last hour", "filter path", "By level", "By function", "Count", "{count} entries", "Snippets", "Couldn't load the OpenAPI spec: {message}", "No OpenAPI spec configured", "Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here.", "API operations", "Filter operations", "No operations match your filter.", "Try it", "Request arguments", "Response body", "Response", "application/json", "Arguments (JSON)", "Send", "Sending…", "Send a request to see the response.", "No example for this response.", "Error", "{ms} ms", "Range", "Value in", "relation", "API spec format", "OpenAPI", "OpenRPC", "Params", "Result", "Field", "Required", "JSON-RPC request", "Couldn't load the OpenRPC spec: {message}", "No OpenRPC spec configured", "Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here.", "used by", "Orphan", "1 record", "{count} records", "References shard", "Which shard's records are checked for references to these files. Empty = root shard.", "Orphaned objects", "Find records whose file reference points at an object the bucket no longer has.", "Check for orphans", "Checking…", "No dangling references.", "Every record's file reference points at an object that exists in the bucket.", "Missing object", "→", "Showing the first {count} dangling references — the scan was truncated.", "Per-function call counts, error rates, and latency land here after your first request.", "Function and request logs for this shard show up here as your app handles traffic.", "No tables in this shard.", "Browse Vectorize indexes and run similarity searches.", "dimensions", "field", "Indexes declared with .vectorize() or defineVectorIndex() appear here.", "metadata", "metric", "No matches.", "No vector indexes.", "score", "Search", "Search by similarity…", "Searching…", "vectors", "Vectors", "Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed.", "Browse and edit key-value pairs in your Workers KV namespaces.", "Deleting…", "Expiration", "Filter", "Filter by prefix…", "Filter keys by prefix", "Key is absent or has no value.", "KV", "KV value", "Copy key", "Copy value", "Create key", "Failed to delete {count} keys.", "Format JSON", "Key name", "Expires after", "TTL unit", "TTL must be at least 60 seconds.", "seconds", "minutes", "hours", "days", "Leave blank to keep the current expiration.", "Metadata (JSON)", "Metadata must be valid JSON.", "New key", "No expiration", "Select all", "Select {name}", "Metadata", "Namespace", "No keys.", "No KV namespaces.", "Saving…", "vs. prev.", "Top functions", "No functions called yet.", "Calls", "Avg", "Err", "Avg latency", "cache hit", "Live connections", "sockets", "active subscriptions", "Recent activity", "No recent activity.", "last interval", "{rate} error rate", "cache entries", "Critical", "Degraded", "All systems healthy", "One or more service levels are breached.", "Some service levels need attention.", "All service levels are within target.", "Showing a partial request/error history — one or more shards have more data than the trend chart can display.", "Analytics", "Analytics is not configured.", "Hot shards", "Latency p50 / p95 per function", "No data points yet.", "Request volume per function", "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels.", "Usage and latency from Analytics Engine — request volume, p50/p95, and hot shards.", "(whole bucket)", "Access Rules", "Bucket", "Inspect storage access rules — per bucket, operation, and key prefix.", "No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix.", "No storage rules defined", "Operation", "Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only.", "Write", "Queues", "Queue", "Mode", "Dead-letter", "No queues defined", "Inspect declared Cloudflare Queues — their producer bindings, consumer mode, and dead-letter queue.", "No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue.", "Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker.", "No dead-letter queue on {queues}.", "Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.", "1 message was recently dead-lettered.", "{count} messages were recently dead-lettered.", "Batch mode needs a JSON array body — each element is enqueued as one message.", "Body", "Body must be valid JSON.", "Captured", "Clear log", "Clear {count} messages?", "Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth.", "Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured.", "Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message.", "Declared", "Delay must be a non-negative number of seconds.", "Delay (s)", "Delay (seconds)", "DLQ", "Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it.", "Message", "Message body (JSON)", "Messages", "No consumed messages yet.", "No queues to send to", "Outcome", "Replay", "Replaying…", "Send as batch (JSON array)", "Send message", "Flags", "Inspect feature flags and their live evaluation under a targeting context.", "Feature flags are read in code with ctx.flags.<type>(\"key\", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.", "Targeting context (JSON)", "Targeting context must be a JSON object.", "Targeting context is not valid JSON.", "Live updates unavailable; showing the last evaluation.", "No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags.", "No flags provider configured", "A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean(\"key\", false) in a query, mutation, or action.", "No flags read", "Key", "Value", "Reason", "Variant", "Workflows", "Inspect declared Cloudflare Workflows and their bindings.", "Binding", "Class", "No workflows defined", "No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow.", "Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. This view is read-only.", "Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.", "Start instance", "Starting…", "Workflow", "Instance id", "Instance id (optional)", "Params (JSON)", "Params (JSON, optional)", "Params must be valid JSON", "Instances", "Status", "Output", "Refresh", "Refreshing…", "Instance history", "Filter by status", "All statuses", "Workflow inspection not configured", "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history.", "No instances", "No instances match this filter for the selected workflow.", "Created", "Ended", "Steps", "Step", "Attempts", "Started", "This instance has no recorded steps yet.", "pause", "resume", "terminate", ">100ms avg execution", "50–100ms avg execution", "<50ms avg execution", "{count} tracked statements", "Avg time", "avg", "avg time", "avgTime", "Critical queries", "Exec count", "exec count", "execCount", "Execution count", "Fast queries", "Full statement", "Moderate queries", "No query insights yet", "Overview", "P90 latency", "P95 latency", "Query insights", "Query insights appear once statements are executed against this shard.", "Query leaderboard", "Rows read", "Rows written", "rowsRead", "Slow queries sorted by {sortField}", "Sort by", "Sort queries by", "Statements", "total", "Total time", "total time", "totalTime", "Edit schema", "Add table", "Add column", "Add index", "Rename / drop / change type…", "Table name", "Column name", "Column type", "Index name", "Index fields (comma-separated)", "Optional", "Unique", "Cancel", "Apply", "Applying…", "This edit changes stored data and must go through a migration. Review the migration before applying.", "Open Migrations", "Schema updated.", "Codegen reported diagnostics:", "Editing the schema is only available in local dev.", "Adds a table, column, or index to lunora/schema.ts and reruns codegen.", "Theme", "Dark theme", "Light theme", "System theme", "Integrity", "Fan-out", "auto-scaled: {relayCount}/{maxRelays} relays", "auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)", "Realtime fan-out cost and per-topic subscriber counts for this shard.", "No fan-out activity yet.", "peak {count} subscribers", "Hot topics", "Topic", "Kind", "Subscribers", "Fan-out cost since this instance woke", "Shape pokes", "Whisper broadcasts", "Passes", "Sockets iterated", "Delivered", "Peak width", "Max time", "Containers", "Container", "Instance", "Last event", "Detail", "Exit", "When", "No container activity", "Live Cloudflare Containers — current lifecycle state per instance from the log stream.", "Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream.", "No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error.", "Traces", "Recent ctx.trace waterfalls for this shard — the drill-down from a log line.", "Search traces", "search trace, span, or function", "Errors only", "Recent traces", "Trace waterfall", "{count} spans", "{name}, {duration}, starts {offset} in{failure}", ", failed: {message}", "Showing the {shown} most recent of {total} traces in the buffer.", "No traces", "Span ID", "Parent span ID", "— (trace root)", "Started at", "+{offset}", "Duration", "Attributes", "Logs ({count})", "Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates.", "Issues", "Issue", "Source", "Events", "First seen", "Last seen", "No issues", "Grouped error triage — Worker throws and container crashes folded by fingerprint.", "No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here.", "Severity", "Assignee", "Set severity", "Unassigned", "Resolve", "Ignore", "Reopen", "All", "Open", "Resolved", "Ignored", "—", "Toggle issue details", "Suggested fix", "No known fix for this error yet.", "Explain in plain language", "Explaining…", "AI explanation", "Generated by {model}", "No AI binding is configured. Wire an AI binding to enable plain-language explanations — the suggested fix above is always available.", "The AI model could not explain this error right now. The suggested fix above still applies.", "No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.", "optional", "required", "unique", "Plugin fields", "New organization", "Edit organization", "Delete organization", "Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone.", "Slug (optional — derived from name)", "Logo URL (optional)", "Owner user id (optional)", "Metadata (JSON, optional)", "Add member", "Invite member", "Send invitation", "Change member role", "Change role", "New team", "Rename team", "Rename", "Delete team", "Delete this team and its memberships? This cannot be undone.", "Add team member", "Team members", "No members.", "No teams.", "No team members.", "Teams", "New role", "Edit role", "Delete role", "Delete this custom role? Members keeping it will lose its grants.", "No custom roles.", "Role name", "Permission", "Permission (JSON, e.g. {\"project\":[\"create\",\"update\"]})", "Plugins", "No plugins enabled.", "Sign-in methods", "Email & password", "Social providers", "None", "Custom roles", "Session policy", "Expires in", "Refresh after", "Fresh window", "Cookie cache", "Rate limit", "Max requests", "Window", "Plugin user fields", "Deployment health", "Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint.", "Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it.", "Liveness", "Readiness", "Ready", "Not ready", "Healthy", "Unhealthy", "Checked", "Subsystem checks", "No checks reported.", "Up", "Down", "Health endpoint unavailable", "The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public.", "Couldn't reach the health endpoint: {message}", "no response"];
1377
1379
  /** A known studio message id — one of the entries in {@link MESSAGE_IDS}. */
1378
1380
  type MessageId = (typeof MESSAGE_IDS)[number];
1379
1381
  /** The locale the studio ships with and falls back to. */
@@ -1 +1 @@
1
- import{c as M}from"react/compiler-runtime";import{useVirtualizer as we}from"@tanstack/react-virtual";import{useState as q,useReducer as Ne,useRef as me,useEffect as he,useMemo as Ce}from"react";import{f as te}from"../packem_shared/log-fields-CoL3hsIQ.js";import{U as Le}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as re}from"../packem_shared/badge-BbuuAio7.js";import{E as Z}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as oe}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Se}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ne}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{r as ke}from"../packem_shared/shard-history-DMEW5VBE.js";import{l as $e}from"../packem_shared/virtual-rect-1o1veP7R.js";import{useLunora as Re}from"@lunora/react";import{u as Pe}from"../packem_shared/button-BkCrNcAs.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{d as Ie,n as Te,f as ge,m as D,b as Ee,p as V}from"../packem_shared/table-DZAB8cs3.js";import se from"../packem_shared/useDebounced-CU-uftxO.js";import{a as fe}from"../packem_shared/cf-links-Dmg86v1D.js";import{f as ie,m as Fe,b as de}from"../packem_shared/internal-zkEvTqy8.js";import{jsx as r,jsxs as T,Fragment as qe}from"react/jsx-runtime";import{c as W}from"../packem_shared/utils-bhneXptQ.js";import{L as _e}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Oe}from"../packem_shared/ShardInput-BVn2iCU0.js";const le=["trace","debug","log","info","warn","error","fatal"],Ae="LOG_ARCHIVE_NOT_CONFIGURED",pe={debug:"secondary",error:"destructive",fatal:"destructive",info:"outline",log:"outline",trace:"outline",warn:"secondary"},Me={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},Ke=(c,e)=>{switch(e.type){case"append":return{...c,cursor:e.cursor,error:null,loading:!1,rows:[...c.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...c,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...c,error:e.message,loading:!1};default:return c}},Ue=c=>{const e=M(33),{row:t}=c;let n;e[0]!==t.fields?(n=te(t.fields),e[0]=t.fields,e[1]=n):n=e[1];const i=n,o=`lg-archive-row-${String(t.ts)}`;let m;e[2]!==t.ts?(m=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=m):m=e[3];let p;e[4]!==m?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:m}),e[4]=m,e[5]=p):p=e[5];const f=pe[t.level];let s;e[6]!==t.level||e[7]!==f?(s=r(V,{children:r(re,{variant:f,children:t.level})}),e[6]=t.level,e[7]=f,e[8]=s):s=e[8];let l;e[9]!==t.functionPath?(l=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=l):l=e[10];let v;e[11]!==t.message?(v=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=v):v=e[12];let a;e[13]!==i?(a=i!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:i,children:i}),e[13]=i,e[14]=a):a=e[14];let d;e[15]!==v||e[16]!==a?(d=T(V,{className:"max-w-md",children:[v,a]}),e[15]=v,e[16]=a,e[17]=d):d=e[17];const u=t.traceId??"—";let h;e[18]!==u?(h=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:u}),e[18]=u,e[19]=h):h=e[19];const b=t.shardKey??"—";let g;e[20]!==b?(g=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=g):g=e[21];const x=t.userId??"—";let y;e[22]!==x?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[22]=x,e[23]=y):y=e[23];let C;return e[24]!==d||e[25]!==h||e[26]!==g||e[27]!==y||e[28]!==o||e[29]!==p||e[30]!==s||e[31]!==l?(C=T(ge,{"data-testid":o,children:[p,s,l,d,h,g,y]}),e[24]=d,e[25]=h,e[26]=g,e[27]=y,e[28]=o,e[29]=p,e[30]=s,e[31]=l,e[32]=C):C=e[32],C},De=({shardKey:c})=>{const e=Re(),t=z(),[n,i]=q(""),[o,m]=q(""),[p,f]=q(""),[{cursor:s,error:l,loading:v,notConfigured:a,rows:d},u]=Ne(Ke,Me),h=se(n.trim(),400),b=se(o.trim(),400),g={...h===""?{}:{functionPathPrefix:h},...p===""?{}:{minLevel:p},...c===""?{}:{shardKey:c},...b===""?{}:{userId:b}},x=JSON.stringify(g),y=me(x);he(()=>{const w={cancelled:!1};return y.current=x,ie((async()=>{u({type:"loading"});try{const N=await e.queryLogArchive(g);w.cancelled||u({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){w.cancelled||u(Fe(N)===Ae?{type:"notConfigured"}:{message:de(N),type:"failed"})}})()),()=>{w.cancelled=!0}},[e,x]);const C=async()=>{if(s===void 0)return;const w=x;u({type:"loading"});try{const N=await e.queryLogArchive({...g,cursor:s});y.current===w&&u({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){y.current===w&&u({message:de(N),type:"pageFailed"})}},$=w=>{i(w.target.value)},L=w=>{m(w.target.value)},S=w=>{f(w.target.value)},R=()=>{ie(C())};return a?r(Z,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:fe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):T("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[T("div",{className:"flex flex-wrap items-center gap-2",children:[r(j,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:$,placeholder:t("function path…"),value:n}),r(j,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:L,placeholder:t("user id…"),value:o}),T("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:S,value:p,children:[r("option",{value:"",children:t("min level")}),le.map(w=>r("option",{value:w,children:w},w))]})]}),l!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:l}),v&&d===null&&l===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),d!==null&&d.length===0&&r(Z,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),d!==null&&d.length>0&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:T(Ie,{"data-testid":"lg-archive-table",children:[r(Te,{children:T(ge,{children:[r(D,{children:t("Time")}),r(D,{children:t("Level")}),r(D,{children:t("Function")}),r(D,{children:t("Message")}),r(D,{children:t("Trace")}),r(D,{children:t("Shard")}),r(D,{children:t("User")})]})}),r(Ee,{children:d.map((w,N)=>r(Ue,{row:w},`${String(w.ts)}-${String(N)}`))})]})}),s!==void 0&&r("div",{children:r(Pe,{"data-testid":"lg-archive-more",disabled:v,onClick:R,size:"sm",variant:"outline",children:t(v?"Loading…":"Load more")})})]})},Ve=c=>{const e=M(11),{level:t,onToggle:n,selected:i}=c;let o;e[0]!==t||e[1]!==n?(o=()=>{n(t)},e[0]=t,e[1]=n,e[2]=o):o=e[2];const m=o,p=i?"border-border bg-muted font-medium":"border-input text-muted-foreground";let f;e[3]!==p?(f=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=f):f=e[4];const s=`logs-level-${t}`;let l;return e[5]!==t||e[6]!==m||e[7]!==i||e[8]!==f||e[9]!==s?(l=r("button",{"aria-pressed":i,className:f,"data-testid":s,onClick:m,type:"button",children:t}),e[5]=t,e[6]=m,e[7]=i,e[8]=f,e[9]=s,e[10]=l):l=e[10],l},je=c=>{const e=M(68),{levelFilter:t,onLogPathChange:n,onSearchChange:i,onTimeRangeChange:o,onToggleLevel:m,onToggleSummary:p,pathFilter:f,search:s,showSummary:l,timeRange:v}=c,a=z();let d;e[0]!==a?(d=a("Search messages"),e[0]=a,e[1]=d):d=e[1];let u;e[2]!==a?(u=a("search message"),e[2]=a,e[3]=u):u=e[3];let h;e[4]!==i||e[5]!==s||e[6]!==d||e[7]!==u?(h=r(j,{"aria-label":d,className:"h-8 w-48","data-testid":"lg-search",onChange:i,placeholder:u,value:s}),e[4]=i,e[5]=s,e[6]=d,e[7]=u,e[8]=h):h=e[8];let b;e[9]!==a?(b=a("Function path"),e[9]=a,e[10]=b):b=e[10];let g;e[11]!==a?(g=a("filter path"),e[11]=a,e[12]=g):g=e[12];let x;e[13]!==n||e[14]!==f||e[15]!==b||e[16]!==g?(x=r(j,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:g,value:f}),e[13]=n,e[14]=f,e[15]=b,e[16]=g,e[17]=x):x=e[17];let y;e[18]!==a?(y=a("Level filter"),e[18]=a,e[19]=y):y=e[19];let C;e[20]!==t||e[21]!==m?(C=le.map(U=>r(Ve,{level:U,onToggle:m,selected:t.has(U)},U)),e[20]=t,e[21]=m,e[22]=C):C=e[22];let $;e[23]!==y||e[24]!==C?($=r("div",{"aria-label":y,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:C}),e[23]=y,e[24]=C,e[25]=$):$=e[25];let L;e[26]!==a?(L=a("Time range"),e[26]=a,e[27]=L):L=e[27];let S;e[28]!==a?(S=a("All time"),e[28]=a,e[29]=S):S=e[29];let R;e[30]!==S?(R=r("option",{value:"all",children:S}),e[30]=S,e[31]=R):R=e[31];let w;e[32]!==a?(w=a("Last 5m"),e[32]=a,e[33]=w):w=e[33];let N;e[34]!==w?(N=r("option",{value:"5m",children:w}),e[34]=w,e[35]=N):N=e[35];let P;e[36]!==a?(P=a("Last 15m"),e[36]=a,e[37]=P):P=e[37];let I;e[38]!==P?(I=r("option",{value:"15m",children:P}),e[38]=P,e[39]=I):I=e[39];let E;e[40]!==a?(E=a("Last hour"),e[40]=a,e[41]=E):E=e[41];let F;e[42]!==E?(F=r("option",{value:"1h",children:E}),e[42]=E,e[43]=F):F=e[43];let O;e[44]!==o||e[45]!==L||e[46]!==R||e[47]!==N||e[48]!==I||e[49]!==F||e[50]!==v?(O=T("select",{"aria-label":L,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:v,children:[R,N,I,F]}),e[44]=o,e[45]=L,e[46]=R,e[47]=N,e[48]=I,e[49]=F,e[50]=v,e[51]=O):O=e[51];const G=l?"border-border bg-muted font-medium":"border-input text-muted-foreground";let K;e[52]!==G?(K=W("h-8 rounded-md border px-3 text-sm",G),e[52]=G,e[53]=K):K=e[53];let A;e[54]!==l||e[55]!==a?(A=a(l?"List":"Summary"),e[54]=l,e[55]=a,e[56]=A):A=e[56];let _;e[57]!==p||e[58]!==l||e[59]!==K||e[60]!==A?(_=r("button",{"aria-pressed":l,className:K,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:A}),e[57]=p,e[58]=l,e[59]=K,e[60]=A,e[61]=_):_=e[61];let B;return e[62]!==O||e[63]!==_||e[64]!==h||e[65]!==x||e[66]!==$?(B=T("div",{className:"flex flex-wrap items-center gap-2",children:[h,x,$,O,_]}),e[62]=O,e[63]=_,e[64]=h,e[65]=x,e[66]=$,e[67]=B):B=e[67],B},Be=c=>{const e=M(53),{onOutcomeChange:t,onPathChange:n,onTableChange:i,onUserChange:o,outcomeFilter:m,pathPrefix:p,tableFilter:f,userIdFilter:s}=c,l=z();let v;e[0]!==l?(v=l("Function path"),e[0]=l,e[1]=v):v=e[1];let a;e[2]!==l?(a=l("file:function"),e[2]=l,e[3]=a):a=e[3];let d;e[4]!==n||e[5]!==p||e[6]!==v||e[7]!==a?(d=r(j,{"aria-label":v,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:a,value:p}),e[4]=n,e[5]=p,e[6]=v,e[7]=a,e[8]=d):d=e[8];let u;e[9]!==l?(u=l("User id"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l?(h=l("userId"),e[11]=l,e[12]=h):h=e[12];let b;e[13]!==o||e[14]!==u||e[15]!==h||e[16]!==s?(b=r(j,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:h,value:s}),e[13]=o,e[14]=u,e[15]=h,e[16]=s,e[17]=b):b=e[17];let g;e[18]!==l?(g=l("Table touched"),e[18]=l,e[19]=g):g=e[19];let x;e[20]!==l?(x=l("table"),e[20]=l,e[21]=x):x=e[21];let y;e[22]!==i||e[23]!==g||e[24]!==x||e[25]!==f?(y=r(j,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-table",onChange:i,placeholder:x,value:f}),e[22]=i,e[23]=g,e[24]=x,e[25]=f,e[26]=y):y=e[26];let C;e[27]!==l?(C=l("Outcome filter"),e[27]=l,e[28]=C):C=e[28];let $;e[29]!==l?($=l("all"),e[29]=l,e[30]=$):$=e[30];let L;e[31]!==$?(L=r("option",{value:"all",children:$}),e[31]=$,e[32]=L):L=e[32];let S;e[33]!==l?(S=l("ok"),e[33]=l,e[34]=S):S=e[34];let R;e[35]!==S?(R=r("option",{value:"ok",children:S}),e[35]=S,e[36]=R):R=e[36];let w;e[37]!==l?(w=l("error"),e[37]=l,e[38]=w):w=e[38];let N;e[39]!==w?(N=r("option",{value:"error",children:w}),e[39]=w,e[40]=N):N=e[40];let P;e[41]!==t||e[42]!==m||e[43]!==C||e[44]!==L||e[45]!==R||e[46]!==N?(P=T("select",{"aria-label":C,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:m,children:[L,R,N]}),e[41]=t,e[42]=m,e[43]=C,e[44]=L,e[45]=R,e[46]=N,e[47]=P):P=e[47];let I;return e[48]!==P||e[49]!==d||e[50]!==b||e[51]!==y?(I=T("div",{className:"flex flex-wrap items-center gap-2",children:[d,b,y,P]}),e[48]=P,e[49]=d,e[50]=b,e[51]=y,e[52]=I):I=e[52],I},ve=c=>{const e=M(7),{bucket:t}=c;let n;e[0]!==t.key?(n=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let i;e[2]!==t.count?(i=r("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=i):i=e[3];let o;return e[4]!==n||e[5]!==i?(o=T("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[n,i]}),e[4]=n,e[5]=i,e[6]=o):o=e[6],o},ze=c=>{const e=M(31),{summary:t}=c,n=z();let i;e[0]!==t.total||e[1]!==n?(i=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=i):i=e[2];let o;e[3]!==i?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:i}),e[3]=i,e[4]=o):o=e[4];let m;e[5]!==n?(m=n("By level"),e[5]=n,e[6]=m):m=e[6];let p;e[7]!==m?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[7]=m,e[8]=p):p=e[8];let f;e[9]!==t.byLevel?(f=t.byLevel.map(Ge),e[9]=t.byLevel,e[10]=f):f=e[10];let s;e[11]!==f?(s=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:f}),e[11]=f,e[12]=s):s=e[12];let l;e[13]!==p||e[14]!==s?(l=T("div",{children:[p,s]}),e[13]=p,e[14]=s,e[15]=l):l=e[15];let v;e[16]!==n?(v=n("By function"),e[16]=n,e[17]=v):v=e[17];let a;e[18]!==v?(a=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[18]=v,e[19]=a):a=e[19];let d;e[20]!==t.byPath?(d=t.byPath.map(We),e[20]=t.byPath,e[21]=d):d=e[21];let u;e[22]!==d?(u=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:d}),e[22]=d,e[23]=u):u=e[23];let h;e[24]!==u||e[25]!==a?(h=T("div",{children:[a,u]}),e[24]=u,e[25]=a,e[26]=h):h=e[26];let b;return e[27]!==h||e[28]!==o||e[29]!==l?(b=T("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,l,h]}),e[27]=h,e[28]=o,e[29]=l,e[30]=b):b=e[30],b};function Ge(c){return r(ve,{bucket:c},c.key)}function We(c){return r(ve,{bucket:c},c.key)}const Qe=c=>{const e=M(46),{liveError:t,onShardKeyChange:n,onShowArchive:i,onShowErrors:o,onShowRequests:m,shardKey:p,view:f}=c,s=z(),l=f==="requests",v=f==="requests"?"bg-muted font-medium":"text-muted-foreground";let a;e[0]!==v?(a=W("px-3 py-1 text-sm",v),e[0]=v,e[1]=a):a=e[1];let d;e[2]!==s?(d=s("Requests"),e[2]=s,e[3]=d):d=e[3];let u;e[4]!==m||e[5]!==l||e[6]!==a||e[7]!==d?(u=r("button",{"aria-selected":l,className:a,"data-testid":"lg-view-requests",onClick:m,role:"tab",type:"button",children:d}),e[4]=m,e[5]=l,e[6]=a,e[7]=d,e[8]=u):u=e[8];const h=f==="errors",b=f==="errors"?"bg-muted font-medium":"text-muted-foreground";let g;e[9]!==b?(g=W("px-3 py-1 text-sm",b),e[9]=b,e[10]=g):g=e[10];let x;e[11]!==s?(x=s("Errors"),e[11]=s,e[12]=x):x=e[12];let y;e[13]!==o||e[14]!==h||e[15]!==g||e[16]!==x?(y=r("button",{"aria-selected":h,className:g,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:x}),e[13]=o,e[14]=h,e[15]=g,e[16]=x,e[17]=y):y=e[17];const C=f==="archive",$=f==="archive"?"bg-muted font-medium":"text-muted-foreground";let L;e[18]!==$?(L=W("px-3 py-1 text-sm",$),e[18]=$,e[19]=L):L=e[19];let S;e[20]!==s?(S=s("Archive"),e[20]=s,e[21]=S):S=e[21];let R;e[22]!==i||e[23]!==C||e[24]!==L||e[25]!==S?(R=r("button",{"aria-selected":C,className:L,"data-testid":"lg-view-archive",onClick:i,role:"tab",type:"button",children:S}),e[22]=i,e[23]=C,e[24]=L,e[25]=S,e[26]=R):R=e[26];let w;e[27]!==y||e[28]!==R||e[29]!==u?(w=T("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,y,R]}),e[27]=y,e[28]=R,e[29]=u,e[30]=w):w=e[30];let N;e[31]!==n||e[32]!==p?(N=r(Oe,{onChange:n,testId:"lg-shard-input",value:p}),e[31]=n,e[32]=p,e[33]=N):N=e[33];let P;e[34]!==t||e[35]!==f?(P=f!=="archive"&&r(_e,{message:t,prefix:"lg"}),e[34]=t,e[35]=f,e[36]=P):P=e[36];let I;e[37]!==s?(I=s("Open in Cloudflare"),e[37]=s,e[38]=I):I=e[38];let E;e[39]!==I?(E=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:fe,rel:"noreferrer",target:"_blank",children:I}),e[39]=I,e[40]=E):E=e[40];let F;return e[41]!==w||e[42]!==N||e[43]!==P||e[44]!==E?(F=T("div",{className:"flex flex-wrap items-center gap-2",children:[w,N,P,E]}),e[41]=w,e[42]=N,e[43]=P,e[44]=E,e[45]=F):F=e[45],F},ee=400,Ye=36,He={height:ee,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},Je={error:"destructive",ok:"secondary"},Xe=c=>{const e=M(26),{entry:t,index:n,measureRef:i,start:o}=c,m=`translateY(${String(o)}px)`;let p;e[0]!==m?(p={...be,transform:m},e[0]=m,e[1]=p):p=e[1];const f=p;let s;e[2]!==t.fields?(s=te(t.fields),e[2]=t.fields,e[3]=s):s=e[3];const l=s;let v;e[4]!==t.timestamp?(v=new Date(t.timestamp).toLocaleString(),e[4]=t.timestamp,e[5]=v):v=e[5];let a;e[6]!==v?(a=r("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:v}),e[6]=v,e[7]=a):a=e[7];const d=pe[t.level];let u;e[8]!==t.level||e[9]!==d?(u=r("span",{className:"w-20 shrink-0",role:"gridcell",children:r(re,{variant:d,children:t.level})}),e[8]=t.level,e[9]=d,e[10]=u):u=e[10];const h=t.functionPath??"—";let b;e[11]!==h?(b=r("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:h}),e[11]=h,e[12]=b):b=e[12];let g;e[13]!==l?(g=l===""?null:r("span",{className:"ml-2 text-muted-foreground","data-testid":"lg-fields",children:l}),e[13]=l,e[14]=g):g=e[14];let x;e[15]!==t.message||e[16]!==g?(x=T("span",{className:"flex-1 truncate",role:"gridcell",children:[t.message,g]}),e[15]=t.message,e[16]=g,e[17]=x):x=e[17];let y;return e[18]!==n||e[19]!==i||e[20]!==f||e[21]!==x||e[22]!==a||e[23]!==u||e[24]!==b?(y=T("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:i,role:"row",style:f,children:[a,u,b,x]}),e[18]=n,e[19]=i,e[20]=f,e[21]=x,e[22]=a,e[23]=u,e[24]=b,e[25]=y):y=e[25],y},ce=c=>c.length===0?"—":c.join(", "),Ze=c=>{const e=M(37),{entry:t,index:n,measureRef:i,start:o}=c,m=`translateY(${String(o)}px)`;let p;e[0]!==m?(p={...be,transform:m},e[0]=m,e[1]=p):p=e[1];const f=p;let s;e[2]!==t.ts?(s=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=s):s=e[3];let l;e[4]!==s?(l=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=l):l=e[5];const v=Je[t.outcome];let a;e[6]!==t.outcome||e[7]!==v?(a=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(re,{variant:v,children:t.outcome})}),e[6]=t.outcome,e[7]=v,e[8]=a):a=e[8];let d;e[9]!==t.functionPath?(d=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=d):d=e[10];const u=t.shardKey??"—";let h;e[11]!==u?(h=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:u}),e[11]=u,e[12]=h):h=e[12];const b=t.userId??"—";let g;e[13]!==b?(g=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b}),e[13]=b,e[14]=g):g=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const y=`${String(x)}ms`;let C;e[17]!==y?(C=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:y}),e[17]=y,e[18]=C):C=e[18];let $;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?($=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ce(t.tablesRead)} · w:${ce(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=$):$=e[23];let L;e[24]!==$?(L=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:$}),e[24]=$,e[25]=L):L=e[25];let S;return e[26]!==n||e[27]!==i||e[28]!==f||e[29]!==g||e[30]!==C||e[31]!==L||e[32]!==l||e[33]!==a||e[34]!==d||e[35]!==h?(S=T("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:i,role:"row",style:f,children:[l,a,d,h,g,C,L]}),e[26]=n,e[27]=i,e[28]=f,e[29]=g,e[30]=C,e[31]=L,e[32]=l,e[33]=a,e[34]=d,e[35]=h,e[36]=S):S=e[36],S},ue=c=>{const{entries:e}=c??{};return Array.isArray(e)?e:[]},et=c=>{const e={};return c.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=c.functionPathPrefix.trim()),c.userId.trim()!==""&&(e.userId=c.userId.trim()),c.tableTouched.trim()!==""&&(e.tableTouched=c.tableTouched.trim()),(c.outcome==="ok"||c.outcome==="error")&&(e.outcome=c.outcome),e},tt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},rt=(c,e)=>{const t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),i=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-tt[e.range];return c.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<i||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||te(o.fields).toLowerCase().includes(t))},lt="—",at=c=>{const e=new Map,t=new Map;for(const o of c){e.set(o.level,(e.get(o.level)??0)+1);const m=o.functionPath??lt;t.set(m,(t.get(m)??0)+1)}const n=le.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),i=[...t.entries()].map(([o,m])=>({count:m,key:o})).toSorted((o,m)=>m.count===o.count?o.key.localeCompare(m.key):m.count-o.count);return{byLevel:n,byPath:i,total:c.length}},Pt=({initialShardKey:c})=>{const e=z(),[t,n]=q("requests"),{queryShardKey:i,setShardKey:o,shardKey:m}=Se(c),[p,f]=q(""),[s,l]=q(()=>new Set),[v,a]=q(""),[d,u]=q("all"),[h,b]=q(!1),[g,x]=q(""),[y,C]=q(""),[$,L]=q(""),[S,R]=q("all"),w=et({functionPathPrefix:g,outcome:S,tableTouched:$,userId:y}),N=oe(ne.getRequestLog,w,{enabled:t==="requests",live:!0,shardKey:i}),P=oe(ne.getLogs,{},{enabled:t==="errors",live:!0,shardKey:i}),I=t==="requests"?N:P,{error:E,errorSource:F,isLoading:O,liveError:G}=I,K=ue(P.data),A=ue(N.data);he(()=>{I.data!==void 0&&ke(i)},[I.data,i]);const _=rt(K,{levels:s,now:Date.now(),path:v,range:d,search:p}),B=at(_),U=t==="requests"?A.length:_.length,J=t==="errors"&&h,Q=Ce(()=>E!==null?"error":U===0?O?J?"summary":"list":"empty":J?"summary":"list",[U,O,E,J]),ae=me(null),Y=we({count:U,estimateSize:()=>Ye,getScrollElement:()=>ae.current,initialRect:{height:ee,width:800},observeElementRect:(k,X)=>$e(k,X,ee),overscan:8}),xe=Y.getVirtualItems(),ye={height:Y.getTotalSize(),position:"relative",width:"100%"};return T("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Qe,{liveError:G,onShardKeyChange:o,onShowArchive:()=>{n("archive"),b(!1)},onShowErrors:()=>{n("errors"),b(!1)},onShowRequests:()=>{n("requests"),b(!1)},shardKey:m,view:t}),t==="errors"&&r(je,{levelFilter:s,onLogPathChange:k=>{a(k.target.value)},onSearchChange:k=>{f(k.target.value)},onTimeRangeChange:k=>{u(k.target.value)},onToggleLevel:k=>{l(X=>{const H=new Set(X);return H.has(k)?H.delete(k):H.add(k),H})},onToggleSummary:()=>{b(k=>!k)},pathFilter:v,search:p,showSummary:h,timeRange:d}),t==="requests"&&r(Be,{onOutcomeChange:k=>{R(k.target.value)},onPathChange:k=>{x(k.target.value)},onTableChange:k=>{L(k.target.value)},onUserChange:k=>{C(k.target.value)},outcomeFilter:S,pathPrefix:g,tableFilter:$,userIdFilter:y}),t==="archive"?r(De,{shardKey:i}):T(qe,{children:[Q==="error"&&r(Le,{error:F,testId:"lg-error"}),Q==="empty"&&r(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Q==="summary"&&r(ze,{summary:B}),Q==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:ae,style:He,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:ye,children:xe.map(k=>t==="requests"?r(Ze,{entry:A[k.index],index:k.index,measureRef:Y.measureElement,start:k.start},k.key):r(Xe,{entry:_[k.index],index:k.index,measureRef:Y.measureElement,start:k.start},k.key))})})]})]})};export{Pt as LogsPanel,rt as filterLogs,at as summarizeLogs};
1
+ import{c as q}from"react/compiler-runtime";import{useVirtualizer as Ne}from"@tanstack/react-virtual";import{useState as O,useReducer as Ce,useRef as ue,useEffect as me,useMemo as Le}from"react";import{f as he}from"../packem_shared/trace-handoff-D7j9TjUT.js";import{U as Se}from"../packem_shared/error-alert-_2q2VtVG.js";import{g as ge}from"../packem_shared/badge-BbuuAio7.js";import{E as ee}from"../packem_shared/empty-state-Cg7t_8qu.js";import{N as le}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{f as ke}from"../packem_shared/use-open-trace-D9XDDHHS.js";import{S as $e}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as B}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{r as Ie}from"../packem_shared/shard-history-DMEW5VBE.js";import{l as Te}from"../packem_shared/virtual-rect-1o1veP7R.js";import{useLunora as Re}from"@lunora/react";import{u as Pe}from"../packem_shared/button-BkCrNcAs.js";import{u as j}from"../packem_shared/input-JHu63lTv.js";import{d as Ee,n as Fe,f as fe,m as D,b as Oe,p as V}from"../packem_shared/table-DZAB8cs3.js";import ne from"../packem_shared/useDebounced-CU-uftxO.js";import{a as pe}from"../packem_shared/cf-links-Dmg86v1D.js";import{f as se,m as qe,b as ie}from"../packem_shared/internal-zkEvTqy8.js";import{L as _e,E as Me}from"../packem_shared/log-line-CmtmbZNE.js";import{jsx as r,jsxs as P,Fragment as Ae}from"react/jsx-runtime";import{c as W}from"../packem_shared/utils-bhneXptQ.js";import{L as Ke}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as Ue}from"../packem_shared/ShardInput-BVn2iCU0.js";const re=["trace","debug","log","info","warn","error","fatal"],De="LOG_ARCHIVE_NOT_CONFIGURED",Ve={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},je=(i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},Be=i=>{const e=q(33),{row:t}=i;let n;e[0]!==t.fields?(n=he(t.fields),e[0]=t.fields,e[1]=n):n=e[1];const s=n,o=`lg-archive-row-${String(t.ts)}`;let c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];const m=_e[t.level];let d;e[6]!==t.level||e[7]!==m?(d=r(V,{children:r(ge,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==s?(l=s!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:s,children:s}),e[13]=s,e[14]=l):l=e[14];let u;e[15]!==h||e[16]!==l?(u=P(V,{className:"max-w-md",children:[h,l]}),e[15]=h,e[16]=l,e[17]=u):u=e[17];const g=t.traceId??"—";let v;e[18]!==g?(v=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:g}),e[18]=g,e[19]=v):v=e[19];const b=t.shardKey??"—";let y;e[20]!==b?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=y):y=e[21];const w=t.userId??"—";let x;e[22]!==w?(x=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[22]=w,e[23]=x):x=e[23];let k;return e[24]!==u||e[25]!==v||e[26]!==y||e[27]!==x||e[28]!==o||e[29]!==p||e[30]!==d||e[31]!==a?(k=P(fe,{"data-testid":o,children:[p,d,a,u,v,y,x]}),e[24]=u,e[25]=v,e[26]=y,e[27]=x,e[28]=o,e[29]=p,e[30]=d,e[31]=a,e[32]=k):k=e[32],k},ze=({shardKey:i})=>{const e=Re(),t=B(),[n,s]=O(""),[o,c]=O(""),[p,m]=O(""),[{cursor:d,error:a,loading:h,notConfigured:l,rows:u},g]=Ce(je,Ve),v=ne(n.trim(),400),b=ne(o.trim(),400),y={...v===""?{}:{functionPathPrefix:v},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...b===""?{}:{userId:b}},w=JSON.stringify(y),x=ue(w);me(()=>{const f={cancelled:!1};return x.current=w,se((async()=>{g({type:"loading"});try{const N=await e.queryLogArchive(y);f.cancelled||g({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){f.cancelled||g(qe(N)===De?{type:"notConfigured"}:{message:ie(N),type:"failed"})}})()),()=>{f.cancelled=!0}},[e,w]);const k=async()=>{if(d===void 0)return;const f=w;g({type:"loading"});try{const N=await e.queryLogArchive({...y,cursor:d});x.current===f&&g({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){x.current===f&&g({message:ie(N),type:"pageFailed"})}},I=f=>{s(f.target.value)},L=f=>{c(f.target.value)},C=f=>{m(f.target.value)},S=()=>{se(k())};return l?r(ee,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:pe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):P("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[P("div",{className:"flex flex-wrap items-center gap-2",children:[r(j,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:I,placeholder:t("function path…"),value:n}),r(j,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:L,placeholder:t("user id…"),value:o}),P("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:C,value:p,children:[r("option",{value:"",children:t("min level")}),re.map(f=>r("option",{value:f,children:f},f))]})]}),a!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),h&&u===null&&a===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),u!==null&&u.length===0&&r(ee,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:P(Ee,{"data-testid":"lg-archive-table",children:[r(Fe,{children:P(fe,{children:[r(D,{children:t("Time")}),r(D,{children:t("Level")}),r(D,{children:t("Function")}),r(D,{children:t("Message")}),r(D,{children:t("Trace")}),r(D,{children:t("Shard")}),r(D,{children:t("User")})]})}),r(Oe,{children:u.map((f,N)=>r(Be,{row:f},`${String(f.ts)}-${String(N)}`))})]})}),d!==void 0&&r("div",{children:r(Pe,{"data-testid":"lg-archive-more",disabled:h,onClick:S,size:"sm",variant:"outline",children:t(h?"Loading…":"Load more")})})]})},Ge=i=>{const e=q(11),{level:t,onToggle:n,selected:s}=i;let o;e[0]!==t||e[1]!==n?(o=()=>{n(t)},e[0]=t,e[1]=n,e[2]=o):o=e[2];const c=o,p=s?"border-border bg-muted font-medium":"border-input text-muted-foreground";let m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];const d=`logs-level-${t}`;let a;return e[5]!==t||e[6]!==c||e[7]!==s||e[8]!==m||e[9]!==d?(a=r("button",{"aria-pressed":s,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=s,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},We=i=>{const e=q(68),{levelFilter:t,onLogPathChange:n,onSearchChange:s,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=B();let u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let g;e[2]!==l?(g=l("search message"),e[2]=l,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==d||e[6]!==u||e[7]!==g?(v=r(j,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:s,placeholder:g,value:d}),e[4]=s,e[5]=d,e[6]=u,e[7]=g,e[8]=v):v=e[8];let b;e[9]!==l?(b=l("Function path"),e[9]=l,e[10]=b):b=e[10];let y;e[11]!==l?(y=l("filter path"),e[11]=l,e[12]=y):y=e[12];let w;e[13]!==n||e[14]!==m||e[15]!==b||e[16]!==y?(w=r(j,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:n,placeholder:y,value:m}),e[13]=n,e[14]=m,e[15]=b,e[16]=y,e[17]=w):w=e[17];let x;e[18]!==l?(x=l("Level filter"),e[18]=l,e[19]=x):x=e[19];let k;e[20]!==t||e[21]!==c?(k=re.map(G=>r(Ge,{level:G,onToggle:c,selected:t.has(G)},G)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let I;e[23]!==x||e[24]!==k?(I=r("div",{"aria-label":x,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=x,e[24]=k,e[25]=I):I=e[25];let L;e[26]!==l?(L=l("Time range"),e[26]=l,e[27]=L):L=e[27];let C;e[28]!==l?(C=l("All time"),e[28]=l,e[29]=C):C=e[29];let S;e[30]!==C?(S=r("option",{value:"all",children:C}),e[30]=C,e[31]=S):S=e[31];let f;e[32]!==l?(f=l("Last 5m"),e[32]=l,e[33]=f):f=e[33];let N;e[34]!==f?(N=r("option",{value:"5m",children:f}),e[34]=f,e[35]=N):N=e[35];let T;e[36]!==l?(T=l("Last 15m"),e[36]=l,e[37]=T):T=e[37];let R;e[38]!==T?(R=r("option",{value:"15m",children:T}),e[38]=T,e[39]=R):R=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let F;e[42]!==E?(F=r("option",{value:"1h",children:E}),e[42]=E,e[43]=F):F=e[43];let _;e[44]!==o||e[45]!==L||e[46]!==S||e[47]!==N||e[48]!==R||e[49]!==F||e[50]!==h?(_=P("select",{"aria-label":L,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[S,N,R,F]}),e[44]=o,e[45]=L,e[46]=S,e[47]=N,e[48]=R,e[49]=F,e[50]=h,e[51]=_):_=e[51];const z=a?"border-border bg-muted font-medium":"border-input text-muted-foreground";let M;e[52]!==z?(M=W("h-8 rounded-md border px-3 text-sm",z),e[52]=z,e[53]=M):M=e[53];let K;e[54]!==a||e[55]!==l?(K=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=K):K=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==M||e[60]!==K?(A=r("button",{"aria-pressed":a,className:M,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:K}),e[57]=p,e[58]=a,e[59]=M,e[60]=K,e[61]=A):A=e[61];let U;return e[62]!==_||e[63]!==A||e[64]!==v||e[65]!==w||e[66]!==I?(U=P("div",{className:"flex flex-wrap items-center gap-2",children:[v,w,I,_,A]}),e[62]=_,e[63]=A,e[64]=v,e[65]=w,e[66]=I,e[67]=U):U=e[67],U},Ye=i=>{const e=q(53),{onOutcomeChange:t,onPathChange:n,onTableChange:s,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=B();let h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let u;e[4]!==n||e[5]!==p||e[6]!==h||e[7]!==l?(u=r(j,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:n,placeholder:l,value:p}),e[4]=n,e[5]=p,e[6]=h,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==a?(g=a("User id"),e[9]=a,e[10]=g):g=e[10];let v;e[11]!==a?(v=a("userId"),e[11]=a,e[12]=v):v=e[12];let b;e[13]!==o||e[14]!==g||e[15]!==v||e[16]!==d?(b=r(j,{"aria-label":g,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:v,value:d}),e[13]=o,e[14]=g,e[15]=v,e[16]=d,e[17]=b):b=e[17];let y;e[18]!==a?(y=a("Table touched"),e[18]=a,e[19]=y):y=e[19];let w;e[20]!==a?(w=a("table"),e[20]=a,e[21]=w):w=e[21];let x;e[22]!==s||e[23]!==y||e[24]!==w||e[25]!==m?(x=r(j,{"aria-label":y,className:"h-8 w-32","data-testid":"lg-req-table",onChange:s,placeholder:w,value:m}),e[22]=s,e[23]=y,e[24]=w,e[25]=m,e[26]=x):x=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let I;e[29]!==a?(I=a("all"),e[29]=a,e[30]=I):I=e[30];let L;e[31]!==I?(L=r("option",{value:"all",children:I}),e[31]=I,e[32]=L):L=e[32];let C;e[33]!==a?(C=a("ok"),e[33]=a,e[34]=C):C=e[34];let S;e[35]!==C?(S=r("option",{value:"ok",children:C}),e[35]=C,e[36]=S):S=e[36];let f;e[37]!==a?(f=a("error"),e[37]=a,e[38]=f):f=e[38];let N;e[39]!==f?(N=r("option",{value:"error",children:f}),e[39]=f,e[40]=N):N=e[40];let T;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==L||e[45]!==S||e[46]!==N?(T=P("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[L,S,N]}),e[41]=t,e[42]=c,e[43]=k,e[44]=L,e[45]=S,e[46]=N,e[47]=T):T=e[47];let R;return e[48]!==T||e[49]!==u||e[50]!==b||e[51]!==x?(R=P("div",{className:"flex flex-wrap items-center gap-2",children:[u,b,x,T]}),e[48]=T,e[49]=u,e[50]=b,e[51]=x,e[52]=R):R=e[52],R},ve=i=>{const e=q(7),{bucket:t}=i;let n;e[0]!==t.key?(n=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=n):n=e[1];let s;e[2]!==t.count?(s=r("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=P("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},Qe=i=>{const e=q(31),{summary:t}=i,n=B();let s;e[0]!==t.total||e[1]!==n?(s=n("{count} entries",{count:t.total}),e[0]=t.total,e[1]=n,e[2]=s):s=e[2];let o;e[3]!==s?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:s}),e[3]=s,e[4]=o):o=e[4];let c;e[5]!==n?(c=n("By level"),e[5]=n,e[6]=c):c=e[6];let p;e[7]!==c?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(He),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=P("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==n?(h=n("By function"),e[16]=n,e[17]=h):h=e[17];let l;e[18]!==h?(l=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(Je),e[20]=t.byPath,e[21]=u):u=e[21];let g;e[22]!==u?(g=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=g):g=e[23];let v;e[24]!==g||e[25]!==l?(v=P("div",{children:[l,g]}),e[24]=g,e[25]=l,e[26]=v):v=e[26];let b;return e[27]!==v||e[28]!==o||e[29]!==a?(b=P("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,v]}),e[27]=v,e[28]=o,e[29]=a,e[30]=b):b=e[30],b};function He(i){return r(ve,{bucket:i},i.key)}function Je(i){return r(ve,{bucket:i},i.key)}const Xe=i=>{const e=q(46),{liveError:t,onShardKeyChange:n,onShowArchive:s,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=B(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground";let l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let u;e[2]!==d?(u=d("Requests"),e[2]=d,e[3]=u):u=e[3];let g;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==u?(g=r("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:u}),e[4]=c,e[5]=a,e[6]=l,e[7]=u,e[8]=g):g=e[8];const v=m==="errors",b=m==="errors"?"bg-muted font-medium":"text-muted-foreground";let y;e[9]!==b?(y=W("px-3 py-1 text-sm",b),e[9]=b,e[10]=y):y=e[10];let w;e[11]!==d?(w=d("Errors"),e[11]=d,e[12]=w):w=e[12];let x;e[13]!==o||e[14]!==v||e[15]!==y||e[16]!==w?(x=r("button",{"aria-selected":v,className:y,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:w}),e[13]=o,e[14]=v,e[15]=y,e[16]=w,e[17]=x):x=e[17];const k=m==="archive",I=m==="archive"?"bg-muted font-medium":"text-muted-foreground";let L;e[18]!==I?(L=W("px-3 py-1 text-sm",I),e[18]=I,e[19]=L):L=e[19];let C;e[20]!==d?(C=d("Archive"),e[20]=d,e[21]=C):C=e[21];let S;e[22]!==s||e[23]!==k||e[24]!==L||e[25]!==C?(S=r("button",{"aria-selected":k,className:L,"data-testid":"lg-view-archive",onClick:s,role:"tab",type:"button",children:C}),e[22]=s,e[23]=k,e[24]=L,e[25]=C,e[26]=S):S=e[26];let f;e[27]!==x||e[28]!==S||e[29]!==g?(f=P("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[g,x,S]}),e[27]=x,e[28]=S,e[29]=g,e[30]=f):f=e[30];let N;e[31]!==n||e[32]!==p?(N=r(Ue,{onChange:n,testId:"lg-shard-input",value:p}),e[31]=n,e[32]=p,e[33]=N):N=e[33];let T;e[34]!==t||e[35]!==m?(T=m!=="archive"&&r(Ke,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=T):T=e[36];let R;e[37]!==d?(R=d("Open in Cloudflare"),e[37]=d,e[38]=R):R=e[38];let E;e[39]!==R?(E=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:pe,rel:"noreferrer",target:"_blank",children:R}),e[39]=R,e[40]=E):E=e[40];let F;return e[41]!==f||e[42]!==N||e[43]!==T||e[44]!==E?(F=P("div",{className:"flex flex-wrap items-center gap-2",children:[f,N,T,E]}),e[41]=f,e[42]=N,e[43]=T,e[44]=E,e[45]=F):F=e[45],F},te=400,Ze=36,et={height:te,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},tt={error:"destructive",ok:"secondary"},xe=i=>{const e=q(6),{onOpenTrace:t,traceId:n}=i,s=B();let o;e[0]!==t||e[1]!==s||e[2]!==n?(o=n===void 0?null:r("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:()=>{t(n)},type:"button",children:s("Trace")}),e[0]=t,e[1]=s,e[2]=n,e[3]=o):o=e[3];let c;return e[4]!==o?(c=r("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},rt=i=>{const e=q(13),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const d=m;let a;e[2]!==t?(a=r(Me,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==n||e[8]!==s||e[9]!==d||e[10]!==a||e[11]!==h?(l=P("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-row",ref:s,role:"row",style:d,children:[a,h]}),e[7]=n,e[8]=s,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},de=i=>i.length===0?"—":i.join(", "),at=i=>{const e=q(41),{entry:t,index:n,measureRef:s,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const d=m;let a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];const l=tt[t.outcome];let u;e[6]!==t.outcome||e[7]!==l?(u=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(ge,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let g;e[9]!==t.functionPath?(g=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=g):g=e[10];const v=t.shardKey??"—";let b;e[11]!==v?(b=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:v}),e[11]=v,e[12]=b):b=e[12];const y=t.userId??"—";let w;e[13]!==y?(w=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:y}),e[13]=y,e[14]=w):w=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const k=`${String(x)}ms`;let I;e[17]!==k?(I=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=I):I=e[18];let L;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(L=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${de(t.tablesRead)} · w:${de(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=L):L=e[23];let C;e[24]!==L?(C=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:L}),e[24]=L,e[25]=C):C=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let f;return e[29]!==n||e[30]!==s||e[31]!==d||e[32]!==w||e[33]!==I||e[34]!==C||e[35]!==S||e[36]!==h||e[37]!==u||e[38]!==g||e[39]!==b?(f=P("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":n,"data-testid":"lg-req-row",ref:s,role:"row",style:d,children:[h,u,g,b,w,I,C,S]}),e[29]=n,e[30]=s,e[31]=d,e[32]=w,e[33]=I,e[34]=C,e[35]=S,e[36]=h,e[37]=u,e[38]=g,e[39]=b,e[40]=f):f=e[40],f},ce=i=>{const{entries:e}=i??{};return Array.isArray(e)?e:[]},lt=i=>{const e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},ot={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},nt=(i,e)=>{const t=e.search.trim().toLowerCase(),n=e.path.trim().toLowerCase(),s=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-ot[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<s||n!==""&&!(o.functionPath??"").toLowerCase().includes(n)?!1:t===""||o.message.toLowerCase().includes(t)||he(o.fields).toLowerCase().includes(t))},st="—",it=i=>{const e=new Map,t=new Map;for(const o of i){e.set(o.level,(e.get(o.level)??0)+1);const c=o.functionPath??st;t.set(c,(t.get(c)??0)+1)}const n=re.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),s=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:n,byPath:s,total:i.length}},qt=({initialShardKey:i})=>{const e=B(),[t,n]=O("requests"),{queryShardKey:s,setShardKey:o,shardKey:c}=$e(i),[p,m]=O(""),[d,a]=O(()=>new Set),[h,l]=O(""),[u,g]=O("all"),[v,b]=O(!1),[y,w]=O(""),[x,k]=O(""),[I,L]=O(""),[C,S]=O("all"),f=lt({functionPathPrefix:y,outcome:C,tableTouched:I,userId:x}),N=le(oe.getRequestLog,f,{enabled:t==="requests",live:!0,shardKey:s}),T=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:s}),R=t==="requests"?N:T,{error:E,errorSource:F,isLoading:_,liveError:z}=R,M=ke(s),K=ce(T.data),A=ce(N.data);me(()=>{R.data!==void 0&&Ie(s)},[R.data,s]);const U=nt(K,{levels:d,now:Date.now(),path:h,range:u,search:p}),G=it(U),J=t==="requests"?A.length:U.length,X=t==="errors"&&v,Y=Le(()=>E!==null?"error":J===0?_?X?"summary":"list":"empty":X?"summary":"list",[J,_,E,X]),ae=ue(null),Q=Ne({count:J,estimateSize:()=>Ze,getScrollElement:()=>ae.current,initialRect:{height:te,width:800},observeElementRect:($,Z)=>Te($,Z,te),overscan:8}),ye=Q.getVirtualItems(),we={height:Q.getTotalSize(),position:"relative",width:"100%"};return P("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Xe,{liveError:z,onShardKeyChange:o,onShowArchive:()=>{n("archive"),b(!1)},onShowErrors:()=>{n("errors"),b(!1)},onShowRequests:()=>{n("requests"),b(!1)},shardKey:c,view:t}),t==="errors"&&r(We,{levelFilter:d,onLogPathChange:$=>{l($.target.value)},onSearchChange:$=>{m($.target.value)},onTimeRangeChange:$=>{g($.target.value)},onToggleLevel:$=>{a(Z=>{const H=new Set(Z);return H.has($)?H.delete($):H.add($),H})},onToggleSummary:()=>{b($=>!$)},pathFilter:h,search:p,showSummary:v,timeRange:u}),t==="requests"&&r(Ye,{onOutcomeChange:$=>{S($.target.value)},onPathChange:$=>{w($.target.value)},onTableChange:$=>{L($.target.value)},onUserChange:$=>{k($.target.value)},outcomeFilter:C,pathPrefix:y,tableFilter:I,userIdFilter:x}),t==="archive"?r(ze,{shardKey:s}):P(Ae,{children:[Y==="error"&&r(Se,{error:F,testId:"lg-error"}),Y==="empty"&&r(ee,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&r(Qe,{summary:G}),Y==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:ae,style:et,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:we,children:ye.map($=>t==="requests"?r(at,{entry:A[$.index],index:$.index,measureRef:Q.measureElement,onOpenTrace:M,start:$.start},$.key):r(rt,{entry:U[$.index],index:$.index,measureRef:Q.measureElement,onOpenTrace:M,start:$.start},$.key))})})]})]})};export{qt as LogsPanel,nt as filterLogs,it as summarizeLogs};
@@ -1 +1 @@
1
- import{useLunora as pt}from"@lunora/react";import{useNavigate as xt}from"@tanstack/react-router";import{useState as fe,useRef as We,useEffect as tt,useMemo as bt}from"react";import{L as vt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{N as Je}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{S as Nt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as pe}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as St}from"../packem_shared/cf-links-Dmg86v1D.js";import{m as $t,l as Ye,f as at,d as wt,b as qt,g as kt}from"../packem_shared/internal-zkEvTqy8.js";import{r as Mt,l as _t}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as It}from"../packem_shared/trace-handoff-CuZ6WGgo.js";import{c as Le}from"react/compiler-runtime";import{f as Ct}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{c as he,f as ge,n as Pe,m as Ue,p as Rt}from"../packem_shared/card-BMKx5UdA.js";import{m as de,n as dt,f as He,p as oe,d as mt,b as ut}from"../packem_shared/table-DZAB8cs3.js";import{S as ht}from"../packem_shared/sparkline-BNvxiJj_.js";import{jsx as r,jsxs as o,Fragment as Ve}from"react/jsx-runtime";import{aggregateMetrics as Dt,computeLatencyPercentiles as Ft,enrichQueryStats as Tt,shardsToAggregate as Lt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{g as me}from"../packem_shared/stat-card-BGJdhfm6.js";import{ResponsiveContainer as lt,AreaChart as Ot,CartesianGrid as st,XAxis as nt,YAxis as it,Tooltip as ot,Area as zt,LineChart as At,Line as Kt}from"recharts";import{E as Et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as jt}from"../packem_shared/utils-bhneXptQ.js";import{w as Pt,z as Ut,_ as Qe,S as Qt,x as Bt}from"../packem_shared/select-BssZMiFY.js";const Jt=(l,e)=>l<e?-1:l>e?1:0,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l))return`[${l.map(d=>Ze(d)).join(",")}]`;const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const d=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${d} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=l,a=Object.keys(s).toSorted(Jt),t=[];for(const d of a){const i=s[d];i!==void 0&&t.push(`${JSON.stringify(d)}:${Ze(i)}`)}return`{${t.join(",")}}`},gt=(l,e,s)=>`${l}:${e}:${Ze(s??{})}`,ft=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Ht=(l,e)=>ft(l,e),Gt=l=>ft(l.kind,l),Xe=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Wt=l=>Array.isArray(l?.series)?l.series:[],Xt="FUNCTION_NOT_FOUND",Yt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const s of l.series)e.set(gt(s.kind,s.name,s.attributes),s.points);return e},Vt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Le(18),{name:s,onOpenTrace:a,traceId:t}=l,d=pe();if(t===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=u):u=e[0],u}let i;e[1]!==t?(i=t.slice(0,8),e[1]=t,e[2]=i):i=e[2];const n=i;if(a===void 0){const u=`mt-instrument-trace-${s}`;let h;return e[3]!==n||e[4]!==u||e[5]!==t?(h=r("span",{className:"text-muted-foreground","data-testid":u,title:t,children:n}),e[3]=n,e[4]=u,e[5]=t,e[6]=h):h=e[6],h}const k=`mt-instrument-trace-${s}`;let f;e[7]!==a||e[8]!==t?(f=()=>{a(t)},e[7]=a,e[8]=t,e[9]=f):f=e[9];let S;e[10]!==d||e[11]!==t?(S=d("Open the exemplar trace {trace}",{trace:t}),e[10]=d,e[11]=t,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==k||e[15]!==f||e[16]!==S?(p=r("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":k,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=k,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},er=l=>{const e=Le(105),{onOpenTrace:s,shardKey:a}=l,t=pe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];const{data:n,error:k,errorSource:f}=Je(ze.getMetricSeries,d,i);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];const{data:u}=Je(ze.getMetricHistory,S,p);let h,M,b,$,_,c,g,x,w,q,y,I,C;if(e[6]!==n||e[7]!==k||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t){x=Symbol.for("react.early_return_sentinel");e:{const z=Wt(n),K=$t(f)===Xt;if(k!==null&&!K){let m;e[25]!==t?(m=t("Instruments"),e[25]=t,e[26]=m):m=e[26];let E;e[27]!==m?(E=r("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let j;e[29]!==k||e[30]!==t?(j=t("Instruments unavailable: {error}",{error:k}),e[29]=k,e[30]=t,e[31]=j):j=e[31];let P;e[32]!==j?(P=r("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:j}),e[32]=j,e[33]=P):P=e[33];let ie;e[34]!==E||e[35]!==P?(ie=o("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,P]}),e[34]=E,e[35]=P,e[36]=ie):ie=e[36],x=ie;break e}if(z.length===0){x=null;break e}const U=Yt(u);let L;e[37]!==t?(L=m=>t(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=L):L=e[38];const Q=L;_="flex flex-col gap-2",c="mt-instruments";let O;e[39]!==t?(O=t("Instruments"),e[39]=t,e[40]=O):O=e[40],e[41]!==O?(g=r("h3",{className:"text-sm font-semibold text-foreground",children:O}),e[41]=O,e[42]=g):g=e[42],$=he,C="overflow-hidden py-0",b=ge,I="px-0",M=mt,q="mt-instruments-table";let A;e[43]!==t?(A=t("name"),e[43]=t,e[44]=A):A=e[44];let J;e[45]!==A?(J=r(de,{children:A}),e[45]=A,e[46]=J):J=e[46];let H;e[47]!==t?(H=t("kind"),e[47]=t,e[48]=H):H=e[48];let G;e[49]!==H?(G=r(de,{children:H}),e[49]=H,e[50]=G):G=e[50];let W;e[51]!==t?(W=t("value"),e[51]=t,e[52]=W):W=e[52];let X;e[53]!==W?(X=r(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==t?(Y=t("count"),e[55]=t,e[56]=Y):Y=e[56];let V;e[57]!==Y?(V=r(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=V):V=e[58];let Z;e[59]!==t?(Z=t("range"),e[59]=t,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=r(de,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==t?(te=t("trend"),e[63]=t,e[64]=te):te=e[64];let re;e[65]!==te?(re=r(de,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==t?(ae=t("trace"),e[67]=t,e[68]=ae):ae=e[68];let le;e[69]!==ae?(le=r(de,{children:ae}),e[69]=ae,e[70]=le):le=e[70];let se;e[71]!==t?(se=t("dimensions"),e[71]=t,e[72]=se):se=e[72];let ne;e[73]!==se?(ne=r(de,{children:se}),e[73]=se,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==V||e[79]!==ee||e[80]!==re||e[81]!==le||e[82]!==ne?(y=r(dt,{children:o(He,{children:[J,G,X,V,ee,re,le,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=V,e[79]=ee,e[80]=re,e[81]=le,e[82]=ne,e[83]=y):y=e[83],h=ut,w=z.map(m=>{const E=Ct(m.attributes),j=gt(m.kind,m.name,m.attributes),P=(U.get(j)??[]).map(ie=>Ht(m.kind,ie));return o(He,{"data-testid":`mt-instrument-${m.name}`,children:[r(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),r(oe,{children:r(et,{variant:Vt[m.kind],children:Q(m.kind)})}),r(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:Xe(Gt(m))}),r(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),r(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${Xe(m.min)}–${Xe(m.max)}`}),r(oe,{children:P.length>=2?r(ht,{ariaLabel:t("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${m.name}`}):r("span",{className:"text-xs text-muted-foreground",children:"—"})}),r(oe,{className:"font-mono text-xs",children:r(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),r(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"—":E})]},j)})}e[6]=n,e[7]=k,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=h,e[13]=M,e[14]=b,e[15]=$,e[16]=_,e[17]=c,e[18]=g,e[19]=x,e[20]=w,e[21]=q,e[22]=y,e[23]=I,e[24]=C}else h=e[12],M=e[13],b=e[14],$=e[15],_=e[16],c=e[17],g=e[18],x=e[19],w=e[20],q=e[21],y=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let R;e[84]!==h||e[85]!==w?(R=r(h,{children:w}),e[84]=h,e[85]=w,e[86]=R):R=e[86];let D;e[87]!==M||e[88]!==R||e[89]!==q||e[90]!==y?(D=o(M,{"data-testid":q,children:[y,R]}),e[87]=M,e[88]=R,e[89]=q,e[90]=y,e[91]=D):D=e[91];let N;e[92]!==b||e[93]!==D||e[94]!==I?(N=r(b,{className:I,children:D}),e[92]=b,e[93]=D,e[94]=I,e[95]=N):N=e[95];let v;e[96]!==$||e[97]!==N||e[98]!==C?(v=r($,{className:C,children:N}),e[96]=$,e[97]=N,e[98]=C,e[99]=v):v=e[99];let T;return e[100]!==_||e[101]!==c||e[102]!==g||e[103]!==v?(T=o("section",{className:_,"data-testid":c,children:[g,v]}),e[100]=_,e[101]=c,e[102]=g,e[103]=v,e[104]=T):T=e[104],T},tr=l=>{const e=Le(74),{aggregate:s,shardResults:a}=l,t=pe();let d;e[0]!==t?(d=t("Shards"),e[0]=t,e[1]=d):d=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==t?(i=s.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):t("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=t,e[5]=i):i=e[5];let n;e[6]!==d||e[7]!==i?(n=r(me,{label:d,testId:"mt-agg-shards",value:i}),e[6]=d,e[7]=i,e[8]=n):n=e[8];let k;e[9]!==t?(k=t("Total requests"),e[9]=t,e[10]=k):k=e[10];let f;e[11]!==s.totalRequests||e[12]!==k?(f=r(me,{label:k,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=k,e[13]=f):f=e[13];let S;e[14]!==t?(S=t("Total errors"),e[14]=t,e[15]=S):S=e[15];let p;e[16]!==s.totalErrors||e[17]!==S?(p=r(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==t?(u=t("Total database size"),e[19]=t,e[20]=u):u=e[20];let h;e[21]!==s.totalDatabaseSize?(h=Ye(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=r(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==t?(b=t("Combined cache hit rate"),e[26]=t,e[27]=b):b=e[27];let $;e[28]!==s.hitRate||e[29]!==t?($=s.hitRate===null?t("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=t,e[30]=$):$=e[30];let _;e[31]!==b||e[32]!==$?(_=r(me,{label:b,testId:"mt-agg-cache",value:$}),e[31]=b,e[32]=$,e[33]=_):_=e[33];let c;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(c=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=c):c=e[39];let g;e[40]!==t?(g=t("shard"),e[40]=t,e[41]=g):g=e[41];let x;e[42]!==g?(x=r(de,{children:g}),e[42]=g,e[43]=x):x=e[43];let w;e[44]!==t?(w=t("requests"),e[44]=t,e[45]=w):w=e[45];let q;e[46]!==w?(q=r(de,{children:w}),e[46]=w,e[47]=q):q=e[47];let y;e[48]!==t?(y=t("errors"),e[48]=t,e[49]=y):y=e[49];let I;e[50]!==y?(I=r(de,{children:y}),e[50]=y,e[51]=I):I=e[51];let C;e[52]!==t?(C=t("db size"),e[52]=t,e[53]=C):C=e[53];let R;e[54]!==C?(R=r(de,{children:C}),e[54]=C,e[55]=R):R=e[55];let D;e[56]!==x||e[57]!==q||e[58]!==I||e[59]!==R?(D=r(dt,{children:o(He,{children:[x,q,I,R]})}),e[56]=x,e[57]=q,e[58]=I,e[59]=R,e[60]=D):D=e[60];let N;if(e[61]!==a||e[62]!==t){let K;e[64]!==t?(K=U=>o(He,{"data-testid":`mt-agg-row-${U.shard}`,children:[r(oe,{children:U.shard}),U.metrics===null?r(oe,{className:"text-destructive",colSpan:3,children:U.error??t("unreachable")}):o(Ve,{children:[r(oe,{className:"tabular-nums",children:U.metrics.requests}),r(oe,{className:"tabular-nums",children:U.metrics.errors}),r(oe,{className:"tabular-nums",children:Ye(U.metrics.databaseSize)})]})]},U.shard),e[64]=t,e[65]=K):K=e[65],N=a.map(K),e[61]=a,e[62]=t,e[63]=N}else N=e[63];let v;e[66]!==N?(v=r(ut,{children:N}),e[66]=N,e[67]=v):v=e[67];let T;e[68]!==D||e[69]!==v?(T=r(he,{className:"overflow-hidden py-0",children:r(ge,{className:"px-0",children:o(mt,{"data-testid":"mt-agg-table",children:[D,v]})})}),e[68]=D,e[69]=v,e[70]=T):T=e[70];let z;return e[71]!==c||e[72]!==T?(z=o("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[c,T]}),e[71]=c,e[72]=T,e[73]=z):z=e[73],z},rr=l=>{const e=Math.floor(l/1e3),s=Math.floor(e/3600),a=Math.floor(e%3600/60),t=e%60;return s>0?`${s.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${t.toString()}s`:`${t.toString()}s`},ar=(l,e)=>{const s=l+e;return s===0?"—":`${(l/s*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Le(75),{currentDelta:s,errorRate:a,history:t,latencyPercentiles:d,metrics:i}=l,n=pe();let k;e[0]!==t||e[1]!==n?(k=t.length>=2?r(ht,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=n,e[2]=k):k=e[2];let f;e[3]!==s||e[4]!==t.length||e[5]!==n?(f=t.length>=2?o(Ve,{children:[r("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):r("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples…")}),e[3]=s,e[4]=t.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==k||e[11]!==f||e[12]!==S?(p=r(me,{chart:k,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=k,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=o(Ve,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=r(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let $;e[26]!==d.p90?($=d.p90>0?`P90 ${ct(d.p90)}`:void 0,e[26]=d.p90,e[27]=$):$=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let c;e[30]!==d.p95?(c=d.p95>0?ct(d.p95):"—",e[30]=d.p95,e[31]=c):c=e[31];let g;e[32]!==_||e[33]!==c||e[34]!==$?(g=r(me,{footer:$,label:_,testId:"mt-p95",value:c}),e[32]=_,e[33]=c,e[34]=$,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let w;e[39]!==n?(w=n("Database size"),e[39]=n,e[40]=w):w=e[40];let q;e[41]!==i.databaseSize?(q=Ye(i.databaseSize),e[41]=i.databaseSize,e[42]=q):q=e[42];let y;e[43]!==x||e[44]!==w||e[45]!==q?(y=r(me,{footer:x,label:w,testId:"mt-db-size",value:q}),e[43]=x,e[44]=w,e[45]=q,e[46]=y):y=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let C;e[49]!==i.shard||e[50]!==I?(C=r(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let D;e[54]!==i.uptimeMs?(D=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=D):D=e[55];let N;e[56]!==R||e[57]!==D?(N=r(me,{label:R,testId:"mt-uptime",value:D}),e[56]=R,e[57]=D,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let T;e[61]!==i.cache||e[62]!==n?(T=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=T):T=e[63];let z;e[64]!==v||e[65]!==T?(z=r(me,{label:v,testId:"mt-cache",value:T}),e[64]=v,e[65]=T,e[66]=z):z=e[66];let K;return e[67]!==g||e[68]!==y||e[69]!==C||e[70]!==N||e[71]!==z||e[72]!==p||e[73]!==b?(K=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,C,N,z]}),e[67]=g,e[68]=y,e[69]=C,e[70]=N,e[71]=z,e[72]=p,e[73]=b,e[74]=K):K=e[74],K},Ge=l=>l>=100?"critical":l>=50?"warning":"good",Oe=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,Be=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),sr=l=>{const e=Le(3),{level:s}=l;if(s==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(s==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},nr=(l,e)=>{const s=[...l];return s.sort((a,t)=>{switch(e){case"avgTime":return t.avgDurationMs-a.avgDurationMs;case"execCount":return t.execCount-a.execCount;case"rowsRead":return t.rowsRead-a.rowsRead;default:return t.totalDurationMs-a.totalDurationMs}}),s},ir=l=>{const e=Le(161),{queryStats:s}=l,a=pe(),[t,d]=fe("totalTime");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[n,k]=fe(i);let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=C=>{C!==null&&d(C)},e[1]=f):f=e[1];const S=f;let p,u,h,M,b,$,_,c,g,x;if(e[2]!==n||e[3]!==s||e[4]!==t||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{const C=nr(s,t);let R;e[16]!==s?(R=s.filter(or),e[16]=s,e[17]=R):R=e[17];const D=R.length;let N;e[18]!==s?(N=s.filter(cr),e[18]=s,e[19]=N):N=e[19];const v=N.length;let T;e[20]!==s?(T=s.filter(dr),e[20]=s,e[21]=T):T=e[21];const z=T.length;let K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=F=>{k(ce=>{const B=new Set(ce);return B.has(F)?B.delete(F):B.add(F),B})},e[22]=K):K=e[22];const U=K;if(s.length===0){let F;e[23]!==a?(F=a("No query insights yet"),e[23]=a,e[24]=F):F=e[24];let ce;e[25]!==F?(ce=r("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:F}),e[25]=F,e[26]=ce):ce=e[26];let B;e[27]!==a?(B=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=B):B=e[28];let ue;e[29]!==B?(ue=r("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=ue):ue=e[30];let je;e[31]!==ce||e[32]!==ue?(je=r(he,{children:r(ge,{className:"py-12",children:o("div",{className:"text-center text-muted-foreground",children:[ce,ue]})})}),e[31]=ce,e[32]=ue,e[33]=je):je=e[33],h=je;break e}_="space-y-4",c="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let Q;e[36]!==L?(Q=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=Q):Q=e[37];let O;e[38]!==D?(O=r("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=O):O=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let J;e[42]!==A?(J=r("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=J):J=e[43];let H;e[44]!==O||e[45]!==J?(H=o(ge,{children:[O,J]}),e[44]=O,e[45]=J,e[46]=H):H=e[46];let G;e[47]!==Q||e[48]!==H?(G=o(he,{children:[Q,H]}),e[47]=Q,e[48]=H,e[49]=G):G=e[49];let W;e[50]!==a?(W=a("Moderate queries"),e[50]=a,e[51]=W):W=e[51];let X;e[52]!==W?(X=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==v?(Y=r("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=Y):Y=e[55];let V;e[56]!==a?(V=a("50–100ms avg execution"),e[56]=a,e[57]=V):V=e[57];let Z;e[58]!==V?(Z=r("p",{className:"text-xs text-muted-foreground",children:V}),e[58]=V,e[59]=Z):Z=e[59];let ee;e[60]!==Y||e[61]!==Z?(ee=o(ge,{children:[Y,Z]}),e[60]=Y,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==X||e[64]!==ee?(te=o(he,{children:[X,ee]}),e[63]=X,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=r(Pe,{className:"pb-2",children:r(Ue,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let le;e[70]!==z?(le=r("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:z}),e[70]=z,e[71]=le):le=e[71];let se;e[72]!==a?(se=a("<50ms avg execution"),e[72]=a,e[73]=se):se=e[73];let ne;e[74]!==se?(ne=r("p",{className:"text-xs text-muted-foreground",children:se}),e[74]=se,e[75]=ne):ne=e[75];let m;e[76]!==le||e[77]!==ne?(m=o(ge,{children:[le,ne]}),e[76]=le,e[77]=ne,e[78]=m):m=e[78];let E;e[79]!==ae||e[80]!==m?(E=o(he,{children:[ae,m]}),e[79]=ae,e[80]=m,e[81]=E):E=e[81],e[82]!==G||e[83]!==te||e[84]!==E?(g=o("div",{className:"grid gap-4 md:grid-cols-3",children:[G,te,E]}),e[82]=G,e[83]=te,e[84]=E,e[85]=g):g=e[85];let j;e[86]!==a?(j=a("Query leaderboard"),e[86]=a,e[87]=j):j=e[87];let P;e[88]!==j?(P=r("h3",{className:"text-lg font-semibold",children:j}),e[88]=j,e[89]=P):P=e[89];let ie;e[90]!==t||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(t)}),e[90]=t,e[91]=a,e[92]=ie):ie=e[92];let xe;e[93]!==ie?(xe=r("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=xe):xe=e[94];let be;e[95]!==P||e[96]!==xe?(be=o("div",{children:[P,xe]}),e[95]=P,e[96]=xe,e[97]=be):be=e[97];let ve;e[98]!==a?(ve=a("Sort by"),e[98]=a,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=r("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==a?(Ne=a("Sort queries by"),e[102]=a,e[103]=Ne):Ne=e[103];let Ae;e[104]===Symbol.for("react.memo_cache_sentinel")?(Ae=r(Pt,{}),e[104]=Ae):Ae=e[104];let Se;e[105]!==Ne?(Se=r(Ut,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Ae}),e[105]=Ne,e[106]=Se):Se=e[106];let $e;e[107]!==a?($e=a("Total time"),e[107]=a,e[108]=$e):$e=e[108];let we;e[109]!==$e?(we=r(Qe,{value:"totalTime",children:$e}),e[109]=$e,e[110]=we):we=e[110];let qe;e[111]!==a?(qe=a("Avg time"),e[111]=a,e[112]=qe):qe=e[112];let ke;e[113]!==qe?(ke=r(Qe,{value:"avgTime",children:qe}),e[113]=qe,e[114]=ke):ke=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let _e;e[117]!==Me?(_e=r(Qe,{value:"execCount",children:Me}),e[117]=Me,e[118]=_e):_e=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=r(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Re;e[123]!==we||e[124]!==ke||e[125]!==_e||e[126]!==Ce?(Re=o(Qt,{children:[we,ke,_e,Ce]}),e[123]=we,e[124]=ke,e[125]=_e,e[126]=Ce,e[127]=Re):Re=e[127];let De;e[128]!==t||e[129]!==Se||e[130]!==Re?(De=o(Bt,{onValueChange:S,value:t,children:[Se,Re]}),e[128]=t,e[129]=Se,e[130]=Re,e[131]=De):De=e[131];let Fe;e[132]!==ye||e[133]!==De?(Fe=o("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=Fe):Fe=e[134],e[135]!==be||e[136]!==Fe?(x=o("div",{className:"flex items-center justify-between",children:[be,Fe]}),e[135]=be,e[136]=Fe,e[137]=x):x=e[137],u=he;let Te;e[138]!==a?(Te=a("Statements"),e[138]=a,e[139]=Te):Te=e[139];let Ke;e[140]!==Te?(Ke=r(Ue,{children:Te}),e[140]=Te,e[141]=Ke):Ke=e[141],$=o(Pe,{children:[Ke,r(Rt,{children:a("{count} tracked statements",{count:C.length})})]}),p=ge,M="space-y-2";let Ee;e[142]!==n||e[143]!==a?(Ee=F=>{const ce=F.normalizedSql,B=n.has(ce),ue=Ge(F.avgDurationMs);return o("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[o("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{U(ce)},type:"button",children:[o("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r(sr,{level:ue}),r("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:F.normalizedSql})]}),o("div",{className:"flex shrink-0 items-center gap-4",children:[o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.totalDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.avgDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),F.p95DurationMs!==void 0&&o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.p95DurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Be(F.execCount)}),r("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),B&&o("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[o("div",{children:[r("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),r("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:F.normalizedSql})]}),o("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[F.p50DurationMs!==void 0&&o("div",{children:[r("span",{className:"text-muted-foreground",children:a("p50")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.p50DurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Exec count")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.execCount)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Total time")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.totalDurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows read")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsRead)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows written")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsWritten)})]})]})]})]},ce)},e[142]=n,e[143]=a,e[144]=Ee):Ee=e[144],b=C.map(Ee)}e[2]=n,e[3]=s,e[4]=t,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=$,e[12]=_,e[13]=c,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],$=e[11],_=e[12],c=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let w;e[145]!==M||e[146]!==b?(w=r("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=w):w=e[147];let q;e[148]!==p||e[149]!==w?(q=r(p,{children:w}),e[148]=p,e[149]=w,e[150]=q):q=e[150];let y;e[151]!==u||e[152]!==q||e[153]!==$?(y=o(u,{children:[$,q]}),e[151]=u,e[152]=q,e[153]=$,e[154]=y):y=e[154];let I;return e[155]!==y||e[156]!==_||e[157]!==c||e[158]!==g||e[159]!==x?(I=o("div",{className:_,"data-testid":c,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=c,e[158]=g,e[159]=x,e[160]=I):I=e[160],I};function or(l){return Ge(l.avgDurationMs)==="critical"}function cr(l){return Ge(l.avgDurationMs)==="warning"}function dr(l){return Ge(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),hr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),gr=({shardKey:l=""})=>{const e=pe(),[s,a]=fe("15m"),t=Je(ze.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,d=hr(t?.buckets??[]);return o("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>r("button",{"aria-pressed":i===s,className:jt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{a(i)},type:"button",children:i},i))}),t?.capped===!0&&r(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),d.length===0?r(Et,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):o("div",{className:"grid gap-4 lg:grid-cols-2",children:[o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),r(lt,{height:140,width:"100%",children:o(Ot,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),r(lt,{height:140,width:"100%",children:o(At,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),r(ir,{queryStats:t?.entries??[]})]})},fr=kt(ze.getMetrics),pr=(l,e)=>l?e:"overview",Qr=({initialShardKey:l})=>{const e=pt(),s=pe(),a=xt(),{queryShardKey:t,setShardKey:d,shardKey:i}=Nt(l),[n,k]=fe("overview"),[f,S]=fe([]),p=We(null),u=We(null),h=We(!0);tt(()=>(h.current=!0,()=>{h.current=!1}),[]);const M=L=>{It({shardKey:t,traceId:L}),at(a({to:"/traces"}))},{data:b,error:$,liveError:_}=Je(ze.getMetrics,{},{live:!0,shardKey:t}),c=b??null;tt(()=>{if(b===void 0)return;Mt(t);const L=b,Q=p.current,O=u.current!==null&&u.current!==L.shard;if(u.current=L.shard,p.current=L.requests,O){S([]);return}Q!==null&&L.requests>=Q&&S(A=>[...A,L.requests-Q].slice(-30))},[b,t]);const[g,x]=fe(null),[w,q]=fe(!1),y=async()=>{q(!0);const L=Lt(i,_t());try{const Q=await Promise.all(L.map(async O=>{try{const A=await e.query(fr,{},wt(O));return{error:null,metrics:A,shard:O===""?A.shard:O}}catch(A){return{error:qt(A),metrics:null,shard:O===""?"__root__":O}}}));h.current&&x(Q)}finally{h.current&&q(!1)}},I=g===null?null:Dt(g),C=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,R=f.length>0?f.at(-1):0,D=c?Ft(c):{p90:0,p95:0},N=bt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return Tt(L)},[c]),v=pr(N!==void 0,n),T=()=>{at(y())},z=()=>{x(null)},K=()=>{k("overview")},U=()=>{k("query-insights")};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r(yt,{onChange:d,testId:"mt-shard-input",value:i}),r(vt,{message:_,prefix:"mt"}),r(rt,{"data-testid":"mt-aggregate",disabled:w,onClick:T,size:"sm",type:"button",variant:"secondary",children:s(w?"Aggregating…":"All shards")}),g!==null&&r(rt,{"data-testid":"mt-aggregate-clear",onClick:z,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),$!==null&&r("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:$}),N!==void 0&&o("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[r("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:K,type:"button",children:s("Overview")}),o("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:U,type:"button",children:[s("Query insights"),N.length>0&&r("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&r(gr,{shardKey:t}),v==="overview"&&c!==null&&r(lr,{currentDelta:R,errorRate:C,history:f,latencyPercentiles:D,metrics:c}),v==="overview"&&c===null&&null,v==="overview"&&r(er,{onOpenTrace:M,shardKey:t}),v==="overview"&&I!==null&&g!==null&&r(tr,{aggregate:I,shardResults:g})]})};export{Qr as MetricsPanel};
1
+ import{useLunora as ft}from"@lunora/react";import{useState as fe,useRef as We,useEffect as tt,useMemo as pt}from"react";import{L as xt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as bt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{N as Je}from"../packem_shared/use-admin-query-CnnyWJXM.js";import{f as vt}from"../packem_shared/use-open-trace-D9XDDHHS.js";import{S as yt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as pe}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as Nt}from"../packem_shared/cf-links-Dmg86v1D.js";import{m as St,l as Ye,f as $t,d as wt,b as qt,g as kt}from"../packem_shared/internal-zkEvTqy8.js";import{r as Mt,l as _t}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as Te}from"react/compiler-runtime";import{f as Ct}from"../packem_shared/trace-handoff-D7j9TjUT.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{c as he,f as ge,n as Ue,m as Pe,p as It}from"../packem_shared/card-BMKx5UdA.js";import{m as de,n as ct,f as He,p as oe,d as dt,b as mt}from"../packem_shared/table-DZAB8cs3.js";import{S as ut}from"../packem_shared/sparkline-BNvxiJj_.js";import{jsx as t,jsxs as o,Fragment as Ve}from"react/jsx-runtime";import{aggregateMetrics as Rt,computeLatencyPercentiles as Dt,enrichQueryStats as Ft,shardsToAggregate as Lt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{g as me}from"../packem_shared/stat-card-BGJdhfm6.js";import{ResponsiveContainer as at,AreaChart as Tt,CartesianGrid as lt,XAxis as st,YAxis as nt,Tooltip as it,Area as Ot,LineChart as zt,Line as At}from"recharts";import{E as Kt}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as Et}from"../packem_shared/utils-bhneXptQ.js";import{w as jt,z as Ut,_ as Qe,S as Pt,x as Qt}from"../packem_shared/select-BssZMiFY.js";const Bt=(l,e)=>l<e?-1:l>e?1:0,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l))return`[${l.map(d=>Ze(d)).join(",")}]`;const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const d=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${d} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=l,a=Object.keys(s).toSorted(Bt),r=[];for(const d of a){const i=s[d];i!==void 0&&r.push(`${JSON.stringify(d)}:${Ze(i)}`)}return`{${r.join(",")}}`},ht=(l,e,s)=>`${l}:${e}:${Ze(s??{})}`,gt=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Jt=(l,e)=>gt(l,e),Ht=l=>gt(l.kind,l),Xe=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Gt=l=>Array.isArray(l?.series)?l.series:[],Wt="FUNCTION_NOT_FOUND",Xt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const s of l.series)e.set(ht(s.kind,s.name,s.attributes),s.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Vt=l=>{const e=Te(18),{name:s,onOpenTrace:a,traceId:r}=l,d=pe();if(r===void 0){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=m):m=e[0],m}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];const n=i;if(a===void 0){const m=`mt-instrument-trace-${s}`;let g;return e[3]!==n||e[4]!==m||e[5]!==r?(g=t("span",{className:"text-muted-foreground","data-testid":m,title:r,children:n}),e[3]=n,e[4]=m,e[5]=r,e[6]=g):g=e[6],g}const S=`mt-instrument-trace-${s}`;let v;e[7]!==a||e[8]!==r?(v=()=>{a(r)},e[7]=a,e[8]=r,e[9]=v):v=e[9];let $;e[10]!==d||e[11]!==r?($=d("Open the exemplar trace {trace}",{trace:r}),e[10]=d,e[11]=r,e[12]=$):$=e[12];let h;return e[13]!==n||e[14]!==S||e[15]!==v||e[16]!==$?(h=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":S,onClick:v,title:$,type:"button",children:n}),e[13]=n,e[14]=S,e[15]=v,e[16]=$,e[17]=h):h=e[17],h},Zt=l=>{const e=Te(105),{onOpenTrace:s,shardKey:a}=l,r=pe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];const{data:n,error:S,errorSource:v}=Je(ze.getMetricSeries,d,i);let $;e[3]===Symbol.for("react.memo_cache_sentinel")?($={},e[3]=$):$=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];const{data:m}=Je(ze.getMetricHistory,$,h);let g,y,w,M,c,p,f,x,q,_,N,I,C;if(e[6]!==n||e[7]!==S||e[8]!==v||e[9]!==m||e[10]!==s||e[11]!==r){x=Symbol.for("react.early_return_sentinel");e:{const O=Gt(n),A=St(v)===Wt;if(S!==null&&!A){let u;e[25]!==r?(u=r("Instruments"),e[25]=r,e[26]=u):u=e[26];let E;e[27]!==u?(E=t("h3",{className:"text-sm font-semibold text-foreground",children:u}),e[27]=u,e[28]=E):E=e[28];let U;e[29]!==S||e[30]!==r?(U=r("Instruments unavailable: {error}",{error:S}),e[29]=S,e[30]=r,e[31]=U):U=e[31];let P;e[32]!==U?(P=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:U}),e[32]=U,e[33]=P):P=e[33];let ie;e[34]!==E||e[35]!==P?(ie=o("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,P]}),e[34]=E,e[35]=P,e[36]=ie):ie=e[36],x=ie;break e}if(O.length===0){x=null;break e}const T=Xt(m);let K;e[37]!==r?(K=u=>r(u==="counter"?"Counter":u==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=K):K=e[38];const j=K;c="flex flex-col gap-2",p="mt-instruments";let z;e[39]!==r?(z=r("Instruments"),e[39]=r,e[40]=z):z=e[40],e[41]!==z?(f=t("h3",{className:"text-sm font-semibold text-foreground",children:z}),e[41]=z,e[42]=f):f=e[42],M=he,C="overflow-hidden py-0",w=ge,I="px-0",y=dt,_="mt-instruments-table";let B;e[43]!==r?(B=r("name"),e[43]=r,e[44]=B):B=e[44];let J;e[45]!==B?(J=t(de,{children:B}),e[45]=B,e[46]=J):J=e[46];let H;e[47]!==r?(H=r("kind"),e[47]=r,e[48]=H):H=e[48];let G;e[49]!==H?(G=t(de,{children:H}),e[49]=H,e[50]=G):G=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let V;e[57]!==Y?(V=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=V):V=e[58];let Z;e[59]!==r?(Z=r("range"),e[59]=r,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=t(de,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==r?(te=r("trend"),e[63]=r,e[64]=te):te=e[64];let re;e[65]!==te?(re=t(de,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==r?(ae=r("trace"),e[67]=r,e[68]=ae):ae=e[68];let le;e[69]!==ae?(le=t(de,{children:ae}),e[69]=ae,e[70]=le):le=e[70];let se;e[71]!==r?(se=r("dimensions"),e[71]=r,e[72]=se):se=e[72];let ne;e[73]!==se?(ne=t(de,{children:se}),e[73]=se,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==V||e[79]!==ee||e[80]!==re||e[81]!==le||e[82]!==ne?(N=t(ct,{children:o(He,{children:[J,G,X,V,ee,re,le,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=V,e[79]=ee,e[80]=re,e[81]=le,e[82]=ne,e[83]=N):N=e[83],g=mt,q=O.map(u=>{const E=Ct(u.attributes),U=ht(u.kind,u.name,u.attributes),P=(T.get(U)??[]).map(ie=>Jt(u.kind,ie));return o(He,{"data-testid":`mt-instrument-${u.name}`,children:[t(oe,{className:"font-mono text-xs",title:u.functionPath,children:u.name}),t(oe,{children:t(et,{variant:Yt[u.kind],children:j(u.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${u.name}`,children:Xe(Ht(u))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:u.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:u.min===u.max?"—":`${Xe(u.min)}–${Xe(u.max)}`}),t(oe,{children:P.length>=2?t(ut,{ariaLabel:r("{name} trend",{name:u.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${u.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Vt,{name:u.name,onOpenTrace:s,traceId:u.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"—":E})]},U)})}e[6]=n,e[7]=S,e[8]=v,e[9]=m,e[10]=s,e[11]=r,e[12]=g,e[13]=y,e[14]=w,e[15]=M,e[16]=c,e[17]=p,e[18]=f,e[19]=x,e[20]=q,e[21]=_,e[22]=N,e[23]=I,e[24]=C}else g=e[12],y=e[13],w=e[14],M=e[15],c=e[16],p=e[17],f=e[18],x=e[19],q=e[20],_=e[21],N=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let R;e[84]!==g||e[85]!==q?(R=t(g,{children:q}),e[84]=g,e[85]=q,e[86]=R):R=e[86];let k;e[87]!==y||e[88]!==R||e[89]!==_||e[90]!==N?(k=o(y,{"data-testid":_,children:[N,R]}),e[87]=y,e[88]=R,e[89]=_,e[90]=N,e[91]=k):k=e[91];let b;e[92]!==w||e[93]!==k||e[94]!==I?(b=t(w,{className:I,children:k}),e[92]=w,e[93]=k,e[94]=I,e[95]=b):b=e[95];let D;e[96]!==M||e[97]!==b||e[98]!==C?(D=t(M,{className:C,children:b}),e[96]=M,e[97]=b,e[98]=C,e[99]=D):D=e[99];let L;return e[100]!==c||e[101]!==p||e[102]!==f||e[103]!==D?(L=o("section",{className:c,"data-testid":p,children:[f,D]}),e[100]=c,e[101]=p,e[102]=f,e[103]=D,e[104]=L):L=e[104],L},er=l=>{const e=Te(74),{aggregate:s,shardResults:a}=l,r=pe();let d;e[0]!==r?(d=r("Shards"),e[0]=r,e[1]=d):d=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==d||e[7]!==i?(n=t(me,{label:d,testId:"mt-agg-shards",value:i}),e[6]=d,e[7]=i,e[8]=n):n=e[8];let S;e[9]!==r?(S=r("Total requests"),e[9]=r,e[10]=S):S=e[10];let v;e[11]!==s.totalRequests||e[12]!==S?(v=t(me,{label:S,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=S,e[13]=v):v=e[13];let $;e[14]!==r?($=r("Total errors"),e[14]=r,e[15]=$):$=e[15];let h;e[16]!==s.totalErrors||e[17]!==$?(h=t(me,{label:$,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=$,e[18]=h):h=e[18];let m;e[19]!==r?(m=r("Total database size"),e[19]=r,e[20]=m):m=e[20];let g;e[21]!==s.totalDatabaseSize?(g=Ye(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=g):g=e[22];let y;e[23]!==m||e[24]!==g?(y=t(me,{label:m,testId:"mt-agg-db-size",value:g}),e[23]=m,e[24]=g,e[25]=y):y=e[25];let w;e[26]!==r?(w=r("Combined cache hit rate"),e[26]=r,e[27]=w):w=e[27];let M;e[28]!==s.hitRate||e[29]!==r?(M=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=M):M=e[30];let c;e[31]!==w||e[32]!==M?(c=t(me,{label:w,testId:"mt-agg-cache",value:M}),e[31]=w,e[32]=M,e[33]=c):c=e[33];let p;e[34]!==y||e[35]!==c||e[36]!==n||e[37]!==v||e[38]!==h?(p=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,v,h,y,c]}),e[34]=y,e[35]=c,e[36]=n,e[37]=v,e[38]=h,e[39]=p):p=e[39];let f;e[40]!==r?(f=r("shard"),e[40]=r,e[41]=f):f=e[41];let x;e[42]!==f?(x=t(de,{children:f}),e[42]=f,e[43]=x):x=e[43];let q;e[44]!==r?(q=r("requests"),e[44]=r,e[45]=q):q=e[45];let _;e[46]!==q?(_=t(de,{children:q}),e[46]=q,e[47]=_):_=e[47];let N;e[48]!==r?(N=r("errors"),e[48]=r,e[49]=N):N=e[49];let I;e[50]!==N?(I=t(de,{children:N}),e[50]=N,e[51]=I):I=e[51];let C;e[52]!==r?(C=r("db size"),e[52]=r,e[53]=C):C=e[53];let R;e[54]!==C?(R=t(de,{children:C}),e[54]=C,e[55]=R):R=e[55];let k;e[56]!==x||e[57]!==_||e[58]!==I||e[59]!==R?(k=t(ct,{children:o(He,{children:[x,_,I,R]})}),e[56]=x,e[57]=_,e[58]=I,e[59]=R,e[60]=k):k=e[60];let b;if(e[61]!==a||e[62]!==r){let A;e[64]!==r?(A=T=>o(He,{"data-testid":`mt-agg-row-${T.shard}`,children:[t(oe,{children:T.shard}),T.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:T.error??r("unreachable")}):o(Ve,{children:[t(oe,{className:"tabular-nums",children:T.metrics.requests}),t(oe,{className:"tabular-nums",children:T.metrics.errors}),t(oe,{className:"tabular-nums",children:Ye(T.metrics.databaseSize)})]})]},T.shard),e[64]=r,e[65]=A):A=e[65],b=a.map(A),e[61]=a,e[62]=r,e[63]=b}else b=e[63];let D;e[66]!==b?(D=t(mt,{children:b}),e[66]=b,e[67]=D):D=e[67];let L;e[68]!==k||e[69]!==D?(L=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:o(dt,{"data-testid":"mt-agg-table",children:[k,D]})})}),e[68]=k,e[69]=D,e[70]=L):L=e[70];let O;return e[71]!==p||e[72]!==L?(O=o("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[p,L]}),e[71]=p,e[72]=L,e[73]=O):O=e[73],O},tr=l=>{const e=Math.floor(l/1e3),s=Math.floor(e/3600),a=Math.floor(e%3600/60),r=e%60;return s>0?`${s.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${r.toString()}s`:`${r.toString()}s`},rr=(l,e)=>{const s=l+e;return s===0?"—":`${(l/s*100).toFixed(1)}%`},ot=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,ar=l=>{const e=Te(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:d,metrics:i}=l,n=pe();let S;e[0]!==r||e[1]!==n?(S=r.length>=2?t(ut,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=S):S=e[2];let v;e[3]!==s||e[4]!==r.length||e[5]!==n?(v=r.length>=2?o(Ve,{children:[t("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples…")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=v):v=e[6];let $;e[7]!==n?($=n("Requests"),e[7]=n,e[8]=$):$=e[8];let h;e[9]!==i.requests||e[10]!==S||e[11]!==v||e[12]!==$?(h=t(me,{chart:S,footer:v,label:$,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=S,e[11]=v,e[12]=$,e[13]=h):h=e[13];let m;e[14]!==a||e[15]!==n?(m=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=m):m=e[16];let g;e[17]!==n?(g=n("Errors"),e[17]=n,e[18]=g):g=e[18];let y;e[19]!==a||e[20]!==i.errors?(y=o(Ve,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=y):y=e[21];let w;e[22]!==m||e[23]!==g||e[24]!==y?(w=t(me,{footer:m,label:g,testId:"mt-errors",value:y}),e[22]=m,e[23]=g,e[24]=y,e[25]=w):w=e[25];let M;e[26]!==d.p90?(M=d.p90>0?`P90 ${ot(d.p90)}`:void 0,e[26]=d.p90,e[27]=M):M=e[27];let c;e[28]!==n?(c=n("P95 latency"),e[28]=n,e[29]=c):c=e[29];let p;e[30]!==d.p95?(p=d.p95>0?ot(d.p95):"—",e[30]=d.p95,e[31]=p):p=e[31];let f;e[32]!==c||e[33]!==p||e[34]!==M?(f=t(me,{footer:M,label:c,testId:"mt-p95",value:p}),e[32]=c,e[33]=p,e[34]=M,e[35]=f):f=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let q;e[39]!==n?(q=n("Database size"),e[39]=n,e[40]=q):q=e[40];let _;e[41]!==i.databaseSize?(_=Ye(i.databaseSize),e[41]=i.databaseSize,e[42]=_):_=e[42];let N;e[43]!==x||e[44]!==q||e[45]!==_?(N=t(me,{footer:x,label:q,testId:"mt-db-size",value:_}),e[43]=x,e[44]=q,e[45]=_,e[46]=N):N=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let C;e[49]!==i.shard||e[50]!==I?(C=t(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let k;e[54]!==i.uptimeMs?(k=tr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=k):k=e[55];let b;e[56]!==R||e[57]!==k?(b=t(me,{label:R,testId:"mt-uptime",value:k}),e[56]=R,e[57]=k,e[58]=b):b=e[58];let D;e[59]!==n?(D=n("Cache hit rate"),e[59]=n,e[60]=D):D=e[60];let L;e[61]!==i.cache||e[62]!==n?(L=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:rr(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=L):L=e[63];let O;e[64]!==D||e[65]!==L?(O=t(me,{label:D,testId:"mt-cache",value:L}),e[64]=D,e[65]=L,e[66]=O):O=e[66];let A;return e[67]!==f||e[68]!==N||e[69]!==C||e[70]!==b||e[71]!==O||e[72]!==h||e[73]!==w?(A=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[h,w,f,N,C,b,O]}),e[67]=f,e[68]=N,e[69]=C,e[70]=b,e[71]=O,e[72]=h,e[73]=w,e[74]=A):A=e[74],A},Ge=l=>l>=100?"critical":l>=50?"warning":"good",Oe=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,Be=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),lr=l=>{const e=Te(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(et,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},sr=(l,e)=>{const s=[...l];return s.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),s},nr=l=>{const e=Te(161),{queryStats:s}=l,a=pe(),[r,d]=fe("totalTime");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[n,S]=fe(i);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=C=>{C!==null&&d(C)},e[1]=v):v=e[1];const $=v;let h,m,g,y,w,M,c,p,f,x;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){g=Symbol.for("react.early_return_sentinel");e:{const C=sr(s,r);let R;e[16]!==s?(R=s.filter(ir),e[16]=s,e[17]=R):R=e[17];const k=R.length;let b;e[18]!==s?(b=s.filter(or),e[18]=s,e[19]=b):b=e[19];const D=b.length;let L;e[20]!==s?(L=s.filter(cr),e[20]=s,e[21]=L):L=e[21];const O=L.length;let A;e[22]===Symbol.for("react.memo_cache_sentinel")?(A=F=>{S(ce=>{const Q=new Set(ce);return Q.has(F)?Q.delete(F):Q.add(F),Q})},e[22]=A):A=e[22];const T=A;if(s.length===0){let F;e[23]!==a?(F=a("No query insights yet"),e[23]=a,e[24]=F):F=e[24];let ce;e[25]!==F?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:F}),e[25]=F,e[26]=ce):ce=e[26];let Q;e[27]!==a?(Q=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=Q):Q=e[28];let ue;e[29]!==Q?(ue=t("p",{className:"mt-1 text-sm",children:Q}),e[29]=Q,e[30]=ue):ue=e[30];let je;e[31]!==ce||e[32]!==ue?(je=t(he,{children:t(ge,{className:"py-12",children:o("div",{className:"text-center text-muted-foreground",children:[ce,ue]})})}),e[31]=ce,e[32]=ue,e[33]=je):je=e[33],g=je;break e}c="space-y-4",p="qi-root";let K;e[34]!==a?(K=a("Critical queries"),e[34]=a,e[35]=K):K=e[35];let j;e[36]!==K?(j=t(Ue,{className:"pb-2",children:t(Pe,{className:"text-sm font-medium",children:K})}),e[36]=K,e[37]=j):j=e[37];let z;e[38]!==k?(z=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=z):z=e[39];let B;e[40]!==a?(B=a(">100ms avg execution"),e[40]=a,e[41]=B):B=e[41];let J;e[42]!==B?(J=t("p",{className:"text-xs text-muted-foreground",children:B}),e[42]=B,e[43]=J):J=e[43];let H;e[44]!==z||e[45]!==J?(H=o(ge,{children:[z,J]}),e[44]=z,e[45]=J,e[46]=H):H=e[46];let G;e[47]!==j||e[48]!==H?(G=o(he,{children:[j,H]}),e[47]=j,e[48]=H,e[49]=G):G=e[49];let W;e[50]!==a?(W=a("Moderate queries"),e[50]=a,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Ue,{className:"pb-2",children:t(Pe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==D?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:D}),e[54]=D,e[55]=Y):Y=e[55];let V;e[56]!==a?(V=a("50–100ms avg execution"),e[56]=a,e[57]=V):V=e[57];let Z;e[58]!==V?(Z=t("p",{className:"text-xs text-muted-foreground",children:V}),e[58]=V,e[59]=Z):Z=e[59];let ee;e[60]!==Y||e[61]!==Z?(ee=o(ge,{children:[Y,Z]}),e[60]=Y,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==X||e[64]!==ee?(te=o(he,{children:[X,ee]}),e[63]=X,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=t(Ue,{className:"pb-2",children:t(Pe,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let le;e[70]!==O?(le=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:O}),e[70]=O,e[71]=le):le=e[71];let se;e[72]!==a?(se=a("<50ms avg execution"),e[72]=a,e[73]=se):se=e[73];let ne;e[74]!==se?(ne=t("p",{className:"text-xs text-muted-foreground",children:se}),e[74]=se,e[75]=ne):ne=e[75];let u;e[76]!==le||e[77]!==ne?(u=o(ge,{children:[le,ne]}),e[76]=le,e[77]=ne,e[78]=u):u=e[78];let E;e[79]!==ae||e[80]!==u?(E=o(he,{children:[ae,u]}),e[79]=ae,e[80]=u,e[81]=E):E=e[81],e[82]!==G||e[83]!==te||e[84]!==E?(f=o("div",{className:"grid gap-4 md:grid-cols-3",children:[G,te,E]}),e[82]=G,e[83]=te,e[84]=E,e[85]=f):f=e[85];let U;e[86]!==a?(U=a("Query leaderboard"),e[86]=a,e[87]=U):U=e[87];let P;e[88]!==U?(P=t("h3",{className:"text-lg font-semibold",children:U}),e[88]=U,e[89]=P):P=e[89];let ie;e[90]!==r||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=ie):ie=e[92];let xe;e[93]!==ie?(xe=t("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=xe):xe=e[94];let be;e[95]!==P||e[96]!==xe?(be=o("div",{children:[P,xe]}),e[95]=P,e[96]=xe,e[97]=be):be=e[97];let ve;e[98]!==a?(ve=a("Sort by"),e[98]=a,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=t("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==a?(Ne=a("Sort queries by"),e[102]=a,e[103]=Ne):Ne=e[103];let Ae;e[104]===Symbol.for("react.memo_cache_sentinel")?(Ae=t(jt,{}),e[104]=Ae):Ae=e[104];let Se;e[105]!==Ne?(Se=t(Ut,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Ae}),e[105]=Ne,e[106]=Se):Se=e[106];let $e;e[107]!==a?($e=a("Total time"),e[107]=a,e[108]=$e):$e=e[108];let we;e[109]!==$e?(we=t(Qe,{value:"totalTime",children:$e}),e[109]=$e,e[110]=we):we=e[110];let qe;e[111]!==a?(qe=a("Avg time"),e[111]=a,e[112]=qe):qe=e[112];let ke;e[113]!==qe?(ke=t(Qe,{value:"avgTime",children:qe}),e[113]=qe,e[114]=ke):ke=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let _e;e[117]!==Me?(_e=t(Qe,{value:"execCount",children:Me}),e[117]=Me,e[118]=_e):_e=e[118];let Ce;e[119]!==a?(Ce=a("Rows read"),e[119]=a,e[120]=Ce):Ce=e[120];let Ie;e[121]!==Ce?(Ie=t(Qe,{value:"rowsRead",children:Ce}),e[121]=Ce,e[122]=Ie):Ie=e[122];let Re;e[123]!==we||e[124]!==ke||e[125]!==_e||e[126]!==Ie?(Re=o(Pt,{children:[we,ke,_e,Ie]}),e[123]=we,e[124]=ke,e[125]=_e,e[126]=Ie,e[127]=Re):Re=e[127];let De;e[128]!==r||e[129]!==Se||e[130]!==Re?(De=o(Qt,{onValueChange:$,value:r,children:[Se,Re]}),e[128]=r,e[129]=Se,e[130]=Re,e[131]=De):De=e[131];let Fe;e[132]!==ye||e[133]!==De?(Fe=o("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=Fe):Fe=e[134],e[135]!==be||e[136]!==Fe?(x=o("div",{className:"flex items-center justify-between",children:[be,Fe]}),e[135]=be,e[136]=Fe,e[137]=x):x=e[137],m=he;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Ke;e[140]!==Le?(Ke=t(Pe,{children:Le}),e[140]=Le,e[141]=Ke):Ke=e[141],M=o(Ue,{children:[Ke,t(It,{children:a("{count} tracked statements",{count:C.length})})]}),h=ge,y="space-y-2";let Ee;e[142]!==n||e[143]!==a?(Ee=F=>{const ce=F.normalizedSql,Q=n.has(ce),ue=Ge(F.avgDurationMs);return o("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[o("button",{"aria-expanded":Q,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{T(ce)},type:"button",children:[o("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(lr,{level:ue}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:F.normalizedSql})]}),o("div",{className:"flex shrink-0 items-center gap-4",children:[o("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Oe(F.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),o("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Oe(F.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),F.p95DurationMs!==void 0&&o("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Oe(F.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),o("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Be(F.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),Q&&o("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[o("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:F.normalizedSql})]}),o("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[F.p50DurationMs!==void 0&&o("div",{children:[t("span",{className:"text-muted-foreground",children:a("p50")}),t("span",{className:"block font-medium tabular-nums",children:Oe(F.p50DurationMs)})]}),o("div",{children:[t("span",{className:"text-muted-foreground",children:a("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Be(F.execCount)})]}),o("div",{children:[t("span",{className:"text-muted-foreground",children:a("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Oe(F.totalDurationMs)})]}),o("div",{children:[t("span",{className:"text-muted-foreground",children:a("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Be(F.rowsRead)})]}),o("div",{children:[t("span",{className:"text-muted-foreground",children:a("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Be(F.rowsWritten)})]})]})]})]},ce)},e[142]=n,e[143]=a,e[144]=Ee):Ee=e[144],w=C.map(Ee)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=h,e[7]=m,e[8]=g,e[9]=y,e[10]=w,e[11]=M,e[12]=c,e[13]=p,e[14]=f,e[15]=x}else h=e[6],m=e[7],g=e[8],y=e[9],w=e[10],M=e[11],c=e[12],p=e[13],f=e[14],x=e[15];if(g!==Symbol.for("react.early_return_sentinel"))return g;let q;e[145]!==y||e[146]!==w?(q=t("div",{className:y,children:w}),e[145]=y,e[146]=w,e[147]=q):q=e[147];let _;e[148]!==h||e[149]!==q?(_=t(h,{children:q}),e[148]=h,e[149]=q,e[150]=_):_=e[150];let N;e[151]!==m||e[152]!==_||e[153]!==M?(N=o(m,{children:[M,_]}),e[151]=m,e[152]=_,e[153]=M,e[154]=N):N=e[154];let I;return e[155]!==N||e[156]!==c||e[157]!==p||e[158]!==f||e[159]!==x?(I=o("div",{className:c,"data-testid":p,children:[f,x,N]}),e[155]=N,e[156]=c,e[157]=p,e[158]=f,e[159]=x,e[160]=I):I=e[160],I};function ir(l){return Ge(l.avgDurationMs)==="critical"}function or(l){return Ge(l.avgDurationMs)==="warning"}function cr(l){return Ge(l.avgDurationMs)==="good"}const dr=["1m","5m","15m","1h"],mr=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ur=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:mr(e.bucketMs)})),hr=({shardKey:l=""})=>{const e=pe(),[s,a]=fe("15m"),r=Je(ze.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,d=ur(r?.buckets??[]);return o("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:dr.map(i=>t("button",{"aria-pressed":i===s,className:Et("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{a(i)},type:"button",children:i},i))}),r?.capped===!0&&t(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),d.length===0?t(Kt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):o("div",{className:"grid gap-4 lg:grid-cols-2",children:[o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(at,{height:140,width:"100%",children:o(Tt,{data:d,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(st,{dataKey:"label",fontSize:10,tickLine:!1}),t(nt,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(it,{}),t(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(at,{height:140,width:"100%",children:o(zt,{data:d,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(st,{dataKey:"label",fontSize:10,tickLine:!1}),t(nt,{fontSize:10,tickLine:!1,width:32}),t(it,{}),t(At,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(nr,{queryStats:r?.entries??[]})]})},gr=kt(ze.getMetrics),fr=(l,e)=>l?e:"overview",Ur=({initialShardKey:l})=>{const e=ft(),s=pe(),{queryShardKey:a,setShardKey:r,shardKey:d}=yt(l),[i,n]=fe("overview"),[S,v]=fe([]),$=We(null),h=We(null),m=We(!0);tt(()=>(m.current=!0,()=>{m.current=!1}),[]);const g=vt(a),{data:y,error:w,liveError:M}=Je(ze.getMetrics,{},{live:!0,shardKey:a}),c=y??null;tt(()=>{if(y===void 0)return;Mt(a);const T=y,K=$.current,j=h.current!==null&&h.current!==T.shard;if(h.current=T.shard,$.current=T.requests,j){v([]);return}K!==null&&T.requests>=K&&v(z=>[...z,T.requests-K].slice(-30))},[y,a]);const[p,f]=fe(null),[x,q]=fe(!1),_=async()=>{q(!0);const T=Lt(d,_t());try{const K=await Promise.all(T.map(async j=>{try{const z=await e.query(gr,{},wt(j));return{error:null,metrics:z,shard:j===""?z.shard:j}}catch(z){return{error:qt(z),metrics:null,shard:j===""?"__root__":j}}}));m.current&&f(K)}finally{m.current&&q(!1)}},N=p===null?null:Rt(p),I=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,C=S.length>0?S.at(-1):0,R=c?Dt(c):{p90:0,p95:0},k=pt(()=>{if(!c||!("queryStats"in c))return;const T=c.queryStats;if(!(!T||!Array.isArray(T)))return Ft(T)},[c]),b=fr(k!==void 0,i),D=()=>{$t(_())},L=()=>{f(null)},O=()=>{n("overview")},A=()=>{n("query-insights")};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[t(bt,{onChange:r,testId:"mt-shard-input",value:d}),t(xt,{message:M,prefix:"mt"}),t(rt,{"data-testid":"mt-aggregate",disabled:x,onClick:D,size:"sm",type:"button",variant:"secondary",children:s(x?"Aggregating…":"All shards")}),p!==null&&t(rt,{"data-testid":"mt-aggregate-clear",onClick:L,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Nt,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),w!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:w}),k!==void 0&&o("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${b==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:O,type:"button",children:s("Overview")}),o("button",{className:`pb-2 text-sm font-medium transition-colors ${b==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:A,type:"button",children:[s("Query insights"),k.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:k.length})]})]}),b==="query-insights"&&k!==void 0&&t(hr,{shardKey:a}),b==="overview"&&c!==null&&t(ar,{currentDelta:C,errorRate:I,history:S,latencyPercentiles:R,metrics:c}),b==="overview"&&c===null&&null,b==="overview"&&t(Zt,{onOpenTrace:g,shardKey:a}),b==="overview"&&N!==null&&p!==null&&t(er,{aggregate:N,shardResults:p})]})};export{Ur as MetricsPanel};