@lunora/studio 1.0.0-alpha.375 → 1.0.0-alpha.377

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 (218) hide show
  1. package/dist/index.d.mts +18 -8
  2. package/dist/index.d.ts +18 -8
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.d.mts +1 -1
  5. package/dist/mount.d.ts +1 -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/ai-usage-panel.mjs +1 -1
  28. package/dist/packem_chunks/assistant-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-audit-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/privacy-requests-panel.mjs +1 -1
  43. package/dist/packem_chunks/queues-panel.mjs +1 -1
  44. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  45. package/dist/packem_chunks/rls-panel.mjs +1 -1
  46. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  47. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  48. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  49. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  50. package/dist/packem_chunks/traces-panel.mjs +1 -1
  51. package/dist/packem_chunks/users-panel.mjs +1 -1
  52. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  53. package/dist/packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs +1 -0
  54. package/dist/packem_shared/{ApiDocsPanel-xqgxgYCy.mjs → ApiDocsPanel-sEDqUNQq.mjs} +1 -1
  55. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs +1 -0
  56. package/dist/packem_shared/{DataBrowser-BrRWqnCr.mjs → DataBrowser-CkVOu6py.mjs} +1 -1
  57. package/dist/packem_shared/GlobalDataBrowser-l2ECwXCm.mjs +1 -0
  58. package/dist/packem_shared/{HomePanel-CHq9VBrh.mjs → HomePanel-c7as4tvl.mjs} +1 -1
  59. package/dist/packem_shared/{MigrationsPanel-BWGgOwmX.mjs → MigrationsPanel-BQol4Un1.mjs} +1 -1
  60. package/dist/packem_shared/{ScheduledJobs-QCTRdugp.mjs → ScheduledJobs-Du8ZGL7v.mjs} +1 -1
  61. package/dist/packem_shared/{Studio-pDEG4JTx.mjs → Studio-BmbkaUrx.mjs} +1 -1
  62. package/dist/packem_shared/{StudioApp-C4IOJPR6.mjs → StudioApp-CsyDnrg2.mjs} +1 -1
  63. package/dist/packem_shared/{advisor-view-Dj-mZPAq.mjs → advisor-view-gtf_DhUU.mjs} +1 -1
  64. package/dist/packem_shared/{app.d-BXrVLb99.d.mts → app.d-DpxFQ0qO.d.mts} +14 -0
  65. package/dist/packem_shared/{app.d-BXrVLb99.d.ts → app.d-DpxFQ0qO.d.ts} +14 -0
  66. package/dist/packem_shared/{assistant-provider-BQG7QZAu.mjs → assistant-provider-Dw0roZh3.mjs} +1 -1
  67. package/dist/packem_shared/{error-alert-BzZfqmf4.mjs → error-alert-3AR_-s_s.mjs} +1 -1
  68. package/dist/packem_shared/{home-panel-DTWHlX5S.mjs → home-panel-TpxiaHgB.mjs} +1 -1
  69. package/dist/packem_shared/{studio-DE7i2--m.mjs → studio-DZlpp4Vx.mjs} +1 -1
  70. package/dist/packem_shared/{table-list-sidebar-DUnCjFL7.mjs → table-list-sidebar-Bfmg04MD.mjs} +1 -1
  71. package/dist/packem_shared/{use-assistant-rpc-DCC6ph2u.mjs → use-assistant-rpc-AKu8hvPm.mjs} +1 -1
  72. package/dist/standalone/{chunk-RKPVI2PI.js → chunk-22OYIN7Q.js} +1 -1
  73. package/dist/standalone/{chunk-N7EIHD3H.js → chunk-2BCNWFC5.js} +1 -1
  74. package/dist/standalone/{chunk-2MZLFQR5.js → chunk-2BUAJRHS.js} +1 -1
  75. package/dist/standalone/{chunk-J45HAKBU.js → chunk-2KTN53PK.js} +1 -1
  76. package/dist/standalone/chunk-2NUCBQFU.js +1 -0
  77. package/dist/standalone/{chunk-PIOHOROI.js → chunk-2SKEPLDB.js} +1 -1
  78. package/dist/standalone/{chunk-BQS3C5V3.js → chunk-3FVWKQLT.js} +1 -1
  79. package/dist/standalone/{chunk-C4BS3LHQ.js → chunk-3J26FAKO.js} +1 -1
  80. package/dist/standalone/{chunk-XZHTVLDG.js → chunk-446DKR7O.js} +1 -1
  81. package/dist/standalone/{chunk-Z6WEYWT7.js → chunk-44ZHY2EU.js} +1 -1
  82. package/dist/standalone/{chunk-4EPW63HS.js → chunk-4AG356VE.js} +1 -1
  83. package/dist/standalone/{chunk-ZSWW2UGP.js → chunk-4KPATTV6.js} +1 -1
  84. package/dist/standalone/{chunk-XITLHKKR.js → chunk-4RPRUFVA.js} +1 -1
  85. package/dist/standalone/{chunk-HFBSWKJS.js → chunk-4SY2N2RS.js} +1 -1
  86. package/dist/standalone/{chunk-KBYFBEG2.js → chunk-553O7ESU.js} +1 -1
  87. package/dist/standalone/{chunk-JPCVFWR5.js → chunk-5Z6PF6KC.js} +1 -1
  88. package/dist/standalone/{chunk-ILSJ22BK.js → chunk-5ZZO5UEC.js} +1 -1
  89. package/dist/standalone/chunk-6ALD476Y.js +8 -0
  90. package/dist/standalone/{chunk-TDJQ7HQM.js → chunk-6BWAMHRF.js} +1 -1
  91. package/dist/standalone/{chunk-2U6Z7A6C.js → chunk-6ORWM6ZT.js} +1 -1
  92. package/dist/standalone/{chunk-4RGKUS3H.js → chunk-74OCXJGH.js} +1 -1
  93. package/dist/standalone/{chunk-CBACG4XF.js → chunk-7E3RA4X6.js} +1 -1
  94. package/dist/standalone/{chunk-645S7KRU.js → chunk-7VZPHPTH.js} +1 -1
  95. package/dist/standalone/chunk-7WGZSDRS.js +2 -0
  96. package/dist/standalone/{chunk-GWNGVKLG.js → chunk-A6TVTNKO.js} +1 -1
  97. package/dist/standalone/{chunk-6G3E4PJ2.js → chunk-ADABTCDI.js} +1 -1
  98. package/dist/standalone/{chunk-WFXS3YRM.js → chunk-AFIY2ATE.js} +1 -1
  99. package/dist/standalone/{chunk-GXTSE66Z.js → chunk-AFLNQEZ5.js} +1 -1
  100. package/dist/standalone/{chunk-AERXMIND.js → chunk-AKOBXMLE.js} +1 -1
  101. package/dist/standalone/{chunk-MJWIIV2C.js → chunk-AMWPN5JC.js} +1 -1
  102. package/dist/standalone/{chunk-NGGTRLCC.js → chunk-APHDGDQX.js} +1 -1
  103. package/dist/standalone/{chunk-RDS46R5R.js → chunk-BMDQFH65.js} +1 -1
  104. package/dist/standalone/{chunk-7SNL633X.js → chunk-BS77NGL6.js} +1 -1
  105. package/dist/standalone/{chunk-OVEOTKK5.js → chunk-CD6Y4HMA.js} +1 -1
  106. package/dist/standalone/{chunk-HZU4WF4X.js → chunk-CF2MJGHC.js} +1 -1
  107. package/dist/standalone/{chunk-6VOBO5QL.js → chunk-CJJSRDJQ.js} +1 -1
  108. package/dist/standalone/{chunk-QHKR5JW4.js → chunk-COLRWCN5.js} +1 -1
  109. package/dist/standalone/{chunk-F5WJCL3F.js → chunk-CTIZP3XO.js} +1 -1
  110. package/dist/standalone/{chunk-QNY5EEBN.js → chunk-CVPH3ATG.js} +1 -1
  111. package/dist/standalone/{chunk-OSHODLMU.js → chunk-D76SLSGV.js} +1 -1
  112. package/dist/standalone/{chunk-LA76GGAT.js → chunk-D7SKD7RO.js} +1 -1
  113. package/dist/standalone/{chunk-PIQ4A4BZ.js → chunk-DB332GVZ.js} +1 -1
  114. package/dist/standalone/{chunk-OODTH4NA.js → chunk-DBOXAUII.js} +1 -1
  115. package/dist/standalone/{chunk-SKZNH5QQ.js → chunk-DBV2V6OY.js} +1 -1
  116. package/dist/standalone/{chunk-JAAXDIR5.js → chunk-DIZP54PG.js} +1 -1
  117. package/dist/standalone/{chunk-2DT3QG6Q.js → chunk-DRHZZ7IN.js} +1 -1
  118. package/dist/standalone/{chunk-4ADB7TWC.js → chunk-EC3XQQRV.js} +1 -1
  119. package/dist/standalone/{chunk-3D67ZJRW.js → chunk-EDL46BPM.js} +1 -1
  120. package/dist/standalone/{chunk-4PI2OSSP.js → chunk-EOFWXI3T.js} +1 -1
  121. package/dist/standalone/{chunk-LR2FBYCC.js → chunk-EYDMS22X.js} +1 -1
  122. package/dist/standalone/{chunk-B76HLC52.js → chunk-F4KT43QZ.js} +1 -1
  123. package/dist/standalone/chunk-FH4R64SS.js +5 -0
  124. package/dist/standalone/{chunk-IJNP6YSD.js → chunk-GBVYBBIF.js} +1 -1
  125. package/dist/standalone/{chunk-RDS72J4I.js → chunk-GQF53GWD.js} +1 -1
  126. package/dist/standalone/{chunk-FGZ73BFG.js → chunk-GWRKSV2Q.js} +1 -1
  127. package/dist/standalone/{chunk-2EB7FN5S.js → chunk-H6VTIXVB.js} +1 -1
  128. package/dist/standalone/{chunk-RUQTILJN.js → chunk-IAVAD545.js} +1 -1
  129. package/dist/standalone/{chunk-ELUYMLPL.js → chunk-IDK6WH4X.js} +1 -1
  130. package/dist/standalone/{chunk-RHYQB4RH.js → chunk-IEMQNFZ7.js} +1 -1
  131. package/dist/standalone/{chunk-KTK4NDWQ.js → chunk-IQ5CIBXJ.js} +1 -1
  132. package/dist/standalone/{chunk-4B54WP4R.js → chunk-IYN56FBP.js} +1 -1
  133. package/dist/standalone/{chunk-EX2DUBRT.js → chunk-JB5VB7PX.js} +1 -1
  134. package/dist/standalone/{chunk-HCOF7HOM.js → chunk-JNWK5MJC.js} +1 -1
  135. package/dist/standalone/{chunk-FT3BWJVP.js → chunk-JQH5M3FB.js} +1 -1
  136. package/dist/standalone/{chunk-WSG35SRF.js → chunk-JUTXPZQK.js} +1 -1
  137. package/dist/standalone/chunk-K24LZAP2.js +7 -0
  138. package/dist/standalone/{chunk-FWOOA2ZR.js → chunk-K7Z7UTJJ.js} +1 -1
  139. package/dist/standalone/{chunk-6YBEKVUG.js → chunk-KMA6JR2E.js} +1 -1
  140. package/dist/standalone/{chunk-YUVGMKHG.js → chunk-L27FKJTG.js} +1 -1
  141. package/dist/standalone/{chunk-LFKKTGEF.js → chunk-LD6JOIEW.js} +1 -1
  142. package/dist/standalone/{chunk-GH6CI2P2.js → chunk-LIQOSH6R.js} +1 -1
  143. package/dist/standalone/{chunk-UBX5ZPLV.js → chunk-LMCBMC2V.js} +1 -1
  144. package/dist/standalone/chunk-LYVYUTQY.js +1 -0
  145. package/dist/standalone/{chunk-ZCOMJH2I.js → chunk-M5VU6MF5.js} +1 -1
  146. package/dist/standalone/{chunk-ASD6UAND.js → chunk-M7EHYZ6R.js} +1 -1
  147. package/dist/standalone/{chunk-D3DZZHZA.js → chunk-MAZES4KJ.js} +1 -1
  148. package/dist/standalone/{chunk-42RZZFLX.js → chunk-MBA6SBBO.js} +1 -1
  149. package/dist/standalone/chunk-MHZNDDGI.js +1 -0
  150. package/dist/standalone/{chunk-JB3DZ2PJ.js → chunk-MUCEG53A.js} +1 -1
  151. package/dist/standalone/{chunk-R52GVSS2.js → chunk-MWF4AQ5B.js} +1 -1
  152. package/dist/standalone/{chunk-WJA2IGZC.js → chunk-MWMVXHQM.js} +1 -1
  153. package/dist/standalone/{chunk-CAEJQOMU.js → chunk-MXYZQCDR.js} +1 -1
  154. package/dist/standalone/{chunk-2CPMCEHD.js → chunk-N33IYFIX.js} +1 -1
  155. package/dist/standalone/{chunk-IELLWQGA.js → chunk-N6H4WQHD.js} +1 -1
  156. package/dist/standalone/{chunk-QRA7AKYO.js → chunk-N7FOBAV3.js} +1 -1
  157. package/dist/standalone/{chunk-D6CDIHHL.js → chunk-NSG5VFIL.js} +1 -1
  158. package/dist/standalone/{chunk-25WEL5RI.js → chunk-NXNTS5G2.js} +1 -1
  159. package/dist/standalone/{chunk-TW4O2BA5.js → chunk-O5QATFN3.js} +3 -3
  160. package/dist/standalone/{chunk-SUUBCPUD.js → chunk-O6HYP4FT.js} +1 -1
  161. package/dist/standalone/{chunk-6FPV3EK2.js → chunk-ODEIAS3V.js} +1 -1
  162. package/dist/standalone/{chunk-QN66FO5B.js → chunk-OR2CSCVB.js} +1 -1
  163. package/dist/standalone/{chunk-EAPNLM2Q.js → chunk-OVXKPVKS.js} +1 -1
  164. package/dist/standalone/{chunk-D65UVZIA.js → chunk-OWRWDDJT.js} +1 -1
  165. package/dist/standalone/chunk-OYCDWIG2.js +33 -0
  166. package/dist/standalone/{chunk-VUOEJJUH.js → chunk-OZID3UYF.js} +1 -1
  167. package/dist/standalone/{chunk-TUFOWHEF.js → chunk-P37L55FP.js} +1 -1
  168. package/dist/standalone/{chunk-XWVFKYZV.js → chunk-PGK4SNG3.js} +1 -1
  169. package/dist/standalone/{chunk-VDSTHVWZ.js → chunk-PP75AWAZ.js} +1 -1
  170. package/dist/standalone/{chunk-VNH4OBJS.js → chunk-QF743FSL.js} +1 -1
  171. package/dist/standalone/{chunk-52ULLZJX.js → chunk-QH6WAQIT.js} +1 -1
  172. package/dist/standalone/{chunk-ONTGYVAN.js → chunk-QLZGKBOW.js} +1 -1
  173. package/dist/standalone/{chunk-3BQD5ITB.js → chunk-QURAUVUB.js} +1 -1
  174. package/dist/standalone/{chunk-G5REMLEG.js → chunk-QVFWLGGW.js} +1 -1
  175. package/dist/standalone/chunk-R3RIZDUS.js +1 -0
  176. package/dist/standalone/{chunk-4EQAUONF.js → chunk-RNTEWZRJ.js} +1 -1
  177. package/dist/standalone/{chunk-LCIDEYA4.js → chunk-RNVK7QCW.js} +1 -1
  178. package/dist/standalone/{chunk-QMULO5AP.js → chunk-RQFK2LYP.js} +1 -1
  179. package/dist/standalone/{chunk-JMZT3CEW.js → chunk-SCTYLLJT.js} +1 -1
  180. package/dist/standalone/{chunk-O3AZ7JKE.js → chunk-T7UKRA6J.js} +1 -1
  181. package/dist/standalone/{chunk-MTX62MQ7.js → chunk-TKALUM7Y.js} +1 -1
  182. package/dist/standalone/{chunk-CGXIERYO.js → chunk-TLOLN6RV.js} +1 -1
  183. package/dist/standalone/{chunk-FK2S7VR4.js → chunk-UBAPZPI2.js} +1 -1
  184. package/dist/standalone/{chunk-MWYGLPDV.js → chunk-VB3BKQCE.js} +1 -1
  185. package/dist/standalone/{chunk-DDTWGWM4.js → chunk-VH4NT2WJ.js} +1 -1
  186. package/dist/standalone/{chunk-MGFELY5Q.js → chunk-VRAOBE6E.js} +1 -1
  187. package/dist/standalone/{chunk-VXZAS5VS.js → chunk-VSYZL2WH.js} +1 -1
  188. package/dist/standalone/{chunk-S36FVTKK.js → chunk-W7CLOQOU.js} +1 -1
  189. package/dist/standalone/chunk-WUWBRYJG.js +1 -0
  190. package/dist/standalone/{chunk-M4TCBPSY.js → chunk-XMJB5JOF.js} +1 -1
  191. package/dist/standalone/{chunk-HCWB4UDT.js → chunk-XNZ4WUSQ.js} +1 -1
  192. package/dist/standalone/{chunk-DHH7WHXQ.js → chunk-Y5HPCYBO.js} +1 -1
  193. package/dist/standalone/chunk-Y6OVSHPH.js +1 -0
  194. package/dist/standalone/{chunk-6IRGBPDN.js → chunk-YKUO2I5M.js} +1 -1
  195. package/dist/standalone/{chunk-XLYFGUEF.js → chunk-YNCZVYCO.js} +1 -1
  196. package/dist/standalone/chunk-YOUTNV5Y.js +1 -0
  197. package/dist/standalone/{chunk-A2Q3TGIQ.js → chunk-YYJGL32M.js} +1 -1
  198. package/dist/standalone/{chunk-2IOS27FL.js → chunk-ZAWNUXWP.js} +1 -1
  199. package/dist/standalone/{chunk-KYN4A72O.js → chunk-ZIUDJD6M.js} +1 -1
  200. package/dist/standalone/{chunk-HPD2PZP2.js → chunk-ZUVDTKXM.js} +1 -1
  201. package/dist/standalone/studio.js +3 -3
  202. package/package.json +13 -13
  203. package/dist/packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs +0 -1
  204. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs +0 -1
  205. package/dist/packem_shared/GlobalDataBrowser-DB1B-WAN.mjs +0 -1
  206. package/dist/standalone/chunk-6A6AELDJ.js +0 -1
  207. package/dist/standalone/chunk-ACWAMBGT.js +0 -1
  208. package/dist/standalone/chunk-BG2CJOVS.js +0 -1
  209. package/dist/standalone/chunk-BKI3JMXQ.js +0 -1
  210. package/dist/standalone/chunk-KGLIQIZU.js +0 -1
  211. package/dist/standalone/chunk-ODLNNVP2.js +0 -7
  212. package/dist/standalone/chunk-PGJOTPWC.js +0 -1
  213. package/dist/standalone/chunk-PUK3H4RN.js +0 -33
  214. package/dist/standalone/chunk-QAOZXPLU.js +0 -1
  215. package/dist/standalone/chunk-RTS5G3ET.js +0 -2
  216. package/dist/standalone/chunk-USVLFLZL.js +0 -5
  217. package/dist/standalone/chunk-Z7ZGAQ5J.js +0 -8
  218. /package/dist/standalone/{chunk-NGVP66OH.js → chunk-QHVUXMRV.js} +0 -0
@@ -1 +1 @@
1
- import{c as me}from"react/compiler-runtime";import{useState as be,useRef as Je,useEffect as We}from"react";import{L as gt}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as pt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as xt}from"../packem_shared/use-open-trace-BJKMJjeS.mjs";import{u as bt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ge}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as yt}from"../packem_shared/cf-links-BPy1pJRO.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as Tt,c as qt}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as _t,r as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as pe,a as xe,b as Be,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as ie,T as ct,c as oe,a as dt,d as mt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as f,jsx as s,Fragment as Ze}from"react/jsx-runtime";import{aggregateMetrics as At,enrichQueryStats as It,shardsToAggregate as $t,computeLatencyPercentiles as Dt}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ce}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as st,c as Et,h as Lt}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as rt,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as Ot,LineChart as zt,Line as Kt}from"recharts";import{E as Pt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Bt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,l)=>`${i}:${e}:${kt(l??{})}`,ht=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ht(i,e),Gt=i=>ht(i.kind,i),Ye=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Yt=i=>Array.isArray(i?.series)?i.series:[],Jt="FUNCTION_NOT_FOUND",Wt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const l of i.series)e.set(ut(l.kind,l.name,l.attributes),l.points);return e},Xt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=me(18),{name:l,onOpenTrace:r,traceId:t}=i,o=ge();if(t===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let n;e[1]!==t?(n=t.slice(0,8),e[1]=t,e[2]=n):n=e[2];const a=n;if(r===void 0){const d=`mt-instrument-trace-${l}`;let c;return e[3]!==a||e[4]!==d||e[5]!==t?(c=s("span",{className:"text-muted-foreground","data-testid":d,title:t,children:a}),e[3]=a,e[4]=d,e[5]=t,e[6]=c):c=e[6],c}const m=`mt-instrument-trace-${l}`;let p;e[7]!==r||e[8]!==t?(p=()=>{r(t)},e[7]=r,e[8]=t,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==t?(h=o("Open the exemplar trace {trace}",{trace:t}),e[10]=o,e[11]=t,e[12]=h):h=e[12];let u;return e[13]!==a||e[14]!==m||e[15]!==p||e[16]!==h?(u=s("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:a}),e[13]=a,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},es=i=>{const e=me(105),{onOpenTrace:l,shardKey:r}=i,t=ge();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let n;e[1]!==r?(n={live:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:a,error:m,errorSource:p}=je(Fe.getMetricSeries,o,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:d}=je(Fe.getMetricHistory,h,u);let c,x,g,v,b,S,y,w,M,_,N,$,q;if(e[6]!==a||e[7]!==m||e[8]!==p||e[9]!==d||e[10]!==l||e[11]!==t){w=Symbol.for("react.early_return_sentinel");e:{const E=Yt(a),L=Nt(p)===Jt;if(m!==null&&!L){let T;e[25]!==t?(T=t("Instruments"),e[25]=t,e[26]=T):T=e[26];let O;e[27]!==T?(O=s("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[27]=T,e[28]=O):O=e[28];let z;e[29]!==m||e[30]!==t?(z=t("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=t,e[31]=z):z=e[31];let K;e[32]!==z?(K=s("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:z}),e[32]=z,e[33]=K):K=e[33];let P;e[34]!==O||e[35]!==K?(P=f("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[O,K]}),e[34]=O,e[35]=K,e[36]=P):P=e[36],w=P;break e}if(E.length===0){w=null;break e}const F=Wt(d);let de;e[37]!==t?(de=T=>t(T==="counter"?"Counter":T==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=de):de=e[38];const fe=de;b="flex flex-col gap-2",S="mt-instruments";let Q;e[39]!==t?(Q=t("Instruments"),e[39]=t,e[40]=Q):Q=e[40],e[41]!==Q?(y=s("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=y):y=e[42],v=pe,q="overflow-hidden py-0",g=xe,$="px-0",x=ct,_="mt-instruments-table";let H;e[43]!==t?(H=t("name"),e[43]=t,e[44]=H):H=e[44];let U;e[45]!==H?(U=s(oe,{children:H}),e[45]=H,e[46]=U):U=e[46];let j;e[47]!==t?(j=t("kind"),e[47]=t,e[48]=j):j=e[48];let V;e[49]!==j?(V=s(oe,{children:j}),e[49]=j,e[50]=V):V=e[50];let G;e[51]!==t?(G=t("value"),e[51]=t,e[52]=G):G=e[52];let Y;e[53]!==G?(Y=s(oe,{className:"text-right",children:G}),e[53]=G,e[54]=Y):Y=e[54];let J;e[55]!==t?(J=t("count"),e[55]=t,e[56]=J):J=e[56];let W;e[57]!==J?(W=s(oe,{className:"text-right",children:J}),e[57]=J,e[58]=W):W=e[58];let X;e[59]!==t?(X=t("range"),e[59]=t,e[60]=X):X=e[60];let Z;e[61]!==X?(Z=s(oe,{className:"text-right",children:X}),e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==t?(ee=t("trend"),e[63]=t,e[64]=ee):ee=e[64];let te;e[65]!==ee?(te=s(oe,{children:ee}),e[65]=ee,e[66]=te):te=e[66];let se;e[67]!==t?(se=t("trace"),e[67]=t,e[68]=se):se=e[68];let re;e[69]!==se?(re=s(oe,{children:se}),e[69]=se,e[70]=re):re=e[70];let le;e[71]!==t?(le=t("dimensions"),e[71]=t,e[72]=le):le=e[72];let ae;e[73]!==le?(ae=s(oe,{children:le}),e[73]=le,e[74]=ae):ae=e[74],e[75]!==U||e[76]!==V||e[77]!==Y||e[78]!==W||e[79]!==Z||e[80]!==te||e[81]!==re||e[82]!==ae?(N=s(dt,{children:f(Ve,{children:[U,V,Y,W,Z,te,re,ae]})}),e[75]=U,e[76]=V,e[77]=Y,e[78]=W,e[79]=Z,e[80]=te,e[81]=re,e[82]=ae,e[83]=N):N=e[83],c=mt,M=E.map(T=>{const O=Rt(T.attributes),z=ut(T.kind,T.name,T.attributes),P=(F.get(z)??[]).map(ue=>Vt(T.kind,ue));return f(Ve,{"data-testid":`mt-instrument-${T.name}`,children:[s(ie,{className:"font-mono text-xs",title:T.functionPath,children:T.name}),s(ie,{children:s(et,{variant:Xt[T.kind],children:fe(T.kind)})}),s(ie,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${T.name}`,children:Ye(Gt(T))}),s(ie,{className:"text-right tabular-nums text-muted-foreground",children:T.count.toLocaleString()}),s(ie,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:T.min===T.max?"—":`${Ye(T.min)}–${Ye(T.max)}`}),s(ie,{children:P.length>=2?s(ft,{ariaLabel:t("{name} trend",{name:T.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${T.name}`}):s("span",{className:"text-xs text-muted-foreground",children:"—"})}),s(ie,{className:"font-mono text-xs",children:s(Zt,{name:T.name,onOpenTrace:l,traceId:T.exemplarTraceId})}),s(ie,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:O,children:O===""?"—":O})]},z)})}e[6]=a,e[7]=m,e[8]=p,e[9]=d,e[10]=l,e[11]=t,e[12]=c,e[13]=x,e[14]=g,e[15]=v,e[16]=b,e[17]=S,e[18]=y,e[19]=w,e[20]=M,e[21]=_,e[22]=N,e[23]=$,e[24]=q}else c=e[12],x=e[13],g=e[14],v=e[15],b=e[16],S=e[17],y=e[18],w=e[19],M=e[20],_=e[21],N=e[22],$=e[23],q=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==c||e[85]!==M?(C=s(c,{children:M}),e[84]=c,e[85]=M,e[86]=C):C=e[86];let k;e[87]!==x||e[88]!==C||e[89]!==_||e[90]!==N?(k=f(x,{"data-testid":_,children:[N,C]}),e[87]=x,e[88]=C,e[89]=_,e[90]=N,e[91]=k):k=e[91];let R;e[92]!==g||e[93]!==k||e[94]!==$?(R=s(g,{className:$,children:k}),e[92]=g,e[93]=k,e[94]=$,e[95]=R):R=e[95];let A;e[96]!==v||e[97]!==R||e[98]!==q?(A=s(v,{className:q,children:R}),e[96]=v,e[97]=R,e[98]=q,e[99]=A):A=e[99];let I;return e[100]!==b||e[101]!==S||e[102]!==y||e[103]!==A?(I=f("section",{className:b,"data-testid":S,children:[y,A]}),e[100]=b,e[101]=S,e[102]=y,e[103]=A,e[104]=I):I=e[104],I},ts=i=>{const e=me(74),{aggregate:l,shardResults:r}=i,t=ge();let o;e[0]!==t?(o=t("Shards"),e[0]=t,e[1]=o):o=e[1];let n;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==t?(n=l.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):t("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=t,e[5]=n):n=e[5];let a;e[6]!==o||e[7]!==n?(a=s(ce,{label:o,testId:"mt-agg-shards",value:n}),e[6]=o,e[7]=n,e[8]=a):a=e[8];let m;e[9]!==t?(m=t("Total requests"),e[9]=t,e[10]=m):m=e[10];let p;e[11]!==l.totalRequests||e[12]!==m?(p=s(ce,{label:m,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t?(h=t("Total errors"),e[14]=t,e[15]=h):h=e[15];let u;e[16]!==l.totalErrors||e[17]!==h?(u=s(ce,{label:h,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=h,e[18]=u):u=e[18];let d;e[19]!==t?(d=t("Total database size"),e[19]=t,e[20]=d):d=e[20];let c;e[21]!==l.totalDatabaseSize?(c=Xe(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=c):c=e[22];let x;e[23]!==d||e[24]!==c?(x=s(ce,{label:d,testId:"mt-agg-db-size",value:c}),e[23]=d,e[24]=c,e[25]=x):x=e[25];let g;e[26]!==t?(g=t("Combined cache hit rate"),e[26]=t,e[27]=g):g=e[27];let v;e[28]!==l.hitRate||e[29]!==t?(v=l.hitRate===null?t("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=t,e[30]=v):v=e[30];let b;e[31]!==g||e[32]!==v?(b=s(ce,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=b):b=e[33];let S;e[34]!==x||e[35]!==b||e[36]!==a||e[37]!==p||e[38]!==u?(S=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[a,p,u,x,b]}),e[34]=x,e[35]=b,e[36]=a,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==t?(y=t("shard"),e[40]=t,e[41]=y):y=e[41];let w;e[42]!==y?(w=s(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let M;e[44]!==t?(M=t("requests"),e[44]=t,e[45]=M):M=e[45];let _;e[46]!==M?(_=s(oe,{children:M}),e[46]=M,e[47]=_):_=e[47];let N;e[48]!==t?(N=t("errors"),e[48]=t,e[49]=N):N=e[49];let $;e[50]!==N?($=s(oe,{children:N}),e[50]=N,e[51]=$):$=e[51];let q;e[52]!==t?(q=t("db size"),e[52]=t,e[53]=q):q=e[53];let C;e[54]!==q?(C=s(oe,{children:q}),e[54]=q,e[55]=C):C=e[55];let k;e[56]!==w||e[57]!==_||e[58]!==$||e[59]!==C?(k=s(dt,{children:f(Ve,{children:[w,_,$,C]})}),e[56]=w,e[57]=_,e[58]=$,e[59]=C,e[60]=k):k=e[60];let R;if(e[61]!==r||e[62]!==t){let L;e[64]!==t?(L=F=>f(Ve,{"data-testid":`mt-agg-row-${F.shard}`,children:[s(ie,{children:F.shard}),F.metrics===null?s(ie,{className:"text-destructive",colSpan:3,children:F.error??t("unreachable")}):f(Ze,{children:[s(ie,{className:"tabular-nums",children:F.metrics.requests}),s(ie,{className:"tabular-nums",children:F.metrics.errors}),s(ie,{className:"tabular-nums",children:Xe(F.metrics.databaseSize)})]})]},F.shard),e[64]=t,e[65]=L):L=e[65],R=r.map(L),e[61]=r,e[62]=t,e[63]=R}else R=e[63];let A;e[66]!==R?(A=s(mt,{children:R}),e[66]=R,e[67]=A):A=e[67];let I;e[68]!==k||e[69]!==A?(I=s(pe,{className:"overflow-hidden py-0",children:s(xe,{className:"px-0",children:f(ct,{"data-testid":"mt-agg-table",children:[k,A]})})}),e[68]=k,e[69]=A,e[70]=I):I=e[70];let E;return e[71]!==S||e[72]!==I?(E=f("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,I]}),e[71]=S,e[72]=I,e[73]=E):E=e[73],E},ss=i=>{const e=me(75),{currentDelta:l,errorRate:r,history:t,latencyPercentiles:o,metrics:n}=i,a=ge(),{cache:m}=n;let p;e[0]!==t||e[1]!==a?(p=t.length>=2?s(ft,{ariaLabel:a("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==l||e[4]!==t.length||e[5]!==a?(h=t.length>=2?f(Ze,{children:[s("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",a("last interval")]}):s("span",{"data-testid":"mt-sparkline-empty",children:a("collecting samples…")}),e[3]=l,e[4]=t.length,e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a?(u=a("Requests"),e[7]=a,e[8]=u):u=e[8];let d;e[9]!==n.requests||e[10]!==p||e[11]!==h||e[12]!==u?(d=s(ce,{chart:p,footer:h,label:u,testId:"mt-requests",value:n.requests}),e[9]=n.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=d):d=e[13];let c;e[14]!==r||e[15]!==a?(c=a("{rate} error rate",{rate:r}),e[14]=r,e[15]=a,e[16]=c):c=e[16];let x;e[17]!==a?(x=a("Errors"),e[17]=a,e[18]=x):x=e[18];let g;e[19]!==r||e[20]!==n.errors?(g=f(Ze,{children:[n.errors," (",r,")"]}),e[19]=r,e[20]=n.errors,e[21]=g):g=e[21];let v;e[22]!==c||e[23]!==x||e[24]!==g?(v=s(ce,{footer:c,label:x,testId:"mt-errors",value:g}),e[22]=c,e[23]=x,e[24]=g,e[25]=v):v=e[25];let b;e[26]!==o.p90?(b=o.p90>0?`P90 ${st(o.p90)}`:void 0,e[26]=o.p90,e[27]=b):b=e[27];let S;e[28]!==a?(S=a("P95 latency"),e[28]=a,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?st(o.p95):"—",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==b?(w=s(ce,{footer:b,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=b,e[35]=w):w=e[35];let M;e[36]!==m||e[37]!==a?(M=m?`${m.entries.toLocaleString()} ${a("cache entries")}`:void 0,e[36]=m,e[37]=a,e[38]=M):M=e[38];let _;e[39]!==a?(_=a("Database size"),e[39]=a,e[40]=_):_=e[40];let N;e[41]!==n.databaseSize?(N=Xe(n.databaseSize),e[41]=n.databaseSize,e[42]=N):N=e[42];let $;e[43]!==M||e[44]!==_||e[45]!==N?($=s(ce,{footer:M,label:_,testId:"mt-db-size",value:N}),e[43]=M,e[44]=_,e[45]=N,e[46]=$):$=e[46];let q;e[47]!==a?(q=a("Shard"),e[47]=a,e[48]=q):q=e[48];let C;e[49]!==n.shard||e[50]!==q?(C=s(ce,{label:q,testId:"mt-shard",value:n.shard}),e[49]=n.shard,e[50]=q,e[51]=C):C=e[51];let k;e[52]!==a?(k=a("Uptime"),e[52]=a,e[53]=k):k=e[53];let R;e[54]!==n.uptimeMs?(R=Et(n.uptimeMs),e[54]=n.uptimeMs,e[55]=R):R=e[55];let A;e[56]!==k||e[57]!==R?(A=s(ce,{label:k,testId:"mt-uptime",value:R}),e[56]=k,e[57]=R,e[58]=A):A=e[58];let I;e[59]!==a?(I=a("Cache hit rate"),e[59]=a,e[60]=I):I=e[60];let E;e[61]!==m||e[62]!==a?(E=m?a("{rate} ({count} entries)",{count:m.entries,rate:Lt(m.hits,m.misses)}):a("no cache configured"),e[61]=m,e[62]=a,e[63]=E):E=e[63];let L;e[64]!==I||e[65]!==E?(L=s(ce,{label:I,testId:"mt-cache",value:E}),e[64]=I,e[65]=E,e[66]=L):L=e[66];let F;return e[67]!==w||e[68]!==$||e[69]!==C||e[70]!==A||e[71]!==L||e[72]!==d||e[73]!==v?(F=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,v,w,$,C,A,L]}),e[67]=w,e[68]=$,e[69]=C,e[70]=A,e[71]=L,e[72]=d,e[73]=v,e[74]=F):F=e[74],F},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Le=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),rs=i=>{const e=me(3),{level:l}=i;if(l==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(l==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s("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]=r):r=e[2],r},ls=(i,e)=>{const l=[...i];return l.sort((r,t)=>{switch(e){case"avgTime":return t.avgDurationMs-r.avgDurationMs;case"execCount":return t.execCount-r.execCount;case"rowsRead":return t.rowsRead-r.rowsRead;default:return t.totalDurationMs-r.totalDurationMs}}),l},as=i=>{const e=me(161),{queryStats:l}=i,r=ge(),[t,o]=be("totalTime");let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[a,m]=be(n);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=q=>{q!==null&&o(q)},e[1]=p):p=e[1];const h=p;let u,d,c,x,g,v,b,S,y,w;if(e[2]!==a||e[3]!==l||e[4]!==t||e[5]!==r){c=Symbol.for("react.early_return_sentinel");e:{const q=ls(l,t);let C;e[16]!==l?(C=l.filter(is),e[16]=l,e[17]=C):C=e[17];const k=C.length;let R;e[18]!==l?(R=l.filter(ns),e[18]=l,e[19]=R):R=e[19];const A=R.length;let I;e[20]!==l?(I=l.filter(os),e[20]=l,e[21]=I):I=e[21];const E=I.length;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=D=>{m(ne=>{const B=new Set(ne);return B.has(D)?B.delete(D):B.add(D),B})},e[22]=L):L=e[22];const F=L;if(l.length===0){let D;e[23]!==r?(D=r("No query insights yet"),e[23]=r,e[24]=D):D=e[24];let ne;e[25]!==D?(ne=s("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:D}),e[25]=D,e[26]=ne):ne=e[26];let B;e[27]!==r?(B=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=B):B=e[28];let he;e[29]!==B?(he=s("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let Pe;e[31]!==ne||e[32]!==he?(Pe=s(pe,{children:s(xe,{className:"py-12",children:f("div",{className:"text-center text-muted-foreground",children:[ne,he]})})}),e[31]=ne,e[32]=he,e[33]=Pe):Pe=e[33],c=Pe;break e}b="space-y-4",S="qi-root";let de;e[34]!==r?(de=r("Critical queries"),e[34]=r,e[35]=de):de=e[35];let fe;e[36]!==de?(fe=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:de})}),e[36]=de,e[37]=fe):fe=e[37];let Q;e[38]!==k?(Q=s("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=Q):Q=e[39];let H;e[40]!==r?(H=r(">100ms avg execution"),e[40]=r,e[41]=H):H=e[41];let U;e[42]!==H?(U=s("p",{className:"text-xs text-muted-foreground",children:H}),e[42]=H,e[43]=U):U=e[43];let j;e[44]!==Q||e[45]!==U?(j=f(xe,{children:[Q,U]}),e[44]=Q,e[45]=U,e[46]=j):j=e[46];let V;e[47]!==fe||e[48]!==j?(V=f(pe,{children:[fe,j]}),e[47]=fe,e[48]=j,e[49]=V):V=e[49];let G;e[50]!==r?(G=r("Moderate queries"),e[50]=r,e[51]=G):G=e[51];let Y;e[52]!==G?(Y=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:G})}),e[52]=G,e[53]=Y):Y=e[53];let J;e[54]!==A?(J=s("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:A}),e[54]=A,e[55]=J):J=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let X;e[58]!==W?(X=s("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=X):X=e[59];let Z;e[60]!==J||e[61]!==X?(Z=f(xe,{children:[J,X]}),e[60]=J,e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==Y||e[64]!==Z?(ee=f(pe,{children:[Y,Z]}),e[63]=Y,e[64]=Z,e[65]=ee):ee=e[65];let te;e[66]!==r?(te=r("Fast queries"),e[66]=r,e[67]=te):te=e[67];let se;e[68]!==te?(se=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:te})}),e[68]=te,e[69]=se):se=e[69];let re;e[70]!==E?(re=s("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:E}),e[70]=E,e[71]=re):re=e[71];let le;e[72]!==r?(le=r("<50ms avg execution"),e[72]=r,e[73]=le):le=e[73];let ae;e[74]!==le?(ae=s("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ae):ae=e[75];let T;e[76]!==re||e[77]!==ae?(T=f(xe,{children:[re,ae]}),e[76]=re,e[77]=ae,e[78]=T):T=e[78];let O;e[79]!==se||e[80]!==T?(O=f(pe,{children:[se,T]}),e[79]=se,e[80]=T,e[81]=O):O=e[81],e[82]!==V||e[83]!==ee||e[84]!==O?(y=f("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ee,O]}),e[82]=V,e[83]=ee,e[84]=O,e[85]=y):y=e[85];let z;e[86]!==r?(z=r("Query leaderboard"),e[86]=r,e[87]=z):z=e[87];let K;e[88]!==z?(K=s("h3",{className:"text-lg font-semibold",children:z}),e[88]=z,e[89]=K):K=e[89];let P;e[90]!==t||e[91]!==r?(P=r("Slow queries sorted by {sortField}",{sortField:r(t)}),e[90]=t,e[91]=r,e[92]=P):P=e[92];let ue;e[93]!==P?(ue=s("p",{className:"text-sm text-muted-foreground",children:P}),e[93]=P,e[94]=ue):ue=e[94];let ve;e[95]!==K||e[96]!==ue?(ve=f("div",{children:[K,ue]}),e[95]=K,e[96]=ue,e[97]=ve):ve=e[97];let ye;e[98]!==r?(ye=r("Sort by"),e[98]=r,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=s("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==r?(Se=r("Sort queries by"),e[102]=r,e[103]=Se):Se=e[103];let Oe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Oe=s(Qt,{}),e[104]=Oe):Oe=e[104];let we;e[105]!==Se?(we=s(Ht,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Oe}),e[105]=Se,e[106]=we):we=e[106];let Te;e[107]!==r?(Te=r("Total time"),e[107]=r,e[108]=Te):Te=e[108];let qe;e[109]!==Te?(qe=s(He,{value:"totalTime",children:Te}),e[109]=Te,e[110]=qe):qe=e[110];let _e;e[111]!==r?(_e=r("Avg time"),e[111]=r,e[112]=_e):_e=e[112];let Ce;e[113]!==_e?(Ce=s(He,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Ce):Ce=e[114];let Re;e[115]!==r?(Re=r("Execution count"),e[115]=r,e[116]=Re):Re=e[116];let Me;e[117]!==Re?(Me=s(He,{value:"execCount",children:Re}),e[117]=Re,e[118]=Me):Me=e[118];let ke;e[119]!==r?(ke=r("Rows read"),e[119]=r,e[120]=ke):ke=e[120];let Ae;e[121]!==ke?(Ae=s(He,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=Ae):Ae=e[122];let Ie;e[123]!==qe||e[124]!==Ce||e[125]!==Me||e[126]!==Ae?(Ie=f(Ut,{children:[qe,Ce,Me,Ae]}),e[123]=qe,e[124]=Ce,e[125]=Me,e[126]=Ae,e[127]=Ie):Ie=e[127];let $e;e[128]!==t||e[129]!==we||e[130]!==Ie?($e=f(jt,{onValueChange:h,value:t,children:[we,Ie]}),e[128]=t,e[129]=we,e[130]=Ie,e[131]=$e):$e=e[131];let De;e[132]!==Ne||e[133]!==$e?(De=f("div",{className:"flex items-center gap-2",children:[Ne,$e]}),e[132]=Ne,e[133]=$e,e[134]=De):De=e[134],e[135]!==ve||e[136]!==De?(w=f("div",{className:"flex items-center justify-between",children:[ve,De]}),e[135]=ve,e[136]=De,e[137]=w):w=e[137],d=pe;let Ee;e[138]!==r?(Ee=r("Statements"),e[138]=r,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=s(Qe,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],v=f(Be,{children:[ze,s(Mt,{children:r("{count} tracked statements",{count:q.length})})]}),u=xe,x="space-y-2";let Ke;e[142]!==a||e[143]!==r?(Ke=D=>{const ne=D.normalizedSql,B=a.has(ne),he=Ge(D.avgDurationMs);return f("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[f("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{F(ne)},type:"button",children:[f("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s(rs,{level:he}),s("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:D.normalizedSql})]}),f("div",{className:"flex shrink-0 items-center gap-4",children:[f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.totalDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.avgDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),D.p95DurationMs!==void 0&&f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.p95DurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Ue(D.execCount)}),s("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),B&&f("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[f("div",{children:[s("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")}),s("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:D.normalizedSql})]}),f("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[D.p50DurationMs!==void 0&&f("div",{children:[s("span",{className:"text-muted-foreground",children:r("p50")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.p50DurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Exec count")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.execCount)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Total time")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.totalDurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows read")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsRead)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows written")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsWritten)})]})]})]})]},ne)},e[142]=a,e[143]=r,e[144]=Ke):Ke=e[144],g=q.map(Ke)}e[2]=a,e[3]=l,e[4]=t,e[5]=r,e[6]=u,e[7]=d,e[8]=c,e[9]=x,e[10]=g,e[11]=v,e[12]=b,e[13]=S,e[14]=y,e[15]=w}else u=e[6],d=e[7],c=e[8],x=e[9],g=e[10],v=e[11],b=e[12],S=e[13],y=e[14],w=e[15];if(c!==Symbol.for("react.early_return_sentinel"))return c;let M;e[145]!==x||e[146]!==g?(M=s("div",{className:x,children:g}),e[145]=x,e[146]=g,e[147]=M):M=e[147];let _;e[148]!==u||e[149]!==M?(_=s(u,{children:M}),e[148]=u,e[149]=M,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==v?(N=f(d,{children:[v,_]}),e[151]=d,e[152]=_,e[153]=v,e[154]=N):N=e[154];let $;return e[155]!==N||e[156]!==b||e[157]!==S||e[158]!==y||e[159]!==w?($=f("div",{className:b,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=b,e[157]=S,e[158]=y,e[159]=w,e[160]=$):$=e[160],$};function is(i){return Ge(i.avgDurationMs)==="critical"}function ns(i){return Ge(i.avgDurationMs)==="warning"}function os(i){return Ge(i.avgDurationMs)==="good"}const cs=["1m","5m","15m","1h"],ds=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ms=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ds(e.bucketMs)})),fs=({shardKey:i=""})=>{const e=ge(),[l,r]=be("15m"),o=je(Fe.getQueryInsights,{range:l},{live:!0,shardKey:i}).data,n=ms(o?.buckets??[]);return f("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[f("div",{className:"flex flex-wrap items-center gap-2",children:[s("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cs.map(a=>s("button",{"aria-pressed":a===l,className:Bt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",a===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${a}`,onClick:()=>{r(a)},type:"button",children:a},a))}),o?.capped===!0&&s(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),n.length===0?s(Pt,{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.")}):f("div",{className:"grid gap-4 lg:grid-cols-2",children:[f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),s(rt,{height:140,width:"100%",children:f(Ft,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),s(rt,{height:140,width:"100%",children:f(zt,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),s(as,{queryStats:o?.entries??[]})]})},us=qt(Fe.getMetrics),hs=[],gs=(i,e)=>i?e:"overview",ps=i=>{const e=me(14);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let r;e[1]!==i?(r={live:!0,shardKey:i},e[1]=i,e[2]=r):r=e[2];const t=je(Fe.getMetrics,l,r),{data:o}=t;let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n={points:[],shard:null},e[3]=n):n=e[3];const[a,m]=be(n),p=Je(null),h=Je(null);let u,d;e[4]!==o||e[5]!==i?(u=()=>{o!==void 0&&Ct(i)},d=[o,i],e[4]=o,e[5]=i,e[6]=u,e[7]=d):(u=e[6],d=e[7]),We(u,d);let c,x;e[8]!==o?(c=()=>{if(o===void 0)return;const b=o,S=h.current!==null&&h.current!==b.shard,y=h.current===b.shard?p.current:null;if(h.current=b.shard,p.current=b.requests,S){m({points:[],shard:b.shard});return}y!==null&&b.requests>=y&&m(w=>({points:[...w.shard===b.shard?w.points:[],b.requests-y].slice(-30),shard:b.shard}))},x=[o],e[8]=o,e[9]=c,e[10]=x):(c=e[9],x=e[10]),We(c,x);const g=a.shard!==null&&a.shard===o?.shard?a.points:hs;let v;return e[11]!==t||e[12]!==g?(v={...t,history:g},e[11]=t,e[12]=g,e[13]=v):v=e[13],v},xs=i=>{const e=vt(),l=Je(!0);We(()=>(l.current=!0,()=>{l.current=!1}),[]);const[r,t]=be(null),[o,n]=be(!1),a=async()=>{n(!0);const p=i,h=$t(p,_t());try{const u=await Promise.all(h.map(async d=>{try{const c=await e.query(us,{},wt(d));return{error:null,metrics:c,shard:d===""?c.shard:d}}catch(c){return{error:Tt(c),metrics:null,shard:d===""?"__root__":d}}}));l.current&&t({results:u,shard:p})}finally{l.current&&n(!1)}},m=r?.shard===i?r.results:null;return{aggregate:m===null?null:At(m),aggregating:o,clearAggregate:()=>{t(null)},runAggregate:()=>{St(a())},shardResults:m}},bs=i=>{if(!i||!("queryStats"in i))return;const e=i.queryStats;if(!(!e||!Array.isArray(e)))return It(e)},ot=i=>`pb-2 text-sm font-medium transition-colors ${i?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,vs=i=>{const e=me(26),{activeTab:l,onSelect:r,queryCount:t}=i,o=ge();let n;e[0]!==r?(n=()=>{r("overview")},e[0]=r,e[1]=n):n=e[1];const a=n;let m;e[2]!==r?(m=()=>{r("query-insights")},e[2]=r,e[3]=m):m=e[3];const p=m,h=l==="overview";let u;e[4]!==h?(u=ot(h),e[4]=h,e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Overview"),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==u||e[10]!==d?(c=s("button",{className:u,"data-testid":"mt-tab-overview",onClick:a,type:"button",children:d}),e[8]=a,e[9]=u,e[10]=d,e[11]=c):c=e[11];const x=l==="query-insights";let g;e[12]!==x?(g=ot(x),e[12]=x,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let b;e[16]!==t?(b=t>0&&s("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:t}),e[16]=t,e[17]=b):b=e[17];let S;e[18]!==p||e[19]!==b||e[20]!==g||e[21]!==v?(S=f("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,b]}),e[18]=p,e[19]=b,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==c?(y=f("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[c,S]}),e[23]=S,e[24]=c,e[25]=y):y=e[25],y},ys=i=>{const e=me(13),{history:l,metrics:r}=i;let t;e[0]!==l?(t=l.at(-1)??0,e[0]=l,e[1]=t):t=e[1];let o;e[2]!==r.errors||e[3]!==r.requests?(o=r.requests===0?"—":`${(r.errors/r.requests*100).toFixed(1)}%`,e[2]=r.errors,e[3]=r.requests,e[4]=o):o=e[4];let n;e[5]!==r?(n=Dt(r),e[5]=r,e[6]=n):n=e[6];let a;return e[7]!==l||e[8]!==r||e[9]!==t||e[10]!==o||e[11]!==n?(a=s(ss,{currentDelta:t,errorRate:o,history:l,latencyPercentiles:n,metrics:r}),e[7]=l,e[8]=r,e[9]=t,e[10]=o,e[11]=n,e[12]=a):a=e[12],a},Ns=i=>{const e=me(25),{aggregating:l,liveError:r,onAggregate:t,onClearAggregate:o,onShardKeyChange:n,shardKey:a}=i,m=ge();let p;e[0]!==n||e[1]!==a?(p=s(pt,{onChange:n,testId:"mt-shard-input",value:a}),e[0]=n,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==r?(h=s(gt,{message:r,prefix:"mt"}),e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==m?(u=m(l?"Aggregating…":"All shards"),e[5]=l,e[6]=m,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==t||e[10]!==u?(d=s(tt,{"data-testid":"mt-aggregate",disabled:l,onClick:t,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=l,e[9]=t,e[10]=u,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==m?(c=o!==void 0&&s(tt,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=c):c=e[14];let x;e[15]!==m?(x=m("Open in Cloudflare"),e[15]=m,e[16]=x):x=e[16];let g;e[17]!==x?(g=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:x}),e[17]=x,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==d||e[22]!==c||e[23]!==g?(v=f("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,d,c,g]}),e[19]=p,e[20]=h,e[21]=d,e[22]=c,e[23]=g,e[24]=v):v=e[24],v},Js=i=>{const e=me(41),{initialShardKey:l}=i,{queryShardKey:r,setShardKey:t,shardKey:o}=bt(l),[n,a]=be("overview"),m=xt(r),{data:p,error:h,history:u,liveError:d}=ps(r),c=p??null,{aggregate:x,aggregating:g,clearAggregate:v,runAggregate:b,shardResults:S}=xs(o);let y;e[0]!==c?(y=bs(c),e[0]=c,e[1]=y):y=e[1];const w=y,M=w!==void 0;let _;e[2]!==n||e[3]!==M?(_=gs(M,n),e[2]=n,e[3]=M,e[4]=_):_=e[4];const N=_,$=S===null?void 0:v;let q;e[5]!==g||e[6]!==d||e[7]!==b||e[8]!==t||e[9]!==o||e[10]!==$?(q=s(Ns,{aggregating:g,liveError:d,onAggregate:b,onClearAggregate:$,onShardKeyChange:t,shardKey:o}),e[5]=g,e[6]=d,e[7]=b,e[8]=t,e[9]=o,e[10]=$,e[11]=q):q=e[11];let C;e[12]!==h?(C=h!==null&&s("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let k;e[14]!==N||e[15]!==w?(k=w!==void 0&&s(vs,{activeTab:N,onSelect:a,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=k):k=e[16];let R;e[17]!==N||e[18]!==r||e[19]!==w?(R=N==="query-insights"&&w!==void 0&&s(fs,{shardKey:r}),e[17]=N,e[18]=r,e[19]=w,e[20]=R):R=e[20];let A;e[21]!==N||e[22]!==u||e[23]!==c?(A=N==="overview"&&c!==null&&s(ys,{history:u,metrics:c}),e[21]=N,e[22]=u,e[23]=c,e[24]=A):A=e[24];let I;e[25]!==N||e[26]!==m||e[27]!==r?(I=N==="overview"&&s(es,{onOpenTrace:m,shardKey:r}),e[25]=N,e[26]=m,e[27]=r,e[28]=I):I=e[28];let E;e[29]!==x||e[30]!==N||e[31]!==S?(E=N==="overview"&&x!==null&&S!==null&&s(ts,{aggregate:x,shardResults:S}),e[29]=x,e[30]=N,e[31]=S,e[32]=E):E=e[32];let L;return e[33]!==I||e[34]!==E||e[35]!==q||e[36]!==C||e[37]!==k||e[38]!==R||e[39]!==A?(L=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[q,C,k,R,A,I,E]}),e[33]=I,e[34]=E,e[35]=q,e[36]=C,e[37]=k,e[38]=R,e[39]=A,e[40]=L):L=e[40],L};export{Js as MetricsPanel};
1
+ import{c as me}from"react/compiler-runtime";import{useState as be,useRef as Je,useEffect as We}from"react";import{L as gt}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as pt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as xt}from"../packem_shared/use-open-trace-BJKMJjeS.mjs";import{u as bt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ge}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{c as yt}from"../packem_shared/cf-links-BPy1pJRO.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as Tt,c as qt}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as _t,r as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as pe,a as xe,b as Be,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as ie,T as ct,c as oe,a as dt,d as mt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as f,jsx as s,Fragment as Ze}from"react/jsx-runtime";import{aggregateMetrics as At,enrichQueryStats as It,shardsToAggregate as $t,computeLatencyPercentiles as Dt}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ce}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as st,c as Et,h as Lt}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as rt,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as Ot,LineChart as zt,Line as Kt}from"recharts";import{E as Pt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Bt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,l)=>`${i}:${e}:${kt(l??{})}`,ht=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ht(i,e),Gt=i=>ht(i.kind,i),Ye=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Yt=i=>Array.isArray(i?.series)?i.series:[],Jt="FUNCTION_NOT_FOUND",Wt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const l of i.series)e.set(ut(l.kind,l.name,l.attributes),l.points);return e},Xt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=me(18),{name:l,onOpenTrace:r,traceId:t}=i,o=ge();if(t===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let n;e[1]!==t?(n=t.slice(0,8),e[1]=t,e[2]=n):n=e[2];const a=n;if(r===void 0){const d=`mt-instrument-trace-${l}`;let c;return e[3]!==a||e[4]!==d||e[5]!==t?(c=s("span",{className:"text-muted-foreground","data-testid":d,title:t,children:a}),e[3]=a,e[4]=d,e[5]=t,e[6]=c):c=e[6],c}const m=`mt-instrument-trace-${l}`;let p;e[7]!==r||e[8]!==t?(p=()=>{r(t)},e[7]=r,e[8]=t,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==t?(h=o("Open the exemplar trace {trace}",{trace:t}),e[10]=o,e[11]=t,e[12]=h):h=e[12];let u;return e[13]!==a||e[14]!==m||e[15]!==p||e[16]!==h?(u=s("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:a}),e[13]=a,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},es=i=>{const e=me(105),{onOpenTrace:l,shardKey:r}=i,t=ge();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let n;e[1]!==r?(n={live:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:a,error:m,errorSource:p}=je(Fe.getMetricSeries,o,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:d}=je(Fe.getMetricHistory,h,u);let c,x,g,v,b,S,y,w,M,_,N,$,q;if(e[6]!==a||e[7]!==m||e[8]!==p||e[9]!==d||e[10]!==l||e[11]!==t){w=Symbol.for("react.early_return_sentinel");e:{const E=Yt(a),L=Nt(p)===Jt;if(m!==null&&!L){let T;e[25]!==t?(T=t("Instruments"),e[25]=t,e[26]=T):T=e[26];let O;e[27]!==T?(O=s("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[27]=T,e[28]=O):O=e[28];let z;e[29]!==m||e[30]!==t?(z=t("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=t,e[31]=z):z=e[31];let K;e[32]!==z?(K=s("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:z}),e[32]=z,e[33]=K):K=e[33];let P;e[34]!==O||e[35]!==K?(P=f("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[O,K]}),e[34]=O,e[35]=K,e[36]=P):P=e[36],w=P;break e}if(E.length===0){w=null;break e}const F=Wt(d);let de;e[37]!==t?(de=T=>t(T==="counter"?"Counter":T==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=de):de=e[38];const fe=de;b="flex flex-col gap-2",S="mt-instruments";let Q;e[39]!==t?(Q=t("Instruments"),e[39]=t,e[40]=Q):Q=e[40],e[41]!==Q?(y=s("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=y):y=e[42],v=pe,q="overflow-hidden py-0",g=xe,$="px-0",x=ct,_="mt-instruments-table";let H;e[43]!==t?(H=t("name"),e[43]=t,e[44]=H):H=e[44];let U;e[45]!==H?(U=s(oe,{children:H}),e[45]=H,e[46]=U):U=e[46];let j;e[47]!==t?(j=t("kind"),e[47]=t,e[48]=j):j=e[48];let V;e[49]!==j?(V=s(oe,{children:j}),e[49]=j,e[50]=V):V=e[50];let G;e[51]!==t?(G=t("value"),e[51]=t,e[52]=G):G=e[52];let Y;e[53]!==G?(Y=s(oe,{className:"text-right",children:G}),e[53]=G,e[54]=Y):Y=e[54];let J;e[55]!==t?(J=t("count"),e[55]=t,e[56]=J):J=e[56];let W;e[57]!==J?(W=s(oe,{className:"text-right",children:J}),e[57]=J,e[58]=W):W=e[58];let X;e[59]!==t?(X=t("range"),e[59]=t,e[60]=X):X=e[60];let Z;e[61]!==X?(Z=s(oe,{className:"text-right",children:X}),e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==t?(ee=t("trend"),e[63]=t,e[64]=ee):ee=e[64];let te;e[65]!==ee?(te=s(oe,{children:ee}),e[65]=ee,e[66]=te):te=e[66];let se;e[67]!==t?(se=t("trace"),e[67]=t,e[68]=se):se=e[68];let re;e[69]!==se?(re=s(oe,{children:se}),e[69]=se,e[70]=re):re=e[70];let le;e[71]!==t?(le=t("dimensions"),e[71]=t,e[72]=le):le=e[72];let ae;e[73]!==le?(ae=s(oe,{children:le}),e[73]=le,e[74]=ae):ae=e[74],e[75]!==U||e[76]!==V||e[77]!==Y||e[78]!==W||e[79]!==Z||e[80]!==te||e[81]!==re||e[82]!==ae?(N=s(dt,{children:f(Ve,{children:[U,V,Y,W,Z,te,re,ae]})}),e[75]=U,e[76]=V,e[77]=Y,e[78]=W,e[79]=Z,e[80]=te,e[81]=re,e[82]=ae,e[83]=N):N=e[83],c=mt,M=E.map(T=>{const O=Rt(T.attributes),z=ut(T.kind,T.name,T.attributes),P=(F.get(z)??[]).map(ue=>Vt(T.kind,ue));return f(Ve,{"data-testid":`mt-instrument-${T.name}`,children:[s(ie,{className:"font-mono text-xs",title:T.functionPath,children:T.name}),s(ie,{children:s(et,{variant:Xt[T.kind],children:fe(T.kind)})}),s(ie,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${T.name}`,children:Ye(Gt(T))}),s(ie,{className:"text-right tabular-nums text-muted-foreground",children:T.count.toLocaleString()}),s(ie,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:T.min===T.max?"—":`${Ye(T.min)}–${Ye(T.max)}`}),s(ie,{children:P.length>=2?s(ft,{ariaLabel:t("{name} trend",{name:T.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${T.name}`}):s("span",{className:"text-xs text-muted-foreground",children:"—"})}),s(ie,{className:"font-mono text-xs",children:s(Zt,{name:T.name,onOpenTrace:l,traceId:T.exemplarTraceId})}),s(ie,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:O,children:O===""?"—":O})]},z)})}e[6]=a,e[7]=m,e[8]=p,e[9]=d,e[10]=l,e[11]=t,e[12]=c,e[13]=x,e[14]=g,e[15]=v,e[16]=b,e[17]=S,e[18]=y,e[19]=w,e[20]=M,e[21]=_,e[22]=N,e[23]=$,e[24]=q}else c=e[12],x=e[13],g=e[14],v=e[15],b=e[16],S=e[17],y=e[18],w=e[19],M=e[20],_=e[21],N=e[22],$=e[23],q=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==c||e[85]!==M?(C=s(c,{children:M}),e[84]=c,e[85]=M,e[86]=C):C=e[86];let k;e[87]!==x||e[88]!==C||e[89]!==_||e[90]!==N?(k=f(x,{"data-testid":_,children:[N,C]}),e[87]=x,e[88]=C,e[89]=_,e[90]=N,e[91]=k):k=e[91];let R;e[92]!==g||e[93]!==k||e[94]!==$?(R=s(g,{className:$,children:k}),e[92]=g,e[93]=k,e[94]=$,e[95]=R):R=e[95];let A;e[96]!==v||e[97]!==R||e[98]!==q?(A=s(v,{className:q,children:R}),e[96]=v,e[97]=R,e[98]=q,e[99]=A):A=e[99];let I;return e[100]!==b||e[101]!==S||e[102]!==y||e[103]!==A?(I=f("section",{className:b,"data-testid":S,children:[y,A]}),e[100]=b,e[101]=S,e[102]=y,e[103]=A,e[104]=I):I=e[104],I},ts=i=>{const e=me(74),{aggregate:l,shardResults:r}=i,t=ge();let o;e[0]!==t?(o=t("Shards"),e[0]=t,e[1]=o):o=e[1];let n;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==t?(n=l.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):t("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=t,e[5]=n):n=e[5];let a;e[6]!==o||e[7]!==n?(a=s(ce,{label:o,testId:"mt-agg-shards",value:n}),e[6]=o,e[7]=n,e[8]=a):a=e[8];let m;e[9]!==t?(m=t("Total requests"),e[9]=t,e[10]=m):m=e[10];let p;e[11]!==l.totalRequests||e[12]!==m?(p=s(ce,{label:m,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t?(h=t("Total errors"),e[14]=t,e[15]=h):h=e[15];let u;e[16]!==l.totalErrors||e[17]!==h?(u=s(ce,{label:h,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=h,e[18]=u):u=e[18];let d;e[19]!==t?(d=t("Total database size"),e[19]=t,e[20]=d):d=e[20];let c;e[21]!==l.totalDatabaseSize?(c=Xe(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=c):c=e[22];let x;e[23]!==d||e[24]!==c?(x=s(ce,{label:d,testId:"mt-agg-db-size",value:c}),e[23]=d,e[24]=c,e[25]=x):x=e[25];let g;e[26]!==t?(g=t("Combined cache hit rate"),e[26]=t,e[27]=g):g=e[27];let v;e[28]!==l.hitRate||e[29]!==t?(v=l.hitRate===null?t("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=t,e[30]=v):v=e[30];let b;e[31]!==g||e[32]!==v?(b=s(ce,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=b):b=e[33];let S;e[34]!==x||e[35]!==b||e[36]!==a||e[37]!==p||e[38]!==u?(S=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[a,p,u,x,b]}),e[34]=x,e[35]=b,e[36]=a,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==t?(y=t("shard"),e[40]=t,e[41]=y):y=e[41];let w;e[42]!==y?(w=s(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let M;e[44]!==t?(M=t("requests"),e[44]=t,e[45]=M):M=e[45];let _;e[46]!==M?(_=s(oe,{children:M}),e[46]=M,e[47]=_):_=e[47];let N;e[48]!==t?(N=t("errors"),e[48]=t,e[49]=N):N=e[49];let $;e[50]!==N?($=s(oe,{children:N}),e[50]=N,e[51]=$):$=e[51];let q;e[52]!==t?(q=t("db size"),e[52]=t,e[53]=q):q=e[53];let C;e[54]!==q?(C=s(oe,{children:q}),e[54]=q,e[55]=C):C=e[55];let k;e[56]!==w||e[57]!==_||e[58]!==$||e[59]!==C?(k=s(dt,{children:f(Ve,{children:[w,_,$,C]})}),e[56]=w,e[57]=_,e[58]=$,e[59]=C,e[60]=k):k=e[60];let R;if(e[61]!==r||e[62]!==t){let L;e[64]!==t?(L=F=>f(Ve,{"data-testid":`mt-agg-row-${F.shard}`,children:[s(ie,{children:F.shard}),F.metrics===null?s(ie,{className:"text-destructive",colSpan:3,children:F.error??t("unreachable")}):f(Ze,{children:[s(ie,{className:"tabular-nums",children:F.metrics.requests}),s(ie,{className:"tabular-nums",children:F.metrics.errors}),s(ie,{className:"tabular-nums",children:Xe(F.metrics.databaseSize)})]})]},F.shard),e[64]=t,e[65]=L):L=e[65],R=r.map(L),e[61]=r,e[62]=t,e[63]=R}else R=e[63];let A;e[66]!==R?(A=s(mt,{children:R}),e[66]=R,e[67]=A):A=e[67];let I;e[68]!==k||e[69]!==A?(I=s(pe,{className:"overflow-hidden py-0",children:s(xe,{className:"px-0",children:f(ct,{"data-testid":"mt-agg-table",children:[k,A]})})}),e[68]=k,e[69]=A,e[70]=I):I=e[70];let E;return e[71]!==S||e[72]!==I?(E=f("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,I]}),e[71]=S,e[72]=I,e[73]=E):E=e[73],E},ss=i=>{const e=me(75),{currentDelta:l,errorRate:r,history:t,latencyPercentiles:o,metrics:n}=i,a=ge(),{cache:m}=n;let p;e[0]!==t||e[1]!==a?(p=t.length>=2?s(ft,{ariaLabel:a("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==l||e[4]!==t.length||e[5]!==a?(h=t.length>=2?f(Ze,{children:[s("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",a("last interval")]}):s("span",{"data-testid":"mt-sparkline-empty",children:a("collecting samples…")}),e[3]=l,e[4]=t.length,e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a?(u=a("Requests"),e[7]=a,e[8]=u):u=e[8];let d;e[9]!==n.requests||e[10]!==p||e[11]!==h||e[12]!==u?(d=s(ce,{chart:p,footer:h,label:u,testId:"mt-requests",value:n.requests}),e[9]=n.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=d):d=e[13];let c;e[14]!==r||e[15]!==a?(c=a("{rate} error rate",{rate:r}),e[14]=r,e[15]=a,e[16]=c):c=e[16];let x;e[17]!==a?(x=a("Errors"),e[17]=a,e[18]=x):x=e[18];let g;e[19]!==r||e[20]!==n.errors?(g=f(Ze,{children:[n.errors," (",r,")"]}),e[19]=r,e[20]=n.errors,e[21]=g):g=e[21];let v;e[22]!==c||e[23]!==x||e[24]!==g?(v=s(ce,{footer:c,label:x,testId:"mt-errors",value:g}),e[22]=c,e[23]=x,e[24]=g,e[25]=v):v=e[25];let b;e[26]!==o.p90?(b=o.p90>0?`P90 ${st(o.p90)}`:void 0,e[26]=o.p90,e[27]=b):b=e[27];let S;e[28]!==a?(S=a("P95 latency"),e[28]=a,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?st(o.p95):"—",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==b?(w=s(ce,{footer:b,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=b,e[35]=w):w=e[35];let M;e[36]!==m||e[37]!==a?(M=m?`${m.entries.toLocaleString()} ${a("cache entries")}`:void 0,e[36]=m,e[37]=a,e[38]=M):M=e[38];let _;e[39]!==a?(_=a("Database size"),e[39]=a,e[40]=_):_=e[40];let N;e[41]!==n.databaseSize?(N=Xe(n.databaseSize),e[41]=n.databaseSize,e[42]=N):N=e[42];let $;e[43]!==M||e[44]!==_||e[45]!==N?($=s(ce,{footer:M,label:_,testId:"mt-db-size",value:N}),e[43]=M,e[44]=_,e[45]=N,e[46]=$):$=e[46];let q;e[47]!==a?(q=a("Shard"),e[47]=a,e[48]=q):q=e[48];let C;e[49]!==n.shard||e[50]!==q?(C=s(ce,{label:q,testId:"mt-shard",value:n.shard}),e[49]=n.shard,e[50]=q,e[51]=C):C=e[51];let k;e[52]!==a?(k=a("Uptime"),e[52]=a,e[53]=k):k=e[53];let R;e[54]!==n.uptimeMs?(R=Et(n.uptimeMs),e[54]=n.uptimeMs,e[55]=R):R=e[55];let A;e[56]!==k||e[57]!==R?(A=s(ce,{label:k,testId:"mt-uptime",value:R}),e[56]=k,e[57]=R,e[58]=A):A=e[58];let I;e[59]!==a?(I=a("Cache hit rate"),e[59]=a,e[60]=I):I=e[60];let E;e[61]!==m||e[62]!==a?(E=m?a("{rate} ({count} entries)",{count:m.entries,rate:Lt(m.hits,m.misses)}):a("no cache configured"),e[61]=m,e[62]=a,e[63]=E):E=e[63];let L;e[64]!==I||e[65]!==E?(L=s(ce,{label:I,testId:"mt-cache",value:E}),e[64]=I,e[65]=E,e[66]=L):L=e[66];let F;return e[67]!==w||e[68]!==$||e[69]!==C||e[70]!==A||e[71]!==L||e[72]!==d||e[73]!==v?(F=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,v,w,$,C,A,L]}),e[67]=w,e[68]=$,e[69]=C,e[70]=A,e[71]=L,e[72]=d,e[73]=v,e[74]=F):F=e[74],F},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Le=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),rs=i=>{const e=me(3),{level:l}=i;if(l==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(l==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s("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]=r):r=e[2],r},ls=(i,e)=>{const l=[...i];return l.sort((r,t)=>{switch(e){case"avgTime":return t.avgDurationMs-r.avgDurationMs;case"execCount":return t.execCount-r.execCount;case"rowsRead":return t.rowsRead-r.rowsRead;default:return t.totalDurationMs-r.totalDurationMs}}),l},as=i=>{const e=me(161),{queryStats:l}=i,r=ge(),[t,o]=be("totalTime");let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[a,m]=be(n);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=q=>{q!==null&&o(q)},e[1]=p):p=e[1];const h=p;let u,d,c,x,g,v,b,S,y,w;if(e[2]!==a||e[3]!==l||e[4]!==t||e[5]!==r){c=Symbol.for("react.early_return_sentinel");e:{const q=ls(l,t);let C;e[16]!==l?(C=l.filter(is),e[16]=l,e[17]=C):C=e[17];const k=C.length;let R;e[18]!==l?(R=l.filter(ns),e[18]=l,e[19]=R):R=e[19];const A=R.length;let I;e[20]!==l?(I=l.filter(os),e[20]=l,e[21]=I):I=e[21];const E=I.length;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=D=>{m(ne=>{const B=new Set(ne);return B.has(D)?B.delete(D):B.add(D),B})},e[22]=L):L=e[22];const F=L;if(l.length===0){let D;e[23]!==r?(D=r("No query insights yet"),e[23]=r,e[24]=D):D=e[24];let ne;e[25]!==D?(ne=s("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:D}),e[25]=D,e[26]=ne):ne=e[26];let B;e[27]!==r?(B=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=B):B=e[28];let he;e[29]!==B?(he=s("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let Pe;e[31]!==ne||e[32]!==he?(Pe=s(pe,{children:s(xe,{className:"py-12",children:f("div",{className:"text-center text-muted-foreground",children:[ne,he]})})}),e[31]=ne,e[32]=he,e[33]=Pe):Pe=e[33],c=Pe;break e}b="space-y-4",S="qi-root";let de;e[34]!==r?(de=r("Critical queries"),e[34]=r,e[35]=de):de=e[35];let fe;e[36]!==de?(fe=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:de})}),e[36]=de,e[37]=fe):fe=e[37];let Q;e[38]!==k?(Q=s("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=Q):Q=e[39];let H;e[40]!==r?(H=r(">100ms avg execution"),e[40]=r,e[41]=H):H=e[41];let U;e[42]!==H?(U=s("p",{className:"text-xs text-muted-foreground",children:H}),e[42]=H,e[43]=U):U=e[43];let j;e[44]!==Q||e[45]!==U?(j=f(xe,{children:[Q,U]}),e[44]=Q,e[45]=U,e[46]=j):j=e[46];let V;e[47]!==fe||e[48]!==j?(V=f(pe,{children:[fe,j]}),e[47]=fe,e[48]=j,e[49]=V):V=e[49];let G;e[50]!==r?(G=r("Moderate queries"),e[50]=r,e[51]=G):G=e[51];let Y;e[52]!==G?(Y=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:G})}),e[52]=G,e[53]=Y):Y=e[53];let J;e[54]!==A?(J=s("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:A}),e[54]=A,e[55]=J):J=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let X;e[58]!==W?(X=s("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=X):X=e[59];let Z;e[60]!==J||e[61]!==X?(Z=f(xe,{children:[J,X]}),e[60]=J,e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==Y||e[64]!==Z?(ee=f(pe,{children:[Y,Z]}),e[63]=Y,e[64]=Z,e[65]=ee):ee=e[65];let te;e[66]!==r?(te=r("Fast queries"),e[66]=r,e[67]=te):te=e[67];let se;e[68]!==te?(se=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:te})}),e[68]=te,e[69]=se):se=e[69];let re;e[70]!==E?(re=s("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:E}),e[70]=E,e[71]=re):re=e[71];let le;e[72]!==r?(le=r("<50ms avg execution"),e[72]=r,e[73]=le):le=e[73];let ae;e[74]!==le?(ae=s("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ae):ae=e[75];let T;e[76]!==re||e[77]!==ae?(T=f(xe,{children:[re,ae]}),e[76]=re,e[77]=ae,e[78]=T):T=e[78];let O;e[79]!==se||e[80]!==T?(O=f(pe,{children:[se,T]}),e[79]=se,e[80]=T,e[81]=O):O=e[81],e[82]!==V||e[83]!==ee||e[84]!==O?(y=f("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ee,O]}),e[82]=V,e[83]=ee,e[84]=O,e[85]=y):y=e[85];let z;e[86]!==r?(z=r("Query leaderboard"),e[86]=r,e[87]=z):z=e[87];let K;e[88]!==z?(K=s("h3",{className:"text-lg font-semibold",children:z}),e[88]=z,e[89]=K):K=e[89];let P;e[90]!==t||e[91]!==r?(P=r("Slow queries sorted by {sortField}",{sortField:r(t)}),e[90]=t,e[91]=r,e[92]=P):P=e[92];let ue;e[93]!==P?(ue=s("p",{className:"text-sm text-muted-foreground",children:P}),e[93]=P,e[94]=ue):ue=e[94];let ve;e[95]!==K||e[96]!==ue?(ve=f("div",{children:[K,ue]}),e[95]=K,e[96]=ue,e[97]=ve):ve=e[97];let ye;e[98]!==r?(ye=r("Sort by"),e[98]=r,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=s("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==r?(Se=r("Sort queries by"),e[102]=r,e[103]=Se):Se=e[103];let Oe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Oe=s(Qt,{}),e[104]=Oe):Oe=e[104];let we;e[105]!==Se?(we=s(Ht,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Oe}),e[105]=Se,e[106]=we):we=e[106];let Te;e[107]!==r?(Te=r("Total time"),e[107]=r,e[108]=Te):Te=e[108];let qe;e[109]!==Te?(qe=s(He,{value:"totalTime",children:Te}),e[109]=Te,e[110]=qe):qe=e[110];let _e;e[111]!==r?(_e=r("Avg time"),e[111]=r,e[112]=_e):_e=e[112];let Ce;e[113]!==_e?(Ce=s(He,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Ce):Ce=e[114];let Re;e[115]!==r?(Re=r("Execution count"),e[115]=r,e[116]=Re):Re=e[116];let Me;e[117]!==Re?(Me=s(He,{value:"execCount",children:Re}),e[117]=Re,e[118]=Me):Me=e[118];let ke;e[119]!==r?(ke=r("Rows read"),e[119]=r,e[120]=ke):ke=e[120];let Ae;e[121]!==ke?(Ae=s(He,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=Ae):Ae=e[122];let Ie;e[123]!==qe||e[124]!==Ce||e[125]!==Me||e[126]!==Ae?(Ie=f(Ut,{children:[qe,Ce,Me,Ae]}),e[123]=qe,e[124]=Ce,e[125]=Me,e[126]=Ae,e[127]=Ie):Ie=e[127];let $e;e[128]!==t||e[129]!==we||e[130]!==Ie?($e=f(jt,{onValueChange:h,value:t,children:[we,Ie]}),e[128]=t,e[129]=we,e[130]=Ie,e[131]=$e):$e=e[131];let De;e[132]!==Ne||e[133]!==$e?(De=f("div",{className:"flex items-center gap-2",children:[Ne,$e]}),e[132]=Ne,e[133]=$e,e[134]=De):De=e[134],e[135]!==ve||e[136]!==De?(w=f("div",{className:"flex items-center justify-between",children:[ve,De]}),e[135]=ve,e[136]=De,e[137]=w):w=e[137],d=pe;let Ee;e[138]!==r?(Ee=r("Statements"),e[138]=r,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=s(Qe,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],v=f(Be,{children:[ze,s(Mt,{children:r("{count} tracked statements",{count:q.length})})]}),u=xe,x="space-y-2";let Ke;e[142]!==a||e[143]!==r?(Ke=D=>{const ne=D.normalizedSql,B=a.has(ne),he=Ge(D.avgDurationMs);return f("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[f("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{F(ne)},type:"button",children:[f("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s(rs,{level:he}),s("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:D.normalizedSql})]}),f("div",{className:"flex shrink-0 items-center gap-4",children:[f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.totalDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.avgDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),D.p95DurationMs!==void 0&&f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.p95DurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Ue(D.execCount)}),s("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),B&&f("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[f("div",{children:[s("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")}),s("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:D.normalizedSql})]}),f("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[D.p50DurationMs!==void 0&&f("div",{children:[s("span",{className:"text-muted-foreground",children:r("p50")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.p50DurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Exec count")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.execCount)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Total time")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.totalDurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows read")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsRead)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows written")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsWritten)})]})]})]})]},ne)},e[142]=a,e[143]=r,e[144]=Ke):Ke=e[144],g=q.map(Ke)}e[2]=a,e[3]=l,e[4]=t,e[5]=r,e[6]=u,e[7]=d,e[8]=c,e[9]=x,e[10]=g,e[11]=v,e[12]=b,e[13]=S,e[14]=y,e[15]=w}else u=e[6],d=e[7],c=e[8],x=e[9],g=e[10],v=e[11],b=e[12],S=e[13],y=e[14],w=e[15];if(c!==Symbol.for("react.early_return_sentinel"))return c;let M;e[145]!==x||e[146]!==g?(M=s("div",{className:x,children:g}),e[145]=x,e[146]=g,e[147]=M):M=e[147];let _;e[148]!==u||e[149]!==M?(_=s(u,{children:M}),e[148]=u,e[149]=M,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==v?(N=f(d,{children:[v,_]}),e[151]=d,e[152]=_,e[153]=v,e[154]=N):N=e[154];let $;return e[155]!==N||e[156]!==b||e[157]!==S||e[158]!==y||e[159]!==w?($=f("div",{className:b,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=b,e[157]=S,e[158]=y,e[159]=w,e[160]=$):$=e[160],$};function is(i){return Ge(i.avgDurationMs)==="critical"}function ns(i){return Ge(i.avgDurationMs)==="warning"}function os(i){return Ge(i.avgDurationMs)==="good"}const cs=["1m","5m","15m","1h"],ds=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ms=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ds(e.bucketMs)})),fs=({shardKey:i=""})=>{const e=ge(),[l,r]=be("15m"),o=je(Fe.getQueryInsights,{range:l},{live:!0,shardKey:i}).data,n=ms(o?.buckets??[]);return f("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[f("div",{className:"flex flex-wrap items-center gap-2",children:[s("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cs.map(a=>s("button",{"aria-pressed":a===l,className:Bt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",a===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${a}`,onClick:()=>{r(a)},type:"button",children:a},a))}),o?.capped===!0&&s(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),n.length===0?s(Pt,{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.")}):f("div",{className:"grid gap-4 lg:grid-cols-2",children:[f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),s(rt,{height:140,width:"100%",children:f(Ft,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),s(rt,{height:140,width:"100%",children:f(zt,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),s(as,{queryStats:o?.entries??[]})]})},us=qt(Fe.getMetrics),hs=[],gs=(i,e)=>i?e:"overview",ps=i=>{const e=me(14);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let r;e[1]!==i?(r={live:!0,shardKey:i},e[1]=i,e[2]=r):r=e[2];const t=je(Fe.getMetrics,l,r),{data:o}=t;let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n={points:[],shard:null},e[3]=n):n=e[3];const[a,m]=be(n),p=Je(null),h=Je(null);let u,d;e[4]!==o||e[5]!==i?(u=()=>{o!==void 0&&Ct(i)},d=[o,i],e[4]=o,e[5]=i,e[6]=u,e[7]=d):(u=e[6],d=e[7]),We(u,d);let c,x;e[8]!==o?(c=()=>{if(o===void 0)return;const b=o,S=h.current!==null&&h.current!==b.shard,y=h.current===b.shard?p.current:null;if(h.current=b.shard,p.current=b.requests,S){m({points:[],shard:b.shard});return}y!==null&&b.requests>=y&&m(w=>({points:[...w.shard===b.shard?w.points:[],b.requests-y].slice(-30),shard:b.shard}))},x=[o],e[8]=o,e[9]=c,e[10]=x):(c=e[9],x=e[10]),We(c,x);const g=a.shard!==null&&a.shard===o?.shard?a.points:hs;let v;return e[11]!==t||e[12]!==g?(v={...t,history:g},e[11]=t,e[12]=g,e[13]=v):v=e[13],v},xs=i=>{const e=vt(),l=Je(!0);We(()=>(l.current=!0,()=>{l.current=!1}),[]);const[r,t]=be(null),[o,n]=be(!1),a=async()=>{n(!0);const p=i,h=$t(p,_t());try{const u=await Promise.all(h.map(async d=>{try{const c=await e.query(us,{},wt(d));return{error:null,metrics:c,shard:d===""?c.shard:d}}catch(c){return{error:Tt(c),metrics:null,shard:d===""?"__root__":d}}}));l.current&&t({results:u,shard:p})}finally{l.current&&n(!1)}},m=r?.shard===i?r.results:null;return{aggregate:m===null?null:At(m),aggregating:o,clearAggregate:()=>{t(null)},runAggregate:()=>{St(a())},shardResults:m}},bs=i=>{if(!i||!("queryStats"in i))return;const e=i.queryStats;if(!(!e||!Array.isArray(e)))return It(e)},ot=i=>`pb-2 text-sm font-medium transition-colors ${i?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,vs=i=>{const e=me(26),{activeTab:l,onSelect:r,queryCount:t}=i,o=ge();let n;e[0]!==r?(n=()=>{r("overview")},e[0]=r,e[1]=n):n=e[1];const a=n;let m;e[2]!==r?(m=()=>{r("query-insights")},e[2]=r,e[3]=m):m=e[3];const p=m,h=l==="overview";let u;e[4]!==h?(u=ot(h),e[4]=h,e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Overview"),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==u||e[10]!==d?(c=s("button",{className:u,"data-testid":"mt-tab-overview",onClick:a,type:"button",children:d}),e[8]=a,e[9]=u,e[10]=d,e[11]=c):c=e[11];const x=l==="query-insights";let g;e[12]!==x?(g=ot(x),e[12]=x,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let b;e[16]!==t?(b=t>0&&s("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:t}),e[16]=t,e[17]=b):b=e[17];let S;e[18]!==p||e[19]!==b||e[20]!==g||e[21]!==v?(S=f("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,b]}),e[18]=p,e[19]=b,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==c?(y=f("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[c,S]}),e[23]=S,e[24]=c,e[25]=y):y=e[25],y},ys=i=>{const e=me(13),{history:l,metrics:r}=i;let t;e[0]!==l?(t=l.at(-1)??0,e[0]=l,e[1]=t):t=e[1];let o;e[2]!==r.errors||e[3]!==r.requests?(o=r.requests===0?"—":`${(r.errors/r.requests*100).toFixed(1)}%`,e[2]=r.errors,e[3]=r.requests,e[4]=o):o=e[4];let n;e[5]!==r?(n=Dt(r),e[5]=r,e[6]=n):n=e[6];let a;return e[7]!==l||e[8]!==r||e[9]!==t||e[10]!==o||e[11]!==n?(a=s(ss,{currentDelta:t,errorRate:o,history:l,latencyPercentiles:n,metrics:r}),e[7]=l,e[8]=r,e[9]=t,e[10]=o,e[11]=n,e[12]=a):a=e[12],a},Ns=i=>{const e=me(25),{aggregating:l,liveError:r,onAggregate:t,onClearAggregate:o,onShardKeyChange:n,shardKey:a}=i,m=ge();let p;e[0]!==n||e[1]!==a?(p=s(pt,{onChange:n,testId:"mt-shard-input",value:a}),e[0]=n,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==r?(h=s(gt,{message:r,prefix:"mt"}),e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==m?(u=m(l?"Aggregating…":"All shards"),e[5]=l,e[6]=m,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==t||e[10]!==u?(d=s(tt,{"data-testid":"mt-aggregate",disabled:l,onClick:t,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=l,e[9]=t,e[10]=u,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==m?(c=o!==void 0&&s(tt,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=c):c=e[14];let x;e[15]!==m?(x=m("Open in Cloudflare"),e[15]=m,e[16]=x):x=e[16];let g;e[17]!==x?(g=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:x}),e[17]=x,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==d||e[22]!==c||e[23]!==g?(v=f("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,d,c,g]}),e[19]=p,e[20]=h,e[21]=d,e[22]=c,e[23]=g,e[24]=v):v=e[24],v},Js=i=>{const e=me(41),{initialShardKey:l}=i,{queryShardKey:r,setShardKey:t,shardKey:o}=bt(l),[n,a]=be("overview"),m=xt(r),{data:p,error:h,history:u,liveError:d}=ps(r),c=p??null,{aggregate:x,aggregating:g,clearAggregate:v,runAggregate:b,shardResults:S}=xs(o);let y;e[0]!==c?(y=bs(c),e[0]=c,e[1]=y):y=e[1];const w=y,M=w!==void 0;let _;e[2]!==n||e[3]!==M?(_=gs(M,n),e[2]=n,e[3]=M,e[4]=_):_=e[4];const N=_,$=S===null?void 0:v;let q;e[5]!==g||e[6]!==d||e[7]!==b||e[8]!==t||e[9]!==o||e[10]!==$?(q=s(Ns,{aggregating:g,liveError:d,onAggregate:b,onClearAggregate:$,onShardKeyChange:t,shardKey:o}),e[5]=g,e[6]=d,e[7]=b,e[8]=t,e[9]=o,e[10]=$,e[11]=q):q=e[11];let C;e[12]!==h?(C=h!==null&&s("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let k;e[14]!==N||e[15]!==w?(k=w!==void 0&&s(vs,{activeTab:N,onSelect:a,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=k):k=e[16];let R;e[17]!==N||e[18]!==r||e[19]!==w?(R=N==="query-insights"&&w!==void 0&&s(fs,{shardKey:r}),e[17]=N,e[18]=r,e[19]=w,e[20]=R):R=e[20];let A;e[21]!==N||e[22]!==u||e[23]!==c?(A=N==="overview"&&c!==null&&s(ys,{history:u,metrics:c}),e[21]=N,e[22]=u,e[23]=c,e[24]=A):A=e[24];let I;e[25]!==N||e[26]!==m||e[27]!==r?(I=N==="overview"&&s(es,{onOpenTrace:m,shardKey:r}),e[25]=N,e[26]=m,e[27]=r,e[28]=I):I=e[28];let E;e[29]!==x||e[30]!==N||e[31]!==S?(E=N==="overview"&&x!==null&&S!==null&&s(ts,{aggregate:x,shardResults:S}),e[29]=x,e[30]=N,e[31]=S,e[32]=E):E=e[32];let L;return e[33]!==I||e[34]!==E||e[35]!==q||e[36]!==C||e[37]!==k||e[38]!==R||e[39]!==A?(L=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[q,C,k,R,A,I,E]}),e[33]=I,e[34]=E,e[35]=q,e[36]=C,e[37]=k,e[38]=R,e[39]=A,e[40]=L):L=e[40],L};export{Js as MetricsPanel};
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as ee}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
1
+ import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{h as ee}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
@@ -1 +1 @@
1
- import{c as Ke}from"react/compiler-runtime";import{useState as k,useEffect as We}from"react";import{ConfirmButton as Le}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Xe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ye}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as et}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as tt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as rt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Me=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=rt(),t=je(),r=u??"",f=tt(r),[v,y]=k(null),[p,$e]=k(""),[de,Oe]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Ee]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Me,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Ee(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),We(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Me,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],et(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Me,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Oe(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Oe(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Ee(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let M;e[53]!==me?(M=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=M):M=e[54];let O;e[55]!==t?(O=t("Current bookmark"),e[55]=t,e[56]=O):O=e[56];let E;e[57]!==O?(E=s("h3",{className:"mb-2 text-sm font-semibold",children:O}),e[57]=O,e[58]=E):E=e[58];let L;e[59]!==v?(L=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=L):L=e[60];let U;e[61]!==L?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:L}),e[61]=L,e[62]=U):U=e[62];let F;e[63]!==E||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[E,U]}),e[63]=E,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(Ye,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Le,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Xe,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Le,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==M||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,M,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=M,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
1
+ import{c as Ke}from"react/compiler-runtime";import{useState as k,useEffect as We}from"react";import{ConfirmButton as Le}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Xe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ye}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as et}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as tt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as rt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Me=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=rt(),t=je(),r=u??"",f=tt(r),[v,y]=k(null),[p,$e]=k(""),[de,Oe]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Ee]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Me,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Ee(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),We(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Me,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],et(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Me,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Oe(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Oe(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Ee(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let M;e[53]!==me?(M=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=M):M=e[54];let O;e[55]!==t?(O=t("Current bookmark"),e[55]=t,e[56]=O):O=e[56];let E;e[57]!==O?(E=s("h3",{className:"mb-2 text-sm font-semibold",children:O}),e[57]=O,e[58]=E):E=e[58];let L;e[59]!==v?(L=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=L):L=e[60];let U;e[61]!==L?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:L}),e[61]=L,e[62]=U):U=e[62];let F;e[63]!==E||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[E,U]}),e[63]=E,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(Ye,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Le,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Xe,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Le,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==M||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,M,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=M,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
@@ -1 +1 @@
1
- import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Oe}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as Le,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-CtVPhOGj.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Le(Me.listTables),it=Le(Me.listTableIndexes),rt=Le(Me.readTablePage),dt=Le(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=lt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=tt(m),[o,u]=_(""),[i,v]=_(null),[f,O]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L={},e[1]=L):L=e[1];const[$,z]=_(L),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;O(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),O($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):O($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Oe(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let O;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(O=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=O):O=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let L;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(L=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=L):L=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==L||e[28]!==C||e[29]!==u||e[30]!==O?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,O,L,C]}),e[27]=L,e[28]=C,e[29]=u,e[30]=O,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Oe();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Oe(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,O]=_(""),[S,G]=_(Ct),[y,L]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),O(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{O(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{L(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Oe();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:O,globalTables:S,indexes:G,refresh:y,setShardKey:L,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==L||e[17]!==C?(D=l(Ze,{onChange:L,testId:"sc-shard-input",value:C}),e[16]=L,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==O||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:O===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=O,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
1
+ import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Oe}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as Le,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-CtVPhOGj.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Le(Me.listTables),it=Le(Me.listTableIndexes),rt=Le(Me.readTablePage),dt=Le(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=lt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=tt(m),[o,u]=_(""),[i,v]=_(null),[f,O]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L={},e[1]=L):L=e[1];const[$,z]=_(L),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;O(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),O($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):O($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Oe(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let O;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(O=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=O):O=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let L;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(L=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=L):L=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==L||e[28]!==C||e[29]!==u||e[30]!==O?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,O,L,C]}),e[27]=L,e[28]=C,e[29]=u,e[30]=O,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Oe();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Oe(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,O]=_(""),[S,G]=_(Ct),[y,L]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),O(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{O(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{L(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Oe();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:O,globalTables:S,indexes:G,refresh:y,setShardKey:L,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==L||e[17]!==C?(D=l(Ze,{onChange:L,testId:"sc-shard-input",value:C}),e[16]=L,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==O||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:O===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=O,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
@@ -1 +1 @@
1
- import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{A as f}from"../packem_shared/advisor-view-Dj-mZPAq.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
1
+ import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{A as f}from"../packem_shared/advisor-view-gtf_DhUU.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
@@ -1 +1 @@
1
- import{c as fe}from"react/compiler-runtime";import{E as De}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as Te}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as oe,C as ie}from"../packem_shared/card-By2O8ULa.mjs";import{T as Se,a as Ce,b as me,c as Y,d as Ae,e as Q}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Ee}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as be}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Re}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{b as Ie}from"../packem_shared/cf-links-BPy1pJRO.mjs";import{r as Le,u as Oe,s as Ue}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{useState as ae,useRef as Ne,useEffect as ye}from"react";import{ConfirmButton as Ke}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as ve}from"../packem_shared/button-q0UYSmrn.mjs";import{I as _e}from"../packem_shared/input-CXhxesPC.mjs";import{u as $e}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as pe,f as xe,b as ge}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as d,jsx as s}from"react/jsx-runtime";const ke=["disabled","schema","schema_and_log","schema_and_log_and_data"],je={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,Fe=()=>{const t=fe(67),e=$e(),l=be();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let b;t[1]!==e?(b={owner:e,tokens:n},t[1]=e,t[2]=b):b=t[2];const[p,N]=ae(b),g=p.owner===e?p.tokens:[],[m,f]=ae(null),[h,o]=ae(null);h!==null&&h.owner!==e&&o(null);const i=h?.owner===e?h.token:null,[r,c]=ae(""),[a,u]=ae(""),[w,_]=ae(null),R=w===e,v=Ne(0),k=Ne(e);let D,I;t[3]!==e?(D=()=>{k.current=e},I=[e],t[3]=e,t[4]=D,t[5]=I):(D=t[4],I=t[5]),ye(D,I);let L;t[6]!==e?(L=async()=>{if(k.current!==e)return;v.current=v.current+1;const x=v.current;try{const E=await e.listAdminTokens();x===v.current&&(N({owner:e,tokens:E}),f(null))}catch(E){const re=E;x===v.current&&f(ge(re))}},t[6]=e,t[7]=L):L=t[7];const y=L;let O,U;t[8]!==y?(O=()=>{xe(y())},U=[y],t[8]=y,t[9]=O,t[10]=U):(O=t[9],U=t[10]),ye(O,U);let K;t[11]!==e||t[12]!==i||t[13]!==R||t[14]!==a||t[15]!==r||t[16]!==y?(K=x=>{if(x.preventDefault(),R||i!==null)return;_(e);const E=e,re=a===""?void 0:Date.now()+Number(a)*Be;xe((async()=>{try{const le=await E.createAdminToken({expiresAt:re,name:r.trim()});k.current===E&&(o({owner:E,token:le}),c(""),u(""),await y())}catch(le){f(ge(le))}_(le=>le===E?null:le)})())},t[11]=e,t[12]=i,t[13]=R,t[14]=a,t[15]=r,t[16]=y,t[17]=K):K=t[17];const F=K,q=x=>{xe((async()=>{try{await e.revokeAdminToken(x),o(E=>E?.token.name===x?null:E),await y()}catch(E){const re=E;await y(),k.current===e&&f(ge(re))}})())},M=ie,z="py-0",H="set-admin-tokens";let T;t[18]!==l?(T=l("Admin tokens"),t[18]=l,t[19]=T):T=t[19];let S;t[20]!==T?(S=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T})}),t[20]=T,t[21]=S):S=t[21];const P=oe,W="flex flex-col gap-3 py-3";let C;t[22]!==l?(C=l("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=l,t[23]=C):C=t[23];let $;t[24]!==C?($=s("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=$):$=t[25];let V;t[26]!==m?(V=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:m}),t[26]=m,t[27]=V):V=t[27];let j;t[28]!==i||t[29]!==l?(j=i!==null&&d("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[s("p",{className:"pb-1 text-muted-foreground",children:l("Copy this token now. It is not shown again.")}),s("code",{className:"font-mono break-all select-all",children:i.token}),s("div",{className:"pt-2",children:s(ve,{"data-testid":"set-admin-token-dismiss",onClick:()=>{o(null)},size:"xs",variant:"outline",children:l("Dismiss")})})]}),t[28]=i,t[29]=l,t[30]=j):j=t[30];let A;t[31]!==l?(A=l("Token name"),t[31]=l,t[32]=A):A=t[32];let B;t[33]===Symbol.for("react.memo_cache_sentinel")?(B=x=>{c(x.target.value)},t[33]=B):B=t[33];let G;t[34]!==r||t[35]!==A?(G=s(_e,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:B,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:r}),t[34]=r,t[35]=A,t[36]=G):G=t[36];let J;t[37]!==l?(J=l("Expires in days (optional)"),t[37]=l,t[38]=J):J=t[38];let de;t[39]===Symbol.for("react.memo_cache_sentinel")?(de=x=>{u(x.target.value)},t[39]=de):de=t[39];let X;t[40]!==l?(X=l("Expires in days (optional)"),t[40]=l,t[41]=X):X=t[41];let Z;t[42]!==a||t[43]!==J||t[44]!==X?(Z=s(_e,{"aria-label":J,className:"w-40",min:1,onChange:de,placeholder:X,type:"number",value:a}),t[42]=a,t[43]=J,t[44]=X,t[45]=Z):Z=t[45];const ue=R||i!==null;let ee;t[46]!==l?(ee=l("Create token"),t[46]=l,t[47]=ee):ee=t[47];let te;t[48]!==ue||t[49]!==ee?(te=s(ve,{"data-testid":"set-admin-token-create",disabled:ue,size:"sm",type:"submit",children:ee}),t[48]=ue,t[49]=ee,t[50]=te):te=t[50];let se;t[51]!==F||t[52]!==G||t[53]!==Z||t[54]!==te?(se=d("form",{className:"flex flex-wrap items-end gap-2",onSubmit:F,children:[G,Z,te]}),t[51]=F,t[52]=G,t[53]=Z,t[54]=te,t[55]=se):se=t[55];const he=g.length>0&&d(Se,{"data-testid":"set-admin-tokens-table",children:[s(Ce,{children:d(me,{children:[s(Y,{children:l("name")}),s(Y,{children:l("Created")}),s(Y,{children:l("Last used")}),s(Y,{children:l("Expires")}),s(Y,{})]})}),s(Ae,{children:g.map(x=>d(me,{"data-testid":"set-admin-token-row",children:[d(Q,{className:"font-mono text-xs",children:[x.name,x.revoked===!0&&s("span",{className:"pl-2 text-destructive",children:l("Revoked")})]}),s(Q,{className:"text-xs",children:pe(x.createdAt)}),s(Q,{className:"text-xs",children:pe(x.lastUsedAt,"—")}),s(Q,{className:"text-xs",children:pe(x.expiresAt,l("Never"))}),s(Q,{children:s(Ke,{onConfirm:()=>{q(x.name)},testId:`set-admin-token-revoke-${x.name}`,children:l("Revoke")})})]},x.name))})]});let ne;t[56]!==P||t[57]!==$||t[58]!==V||t[59]!==j||t[60]!==se||t[61]!==he?(ne=d(P,{className:W,children:[$,V,j,se,he]}),t[56]=P,t[57]=$,t[58]=V,t[59]=j,t[60]=se,t[61]=he,t[62]=ne):ne=t[62];let ce;return t[63]!==M||t[64]!==S||t[65]!==ne?(ce=d(M,{className:z,"data-testid":H,children:[S,ne]}),t[63]=M,t[64]=S,t[65]=ne,t[66]=ce):ce=t[66],ce},Me={binding:"outline",secret:"destructive",var:"secondary"},Pe=(t,e)=>{if(t===void 0)return[];const l=[];return t.workerUrl!==void 0&&l.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&l.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&l.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&l.push({label:e("Version"),value:t.versionTag}),l},Ve={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},qe=t=>{const e=[];for(const[l,n]of Object.entries(je))n===t&&e.push(l);return e},ze=()=>{const t=fe(29),e=be();let l,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},n={shardKey:""},t[0]=l,t[1]=n):(l=t[0],n=t[1]);const{data:b}=Ee(Re.aiAvailable,l,n),p=b?.level;let N;t[2]!==p?(N=p===void 0?-1:ke.indexOf(p),t[2]=p,t[3]=N):N=t[3];const g=N;let m;t[4]!==e?(m=e("AI assistant data sharing"),t[4]=e,t[5]=m):m=t[5];let f;t[6]!==m?(f=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),t[6]=m,t[7]=f):f=t[7];let h;t[8]!==p?(h=p!==void 0&&s(Te,{"data-testid":"set-ai-level",variant:p==="disabled"?"outline":"secondary",children:p}),t[8]=p,t[9]=h):h=t[9];let o;t[10]!==f||t[11]!==h?(o=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[f,h]}),t[10]=f,t[11]=h,t[12]=o):o=t[12];let i;t[13]!==g||t[14]!==p||t[15]!==e?(i=ke.map((_,R)=>{const v=g>=R,k=qe(_);return d("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${_}`,children:[d("span",{className:"flex items-center gap-2",children:[s("span",{className:"font-mono text-xs",children:_}),_===p&&s("span",{className:"text-[11px] text-primary",children:e("current")})]}),s("span",{className:"text-xs text-muted-foreground",children:e(Ve[_])}),k.length>0&&s("span",{className:"font-mono text-[11px] text-muted-foreground",children:k.join(", ")})]},_)}),t[13]=g,t[14]=p,t[15]=e,t[16]=i):i=t[16];let r;t[17]!==i?(r=s("ul",{className:"flex flex-col gap-1.5 text-sm",children:i}),t[17]=i,t[18]=r):r=t[18];let c;t[19]!==e?(c=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=c):c=t[20];let a;t[21]!==c?(a=s("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:c}),t[21]=c,t[22]=a):a=t[22];let u;t[23]!==a||t[24]!==r?(u=d(oe,{className:"flex flex-col gap-3 py-3",children:[r,a]}),t[23]=a,t[24]=r,t[25]=u):u=t[25];let w;return t[26]!==u||t[27]!==o?(w=d(ie,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=w):w=t[28],w},we=t=>{const e=fe(18),{modifier:l,name:n,label:b}=t,p=Oe();let N;e[0]!==n?(N=u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),Ue(n,u.key)}},e[0]=n,e[1]=N):N=e[1];const g=N,m=`set-shortcut-${n}`;let f;e[2]!==b?(f=s("dt",{className:"text-muted-foreground",children:b}),e[2]=b,e[3]=f):f=e[3];let h;e[4]!==l?(h=s("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:l}),e[4]=l,e[5]=h):h=e[5];const o=`set-shortcut-input-${n}`,i=p[n];let r;e[6]!==b||e[7]!==g||e[8]!==o||e[9]!==i?(r=s("input",{"aria-label":b,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:g,readOnly:!0,value:i}),e[6]=b,e[7]=g,e[8]=o,e[9]=i,e[10]=r):r=e[10];let c;e[11]!==h||e[12]!==r?(c=d("dd",{className:"flex items-center gap-1.5",children:[h,r]}),e[11]=h,e[12]=r,e[13]=c):c=e[13];let a;return e[14]!==m||e[15]!==f||e[16]!==c?(a=d("div",{className:"contents","data-testid":m,children:[f,c]}),e[14]=m,e[15]=f,e[16]=c,e[17]=a):a=e[17],a},ft=t=>{const e=fe(87),{initialShardKey:l}=t,n=be();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const p=l??"";let N;e[1]!==p?(N={shardKey:p},e[1]=p,e[2]=N):N=e[2];const{data:g,error:m,errorSource:f,isLoading:h}=Ee(Re.getSettings,b,N);let o,i,r,c,a,u,w;if(e[3]!==m||e[4]!==f||e[5]!==g?.deploy||e[6]!==g?.settings||e[7]!==n){const V=Pe(g?.deploy,n);let j;e[15]!==g?.settings?(j=g?.settings??[],e[15]=g?.settings,e[16]=j):j=e[16],o=j,i="flex flex-col gap-4",r="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(c=s("div",{className:"flex flex-wrap items-center gap-3",children:s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ie,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=c):c=e[20];let B;e[21]!==n?(B=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=B):B=e[22],e[23]!==B?(a=s("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=a):a=e[24],e[25]!==m||e[26]!==f?(u=m!==null&&s(De,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=u):u=e[27],w=V.length>0&&d(ie,{className:"py-0","data-testid":"set-deploy",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),s(oe,{className:"py-3",children:s("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(He)})})]}),e[3]=m,e[4]=f,e[5]=g?.deploy,e[6]=g?.settings,e[7]=n,e[8]=o,e[9]=i,e[10]=r,e[11]=c,e[12]=a,e[13]=u,e[14]=w}else o=e[8],i=e[9],r=e[10],c=e[11],a=e[12],u=e[13],w=e[14];let _,R;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=s(ze,{}),R=s(Fe,{}),e[28]=_,e[29]=R):(_=e[28],R=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let k;e[32]!==v?(k=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=k):k=e[33];let D;e[34]!==n?(D=n("Reset"),e[34]=n,e[35]=D):D=e[35];let I;e[36]!==D?(I=s("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Le,type:"button",children:D}),e[36]=D,e[37]=I):I=e[37];let L;e[38]!==k||e[39]!==I?(L=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[k,I]}),e[38]=k,e[39]=I,e[40]=L):L=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let O;e[43]!==y?(O=s(we,{label:y,modifier:"⌘/Ctrl",name:"palette"}),e[43]=y,e[44]=O):O=e[44];let U;e[45]!==n?(U=n("Operation console"),e[45]=n,e[46]=U):U=e[46];let K;e[47]!==U?(K=s(we,{label:U,modifier:"Ctrl",name:"console"}),e[47]=U,e[48]=K):K=e[48];let F;e[49]!==O||e[50]!==K?(F=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[O,K]}),e[49]=O,e[50]=K,e[51]=F):F=e[51];let q;e[52]!==n?(q=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=q):q=e[53];let M;e[54]!==q?(M=s("p",{className:"pt-3 text-xs text-muted-foreground",children:q}),e[54]=q,e[55]=M):M=e[55];let z;e[56]!==F||e[57]!==M?(z=d(oe,{className:"py-3",children:[F,M]}),e[56]=F,e[57]=M,e[58]=z):z=e[58];let H;e[59]!==L||e[60]!==z?(H=d(ie,{className:"py-0","data-testid":"set-preferences",children:[L,z]}),e[59]=L,e[60]=z,e[61]=H):H=e[61];let T;e[62]!==n?(T=n("Environment & bindings"),e[62]=n,e[63]=T):T=e[63];let S;e[64]!==T?(S=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T})}),e[64]=T,e[65]=S):S=e[65];let P;e[66]!==m||e[67]!==h||e[68]!==o.length||e[69]!==n?(P=m===null&&!h&&o.length===0&&s("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=m,e[67]=h,e[68]=o.length,e[69]=n,e[70]=P):P=e[70];let W;e[71]!==o||e[72]!==n?(W=o.length>0&&s(oe,{className:"px-0 py-0",children:d(Se,{"data-testid":"set-table",children:[s(Ce,{children:d(me,{children:[s(Y,{children:n("name")}),s(Y,{children:n("kind")}),s(Y,{children:n("value")})]})}),s(Ae,{children:o.map(We)})]})}),e[71]=o,e[72]=n,e[73]=W):W=e[73];let C;e[74]!==S||e[75]!==P||e[76]!==W?(C=d(ie,{className:"py-0",children:[S,P,W]}),e[74]=S,e[75]=P,e[76]=W,e[77]=C):C=e[77];let $;return e[78]!==H||e[79]!==C||e[80]!==i||e[81]!==r||e[82]!==c||e[83]!==a||e[84]!==u||e[85]!==w?($=d("div",{className:i,"data-testid":r,children:[c,a,u,w,_,R,H,C]}),e[78]=H,e[79]=C,e[80]=i,e[81]=r,e[82]=c,e[83]=a,e[84]=u,e[85]=w,e[86]=$):$=e[86],$};function He(t){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[s("dt",{className:"text-muted-foreground",children:t.label}),s("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}function We(t){return d(me,{"data-testid":"set-row",children:[s(Q,{className:"font-mono text-xs font-medium",children:t.name}),s(Q,{children:s(Te,{variant:Me[t.kind],children:t.bindingType??t.kind})}),s(Q,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??s("span",{className:"text-muted-foreground",children:"—"})})]},t.name)}export{ft as SettingsPanel};
1
+ import{c as fe}from"react/compiler-runtime";import{E as De}from"../packem_shared/error-alert-3AR_-s_s.mjs";import{B as Te}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as oe,C as ie}from"../packem_shared/card-By2O8ULa.mjs";import{T as Se,a as Ce,b as me,c as Y,d as Ae,e as Q}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Ee}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as be}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Re}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{b as Ie}from"../packem_shared/cf-links-BPy1pJRO.mjs";import{r as Le,u as Oe,s as Ue}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{useState as ae,useRef as Ne,useEffect as ye}from"react";import{ConfirmButton as Ke}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as ve}from"../packem_shared/button-q0UYSmrn.mjs";import{I as _e}from"../packem_shared/input-CXhxesPC.mjs";import{u as $e}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as pe,f as xe,b as ge}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as d,jsx as s}from"react/jsx-runtime";const ke=["disabled","schema","schema_and_log","schema_and_log_and_data"],je={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,Fe=()=>{const t=fe(67),e=$e(),l=be();let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let b;t[1]!==e?(b={owner:e,tokens:n},t[1]=e,t[2]=b):b=t[2];const[p,N]=ae(b),g=p.owner===e?p.tokens:[],[m,f]=ae(null),[h,o]=ae(null);h!==null&&h.owner!==e&&o(null);const i=h?.owner===e?h.token:null,[r,c]=ae(""),[a,u]=ae(""),[w,_]=ae(null),R=w===e,v=Ne(0),k=Ne(e);let D,I;t[3]!==e?(D=()=>{k.current=e},I=[e],t[3]=e,t[4]=D,t[5]=I):(D=t[4],I=t[5]),ye(D,I);let L;t[6]!==e?(L=async()=>{if(k.current!==e)return;v.current=v.current+1;const x=v.current;try{const E=await e.listAdminTokens();x===v.current&&(N({owner:e,tokens:E}),f(null))}catch(E){const re=E;x===v.current&&f(ge(re))}},t[6]=e,t[7]=L):L=t[7];const y=L;let O,U;t[8]!==y?(O=()=>{xe(y())},U=[y],t[8]=y,t[9]=O,t[10]=U):(O=t[9],U=t[10]),ye(O,U);let K;t[11]!==e||t[12]!==i||t[13]!==R||t[14]!==a||t[15]!==r||t[16]!==y?(K=x=>{if(x.preventDefault(),R||i!==null)return;_(e);const E=e,re=a===""?void 0:Date.now()+Number(a)*Be;xe((async()=>{try{const le=await E.createAdminToken({expiresAt:re,name:r.trim()});k.current===E&&(o({owner:E,token:le}),c(""),u(""),await y())}catch(le){f(ge(le))}_(le=>le===E?null:le)})())},t[11]=e,t[12]=i,t[13]=R,t[14]=a,t[15]=r,t[16]=y,t[17]=K):K=t[17];const F=K,q=x=>{xe((async()=>{try{await e.revokeAdminToken(x),o(E=>E?.token.name===x?null:E),await y()}catch(E){const re=E;await y(),k.current===e&&f(ge(re))}})())},M=ie,z="py-0",H="set-admin-tokens";let T;t[18]!==l?(T=l("Admin tokens"),t[18]=l,t[19]=T):T=t[19];let S;t[20]!==T?(S=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T})}),t[20]=T,t[21]=S):S=t[21];const P=oe,W="flex flex-col gap-3 py-3";let C;t[22]!==l?(C=l("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=l,t[23]=C):C=t[23];let $;t[24]!==C?($=s("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=$):$=t[25];let V;t[26]!==m?(V=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:m}),t[26]=m,t[27]=V):V=t[27];let j;t[28]!==i||t[29]!==l?(j=i!==null&&d("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[s("p",{className:"pb-1 text-muted-foreground",children:l("Copy this token now. It is not shown again.")}),s("code",{className:"font-mono break-all select-all",children:i.token}),s("div",{className:"pt-2",children:s(ve,{"data-testid":"set-admin-token-dismiss",onClick:()=>{o(null)},size:"xs",variant:"outline",children:l("Dismiss")})})]}),t[28]=i,t[29]=l,t[30]=j):j=t[30];let A;t[31]!==l?(A=l("Token name"),t[31]=l,t[32]=A):A=t[32];let B;t[33]===Symbol.for("react.memo_cache_sentinel")?(B=x=>{c(x.target.value)},t[33]=B):B=t[33];let G;t[34]!==r||t[35]!==A?(G=s(_e,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:B,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:r}),t[34]=r,t[35]=A,t[36]=G):G=t[36];let J;t[37]!==l?(J=l("Expires in days (optional)"),t[37]=l,t[38]=J):J=t[38];let de;t[39]===Symbol.for("react.memo_cache_sentinel")?(de=x=>{u(x.target.value)},t[39]=de):de=t[39];let X;t[40]!==l?(X=l("Expires in days (optional)"),t[40]=l,t[41]=X):X=t[41];let Z;t[42]!==a||t[43]!==J||t[44]!==X?(Z=s(_e,{"aria-label":J,className:"w-40",min:1,onChange:de,placeholder:X,type:"number",value:a}),t[42]=a,t[43]=J,t[44]=X,t[45]=Z):Z=t[45];const ue=R||i!==null;let ee;t[46]!==l?(ee=l("Create token"),t[46]=l,t[47]=ee):ee=t[47];let te;t[48]!==ue||t[49]!==ee?(te=s(ve,{"data-testid":"set-admin-token-create",disabled:ue,size:"sm",type:"submit",children:ee}),t[48]=ue,t[49]=ee,t[50]=te):te=t[50];let se;t[51]!==F||t[52]!==G||t[53]!==Z||t[54]!==te?(se=d("form",{className:"flex flex-wrap items-end gap-2",onSubmit:F,children:[G,Z,te]}),t[51]=F,t[52]=G,t[53]=Z,t[54]=te,t[55]=se):se=t[55];const he=g.length>0&&d(Se,{"data-testid":"set-admin-tokens-table",children:[s(Ce,{children:d(me,{children:[s(Y,{children:l("name")}),s(Y,{children:l("Created")}),s(Y,{children:l("Last used")}),s(Y,{children:l("Expires")}),s(Y,{})]})}),s(Ae,{children:g.map(x=>d(me,{"data-testid":"set-admin-token-row",children:[d(Q,{className:"font-mono text-xs",children:[x.name,x.revoked===!0&&s("span",{className:"pl-2 text-destructive",children:l("Revoked")})]}),s(Q,{className:"text-xs",children:pe(x.createdAt)}),s(Q,{className:"text-xs",children:pe(x.lastUsedAt,"—")}),s(Q,{className:"text-xs",children:pe(x.expiresAt,l("Never"))}),s(Q,{children:s(Ke,{onConfirm:()=>{q(x.name)},testId:`set-admin-token-revoke-${x.name}`,children:l("Revoke")})})]},x.name))})]});let ne;t[56]!==P||t[57]!==$||t[58]!==V||t[59]!==j||t[60]!==se||t[61]!==he?(ne=d(P,{className:W,children:[$,V,j,se,he]}),t[56]=P,t[57]=$,t[58]=V,t[59]=j,t[60]=se,t[61]=he,t[62]=ne):ne=t[62];let ce;return t[63]!==M||t[64]!==S||t[65]!==ne?(ce=d(M,{className:z,"data-testid":H,children:[S,ne]}),t[63]=M,t[64]=S,t[65]=ne,t[66]=ce):ce=t[66],ce},Me={binding:"outline",secret:"destructive",var:"secondary"},Pe=(t,e)=>{if(t===void 0)return[];const l=[];return t.workerUrl!==void 0&&l.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&l.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&l.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&l.push({label:e("Version"),value:t.versionTag}),l},Ve={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},qe=t=>{const e=[];for(const[l,n]of Object.entries(je))n===t&&e.push(l);return e},ze=()=>{const t=fe(29),e=be();let l,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},n={shardKey:""},t[0]=l,t[1]=n):(l=t[0],n=t[1]);const{data:b}=Ee(Re.aiAvailable,l,n),p=b?.level;let N;t[2]!==p?(N=p===void 0?-1:ke.indexOf(p),t[2]=p,t[3]=N):N=t[3];const g=N;let m;t[4]!==e?(m=e("AI assistant data sharing"),t[4]=e,t[5]=m):m=t[5];let f;t[6]!==m?(f=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),t[6]=m,t[7]=f):f=t[7];let h;t[8]!==p?(h=p!==void 0&&s(Te,{"data-testid":"set-ai-level",variant:p==="disabled"?"outline":"secondary",children:p}),t[8]=p,t[9]=h):h=t[9];let o;t[10]!==f||t[11]!==h?(o=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[f,h]}),t[10]=f,t[11]=h,t[12]=o):o=t[12];let i;t[13]!==g||t[14]!==p||t[15]!==e?(i=ke.map((_,R)=>{const v=g>=R,k=qe(_);return d("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${_}`,children:[d("span",{className:"flex items-center gap-2",children:[s("span",{className:"font-mono text-xs",children:_}),_===p&&s("span",{className:"text-[11px] text-primary",children:e("current")})]}),s("span",{className:"text-xs text-muted-foreground",children:e(Ve[_])}),k.length>0&&s("span",{className:"font-mono text-[11px] text-muted-foreground",children:k.join(", ")})]},_)}),t[13]=g,t[14]=p,t[15]=e,t[16]=i):i=t[16];let r;t[17]!==i?(r=s("ul",{className:"flex flex-col gap-1.5 text-sm",children:i}),t[17]=i,t[18]=r):r=t[18];let c;t[19]!==e?(c=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=c):c=t[20];let a;t[21]!==c?(a=s("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:c}),t[21]=c,t[22]=a):a=t[22];let u;t[23]!==a||t[24]!==r?(u=d(oe,{className:"flex flex-col gap-3 py-3",children:[r,a]}),t[23]=a,t[24]=r,t[25]=u):u=t[25];let w;return t[26]!==u||t[27]!==o?(w=d(ie,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=w):w=t[28],w},we=t=>{const e=fe(18),{modifier:l,name:n,label:b}=t,p=Oe();let N;e[0]!==n?(N=u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),Ue(n,u.key)}},e[0]=n,e[1]=N):N=e[1];const g=N,m=`set-shortcut-${n}`;let f;e[2]!==b?(f=s("dt",{className:"text-muted-foreground",children:b}),e[2]=b,e[3]=f):f=e[3];let h;e[4]!==l?(h=s("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:l}),e[4]=l,e[5]=h):h=e[5];const o=`set-shortcut-input-${n}`,i=p[n];let r;e[6]!==b||e[7]!==g||e[8]!==o||e[9]!==i?(r=s("input",{"aria-label":b,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:g,readOnly:!0,value:i}),e[6]=b,e[7]=g,e[8]=o,e[9]=i,e[10]=r):r=e[10];let c;e[11]!==h||e[12]!==r?(c=d("dd",{className:"flex items-center gap-1.5",children:[h,r]}),e[11]=h,e[12]=r,e[13]=c):c=e[13];let a;return e[14]!==m||e[15]!==f||e[16]!==c?(a=d("div",{className:"contents","data-testid":m,children:[f,c]}),e[14]=m,e[15]=f,e[16]=c,e[17]=a):a=e[17],a},ft=t=>{const e=fe(87),{initialShardKey:l}=t,n=be();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const p=l??"";let N;e[1]!==p?(N={shardKey:p},e[1]=p,e[2]=N):N=e[2];const{data:g,error:m,errorSource:f,isLoading:h}=Ee(Re.getSettings,b,N);let o,i,r,c,a,u,w;if(e[3]!==m||e[4]!==f||e[5]!==g?.deploy||e[6]!==g?.settings||e[7]!==n){const V=Pe(g?.deploy,n);let j;e[15]!==g?.settings?(j=g?.settings??[],e[15]=g?.settings,e[16]=j):j=e[16],o=j,i="flex flex-col gap-4",r="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(c=s("div",{className:"flex flex-wrap items-center gap-3",children:s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ie,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=c):c=e[20];let B;e[21]!==n?(B=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=B):B=e[22],e[23]!==B?(a=s("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=a):a=e[24],e[25]!==m||e[26]!==f?(u=m!==null&&s(De,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=u):u=e[27],w=V.length>0&&d(ie,{className:"py-0","data-testid":"set-deploy",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),s(oe,{className:"py-3",children:s("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(He)})})]}),e[3]=m,e[4]=f,e[5]=g?.deploy,e[6]=g?.settings,e[7]=n,e[8]=o,e[9]=i,e[10]=r,e[11]=c,e[12]=a,e[13]=u,e[14]=w}else o=e[8],i=e[9],r=e[10],c=e[11],a=e[12],u=e[13],w=e[14];let _,R;e[28]===Symbol.for("react.memo_cache_sentinel")?(_=s(ze,{}),R=s(Fe,{}),e[28]=_,e[29]=R):(_=e[28],R=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let k;e[32]!==v?(k=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=k):k=e[33];let D;e[34]!==n?(D=n("Reset"),e[34]=n,e[35]=D):D=e[35];let I;e[36]!==D?(I=s("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Le,type:"button",children:D}),e[36]=D,e[37]=I):I=e[37];let L;e[38]!==k||e[39]!==I?(L=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[k,I]}),e[38]=k,e[39]=I,e[40]=L):L=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let O;e[43]!==y?(O=s(we,{label:y,modifier:"⌘/Ctrl",name:"palette"}),e[43]=y,e[44]=O):O=e[44];let U;e[45]!==n?(U=n("Operation console"),e[45]=n,e[46]=U):U=e[46];let K;e[47]!==U?(K=s(we,{label:U,modifier:"Ctrl",name:"console"}),e[47]=U,e[48]=K):K=e[48];let F;e[49]!==O||e[50]!==K?(F=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[O,K]}),e[49]=O,e[50]=K,e[51]=F):F=e[51];let q;e[52]!==n?(q=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=q):q=e[53];let M;e[54]!==q?(M=s("p",{className:"pt-3 text-xs text-muted-foreground",children:q}),e[54]=q,e[55]=M):M=e[55];let z;e[56]!==F||e[57]!==M?(z=d(oe,{className:"py-3",children:[F,M]}),e[56]=F,e[57]=M,e[58]=z):z=e[58];let H;e[59]!==L||e[60]!==z?(H=d(ie,{className:"py-0","data-testid":"set-preferences",children:[L,z]}),e[59]=L,e[60]=z,e[61]=H):H=e[61];let T;e[62]!==n?(T=n("Environment & bindings"),e[62]=n,e[63]=T):T=e[63];let S;e[64]!==T?(S=s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T})}),e[64]=T,e[65]=S):S=e[65];let P;e[66]!==m||e[67]!==h||e[68]!==o.length||e[69]!==n?(P=m===null&&!h&&o.length===0&&s("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=m,e[67]=h,e[68]=o.length,e[69]=n,e[70]=P):P=e[70];let W;e[71]!==o||e[72]!==n?(W=o.length>0&&s(oe,{className:"px-0 py-0",children:d(Se,{"data-testid":"set-table",children:[s(Ce,{children:d(me,{children:[s(Y,{children:n("name")}),s(Y,{children:n("kind")}),s(Y,{children:n("value")})]})}),s(Ae,{children:o.map(We)})]})}),e[71]=o,e[72]=n,e[73]=W):W=e[73];let C;e[74]!==S||e[75]!==P||e[76]!==W?(C=d(ie,{className:"py-0",children:[S,P,W]}),e[74]=S,e[75]=P,e[76]=W,e[77]=C):C=e[77];let $;return e[78]!==H||e[79]!==C||e[80]!==i||e[81]!==r||e[82]!==c||e[83]!==a||e[84]!==u||e[85]!==w?($=d("div",{className:i,"data-testid":r,children:[c,a,u,w,_,R,H,C]}),e[78]=H,e[79]=C,e[80]=i,e[81]=r,e[82]=c,e[83]=a,e[84]=u,e[85]=w,e[86]=$):$=e[86],$};function He(t){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[s("dt",{className:"text-muted-foreground",children:t.label}),s("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}function We(t){return d(me,{"data-testid":"set-row",children:[s(Q,{className:"font-mono text-xs font-medium",children:t.name}),s(Q,{children:s(Te,{variant:Me[t.kind],children:t.bindingType??t.kind})}),s(Q,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??s("span",{className:"text-muted-foreground",children:"—"})})]},t.name)}export{ft as SettingsPanel};
@@ -1,4 +1,4 @@
1
- import{c as G}from"react/compiler-runtime";import{useState as te,useMemo as je,useCallback as Ze,useEffect as ue,useRef as de,useId as ht}from"react";import{u as bt}from"../packem_shared/assistant-provider-BQG7QZAu.mjs";import{u as gt}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{u as $e}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{u as Oe,n as et,b as Be,r as Ce,s as xt}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as Re,f as ie,c as Ie,l as vt,b as yt}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as St}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import wt from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{c as ae}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as W,jsx as u,Fragment as xe}from"react/jsx-runtime";import{I as Le}from"../packem_shared/input-CXhxesPC.mjs";import{a as tt}from"../packem_shared/assistant-reason-D6EwMCxT.mjs";import{diffLines as Ct}from"diff";import{S as Et,a as Nt}from"../packem_shared/sql-result-table-DCwooMGW.mjs";import{ShardInput as kt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{A as Tt}from"../packem_shared/alert-PB5W11MM.mjs";import{E as Rt}from"../packem_shared/grid-features-Drvfswwy.mjs";const Lt="x",ze=" ",_t={'"':'"',"'":"'","[":"]","`":"`"},nt=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
1
+ import{c as G}from"react/compiler-runtime";import{useState as te,useMemo as je,useCallback as Ze,useEffect as ue,useRef as de,useId as ht}from"react";import{u as bt}from"../packem_shared/assistant-provider-Dw0roZh3.mjs";import{u as gt}from"../packem_shared/use-assistant-rpc-AKu8hvPm.mjs";import{u as $e}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{u as Oe,n as et,b as Be,r as Ce,s as xt}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as Re,f as ie,c as Ie,l as vt,b as yt}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as St}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import wt from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{c as ae}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as W,jsx as u,Fragment as xe}from"react/jsx-runtime";import{I as Le}from"../packem_shared/input-CXhxesPC.mjs";import{a as tt}from"../packem_shared/assistant-reason-D6EwMCxT.mjs";import{diffLines as Ct}from"diff";import{S as Et,a as Nt}from"../packem_shared/sql-result-table-DCwooMGW.mjs";import{ShardInput as kt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{A as Tt}from"../packem_shared/alert-PB5W11MM.mjs";import{E as Rt}from"../packem_shared/grid-features-Drvfswwy.mjs";const Lt="x",ze=" ",_t={'"':'"',"'":"'","[":"]","`":"`"},nt=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
2
2
  `;)n+=1;return n},st=(l,e)=>{const n=l.indexOf("*/",e+2);return n===-1?-1:n+2},ot=l=>{const e=l.split("");let n=0;for(;n<l.length;){const t=l[n]??"",s=_t[t];if(t==="-"&&l[n+1]==="-"){const o=nt(l,n);e.fill(ze,n,o),n=o}else if(t==="/"&&l[n+1]==="*"){const o=st(l,n);if(o===-1)return;e.fill(ze,n,o),n=o}else if(s!==void 0){let o=n+1;for(;o<l.length;)if(l[o]!==s)o+=1;else if(s!=="]"&&l[o+1]===s)o+=2;else break;if(o>=l.length)return;e.fill(Lt,n,o+1),n=o+1}else n+=1}for(let t=0;t<l.length;t+=1)l[t]===`
3
3
  `&&(e[t]=`
4
4
  `);return e.join("")},qt="__lunora_admin_tokens__",Pe=new Set([qt,"dbstat","sqlite_dbpage"]),lt="pragma_",It=l=>/[\p{L}_]/u.test(l)||(l.codePointAt(0)??0)>127,At=l=>/[\p{L}\p{N}_$]/u.test(l)||(l.codePointAt(0)??0)>127,Dt=/^pragma_\w+$/u,Ot=l=>Pe.has(l)||Dt.test(l)?l:void 0,Ke=l=>{if(Pe.has(l)||l.startsWith(lt))return l},Ue=(l,e,n)=>{let t="",s=e+1;for(;s<l.length;){const o=l[s];if(o===n){if(n!=="]"&&l[s+1]===n){t+=n,s+=2;continue}return{end:s+1,text:t}}t+=o,s+=1}},Ye={'"':'"',"`":"`","[":"]"},Ae=l=>{const e=l.toLowerCase().replaceAll(/["'`[\]]/gu,"");for(const n of Pe)if(e.includes(n))return n;return/\bpragma_/u.test(e)?lt:void 0},Mt=l=>{let e=0;for(;e<l.length;){const n=l[e];if(/\s/u.test(n))e+=1;else if(n==="-"&&l[e+1]==="-"){const t=l.indexOf(`
@@ -1 +1 @@
1
- import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-BrRWqnCr.mjs";import{GlobalDataBrowser as Y}from"../packem_shared/GlobalDataBrowser-DB1B-WAN.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",$=50,z=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,y=()=>O(N).filter(z),B=r=>{I(N,r)},H=(r,e)=>{const l=r.trim();if(l==="")return y();const n=[{name:l,view:e},...y().filter(o=>o.name!==l)].slice(0,$);return B(n),n},U=r=>{const e=y().filter(l=>l.name!==r);return B(e),e},W=r=>{const e=k(15),{onChange:l,tier:n}=r,o=K();let p;e[0]!==l?(p=S=>{l(S.target.value)},e[0]=l,e[1]=p):p=e[1];const u=p;let s;e[2]!==o?(s=o("Storage tier"),e[2]=o,e[3]=s):s=e[3];let d;e[4]!==s?(d=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];const g=w[n];let c,i;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=v("option",{value:"shard",children:w.shard.label}),i=v("option",{value:"global",children:w.global.label}),e[6]=c,e[7]=i):(c=e[6],i=e[7]);let h;e[8]!==u||e[9]!==g.title||e[10]!==n?(h=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:u,title:g.title,value:n,children:[c,i]}),e[8]=u,e[9]=g.title,e[10]=n,e[11]=h):h=e[11];let f;return e[12]!==d||e[13]!==h?(f=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[d,h]}),e[12]=d,e[13]=h,e[14]=f):f=e[14],f},Z=()=>{try{m(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},ge=({canGenerateRows:r=!1,editable:e=!1,initialShardKey:l})=>{const n=J(),o=F(),p=M(),u=P({strict:!1}),s=L(u),d=q(u),g=()=>p.state.location.pathname.split("/").findLast(Boolean)==="data",c=s.tier??"shard",i=s.table,[h,f]=Q(()=>y()),[S,C]=Q(()=>new Set);A(()=>{m((async()=>{try{const a=await n.listGlobalTables();C(new Set(a.map(t=>t.name)))}catch{}})())},[n]),A(()=>{c==="shard"&&i!==void 0&&S.has(i)&&m(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[S,o,i,c]);const R=a=>{m(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{g()&&m(o({search:b=>({schema:b.schema,search:t?.search,shard:b.shard,table:a}),to:"/data"}))},G=a=>{m(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},_=a=>{const t=D(a),{current:b}=d;(b.filters??void 0)===t.filters&&(b.order??void 0)===t.order&&(b.search??void 0)===t.search&&(b.shard??void 0)===t.shard||!g()||m(o({replace:!0,search:V=>({...V,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},j={onApplyQuery:a=>{const t=D(a.view);m(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:Z,onDeleteQuery:a=>{f(U(a))},onSaveQuery:(a,t)=>{f(H(a,t))},saved:h},x=v(W,{onChange:R,tier:c});return c==="global"?v(Y,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(X,{canGenerateRows:r,editable:e,globalTableNames:S,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:u.pins,initialSearch:s.search,initialShardKey:s.shard??l,onNavigateToGlobal:G,onSelectTable:T,onViewChange:_,queryBar:j,schemaSwitch:x,tableParam:i})};export{ge as TableEditor};
1
+ import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-CkVOu6py.mjs";import{GlobalDataBrowser as Y}from"../packem_shared/GlobalDataBrowser-l2ECwXCm.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",$=50,z=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,y=()=>O(N).filter(z),B=r=>{I(N,r)},H=(r,e)=>{const l=r.trim();if(l==="")return y();const n=[{name:l,view:e},...y().filter(o=>o.name!==l)].slice(0,$);return B(n),n},U=r=>{const e=y().filter(l=>l.name!==r);return B(e),e},W=r=>{const e=k(15),{onChange:l,tier:n}=r,o=K();let p;e[0]!==l?(p=S=>{l(S.target.value)},e[0]=l,e[1]=p):p=e[1];const u=p;let s;e[2]!==o?(s=o("Storage tier"),e[2]=o,e[3]=s):s=e[3];let d;e[4]!==s?(d=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];const g=w[n];let c,i;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=v("option",{value:"shard",children:w.shard.label}),i=v("option",{value:"global",children:w.global.label}),e[6]=c,e[7]=i):(c=e[6],i=e[7]);let h;e[8]!==u||e[9]!==g.title||e[10]!==n?(h=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:u,title:g.title,value:n,children:[c,i]}),e[8]=u,e[9]=g.title,e[10]=n,e[11]=h):h=e[11];let f;return e[12]!==d||e[13]!==h?(f=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[d,h]}),e[12]=d,e[13]=h,e[14]=f):f=e[14],f},Z=()=>{try{m(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},ge=({canGenerateRows:r=!1,editable:e=!1,initialShardKey:l})=>{const n=J(),o=F(),p=M(),u=P({strict:!1}),s=L(u),d=q(u),g=()=>p.state.location.pathname.split("/").findLast(Boolean)==="data",c=s.tier??"shard",i=s.table,[h,f]=Q(()=>y()),[S,C]=Q(()=>new Set);A(()=>{m((async()=>{try{const a=await n.listGlobalTables();C(new Set(a.map(t=>t.name)))}catch{}})())},[n]),A(()=>{c==="shard"&&i!==void 0&&S.has(i)&&m(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[S,o,i,c]);const R=a=>{m(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{g()&&m(o({search:b=>({schema:b.schema,search:t?.search,shard:b.shard,table:a}),to:"/data"}))},G=a=>{m(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},_=a=>{const t=D(a),{current:b}=d;(b.filters??void 0)===t.filters&&(b.order??void 0)===t.order&&(b.search??void 0)===t.search&&(b.shard??void 0)===t.shard||!g()||m(o({replace:!0,search:V=>({...V,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},j={onApplyQuery:a=>{const t=D(a.view);m(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:Z,onDeleteQuery:a=>{f(U(a))},onSaveQuery:(a,t)=>{f(H(a,t))},saved:h},x=v(W,{onChange:R,tier:c});return c==="global"?v(Y,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(X,{canGenerateRows:r,editable:e,globalTableNames:S,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:u.pins,initialSearch:s.search,initialShardKey:s.shard??l,onNavigateToGlobal:G,onSelectTable:T,onViewChange:_,queryBar:j,schemaSwitch:x,tableParam:i})};export{ge as TableEditor};