@lunora/studio 1.0.0-alpha.361 → 1.0.0-alpha.363

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 (327) hide show
  1. package/dist/index.d.mts +4 -1
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  9. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  10. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  11. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  12. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  13. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  14. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  15. package/dist/packem_chunks/MailPanel.mjs +1 -1
  16. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  17. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  18. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  19. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  20. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  21. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  22. package/dist/packem_chunks/SqlEditorPanel.mjs +24 -9
  23. package/dist/packem_chunks/TableEditor.mjs +1 -1
  24. package/dist/packem_chunks/agents-panel.mjs +1 -1
  25. package/dist/packem_chunks/ai-knowledge.mjs +1 -0
  26. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  27. package/dist/packem_chunks/assistant-panel.mjs +3 -0
  28. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  29. package/dist/packem_chunks/containers-panel.mjs +1 -1
  30. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  31. package/dist/packem_chunks/evals-panel.mjs +1 -1
  32. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  33. package/dist/packem_chunks/flags-panel.mjs +1 -1
  34. package/dist/packem_chunks/issues-panel.mjs +1 -1
  35. package/dist/packem_chunks/kv-browser.mjs +1 -1
  36. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  37. package/dist/packem_chunks/migrations-route.mjs +1 -1
  38. package/dist/packem_chunks/payments-panel.mjs +1 -1
  39. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  40. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  41. package/dist/packem_chunks/queues-panel.mjs +1 -1
  42. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  43. package/dist/packem_chunks/rls-panel.mjs +1 -1
  44. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  45. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  46. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  47. package/dist/packem_chunks/traces-panel.mjs +1 -1
  48. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  49. package/dist/packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs +1 -0
  50. package/dist/packem_shared/{ApiDocsPanel-DD2Uns6b.mjs → ApiDocsPanel-B9S9l1Ce.mjs} +1 -1
  51. package/dist/packem_shared/{DataBrowser-CVRWnNWu.mjs → DataBrowser-Dm-jhIUP.mjs} +2 -2
  52. package/dist/packem_shared/{GlobalDataBrowser-DC47T6Zl.mjs → GlobalDataBrowser-C1Y8GUhe.mjs} +1 -1
  53. package/dist/packem_shared/{HomePanel-D12HxHQo.mjs → HomePanel-B5ytwPIo.mjs} +1 -1
  54. package/dist/packem_shared/{MigrationsPanel-DMkxSXNl.mjs → MigrationsPanel-CwLikxDT.mjs} +1 -1
  55. package/dist/packem_shared/Studio-B89ZNMOD.mjs +1 -0
  56. package/dist/packem_shared/{StudioApp-isdWpF9P.mjs → StudioApp-C9l1a3A8.mjs} +1 -1
  57. package/dist/packem_shared/advisor-view-CzieqKMe.mjs +5 -0
  58. package/dist/packem_shared/assistant-provider-Bp72uWsq.mjs +1 -0
  59. package/dist/packem_shared/assistant-reason-D6EwMCxT.mjs +1 -0
  60. package/dist/packem_shared/{cf-links-CBJ5SywP.mjs → cf-links-C4DVTr8A.mjs} +1 -1
  61. package/dist/packem_shared/error-alert-DKXm5h19.mjs +6 -0
  62. package/dist/packem_shared/{home-panel-CDVTuTF8.mjs → home-panel-5fGktYeD.mjs} +1 -1
  63. package/dist/packem_shared/recording-client-z4CBi0y8.mjs +1 -0
  64. package/dist/packem_shared/studio-gZfpz1wC.mjs +2 -0
  65. package/dist/packem_shared/{table-list-sidebar-CNadcIgG.mjs → table-list-sidebar-kpHaDWjy.mjs} +1 -1
  66. package/dist/packem_shared/use-assistant-rpc-GCUK2zPa.mjs +1 -0
  67. package/dist/standalone/chunk-2DT3QG6Q.js +1 -0
  68. package/dist/standalone/chunk-2EB7FN5S.js +1 -0
  69. package/dist/standalone/chunk-2H6VLY2M.js +1 -0
  70. package/dist/standalone/chunk-2NGKUO32.js +1 -0
  71. package/dist/standalone/chunk-2SNHKJXK.js +1 -0
  72. package/dist/standalone/chunk-2W4UO5BC.js +1 -0
  73. package/dist/standalone/chunk-32V7XGNC.js +1 -0
  74. package/dist/standalone/{chunk-SLIDAWNX.js → chunk-3D67ZJRW.js} +1 -1
  75. package/dist/standalone/chunk-3X3NXJBR.js +1 -0
  76. package/dist/standalone/chunk-4EPW63HS.js +1 -0
  77. package/dist/standalone/chunk-4L55URI5.js +2 -0
  78. package/dist/standalone/chunk-4N76XUNG.js +1 -0
  79. package/dist/standalone/{chunk-WS36BO4R.js → chunk-4NKJV7YX.js} +1 -1
  80. package/dist/standalone/chunk-4PI2OSSP.js +1 -0
  81. package/dist/standalone/chunk-53XKGQEE.js +1 -0
  82. package/dist/standalone/chunk-5GYHGDIF.js +8 -0
  83. package/dist/standalone/chunk-5PEAXTYQ.js +1 -0
  84. package/dist/standalone/chunk-5QUTVSHM.js +1 -0
  85. package/dist/standalone/{chunk-BYOGQ2IV.js → chunk-5RX5CQSU.js} +2 -2
  86. package/dist/standalone/{chunk-O2NMPIV2.js → chunk-5WNGRT7N.js} +1 -1
  87. package/dist/standalone/chunk-5Z2U4KBN.js +1 -0
  88. package/dist/standalone/chunk-66BMMNUR.js +1 -0
  89. package/dist/standalone/chunk-6FPV3EK2.js +1 -0
  90. package/dist/standalone/chunk-6G3E4PJ2.js +1 -0
  91. package/dist/standalone/chunk-75TRPM7O.js +1 -0
  92. package/dist/standalone/chunk-7MLX5CGD.js +1 -0
  93. package/dist/standalone/chunk-7QEZ2SFW.js +1 -0
  94. package/dist/standalone/chunk-7TQ7BZ67.js +1 -0
  95. package/dist/standalone/chunk-A2Q3TGIQ.js +1 -0
  96. package/dist/standalone/chunk-AD5J2ANS.js +1 -0
  97. package/dist/standalone/chunk-ALR4VAUE.js +1 -0
  98. package/dist/standalone/chunk-AXE2SDRU.js +1 -0
  99. package/dist/standalone/chunk-AZIKM5BA.js +1 -0
  100. package/dist/standalone/chunk-BAEIW3YS.js +1 -0
  101. package/dist/standalone/chunk-BBDTJG2K.js +1 -0
  102. package/dist/standalone/chunk-BCUOQNI2.js +1 -0
  103. package/dist/standalone/chunk-BG2CJOVS.js +1 -0
  104. package/dist/standalone/chunk-BI6MZHZJ.js +1 -0
  105. package/dist/standalone/chunk-BKI3JMXQ.js +1 -0
  106. package/dist/standalone/chunk-CKEQX655.js +1 -0
  107. package/dist/standalone/{chunk-DX55P3KZ.js → chunk-CL3JOU6F.js} +1 -1
  108. package/dist/standalone/chunk-CP7QNLR4.js +1 -0
  109. package/dist/standalone/chunk-CVSIFPI5.js +1 -0
  110. package/dist/standalone/chunk-D57B4MFK.js +1 -0
  111. package/dist/standalone/chunk-D65UVZIA.js +1 -0
  112. package/dist/standalone/{chunk-DBVJ5VLI.js → chunk-DA2CAFXI.js} +1 -1
  113. package/dist/standalone/chunk-DB6QX4X6.js +1 -0
  114. package/dist/standalone/chunk-DZFXH55R.js +1 -0
  115. package/dist/standalone/chunk-ELSQ4FVH.js +1 -0
  116. package/dist/standalone/chunk-EPWCW2DF.js +1 -0
  117. package/dist/standalone/chunk-FHLODLBC.js +1 -0
  118. package/dist/standalone/chunk-FJLRSFTE.js +1 -0
  119. package/dist/standalone/{chunk-3FS22LNI.js → chunk-FVCBNFQW.js} +3 -3
  120. package/dist/standalone/{chunk-VEWQWS3J.js → chunk-FWM5Z6CH.js} +1 -1
  121. package/dist/standalone/chunk-GJXCPZDN.js +1 -0
  122. package/dist/standalone/chunk-GNI37YCV.js +33 -0
  123. package/dist/standalone/chunk-GVQPNM3T.js +3 -0
  124. package/dist/standalone/chunk-GWNGVKLG.js +1 -0
  125. package/dist/standalone/chunk-GXTSE66Z.js +1 -0
  126. package/dist/standalone/chunk-H3EIPYRZ.js +1 -0
  127. package/dist/standalone/chunk-H5TMLWIS.js +1 -0
  128. package/dist/standalone/{chunk-XIRKBJPD.js → chunk-HBG6SSE2.js} +5 -5
  129. package/dist/standalone/chunk-HC2B7SXW.js +1 -0
  130. package/dist/standalone/chunk-HCOF7HOM.js +1 -0
  131. package/dist/standalone/chunk-HGCOTYPV.js +1 -0
  132. package/dist/standalone/chunk-HLHMHCXS.js +1 -0
  133. package/dist/standalone/chunk-HSF2DCJ2.js +30 -0
  134. package/dist/standalone/chunk-HZDLUAWS.js +1 -0
  135. package/dist/standalone/{chunk-3PAYDWHN.js → chunk-I3SSF2T6.js} +2 -2
  136. package/dist/standalone/chunk-I5QX75DE.js +1 -0
  137. package/dist/standalone/chunk-ICHZ2IBL.js +1 -0
  138. package/dist/standalone/{chunk-7ZIYHKLX.js → chunk-IG5VD7R7.js} +3 -3
  139. package/dist/standalone/{chunk-SU5DTRGK.js → chunk-IHGRWY3Y.js} +1 -1
  140. package/dist/standalone/chunk-J45HAKBU.js +1 -0
  141. package/dist/standalone/chunk-J4PQAVOF.js +1 -0
  142. package/dist/standalone/chunk-JD6PRRFO.js +1 -0
  143. package/dist/standalone/chunk-JOPNP4EO.js +1 -0
  144. package/dist/standalone/chunk-JVP3TR3A.js +1 -0
  145. package/dist/standalone/chunk-KGLIQIZU.js +1 -0
  146. package/dist/standalone/{chunk-ONWGX5Y4.js → chunk-KH6OXCG3.js} +1 -1
  147. package/dist/standalone/chunk-KKMQUBYH.js +1 -0
  148. package/dist/standalone/chunk-L2FYX4FN.js +1 -0
  149. package/dist/standalone/chunk-LDHJRHPZ.js +1 -0
  150. package/dist/standalone/chunk-LSEUUZN4.js +1 -0
  151. package/dist/standalone/chunk-MNYDT3RH.js +1 -0
  152. package/dist/standalone/chunk-MT4ICMXJ.js +1 -0
  153. package/dist/standalone/chunk-MXJTD2OX.js +1 -0
  154. package/dist/standalone/chunk-NGZNXNRD.js +1 -0
  155. package/dist/standalone/chunk-O3AZ7JKE.js +1 -0
  156. package/dist/standalone/chunk-OK2QU2EV.js +1 -0
  157. package/dist/standalone/{chunk-IH2CJZF2.js → chunk-ONTGYVAN.js} +1 -1
  158. package/dist/standalone/chunk-OWRKSQPE.js +1 -0
  159. package/dist/standalone/chunk-OZAOWE7T.js +1 -0
  160. package/dist/standalone/chunk-P5EVJEGC.js +1 -0
  161. package/dist/standalone/chunk-PDBW6GTJ.js +1 -0
  162. package/dist/standalone/chunk-PJUVJTDR.js +1 -0
  163. package/dist/standalone/chunk-Q3IA6HPX.js +1 -0
  164. package/dist/standalone/chunk-QAOZXPLU.js +1 -0
  165. package/dist/standalone/chunk-QKUVJIRX.js +1 -0
  166. package/dist/standalone/chunk-QNM2J7MG.js +1 -0
  167. package/dist/standalone/chunk-QRA7AKYO.js +1 -0
  168. package/dist/standalone/chunk-RBIVXSXT.js +1 -0
  169. package/dist/standalone/chunk-RCXNYW7P.js +1 -0
  170. package/dist/standalone/{chunk-TDVDZ7XQ.js → chunk-RIAOZECW.js} +1 -1
  171. package/dist/standalone/{chunk-LUHXNZI4.js → chunk-RTS5G3ET.js} +1 -1
  172. package/dist/standalone/chunk-S36FVTKK.js +1 -0
  173. package/dist/standalone/chunk-SDDEOSQB.js +1 -0
  174. package/dist/standalone/chunk-SHHGIT7M.js +7 -0
  175. package/dist/standalone/chunk-SR6CPTRT.js +1 -0
  176. package/dist/standalone/chunk-SVQWZPO4.js +1 -0
  177. package/dist/standalone/chunk-T3ZCW3RG.js +1 -0
  178. package/dist/standalone/chunk-TEMI7MVE.js +1 -0
  179. package/dist/standalone/chunk-TKBTZX4K.js +1 -0
  180. package/dist/standalone/chunk-TW4O2BA5.js +159 -0
  181. package/dist/standalone/chunk-U5MPNEM2.js +1 -0
  182. package/dist/standalone/chunk-UD5REVU2.js +1 -0
  183. package/dist/standalone/chunk-ULQNADMJ.js +1 -0
  184. package/dist/standalone/chunk-UPPNZ6MI.js +1 -0
  185. package/dist/standalone/{chunk-PQH2LSJX.js → chunk-UQA2AJGI.js} +1 -1
  186. package/dist/standalone/chunk-UTQLJKHH.js +1 -0
  187. package/dist/standalone/chunk-UVG3ZISC.js +1 -0
  188. package/dist/standalone/chunk-UXBNXITB.js +1 -0
  189. package/dist/standalone/chunk-UZ2ZXB74.js +1 -0
  190. package/dist/standalone/chunk-V3BE427M.js +1 -0
  191. package/dist/standalone/chunk-VQDTA4P6.js +1 -0
  192. package/dist/standalone/chunk-W4LJQYCI.js +1 -0
  193. package/dist/standalone/chunk-WLHQ4FKC.js +1 -0
  194. package/dist/standalone/chunk-XPFVUAPX.js +1 -0
  195. package/dist/standalone/{chunk-SYGCASPT.js → chunk-Y2YLTUMD.js} +1 -1
  196. package/dist/standalone/chunk-Y3IGTWUE.js +1 -0
  197. package/dist/standalone/chunk-Y64STA6O.js +1 -0
  198. package/dist/standalone/chunk-YEVTA35E.js +1 -0
  199. package/dist/standalone/chunk-YEXTJUKQ.js +6 -0
  200. package/dist/standalone/chunk-YFTPHGS2.js +1 -0
  201. package/dist/standalone/{chunk-R36QXQZX.js → chunk-YORPLSI5.js} +1 -1
  202. package/dist/standalone/chunk-Z64BZNPS.js +1 -0
  203. package/dist/standalone/chunk-Z6VILGGP.js +5 -0
  204. package/dist/standalone/chunk-ZBOB33BA.js +1 -0
  205. package/dist/standalone/{chunk-5R2YO7HF.js → chunk-ZOKSVUID.js} +4 -4
  206. package/dist/standalone/{chunk-H7HZ42JY.js → chunk-ZPQBVYNN.js} +1 -1
  207. package/dist/standalone/chunk-ZSWW2UGP.js +1 -0
  208. package/dist/standalone/studio.js +2 -2
  209. package/dist/styles.css +1 -1
  210. package/package.json +7 -6
  211. package/dist/packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs +0 -1
  212. package/dist/packem_shared/Studio-MA8kKZLu.mjs +0 -1
  213. package/dist/packem_shared/advisor-view-tBumWci_.mjs +0 -1
  214. package/dist/packem_shared/error-alert-C0R39DO1.mjs +0 -1
  215. package/dist/packem_shared/recording-client-DAipTA_n.mjs +0 -1
  216. package/dist/packem_shared/studio-UhUrPz5J.mjs +0 -2
  217. package/dist/packem_shared/use-sql-assistant-rZPs3LC3.mjs +0 -1
  218. package/dist/standalone/chunk-2AH4ABE5.js +0 -1
  219. package/dist/standalone/chunk-2G57ENH5.js +0 -1
  220. package/dist/standalone/chunk-3GXPALXG.js +0 -1
  221. package/dist/standalone/chunk-3GYLOE4V.js +0 -1
  222. package/dist/standalone/chunk-473JK2PQ.js +0 -1
  223. package/dist/standalone/chunk-4C4THJUD.js +0 -1
  224. package/dist/standalone/chunk-4DAKKAK7.js +0 -1
  225. package/dist/standalone/chunk-4M57OYFX.js +0 -1
  226. package/dist/standalone/chunk-4SQBAPY6.js +0 -1
  227. package/dist/standalone/chunk-5DNGK3NT.js +0 -1
  228. package/dist/standalone/chunk-5GIQ6C5N.js +0 -1
  229. package/dist/standalone/chunk-5WJG7FMH.js +0 -1
  230. package/dist/standalone/chunk-63KDHS3H.js +0 -1
  231. package/dist/standalone/chunk-6B6ARRMI.js +0 -1
  232. package/dist/standalone/chunk-6LMO2D54.js +0 -1
  233. package/dist/standalone/chunk-6M7FLLMT.js +0 -1
  234. package/dist/standalone/chunk-6QEXGYWH.js +0 -1
  235. package/dist/standalone/chunk-6UTZXEW3.js +0 -1
  236. package/dist/standalone/chunk-6VAY6L4J.js +0 -1
  237. package/dist/standalone/chunk-7PADVGQX.js +0 -1
  238. package/dist/standalone/chunk-7RGYCU6F.js +0 -1
  239. package/dist/standalone/chunk-7UM5ROG6.js +0 -1
  240. package/dist/standalone/chunk-A566HCBX.js +0 -1
  241. package/dist/standalone/chunk-A5JISKHE.js +0 -1
  242. package/dist/standalone/chunk-ADNRFCMZ.js +0 -1
  243. package/dist/standalone/chunk-AP4PC2M4.js +0 -1
  244. package/dist/standalone/chunk-BFE2DRP6.js +0 -33
  245. package/dist/standalone/chunk-BPEB4KFE.js +0 -1
  246. package/dist/standalone/chunk-BVX45MU5.js +0 -7
  247. package/dist/standalone/chunk-C6GN7ZXJ.js +0 -1
  248. package/dist/standalone/chunk-CL2VZNDI.js +0 -1
  249. package/dist/standalone/chunk-CNA3TVUK.js +0 -1
  250. package/dist/standalone/chunk-CZ6HBDIL.js +0 -1
  251. package/dist/standalone/chunk-D6S7MXW4.js +0 -1
  252. package/dist/standalone/chunk-E26OT26O.js +0 -1
  253. package/dist/standalone/chunk-FCAXVYAX.js +0 -1
  254. package/dist/standalone/chunk-FXPAJDES.js +0 -1
  255. package/dist/standalone/chunk-HHRYM6UW.js +0 -1
  256. package/dist/standalone/chunk-HPRF5LMA.js +0 -1
  257. package/dist/standalone/chunk-IB22LETR.js +0 -1
  258. package/dist/standalone/chunk-IBJVVHV5.js +0 -1
  259. package/dist/standalone/chunk-IENQRRQT.js +0 -1
  260. package/dist/standalone/chunk-IQ4TTHQT.js +0 -1
  261. package/dist/standalone/chunk-ITH5LRWM.js +0 -1
  262. package/dist/standalone/chunk-J6VFG6M5.js +0 -1
  263. package/dist/standalone/chunk-JSDKOE4U.js +0 -1
  264. package/dist/standalone/chunk-JTGGWF7R.js +0 -1
  265. package/dist/standalone/chunk-JZD7ZN3F.js +0 -1
  266. package/dist/standalone/chunk-K3CWB3AM.js +0 -1
  267. package/dist/standalone/chunk-KNFB3FGW.js +0 -1
  268. package/dist/standalone/chunk-KNXWDE4N.js +0 -1
  269. package/dist/standalone/chunk-KRPXOSBL.js +0 -1
  270. package/dist/standalone/chunk-KRY7BYHT.js +0 -1
  271. package/dist/standalone/chunk-KYAG2YMF.js +0 -1
  272. package/dist/standalone/chunk-KZCEJFZF.js +0 -1
  273. package/dist/standalone/chunk-KZILJQX3.js +0 -8
  274. package/dist/standalone/chunk-LEYUH5TS.js +0 -1
  275. package/dist/standalone/chunk-LFM672WN.js +0 -1
  276. package/dist/standalone/chunk-LIGOLZND.js +0 -1
  277. package/dist/standalone/chunk-LPU6YTSU.js +0 -1
  278. package/dist/standalone/chunk-MWJC3S62.js +0 -1
  279. package/dist/standalone/chunk-NP2AQOLE.js +0 -1
  280. package/dist/standalone/chunk-NVKLYDOH.js +0 -1
  281. package/dist/standalone/chunk-O2X2XYCM.js +0 -1
  282. package/dist/standalone/chunk-O3MDWYXF.js +0 -1
  283. package/dist/standalone/chunk-ONG4JEZD.js +0 -1
  284. package/dist/standalone/chunk-OS26JXYA.js +0 -1
  285. package/dist/standalone/chunk-OXFKZ4BM.js +0 -1
  286. package/dist/standalone/chunk-PGTEGUAB.js +0 -1
  287. package/dist/standalone/chunk-PTBUWRBY.js +0 -1
  288. package/dist/standalone/chunk-Q6HA3L2H.js +0 -1
  289. package/dist/standalone/chunk-QGV5ARD2.js +0 -1
  290. package/dist/standalone/chunk-QWRK4ESB.js +0 -1
  291. package/dist/standalone/chunk-RL2ITK2N.js +0 -1
  292. package/dist/standalone/chunk-RTJO3AR4.js +0 -1
  293. package/dist/standalone/chunk-SFY646MC.js +0 -1
  294. package/dist/standalone/chunk-T5UMHPAB.js +0 -1
  295. package/dist/standalone/chunk-T6HV2FQP.js +0 -2
  296. package/dist/standalone/chunk-T7ZKNNGX.js +0 -1
  297. package/dist/standalone/chunk-TCYPNSTV.js +0 -1
  298. package/dist/standalone/chunk-TQM6XHBA.js +0 -1
  299. package/dist/standalone/chunk-TRMWBRRU.js +0 -1
  300. package/dist/standalone/chunk-TW7KJSMR.js +0 -15
  301. package/dist/standalone/chunk-TYD3V4NB.js +0 -1
  302. package/dist/standalone/chunk-TZKLK52W.js +0 -1
  303. package/dist/standalone/chunk-U4RXQSQ7.js +0 -1
  304. package/dist/standalone/chunk-UNZ2UBVL.js +0 -1
  305. package/dist/standalone/chunk-VJRNOSRY.js +0 -1
  306. package/dist/standalone/chunk-W2BCSK5S.js +0 -1
  307. package/dist/standalone/chunk-W7MRISE3.js +0 -1
  308. package/dist/standalone/chunk-WM72PRE3.js +0 -1
  309. package/dist/standalone/chunk-X4WHMCOZ.js +0 -1
  310. package/dist/standalone/chunk-X74GEPSG.js +0 -1
  311. package/dist/standalone/chunk-XKPD4SFN.js +0 -1
  312. package/dist/standalone/chunk-XMSNLMWU.js +0 -1
  313. package/dist/standalone/chunk-XOPFDWXX.js +0 -1
  314. package/dist/standalone/chunk-XQLOVFPP.js +0 -1
  315. package/dist/standalone/chunk-XSHYZPGF.js +0 -1
  316. package/dist/standalone/chunk-XST3UEHU.js +0 -1
  317. package/dist/standalone/chunk-XYR5NST4.js +0 -1
  318. package/dist/standalone/chunk-Y74LIFSL.js +0 -1
  319. package/dist/standalone/chunk-YHTHRYP5.js +0 -1
  320. package/dist/standalone/chunk-YMEKCV27.js +0 -1
  321. package/dist/standalone/chunk-Z5EV64KS.js +0 -1
  322. package/dist/standalone/chunk-ZBON5T5A.js +0 -1
  323. package/dist/standalone/chunk-ZGSL4DPP.js +0 -1
  324. package/dist/standalone/chunk-ZOQTXWPK.js +0 -1
  325. package/dist/standalone/chunk-ZTOREMGH.js +0 -1
  326. package/dist/standalone/chunk-ZZ5GICTF.js +0 -1
  327. /package/dist/standalone/{chunk-UYEZR3BI.js → chunk-P6VNMPWR.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-4aGsMs95.mjs";import{c as yt}from"../packem_shared/cf-links-CBJ5SywP.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-DUXsXId1.mjs";import{c as yt}from"../packem_shared/cf-links-C4DVTr8A.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-C0R39DO1.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-4aGsMs95.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-DKXm5h19.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-DUXsXId1.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-4aGsMs95.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-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-DUXsXId1.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-4aGsMs95.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-DUXsXId1.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-4aGsMs95.mjs";import{A as f}from"../packem_shared/advisor-view-tBumWci_.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-DUXsXId1.mjs";import{A as f}from"../packem_shared/advisor-view-CzieqKMe.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 G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-C0R39DO1.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card-By2O8ULa.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs";import{C as ne}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{r as ae,u as ie,s as oe}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as d,jsx as r}from"react/jsx-runtime";const de={binding:"outline",secret:"destructive",var:"secondary"},ce=(s,e)=>{if(s===void 0)return[];const u=[];return s.workerUrl!==void 0&&u.push({label:e("URL"),value:s.workerUrl}),s.environment!==void 0&&u.push({label:e("Environment"),value:s.environment}),s.deploymentId!==void 0&&u.push({label:e("Deployment"),value:s.deploymentId}),s.versionTag!==void 0&&u.push({label:e("Version"),value:s.versionTag}),u},z=s=>{const e=G(18),{modifier:u,name:t,label:p}=s,F=ie();let b;e[0]!==t?(b=a=>{if(!["Escape","Tab"].includes(a.key)){if(a.shiftKey){a.preventDefault();return}a.preventDefault(),oe(t,a.key)}},e[0]=t,e[1]=b):b=e[1];const c=b,m=`set-shortcut-${t}`;let f;e[2]!==p?(f=r("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=f):f=e[3];let h;e[4]!==u?(h=r("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];const n=`set-shortcut-input-${t}`,x=F[t];let i;e[6]!==p||e[7]!==c||e[8]!==n||e[9]!==x?(i=r("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":n,onKeyDown:c,readOnly:!0,value:x}),e[6]=p,e[7]=c,e[8]=n,e[9]=x,e[10]=i):i=e[10];let l;e[11]!==h||e[12]!==i?(l=d("dd",{className:"flex items-center gap-1.5",children:[h,i]}),e[11]=h,e[12]=i,e[13]=l):l=e[13];let o;return e[14]!==m||e[15]!==f||e[16]!==l?(o=d("div",{className:"contents","data-testid":m,children:[f,l]}),e[14]=m,e[15]=f,e[16]=l,e[17]=o):o=e[17],o},Ce=s=>{const e=G(85),{initialShardKey:u}=s,t=se();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const F=u??"";let b;e[1]!==F?(b={shardKey:F},e[1]=F,e[2]=b):b=e[2];const{data:c,error:m,errorSource:f,isLoading:h}=re(le.getSettings,p,b);let n,x,i,l,o,a,g;if(e[3]!==m||e[4]!==f||e[5]!==c?.deploy||e[6]!==c?.settings||e[7]!==t){const q=ce(c?.deploy,t);let H;e[15]!==c?.settings?(H=c?.settings??[],e[15]=c?.settings,e[16]=H):H=e[16],n=H,x="flex flex-col gap-4",i="lunora-settings";let j;e[17]!==t?(j=t("Open in Cloudflare"),e[17]=t,e[18]=j):j=e[18],e[19]!==j?(l=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:j})}),e[19]=j,e[20]=l):l=e[20];let B;e[21]!==t?(B=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=t,e[22]=B):B=e[22],e[23]!==B?(o=r("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=o):o=e[24],e[25]!==m||e[26]!==f?(a=m!==null&&r(X,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=a):a=e[27],g=q.length>0&&d(M,{className:"py-0","data-testid":"set-deploy",children:[r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),r(P,{className:"py-3",children:r("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:q.map(me)})})]}),e[3]=m,e[4]=f,e[5]=c?.deploy,e[6]=c?.settings,e[7]=t,e[8]=n,e[9]=x,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=g}else n=e[8],x=e[9],i=e[10],l=e[11],o=e[12],a=e[13],g=e[14];let N;e[28]!==t?(N=t("Keyboard shortcuts"),e[28]=t,e[29]=N):N=e[29];let v;e[30]!==N?(v=r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[30]=N,e[31]=v):v=e[31];let y;e[32]!==t?(y=t("Reset"),e[32]=t,e[33]=y):y=e[33];let k;e[34]!==y?(k=r("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:ae,type:"button",children:y}),e[34]=y,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==t?(C=t("Command palette"),e[39]=t,e[40]=C):C=e[40];let T;e[41]!==C?(T=r(z,{label:C,modifier:"⌘/Ctrl",name:"palette"}),e[41]=C,e[42]=T):T=e[42];let S;e[43]!==t?(S=t("Operation console"),e[43]=t,e[44]=S):S=e[44];let R;e[45]!==S?(R=r(z,{label:S,modifier:"Ctrl",name:"console"}),e[45]=S,e[46]=R):R=e[46];let _;e[47]!==T||e[48]!==R?(_=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[T,R]}),e[47]=T,e[48]=R,e[49]=_):_=e[49];let D;e[50]!==t?(D=t("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=t,e[51]=D):D=e[51];let E;e[52]!==D?(E=r("p",{className:"pt-3 text-xs text-muted-foreground",children:D}),e[52]=D,e[53]=E):E=e[53];let I;e[54]!==_||e[55]!==E?(I=d(P,{className:"py-3",children:[_,E]}),e[54]=_,e[55]=E,e[56]=I):I=e[56];let K;e[57]!==w||e[58]!==I?(K=d(M,{className:"py-0","data-testid":"set-preferences",children:[w,I]}),e[57]=w,e[58]=I,e[59]=K):K=e[59];let A;e[60]!==t?(A=t("Environment & bindings"),e[60]=t,e[61]=A):A=e[61];let O;e[62]!==A?(O=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[62]=A,e[63]=O):O=e[63];let U;e[64]!==m||e[65]!==h||e[66]!==n.length||e[67]!==t?(U=m===null&&!h&&n.length===0&&r("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[64]=m,e[65]=h,e[66]=n.length,e[67]=t,e[68]=U):U=e[68];let L;e[69]!==n||e[70]!==t?(L=n.length>0&&r(P,{className:"px-0 py-0",children:d(Z,{"data-testid":"set-table",children:[r(ee,{children:d(J,{children:[r(Q,{children:t("name")}),r(Q,{children:t("kind")}),r(Q,{children:t("value")})]})}),r(te,{children:n.map(fe)})]})}),e[69]=n,e[70]=t,e[71]=L):L=e[71];let $;e[72]!==O||e[73]!==U||e[74]!==L?($=d(M,{className:"py-0",children:[O,U,L]}),e[72]=O,e[73]=U,e[74]=L,e[75]=$):$=e[75];let V;return e[76]!==K||e[77]!==$||e[78]!==x||e[79]!==i||e[80]!==l||e[81]!==o||e[82]!==a||e[83]!==g?(V=d("div",{className:x,"data-testid":i,children:[l,o,a,g,K,$]}),e[76]=K,e[77]=$,e[78]=x,e[79]=i,e[80]=l,e[81]=o,e[82]=a,e[83]=g,e[84]=V):V=e[84],V};function me(s){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[r("dt",{className:"text-muted-foreground",children:s.label}),r("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}function fe(s){return d(J,{"data-testid":"set-row",children:[r(W,{className:"font-mono text-xs font-medium",children:s.name}),r(W,{children:r(Y,{variant:de[s.kind],children:s.bindingType??s.kind})}),r(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??r("span",{className:"text-muted-foreground",children:"—"})})]},s.name)}export{Ce as SettingsPanel};
1
+ import{c as Y}from"react/compiler-runtime";import{E as le}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as X}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as H,a as q}from"../packem_shared/card-By2O8ULa.mjs";import{T as ae,a as re,b as Z,c as Q,d as ne,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as ee}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as te}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as se}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{a as oe}from"../packem_shared/cf-links-C4DVTr8A.mjs";import{r as ie,u as de,s as ce}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as u,jsx as l}from"react/jsx-runtime";const G=["disabled","schema","schema_and_log","schema_and_log_and_data"],me={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},fe={binding:"outline",secret:"destructive",var:"secondary"},ue=(t,e)=>{if(t===void 0)return[];const m=[];return t.workerUrl!==void 0&&m.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&m.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&m.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&m.push({label:e("Version"),value:t.versionTag}),m},he={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."},pe=t=>{const e=[];for(const[m,s]of Object.entries(me))s===t&&e.push(m);return e},xe=()=>{const t=Y(29),e=te();let m,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(m={},s={shardKey:""},t[0]=m,t[1]=s):(m=t[0],s=t[1]);const{data:b}=ee(se.aiAvailable,m,s),f=b?.level;let g;t[2]!==f?(g=f===void 0?-1:G.indexOf(f),t[2]=f,t[3]=g):g=t[3];const x=g;let d;t[4]!==e?(d=e("AI assistant data sharing"),t[4]=e,t[5]=d):d=t[5];let c;t[6]!==d?(c=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),t[6]=d,t[7]=c):c=t[7];let h;t[8]!==f?(h=f!==void 0&&l(X,{"data-testid":"set-ai-level",variant:f==="disabled"?"outline":"secondary",children:f}),t[8]=f,t[9]=h):h=t[9];let r;t[10]!==c||t[11]!==h?(r=u("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[c,h]}),t[10]=c,t[11]=h,t[12]=r):r=t[12];let p;t[13]!==x||t[14]!==f||t[15]!==e?(p=G.map((v,T)=>{const y=x>=T,_=pe(v);return u("li",{className:y?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(y),"data-testid":`set-ai-tier-${v}`,children:[u("span",{className:"flex items-center gap-2",children:[l("span",{className:"font-mono text-xs",children:v}),v===f&&l("span",{className:"text-[11px] text-primary",children:e("current")})]}),l("span",{className:"text-xs text-muted-foreground",children:e(he[v])}),_.length>0&&l("span",{className:"font-mono text-[11px] text-muted-foreground",children:_.join(", ")})]},v)}),t[13]=x,t[14]=f,t[15]=e,t[16]=p):p=t[16];let o;t[17]!==p?(o=l("ul",{className:"flex flex-col gap-1.5 text-sm",children:p}),t[17]=p,t[18]=o):o=t[18];let a;t[19]!==e?(a=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]=a):a=t[20];let i;t[21]!==a?(i=l("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:a}),t[21]=a,t[22]=i):i=t[22];let n;t[23]!==i||t[24]!==o?(n=u(q,{className:"flex flex-col gap-3 py-3",children:[o,i]}),t[23]=i,t[24]=o,t[25]=n):n=t[25];let N;return t[26]!==n||t[27]!==r?(N=u(H,{className:"py-0","data-testid":"set-ai-sharing",children:[r,n]}),t[26]=n,t[27]=r,t[28]=N):N=t[28],N},J=t=>{const e=Y(18),{modifier:m,name:s,label:b}=t,f=de();let g;e[0]!==s?(g=n=>{if(!["Escape","Tab"].includes(n.key)){if(n.shiftKey){n.preventDefault();return}n.preventDefault(),ce(s,n.key)}},e[0]=s,e[1]=g):g=e[1];const x=g,d=`set-shortcut-${s}`;let c;e[2]!==b?(c=l("dt",{className:"text-muted-foreground",children:b}),e[2]=b,e[3]=c):c=e[3];let h;e[4]!==m?(h=l("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:m}),e[4]=m,e[5]=h):h=e[5];const r=`set-shortcut-input-${s}`,p=f[s];let o;e[6]!==b||e[7]!==x||e[8]!==r||e[9]!==p?(o=l("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":r,onKeyDown:x,readOnly:!0,value:p}),e[6]=b,e[7]=x,e[8]=r,e[9]=p,e[10]=o):o=e[10];let a;e[11]!==h||e[12]!==o?(a=u("dd",{className:"flex items-center gap-1.5",children:[h,o]}),e[11]=h,e[12]=o,e[13]=a):a=e[13];let i;return e[14]!==d||e[15]!==c||e[16]!==a?(i=u("div",{className:"contents","data-testid":d,children:[c,a]}),e[14]=d,e[15]=c,e[16]=a,e[17]=i):i=e[17],i},Le=t=>{const e=Y(86),{initialShardKey:m}=t,s=te();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const f=m??"";let g;e[1]!==f?(g={shardKey:f},e[1]=f,e[2]=g):g=e[2];const{data:x,error:d,errorSource:c,isLoading:h}=ee(se.getSettings,b,g);let r,p,o,a,i,n,N;if(e[3]!==d||e[4]!==c||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==s){const z=ue(x?.deploy,s);let M;e[15]!==x?.settings?(M=x?.settings??[],e[15]=x?.settings,e[16]=M):M=e[16],r=M,p="flex flex-col gap-4",o="lunora-settings";let P;e[17]!==s?(P=s("Open in Cloudflare"),e[17]=s,e[18]=P):P=e[18],e[19]!==P?(a=l("div",{className:"flex flex-wrap items-center gap-3",children:l("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:oe,rel:"noreferrer",target:"_blank",children:P})}),e[19]=P,e[20]=a):a=e[20];let B;e[21]!==s?(B=s("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=s,e[22]=B):B=e[22],e[23]!==B?(i=l("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=i):i=e[24],e[25]!==d||e[26]!==c?(n=d!==null&&l(le,{error:c,testId:"set-error"}),e[25]=d,e[26]=c,e[27]=n):n=e[27],N=z.length>0&&u(H,{className:"py-0","data-testid":"set-deploy",children:[l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Deployment")})}),l(q,{className:"py-3",children:l("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:z.map(ge)})})]}),e[3]=d,e[4]=c,e[5]=x?.deploy,e[6]=x?.settings,e[7]=s,e[8]=r,e[9]=p,e[10]=o,e[11]=a,e[12]=i,e[13]=n,e[14]=N}else r=e[8],p=e[9],o=e[10],a=e[11],i=e[12],n=e[13],N=e[14];let v;e[28]===Symbol.for("react.memo_cache_sentinel")?(v=l(xe,{}),e[28]=v):v=e[28];let T;e[29]!==s?(T=s("Keyboard shortcuts"),e[29]=s,e[30]=T):T=e[30];let y;e[31]!==T?(y=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T}),e[31]=T,e[32]=y):y=e[32];let _;e[33]!==s?(_=s("Reset"),e[33]=s,e[34]=_):_=e[34];let w;e[35]!==_?(w=l("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:ie,type:"button",children:_}),e[35]=_,e[36]=w):w=e[36];let S;e[37]!==y||e[38]!==w?(S=u("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[y,w]}),e[37]=y,e[38]=w,e[39]=S):S=e[39];let k;e[40]!==s?(k=s("Command palette"),e[40]=s,e[41]=k):k=e[41];let C;e[42]!==k?(C=l(J,{label:k,modifier:"⌘/Ctrl",name:"palette"}),e[42]=k,e[43]=C):C=e[43];let E;e[44]!==s?(E=s("Operation console"),e[44]=s,e[45]=E):E=e[45];let A;e[46]!==E?(A=l(J,{label:E,modifier:"Ctrl",name:"console"}),e[46]=E,e[47]=A):A=e[47];let L;e[48]!==C||e[49]!==A?(L=u("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[C,A]}),e[48]=C,e[49]=A,e[50]=L):L=e[50];let R;e[51]!==s?(R=s("Stored in this browser. Focus a box and press a key to rebind it."),e[51]=s,e[52]=R):R=e[52];let O;e[53]!==R?(O=l("p",{className:"pt-3 text-xs text-muted-foreground",children:R}),e[53]=R,e[54]=O):O=e[54];let D;e[55]!==L||e[56]!==O?(D=u(q,{className:"py-3",children:[L,O]}),e[55]=L,e[56]=O,e[57]=D):D=e[57];let I;e[58]!==S||e[59]!==D?(I=u(H,{className:"py-0","data-testid":"set-preferences",children:[S,D]}),e[58]=S,e[59]=D,e[60]=I):I=e[60];let K;e[61]!==s?(K=s("Environment & bindings"),e[61]=s,e[62]=K):K=e[62];let U;e[63]!==K?(U=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[63]=K,e[64]=U):U=e[64];let j;e[65]!==d||e[66]!==h||e[67]!==r.length||e[68]!==s?(j=d===null&&!h&&r.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:s("No environment variables or bindings.")}),e[65]=d,e[66]=h,e[67]=r.length,e[68]=s,e[69]=j):j=e[69];let $;e[70]!==r||e[71]!==s?($=r.length>0&&l(q,{className:"px-0 py-0",children:u(ae,{"data-testid":"set-table",children:[l(re,{children:u(Z,{children:[l(Q,{children:s("name")}),l(Q,{children:s("kind")}),l(Q,{children:s("value")})]})}),l(ne,{children:r.map(be)})]})}),e[70]=r,e[71]=s,e[72]=$):$=e[72];let V;e[73]!==U||e[74]!==j||e[75]!==$?(V=u(H,{className:"py-0",children:[U,j,$]}),e[73]=U,e[74]=j,e[75]=$,e[76]=V):V=e[76];let F;return e[77]!==I||e[78]!==V||e[79]!==p||e[80]!==o||e[81]!==a||e[82]!==i||e[83]!==n||e[84]!==N?(F=u("div",{className:p,"data-testid":o,children:[a,i,n,N,v,I,V]}),e[77]=I,e[78]=V,e[79]=p,e[80]=o,e[81]=a,e[82]=i,e[83]=n,e[84]=N,e[85]=F):F=e[85],F};function ge(t){return u("div",{className:"contents","data-testid":"set-deploy-row",children:[l("dt",{className:"text-muted-foreground",children:t.label}),l("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}function be(t){return u(Z,{"data-testid":"set-row",children:[l(W,{className:"font-mono text-xs font-medium",children:t.name}),l(W,{children:l(X,{variant:fe[t.kind],children:t.bindingType??t.kind})}),l(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??l("span",{className:"text-muted-foreground",children:"—"})})]},t.name)}export{Le as SettingsPanel};