@lunora/studio 1.0.0-alpha.141 → 1.0.0-alpha.143

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 (151) hide show
  1. package/dist/index.d.mts +16 -4
  2. package/dist/index.d.ts +16 -4
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.d.mts +2 -1
  5. package/dist/mount.d.ts +2 -1
  6. package/dist/mount.mjs +1 -1
  7. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  8. package/dist/packem_chunks/ApiTab.mjs +1 -1
  9. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  10. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  11. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  12. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  13. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  14. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  15. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  16. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  17. package/dist/packem_chunks/MailPanel.mjs +1 -1
  18. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  19. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  20. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  21. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  22. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  23. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  24. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  25. package/dist/packem_chunks/TableEditor.mjs +1 -1
  26. package/dist/packem_chunks/agents-panel.mjs +1 -1
  27. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  28. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  30. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  31. package/dist/packem_chunks/containers-panel.mjs +1 -1
  32. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  33. package/dist/packem_chunks/evals-panel.mjs +1 -1
  34. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  35. package/dist/packem_chunks/flags-panel.mjs +1 -1
  36. package/dist/packem_chunks/issues-panel.mjs +1 -1
  37. package/dist/packem_chunks/kv-browser.mjs +1 -1
  38. package/dist/packem_chunks/migrations-route.mjs +1 -1
  39. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  40. package/dist/packem_chunks/payments-panel.mjs +1 -1
  41. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  42. package/dist/packem_chunks/queues-panel.mjs +1 -1
  43. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  44. package/dist/packem_chunks/rls-panel.mjs +1 -1
  45. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  46. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  47. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  48. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  49. package/dist/packem_chunks/traces-panel.mjs +1 -1
  50. package/dist/packem_chunks/users-panel.mjs +1 -1
  51. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  52. package/dist/packem_shared/{ADMIN_FUNCTIONS-B6z7VLYt.mjs → ADMIN_FUNCTIONS-B8yyk5BX.mjs} +1 -1
  53. package/dist/packem_shared/{ApiDocsPanel-BOxViKDM.mjs → ApiDocsPanel-l4DQX1Vq.mjs} +1 -1
  54. package/dist/packem_shared/DataBrowser-C2B-HNOL.mjs +4 -0
  55. package/dist/packem_shared/{GlobalDataBrowser-BKm77TNC.mjs → GlobalDataBrowser-DK4fgb7h.mjs} +1 -1
  56. package/dist/packem_shared/{HomePanel-YG8qu2Nb.mjs → HomePanel-B869m6wb.mjs} +1 -1
  57. package/dist/packem_shared/{MigrationsPanel-CYe0ygT8.mjs → MigrationsPanel-BZJ_Rv4t.mjs} +1 -1
  58. package/dist/packem_shared/{ScheduledJobs-DN0yQoo6.mjs → ScheduledJobs-Db0HZ8R9.mjs} +1 -1
  59. package/dist/packem_shared/{Studio-D8OZ5P-V.mjs → Studio-UxOpDgEl.mjs} +1 -1
  60. package/dist/packem_shared/StudioApp-BdisV3FN.mjs +1 -0
  61. package/dist/packem_shared/{advisor-view-5mZH6453.mjs → advisor-view-DoSv436g.mjs} +1 -1
  62. package/dist/packem_shared/aggregateMetrics-CY05xrYU.mjs +1 -0
  63. package/dist/packem_shared/{app.d-D1bPR8FO.d.mts → app.d-DFjg4Uki.d.mts} +33 -1
  64. package/dist/packem_shared/{app.d-D1bPR8FO.d.ts → app.d-DFjg4Uki.d.ts} +33 -1
  65. package/dist/packem_shared/{error-alert-CczbAfst.mjs → error-alert-CWs6gA3I.mjs} +1 -1
  66. package/dist/packem_shared/{home-panel-BID7w6j3.mjs → home-panel-ChKczU0I.mjs} +1 -1
  67. package/dist/packem_shared/{recording-client-BEZ6tVgo.mjs → recording-client-BGyq5_JP.mjs} +1 -1
  68. package/dist/packem_shared/{select-Cx8-CokP.mjs → select-DPyS18Vy.mjs} +1 -1
  69. package/dist/packem_shared/{studio-ByaR_3g9.mjs → studio-DE8N0tIQ.mjs} +1 -1
  70. package/dist/packem_shared/{table-list-sidebar-BxZm3sBJ.mjs → table-list-sidebar-T7--Fv-V.mjs} +1 -1
  71. package/dist/packem_shared/use-admin-query-C7JRlFIE.mjs +1 -0
  72. package/dist/packem_shared/{use-auth-config-gxJL0E1r.mjs → use-auth-config-o-FcIXzR.mjs} +1 -1
  73. package/dist/packem_shared/{use-sql-assistant-CFRzdA9E.mjs → use-sql-assistant-Ib7Ik6cw.mjs} +1 -1
  74. package/dist/packem_shared/wire-codec-DGcjNTbZ.mjs +1 -0
  75. package/dist/standalone/chunk-2BN33A2H.js +1 -0
  76. package/dist/standalone/{chunk-TRL7AHZK.js → chunk-2DRUQ42V.js} +1 -1
  77. package/dist/standalone/{chunk-43Y54D7O.js → chunk-44XP35PZ.js} +1 -1
  78. package/dist/standalone/{chunk-G63MGXPG.js → chunk-4RDRBZ3Z.js} +1 -1
  79. package/dist/standalone/{chunk-CXNZVJ3S.js → chunk-4ZEL6BYL.js} +1 -1
  80. package/dist/standalone/{chunk-MRJNT4OH.js → chunk-5OSOXQGT.js} +1 -1
  81. package/dist/standalone/chunk-5OWAVF7Y.js +1 -0
  82. package/dist/standalone/{chunk-RK3WWWTT.js → chunk-5UFDH5PE.js} +1 -1
  83. package/dist/standalone/{chunk-VPPKG2IW.js → chunk-64KROZ2C.js} +1 -1
  84. package/dist/standalone/{chunk-YFPU55K4.js → chunk-6DSKJTA4.js} +1 -1
  85. package/dist/standalone/{chunk-UBVWMMQG.js → chunk-6GTVFSLV.js} +1 -1
  86. package/dist/standalone/{chunk-2QSOSRNW.js → chunk-73TWF2G4.js} +1 -1
  87. package/dist/standalone/{chunk-56AFJWER.js → chunk-76EQ5JUU.js} +1 -1
  88. package/dist/standalone/chunk-ADJTCEH3.js +1 -0
  89. package/dist/standalone/{chunk-BX3F7MXP.js → chunk-AQI7ZNT2.js} +1 -1
  90. package/dist/standalone/{chunk-7QMV55PO.js → chunk-CDTGKA5J.js} +1 -1
  91. package/dist/standalone/{chunk-2AFIMJPZ.js → chunk-DHSCHEJZ.js} +1 -1
  92. package/dist/standalone/chunk-DPS5Q64N.js +1 -0
  93. package/dist/standalone/{chunk-OOESPRIZ.js → chunk-FRIPZLHV.js} +1 -1
  94. package/dist/standalone/{chunk-QSOJFV42.js → chunk-FSFJ5LI2.js} +1 -1
  95. package/dist/standalone/{chunk-JYMXJUJ2.js → chunk-GUIGDTCU.js} +1 -1
  96. package/dist/standalone/{chunk-EG6XHY7N.js → chunk-HWBXHONF.js} +1 -1
  97. package/dist/standalone/{chunk-KDWJAKFX.js → chunk-I6GOQSDQ.js} +1 -1
  98. package/dist/standalone/{chunk-LC3XGRNU.js → chunk-ICVRD6K5.js} +1 -1
  99. package/dist/standalone/{chunk-ZE2Q22OK.js → chunk-IPIFMAW4.js} +1 -1
  100. package/dist/standalone/{chunk-N6KHKQJH.js → chunk-KVPXTLKG.js} +1 -1
  101. package/dist/standalone/{chunk-TZI3JW3Q.js → chunk-M5ROVSBF.js} +1 -1
  102. package/dist/standalone/chunk-MM322O3E.js +1 -0
  103. package/dist/standalone/{chunk-Q3HF6P2M.js → chunk-MOSQV7WU.js} +1 -1
  104. package/dist/standalone/{chunk-C5L4BSYY.js → chunk-MUOVSMDK.js} +1 -1
  105. package/dist/standalone/{chunk-DQHYNFE4.js → chunk-MWHKPKQC.js} +1 -1
  106. package/dist/standalone/{chunk-S63ID2FC.js → chunk-NDVLXSQJ.js} +1 -1
  107. package/dist/standalone/{chunk-ZOWSTFP5.js → chunk-OAEQLGGA.js} +1 -1
  108. package/dist/standalone/{chunk-YFLOZILV.js → chunk-OIZ7KE2D.js} +1 -1
  109. package/dist/standalone/{chunk-HODZXHVK.js → chunk-OVCT4ANW.js} +1 -1
  110. package/dist/standalone/{chunk-MIVYBFY3.js → chunk-P6NXPLYT.js} +1 -1
  111. package/dist/standalone/chunk-Q2ONYLZ3.js +7 -0
  112. package/dist/standalone/chunk-Q3627RWT.js +11 -0
  113. package/dist/standalone/{chunk-ZB74UWVA.js → chunk-QDUP4VDB.js} +1 -1
  114. package/dist/standalone/{chunk-JHEUUNXM.js → chunk-RI6SDJNF.js} +1 -1
  115. package/dist/standalone/{chunk-LJC5BM3X.js → chunk-RROTBODU.js} +1 -1
  116. package/dist/standalone/{chunk-V36AL47B.js → chunk-SFZVHU6C.js} +1 -1
  117. package/dist/standalone/chunk-SUDJTC4S.js +1 -0
  118. package/dist/standalone/{chunk-KEZZGUYY.js → chunk-T5JCEI5W.js} +1 -1
  119. package/dist/standalone/{chunk-3ZKYTFKY.js → chunk-TJPEAOEL.js} +1 -1
  120. package/dist/standalone/{chunk-WR675JUF.js → chunk-TUHIU3JC.js} +1 -1
  121. package/dist/standalone/{chunk-FNGY5SUZ.js → chunk-UAN6GGJ4.js} +1 -1
  122. package/dist/standalone/{chunk-ERWZGAOA.js → chunk-UVY6KN6G.js} +1 -1
  123. package/dist/standalone/{chunk-NE7AR3N3.js → chunk-V7HAXWCR.js} +1 -1
  124. package/dist/standalone/{chunk-X43AA6RX.js → chunk-VFMJJZVG.js} +1 -1
  125. package/dist/standalone/{chunk-PAUQAU23.js → chunk-VKYBRQC2.js} +1 -1
  126. package/dist/standalone/{chunk-USC5APTS.js → chunk-VQS5E53D.js} +1 -1
  127. package/dist/standalone/{chunk-EILTQDXX.js → chunk-VRLTD6I6.js} +1 -1
  128. package/dist/standalone/{chunk-Z5APSEW7.js → chunk-WJBOVMUO.js} +1 -1
  129. package/dist/standalone/{chunk-JAZCU2PP.js → chunk-WRLGCVLF.js} +1 -1
  130. package/dist/standalone/{chunk-2DO5EQCU.js → chunk-X6KMHRS7.js} +1 -1
  131. package/dist/standalone/{chunk-UKL4FSKP.js → chunk-XKABJHJG.js} +1 -1
  132. package/dist/standalone/{chunk-UWDFH35E.js → chunk-XYZBO7IN.js} +1 -1
  133. package/dist/standalone/{chunk-3PKWDMXA.js → chunk-YM62NSM6.js} +1 -1
  134. package/dist/standalone/{chunk-5PCGB55O.js → chunk-YQOVNRK5.js} +1 -1
  135. package/dist/standalone/{chunk-M6MCQSPI.js → chunk-ZJ6AMQGH.js} +1 -1
  136. package/dist/standalone/studio.js +7 -7
  137. package/package.json +6 -6
  138. package/dist/packem_shared/DataBrowser-rqpuEiuQ.mjs +0 -4
  139. package/dist/packem_shared/StudioApp-VZ3I91QA.mjs +0 -1
  140. package/dist/packem_shared/aggregateMetrics-A-Y7OH6R.mjs +0 -1
  141. package/dist/packem_shared/use-admin-query-Cbj2GuHu.mjs +0 -1
  142. package/dist/packem_shared/wire-codec-Dl3VeNrd.mjs +0 -1
  143. package/dist/standalone/chunk-CKZQXAZE.js +0 -1
  144. package/dist/standalone/chunk-ECQTVV2J.js +0 -1
  145. package/dist/standalone/chunk-EIKBBMM4.js +0 -1
  146. package/dist/standalone/chunk-JBIN7W2B.js +0 -11
  147. package/dist/standalone/chunk-JJA7KHJK.js +0 -1
  148. package/dist/standalone/chunk-MVKXAIW3.js +0 -7
  149. package/dist/standalone/chunk-O2FV34ZD.js +0 -1
  150. package/dist/standalone/chunk-TQCXJX4I.js +0 -1
  151. /package/dist/standalone/{chunk-YEBHHIAY.js → chunk-U5JDESCI.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/studio",
3
- "version": "1.0.0-alpha.141",
3
+ "version": "1.0.0-alpha.143",
4
4
  "description": "The Lunora Studio: a local admin UI for your schema, data, logs, and advisors",
5
5
  "keywords": [
6
6
  "admin-ui",
@@ -58,11 +58,11 @@
58
58
  "@hugeicons/react": "^1.1.9",
59
59
  "@lingui/core": "^6.6.0",
60
60
  "@lingui/message-utils": "^6.6.0",
61
- "@lunora/advisor": "1.0.0-alpha.101",
62
- "@lunora/bindings": "1.0.0-alpha.43",
63
- "@lunora/client": "1.0.0-alpha.67",
64
- "@lunora/errors": "1.0.0-alpha.26",
65
- "@lunora/react": "1.0.0-alpha.72",
61
+ "@lunora/advisor": "1.0.0-alpha.103",
62
+ "@lunora/bindings": "1.0.0-alpha.44",
63
+ "@lunora/client": "1.0.0-alpha.69",
64
+ "@lunora/errors": "1.0.0-alpha.27",
65
+ "@lunora/react": "1.0.0-alpha.74",
66
66
  "@tanstack/react-query": "^5.101.4",
67
67
  "@tanstack/react-router": "^1.170.25",
68
68
  "@tanstack/react-table": "^8.21.3",
@@ -1,4 +0,0 @@
1
- import{c as L}from"react/compiler-runtime";import{useLunora as lt}from"@lunora/react";import{useState as $,useEffect as Fe,useMemo as ht,useRef as Qe,useCallback as ot}from"react";import{ShardInput as xn}from"./ShardInput-C6mjgAh4.mjs";import{u as et}from"./use-admin-query-Cbj2GuHu.mjs";import{ADMIN_FUNCTIONS as te}from"./ADMIN_FUNCTIONS-B6z7VLYt.mjs";import{b as Ft}from"./browser-storage-BH1MxLZs.mjs";import{f as ie,h as Be,j as vn,c as Se,d as he,i as wn}from"./internal-CwaF9YNk.mjs";import{m as yn,c as Lt,d as ut,G as Cn,a as Sn,u as ft,b as Nn,T as kn,D as Tn}from"./table-list-sidebar-BxZm3sBJ.mjs";import{u as En}from"./use-sql-assistant-CFRzdA9E.mjs";import{M as wt}from"./modal-shell-CDztwLnv.mjs";import{useT as ne}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsxs as T,jsx as u,Fragment as Ue}from"react/jsx-runtime";import{ConfirmButton as kt}from"./ConfirmButton-DU4p72Er.mjs";import{E as _n}from"./empty-state-D7jEML_T.mjs";import{C as xt,a as Me}from"./control-button-BOZ5K-FC.mjs";import{useReactTable as Rn,getSortedRowModel as $n,getCoreRowModel as Dn,flexRender as In}from"@tanstack/react-table";import{useVirtualizer as Mn}from"@tanstack/react-virtual";import{C as yt}from"./checkbox-CnS9cyCz.mjs";import{c as st}from"./utils-bhneXptQ.mjs";import{f as An}from"./virtual-rect-D_j7aLxX.mjs";import{C as mt,G as Pn,T as On}from"./data-grid-BqNXJ9PF.mjs";import{DataFilters as Fn,toFilterClauses as Ve}from"./DataFilters-3nbW0uax.mjs";import{G as Ln,C as Vn}from"./grid-features-D8w5isjt.mjs";import{e as Bn,a as zn,i as jn,d as Gn}from"./wire-codec-Dl3VeNrd.mjs";import Tt from"./useDebounced-DVeQ5-oW.mjs";import{r as qn,l as Jn}from"./shard-history-CaO3C4KQ.mjs";const Kn=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,references:o.ref,table:e}))}))}),Wn=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const i=t.references,l=`${i}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(i)??[];r.push({...t,table:o.name}),e.set(i,r)}return e},Hn=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const i of t.children)o.push(i)}return n},Et=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const i of t)i.ref===s&&n.push({column:i.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Ct=s=>`${s.table}.${s.column}`,_t=6,tt=100,Un=s=>({paddingLeft:s*16}),Qn=s=>{const e=L(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=u("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},Yn=s=>{const e=L(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=u("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},Xn=s=>{const e=L(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=u("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},Zn=s=>s.relation===void 0||s.relation.onDelete==="cascade"?u(Yn,{table:s.table}):s.isRestrict?u(Qn,{table:s.table}):u(Xn,{table:s.table}),Vt=s=>{const e=L(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let i;e[0]!==n?(i=Un(n),e[0]=n,e[1]=i):i=e[1];let l;e[2]!==n?(l=n>0&&u("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=u("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&T("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let c;e[9]!==o.rowCount?(c=o.rowCount.toString(),e[9]=o.rowCount,e[10]=c):c=e[10];let g;e[11]!==c?(g=T("span",{className:"text-muted-foreground",children:["(",c," rows)"]}),e[11]=c,e[12]=g):g=e[12];let f;e[13]!==o?(f=Zn(o),e[13]=o,e[14]=f):f=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&T("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let m;e[18]!==t||e[19]!==i||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==g||e[24]!==f||e[25]!==p?(m=T("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:i,children:[l,r,a,g,f,p]}),e[18]=t,e[19]=i,e[20]=l,e[21]=r,e[22]=a,e[23]=g,e[24]=f,e[25]=p,e[26]=m):m=e[26];let d;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(v,x)=>u(Vt,{depth:n+1,node:v},`${v.table}-${v.relation?.field??"root"}-${x.toString()}`),e[30]=n,e[31]=h):h=e[31],d=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=d}else d=e[29];let b;return e[32]!==m||e[33]!==d?(b=T(Ue,{children:[m,d]}),e[32]=m,e[33]=d,e[34]=b):b=e[34],b},eo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},to=async(s,e,n,o)=>{try{const t=await o(s,e,n),i=t.rows.flatMap(a=>eo(a)||[]).slice(0,tt),l=t.total??0;return{capNote:l>tt?`showing first ${tt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:i}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},Bt=async(s,e,n,o,t,i,l)=>{const{capNote:r,rowCount:a,rowIds:c}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await to(s,n.field,e,l),g=n?.onDelete==="restrict",f=[],p=`${s}:${e}`,m=i>=_t;if(!t.has(p)&&!m){t.add(p);const b=o.get(s)??[];for(const h of b)for(const v of c.slice(0,10)){const x=await Bt(h.table,v,h,o,t,i+1,l);(x.rowCount>0||i===0)&&f.push(x)}t.delete(p)}let d=r;if(m){const b=`depth capped at ${_t.toString()}`;d=r===void 0?b:`${r}; ${b}`}return{capNote:d,children:f,isRestrict:g,relation:n,rowCount:a,rowIds:c,table:s}},no=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:i})=>{const l=ne(),[r,a]=$(!0),[c,g]=$(null),[f,p]=$(null);Fe(()=>{let b=!1;return ie((async()=>{try{a(!0),p(null);const v=Wn(t);if(!((v.get(i)??[]).length>0)){b||(g({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:i}),a(!1));return}const w=await Bt(i,o,void 0,v,new Set,0,n);b||(g(w),a(!1))}catch(v){b||(p(v.message),a(!1))}})()),()=>{b=!0}},[o,i]);const m=c!==null&&Hn(c,b=>b.isRestrict).length>0,d=()=>{e(),s()};return T(wt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[T("div",{className:"flex items-start justify-between",children:[T("div",{className:"flex flex-col gap-0.5",children:[u("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),u("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),u("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&u("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),f!==null&&u("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:f}),!r&&c!==null&&u("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:u(Vt,{depth:0,node:c})}),!r&&c!==null&&c.children.length===0&&u("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),m&&u("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),T("div",{className:"flex justify-end gap-2",children:[u("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),u("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:d,type:"button",children:l("Delete")})]})]})},oo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(f=>f.id)),leadPx:0,tailPx:0};const i=n-t,l=n+o+t,r=new Set;let a=0,c=0,g=0;for(const f of s){const p=f.getSize(),m=e.has(f.id),d=a+p>i&&a<l;m||d?r.add(f.id):a<i?c+=p:g+=p,a+=p}return{ids:r,leadPx:c,tailPx:g}},so=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},lo=()=>{const s=L(11);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(m,d,b)=>{o(h=>({...h,[m]:{...h[m],[d]:b}}))},s[1]=t):t=s[1];const i=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]!==n?(a=(m,d)=>{const b=n[m];return b!==void 0&&d in b?{value:b[d]}:void 0},s[3]=n,s[4]=a):a=s[4];const c=a;let g;s[5]!==n?(g=Object.values(n).reduce(ao,0),s[5]=n,s[6]=g):g=s[6];const f=g;let p;return s[7]!==f||s[8]!==n||s[9]!==c?(p={clear:r,count:f,stage:i,staged:n,stagedValue:c},s[7]=f,s[8]=n,s[9]=c,s[10]=p):p=s[10],p},zt=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},ro=s=>{const e=L(29),{changes:n,committing:o,onCommit:t,onDiscard:i}=s,l=ne();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=u("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let c;e[5]!==o||e[6]!==l?(c=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=c):c=e[7];let g;e[8]!==o||e[9]!==t||e[10]!==c?(g=u("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:c}),e[8]=o,e[9]=t,e[10]=c,e[11]=g):g=e[11];let f;e[12]!==l?(f=l("Discard"),e[12]=l,e[13]=f):f=e[13];let p;e[14]!==o||e[15]!==i||e[16]!==f?(p=u("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:i,type:"button",children:f}),e[14]=o,e[15]=i,e[16]=f,e[17]=p):p=e[17];let m;e[18]!==a||e[19]!==g||e[20]!==p?(m=T("div",{className:"flex flex-wrap items-center gap-2",children:[a,g,p]}),e[18]=a,e[19]=g,e[20]=p,e[21]=m):m=e[21];let d;e[22]!==n?(d=n.map(io),e[22]=n,e[23]=d):d=e[23];let b;e[24]!==d?(b=u("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:d}),e[24]=d,e[25]=b):b=e[25];let h;return e[26]!==m||e[27]!==b?(h=T("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[m,b]}),e[26]=m,e[27]=b,e[28]=h):h=e[28],h};function ao(s,e){return s+Object.keys(e).length}function io(s){return T("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[T("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),u("span",{className:"text-destructive line-through",children:Be(s.oldValue)}),u("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),u("span",{className:"text-foreground",children:Be(s.newValue)})]},`${s.rowId}:${s.column}`)}const Rt=400,co=36,uo={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},fo={width:"100%"},mo=/\n$/u,go={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},po={display:"flex",width:"100%"},$t={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},bo="2.5rem",jt={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},St=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),Gt=(s,e)=>({...St(s),left:`calc(${bo} + ${e.toString()}px)`,position:"sticky",zIndex:2}),gt="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ho=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,vt="__back__:",xo=s=>`${vt}${s.table}.${s.column}`,vo=s=>{const e=L(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=u("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let i;return e[1]!==t?(i=u("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=i):i=e[2],i},_e=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},wo=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},yo=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return wo(s,n);const o=zt(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},Co=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:i})=>{const l=i.replaceAll(`\r
2
- `,`
3
- `).replace(mo,"").split(`
4
- `),r=[];let a=0;for(const[c,g]of l.entries()){const f=t[s.row+c],p=f===void 0?null:_e(f),m=g.split(" ");if(f===void 0||p===null){a+=m.length;continue}for(const[d,b]of m.entries()){const h=e[s.col+d],v=h===void 0||!o(h)?void 0:yo(b,f[h],n?.[h]);h===void 0||v===void 0?a+=1:r.push({column:h,rowId:p,value:v.value})}}return{edits:r,skipped:a}},qt=(s,e)=>_e(s)??`row-${e.toString()}`,So=8,No=s=>{const e=L(17),{anchor:n,mask:o,state:t}=s,i=ne();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let g;e[3]!==i?(g=i("Loading…"),e[3]=i,e[4]=g):g=e[4];let f;e[5]!==g?(f=u("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:g}),e[5]=g,e[6]=f):f=e[6],a=f}else if(t.row===null){let g;e[7]!==i?(g=i("No matching row."),e[7]=i,e[8]=g):g=e[8];let f;e[9]!==g?(f=u("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:g}),e[9]=g,e[10]=f):f=e[10],a=f}else{let g;if(e[11]!==o||e[12]!==t.row){const f=Object.entries(Lt(t.row,o)).slice(0,So);g=u("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:f.map(Oo)}),e[11]=o,e[12]=t.row,e[13]=g}else g=e[13];a=g}let c;return e[14]!==a||e[15]!==r?(c=u("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=c):c=e[16],c},ko=s=>{const e=L(24),{column:n,id:o,maskViewFor:t,onNavigate:i,onPreview:l,target:r}=s,[a,c]=$(null),[g,f]=$("idle");let p;e[0]!==o||e[1]!==i||e[2]!==r?(p=()=>{i(r,o)},e[0]=o,e[1]=i,e[2]=r,e[3]=p):p=e[3];const m=p;let d;e[4]!==o||e[5]!==l||e[6]!==g||e[7]!==r?(d=S=>{const C=S.currentTarget.getBoundingClientRect();if(c({left:C.left,top:C.bottom+4}),g!=="idle")return;f("loading"),ie((async()=>{try{f({row:await l(r,o)})}catch{f({row:null})}})())},e[4]=o,e[5]=l,e[6]=g,e[7]=r,e[8]=d):d=e[8];const b=d;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{c(null)},e[9]=h):h=e[9];const v=h,x=`db-ref-${n}`,w=`Open ${r} ${o}`;let y;e[10]!==o||e[11]!==m||e[12]!==b||e[13]!==x||e[14]!==w?(y=T("button",{"data-testid":x,onBlur:v,onClick:m,onFocus:b,onMouseEnter:b,onMouseLeave:v,title:w,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=m,e[12]=b,e[13]=x,e[14]=w,e[15]=y):y=e[15];let N;e[16]!==a||e[17]!==t||e[18]!==g||e[19]!==r?(N=a!==null&&g!=="idle"&&u(No,{anchor:a,mask:t(r,g==="loading"||g.row===null?[]:Object.keys(g.row)),state:g}),e[16]=a,e[17]=t,e[18]=g,e[19]=r,e[20]=N):N=e[20];let E;return e[21]!==y||e[22]!==N?(E=T(Ue,{children:[y,N]}),e[21]=y,e[22]=N,e[23]=E):E=e[23],E},To=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",Eo="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",Dt=s=>{const e=L(8),{column:n,onExpand:o,value:t}=s;let i;e[0]!==n||e[1]!==o||e[2]!==t?(i=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=i):i=e[3];const l=i,r=`db-expand-${n}`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:u("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[4]=a):a=e[4];let c;return e[5]!==l||e[6]!==r?(c=u("button",{"aria-label":"Expand cell",className:Eo,"data-testid":r,onClick:l,type:"button",children:a}),e[5]=l,e[6]=r,e[7]=c):c=e[7],c},_o=s=>{const e=L(15),{column:n,initial:o,onCancel:t,onCommit:i,recordId:l}=s,r=Qe(null);let a,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},c=[],e[0]=a,e[1]=c):(a=e[0],c=e[1]),Fe(a,c);let g;e[2]!==t||e[3]!==i?(g=v=>{v.key==="Enter"?(v.preventDefault(),i(v.currentTarget.value)):v.key==="Escape"&&(v.preventDefault(),t())},e[2]=t,e[3]=i,e[4]=g):g=e[4];const f=g;let p;e[5]!==i?(p=v=>{i(v.currentTarget.value)},e[5]=i,e[6]=p):p=e[6];const m=p,d=`db-cell-input-${l}-${n}`;let b;e[7]!==o?(b=Be(o),e[7]=o,e[8]=b):b=e[8];let h;return e[9]!==n||e[10]!==m||e[11]!==f||e[12]!==d||e[13]!==b?(h=u("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":d,defaultValue:b,onBlur:m,onKeyDown:f,ref:r}),e[9]=n,e[10]=m,e[11]=f,e[12]=d,e[13]=b,e[14]=h):h=e[14],h},Ro=s=>{const e=L(70),{cell:n,edit:o,highlight:t,mask:i,refs:l}=s,r=n.column.id;let a,c,g,f;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==i||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){f=Symbol.for("react.early_return_sentinel");e:{c=n.getValue(),a=_e(n.row.original);const D=l.columns?.[r];if(i.enabled&&i.columns.has(r)){const _=`db-masked-${r}`,I=u(mt,{value:yn(c,r,i)});let R;e[12]!==_||e[13]!==I?(R=u("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:I}),e[12]=_,e[13]=I,e[14]=R):R=e[14],f=R;break e}if(D!==void 0&&(typeof c=="string"||typeof c=="number")&&String(c)!==""){const _=String(c),I=`${D}:${String(c)}`;let R;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==I||e[21]!==D?(R=u(ko,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:D},I),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=I,e[21]=D,e[22]=R):R=e[22],f=R;break e}if(a===null){let _;e[23]!==c?(_=u(mt,{value:c}),e[23]=c,e[24]=_):_=e[24];let I;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==c?(I=u(Dt,{column:r,onExpand:o.onExpandCell,value:c}),e[25]=r,e[26]=o.onExpandCell,e[27]=c,e[28]=I):I=e[28];let R;e[29]!==_||e[30]!==I?(R=T(Ue,{children:[_,I]}),e[29]=_,e[30]=I,e[31]=R):R=e[31],f=R;break e}g=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=i,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=c,e[10]=g,e[11]=f}else a=e[8],c=e[9],g=e[10],f=e[11];if(f!==Symbol.for("react.early_return_sentinel"))return f;const p=g,m=p===void 0?c:p.value;let d;e[32]!==r||e[33]!==o?(d=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=d):d=e[34];const b=d;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let D;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==c?(D=I=>{o.stage(a,r,zt(I,c)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=c,e[39]=D):D=e[39];let _;return e[40]!==r||e[41]!==m||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==D?(_=u(_o,{column:r,initial:m,onCancel:o.cancelEdit,onCommit:D,recordId:a}),e[40]=r,e[41]=m,e[42]=o.cancelEdit,e[43]=a,e[44]=D,e[45]=_):_=e[45],_}let v;p!==void 0?v="rounded bg-warning/15 px-1":b&&(v="cursor-text");let x;e[46]!==b||e[47]!==r||e[48]!==o||e[49]!==a?(x=b?()=>{o.startEdit(a,r)}:void 0,e[46]=b,e[47]=r,e[48]=o,e[49]=a,e[50]=x):x=e[50];const w=x,y=v,N=`db-cell-${a}-${r}`;let E;e[51]!==r||e[52]!==t||e[53]!==i?(E=ho(t,i,r),e[51]=r,e[52]=t,e[53]=i,e[54]=E):E=e[54];let S;e[55]!==m||e[56]!==E?(S=u(mt,{highlight:E,value:m}),e[55]=m,e[56]=E,e[57]=S):S=e[57];let C;e[58]!==v||e[59]!==w||e[60]!==N||e[61]!==S?(C=u("span",{className:y,"data-testid":N,onDoubleClick:w,children:S}),e[58]=v,e[59]=w,e[60]=N,e[61]=S,e[62]=C):C=e[62];let k;e[63]!==r||e[64]!==m||e[65]!==o.onExpandCell?(k=u(Dt,{column:r,onExpand:o.onExpandCell,value:m}),e[63]=r,e[64]=m,e[65]=o.onExpandCell,e[66]=k):k=e[66];let A;return e[67]!==k||e[68]!==C?(A=T(Ue,{children:[C,k]}),e[67]=k,e[68]=C,e[69]=A):A=e[69],A},$o=s=>{s.preventDefault()},It={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},Do=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:i,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const c=e.current,g=n.column.id;if(e.current=null,c===null||c===g)return;const f=l.getState().columnOrder,m=(f.length>0?f:l.getAllLeafColumns().map(b=>b.id)).filter(b=>b!==c),d=m.indexOf(g);m.splice(d===-1?m.length:d,0,c),l.setColumnOrder(m)};return T("th",{className:st("group/head text-start text-xs font-medium text-muted-foreground",i!==void 0&&"border-e border-border bg-muted"),draggable:!0,onDragOver:$o,onDragStart:r,onDrop:a,style:i===void 0?St(n.getSize()):Gt(n.getSize(),i),children:[T("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[In(n.column.columnDef.header,n.getContext()),To(n.column.getIsSorted())]}),s!==void 0&&It[s]!==void 0&&u("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:It[s]}),o&&u("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),u("button",{"aria-label":i===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":i!==void 0,className:st("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",i===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),u("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},Io=s=>{const e=L(13),{table:n}=s,o=ne();let t;e[0]!==n?(t=g=>{n.toggleAllRowsSelected(g)},e[0]=n,e[1]=t):t=e[1];const i=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let c;return e[8]!==i||e[9]!==l||e[10]!==r||e[11]!==a?(c=u("th",{className:"bg-muted",style:jt,children:u(yt,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:i})}),e[8]=i,e[9]=l,e[10]=r,e[11]=a,e[12]=c):c=e[12],c},Mo=s=>{const e=L(17),{row:n}=s,o=ne();let t;e[0]!==n.original?(t=_e(n.original),e[0]=n.original,e[1]=t):t=e[1];const i=t;let l;e[2]!==n?(l=d=>{n.toggleSelected(d)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let c;e[6]!==n?(c=n.getIsSelected(),e[6]=n,e[7]=c):c=e[7];let g;e[8]!==n.index||e[9]!==n.original?(g=qt(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=g):g=e[10];const f=`db-select-${g}`,p=i===null;let m;return e[11]!==r||e[12]!==a||e[13]!==c||e[14]!==f||e[15]!==p?(m=u("td",{className:"bg-background",style:jt,children:u(yt,{"aria-label":a,checked:c,"data-testid":f,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=c,e[14]=f,e[15]=p,e[16]=m):m=e[16],m},Ao=s=>{const e=L(91),{columnMeta:n,edit:o,editable:t,mask:i,onDelete:l,onEdit:r,onInspect:a,highlight:c,backRelationCounts:g,onTogglePin:f,pinnedColumns:p,refs:m,tableModel:d}=s,b=ne(),{attachScroll:h,scrollLeft:v,scrollToIndex:x,table:w,tableRows:y,tbodyStyle:N,viewportWidth:E,virtualRows:S}=d,C=Qe(null),[k,A]=$(null);let D;e[0]===Symbol.for("react.memo_cache_sentinel")?(D={columns:"",count:0},e[0]=D):D=e[0];const[_,I]=$(D);let R;e[1]!==w?(R=w.getVisibleLeafColumns(),e[1]=w,e[2]=R):R=e[2];const z=R.length;let F;e[3]!==k||e[4]!==z||e[5]!==o||e[6]!==w||e[7]!==y?(F=le=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(le.key))return;le.preventDefault();const K=k??{col:0,row:0};if(le.key==="Enter"){const B=y[K.row],pe=w.getVisibleLeafColumns()[K.col];if(B!==void 0&&pe!==void 0){const W=_e(B.original);W!==null&&o.editableColumn(pe.id)&&o.startEdit(W,pe.id)}A(K);return}let{col:Z,row:Q}=K;e:switch(le.key){case"ArrowDown":{Q=Math.min(Q+1,y.length-1);break e}case"ArrowRight":{Z=Math.min(Z+1,z-1);break e}case"ArrowUp":{Q=Math.max(Q-1,0);break e}default:Z=Math.max(Z-1,0)}A({col:Z,row:Q})},e[3]=k,e[4]=z,e[5]=o,e[6]=w,e[7]=y,e[8]=F):F=e[8];const j=F;let P;e[9]!==k||e[10]!==n||e[11]!==o||e[12]!==w||e[13]!==y?(P=le=>{const K=o.editable?le.clipboardData.getData("text/plain"):"";if(K==="")return;le.preventDefault();const Z=w.getVisibleLeafColumns().map(Fo),Q=Co({anchor:k??{col:0,row:0},columnIds:Z,columnMeta:n,editableColumn:o.editableColumn,rows:y.map(Lo),text:K});for(const B of Q.edits)o.stage(B.rowId,B.column,B.value);I({columns:Z.join("\0"),count:Q.skipped})},e[9]=k,e[10]=n,e[11]=o,e[12]=w,e[13]=y,e[14]=P):P=e[14];const J=P;let H,q;e[15]!==k||e[16]!==x?(H=()=>{k!==null&&x(k.row)},q=[k,x],e[15]=k,e[16]=x,e[17]=H,e[18]=q):(H=e[17],q=e[18]),Fe(H,q);let X,Ne,re,xe,ve,ke,ce,Te,de,ee,Ee,ue,fe,oe,me,U;if(e[19]!==k||e[20]!==h||e[21]!==g||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==c||e[26]!==i||e[27]!==l||e[28]!==r||e[29]!==j||e[30]!==J||e[31]!==a||e[32]!==f||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==m||e[37]!==v||e[38]!==b||e[39]!==w||e[40]!==y||e[41]!==N||e[42]!==E||e[43]!==S){const le=w.getVisibleLeafColumns().map(Vo),K=oo(le,p,v,E),Z=so(w.getVisibleLeafColumns().map(Bo),p),Q=W=>{const Ae=y[W.index],{original:Re}=Ae,$e=_e(Re),Pe=qt(Re,W.index),ze={...go,height:`${W.size.toString()}px`,transform:`translateY(${W.start.toString()}px)`};return T("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:ze,children:[u(Mo,{row:Ae}),K.leadPx>0&&u("td",{"aria-hidden":"true",style:{flex:`0 0 ${K.leadPx.toString()}px`}}),Ae.getVisibleCells().map((be,je)=>{if(!K.ids.has(be.column.id))return null;const Le=Z.get(be.column.id),Ke=k!==null&&k.row===W.index&&k.col===je?" ring-1 ring-ring ring-inset":"";return u("td",{className:st("group/cell truncate font-mono text-muted-foreground",Le!==void 0&&"border-e border-border bg-background",Ke),onPointerDown:()=>{A({col:je,row:W.index})},style:Le===void 0?St(be.column.getSize()):Gt(be.column.getSize(),Le),children:be.column.id.startsWith(vt)?u(vo,{counts:g[be.column.id.slice(vt.length)],rowId:Pe}):u(Ro,{cell:be,edit:o,highlight:c,mask:i,refs:m})},be.id)}),K.tailPx>0&&u("td",{"aria-hidden":"true",style:{flex:`0 0 ${K.tailPx.toString()}px`}}),T("td",{className:"flex items-center gap-1",style:$t,children:[u("button",{className:gt,"data-testid":`db-inspect-${Pe}`,onClick:()=>{a(Re)},type:"button",children:"Details"}),t&&T(Ue,{children:[u("button",{className:gt,"data-testid":`db-edit-${Pe}`,disabled:$e===null,onClick:()=>{r($e,Re)},type:"button",children:"Edit"}),u("button",{className:gt,"data-testid":`db-delete-${Pe}`,disabled:$e===null,onClick:()=>{l($e)},type:"button",children:"Delete"})]})]})]},Ae.id)};X=Pn,ue="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==b||e[63]!==w?(fe=_.count>0&&_.columns===w.getVisibleLeafColumns().map(zo).join("\0")&&u("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:b("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=b,e[63]=w,e[64]=fe):fe=e[64],ve="db-scroll",ke=j,ce=J,Te=h,de="grid",ee=uo,Ee=0,U="w-full text-xs",Ne="db-rows",re=fo;let B;e[65]!==w?(B=u(Io,{table:w}),e[65]=w,e[66]=B):B=e[66];let pe;e[67]===Symbol.for("react.memo_cache_sentinel")?(pe=u("th",{"aria-label":"Row actions",style:$t}),e[67]=pe):pe=e[67],xe=u("thead",{className:"bg-muted/50",children:T("tr",{className:"border-b border-border",style:po,children:[B,K.leadPx>0&&u("th",{"aria-hidden":"true",style:{flex:`0 0 ${K.leadPx.toString()}px`}}),w.getFlatHeaders().map(W=>K.ids.has(W.column.id)?u(Do,{declaredType:n?.[W.column.id]?.type,draggedRef:C,header:W,masked:i.columns.has(W.column.id),onTogglePin:f,pinnedOffset:Z.get(W.column.id),table:w},W.id):null),K.tailPx>0&&u("th",{"aria-hidden":"true",style:{flex:`0 0 ${K.tailPx.toString()}px`}}),pe]})}),oe=N,me=S.map(W=>Q(W)),e[19]=k,e[20]=h,e[21]=g,e[22]=n,e[23]=o,e[24]=t,e[25]=c,e[26]=i,e[27]=l,e[28]=r,e[29]=j,e[30]=J,e[31]=a,e[32]=f,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=m,e[37]=v,e[38]=b,e[39]=w,e[40]=y,e[41]=N,e[42]=E,e[43]=S,e[44]=X,e[45]=Ne,e[46]=re,e[47]=xe,e[48]=ve,e[49]=ke,e[50]=ce,e[51]=Te,e[52]=de,e[53]=ee,e[54]=Ee,e[55]=ue,e[56]=fe,e[57]=oe,e[58]=me,e[59]=U}else X=e[44],Ne=e[45],re=e[46],xe=e[47],ve=e[48],ke=e[49],ce=e[50],Te=e[51],de=e[52],ee=e[53],Ee=e[54],ue=e[55],fe=e[56],oe=e[57],me=e[58],U=e[59];let G;e[68]!==oe||e[69]!==me?(G=u("tbody",{style:oe,children:me}),e[68]=oe,e[69]=me,e[70]=G):G=e[70];let we;e[71]!==Ne||e[72]!==re||e[73]!==xe||e[74]!==G||e[75]!==U?(we=T("table",{className:U,"data-testid":Ne,style:re,children:[xe,G]}),e[71]=Ne,e[72]=re,e[73]=xe,e[74]=G,e[75]=U,e[76]=we):we=e[76];let se;e[77]!==ve||e[78]!==ke||e[79]!==ce||e[80]!==Te||e[81]!==de||e[82]!==ee||e[83]!==Ee||e[84]!==we?(se=u("div",{"data-testid":ve,onKeyDown:ke,onPaste:ce,ref:Te,role:de,style:ee,tabIndex:Ee,children:we}),e[77]=ve,e[78]=ke,e[79]=ce,e[80]=Te,e[81]=de,e[82]=ee,e[83]=Ee,e[84]=we,e[85]=se):se=e[85];let ge;return e[86]!==X||e[87]!==ue||e[88]!==fe||e[89]!==se?(ge=T(X,{layout:ue,children:[fe,se]}),e[86]=X,e[87]=ue,e[88]=fe,e[89]=se,e[90]=ge):ge=e[90],ge},Po=(s,e,n,o=[])=>{const t=s?.columns,i=s?.rows,l=s?.refs,r=ht(()=>{if(t===void 0)return[];const C=t.map(k=>({accessorFn:A=>A[k],header:l?.[k]===void 0?k:`${k} →`,id:k}));for(const k of o)C.push({accessorFn:()=>{},enableSorting:!1,header:`← ${k.table}`,id:xo(k)});return C},[o,t,l]),a=ht(()=>i??[],[i]),[c,g]=$({}),[f,p]=$({}),m=Rn({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:C=>_e(C.original)!==null,getCoreRowModel:Dn(),getRowId:(C,k)=>_e(C)??`row-${k.toString()}`,getSortedRowModel:$n(),manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:g,onSortingChange:n,state:{columnVisibility:f,rowSelection:c,sorting:e}}),d=m.getRowModel().rows,b=Qe(null),h=Mn({count:d.length,estimateSize:()=>co,getScrollElement:()=>b.current,initialRect:{height:Rt,width:0},observeElementRect:(C,k)=>An(C,k,Rt),overscan:8}),v=ot(C=>{h.scrollToIndex(C)},[h]),[x,w]=$({left:0,width:0}),y=ot(C=>{if(b.current=C,C===null)return;const k=()=>{w(D=>D.left===C.scrollLeft&&D.width===C.clientWidth?D:{left:C.scrollLeft,width:C.clientWidth})};C.addEventListener("scroll",k,{passive:!0});const A=new ResizeObserver(k);return A.observe(C),()=>{C.removeEventListener("scroll",k),A.disconnect(),b.current=null}},[]),N=h.getVirtualItems(),S={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:y,scrollLeft:x.left,scrollToIndex:v,table:m,tableRows:d,tbodyStyle:S,viewportWidth:x.width,virtualRows:N}};function Oo(s){const[e,n]=s;return T("div",{className:"contents",children:[u("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),u("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Be(n),children:Be(n)})]},e)}function Fo(s){return s.id}function Lo(s){return s.original}function Vo(s){return{getSize:()=>s.getSize(),id:s.id}}function Bo(s){return{getSize:()=>s.getSize(),id:s.id}}function zo(s){return s.id}const jo=s=>{const e=L(22),{onCommit:n}=s,o=ne(),[t,i]=$(""),l=Qe(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),Fe(r,a);let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=w=>{i(w.target.value)},e[2]=c):c=e[2];const g=c;let f;e[3]!==t||e[4]!==n?(f=()=>{const w=t.trim();w!==""&&n(w)},e[3]=t,e[4]=n,e[5]=f):f=e[5];const p=f;let m;e[6]!==o?(m=o("Query name"),e[6]=o,e[7]=m):m=e[7];let d;e[8]!==o?(d=o("Query name"),e[8]=o,e[9]=d):d=e[9];let b;e[10]!==t||e[11]!==m||e[12]!==d?(b=u("input",{"aria-label":m,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:g,placeholder:d,ref:l,value:t}),e[10]=t,e[11]=m,e[12]=d,e[13]=b):b=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==p||e[17]!==h?(v=u("button",{className:xt,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=v):v=e[18];let x;return e[19]!==b||e[20]!==v?(x=T("span",{className:"inline-flex items-center gap-1",children:[b,v]}),e[19]=b,e[20]=v,e[21]=x):x=e[21],x},Go=s=>{const e=L(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:i,saved:l}=s,r=ne(),[a,c]=$(!1);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{c(!0)},e[0]=g):g=e[0];const f=g;let p;e[1]!==i?(p=S=>{i(S),c(!1)},e[1]=i,e[2]=p):p=e[2];const m=p;let d;e[3]!==n||e[4]!==l?(d=S=>{const C=l[Number(S.currentTarget.dataset.index)];C!==void 0&&n(C)},e[3]=n,e[4]=l,e[5]=d):d=e[5];const b=d;let h;e[6]!==t||e[7]!==l?(h=S=>{const C=l[Number(S.currentTarget.dataset.index)];C!==void 0&&t(C.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const v=h;let x;e[9]!==r?(x=r("Copy link"),e[9]=r,e[10]=x):x=e[10];let w;e[11]!==o||e[12]!==x?(w=u("button",{className:xt,"data-testid":"db-copy-link",onClick:o,type:"button",children:x}),e[11]=o,e[12]=x,e[13]=w):w=e[13];let y;e[14]!==m||e[15]!==a||e[16]!==r?(y=a?u(jo,{onCommit:m}):u("button",{className:xt,"data-testid":"db-save-query",onClick:f,type:"button",children:r("Save query")}),e[14]=m,e[15]=a,e[16]=r,e[17]=y):y=e[17];let N;e[18]!==b||e[19]!==v||e[20]!==l||e[21]!==r?(N=l.length>0&&T("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[u("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((S,C)=>T("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[u("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":C,"data-testid":`db-saved-query-${S.name}`,onClick:b,type:"button",children:S.name}),u("button",{"aria-label":r("Delete saved query {name}",{name:S.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":C,"data-testid":`db-saved-query-delete-${S.name}`,onClick:v,type:"button",children:"✕"})]},S.name))]}),e[18]=b,e[19]=v,e[20]=l,e[21]=r,e[22]=N):N=e[22];let E;return e[23]!==w||e[24]!==y||e[25]!==N?(E=T("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[w,y,N]}),e[23]=w,e[24]=y,e[25]=N,e[26]=E):E=e[26],E},Je="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",Jt=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Mt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?Jt.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",qo=(s,e,n)=>n===void 0?Mt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?Jt.test(s)?"date":"number":Mt(s,e),Jo=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},Ko=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},qe="\0clear",Wo=s=>{const e=L(23),{column:n,nullable:o,onChange:t,value:i}=s,l=ne();let r;e[0]!==n||e[1]!==t?(r=x=>{t(n,x)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let c;e[3]!==n||e[4]!==t?(c=x=>{t(n,x.target.value===qe?null:x.target.value==="true")},e[3]=n,e[4]=t,e[5]=c):c=e[5];const g=c;if(!o&&i!==null){const x=i===!0,w=`db-field-${n}`;let y;return e[6]!==n||e[7]!==a||e[8]!==x||e[9]!==w?(y=u(yt,{"aria-label":n,checked:x,"data-testid":w,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=x,e[9]=w,e[10]=y):y=e[10],y}const f=`db-field-${n}`,p=i===!0||i===!1?String(i):qe;let m;e[11]!==l?(m=l("(none)"),e[11]=l,e[12]=m):m=e[12];let d;e[13]!==m?(d=u("option",{value:qe,children:m}),e[13]=m,e[14]=d):d=e[14];let b,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=u("option",{value:"true",children:"true"}),h=u("option",{value:"false",children:"false"}),e[15]=b,e[16]=h):(b=e[15],h=e[16]);let v;return e[17]!==n||e[18]!==g||e[19]!==f||e[20]!==p||e[21]!==d?(v=T("select",{"aria-label":n,className:Je,"data-testid":f,onChange:g,value:p,children:[d,b,h]}),e[17]=n,e[18]=g,e[19]=f,e[20]=p,e[21]=d,e[22]=v):v=e[22],v},Ho=s=>{const e=L(23),{column:n,nullable:o,onChange:t,options:i,value:l}=s,r=ne(),a=typeof l=="string"?l:null;let c;e[0]!==i||e[1]!==a?(c=a!==null&&!i.includes(a),e[0]=i,e[1]=a,e[2]=c):c=e[2];const g=c;let f;e[3]!==n||e[4]!==t?(f=w=>{t(n,w.target.value===qe?null:w.target.value)},e[3]=n,e[4]=t,e[5]=f):f=e[5];const p=f,m=`db-field-${n}`,d=a??qe;let b;e[6]!==o||e[7]!==a||e[8]!==r?(b=(o||a===null)&&u("option",{value:qe,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=b):b=e[9];let h;e[10]!==a||e[11]!==g?(h=g&&u("option",{value:a,children:a}),e[10]=a,e[11]=g,e[12]=h):h=e[12];let v;e[13]!==i?(v=i.map(ts),e[13]=i,e[14]=v):v=e[14];let x;return e[15]!==n||e[16]!==p||e[17]!==m||e[18]!==d||e[19]!==b||e[20]!==h||e[21]!==v?(x=T("select",{"aria-label":n,className:Je,"data-testid":m,onChange:p,value:d,children:[b,h,v]}),e[15]=n,e[16]=p,e[17]=m,e[18]=d,e[19]=b,e[20]=h,e[21]=v,e[22]=x):x=e[22],x},Uo=s=>{const e=L(8),{column:n,onChange:o,value:t}=s;let i;e[0]!==n||e[1]!==o?(i=g=>{const f=Number(g.target.value);g.target.value!==""&&!Number.isNaN(f)&&o(n,f)},e[0]=n,e[1]=o,e[2]=i):i=e[2];const l=i,r=`db-field-${n}`,a=typeof t=="number"?t:"";let c;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(c=u("input",{"aria-label":n,className:Je,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=c):c=e[7],c},Qo=s=>{const e=L(10),{column:n,onChange:o,value:t}=s;let i;e[0]!==n||e[1]!==o?(i=g=>{const f=new Date(g.target.value).getTime();Number.isNaN(f)||o(n,f)},e[0]=n,e[1]=o,e[2]=i):i=e[2];const l=i,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?Ko(t):"",e[3]=t,e[4]=a):a=e[4];let c;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(c=u("input",{"aria-label":n,className:Je,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=c):c=e[9],c},Yo=s=>{const e=L(8),{column:n,onChange:o,value:t}=s;let i;e[0]!==n||e[1]!==o?(i=g=>{o(n,g.target.value)},e[0]=n,e[1]=o,e[2]=i):i=e[2];const l=i,r=`db-field-${n}`,a=typeof t=="string"?t:"";let c;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(c=u("input",{"aria-label":n,className:Je,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=c):c=e[7],c},Xo=s=>{const e=L(20),{column:n,onChange:o,value:t}=s,i=ne();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=$(l),[c,g]=$(!1);let f;e[2]!==n||e[3]!==o?(f=w=>{const y=w.target.value;a(y);try{o(n,JSON.parse(y)),g(!1)}catch{g(!0)}},e[2]=n,e[3]=o,e[4]=f):f=e[4];const p=f,m=c&&"border-destructive";let d;e[5]!==m?(d=st(Je,"min-h-16",m),e[5]=m,e[6]=d):d=e[6];const b=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==d||e[10]!==b||e[11]!==r?(h=u("textarea",{"aria-label":n,className:d,"data-testid":b,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=d,e[10]=b,e[11]=r,e[12]=h):h=e[12];let v;e[13]!==n||e[14]!==c||e[15]!==i?(v=c&&u("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:i("Invalid JSON")}),e[13]=n,e[14]=c,e[15]=i,e[16]=v):v=e[16];let x;return e[17]!==h||e[18]!==v?(x=T("div",{className:"flex flex-col gap-1",children:[h,v]}),e[17]=h,e[18]=v,e[19]=x):x=e[19],x},Zo=s=>{const e=L(56),{column:n,meta:o,onChange:t,target:i,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=qo(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,c=`db-field-${n}`;let g;e[4]!==n?(g=u("span",{className:"font-mono",children:n}),e[4]=n,e[5]=g):g=e[5];let f;e[6]!==n||e[7]!==o?(f=o!==void 0&&u("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=f):f=e[8];let p;e[9]!==i?(p=i!==void 0&&T("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",i]}),e[9]=i,e[10]=p):p=e[10];let m;e[11]!==g||e[12]!==f||e[13]!==p?(m=T("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[g,f,p]}),e[11]=g,e[12]=f,e[13]=p,e[14]=m):m=e[14];let d;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(d=a==="boolean"&&u(Wo,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=d):d=e[20];let b;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(b=a==="enum"&&o?.enumValues!==void 0&&u(Ho,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=b):b=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&u(Uo,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let v;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(v=a==="date"&&u(Qo,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=v):v=e[36];let x;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(x=a==="json"&&u(Xo,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=x):x=e[41];let w;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(w=a==="text"&&u(Yo,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=w):w=e[46];let y;return e[47]!==v||e[48]!==x||e[49]!==w||e[50]!==c||e[51]!==m||e[52]!==d||e[53]!==b||e[54]!==h?(y=T("label",{className:"flex flex-col gap-1 text-xs",htmlFor:c,children:[m,d,b,h,v,x,w]}),e[47]=v,e[48]=x,e[49]=w,e[50]=c,e[51]=m,e[52]=d,e[53]=b,e[54]=h,e[55]=y):y=e[55],y},es=s=>{const e=L(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:i,onSave:l,refs:r}=s,a=ne();let c;e[0]!==o?(c=Jo(o),e[0]=o,e[1]=c):c=e[1];const g=c,[f,p]=$(!1),m=!f&&g!==null;let d;e[2]!==g||e[3]!==i?(d=(H,q)=>{i(JSON.stringify({...g,[H]:q},null,2))},e[2]=g,e[3]=i,e[4]=d):d=e[4];const b=d;let h;e[5]!==i?(h=H=>{i(H.target.value)},e[5]=i,e[6]=h):h=e[6];const v=h;let x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{p(!1)},e[7]=x):x=e[7];const w=x;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{p(!0)},e[8]=y):y=e[8];const N=y,E=g===null;let S;e[9]!==a?(S=a("Form"),e[9]=a,e[10]=S):S=e[10];let C;e[11]!==m||e[12]!==E||e[13]!==S?(C=u("button",{"aria-pressed":m,className:Me,"data-testid":"db-editor-form",disabled:E,onClick:w,type:"button",children:S}),e[11]=m,e[12]=E,e[13]=S,e[14]=C):C=e[14];const k=!m;let A;e[15]!==a?(A=a("JSON"),e[15]=a,e[16]=A):A=e[16];let D;e[17]!==A||e[18]!==k?(D=u("button",{"aria-pressed":k,className:Me,"data-testid":"db-editor-json",onClick:N,type:"button",children:A}),e[17]=A,e[18]=k,e[19]=D):D=e[19];let _;e[20]!==D||e[21]!==C?(_=T("div",{className:"flex items-center gap-1.5",children:[C,D]}),e[20]=D,e[21]=C,e[22]=_):_=e[22];let I;e[23]!==n||e[24]!==o||e[25]!==g||e[26]!==b||e[27]!==v||e[28]!==r||e[29]!==m||e[30]!==a?(I=m?u("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(g).map(H=>{const[q,X]=H;return u(Zo,{column:q,meta:n?.[q],onChange:b,target:r?.[q],value:X},q)})}):u("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:v,value:o}),e[23]=n,e[24]=o,e[25]=g,e[26]=b,e[27]=v,e[28]=r,e[29]=m,e[30]=a,e[31]=I):I=e[31];let R;e[32]!==a?(R=a("Save"),e[32]=a,e[33]=R):R=e[33];let z;e[34]!==l||e[35]!==R?(z=u("button",{className:Me,"data-testid":"db-editor-save",onClick:l,type:"button",children:R}),e[34]=l,e[35]=R,e[36]=z):z=e[36];let F;e[37]!==a?(F=a("Cancel"),e[37]=a,e[38]=F):F=e[38];let j;e[39]!==t||e[40]!==F?(j=u("button",{className:Me,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:F}),e[39]=t,e[40]=F,e[41]=j):j=e[41];let P;e[42]!==z||e[43]!==j?(P=T("div",{className:"flex items-center gap-1.5",children:[z,j]}),e[42]=z,e[43]=j,e[44]=P):P=e[44];let J;return e[45]!==_||e[46]!==I||e[47]!==P?(J=T("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,I,P]}),e[45]=_,e[46]=I,e[47]=P,e[48]=J):J=e[48],J};function ts(s){return u("option",{value:s,children:s},s)}const ns=s=>{const e=L(61),{columns:n,editable:o,filter:t,filters:i,hasMaskedColumns:l,liveError:r,maskOn:a,onAddRow:c,onBulkDelete:g,onAskAiFilter:f,onClearTable:p,onFilterChange:m,onFiltersChange:d,onGenerateRows:b,onShowJson:h,onShowTable:v,onToggleMask:x,total:w,viewMode:y}=s,N=ne(),E=y==="table";let S;e[0]!==v||e[1]!==E?(S=u("button",{"aria-pressed":E,className:Me,"data-testid":"db-view-table",onClick:v,type:"button",children:"Table"}),e[0]=v,e[1]=E,e[2]=S):S=e[2];const C=y==="json";let k;e[3]!==h||e[4]!==C?(k=u("button",{"aria-pressed":C,className:Me,"data-testid":"db-view-json",onClick:h,type:"button",children:"JSON"}),e[3]=h,e[4]=C,e[5]=k):k=e[5];let A;e[6]!==r||e[7]!==N?(A=r===void 0?N("Live — changes stream in automatically"):N("Live unavailable: {liveError}",{liveError:r}),e[6]=r,e[7]=N,e[8]=A):A=e[8];const D=`size-1.5 rounded-full ${r===void 0?"bg-success":"bg-muted-foreground/50"}`;let _;e[9]!==D?(_=u("span",{"aria-hidden":"true",className:D}),e[9]=D,e[10]=_):_=e[10];let I;e[11]!==r||e[12]!==N?(I=N(r===void 0?"Live":"Live unavailable"),e[11]=r,e[12]=N,e[13]=I):I=e[13];let R;e[14]!==A||e[15]!==_||e[16]!==I?(R=T("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:A,children:[_,I]}),e[14]=A,e[15]=_,e[16]=I,e[17]=R):R=e[17];let z;e[18]!==l||e[19]!==a||e[20]!==x||e[21]!==N?(z=l&&u("button",{"aria-pressed":a,className:Me,"data-testid":"db-mask-toggle",onClick:x,type:"button",children:N("Mask sensitive columns")}),e[18]=l,e[19]=a,e[20]=x,e[21]=N,e[22]=z):z=e[22];let F;e[23]!==o||e[24]!==c?(F=o&&u("button",{className:Me,"data-testid":"db-add-row",onClick:c,type:"button",children:"Add row"}),e[23]=o,e[24]=c,e[25]=F):F=e[25];let j;e[26]!==o||e[27]!==b||e[28]!==N?(j=o&&u("button",{className:Me,"data-testid":"db-generate-rows",onClick:b,type:"button",children:N("Generate rows")}),e[26]=o,e[27]=b,e[28]=N,e[29]=j):j=e[29];let P;e[30]!==o||e[31]!==t||e[32]!==i||e[33]!==g||e[34]!==w?(P=o&&w>0&&(t!==""||i.length>0)&&u(kt,{confirmLabel:`Delete ${w.toString()} matching?`,onConfirm:g,testId:"db-bulk-delete",children:`Delete ${w.toString()} matching`}),e[30]=o,e[31]=t,e[32]=i,e[33]=g,e[34]=w,e[35]=P):P=e[35];let J;e[36]!==o||e[37]!==t||e[38]!==i||e[39]!==p||e[40]!==w?(J=o&&w>0&&t===""&&i.length===0&&u(kt,{confirmLabel:`Clear all ${w.toString()} rows?`,onConfirm:p,testId:"db-clear-table",children:`Clear table (${w.toString()})`}),e[36]=o,e[37]=t,e[38]=i,e[39]=p,e[40]=w,e[41]=J):J=e[41];let H;e[42]!==z||e[43]!==F||e[44]!==j||e[45]!==P||e[46]!==J||e[47]!==S||e[48]!==k||e[49]!==R?(H=T("div",{className:"flex flex-wrap items-center gap-1.5",children:[S,k,R,z,F,j,P,J]}),e[42]=z,e[43]=F,e[44]=j,e[45]=P,e[46]=J,e[47]=S,e[48]=k,e[49]=R,e[50]=H):H=e[50];let q;e[51]!==n||e[52]!==t||e[53]!==i||e[54]!==f||e[55]!==m||e[56]!==d?(q=u(Fn,{columns:n,filters:i,onAskAi:f,onFiltersChange:d,onSearchChange:m,search:t}),e[51]=n,e[52]=t,e[53]=i,e[54]=f,e[55]=m,e[56]=d,e[57]=q):q=e[57];let X;return e[58]!==H||e[59]!==q?(X=T("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[H,q]}),e[58]=H,e[59]=q,e[60]=X):X=e[60],X},os=s=>{const e=L(104),{assistant:n,backRelations:o,browser:t,columnMeta:i,edit:l,editable:r,onAskAiFilter:a,onInspect:c,onOpenGenerateRows:g,onRowDelete:f,onSaveQuery:p,page:m,preferences:d,queryBar:b,references:h}=s,v=d.maskColumns.size>0,x=n.unavailable?void 0:a;let w;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.liveError||e[7]!==t.onFilterChange||e[8]!==t.onFiltersChange||e[9]!==t.showJson||e[10]!==t.showTable||e[11]!==t.total||e[12]!==t.viewMode||e[13]!==r||e[14]!==g||e[15]!==d.maskOn||e[16]!==d.onToggleMask||e[17]!==v||e[18]!==x?(w=u(ns,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,liveError:t.liveError,maskOn:d.maskOn,onAddRow:t.addRow,onAskAiFilter:x,onBulkDelete:t.bulkDelete,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:g,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:d.onToggleMask,total:t.total,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.liveError,e[7]=t.onFilterChange,e[8]=t.onFiltersChange,e[9]=t.showJson,e[10]=t.showTable,e[11]=t.total,e[12]=t.viewMode,e[13]=r,e[14]=g,e[15]=d.maskOn,e[16]=d.onToggleMask,e[17]=v,e[18]=x,e[19]=w):w=e[19];let y;e[20]!==p||e[21]!==b?(y=b!==void 0&&u(Go,{onApply:b.onApplyQuery,onCopyLink:b.onCopyLink,onDelete:b.onDeleteQuery,onSave:p,saved:b.saved}),e[20]=p,e[21]=b,e[22]=y):y=e[22];let N;e[23]!==o||e[24]!==t.onBulkDeleteSelected||e[25]!==t.selectedTable||e[26]!==t.table||e[27]!==t.viewMode||e[28]!==r||e[29]!==m||e[30]!==d.maskView||e[31]!==d.onToggleTranspose||e[32]!==d.transposed?(N=t.viewMode==="table"&&m.rows.length>0&&u(Ln,{backRelations:o.available,columns:m.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:d.onToggleTranspose,rows:ut(m.rows,d.maskView),table:t.table.table,transposed:d.transposed}),e[23]=o,e[24]=t.onBulkDeleteSelected,e[25]=t.selectedTable,e[26]=t.table,e[27]=t.viewMode,e[28]=r,e[29]=m,e[30]=d.maskView,e[31]=d.onToggleTranspose,e[32]=d.transposed,e[33]=N):N=e[33];let E;e[34]!==t.cancelEdit||e[35]!==t.editing||e[36]!==t.saveEdit||e[37]!==t.setEditorDocumentText||e[38]!==i||e[39]!==r||e[40]!==m?(E=r&&t.editing!==null&&u(es,{columnMeta:i,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:m.refs}),e[34]=t.cancelEdit,e[35]=t.editing,e[36]=t.saveEdit,e[37]=t.setEditorDocumentText,e[38]=i,e[39]=r,e[40]=m,e[41]=E):E=e[41];let S;e[42]!==t.committing||e[43]!==t.discardStaged||e[44]!==t.onCommitStaged||e[45]!==t.stagedChanges||e[46]!==r?(S=r&&t.stagedChanges.length>0&&u(ro,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[42]=t.committing,e[43]=t.discardStaged,e[44]=t.onCommitStaged,e[45]=t.stagedChanges,e[46]=r,e[47]=S):S=e[47];let C;e[48]!==t.writeError?(C=t.writeError!==null&&u("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[48]=t.writeError,e[49]=C):C=e[49];let k;e[50]!==w||e[51]!==y||e[52]!==N||e[53]!==E||e[54]!==S||e[55]!==C?(k=T("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[w,y,N,E,S,C]}),e[50]=w,e[51]=y,e[52]=N,e[53]=E,e[54]=S,e[55]=C,e[56]=k):k=e[56];let A;e[57]!==t.viewMode||e[58]!==m?(A=t.viewMode==="table"&&m.rows.length===0&&u("div",{className:"flex flex-1 items-center justify-center p-6",children:u(_n,{description:"Rows you insert into this table will show up here.",icon:u("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[57]=t.viewMode,e[58]=m,e[59]=A):A=e[59];let D;e[60]!==t.viewMode||e[61]!==m||e[62]!==d.maskView||e[63]!==d.transposed?(D=t.viewMode==="table"&&m.rows.length>0&&d.transposed&&u(On,{columns:m.columns,rows:ut(m.rows,d.maskView)}),e[60]=t.viewMode,e[61]=m,e[62]=d.maskView,e[63]=d.transposed,e[64]=D):D=e[64];let _;e[65]!==o||e[66]!==t.filter||e[67]!==t.onRowEdit||e[68]!==t.table||e[69]!==t.viewMode||e[70]!==i||e[71]!==l||e[72]!==r||e[73]!==c||e[74]!==f||e[75]!==m||e[76]!==d.maskView||e[77]!==d.onTogglePin||e[78]!==d.pinnedColumns||e[79]!==d.transposed||e[80]!==h?(_=t.viewMode==="table"&&m.rows.length>0&&!d.transposed&&u(Ao,{backRelationCounts:o.counts,columnMeta:i,edit:l,editable:r,highlight:t.filter,mask:d.maskView,onDelete:f,onEdit:t.onRowEdit,onInspect:c,onTogglePin:d.onTogglePin,pinnedColumns:d.pinnedColumns,refs:h,tableModel:t.table}),e[65]=o,e[66]=t.filter,e[67]=t.onRowEdit,e[68]=t.table,e[69]=t.viewMode,e[70]=i,e[71]=l,e[72]=r,e[73]=c,e[74]=f,e[75]=m,e[76]=d.maskView,e[77]=d.onTogglePin,e[78]=d.pinnedColumns,e[79]=d.transposed,e[80]=h,e[81]=_):_=e[81];let I;e[82]!==t.viewMode||e[83]!==m||e[84]!==d.maskView?(I=t.viewMode==="json"&&u("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(ut(m.rows,d.maskView),vn,2)}),e[82]=t.viewMode,e[83]=m,e[84]=d.maskView,e[85]=I):I=e[85];let R;e[86]!==t.changePageSize||e[87]!==t.goNext||e[88]!==t.goPrevious||e[89]!==t.hasNext||e[90]!==t.hasPrevious||e[91]!==t.jumpToPage||e[92]!==t.pageSize||e[93]!==t.rangeEnd||e[94]!==t.rangeStart||e[95]!==t.total?(R=u("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:u(Cn,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[86]=t.changePageSize,e[87]=t.goNext,e[88]=t.goPrevious,e[89]=t.hasNext,e[90]=t.hasPrevious,e[91]=t.jumpToPage,e[92]=t.pageSize,e[93]=t.rangeEnd,e[94]=t.rangeStart,e[95]=t.total,e[96]=R):R=e[96];let z;return e[97]!==A||e[98]!==D||e[99]!==_||e[100]!==I||e[101]!==R||e[102]!==k?(z=T("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[k,A,D,_,I,R]}),e[97]=A,e[98]=D,e[99]=_,e[100]=I,e[101]=R,e[102]=k,e[103]=z):z=e[103],z},ss="/__lunora/seed",pt=200,ls=50,rs=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},as=async s=>{const e=await fetch(ss,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json();return e.ok&&n.rows!==void 0?{kind:"ok",rows:n.rows}:{kind:"error",message:n.error??`seed request failed (${String(e.status)})`}},is="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",cs="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",ds=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const i=ne(),[l,r]=$(10),[a,c]=$(!1),[g,f]=$(void 0),[p,m]=$(void 0),[d,b]=$(0),h=y=>{const N=Number(y.target.value);!Number.isNaN(N)&&N>=1&&r(Math.min(N,pt))},v=async()=>{f(void 0),m(void 0),b(0),c(!0);try{const y=await as({count:l,existingIds:e,seed:Date.now(),table:t});if(y.kind==="error"){f(y.message);return}const{rows:N}=y;if(N.length===0){f(i("No rows generated — all columns were skipped."));return}const E=await o(N);if(E.error!==void 0){f(E.error);return}m(E.inserted),b(E.conflicts);const S=rs(s,e);S.length>0&&f(i("Inserted {count} rows. Skipped FK columns: {cols}",{cols:S.join(", "),count:E.inserted.toString()}))}finally{c(!1)}},x=()=>{ie(v())},w=s.filter(y=>y.pk!==!0);return T(wt,{label:i("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[T("div",{className:"flex items-start justify-between",children:[T("div",{className:"flex flex-col gap-0.5",children:[u("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:i("Generate dummy rows")}),u("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:i("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),u("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:i("Close")})]}),T("div",{className:"flex items-center gap-2",children:[u("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:i("Row count")}),u("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:pt,min:1,onChange:h,type:"number",value:l}),u("span",{className:"text-xs text-muted-foreground",children:i("(max {max})",{max:pt.toString()})})]}),w.length>0&&T("div",{className:"flex flex-col gap-1",children:[u("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:i("Columns to seed")}),u("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:w.map(y=>{const N=y.ref!==void 0&&y.type==="id",E=N&&(e[y.ref??""]??[]).length===0,S=E?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",C=E?`gen-rows-fk-empty-${y.name}`:`gen-rows-fk-ok-${y.name}`,k=E?i("FK: no rows in {ref} — will skip",{ref:y.ref??""}):i("→ {ref}",{ref:y.ref??""});return T("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[u("span",{className:"text-foreground",children:y.name}),T("span",{className:"text-muted-foreground",children:["(",y.type,")"]}),y.optional&&u("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),N&&u("span",{className:S,"data-testid":C,children:k})]},y.name)})})]}),g!==void 0&&u("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:g}),p!==void 0&&g===void 0&&u("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:d>0?i("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:d.toString(),inserted:p.toString(),total:(p+d).toString()}):i("Inserted {count} rows successfully.",{count:p.toString()})}),T("div",{className:"flex justify-end gap-2",children:[u("button",{className:is,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:i("Cancel")}),u("button",{className:cs,"data-testid":"gen-rows-generate",disabled:a,onClick:x,type:"button",children:i(a?"Inserting…":"Generate & insert")})]})]})},us=Se(te.backRelationCounts),fs=(s,e,n,o)=>{const t=L(16),i=lt();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=$(l);let c;if(t[1]!==s||t[2]!==e){let v;t[4]!==s?(v=x=>s.has(Ct(x)),t[4]=s,t[5]=v):v=t[5],c=e.filter(v),t[1]=s,t[2]=e,t[3]=c}else c=t[3];const g=c;let f;t[6]!==n||t[7]!==g?(f=JSON.stringify([g,n]),t[6]=n,t[7]=g,t[8]=f):f=t[8];const p=f;let m;t[9]!==i||t[10]!==o||t[11]!==p?(m=async v=>{const[x,w]=JSON.parse(p);if(x.length===0||w.length===0){v.cancelled||a({});return}try{const y=await i.query(us,{ids:w,relations:x},he(o));v.cancelled||a(Object.fromEntries(y.relations.map(ms)))}catch{}},t[9]=i,t[10]=o,t[11]=p,t[12]=m):m=t[12];const d=m;let b,h;return t[13]!==d?(b=()=>{const v={cancelled:!1};return ie(d(v)),()=>{v.cancelled=!0}},h=[d],t[13]=d,t[14]=b,t[15]=h):(b=t[14],h=t[15]),Fe(b,h),r};function ms(s){return[Ct(s),s.counts]}const nt=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},Kt=s=>s==null?"":typeof s=="object"?JSON.stringify(s):String(s),At=s=>s.map(e=>({column:e.column,operator:e.operator,value:e.value===void 0?"":Kt(e.value)})),Pt=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],gs=s=>[s.column,s.operator,s.value],Ze=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>gs(t)),o===void 0?null:[o.column,o.direction]]),Ot=200,ps=20,bs=Se(te.readTablePage),hs=Se(te.facetColumn),bt=Se(te.writeRow),xs=Se(te.deleteRows),vs=Se(te.clearTable),ws={},Nt=new Set(["__doc__","__id__","_creationTime","_id","id"]),ys=s=>{const e=s.__doc__;if(typeof e=="string"){const o=Gn(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Nt.has(o)||(n[o]=t);return n},Cs=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:i})=>({filters:Ve(s),limit:n,offset:e,orderBy:nt(t),search:o,skipCount:!0,table:i}),Ss=({filters:s,search:e,table:n})=>({filters:Ve(s),limit:1,search:e,table:n}),Ns=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const i=_e(t);i!==null&&n.set(i,t)}const o=[];for(const[t,i]of Object.entries(e))for(const[l,r]of Object.entries(i))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},ks=s=>!Nt.has(s),Ts=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:i,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const c=lt(),[g,f]=$(l),[p,m]=$(o??""),d=a===void 0||a===""?null:a,[b,h]=$(0),[v,x]=$("table"),[w,y]=$(()=>Pt(e)),[N,E]=$(n??""),[S,C]=$(()=>At(s??[])),{clearFacets:k,facets:A,refetchFacets:D,toggleFacet:_}=Sn(),[I,R]=$(null),[z,F]=$(null),j=lo(),[P,J]=$(null),[H,q]=$(!1),[X,Ne]=$(a),[re,xe]=$(()=>Ze(o,n,s,e)),[ve,ke]=$(0),[ce,Te]=$(()=>Ze(o,n,s,e)),de=a!==X,ee=Ze(o,n,s,e),ue=de||!de&&ee!==re&&ee!==ce;if(ue){Ne(a),xe(ee),ke(V=>V+1),y(Pt(e)),E(n??"");const M=At(s??[]);C(M),m(o??""),k(),j.clear(),J(null),h(0)}else ee!==re&&xe(ee);const fe=ue?n??"":N,oe=ue?o??"":p,me=`${a??""}:${ve.toString()}`,U=Tt(fe.trim(),300,me),G=Tt(oe.trim(),400,me),we=Ze(G,U,Ve(S),nt(w));we!==ce&&Te(we);const se=et(te.listTables,ws,{live:!0,shardKey:G}),ge=se.data??null,le=se.error,K=Cs({filters:S,offset:b,pageSize:g,search:U,sorting:w,table:d??""}),Z=Ss({filters:S,search:U,table:d??""}),Q=et(te.readTablePage,K,{enabled:d!==null,keepPreviousData:!1,live:!0,shardKey:G}),B=Q.data??null,pe=Q.error,{liveError:W}=Q,Ae=et(te.readTablePage,Z,{enabled:d!==null,live:!0,shardKey:G});Fe(()=>{se.data!==void 0&&qn(G)},[se.data,G]);const Re=M=>{t?.(M)},$e=(M,V)=>{t?.(M,{search:V})},Pe=async(M,V)=>{try{return(await c.query(bs,{filters:[],limit:ps,offset:0,search:V,table:M},he(G))).rows.find(Ce=>_e(Ce)===V)??null}catch{return null}},ze=(M,V,ae,Ce)=>Ie=>c.query(hs,{column:Ie,filters:Ve(ae),search:Ce,table:V},he(M)),be=M=>{_(M,d===null?null:ze(G,d,S,U))},je=(M,V)=>{const ae=Kt(V);C(Ce=>[...Ce.filter(Ie=>Ie.column!==M),{column:M,operator:"eq",value:ae}]),h(0)},Le=ft(ze),Ke=ft(D),We=ft(i);Fe(()=>{d!==null&&Ke.current(Le.current(G,d,S,U))},[G,d,S,U]),Fe(()=>{d===null||We.current===void 0||X!==a||re!==ee||We.current({filters:Ve(S),orderBy:nt(w),search:U,shard:G})},[d,a,X,re,ee,S,w,U,G]);const He=M=>{d!==null&&h(Math.max(0,M))},rt=(M,V)=>{J({column:V,rowId:M})},at=()=>{J(null)},it=async()=>{if(d!==null){F(null),q(!0);try{for(const[M,V]of Object.entries(j.staged))await c.query(bt,{doc:V,id:M,op:"patch",table:d},he(G));j.clear(),J(null),Q.refetch()}catch(M){F(M.message)}q(!1)}},ct=()=>{j.clear(),J(null)},dt=Ns(B,j.staged),Ye=async(M,V,ae)=>{if(d===null)return;F(null);let Ce;if(M!=="delete"){let Ie;try{Ie=ae===void 0||ae.trim()===""?{}:JSON.parse(ae)}catch(Ge){F(`Invalid JSON: ${Ge.message}`);return}try{const Ge=zn(Ie);if(!jn(Ge)){F("The document must be a JSON object.");return}Ce=Ge}catch(Ge){F(`Invalid document: ${Ge.message}`);return}}try{await c.query(bt,{doc:Ce,id:V??void 0,op:M,table:d},he(G)),R(null),Q.refetch()}catch(Ie){F(Ie.message)}},O=async(M,V)=>{if(d!==null){F(null);try{let ae="cap-hit";for(let Ce=0;Ce<Ot;Ce+=1)if(!(await c.query(M,V,he(G))).hasMore){ae="completed";break}h(0),Q.refetch(),ae==="cap-hit"&&F(`Stopped after ${Ot.toString()} batches — rows still match this delete. Run it again to remove the rest.`)}catch(ae){F(ae.message)}}},Y=M=>{y(M),h(0)},ye=ht(()=>d===null?[]:r?.(d)??[],[r,d]),De=Po(B,w,Y,ye),Oe={filters:Ve(S),orderBy:nt(w),search:U,shard:p,table:d??void 0},Xe=Ae.data?.total??(B===null?0:b+B.rows.length),Wt=b>0,Ht=B!==null&&b+B.rows.length<Xe,Ut=B===null||B.rows.length===0?0:b+1,Qt=B===null?0:b+B.rows.length,Yt=()=>{se.refetch()},Xt=()=>{x("table")},Zt=()=>{x("json")},en=()=>{ie(O(xs,{filters:Ve(S),search:U,table:d}))},tn=()=>{ie(O(vs,{table:d}))},nn=M=>{E(M.target.value),h(0)},on=M=>{C(M),h(0)},sn=()=>{F(null);const M={};for(const V of B?.columns??[])Nt.has(V)||(M[V]="");R({docText:JSON.stringify(M,null,2),id:""})},ln=M=>{R(V=>V===null?V:{docText:M,id:V.id})},rn=()=>{I!==null&&ie(Ye(I.id===""?"insert":"patch",I.id===""?null:I.id,I.docText))},an=()=>{R(null),F(null)},cn=()=>{He(b-g)},dn=()=>{He(b+g)},un=M=>{He(Math.max(0,(M-1)*g))},fn=M=>{f(M),h(0)},mn=(M,V)=>{F(null),R({docText:JSON.stringify(Bn(ys(V)),null,2),id:M})},gn=M=>{ie(Ye("delete",M))},pn=async M=>{if(!(d===null||M.length===0)){F(null);try{for(const V of M)await c.query(bt,{id:V,op:"delete",table:d},he(G));Q.refetch()}catch(V){F(V.message)}}},bn=M=>{ie(pn(M))},hn=()=>{ie(it())};return{addRow:sn,bulkDelete:en,cancelCellEdit:at,cancelEdit:an,changePageSize:fn,clearTable:tn,columns:B?.columns??[],committing:H,currentView:Oe,discardStaged:ct,editableColumn:ks,editing:I,editingCell:P,facetFilter:je,facets:A,filter:N,filters:S,goNext:dn,goPrevious:cn,hasNext:Ht,hasPrevious:Wt,jumpToPage:un,liveError:W,loadTables:Yt,navigateToRef:$e,onBulkDeleteSelected:bn,onCommitStaged:hn,onFilterChange:nn,onFiltersChange:on,onRowDelete:gn,onRowEdit:mn,page:B,previewRef:Pe,pageError:pe,pageSize:g,rangeEnd:Qt,rangeStart:Ut,queryShardKey:G,saveEdit:rn,selectedTable:d,selectTable:Re,setEditorDocumentText:ln,setShardKey:m,shardKey:p,showJson:Zt,showTable:Xt,stage:j.stage,stagedChanges:dt,stagedValue:j.stagedValue,startCellEdit:rt,table:De,tables:ge,tablesError:le,toggleFacet:be,total:Xe,viewMode:v,writeError:z}},Es="lunora-studio-pinned-columns",_s=s=>{const e=L(21),{columns:n,initialPins:o,selectedTable:t}=s;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];const[l,r]=Ft(Es,i),a=t??"",c=l[a];let g;e[1]!==o||e[2]!==c?(g=c===void 0?new Set((o??"").split(",").filter(Rs)):new Set(c),e[1]=o,e[2]=c,e[3]=g):g=e[3];const f=g;let p;e[4]!==a||e[5]!==f||e[6]!==r?(p=k=>{r(A=>{const D=A[a]??[...f],_=D.includes(k)?D.filter(I=>I!==k):[...D,k];return{...A,[a]:_}})},e[4]=a,e[5]=f,e[6]=r,e[7]=p):p=e[7];const m=p,[d,b]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{b($s)},e[8]=h):h=e[8];const v=h;let x;e[9]!==n||e[10]!==t?(x={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=x):x=e[11];const{maskColumns:w,maskOn:y,maskView:N,maskViewFor:E,onToggleMask:S}=Nn(x);let C;return e[12]!==w||e[13]!==y||e[14]!==N||e[15]!==E||e[16]!==S||e[17]!==m||e[18]!==f||e[19]!==d?(C={maskColumns:w,maskOn:y,maskView:N,maskViewFor:E,onToggleMask:S,onTogglePin:m,onToggleTranspose:v,pinnedColumns:f,transposed:d},e[12]=w,e[13]=y,e[14]=N,e[15]=E,e[16]=S,e[17]=m,e[18]=f,e[19]=d,e[20]=C):C=e[20],C};function Rs(s){return s!==""}function $s(s){return!s}const Ds=Se(te.describeTable),Is=Se(te.readTablePage),Ms=Se(te.importShard),As=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},Ps=s=>{const e=Object.values(s.inserted).reduce((a,c)=>a+c,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,i=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${i})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},Os=s=>{const e=lt(),[n,o]=$(!1),[t,i]=$(void 0),[l,r]=$(void 0),[a,c]=$(void 0),[g,f]=$({}),[p,m]=$(!1),[d,b]=$(void 0),h=async(y,N)=>{o(!0),i(y),r(N),c(void 0),f({}),b(void 0),m(!0);try{const E=await e.query(Ds,{table:y},he(N)),{columns:S}=E;c(S);const C={},k=S.filter(A=>A.ref!==void 0&&A.type==="id"&&A.pk!==!0);for(const A of k){if(A.ref===void 0)continue;const{ref:D}=A;if(C[D]===void 0)try{const _=await e.query(Is,{filters:[],limit:ls,offset:0,search:"",table:D},he(N));C[D]=_.rows.flatMap(I=>As(I)||[])}catch{C[D]=[]}}f(C)}catch(E){b(E.message)}m(!1)};return{closeDialog:()=>{o(!1),i(void 0),r(void 0),c(void 0),f({}),b(void 0)},columnMeta:a,error:d,fkPools:g,insertBatch:async(y,N)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const E=await e.query(Ms,{rows:y.map(C=>({doc:C,table:t}))},he(l)),S=Ps(E);return S.error!==void 0||(N(),s()),S}catch(E){return{conflicts:0,error:E.message,inserted:0}}},loading:p,open:n,openDialog:(y,N)=>{ie(h(y,N))},shardKey:l,table:t}},Fs=()=>{const s=L(6),[e,n]=$(null);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},s[0]=o):o=s[0];const t=o,[i,l]=$(null);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=(p,m)=>{l({column:p,value:m})},s[1]=r):r=s[1];const a=r;let c;s[2]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{l(null)},s[2]=c):c=s[2];const g=c;let f;return s[3]!==i||s[4]!==e?(f={closeExpandedCell:g,closeInspect:t,expandedCell:i,inspecting:e,onExpandCell:a,onInspect:n},s[3]=i,s[4]=e,s[5]=f):f=s[5],f},Ls=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Vs=(s,e)=>typeof e=="number"&&Ls.test(s),Bs=s=>{const e=L(31),{column:n,masked:o,onNavigate:t,target:i,value:l}=s;let r;e[0]!==t||e[1]!==i||e[2]!==l?(r=()=>{i!==void 0&&t(i,String(l))},e[0]=t,e[1]=i,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let f;return e[4]===Symbol.for("react.memo_cache_sentinel")?(f=u("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=f):f=e[4],f}if(o){const f=`rd-masked-${n}`;let p;e[5]!==l?(p=Be(l),e[5]=l,e[6]=p):p=e[6];let m;return e[7]!==f||e[8]!==p?(m=u("span",{className:"italic text-muted-foreground","data-testid":f,title:"Masked (preview)",children:p}),e[7]=f,e[8]=p,e[9]=m):m=e[9],m}if(i!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const f=`rd-ref-${n}`,p=`Open ${i} ${String(l)}`,m=String(l);let d;return e[10]!==a||e[11]!==f||e[12]!==p||e[13]!==m?(d=T("button",{"data-testid":f,onClick:a,title:p,type:"button",children:[m," ↗"]}),e[10]=a,e[11]=f,e[12]=p,e[13]=m,e[14]=d):d=e[14],d}if(Vs(n,l)){const f=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let m;e[17]!==l?(m=wn(l),e[17]=l,e[18]=m):m=e[18];let d;return e[19]!==f||e[20]!==p||e[21]!==m?(d=u("span",{"data-testid":f,title:p,children:m}),e[19]=f,e[20]=p,e[21]=m,e[22]=d):d=e[22],d}if(typeof l=="object"){let f;e[23]!==l?(f=JSON.stringify(l,null,2),e[23]=l,e[24]=f):f=e[24];let p;return e[25]!==f?(p=u("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:f}),e[25]=f,e[26]=p):p=e[26],p}let c;e[27]!==l?(c=Be(l),e[27]=l,e[28]=c):c=e[28];let g;return e[29]!==c?(g=u("span",{children:c}),e[29]=c,e[30]=g):g=e[30],g},zs=s=>{const e=L(23),{columns:n,mask:o,onClose:t,onNavigate:i,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==i?(a=(b,h)=>{i(b,h),t()},e[0]=t,e[1]=i,e[2]=a):a=e[2];const c=a;let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=u("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=g):g=e[3];let f;e[4]!==t?(f=T("div",{className:"mb-3 flex items-center justify-between",children:[g,u("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=f):f=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==c||e[9]!==l||e[10]!==r){let b;e[12]!==o||e[13]!==c||e[14]!==l||e[15]!==r?(b=h=>T("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[u("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),u("dd",{className:"m-0",children:u(Bs,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:c,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=c,e[14]=l,e[15]=r,e[16]=b):b=e[16],p=n.map(b),e[6]=n,e[7]=o,e[8]=c,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let m;e[17]!==p?(m=u("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=m):m=e[18];let d;return e[19]!==t||e[20]!==f||e[21]!==m?(d=T(wt,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[f,m]}),e[19]=t,e[20]=f,e[21]=m,e[22]=d):d=e[22],d},js=50,Gs=s=>{const e=L(8),{active:n,onPick:o,shard:t}=s;let i;e[0]!==o||e[1]!==t?(i=()=>{o(t)},e[0]=o,e[1]=t,e[2]=i):i=e[2];const l=i,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let c;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(c=u("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=c):c=e[7],c},qs=({onFetchTables:s,onSelect:e})=>{const n=ne(),[o]=$(()=>Jn()),[t,i]=$(!1),[l,r]=$(void 0),[a,c]=$(void 0),[g,f]=$(!1),[p,m]=$(void 0),d=Qe(0),b=()=>{i(x=>!x)},h=async x=>{e(x),r(x),c(void 0),m(void 0),f(!0),d.current+=1;const w=d.current;try{const y=await s(x);d.current===w&&c(y?.slice(0,js))}catch(y){d.current===w&&m(y.message)}d.current===w&&f(!1)},v=x=>{ie(h(x))};return o.length===0?null:T("div",{"data-testid":"shard-explorer",children:[T("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:b,type:"button",children:[n("Shards seen"),u("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&T("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[u("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),u("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(x=>u("li",{children:u(Gs,{active:l===x,onPick:v,shard:x})},x))}),l!==void 0&&T("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[u("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),g&&u("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&u("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!g&&p===void 0&&a?.length===0&&u("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!g&&p===void 0&&a!==void 0&&a.length>0&&u("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(x=>T("li",{className:"flex items-center justify-between text-xs",children:[u("span",{"data-testid":`shard-explorer-table-${x.name}`,children:x.name}),u("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${x.name}`,children:x.rowCount})]},x.name))})]})]})]})},Js="lunora-studio-back-relations",Ks={},Ws=50,Hs=[],Us=Se(te.listTables),Qs=Se(te.readTablePage),Ys=s=>{const e=L(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:i}=s;let l;e[0]!==o||e[1]!==i?(l=u(xn,{onChange:o,testId:"db-shard-input",value:i}),e[0]=o,e[1]=i,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=u(qs,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=T("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},kl=({editable:s=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:t,initialSearch:i,initialShardKey:l,onNavigateToGlobal:r,onSelectTable:a,onViewChange:c,pageSize:g=Ws,queryBar:f,schemaSwitch:p,tableParam:m})=>{const b=et(te.describeTables,{},{shardKey:l??""}).data?.columnsByTable??Ks,[h,v]=Ft(Js,{}),x=ot(O=>{const Y=new Set(h[O]);return Et(O,b).filter(ye=>Y.has(Ct(ye)))},[h,b]),w=Ts({initialFilters:n,initialOrderBy:o,initialSearch:i,initialShardKey:l,onSelectTable:a,onViewChange:c,pageSize:g,resolveBackRelations:x,tableParam:m}),{cancelCellEdit:y,columns:N,currentView:E,editableColumn:S,editingCell:C,facetFilter:k,facets:A,loadTables:D,navigateToRef:_,onFiltersChange:I,page:R,pageError:z,previewRef:F,queryShardKey:j,selectedTable:P,selectTable:J,setShardKey:H,shardKey:q,stage:X,stagedValue:Ne,startCellEdit:re,tables:xe,tablesError:ve,toggleFacet:ke}=w,ce=En(q),Te=O=>{ie((async()=>{const ye=await ce.suggestFilter(O,P??"");ye!==void 0&&I(ye.map(De=>{const Oe=De.value,Xe=typeof Oe=="string"||typeof Oe=="number"||typeof Oe=="boolean"?String(Oe):"";return{column:De.column,operator:De.operator,value:Xe}}))})())},de=P===null?[]:Et(P,b),ee=new Set(h[P??""]),Ee=[];for(const O of R?.rows??[]){const Y=O._id??O.id;typeof Y=="string"&&Y!==""&&Ee.push(Y)}const ue=fs(ee,de,Ee,j),fe=O=>{v(Y=>{const ye=P??"",De=Y[ye]??[];return{...Y,[ye]:De.includes(O)?De.filter(Oe=>Oe!==O):[...De,O]}})},oe=_s({columns:N,initialPins:t,selectedTable:P}),me=Fs(),[U,G]=$(null),{closeExpandedCell:we,closeInspect:se,expandedCell:ge,inspecting:le,onExpandCell:K}=me,Z=lt(),Q=Object.fromEntries((b[P??""]??[]).map(O=>[O.name,O])),B=new Map;for(const O of b[P??""]??[])O.isStorage===!0&&B.set(O.name,O.bucket);const pe=ot(async(O,Y)=>Z.signedStorageUrl(O,Y===void 0?{}:{bucket:Y}),[Z]),W=async O=>await Z.query(Us,{},he(O)),Ae=()=>{P!==null&&J(P)},{closeDialog:Re,columnMeta:$e,fkPools:Pe,insertBatch:ze,open:be,openDialog:je}=Os(Ae),Le=()=>{P!==null&&je(P,q)},Ke=O=>ze(O,Re),We=(O,Y)=>{if(r!==void 0&&e?.has(O)===!0){r(O,Y);return}_(O,Y)},He=f?.onSaveQuery,rt=O=>{He?.(O,E)},at={cancelEdit:y,editable:s,editableColumn:S,editingCell:C,onExpandCell:K,stage:X,stagedValue:Ne,startEdit:re},it=O=>{O!==null&&G(O)},ct=()=>{w.onRowDelete(U)},dt=async(O,Y,ye)=>await Z.query(Qs,{filters:[{column:Y,operator:"eq",value:ye}],limit:tt,offset:0,orderBy:[],table:O},he(j)),Ye={columns:R?.refs,maskViewFor:oe.maskViewFor,onNavigate:We,onPreview:F};return T("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[u(kn,{header:u(Ys,{onFetchShardTables:W,onShardChange:H,schemaSwitch:p,shardKey:q}),onReload:D,onSelect:J,prefix:"db",selected:P,tables:xe??Hs}),T("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ve!==null&&u("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ve}),R===null&&z===null&&u("div",{className:"flex flex-1 items-center justify-center p-6",children:u("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),z!==null&&u("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:z}),R!==null&&u(os,{assistant:ce,backRelations:{available:de,counts:ue,enabled:ee,onToggle:fe},browser:w,columnMeta:Q,edit:at,editable:s,onAskAiFilter:Te,onInspect:me.onInspect,onOpenGenerateRows:Le,onRowDelete:it,onSaveQuery:rt,page:R,preferences:oe,queryBar:f,references:Ye})]}),R!==null&&u(Tn,{columns:N,facets:A,mask:oe.maskView,onFacetFilter:k,onToggleFacet:ke}),le!==null&&R!==null&&u(zs,{columns:R.columns,mask:oe.maskView,onClose:se,onNavigate:We,refs:R.refs,row:Lt(le,oe.maskView)}),U!==null&&P!==null&&u(no,{onClose:()=>{G(null)},onConfirm:ct,readPage:dt,rowId:U,schema:Kn(b),table:P}),ge!==null&&u(Vn,{bucket:B.get(ge.column),column:ge.column,onClose:we,resolveUrl:B.has(ge.column)?pe:void 0,value:ge.value}),be&&P!==null&&$e!==void 0&&u(ds,{columns:$e,fkPools:Pe,onClose:Re,onInsertRows:Ke,table:P})]})};export{kl as DataBrowser};
@@ -1 +0,0 @@
1
- import{c as O}from"react/compiler-runtime";import{LunoraClient as G}from"@lunora/client";import{LunoraProvider as H}from"@lunora/react";import{useState as B,useEffect as R}from"react";import{ErrorBoundary as z}from"./ErrorBoundary-BWNF98VF.mjs";import{u as U,B as V,T as Y,a as q,S as J}from"./studio-ByaR_3g9.mjs";import Q from"./useDebounced-DVeQ5-oW.mjs";import{useT as j,createStudioI18n as X}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{StudioI18nProvider as D}from"./StudioI18nProvider-fVsCSs5L.mjs";import{r as Z}from"./internal-CwaF9YNk.mjs";import{w as $}from"./recording-client-BEZ6tVgo.mjs";import F from"./STUDIO_ROOT_CLASS-C6MccdVk.mjs";import{a as K}from"./browser-storage-BH1MxLZs.mjs";import{c as W}from"./utils-bhneXptQ.mjs";import{B as ee}from"./button-q0UYSmrn.mjs";import{I as te}from"./input-CXhxesPC.mjs";import{jsx as g,jsxs as L}from"react/jsx-runtime";const P="lunora-studio-admin-token",oe=()=>{try{return K("session")?.getItem(P)??""}catch{return""}},ne=b=>{const e=K("session");if(e!==void 0)try{b===""?e.removeItem(P):e.setItem(P,b)}catch{}},se="/_lunora/admin/ws-token",ie=1e4,le=b=>{const e=b;return typeof e?.token=="string"&&e.token.length>0&&typeof e.expiresAtMs=="number"},re=b=>{const{adminToken:e,baseUrl:d}=b,o=b.fetchImpl??fetch;let n=d;for(;n.endsWith("/");)n=n.slice(0,-1);const r=`${n}${se}`;let t,s=!1,i;const f=async()=>{const u=await o(r,{headers:{authorization:`Bearer ${e}`},method:"POST"});if(u.status===404||u.status===405)return s=!0,e;if(!u.ok)throw new Error(`ws-token mint failed: ${String(u.status)}`);const l=await u.json().catch(()=>{});if(!le(l))throw new Error("ws-token mint failed: malformed response body");return t=l,l.token};return{getToken:async()=>s?e:t!==void 0&&t.expiresAtMs-ie>Date.now()?t.token:(i??=f().finally(()=>{i=void 0}),i),invalidate:()=>{t=void 0}}},ae=b=>{const e=O(42),{onSubmit:d}=b,o=j(),[n,r]=B("");let t;e[0]!==n?(t=n.trim(),e[0]=n,e[1]=t):t=e[1];const s=t;let i;e[2]!==d||e[3]!==s?(i=_=>{_.preventDefault(),s!==""&&d(s)},e[2]=d,e[3]=s,e[4]=i):i=e[4];const f=i;let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=g("div",{className:"h-10 w-10 text-foreground",children:g(V,{})}),e[5]=u):u=e[5];let l;e[6]!==o?(l=o("Connect to Lunora Studio"),e[6]=o,e[7]=l):l=e[7];let v;e[8]!==l?(v=g("h1",{className:"text-base font-semibold text-foreground",children:l}),e[8]=l,e[9]=v):v=e[9];let k;e[10]!==o?(k=o("Enter your admin token to access the studio."),e[10]=o,e[11]=k):k=e[11];let m;e[12]!==k?(m=g("p",{className:"text-[13px] text-muted-foreground",children:k}),e[12]=k,e[13]=m):m=e[13];let c;e[14]!==v||e[15]!==m?(c=L("div",{className:"flex flex-col items-center gap-3 text-center",children:[u,L("div",{className:"flex flex-col gap-1",children:[v,m]})]}),e[14]=v,e[15]=m,e[16]=c):c=e[16];let h;e[17]!==o?(h=o("admin token"),e[17]=o,e[18]=h):h=e[18];let a;e[19]!==h?(a=g("label",{className:"text-xs font-medium text-foreground",htmlFor:"lunora-studio-login-token",children:h}),e[19]=h,e[20]=a):a=e[20];let p;e[21]===Symbol.for("react.memo_cache_sentinel")?(p=_=>{r(_.target.value)},e[21]=p):p=e[21];let S;e[22]!==n?(S=g(te,{autoComplete:"off",autoFocus:!0,"data-testid":"lunora-studio-login-token",id:"lunora-studio-login-token",onChange:p,placeholder:"LUNORA_ADMIN_TOKEN",type:"password",value:n}),e[22]=n,e[23]=S):S=e[23];let x;e[24]!==o?(x=o("From your worker's LUNORA_ADMIN_TOKEN — your project's .dev.vars in dev, or a deployment secret in production."),e[24]=o,e[25]=x):x=e[25];let A;e[26]!==x?(A=g("p",{className:"text-[11px] text-muted-foreground",children:x}),e[26]=x,e[27]=A):A=e[27];let T;e[28]!==a||e[29]!==S||e[30]!==A?(T=L("div",{className:"flex flex-col gap-1.5",children:[a,S,A]}),e[28]=a,e[29]=S,e[30]=A,e[31]=T):T=e[31];const E=s==="";let y;e[32]!==o?(y=o("Connect"),e[32]=o,e[33]=y):y=e[33];let w;e[34]!==E||e[35]!==y?(w=g(ee,{"data-testid":"lunora-studio-login-submit",disabled:E,type:"submit",children:y}),e[34]=E,e[35]=y,e[36]=w):w=e[36];let N;return e[37]!==f||e[38]!==T||e[39]!==w||e[40]!==c?(N=L("form",{className:"flex w-full max-w-sm flex-col gap-5 rounded-xl border border-border bg-card p-7 shadow-lg","data-testid":"lunora-studio-login",onSubmit:f,children:[c,T,w]}),e[37]=f,e[38]=T,e[39]=w,e[40]=c,e[41]=N):N=e[41],N},ce=b=>{const e=O(10),{i18n:d,onSubmit:o}=b,{resolvedTheme:n}=U(),r=n==="dark"&&"dark";let t;e[0]!==r?(t=W(F,r,"flex h-dvh items-center justify-center bg-sidebar p-6 text-sm text-foreground"),e[0]=r,e[1]=t):t=e[1];let s;e[2]!==o?(s=g(ae,{onSubmit:o}),e[2]=o,e[3]=s):s=e[3];let i;e[4]!==d||e[5]!==s?(i=g(D,{i18n:d,children:s}),e[4]=d,e[5]=s,e[6]=i):i=e[6];let f;return e[7]!==t||e[8]!==i?(f=g("div",{className:t,"data-testid":"lunora-studio-login-root",children:i}),e[7]=t,e[8]=i,e[9]=f):f=e[9],f},de=b=>{const e=O(23),{basePath:d,chrome:o,studio:n}=b,r=j();let t;e[0]!==r?(t=r("Studio failed"),e[0]=r,e[1]=t):t=e[1];let s;e[2]!==r?(s=r("Studio"),e[2]=r,e[3]=s):s=e[3];let i;e[4]!==r?(i=r("Try again"),e[4]=r,e[5]=i):i=e[5];const f=n?.dataEditable,u=n?.functions,l=n?.initialShardKey,v=n?.openApiSpec,k=n?.openRpcSpec,m=n?.runAsIdentity,c=n?.scheduledCancel,h=n?.scheduledLoad,a=n?.schemaEditable;let p;e[6]!==d||e[7]!==o||e[8]!==c||e[9]!==h||e[10]!==a||e[11]!==f||e[12]!==u||e[13]!==l||e[14]!==v||e[15]!==k||e[16]!==m?(p=g(J,{basePath:d,chrome:o,dataEditable:f,functions:u,initialShardKey:l,openApiSpec:v,openRpcSpec:k,runAsIdentity:m,scheduledCancel:c,scheduledLoad:h,schemaEditable:a}),e[6]=d,e[7]=o,e[8]=c,e[9]=h,e[10]=a,e[11]=f,e[12]=u,e[13]=l,e[14]=v,e[15]=k,e[16]=m,e[17]=p):p=e[17];let S;return e[18]!==t||e[19]!==p||e[20]!==s||e[21]!==i?(S=g(z,{fallbackTitle:t,label:s,retryLabel:i,children:p}),e[18]=t,e[19]=p,e[20]=s,e[21]=i,e[22]=S):S=e[22],S},fe=b=>{const e=O(20),{basePath:d,clearToken:o,client:n,i18n:r,onTokenChange:t,rulesInstalled:s,studio:i,token:f}=b,{resolvedTheme:u}=U();let l;e[0]!==o||e[1]!==t||e[2]!==s||e[3]!==f?(l={clearToken:o,onTokenChange:t,rulesInstalled:s,token:f},e[0]=o,e[1]=t,e[2]=s,e[3]=f,e[4]=l):l=e[4];const v=l,k=u==="dark"&&"dark";let m;e[5]!==k?(m=W(F,k,"flex h-dvh flex-col overflow-hidden bg-sidebar text-sm text-foreground"),e[5]=k,e[6]=m):m=e[6];let c;e[7]!==d||e[8]!==v||e[9]!==i?(c=g(q,{children:g(de,{basePath:d,chrome:v,studio:i})}),e[7]=d,e[8]=v,e[9]=i,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==c?(h=g(D,{i18n:r,children:c}),e[11]=r,e[12]=c,e[13]=h):h=e[13];let a;e[14]!==n||e[15]!==h?(a=g(H,{client:n,children:h}),e[14]=n,e[15]=h,e[16]=a):a=e[16];let p;return e[17]!==m||e[18]!==a?(p=g("div",{className:m,"data-testid":"lunora-studio-app",children:a}),e[17]=m,e[18]=a,e[19]=p):p=e[19],p},Ee=b=>{const e=O(27);let d;e[0]!==b?(d=b===void 0?{}:b,e[0]=b,e[1]=d):d=e[1];const{adminToken:o,basePath:n,baseUrl:r,client:t,rulesInstalled:s,studio:i,locale:f}=d;let u;e[2]!==o?(u=()=>o??oe(),e[2]=o,e[3]=u):u=e[3];const[l,v]=B(u);let k,m;e[4]!==l?(k=()=>{ne(l)},m=[l],e[4]=l,e[5]=k,e[6]=m):(k=e[5],m=e[6]),R(k,m);const c=Q(l,300);let h;e:{if(t!==void 0){let I;e[7]!==t?(I=$(t),e[7]=t,e[8]=I):I=e[8],h=I;break e}let _;if(e[9]!==r||e[10]!==c){const I=Z(r),C=c===""?void 0:re({adminToken:c,baseUrl:I}),M=new G({url:I,...C===void 0?{}:{wsToken:C.getToken}});C!==void 0&&(M.setAuthToken(c),M.onTokenExpired(C.invalidate)),_=$(M),e[9]=r,e[10]=c,e[11]=_}else _=e[11];h=_}const a=h;let p,S;e[12]!==a||e[13]!==t?(p=()=>()=>{t===void 0&&a.close()},S=[a,t],e[12]=a,e[13]=t,e[14]=p,e[15]=S):(p=e[14],S=e[15]),R(p,S);let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=_=>{v(_.target.value)},e[16]=x):x=e[16];const A=x;let T;e[17]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{v("")},e[17]=T):T=e[17];const E=T;let y;e[18]!==f?(y=X(f),e[18]=f,e[19]=y):y=e[19];const w=y;let N;return e[20]!==n||e[21]!==a||e[22]!==w||e[23]!==s||e[24]!==i||e[25]!==l?(N=g(Y,{children:l===""?g(ce,{i18n:w,onSubmit:v}):g(fe,{basePath:n,clearToken:E,client:a,i18n:w,onTokenChange:A,rulesInstalled:s,studio:i,token:l})}),e[20]=n,e[21]=a,e[22]=w,e[23]=s,e[24]=i,e[25]=l,e[26]=N):N=e[26],N};export{Ee as StudioApp};
@@ -1 +0,0 @@
1
- const u=t=>{let e=0,c=0,s=0,n=0,r=0,i=0,a=0;for(const{metrics:o}of t){if(o===null){r+=1;continue}n+=1,e+=o.requests,c+=o.errors,s+=o.databaseSize??0,o.cache!==null&&(i+=o.cache.hits,a+=o.cache.hits+o.cache.misses)}return{failed:r,hitRate:a===0?null:i/a,reachable:n,totalDatabaseSize:s,totalErrors:c,totalRequests:e}},h=(t,e)=>{const c=new Set,s=[];for(const n of["",t.trim(),...e])c.has(n)||(c.add(n),s.push(n));return s},l=(t,e)=>{if(t.length===0)return 0;if(t.sort((s,n)=>s-n),e<=0)return t[0]??0;if(e>=100)return t.at(-1)??0;const c=Math.ceil(e/100*t.length)-1;return t[c]??0},f=t=>{const c=t.functions;if(!c||c.length===0)return{p90:0,p95:0};const s=1e3,n=[];for(const r of c){if(r.calls<=0)continue;const i=r.totalDurationMs/r.calls,a=Math.min(r.calls,s);for(let o=0;o<a;o+=1)n.push(i)}return n.length===0?{p90:0,p95:0}:{p90:l([...n],90),p95:l([...n],95)}},p=(t,e,c="neutral")=>{const s=e-t,n=t===0?null:s/t*100;return{delta:s,direction:c,pct:n}},g=t=>t.map(e=>({...e,avgDurationMs:e.execCount>0?e.totalDurationMs/e.execCount:0}));export{u as aggregateMetrics,p as computeDelta,f as computeLatencyPercentiles,g as enrichQueryStats,l as percentile,h as shardsToAggregate};
@@ -1 +0,0 @@
1
- import{c as Q}from"react/compiler-runtime";import{useLunora as A}from"@lunora/react";import{useQueryClient as g,useQuery as R,keepPreviousData as _}from"@tanstack/react-query";import{useState as M,useEffect as P}from"react";import{c as b,d as v,f as I,b as T}from"./internal-CwaF9YNk.mjs";const S=300,l=e=>typeof e=="string"?e===""?void 0:e:typeof e=="number"||typeof e=="boolean"?String(e):void 0,d=e=>e.filter(t=>t!==void 0).join(" "),K={deleteRows:e=>d([l(e.table),Array.isArray(e.ids)?`${String(e.ids.length)} rows`:void 0]),facetColumn:e=>d([l(e.table),l(e.column)]),lintSql:()=>"sql",readTablePage:e=>d([l(e.table),Array.isArray(e.filters)&&e.filters.length>0?`${String(e.filters.length)} filters`:void 0,typeof e.search=="string"&&e.search!==""?"search":void 0,typeof e.limit=="number"?`limit ${String(e.limit)}`:void 0]),runMigration:e=>d([l(e.id),l(e.direction),e.dryRun===!0?"dry-run":void 0]),runSql:e=>typeof e.sql=="string"?`${String(e.sql.length)} chars`:"",schemaVersion:e=>typeof e.hash=="string"?e.hash.slice(0,8):"",writeRow:e=>d([l(e.table),"1 row"])},q="__lunora_admin__:",j=(e,t)=>{const r=e.startsWith(q)?e.slice(q.length):e,s=K[r];if(s!==void 0)return s(t);const i=Object.keys(t);return i.length===0?"":i.join(", ")},x=e=>{if(Array.isArray(e))return e.length;if(!(typeof e!="object"||e===null)){for(const t of Object.values(e))if(Array.isArray(t))return t.length}};class C{entries=[];listeners=new Set;nextSeq=1;getSnapshot=()=>this.entries;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});start(t,r,s){return this.append(t,r,s,"call","pending")}startSubscription(t,r,s){return this.append(t,r,s,"subscription","live")}recordPush(t){if(this.listeners.size===0){const r=this.entries.find(s=>s.seq===t);r!==void 0&&(r.pushes=(r.pushes??0)+1);return}this.patch(t,r=>({...r,pushes:(r.pushes??0)+1}))}failSubscription(t,r){this.patch(t,s=>({...s,error:r,status:"error"}))}endSubscription(t){this.patch(t,r=>r.status==="error"?r:{...r,durationMs:Date.now()-r.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(t=>t.status==="error")?.seq}settle(t,r){this.patch(t,s=>({...s,durationMs:Date.now()-s.startedAt,...r.error===void 0?{resultCount:x(r.result),status:"ok"}:{error:r.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(t,r,s,i,n){const u=this.nextSeq;this.nextSeq+=1;const c={functionPath:t,kind:i,seq:u,shardKey:s,startedAt:Date.now(),status:n,summary:j(t,r),...i==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>S?o.slice(o.length-S):o,this.emit(),u}patch(t,r){const s=this.entries.findIndex(i=>i.seq===t);s!==-1&&(this.entries=this.entries.with(s,r(this.entries[s])),this.emit())}emit(){for(const t of this.listeners)t()}}const f=new C,w=(e,t,r)=>["lunora-admin",e,t,r.trim()],E=(e,t)=>[...e,t];function F(e,t,r={}){const s=A(),{enabled:i=!0,keepPreviousData:n=!1,staleTime:u=0}=r,c=E(e,s.clientIdentifier()),a=R({enabled:i,queryFn:t,placeholderData:n?_:void 0,queryKey:c,staleTime:u});return{data:a.data,error:a.error?T(a.error):a.error,errorSource:a.error??void 0,isLoading:a.isLoading,liveError:void 0,refetch:()=>{I(a.refetch())}}}function J(e,t,r={}){const s=A(),i=g(),{enabled:n=!0,keepPreviousData:u=!1,live:c=!1,shardKey:o="",staleTime:a}=r,p=w(e,t,o),D=F(p,()=>s.query(b(e),t,v(o)),{enabled:n,keepPreviousData:u,staleTime:a??(c?Number.POSITIVE_INFINITY:0)}),[k,y]=M(void 0),L=JSON.stringify(p);return P(()=>{if(!n||!c)return;y(void 0);const m=f.startSubscription(e,t,o),O=s.subscribe(b(e),t,h=>{f.recordPush(m),y(void 0),i.setQueryData(E(p,s.clientIdentifier()),h)},{...v(o),onError:h=>{f.failSubscription(m,h.message),y(h.message)}});return()=>{f.endSubscription(m),O()}},[L,n,c]),{...D,liveError:n&&c?k:void 0}}const U=()=>{const e=Q(2),t=g();let r;return e[0]!==t?(r=(s,i,n)=>{const u=i===void 0?["lunora-admin",s]:w(s,i,n??"");I(t.invalidateQueries({queryKey:u}))},e[0]=t,e[1]=r):r=e[1],r};export{U as a,F as b,f as o,J as u};
@@ -1 +0,0 @@
1
- const g=e=>{let t="";for(let o=0;o<e.length;o+=32768)t+=String.fromCharCode(...e.subarray(o,o+32768));return btoa(t)},p=e=>{const t=atob(e),a=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)a[o]=t.codePointAt(o)??0;return a},i="$lunora.wire$";const A="__proto__",m={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},w={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},E=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},u=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===void 0)return[i,"undefined"];if(e===null)return null;const a=typeof e;if(a==="bigint")return[i,"bigint",e.toString()];if(a==="number"){const r=e;return Number.isNaN(r)?[i,"nan"]:r===1/0?[i,"inf"]:r===-1/0?[i,"-inf"]:r}if(a!=="object")return e;if(e instanceof Date)return[i,"date",u(e.getTime(),t+1)];if(e instanceof Error){const r=e,n={};for(const y of Object.keys(r))r[y]!==void 0&&(n[y]=u(r[y],t+1));const c=[i,"error",r.name,r.message,n];return r.cause!==void 0&&c.push(u(r.cause,t+1)),c}if(e instanceof URL)return[i,"url",e.href];if(e instanceof Map)return[i,"map",[...e.entries()].map(([r,n])=>[u(r,t+1),u(n,t+1)])];if(e instanceof Set)return[i,"set",[...e].map(r=>u(r,t+1))];if(e instanceof ArrayBuffer)return[i,"bytes",g(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const r=e,n=r.constructor.name,c=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return n==="Uint8Array"?[i,"bytes",g(c)]:[i,"bytes",g(c),n]}if(Array.isArray(e)){const r=e.map(n=>u(n,t+1));return r.length>0&&r[0]===i?[i,"arr",r]:r}if(!E(e)){const r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const o=e,s={};for(const r of Object.keys(o)){const n=o[r];if(n===void 0)continue;const c=u(n,t+1);r===A?Object.defineProperty(s,r,{configurable:!0,enumerable:!0,value:c,writable:!0}):s[r]=c}return s},f=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===i)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>f(r,t+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>1024||!/^-?\d+$/.test(r))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(r)}case"date":return new Date(f(e[2],t+1));case"map":return new Map(e[2].map(([r,n])=>[f(r,t+1),f(n,t+1)]));case"set":return new Set(e[2].map(r=>f(r,t+1)));case"url":return new URL(e[2]);case"error":{const r=e[2],n=e[3],c=(Object.hasOwn(w,r)?w[r]:void 0)??Error,y=new c(n);y.name!==r&&Object.defineProperty(y,"name",{configurable:!0,value:r,writable:!0});const d=f(e[4],t+1);for(const b of Object.keys(d))b===A?Object.defineProperty(y,b,{configurable:!0,enumerable:!0,value:d[b],writable:!0}):y[b]=d[b];return e.length>5&&Object.defineProperty(y,"cause",{configurable:!0,value:f(e[5],t+1),writable:!0}),y}case"bytes":{const r=p(e[2]),n=e[3]??"Uint8Array";if(n==="ArrayBuffer")return r.buffer.byteLength===r.byteLength?r.buffer:r.slice().buffer;const c=Object.hasOwn(m,n)?m[n]:void 0;return c?new c(r.slice().buffer):r}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>f(r,t+1))}return e.map(s=>f(s,t+1))}const a=e,o={};for(const s of Object.keys(a)){const r=f(a[s],t+1);s===A?Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):o[s]=r}return o},l=e=>{try{const t=f(JSON.parse(e));return E(t)?t:void 0}catch{return}};export{f as a,l as d,u as e,E as i};
@@ -1 +0,0 @@
1
- import{a as L}from"./chunk-FKVZRPV5.js";import{a as O,b as v,c as N,d as E,e as _,f as M}from"./chunk-HEAQVSNS.js";import{a as q}from"./chunk-WUWBZPUK.js";import{d as x,h as T,m as k,o as I}from"./chunk-Y4Q25F6X.js";import{c as R}from"./chunk-T2IE5GKA.js";import{a as u,d as b,e as Y,f as U,g as W}from"./chunk-YKXDMIHQ.js";var $=b(U(),1);var F="https://api.cloudflare.com/client/v4/accounts",H=6e4,f=class extends R{static{u(this,"r")}constructor(t,p){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(t)}: ${p}`,{name:"AnalyticsSqlError",status:t})}},C=u(a=>{let t=a.fetch??globalThis.fetch,p=`${F}/${encodeURIComponent(a.accountId)}/analytics_engine/sql`,m=a.timeoutMs??H;return{query:u(async c=>{let l=new AbortController,r=setTimeout(()=>{l.abort()},m);try{let e=await t(p,{body:c,headers:{Authorization:`Bearer ${a.apiToken}`,"Content-Type":"text/plain"},method:"POST",signal:l.signal});if(!e.ok)throw new f(e.status,await e.text().catch(()=>"<error body unavailable: the request deadline fired before it was read>"));let o;try{o=await e.json()}catch(d){throw l.signal.aborted?d:new f(e.status,"Analytics Engine SQL API returned a non-JSON body.")}let s=o,i=s.data??[];return{columns:s.meta??[],rowCount:s.rows??i.length,rows:i}}catch(e){throw l.signal.aborted&&!(e instanceof f)?new f(504,`query timed out after ${String(m)}ms (AnalyticsSqlConfig.timeoutMs)`):e}finally{clearTimeout(r)}},"query")}},"p");var y=b(Y(),1);var n=b(W(),1);var Q="ANALYTICS",D=[{key:"volume",sql:u(a=>`SELECT blob2 AS fn, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:u(a=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:u(a=>`SELECT blob3 AS shard, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=u(a=>{let t=(0,$.c)(27),{state:p,title:m}=a,c=x(),{error:l,loading:r,result:e}=p,o=`analytics-panel-${m}`,s;t[0]!==c||t[1]!==m?(s=c(m),t[0]=c,t[1]=m,t[2]=s):s=t[2];let i;t[3]!==s?(i=(0,n.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s})}),t[3]=s,t[4]=i):i=t[4];let d;t[5]!==r||t[6]!==c?(d=r&&(0,n.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:c("Loading\u2026")}),t[5]=r,t[6]=c,t[7]=d):d=t[7];let h;t[8]!==l||t[9]!==r?(h=!r&&l!==null&&(0,n.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l}),t[8]=l,t[9]=r,t[10]=h):h=t[10];let A;t[11]!==l||t[12]!==r||t[13]!==e||t[14]!==c?(A=!r&&l===null&&e!==null&&e.rows.length===0&&(0,n.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:c("No data points yet.")}),t[11]=l,t[12]=r,t[13]=e,t[14]=c,t[15]=A):A=t[15];let g;t[16]!==l||t[17]!==r||t[18]!==e?(g=!r&&l===null&&e!==null&&e.rows.length>0&&(0,n.jsxs)(O,{children:[(0,n.jsx)(v,{children:(0,n.jsx)(E,{children:e.columns.map(V)})}),(0,n.jsx)(N,{children:e.rows.map((B,P)=>(0,n.jsx)(E,{children:e.columns.map(w=>(0,n.jsx)(M,{className:"font-mono text-xs",children:k(B[w.name])},w.name))},P))})]}),t[16]=l,t[17]=r,t[18]=e,t[19]=g):g=t[19];let S;return t[20]!==o||t[21]!==i||t[22]!==d||t[23]!==h||t[24]!==A||t[25]!==g?(S=(0,n.jsxs)(q,{className:"gap-0 py-0","data-testid":o,children:[i,d,h,A,g]}),t[20]=o,t[21]=i,t[22]=d,t[23]=h,t[24]=A,t[25]=g,t[26]=S):S=t[26],S},"H"),ot=u(({config:a,dataset:t=Q,runQuery:p}={})=>{let m=x(),[c,l]=(0,y.useState)({}),r=(0,y.useMemo)(()=>{if(p!==void 0)return p;if(a===void 0)return null;let o=C({accountId:a.accountId,apiToken:a.apiToken});return s=>o.query(s)},[a,p]),e=(0,y.useCallback)(async o=>{if(r!==null)for(let s of D){if(o.cancelled)return;l(i=>({...i,[s.key]:{error:null,loading:!0,result:null}}));try{let i=await r(s.sql(t));o.cancelled||l(d=>({...d,[s.key]:{error:null,loading:!1,result:i}}))}catch(i){o.cancelled||l(d=>({...d,[s.key]:{error:T(i),loading:!1,result:null}}))}}},[r,t]);return(0,y.useEffect)(()=>{let o={cancelled:!1};return I(e(o)),()=>{o.cancelled=!0}},[e]),r===null?(0,n.jsx)(L,{description:m("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,n.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,n.jsx)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:m("Analytics is not configured.")}):(0,n.jsx)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:D.map(o=>(0,n.jsx)(G,{state:c[o.key]??j,title:o.title},o.key))})},"Q");function V(a){return(0,n.jsx)(_,{children:a.name},a.name)}u(V,"W");export{ot as AnalyticsPanel};
@@ -1 +0,0 @@
1
- import{b as P,c as v,d as I,f as g}from"./chunk-JBIN7W2B.js";import{f as S,g as q,h as k,o as w}from"./chunk-Y4Q25F6X.js";import{a as i,d as D,e as N,f as R}from"./chunk-YKXDMIHQ.js";var _=D(R(),1);var p=D(N(),1);var T=300,d=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"l"),c=i(t=>t.filter(e=>e!==void 0).join(" "),"d"),$={deleteRows:i(t=>c([d(t.table),Array.isArray(t.ids)?`${String(t.ids.length)} rows`:void 0]),"deleteRows"),facetColumn:i(t=>c([d(t.table),d(t.column)]),"facetColumn"),lintSql:i(()=>"sql","lintSql"),readTablePage:i(t=>c([d(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>c([d(t.id),d(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>c([d(t.table),"1 row"]),"writeRow")},E="__lunora_admin__:",F=i((t,e)=>{let r=t.startsWith(E)?t.slice(E.length):t,s=$[r];if(s!==void 0)return s(e);let o=Object.keys(e);return o.length===0?"":o.join(", ")},"j"),C=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let e of Object.values(t))if(Array.isArray(e))return e.length}},"x"),A=class{static{i(this,"C")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),"subscribe");start(e,r,s){return this.append(e,r,s,"call","pending")}startSubscription(e,r,s){return this.append(e,r,s,"subscription","live")}recordPush(e){if(this.listeners.size===0){let r=this.entries.find(s=>s.seq===e);r!==void 0&&(r.pushes=(r.pushes??0)+1);return}this.patch(e,r=>({...r,pushes:(r.pushes??0)+1}))}failSubscription(e,r){this.patch(e,s=>({...s,error:r,status:"error"}))}endSubscription(e){this.patch(e,r=>r.status==="error"?r:{...r,durationMs:Date.now()-r.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(e=>e.status==="error")?.seq}settle(e,r){this.patch(e,s=>({...s,durationMs:Date.now()-s.startedAt,...r.error===void 0?{resultCount:C(r.result),status:"ok"}:{error:r.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(e,r,s,o,a){let u=this.nextSeq;this.nextSeq+=1;let l={functionPath:e,kind:o,seq:u,shardKey:s,startedAt:Date.now(),status:a,summary:F(e,r),...o==="subscription"?{pushes:0}:{}},n=[...this.entries,l];return this.entries=n.length>T?n.slice(n.length-T):n,this.emit(),u}patch(e,r){let s=this.entries.findIndex(o=>o.seq===e);s!==-1&&(this.entries=this.entries.with(s,r(this.entries[s])),this.emit())}emit(){for(let e of this.listeners)e()}},f=new A,j=i((t,e,r)=>["lunora-admin",t,e,r.trim()],"w"),x=i((t,e)=>[...t,e],"E");function J(t,e,r={}){let s=g(),{enabled:o=!0,keepPreviousData:a=!1,staleTime:u=0}=r,l=x(t,s.clientIdentifier()),n=I({enabled:o,queryFn:e,placeholderData:a?P:void 0,queryKey:l,staleTime:u});return{data:n.data,error:n.error?k(n.error):n.error,errorSource:n.error??void 0,isLoading:n.isLoading,liveError:void 0,refetch:i(()=>{w(n.refetch())},"refetch")}}i(J,"F");function W(t,e,r={}){let s=g(),o=v(),{enabled:a=!0,keepPreviousData:u=!1,live:l=!1,shardKey:n="",staleTime:K}=r,m=j(t,e,n),L=J(m,()=>s.query(S(t),e,q(n)),{enabled:a,keepPreviousData:u,staleTime:K??(l?Number.POSITIVE_INFINITY:0)}),[O,y]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!l)return;y(void 0);let b=f.startSubscription(t,e,n),M=s.subscribe(S(t),e,h=>{f.recordPush(b),y(void 0),o.setQueryData(x(m,s.clientIdentifier()),h)},{...q(n),onError:i(h=>{f.failSubscription(b,h.message),y(h.message)},"onError")});return()=>{f.endSubscription(b),M()}},[Q,a,l]),{...L,liveError:a&&l?O:void 0}}i(W,"J");var Y=i(()=>{let t=(0,_.c)(2),e=v(),r;return t[0]!==e?(r=i((s,o,a)=>{let u=o===void 0?["lunora-admin",s]:j(s,o,a??"");w(e.invalidateQueries({queryKey:u}))},"r"),t[0]=e,t[1]=r):r=t[1],r},"U");export{f as a,J as b,W as c,Y as d};
@@ -1 +0,0 @@
1
- import{a as me}from"./chunk-F7UC63UN.js";import{a as Ft,b as Lt,c as At,d as Kt}from"./chunk-TQCXJX4I.js";import{a as it}from"./chunk-PKCC4J5W.js";import{a as Ct,b as It,c as Tt,d as Rt,e as je}from"./chunk-YEBHHIAY.js";import{a as Ot}from"./chunk-RPQL45FL.js";import{a as zt}from"./chunk-DEJLINCJ.js";import"./chunk-4GTO7FL5.js";import"./chunk-I52I2DJG.js";import{e as _t}from"./chunk-UYEZR3BI.js";import"./chunk-TWTNWOJU.js";import{a as $t}from"./chunk-7QRRR3K6.js";import"./chunk-C3TOZ4LG.js";import"./chunk-D27D4UUI.js";import"./chunk-SB35BJ7A.js";import"./chunk-FO26ZU7E.js";import{a as Ze,b as et,c as tt,d as vt,e as yt,f as rt,g as at,h as Nt,i as St}from"./chunk-XSLMHPP2.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import{a as Mt}from"./chunk-S3CRZLGS.js";import{a as kt}from"./chunk-IFLTA2OD.js";import{a as wt,b as qt}from"./chunk-OGUKYRFM.js";import"./chunk-JVUZEYKQ.js";import"./chunk-OKG3HWSJ.js";import"./chunk-46ZJ3TM4.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as Ye}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as Ue}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as Le}from"./chunk-CXNZVJ3S.js";import{c as De}from"./chunk-ECQTVV2J.js";import{f as dt}from"./chunk-JBIN7W2B.js";import"./chunk-FSRSK4LY.js";import{a as ht}from"./chunk-FKVZRPV5.js";import{a as st,b as lt,c as nt,d as Ee,e as de,f as H}from"./chunk-HEAQVSNS.js";import{a as fe,b as Ae,c as Ke,d as ut,e as pe}from"./chunk-WUWBZPUK.js";import{d as ge,f as gt,g as ft,h as pt,i as xt,l as We,o as bt}from"./chunk-Y4Q25F6X.js";import"./chunk-T2IE5GKA.js";import{a as o,d as Xe,e as Qt,f as Jt,g as Bt,i as mt}from"./chunk-YKXDMIHQ.js";var j=Xe(Qt(),1);var xe=Xe(Jt(),1);var t=Xe(Bt(),1);var Ht=/["\\\u0000-\u001F\uD800-\uDFFF]/,Dt=o(s=>Ht.test(s)?JSON.stringify(s):`"${s}"`,"ot"),ct=o(s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(typeof s=="number"){if(Number.isNaN(s))return"nan";if(s===1/0)return"inf";if(s===-1/0)return"-inf";if(Object.is(s,-0))return"-0"}if(typeof s=="string")return Dt(s);if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s)){let i="[";for(let n=0;n<s.length;n++)n>0&&(i+=","),i+=ct(s[n]);return i+"]"}let e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){let i=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let l=s,a=Object.keys(l).sort(),r="{",u=!0;for(let i of a){let n=l[i];n!==void 0&&(u?u=!1:r+=",",r+=Dt(i),r+=":",r+=ct(n))}return r+"}"},"Ze"),jt=o((s,e,l)=>`${s}:${e}:${ct(l??{})}`,"ht"),Pt=o((s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,"gt"),Ut=o((s,e)=>Pt(s,e),"Jt"),Wt=o(s=>Pt(s.kind,s),"Vt"),ot=o(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Gt=o(s=>Array.isArray(s?.series)?s.series:[],"Gt"),Vt="FUNCTION_NOT_FOUND",Xt=o(s=>{let e=new Map;if(!Array.isArray(s?.series))return e;for(let l of s.series)e.set(jt(l.kind,l.name,l.attributes),l.points);return e},"Xt"),Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=o(s=>{let e=(0,xe.c)(18),{name:l,onOpenTrace:a,traceId:r}=s,u=ge();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=d):d=e[0],d}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let d=`mt-instrument-trace-${l}`,g;return e[3]!==n||e[4]!==d||e[5]!==r?(g=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":d,title:r,children:n}),e[3]=n,e[4]=d,e[5]=r,e[6]=g):g=e[6],g}let S=`mt-instrument-trace-${l}`,v;e[7]!==a||e[8]!==r?(v=o(()=>{a(r)},"y"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==u||e[11]!==r?(w=u("Open the exemplar trace {trace}",{trace:r}),e[10]=u,e[11]=r,e[12]=w):w=e[12];let h;return e[13]!==n||e[14]!==S||e[15]!==v||e[16]!==w?(h=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":S,onClick:v,title:w,type:"button",children:n}),e[13]=n,e[14]=S,e[15]=v,e[16]=w,e[17]=h):h=e[17],h},"Zt"),er=o(s=>{let e=(0,xe.c)(105),{onOpenTrace:l,shardKey:a}=s,r=ge(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:S,errorSource:v}=De(Le.getMetricSeries,u,i),w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let h;e[4]!==a?(h={live:!0,shardKey:a},e[4]=a,e[5]=h):h=e[5];let{data:d}=De(Le.getMetricHistory,w,h),g,y,q,$,c,p,f,x,k,_,N,I,C;if(e[6]!==n||e[7]!==S||e[8]!==v||e[9]!==d||e[10]!==l||e[11]!==r){x=Symbol.for("react.early_return_sentinel");e:{let L=Gt(n),K=xt(v)===Vt;if(S!==null&&!K){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let E;e[27]!==m?(E=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let Q;e[29]!==S||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:S}),e[29]=S,e[30]=r,e[31]=Q):Q=e[31];let J;e[32]!==Q?(J=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=J):J=e[33];let ce;e[34]!==E||e[35]!==J?(ce=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,J]}),e[34]=E,e[35]=J,e[36]=ce):ce=e[36],x=ce;break e}if(L.length===0){x=null;break e}let F=Xt(d),D;e[37]!==r?(D=o(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"z"),e[37]=r,e[38]=D):D=e[38];let P=D;c="flex flex-col gap-2",p="mt-instruments";let A;e[39]!==r?(A=r("Instruments"),e[39]=r,e[40]=A):A=e[40],e[41]!==A?(f=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:A}),e[41]=A,e[42]=f):f=e[42],$=fe,C="overflow-hidden py-0",q=pe,I="px-0",y=st,_="mt-instruments-table";let U;e[43]!==r?(U=r("name"),e[43]=r,e[44]=U):U=e[44];let W;e[45]!==U?(W=(0,t.jsx)(de,{children:U}),e[45]=U,e[46]=W):W=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let V;e[49]!==G?(V=(0,t.jsx)(de,{children:G}),e[49]=G,e[50]=V):V=e[50];let X;e[51]!==r?(X=r("value"),e[51]=r,e[52]=X):X=e[52];let Y;e[53]!==X?(Y=(0,t.jsx)(de,{className:"text-right",children:X}),e[53]=X,e[54]=Y):Y=e[54];let Z;e[55]!==r?(Z=r("count"),e[55]=r,e[56]=Z):Z=e[56];let ee;e[57]!==Z?(ee=(0,t.jsx)(de,{className:"text-right",children:Z}),e[57]=Z,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(de,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(de,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(de,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(de,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==W||e[76]!==V||e[77]!==Y||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(N=(0,t.jsx)(lt,{children:(0,t.jsxs)(Ee,{children:[W,V,Y,ee,re,se,ne,oe]})}),e[75]=W,e[76]=V,e[77]=Y,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=N):N=e[83],g=nt,k=L.map(m=>{let E=Ot(m.attributes),Q=jt(m.kind,m.name,m.attributes),J=(F.get(Q)??[]).map(ce=>Ut(m.kind,ce));return(0,t.jsxs)(Ee,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(H,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(H,{children:(0,t.jsx)(Ue,{variant:Yt[m.kind],children:P(m.kind)})}),(0,t.jsx)(H,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:ot(Wt(m))}),(0,t.jsx)(H,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(H,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${ot(m.min)}\u2013${ot(m.max)}`}),(0,t.jsx)(H,{children:J.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:J,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(H,{className:"font-mono text-xs",children:(0,t.jsx)(Zt,{name:m.name,onOpenTrace:l,traceId:m.exemplarTraceId})}),(0,t.jsx)(H,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"\u2014":E})]},Q)})}e[6]=n,e[7]=S,e[8]=v,e[9]=d,e[10]=l,e[11]=r,e[12]=g,e[13]=y,e[14]=q,e[15]=$,e[16]=c,e[17]=p,e[18]=f,e[19]=x,e[20]=k,e[21]=_,e[22]=N,e[23]=I,e[24]=C}else g=e[12],y=e[13],q=e[14],$=e[15],c=e[16],p=e[17],f=e[18],x=e[19],k=e[20],_=e[21],N=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let T;e[84]!==g||e[85]!==k?(T=(0,t.jsx)(g,{children:k}),e[84]=g,e[85]=k,e[86]=T):T=e[86];let M;e[87]!==y||e[88]!==T||e[89]!==_||e[90]!==N?(M=(0,t.jsxs)(y,{"data-testid":_,children:[N,T]}),e[87]=y,e[88]=T,e[89]=_,e[90]=N,e[91]=M):M=e[91];let b;e[92]!==q||e[93]!==M||e[94]!==I?(b=(0,t.jsx)(q,{className:I,children:M}),e[92]=q,e[93]=M,e[94]=I,e[95]=b):b=e[95];let R;e[96]!==$||e[97]!==b||e[98]!==C?(R=(0,t.jsx)($,{className:C,children:b}),e[96]=$,e[97]=b,e[98]=C,e[99]=R):R=e[99];let z;return e[100]!==c||e[101]!==p||e[102]!==f||e[103]!==R?(z=(0,t.jsxs)("section",{className:c,"data-testid":p,children:[f,R]}),e[100]=c,e[101]=p,e[102]=f,e[103]=R,e[104]=z):z=e[104],z},"er"),tr=o(s=>{let e=(0,xe.c)(74),{aggregate:l,shardResults:a}=s,r=ge(),u;e[0]!==r?(u=r("Shards"),e[0]=r,e[1]=u):u=e[1];let i;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==r?(i=l.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):r("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==u||e[7]!==i?(n=(0,t.jsx)(me,{label:u,testId:"mt-agg-shards",value:i}),e[6]=u,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]!==l.totalRequests||e[12]!==S?(v=(0,t.jsx)(me,{label:S,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=S,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let h;e[16]!==l.totalErrors||e[17]!==w?(h=(0,t.jsx)(me,{label:w,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=w,e[18]=h):h=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let g;e[21]!==l.totalDatabaseSize?(g=We(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=g):g=e[22];let y;e[23]!==d||e[24]!==g?(y=(0,t.jsx)(me,{label:d,testId:"mt-agg-db-size",value:g}),e[23]=d,e[24]=g,e[25]=y):y=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let $;e[28]!==l.hitRate||e[29]!==r?($=l.hitRate===null?r("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=r,e[30]=$):$=e[30];let c;e[31]!==q||e[32]!==$?(c=(0,t.jsx)(me,{label:q,testId:"mt-agg-cache",value:$}),e[31]=q,e[32]=$,e[33]=c):c=e[33];let p;e[34]!==y||e[35]!==c||e[36]!==n||e[37]!==v||e[38]!==h?(p=(0,t.jsxs)("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=(0,t.jsx)(de,{children:f}),e[42]=f,e[43]=x):x=e[43];let k;e[44]!==r?(k=r("requests"),e[44]=r,e[45]=k):k=e[45];let _;e[46]!==k?(_=(0,t.jsx)(de,{children:k}),e[46]=k,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=(0,t.jsx)(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 T;e[54]!==C?(T=(0,t.jsx)(de,{children:C}),e[54]=C,e[55]=T):T=e[55];let M;e[56]!==x||e[57]!==_||e[58]!==I||e[59]!==T?(M=(0,t.jsx)(lt,{children:(0,t.jsxs)(Ee,{children:[x,_,I,T]})}),e[56]=x,e[57]=_,e[58]=I,e[59]=T,e[60]=M):M=e[60];let b;if(e[61]!==a||e[62]!==r){let K;e[64]!==r?(K=o(F=>(0,t.jsxs)(Ee,{"data-testid":`mt-agg-row-${F.shard}`,children:[(0,t.jsx)(H,{children:F.shard}),F.metrics===null?(0,t.jsx)(H,{className:"text-destructive",colSpan:3,children:F.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(H,{className:"tabular-nums",children:F.metrics.requests}),(0,t.jsx)(H,{className:"tabular-nums",children:F.metrics.errors}),(0,t.jsx)(H,{className:"tabular-nums",children:We(F.metrics.databaseSize)})]})]},F.shard),"L"),e[64]=r,e[65]=K):K=e[65],b=a.map(K),e[61]=a,e[62]=r,e[63]=b}else b=e[63];let R;e[66]!==b?(R=(0,t.jsx)(nt,{children:b}),e[66]=b,e[67]=R):R=e[67];let z;e[68]!==M||e[69]!==R?(z=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(st,{"data-testid":"mt-agg-table",children:[M,R]})})}),e[68]=M,e[69]=R,e[70]=z):z=e[70];let L;return e[71]!==p||e[72]!==z?(L=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[p,z]}),e[71]=p,e[72]=z,e[73]=L):L=e[73],L},"tr"),rr=o(s=>{let e=Math.floor(s/1e3),l=Math.floor(e/3600),a=Math.floor(e%3600/60),r=e%60;return l>0?`${l.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${r.toString()}s`:`${r.toString()}s`},"rr"),ar=o((s,e)=>{let l=s+e;return l===0?"\u2014":`${(s/l*100).toFixed(1)}%`},"sr"),Et=o(s=>s<=0?"\u2014":s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"ct"),sr=o(s=>{let e=(0,xe.c)(75),{currentDelta:l,errorRate:a,history:r,latencyPercentiles:u,metrics:i}=s,n=ge(),S;e[0]!==r||e[1]!==n?(S=r.length>=2?(0,t.jsx)(it,{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]!==l||e[4]!==r.length||e[5]!==n?(v=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=l,e[4]=r.length,e[5]=n,e[6]=v):v=e[6];let w;e[7]!==n?(w=n("Requests"),e[7]=n,e[8]=w):w=e[8];let h;e[9]!==i.requests||e[10]!==S||e[11]!==v||e[12]!==w?(h=(0,t.jsx)(me,{chart:S,footer:v,label:w,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=S,e[11]=v,e[12]=w,e[13]=h):h=e[13];let d;e[14]!==a||e[15]!==n?(d=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=d):d=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=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=y):y=e[21];let q;e[22]!==d||e[23]!==g||e[24]!==y?(q=(0,t.jsx)(me,{footer:d,label:g,testId:"mt-errors",value:y}),e[22]=d,e[23]=g,e[24]=y,e[25]=q):q=e[25];let $;e[26]!==u.p90?($=u.p90>0?`P90 ${Et(u.p90)}`:void 0,e[26]=u.p90,e[27]=$):$=e[27];let c;e[28]!==n?(c=n("P95 latency"),e[28]=n,e[29]=c):c=e[29];let p;e[30]!==u.p95?(p=u.p95>0?Et(u.p95):"\u2014",e[30]=u.p95,e[31]=p):p=e[31];let f;e[32]!==c||e[33]!==p||e[34]!==$?(f=(0,t.jsx)(me,{footer:$,label:c,testId:"mt-p95",value:p}),e[32]=c,e[33]=p,e[34]=$,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 k;e[39]!==n?(k=n("Database size"),e[39]=n,e[40]=k):k=e[40];let _;e[41]!==i.databaseSize?(_=We(i.databaseSize),e[41]=i.databaseSize,e[42]=_):_=e[42];let N;e[43]!==x||e[44]!==k||e[45]!==_?(N=(0,t.jsx)(me,{footer:x,label:k,testId:"mt-db-size",value:_}),e[43]=x,e[44]=k,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=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let T;e[52]!==n?(T=n("Uptime"),e[52]=n,e[53]=T):T=e[53];let M;e[54]!==i.uptimeMs?(M=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=M):M=e[55];let b;e[56]!==T||e[57]!==M?(b=(0,t.jsx)(me,{label:T,testId:"mt-uptime",value:M}),e[56]=T,e[57]=M,e[58]=b):b=e[58];let R;e[59]!==n?(R=n("Cache hit rate"),e[59]=n,e[60]=R):R=e[60];let z;e[61]!==i.cache||e[62]!==n?(z=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]=z):z=e[63];let L;e[64]!==R||e[65]!==z?(L=(0,t.jsx)(me,{label:R,testId:"mt-cache",value:z}),e[64]=R,e[65]=z,e[66]=L):L=e[66];let K;return e[67]!==f||e[68]!==N||e[69]!==C||e[70]!==b||e[71]!==L||e[72]!==h||e[73]!==q?(K=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[h,q,f,N,C,b,L]}),e[67]=f,e[68]=N,e[69]=C,e[70]=b,e[71]=L,e[72]=h,e[73]=q,e[74]=K):K=e[74],K},"lr"),Ve=o(s=>s>=100?"critical":s>=50?"warning":"good","Ve"),Pe=o(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"Ae"),Ge=o(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"He"),lr=o(s=>{let e=(0,xe.c)(3),{level:l}=s;if(l==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ue,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(l==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("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=(0,t.jsx)("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},"ar"),nr=o((s,e)=>{let l=[...s];return l.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}}),l},"ir"),ir=o(s=>{let e=(0,xe.c)(161),{queryStats:l}=s,a=ge(),[r,u]=(0,j.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,S]=(0,j.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=o(C=>{C!==null&&u(C)},"y"),e[1]=v):v=e[1];let w=v,h,d,g,y,q,$,c,p,f,x;if(e[2]!==n||e[3]!==l||e[4]!==r||e[5]!==a){g=Symbol.for("react.early_return_sentinel");e:{let C=nr(l,r),T;e[16]!==l?(T=l.filter(or),e[16]=l,e[17]=T):T=e[17];let M=T.length,b;e[18]!==l?(b=l.filter(cr),e[18]=l,e[19]=b):b=e[19];let R=b.length,z;e[20]!==l?(z=l.filter(dr),e[20]=l,e[21]=z):z=e[21];let L=z.length,K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=o(O=>{S(ue=>{let B=new Set(ue);return B.has(O)?B.delete(O):B.add(O),B})},"L"),e[22]=K):K=e[22];let F=K;if(l.length===0){let O;e[23]!==a?(O=a("No query insights yet"),e[23]=a,e[24]=O):O=e[24];let ue;e[25]!==O?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:O}),e[25]=O,e[26]=ue):ue=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 he;e[29]!==B?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let He;e[31]!==ue||e[32]!==he?(He=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=He):He=e[33],g=He;break e}c="space-y-4",p="qi-root";let D;e[34]!==a?(D=a("Critical queries"),e[34]=a,e[35]=D):D=e[35];let P;e[36]!==D?(P=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Ke,{className:"text-sm font-medium",children:D})}),e[36]=D,e[37]=P):P=e[37];let A;e[38]!==M?(A=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:M}),e[38]=M,e[39]=A):A=e[39];let U;e[40]!==a?(U=a(">100ms avg execution"),e[40]=a,e[41]=U):U=e[41];let W;e[42]!==U?(W=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:U}),e[42]=U,e[43]=W):W=e[43];let G;e[44]!==A||e[45]!==W?(G=(0,t.jsxs)(pe,{children:[A,W]}),e[44]=A,e[45]=W,e[46]=G):G=e[46];let V;e[47]!==P||e[48]!==G?(V=(0,t.jsxs)(fe,{children:[P,G]}),e[47]=P,e[48]=G,e[49]=V):V=e[49];let X;e[50]!==a?(X=a("Moderate queries"),e[50]=a,e[51]=X):X=e[51];let Y;e[52]!==X?(Y=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Ke,{className:"text-sm font-medium",children:X})}),e[52]=X,e[53]=Y):Y=e[53];let Z;e[54]!==R?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:R}),e[54]=R,e[55]=Z):Z=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==Z||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[Z,te]}),e[60]=Z,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==Y||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[Y,re]}),e[63]=Y,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Ke,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==L?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:L}),e[70]=L,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let E;e[79]!==le||e[80]!==m?(E=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=E):E=e[81],e[82]!==V||e[83]!==ae||e[84]!==E?(f=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ae,E]}),e[82]=V,e[83]=ae,e[84]=E,e[85]=f):f=e[85];let Q;e[86]!==a?(Q=a("Query leaderboard"),e[86]=a,e[87]=Q):Q=e[87];let J;e[88]!==Q?(J=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=J):J=e[89];let ce;e[90]!==r||e[91]!==a?(ce=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=ce):ce=e[92];let be;e[93]!==ce?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:ce}),e[93]=ce,e[94]=be):be=e[94];let ve;e[95]!==J||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[J,be]}),e[95]=J,e[96]=be,e[97]=ve):ve=e[97];let ye;e[98]!==a?(ye=a("Sort by"),e[98]=a,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==a?(Se=a("Sort queries by"),e[102]=a,e[103]=Se):Se=e[103];let Qe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Qe=(0,t.jsx)(It,{}),e[104]=Qe):Qe=e[104];let we;e[105]!==Se?(we=(0,t.jsx)(Tt,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Qe}),e[105]=Se,e[106]=we):we=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(je,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let Me;e[111]!==a?(Me=a("Avg time"),e[111]=a,e[112]=Me):Me=e[112];let $e;e[113]!==Me?($e=(0,t.jsx)(je,{value:"avgTime",children:Me}),e[113]=Me,e[114]=$e):$e=e[114];let _e;e[115]!==a?(_e=a("Execution count"),e[115]=a,e[116]=_e):_e=e[116];let Ce;e[117]!==_e?(Ce=(0,t.jsx)(je,{value:"execCount",children:_e}),e[117]=_e,e[118]=Ce):Ce=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Te;e[121]!==Ie?(Te=(0,t.jsx)(je,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Te):Te=e[122];let Re;e[123]!==ke||e[124]!==$e||e[125]!==Ce||e[126]!==Te?(Re=(0,t.jsxs)(Rt,{children:[ke,$e,Ce,Te]}),e[123]=ke,e[124]=$e,e[125]=Ce,e[126]=Te,e[127]=Re):Re=e[127];let Oe;e[128]!==r||e[129]!==we||e[130]!==Re?(Oe=(0,t.jsxs)(Ct,{onValueChange:w,value:r,children:[we,Re]}),e[128]=r,e[129]=we,e[130]=Re,e[131]=Oe):Oe=e[131];let ze;e[132]!==Ne||e[133]!==Oe?(ze=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,Oe]}),e[132]=Ne,e[133]=Oe,e[134]=ze):ze=e[134],e[135]!==ve||e[136]!==ze?(x=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,ze]}),e[135]=ve,e[136]=ze,e[137]=x):x=e[137],d=fe;let Fe;e[138]!==a?(Fe=a("Statements"),e[138]=a,e[139]=Fe):Fe=e[139];let Je;e[140]!==Fe?(Je=(0,t.jsx)(Ke,{children:Fe}),e[140]=Fe,e[141]=Je):Je=e[141],$=(0,t.jsxs)(Ae,{children:[Je,(0,t.jsx)(ut,{children:a("{count} tracked statements",{count:C.length})})]}),h=pe,y="space-y-2";let Be;e[142]!==n||e[143]!==a?(Be=o(O=>{let ue=O.normalizedSql,B=n.has(ue),he=Ve(O.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:o(()=>{F(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(lr,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:O.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Pe(O.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Pe(O.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),O.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Pe(O.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:Ge(O.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),B&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:O.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[O.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Pe(O.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ge(O.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Pe(O.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ge(O.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:Ge(O.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=n,e[143]=a,e[144]=Be):Be=e[144],q=C.map(Be)}e[2]=n,e[3]=l,e[4]=r,e[5]=a,e[6]=h,e[7]=d,e[8]=g,e[9]=y,e[10]=q,e[11]=$,e[12]=c,e[13]=p,e[14]=f,e[15]=x}else h=e[6],d=e[7],g=e[8],y=e[9],q=e[10],$=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 k;e[145]!==y||e[146]!==q?(k=(0,t.jsx)("div",{className:y,children:q}),e[145]=y,e[146]=q,e[147]=k):k=e[147];let _;e[148]!==h||e[149]!==k?(_=(0,t.jsx)(h,{children:k}),e[148]=h,e[149]=k,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==$?(N=(0,t.jsxs)(d,{children:[$,_]}),e[151]=d,e[152]=_,e[153]=$,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=(0,t.jsxs)("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},"nr");function or(s){return Ve(s.avgDurationMs)==="critical"}o(or,"or");function cr(s){return Ve(s.avgDurationMs)==="warning"}o(cr,"cr");function dr(s){return Ve(s.avgDurationMs)==="good"}o(dr,"dr");var mr=["1m","5m","15m","1h"],ur=o(s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"ur"),hr=o(s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),"fr"),gr=o(({shardKey:s=""})=>{let e=ge(),[l,a]=(0,j.useState)("15m"),r=De(Le.getQueryInsights,{range:l},{live:!0,shardKey:s}).data,u=hr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===l,className:mt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:o(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ue,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),u.length===0?(0,t.jsx)(ht,{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.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:u,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(yt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(Nt,{data:u,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(vt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(ir,{queryStats:r?.entries??[]})]})},"hr"),fr=gt(Le.getMetrics),pr=o((s,e)=>s?e:"overview","pr"),Er=o(({initialShardKey:s})=>{let e=dt(),l=ge(),{queryShardKey:a,setShardKey:r,shardKey:u}=Mt(s),[i,n]=(0,j.useState)("overview"),[S,v]=(0,j.useState)([]),w=(0,j.useRef)(null),h=(0,j.useRef)(null),d=(0,j.useRef)(!0);(0,j.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let g=zt(a),{data:y,error:q,liveError:$}=De(Le.getMetrics,{},{live:!0,shardKey:a}),c=y??null;(0,j.useEffect)(()=>{if(y===void 0)return;qt(a);let F=y,D=w.current,P=h.current!==null&&h.current!==F.shard;if(h.current=F.shard,w.current=F.requests,P){v([]);return}D!==null&&F.requests>=D&&v(A=>[...A,F.requests-D].slice(-30))},[y,a]);let[p,f]=(0,j.useState)(null),[x,k]=(0,j.useState)(!1),_=o(async()=>{k(!0);let F=Lt(u,wt());try{let D=await Promise.all(F.map(async P=>{try{let A=await e.query(fr,{},ft(P));return{error:null,metrics:A,shard:P===""?A.shard:P}}catch(A){return{error:pt(A),metrics:null,shard:P===""?"__root__":P}}}));d.current&&f(D)}finally{d.current&&k(!1)}},"R"),N=p===null?null:Ft(p),I=c===null||c.requests===0?"\u2014":`${(c.errors/c.requests*100).toFixed(1)}%`,C=S.length>0?S.at(-1):0,T=c?At(c):{p90:0,p95:0},M=(0,j.useMemo)(()=>{if(!c||!("queryStats"in c))return;let F=c.queryStats;if(!(!F||!Array.isArray(F)))return Kt(F)},[c]),b=pr(M!==void 0,i),R=o(()=>{bt(_())},"I"),z=o(()=>{f(null)},"E"),L=o(()=>{n("overview")},"A"),K=o(()=>{n("query-insights")},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(kt,{onChange:r,testId:"mt-shard-input",value:u}),(0,t.jsx)($t,{message:$,prefix:"mt"}),(0,t.jsx)(Ye,{"data-testid":"mt-aggregate",disabled:x,onClick:R,size:"sm",type:"button",variant:"secondary",children:l(x?"Aggregating\u2026":"All shards")}),p!==null&&(0,t.jsx)(Ye,{"data-testid":"mt-aggregate-clear",onClick:z,size:"sm",type:"button",variant:"ghost",children:l("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:_t,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),q!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),M!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("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:L,type:"button",children:l("Overview")}),(0,t.jsxs)("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:K,type:"button",children:[l("Query insights"),M.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:M.length})]})]}),b==="query-insights"&&M!==void 0&&(0,t.jsx)(gr,{shardKey:a}),b==="overview"&&c!==null&&(0,t.jsx)(sr,{currentDelta:C,errorRate:I,history:S,latencyPercentiles:T,metrics:c}),b==="overview"&&c===null&&null,b==="overview"&&(0,t.jsx)(er,{onOpenTrace:g,shardKey:a}),b==="overview"&&N!==null&&p!==null&&(0,t.jsx)(tr,{aggregate:N,shardResults:p})]})},"jr");export{Er as MetricsPanel};