@lunora/studio 1.0.0-alpha.34 → 1.0.0-alpha.340

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 (472) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.mts +1597 -0
  4. package/dist/index.d.ts +991 -807
  5. package/dist/index.mjs +1 -0
  6. package/dist/mount.d.mts +22 -0
  7. package/dist/mount.d.ts +11 -10
  8. package/dist/mount.mjs +1 -0
  9. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -0
  10. package/dist/packem_chunks/ApiTab.mjs +1 -0
  11. package/dist/packem_chunks/AuditPanel.mjs +1 -0
  12. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -0
  13. package/dist/packem_chunks/ExportImportPanel.mjs +6 -0
  14. package/dist/packem_chunks/FileBrowser.mjs +4 -0
  15. package/dist/packem_chunks/FunctionRunner.mjs +1 -0
  16. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -0
  17. package/dist/packem_chunks/HealthPanel.mjs +1 -0
  18. package/dist/packem_chunks/InsightsPanel.mjs +1 -0
  19. package/dist/packem_chunks/LogsPanel.mjs +1 -0
  20. package/dist/packem_chunks/MailPanel.mjs +2 -0
  21. package/dist/packem_chunks/MetricsPanel.mjs +1 -0
  22. package/dist/packem_chunks/NotificationsPanel.mjs +1 -0
  23. package/dist/packem_chunks/PitrPanel.mjs +1 -0
  24. package/dist/packem_chunks/SchemaViewer.mjs +1 -0
  25. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -0
  26. package/dist/packem_chunks/SettingsPanel.mjs +1 -0
  27. package/dist/packem_chunks/SqlEditorPanel.mjs +10 -0
  28. package/dist/packem_chunks/TableEditor.mjs +1 -0
  29. package/dist/packem_chunks/agents-panel.mjs +1 -0
  30. package/dist/packem_chunks/ai-usage-panel.mjs +1 -0
  31. package/dist/packem_chunks/analytics-panel.mjs +1 -0
  32. package/dist/packem_chunks/architecture-panel.mjs +1 -0
  33. package/dist/packem_chunks/auth-audit-panel.mjs +1 -0
  34. package/dist/packem_chunks/auth-config-panel.mjs +1 -0
  35. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -0
  36. package/dist/packem_chunks/containers-panel.mjs +1 -0
  37. package/dist/packem_chunks/dashboards-panel.mjs +1 -0
  38. package/dist/packem_chunks/evals-panel.mjs +1 -0
  39. package/dist/packem_chunks/fanout-panel.mjs +1 -0
  40. package/dist/packem_chunks/flags-panel.mjs +1 -0
  41. package/dist/packem_chunks/issues-panel.mjs +1 -0
  42. package/dist/packem_chunks/kv-browser.mjs +1 -0
  43. package/dist/packem_chunks/log-drains-panel.mjs +4 -0
  44. package/dist/packem_chunks/migrations-route.mjs +1 -0
  45. package/dist/packem_chunks/organizations-panel.mjs +1 -0
  46. package/dist/packem_chunks/payments-panel.mjs +1 -0
  47. package/dist/packem_chunks/permissions-panel.mjs +1 -0
  48. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -0
  49. package/dist/packem_chunks/queues-panel.mjs +1 -0
  50. package/dist/packem_chunks/reactors-panel.mjs +1 -0
  51. package/dist/packem_chunks/rls-panel.mjs +1 -0
  52. package/dist/packem_chunks/schedule-panel.mjs +1 -0
  53. package/dist/packem_chunks/sparkline.mjs +1 -0
  54. package/dist/packem_chunks/storage-rules-panel.mjs +1 -0
  55. package/dist/packem_chunks/subscriptions-panel.mjs +1 -0
  56. package/dist/packem_chunks/sync-client-panel.mjs +1 -0
  57. package/dist/packem_chunks/traces-panel.mjs +1 -0
  58. package/dist/packem_chunks/users-panel.mjs +1 -0
  59. package/dist/packem_chunks/vector-browser.mjs +1 -0
  60. package/dist/packem_chunks/workflows-panel.mjs +1 -0
  61. package/dist/packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs +1 -0
  62. package/dist/packem_shared/ApiDocsPanel-Py7C4ibM.mjs +2 -0
  63. package/dist/packem_shared/ApiReferencePanel-DlYVADAy.mjs +1 -0
  64. package/dist/packem_shared/CommandPalette-CM1hqAOD.mjs +1 -0
  65. package/dist/packem_shared/ConfirmButton-DU4p72Er.mjs +1 -0
  66. package/dist/packem_shared/ConnectionBadge-B8Hj5DaE.mjs +1 -0
  67. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs +1 -0
  68. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs +1 -0
  69. package/dist/packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs +1 -0
  70. package/dist/packem_shared/DataBrowser-DxlLv5x1.mjs +4 -0
  71. package/dist/packem_shared/DataFilters-CYZFt2EK.mjs +1 -0
  72. package/dist/packem_shared/ErrorBoundary-BWNF98VF.mjs +1 -0
  73. package/dist/packem_shared/GlobalDataBrowser-TFTQpSVj.mjs +1 -0
  74. package/dist/packem_shared/HomePanel-BVz2sDQ4.mjs +1 -0
  75. package/dist/packem_shared/MigrationsPanel-fUyhbt0w.mjs +1 -0
  76. package/dist/packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs +1 -0
  77. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs +1 -0
  78. package/dist/packem_shared/ScheduledJobs-zSeU_6cN.mjs +1 -0
  79. package/dist/packem_shared/ShardInput-C6mjgAh4.mjs +1 -0
  80. package/dist/packem_shared/Studio-CNqMkRmB.mjs +1 -0
  81. package/dist/packem_shared/StudioApp-CUxEVr__.mjs +1 -0
  82. package/dist/packem_shared/StudioI18nProvider-fVsCSs5L.mjs +1 -0
  83. package/dist/packem_shared/advisor-view-CXiPdw4B.mjs +1 -0
  84. package/dist/packem_shared/aggregateMetrics-DKFJc-o5.mjs +1 -0
  85. package/dist/packem_shared/alert-PB5W11MM.mjs +1 -0
  86. package/dist/packem_shared/app.d-D45VvUTx.d.mts +351 -0
  87. package/dist/packem_shared/app.d-D45VvUTx.d.ts +351 -0
  88. package/dist/packem_shared/auth-pager-DiDnXsfe.mjs +1 -0
  89. package/dist/packem_shared/badge-r_5B4LHP.mjs +1 -0
  90. package/dist/packem_shared/bar-chart-BCsEIQoQ.mjs +6 -0
  91. package/dist/packem_shared/browser-storage-BH1MxLZs.mjs +1 -0
  92. package/dist/packem_shared/button-q0UYSmrn.mjs +1 -0
  93. package/dist/packem_shared/card-By2O8ULa.mjs +1 -0
  94. package/dist/packem_shared/cf-links-CBJ5SywP.mjs +1 -0
  95. package/dist/packem_shared/checkbox-CnS9cyCz.mjs +1 -0
  96. package/dist/packem_shared/control-button-BOZ5K-FC.mjs +1 -0
  97. package/dist/packem_shared/data-grid-BHTuvSI7.mjs +1 -0
  98. package/dist/packem_shared/data-view-params-DhYmAkcj.mjs +1 -0
  99. package/dist/packem_shared/diagram-export-panel-BMLzao0Y.mjs +2 -0
  100. package/dist/packem_shared/dropdown-menu-jLZenfWH.mjs +2 -0
  101. package/dist/packem_shared/empty-state-D7jEML_T.mjs +1 -0
  102. package/dist/packem_shared/error-alert-D-ftqyo-.mjs +1 -0
  103. package/dist/packem_shared/grid-features-CIdZ8Dqo.mjs +6 -0
  104. package/dist/packem_shared/grid-pagination-DgzyzfBh.mjs +1 -0
  105. package/dist/packem_shared/home-panel-CF-MfsnH.mjs +3 -0
  106. package/dist/packem_shared/input-CXhxesPC.mjs +1 -0
  107. package/dist/packem_shared/internal-BXEjuLPN.mjs +2 -0
  108. package/dist/packem_shared/label-DKFzyHq6.mjs +1 -0
  109. package/dist/packem_shared/live-status-BuJdUZFU.mjs +1 -0
  110. package/dist/packem_shared/log-fields-BolUoZ9g.mjs +1 -0
  111. package/dist/packem_shared/log-line-BWDt_F56.mjs +1 -0
  112. package/dist/packem_shared/metrics-format-1sNGG47R.mjs +1 -0
  113. package/dist/packem_shared/modal-shell-CDztwLnv.mjs +1 -0
  114. package/dist/packem_shared/operation-console-provider-DoloEvon.mjs +1 -0
  115. package/dist/packem_shared/recording-client-CFBkH4uZ.mjs +1 -0
  116. package/dist/packem_shared/reference-view-BrsL8UGn.mjs +13 -0
  117. package/dist/packem_shared/schema-diagram-ghsOCED7.mjs +2 -0
  118. package/dist/packem_shared/scroll-area-CXCQH7VT.mjs +2 -0
  119. package/dist/packem_shared/select-DPyS18Vy.mjs +2 -0
  120. package/dist/packem_shared/shard-history-CaO3C4KQ.mjs +1 -0
  121. package/dist/packem_shared/shortcuts-B9gDaXmw.mjs +1 -0
  122. package/dist/packem_shared/skeleton-DX1gfixl.mjs +1 -0
  123. package/dist/packem_shared/sparkline-B_sPPO_8.mjs +1 -0
  124. package/dist/packem_shared/sql-result-table-COsfUSGc.mjs +1 -0
  125. package/dist/packem_shared/stat-card-BAv73QtB.mjs +1 -0
  126. package/dist/packem_shared/storage-tier-C2mKwYRj.mjs +1 -0
  127. package/dist/packem_shared/studio-BcHsk7mT.mjs +2 -0
  128. package/dist/packem_shared/table-D0SBiDu-.mjs +2 -0
  129. package/dist/packem_shared/table-list-sidebar-DwqtHSHU.mjs +1 -0
  130. package/dist/packem_shared/textarea--40GKAyz.mjs +1 -0
  131. package/dist/packem_shared/trace-handoff-BV3EWqy_.mjs +1 -0
  132. package/dist/packem_shared/use-admin-query-I1uILsUP.mjs +1 -0
  133. package/dist/packem_shared/use-admin-spec-BdNLZbTO.mjs +1 -0
  134. package/dist/packem_shared/use-async-submit-2eBBD0-m.mjs +1 -0
  135. package/dist/packem_shared/use-auth-config-DQ8tNyBh.mjs +1 -0
  136. package/dist/packem_shared/use-mirrored-ref-CVDf2z1M.mjs +1 -0
  137. package/dist/packem_shared/use-open-trace-B_0LbTD7.mjs +1 -0
  138. package/dist/packem_shared/use-shard-key-BsP3o5wT.mjs +1 -0
  139. package/dist/packem_shared/use-sql-assistant-DetnUyFf.mjs +1 -0
  140. package/dist/packem_shared/useDebounced-DVeQ5-oW.mjs +1 -0
  141. package/dist/packem_shared/utils-bhneXptQ.mjs +1 -0
  142. package/dist/packem_shared/virtual-rect-D_j7aLxX.mjs +1 -0
  143. package/dist/standalone/chunk-253UHWDX.js +1 -0
  144. package/dist/standalone/chunk-2I4NHEKA.js +1 -0
  145. package/dist/standalone/chunk-2IKDEUCX.js +1 -0
  146. package/dist/standalone/chunk-2SNK7KHX.js +1 -0
  147. package/dist/standalone/chunk-37WYCOQ2.js +1 -0
  148. package/dist/standalone/chunk-3FYMEXVB.js +1 -0
  149. package/dist/standalone/chunk-3N5PRV3V.js +1 -0
  150. package/dist/standalone/chunk-3YXASVTP.js +1 -0
  151. package/dist/standalone/chunk-43GV7LQK.js +1 -0
  152. package/dist/standalone/chunk-4CGBMYO3.js +6 -0
  153. package/dist/standalone/chunk-4NOMAGEO.js +1 -0
  154. package/dist/standalone/chunk-4ZEL6BYL.js +1 -0
  155. package/dist/standalone/chunk-55UGUCQ6.js +1 -0
  156. package/dist/standalone/chunk-5B2RTXBS.js +1 -0
  157. package/dist/standalone/chunk-5QR2SQIS.js +1 -0
  158. package/dist/standalone/chunk-5SLTDY4C.js +1 -0
  159. package/dist/standalone/chunk-5Y5UTG4N.js +1 -0
  160. package/dist/standalone/chunk-6XKL22OG.js +3 -0
  161. package/dist/standalone/chunk-6ZSIPBTC.js +6 -0
  162. package/dist/standalone/chunk-74IYYDDI.js +19 -0
  163. package/dist/standalone/chunk-7G4Z6Q7X.js +1 -0
  164. package/dist/standalone/chunk-7GVT36VI.js +1 -0
  165. package/dist/standalone/chunk-7Q256NLI.js +1 -0
  166. package/dist/standalone/chunk-7RKB5KS7.js +1 -0
  167. package/dist/standalone/chunk-7Y3SY37W.js +1 -0
  168. package/dist/standalone/chunk-APEQELK3.js +1 -0
  169. package/dist/standalone/chunk-AUAECCXB.js +1 -0
  170. package/dist/standalone/{chunk-BJGBHGK3.js → chunk-AUGKHAMQ.js} +1 -1
  171. package/dist/standalone/chunk-BFQMOALO.js +1 -0
  172. package/dist/standalone/chunk-BOMPSVRC.js +1 -0
  173. package/dist/standalone/chunk-BTG6YDYM.js +1 -0
  174. package/dist/standalone/chunk-BTQ72TPT.js +1 -0
  175. package/dist/standalone/chunk-CCDX5RYT.js +1 -0
  176. package/dist/standalone/chunk-CGQMJYCW.js +1 -0
  177. package/dist/standalone/chunk-CVXNHIQW.js +1 -0
  178. package/dist/standalone/chunk-DBHZXRL6.js +1 -0
  179. package/dist/standalone/chunk-DBZ4TBP5.js +1 -0
  180. package/dist/standalone/chunk-DEFCA7GG.js +5 -0
  181. package/dist/standalone/chunk-DHGPCQ2F.js +1 -0
  182. package/dist/standalone/chunk-E4PXACVL.js +3 -0
  183. package/dist/standalone/chunk-E5DXYVPB.js +1 -0
  184. package/dist/standalone/chunk-ECY2JC5F.js +1 -0
  185. package/dist/standalone/chunk-EE227HDE.js +1 -0
  186. package/dist/standalone/chunk-ENIA26XP.js +1 -0
  187. package/dist/standalone/chunk-EWMBX5N2.js +1 -0
  188. package/dist/standalone/chunk-FCXFQF2W.js +1 -0
  189. package/dist/standalone/chunk-FPI7AMQJ.js +1 -0
  190. package/dist/standalone/chunk-FUL4ROKH.js +1 -0
  191. package/dist/standalone/chunk-FUYEZFBP.js +1 -0
  192. package/dist/standalone/chunk-G2F22AMT.js +1 -0
  193. package/dist/standalone/chunk-GC4XRCRZ.js +1 -0
  194. package/dist/standalone/chunk-GHQ2VDI2.js +1 -0
  195. package/dist/standalone/chunk-GOFZ4Y74.js +1 -0
  196. package/dist/standalone/chunk-GUDC24NJ.js +1 -0
  197. package/dist/standalone/chunk-GWVYDOBH.js +1 -0
  198. package/dist/standalone/chunk-GYBCO7NN.js +1 -0
  199. package/dist/standalone/chunk-HCFJBY65.js +1 -0
  200. package/dist/standalone/chunk-HCTJKP5J.js +1 -0
  201. package/dist/standalone/chunk-HGHIVU76.js +1 -0
  202. package/dist/standalone/chunk-HH52IEFY.js +4 -0
  203. package/dist/standalone/chunk-HIJGQX6F.js +4 -0
  204. package/dist/standalone/chunk-HPYJUVCC.js +1 -0
  205. package/dist/standalone/chunk-I26MS5PJ.js +1 -0
  206. package/dist/standalone/chunk-ICRKYAYO.js +1 -0
  207. package/dist/standalone/chunk-IRSSZXC3.js +1 -0
  208. package/dist/standalone/chunk-ITT6MM23.js +1 -0
  209. package/dist/standalone/chunk-IWZ7GVQO.js +1 -0
  210. package/dist/standalone/chunk-JR4ROUBB.js +1 -0
  211. package/dist/standalone/chunk-K2EHRNYW.js +1 -0
  212. package/dist/standalone/chunk-K3UAOIR7.js +1 -0
  213. package/dist/standalone/chunk-KCFO2BVI.js +15 -0
  214. package/dist/standalone/chunk-KF7Y5S5O.js +1 -0
  215. package/dist/standalone/chunk-LHG2JVIM.js +2 -0
  216. package/dist/standalone/chunk-LXCVA5SP.js +1 -0
  217. package/dist/standalone/chunk-M3QKMHAP.js +15 -0
  218. package/dist/standalone/chunk-MVWZMWPD.js +1 -0
  219. package/dist/standalone/chunk-NCBLHBRW.js +1 -0
  220. package/dist/standalone/chunk-NCCORPSU.js +7 -0
  221. package/dist/standalone/chunk-NCPW7WHO.js +1 -0
  222. package/dist/standalone/chunk-NGVP66OH.js +1 -0
  223. package/dist/standalone/chunk-NQZALRU3.js +1 -0
  224. package/dist/standalone/chunk-NRP22GKC.js +1 -0
  225. package/dist/standalone/chunk-NXQW5E6W.js +1 -0
  226. package/dist/standalone/chunk-O2FW4VRL.js +1 -0
  227. package/dist/standalone/chunk-OI5HX3ZO.js +1 -0
  228. package/dist/standalone/chunk-OLIKYC3C.js +59 -0
  229. package/dist/standalone/chunk-OPM7ESDV.js +1 -0
  230. package/dist/standalone/chunk-OQ6I6OXT.js +2 -0
  231. package/dist/standalone/chunk-OYCUPD3Q.js +1 -0
  232. package/dist/standalone/chunk-PSMQQV6S.js +1 -0
  233. package/dist/standalone/chunk-Q6ED4KUL.js +1 -0
  234. package/dist/standalone/chunk-Q6IT6ZD7.js +1 -0
  235. package/dist/standalone/{chunk-ZHVTQ37P.js → chunk-QAQDMS6R.js} +1 -1
  236. package/dist/standalone/chunk-QJLHH3ET.js +1 -0
  237. package/dist/standalone/chunk-R3ADWOYR.js +1 -0
  238. package/dist/standalone/chunk-R6U22RSY.js +1 -0
  239. package/dist/standalone/chunk-RB3WPSY5.js +14 -0
  240. package/dist/standalone/chunk-RGMVGZV4.js +1 -0
  241. package/dist/standalone/chunk-RWVIV3U7.js +1 -0
  242. package/dist/standalone/chunk-S4Z7K55A.js +1 -0
  243. package/dist/standalone/chunk-SA2OGF3F.js +1 -0
  244. package/dist/standalone/chunk-SC6P4M3S.js +1 -0
  245. package/dist/standalone/chunk-SJQERRSZ.js +1 -0
  246. package/dist/standalone/chunk-SU6QNITV.js +1 -0
  247. package/dist/standalone/chunk-T6IV7OKH.js +1 -0
  248. package/dist/standalone/chunk-UC7MNI2F.js +1 -0
  249. package/dist/standalone/chunk-UIIKW4II.js +1 -0
  250. package/dist/standalone/chunk-UJQNKTYE.js +1 -0
  251. package/dist/standalone/chunk-UVL7N5IL.js +1 -0
  252. package/dist/standalone/chunk-UYEZR3BI.js +1 -0
  253. package/dist/standalone/chunk-VCFEO3RI.js +1 -0
  254. package/dist/standalone/chunk-VDC6JP4A.js +1 -0
  255. package/dist/standalone/chunk-VENSZ6LF.js +1 -0
  256. package/dist/standalone/chunk-VESGIGMQ.js +1 -0
  257. package/dist/standalone/chunk-VJ7RCBJ7.js +1 -0
  258. package/dist/standalone/chunk-VNMKNORK.js +1 -0
  259. package/dist/standalone/chunk-VQRCJJXS.js +1 -0
  260. package/dist/standalone/chunk-VVCXVAA7.js +8 -0
  261. package/dist/standalone/chunk-VXJJSPX3.js +1 -0
  262. package/dist/standalone/chunk-WJRYEML4.js +1 -0
  263. package/dist/standalone/chunk-WUI2PUY6.js +1 -0
  264. package/dist/standalone/chunk-WVWCUB4S.js +1 -0
  265. package/dist/standalone/chunk-WVYIBXUH.js +1 -0
  266. package/dist/standalone/chunk-X4MAMXRE.js +1 -0
  267. package/dist/standalone/chunk-XBQ66PGW.js +1 -0
  268. package/dist/standalone/chunk-XGCIDUJF.js +1 -0
  269. package/dist/standalone/chunk-XKISL2CG.js +1 -0
  270. package/dist/standalone/chunk-Y3AYVFTK.js +1 -0
  271. package/dist/standalone/chunk-YZ72ZAGX.js +1 -0
  272. package/dist/standalone/chunk-ZJQIGWLG.js +1 -0
  273. package/dist/standalone/chunk-ZKJS6EBE.js +1 -0
  274. package/dist/standalone/chunk-ZKV2XC5B.js +1 -0
  275. package/dist/standalone/chunk-ZPNTFCVI.js +1 -0
  276. package/dist/standalone/studio.js +9 -214
  277. package/dist/styles.css +2 -2
  278. package/package.json +26 -22
  279. package/dist/index.js +0 -41
  280. package/dist/mount.js +0 -27
  281. package/dist/packem_chunks/ApiTab.js +0 -251
  282. package/dist/packem_chunks/AuditPanel.js +0 -200
  283. package/dist/packem_chunks/ExportImportPanel.js +0 -198
  284. package/dist/packem_chunks/FileBrowser.js +0 -2932
  285. package/dist/packem_chunks/FunctionRunner.js +0 -343
  286. package/dist/packem_chunks/FunctionStatsPanel.js +0 -377
  287. package/dist/packem_chunks/HealthPanel.js +0 -648
  288. package/dist/packem_chunks/InsightsPanel.js +0 -462
  289. package/dist/packem_chunks/LogsPanel.js +0 -827
  290. package/dist/packem_chunks/MailPanel.js +0 -441
  291. package/dist/packem_chunks/MetricsPanel.js +0 -1344
  292. package/dist/packem_chunks/MigrationsPanel.js +0 -239
  293. package/dist/packem_chunks/PitrPanel.js +0 -252
  294. package/dist/packem_chunks/SchemaViewer.js +0 -2513
  295. package/dist/packem_chunks/SecurityAdvisorPanel.js +0 -95
  296. package/dist/packem_chunks/SettingsPanel.js +0 -391
  297. package/dist/packem_chunks/SqlEditorPanel.js +0 -2323
  298. package/dist/packem_chunks/TableEditor.js +0 -313
  299. package/dist/packem_chunks/analytics-panel.js +0 -261
  300. package/dist/packem_chunks/auth-config-panel.js +0 -179
  301. package/dist/packem_chunks/auth-sessions-panel.js +0 -175
  302. package/dist/packem_chunks/containers-panel.js +0 -247
  303. package/dist/packem_chunks/dashboards-panel.js +0 -780
  304. package/dist/packem_chunks/fanout-panel.js +0 -482
  305. package/dist/packem_chunks/flags-panel.js +0 -176
  306. package/dist/packem_chunks/kv-browser.js +0 -1896
  307. package/dist/packem_chunks/log-drains-panel.js +0 -273
  308. package/dist/packem_chunks/organizations-panel.js +0 -670
  309. package/dist/packem_chunks/payments-panel.js +0 -186
  310. package/dist/packem_chunks/permissions-panel.js +0 -805
  311. package/dist/packem_chunks/queues-panel.js +0 -148
  312. package/dist/packem_chunks/rls-panel.js +0 -315
  313. package/dist/packem_chunks/schedule-panel.js +0 -831
  314. package/dist/packem_chunks/sparkline.js +0 -79
  315. package/dist/packem_chunks/storage-rules-panel.js +0 -140
  316. package/dist/packem_chunks/subscriptions-panel.js +0 -238
  317. package/dist/packem_chunks/users-panel.js +0 -1265
  318. package/dist/packem_chunks/vector-browser.js +0 -281
  319. package/dist/packem_chunks/workflows-panel.js +0 -562
  320. package/dist/packem_shared/ADMIN_FUNCTIONS-CdaxLGkE.js +0 -48
  321. package/dist/packem_shared/ApiDocsPanel-Cu6mD4u7.js +0 -842
  322. package/dist/packem_shared/ApiReferencePanel-Co_wpRF2.js +0 -230
  323. package/dist/packem_shared/CommandPalette-BUPpbpMc.js +0 -373
  324. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  325. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  326. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  327. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  328. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  329. package/dist/packem_shared/DataBrowser-DSNK1tPg.js +0 -4493
  330. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  331. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  332. package/dist/packem_shared/GlobalDataBrowser-ErfvIs1S.js +0 -289
  333. package/dist/packem_shared/HomePanel-DQk3P8xX.js +0 -14
  334. package/dist/packem_shared/OpenRpcReferencePanel-DLWzrIx9.js +0 -192
  335. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  336. package/dist/packem_shared/ScheduledJobs-ClaNpZsg.js +0 -262
  337. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  338. package/dist/packem_shared/Studio-Biu37c3O.js +0 -16
  339. package/dist/packem_shared/StudioApp-D6a2ZmXS.js +0 -657
  340. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  341. package/dist/packem_shared/advisor-view-D3-U4kRR.js +0 -159
  342. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  343. package/dist/packem_shared/alert-CdAET2K_.js +0 -68
  344. package/dist/packem_shared/app.d-CNLRTrWw.d.ts +0 -300
  345. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  346. package/dist/packem_shared/bar-chart-DSwcWIRy.js +0 -3246
  347. package/dist/packem_shared/browser-storage-tLOxkIHd.js +0 -185
  348. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  349. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  350. package/dist/packem_shared/cf-links-BZfRdxSE.js +0 -8
  351. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  352. package/dist/packem_shared/data-grid-Jz8FqQ2C.js +0 -183
  353. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +0 -96
  354. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  355. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  356. package/dist/packem_shared/error-alert-BBT6D22d.js +0 -114
  357. package/dist/packem_shared/grid-features-CUr8Z1_O.js +0 -745
  358. package/dist/packem_shared/home-panel-Bo-Mgrkn.js +0 -1639
  359. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  360. package/dist/packem_shared/internal-DTsYVn-g.js +0 -97
  361. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  362. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  363. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +0 -100
  364. package/dist/packem_shared/reference-view-CSKyUyPl.js +0 -2141
  365. package/dist/packem_shared/select-UkNYCT3s.js +0 -273
  366. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  367. package/dist/packem_shared/skeleton-CGhL0p20.js +0 -45
  368. package/dist/packem_shared/sparkline-BnA1kC9X.js +0 -93
  369. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  370. package/dist/packem_shared/studio-C4sgu0F7.js +0 -4015
  371. package/dist/packem_shared/table-DsCa9Qp9.js +0 -246
  372. package/dist/packem_shared/table-list-sidebar-B5psdSV1.js +0 -832
  373. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  374. package/dist/packem_shared/use-admin-query-BHPKmPuj.js +0 -106
  375. package/dist/packem_shared/use-auth-capabilities-C-VH0oJJ.js +0 -32
  376. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  377. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  378. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
  379. package/dist/standalone/chunk-25VHPD2I.js +0 -1
  380. package/dist/standalone/chunk-2GGMGPEP.js +0 -1
  381. package/dist/standalone/chunk-2K47A3P6.js +0 -1
  382. package/dist/standalone/chunk-2NGUNNGW.js +0 -1
  383. package/dist/standalone/chunk-3CJW6NWG.js +0 -4
  384. package/dist/standalone/chunk-3OA7PECS.js +0 -6
  385. package/dist/standalone/chunk-4H2OJBXO.js +0 -1
  386. package/dist/standalone/chunk-4MLAVZP4.js +0 -1
  387. package/dist/standalone/chunk-4QHKBC77.js +0 -1
  388. package/dist/standalone/chunk-55YA7ZZI.js +0 -76
  389. package/dist/standalone/chunk-5OH3VPZF.js +0 -1
  390. package/dist/standalone/chunk-5OIBXYZM.js +0 -1
  391. package/dist/standalone/chunk-5PQMXK24.js +0 -1
  392. package/dist/standalone/chunk-6GFEVKJP.js +0 -1
  393. package/dist/standalone/chunk-764T6X6X.js +0 -1
  394. package/dist/standalone/chunk-7M3F6U4L.js +0 -1
  395. package/dist/standalone/chunk-7TJJXVSE.js +0 -1
  396. package/dist/standalone/chunk-7VF3IAAW.js +0 -2
  397. package/dist/standalone/chunk-AHILM3ZP.js +0 -1
  398. package/dist/standalone/chunk-AJIUI7DD.js +0 -1
  399. package/dist/standalone/chunk-AQGOX5DK.js +0 -1
  400. package/dist/standalone/chunk-BACPICH6.js +0 -1
  401. package/dist/standalone/chunk-BET2625I.js +0 -1
  402. package/dist/standalone/chunk-BQUQS7QN.js +0 -1
  403. package/dist/standalone/chunk-CKSHCYGC.js +0 -2
  404. package/dist/standalone/chunk-DCECRP45.js +0 -1
  405. package/dist/standalone/chunk-DFP2DADO.js +0 -1
  406. package/dist/standalone/chunk-DORBUITF.js +0 -1
  407. package/dist/standalone/chunk-DVKPRFIJ.js +0 -1
  408. package/dist/standalone/chunk-DWDILV2E.js +0 -1
  409. package/dist/standalone/chunk-E6WUCLSI.js +0 -1
  410. package/dist/standalone/chunk-E7WLF6IU.js +0 -1
  411. package/dist/standalone/chunk-EVPLBWUT.js +0 -8
  412. package/dist/standalone/chunk-FCSPAJW4.js +0 -1
  413. package/dist/standalone/chunk-FKO3HO6I.js +0 -4
  414. package/dist/standalone/chunk-G2ICR3DL.js +0 -1
  415. package/dist/standalone/chunk-GJ6PGSES.js +0 -13
  416. package/dist/standalone/chunk-GMSGZDDH.js +0 -13
  417. package/dist/standalone/chunk-GTM65MVX.js +0 -1
  418. package/dist/standalone/chunk-GVRM4U6W.js +0 -2
  419. package/dist/standalone/chunk-GZDWDDXN.js +0 -1
  420. package/dist/standalone/chunk-HV7G6DFP.js +0 -5
  421. package/dist/standalone/chunk-ISJAJWYI.js +0 -1
  422. package/dist/standalone/chunk-J6J54MBP.js +0 -1
  423. package/dist/standalone/chunk-JIDZFLTB.js +0 -4
  424. package/dist/standalone/chunk-JSEXCW5Q.js +0 -1
  425. package/dist/standalone/chunk-K3GNLVYK.js +0 -1
  426. package/dist/standalone/chunk-K4ZDRTQM.js +0 -1
  427. package/dist/standalone/chunk-KEGAWN6Y.js +0 -1
  428. package/dist/standalone/chunk-KTK3V4DC.js +0 -1
  429. package/dist/standalone/chunk-KZ6INM5M.js +0 -1
  430. package/dist/standalone/chunk-LI43EKM6.js +0 -1
  431. package/dist/standalone/chunk-MFPTVCJ6.js +0 -1
  432. package/dist/standalone/chunk-MPYFGAOW.js +0 -1
  433. package/dist/standalone/chunk-O3NAGRTR.js +0 -1
  434. package/dist/standalone/chunk-O77VNUFD.js +0 -1
  435. package/dist/standalone/chunk-PA3LN4XJ.js +0 -1
  436. package/dist/standalone/chunk-PN5NCZDX.js +0 -1
  437. package/dist/standalone/chunk-PVZI3CXP.js +0 -19
  438. package/dist/standalone/chunk-PZ7HD5T2.js +0 -1
  439. package/dist/standalone/chunk-QAFAJBAW.js +0 -1
  440. package/dist/standalone/chunk-QBAT52GB.js +0 -1
  441. package/dist/standalone/chunk-QHIIRFG7.js +0 -1
  442. package/dist/standalone/chunk-RRCPZMC2.js +0 -22
  443. package/dist/standalone/chunk-RSEEHNFI.js +0 -1
  444. package/dist/standalone/chunk-SEU5V7I6.js +0 -1
  445. package/dist/standalone/chunk-SGDQIWAR.js +0 -4
  446. package/dist/standalone/chunk-SVR644RF.js +0 -1
  447. package/dist/standalone/chunk-SYEIXTEU.js +0 -1
  448. package/dist/standalone/chunk-T5HRXUSY.js +0 -1
  449. package/dist/standalone/chunk-TAD43CG5.js +0 -1
  450. package/dist/standalone/chunk-TBMYIZIO.js +0 -1
  451. package/dist/standalone/chunk-TDL7NEWA.js +0 -1
  452. package/dist/standalone/chunk-TM7CMA7X.js +0 -1
  453. package/dist/standalone/chunk-TQ36RWOP.js +0 -1
  454. package/dist/standalone/chunk-TY7L2V4E.js +0 -1
  455. package/dist/standalone/chunk-U4OAQPBT.js +0 -1
  456. package/dist/standalone/chunk-UDSVXA42.js +0 -1
  457. package/dist/standalone/chunk-UII66UVF.js +0 -1
  458. package/dist/standalone/chunk-UK64ZSUW.js +0 -1
  459. package/dist/standalone/chunk-VEZO7G5Q.js +0 -3
  460. package/dist/standalone/chunk-VLXV72QE.js +0 -1
  461. package/dist/standalone/chunk-VSHUSN6T.js +0 -1
  462. package/dist/standalone/chunk-VYMCCC6O.js +0 -1
  463. package/dist/standalone/chunk-WXPWVBIY.js +0 -1
  464. package/dist/standalone/chunk-X72PYOEW.js +0 -1
  465. package/dist/standalone/chunk-X7MMBSNW.js +0 -1
  466. package/dist/standalone/chunk-XIGIWZLO.js +0 -4
  467. package/dist/standalone/chunk-XNJNSCLM.js +0 -1
  468. package/dist/standalone/chunk-XUGSA2NG.js +0 -1
  469. package/dist/standalone/chunk-Y2ZPNDL7.js +0 -4
  470. package/dist/standalone/chunk-YM6BBZDN.js +0 -1
  471. package/dist/standalone/chunk-ZPP2KOR4.js +0 -1
  472. package/dist/standalone/chunk-ZPUO7FNI.js +0 -1
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{StudioApp as r}from"./packem_shared/StudioApp-CUxEVr__.mjs";import{CommandPalette as a,openCommandPalette as f}from"./packem_shared/CommandPalette-CM1hqAOD.mjs";import{S as m}from"./packem_shared/studio-BcHsk7mT.mjs";import{ConfirmButton as l}from"./packem_shared/ConfirmButton-DU4p72Er.mjs";import{default as s}from"./packem_shared/ConnectionBadge-B8Hj5DaE.mjs";import{ErrorBoundary as d}from"./packem_shared/ErrorBoundary-BWNF98VF.mjs";import{ShardInput as P}from"./packem_shared/ShardInput-C6mjgAh4.mjs";import{default as A}from"./packem_chunks/AdvisorHealthPanel.mjs";import{DEFAULT_INSIGHT_THRESHOLDS as I,deriveInsights as T}from"./packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{InsightsPanel as g}from"./packem_chunks/InsightsPanel.mjs";import{default as F}from"./packem_chunks/SecurityAdvisorPanel.mjs";import{default as h}from"./packem_shared/ApiDocsPanel-Py7C4ibM.mjs";import{default as C}from"./packem_shared/ApiReferencePanel-DlYVADAy.mjs";import{default as O}from"./packem_chunks/ApiTab.mjs";import{default as N}from"./packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs";import{DataBrowser as U}from"./packem_shared/DataBrowser-DxlLv5x1.mjs";import{DataFilters as b,toFilterClauses as v}from"./packem_shared/DataFilters-CYZFt2EK.mjs";import{GlobalDataBrowser as y}from"./packem_shared/GlobalDataBrowser-TFTQpSVj.mjs";import{TableEditor as q}from"./packem_chunks/TableEditor.mjs";import{ExportImportPanel as V}from"./packem_chunks/ExportImportPanel.mjs";import{MigrationsPanel as j}from"./packem_shared/MigrationsPanel-fUyhbt0w.mjs";import{PitrPanel as z}from"./packem_chunks/PitrPanel.mjs";import{FunctionRunner as Q}from"./packem_chunks/FunctionRunner.mjs";import{FunctionStatsPanel as Y}from"./packem_chunks/FunctionStatsPanel.mjs";import{DeploymentHealthPanel as $}from"./packem_chunks/DeploymentHealthPanel.mjs";import{H as oe}from"./packem_shared/home-panel-CF-MfsnH.mjs";import{AuditPanel as te}from"./packem_chunks/AuditPanel.mjs";import{LogsPanel as fe}from"./packem_chunks/LogsPanel.mjs";import{MailPanel as me}from"./packem_chunks/MailPanel.mjs";import{ScheduledJobs as le}from"./packem_shared/ScheduledJobs-zSeU_6cN.mjs";import{default as se}from"./packem_chunks/NotificationsPanel.mjs";import{HealthPanel as de}from"./packem_chunks/HealthPanel.mjs";import{aggregateMetrics as Pe,shardsToAggregate as Se}from"./packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{MetricsPanel as ce}from"./packem_chunks/MetricsPanel.mjs";import{SchemaViewer as Te}from"./packem_chunks/SchemaViewer.mjs";import{SettingsPanel as ge}from"./packem_chunks/SettingsPanel.mjs";import{SqlEditorPanel as Fe}from"./packem_chunks/SqlEditorPanel.mjs";import{FileBrowser as he}from"./packem_chunks/FileBrowser.mjs";import{DEFAULT_AUTO_REFRESH_MS as Ce,useAutoRefresh as He}from"./packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{default as Le}from"./packem_shared/useDebounced-DVeQ5-oW.mjs";import{DEFAULT_LOCALE as Me,createStudioI18n as Ue,studioI18n as Be,useT as be}from"./packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{StudioI18nProvider as we}from"./packem_shared/StudioI18nProvider-fVsCSs5L.mjs";import{ADMIN_FUNCTIONS as Ge,ADMIN_FUNCTION_PREFIX as qe}from"./packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{default as Ve}from"./packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs";export{Ge as ADMIN_FUNCTIONS,qe as ADMIN_FUNCTION_PREFIX,A as AdvisorHealthPanel,h as ApiDocsPanel,C as ApiReferencePanel,O as ApiTab,te as AuditPanel,a as CommandPalette,l as ConfirmButton,s as ConnectionBadge,Ce as DEFAULT_AUTO_REFRESH_MS,I as DEFAULT_INSIGHT_THRESHOLDS,Me as DEFAULT_LOCALE,U as DataBrowser,b as DataFilters,$ as DeploymentHealthPanel,d as ErrorBoundary,V as ExportImportPanel,he as FileBrowser,Q as FunctionRunner,Y as FunctionStatsPanel,y as GlobalDataBrowser,de as HealthPanel,oe as HomePanel,g as InsightsPanel,fe as LogsPanel,me as MailPanel,ce as MetricsPanel,j as MigrationsPanel,se as NotificationsPanel,N as OpenRpcReferencePanel,z as PitrPanel,Ve as STUDIO_ROOT_CLASS,le as ScheduledJobs,Te as SchemaViewer,F as SecurityAdvisorPanel,ge as SettingsPanel,P as ShardInput,Fe as SqlEditorPanel,m as Studio,r as StudioApp,we as StudioI18nProvider,q as TableEditor,Pe as aggregateMetrics,Ue as createStudioI18n,T as deriveInsights,f as openCommandPalette,Se as shardsToAggregate,Be as studioI18n,v as toFilterClauses,He as useAutoRefresh,Le as useDebounced,be as useT};
@@ -0,0 +1,22 @@
1
+ import { Root } from 'react-dom/client';
2
+ import { S as StudioAppProps } from "./packem_shared/app.d-D45VvUTx.mjs";
3
+ import '@lunora/client';
4
+ import 'react';
5
+ import '@lingui/core';
6
+ import '@lunora/bindings/analytics-sql';
7
+ interface MountStudioOptions extends StudioAppProps {
8
+ /**
9
+ * The container to mount into. Accepts an element or a selector; defaults to
10
+ * `#root`. Throws if the selector matches nothing so misconfiguration fails
11
+ * loudly rather than silently rendering nowhere.
12
+ */
13
+ readonly container?: Element | string;
14
+ }
15
+ /**
16
+ * Mount the batteries-included {@link StudioApp} into the DOM and return the
17
+ * React root (call `.unmount()` to tear it down). This is the entry the
18
+ * standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
19
+ * keeps the host HTML to a single `<div id="root">` plus one script.
20
+ */
21
+ declare const mountStudio: (options?: MountStudioOptions) => Root;
22
+ export { MountStudioOptions, mountStudio };
package/dist/mount.d.ts CHANGED
@@ -1,21 +1,22 @@
1
1
  import { Root } from 'react-dom/client';
2
- import { S as StudioAppProps } from "./packem_shared/app.d-CNLRTrWw.js";
2
+ import { S as StudioAppProps } from "./packem_shared/app.d-D45VvUTx.js";
3
3
  import '@lunora/client';
4
4
  import 'react';
5
5
  import '@lingui/core';
6
+ import '@lunora/bindings/analytics-sql';
6
7
  interface MountStudioOptions extends StudioAppProps {
7
8
  /**
8
- * The container to mount into. Accepts an element or a selector; defaults to
9
- * `#root`. Throws if the selector matches nothing so misconfiguration fails
10
- * loudly rather than silently rendering nowhere.
11
- */
9
+ * The container to mount into. Accepts an element or a selector; defaults to
10
+ * `#root`. Throws if the selector matches nothing so misconfiguration fails
11
+ * loudly rather than silently rendering nowhere.
12
+ */
12
13
  readonly container?: Element | string;
13
14
  }
14
15
  /**
15
- * Mount the batteries-included {@link StudioApp} into the DOM and return the
16
- * React root (call `.unmount()` to tear it down). This is the entry the
17
- * standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
18
- * keeps the host HTML to a single `&lt;div id="root">` plus one script.
19
- */
16
+ * Mount the batteries-included {@link StudioApp} into the DOM and return the
17
+ * React root (call `.unmount()` to tear it down). This is the entry the
18
+ * standalone app's `main.tsx` and the `@lunora/vite` dev route both call — it
19
+ * keeps the host HTML to a single `<div id="root">` plus one script.
20
+ */
20
21
  declare const mountStudio: (options?: MountStudioOptions) => Root;
21
22
  export { MountStudioOptions, mountStudio };
package/dist/mount.mjs ADDED
@@ -0,0 +1 @@
1
+ import{LunoraError as m}from"@lunora/errors";import{createRoot as i}from"react-dom/client";import{StudioApp as p}from"./packem_shared/StudioApp-CUxEVr__.mjs";import{jsx as u}from"react/jsx-runtime";const a=(n={})=>{const{container:o="#root",...e}=n,t=typeof o=="string"?document.querySelector(o):o;if(t===null)throw new m("INTERNAL",`mountStudio: container ${typeof o=="string"?o:"element"} not found`);const r=i(t);return r.render(u(p,{...e})),r};export{a as mountStudio};
@@ -0,0 +1 @@
1
+ import{scoreAdvisor as T}from"@lunora/advisor";import{E as A}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{C as c,a as o}from"../packem_shared/card-By2O8ULa.mjs";import{T as j,a as R,b as f,c as i,d as $,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{u as v}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as C}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as N}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as u}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as e,jsxs as r}from"react/jsx-runtime";const n={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},b={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},E=(s,a)=>`exempt: ${s.exemptReason===void 0||s.exemptReason===""?a:s.exemptReason}`,S=s=>s.toSorted((a,l)=>a.coverage==="clean"&&l.coverage!=="clean"?1:l.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-l.score),Y=({testId:s="advisor-health"})=>{const a=C(),l=v(N.getAdvisories,{},{live:!0}),x=v(N.getAdvisorProcedures,{},{live:!0}),p=l.data?.advisories??null,h=x.data?.procedures??null,t=p===null||h===null?null:T(h,p),g=x.error??l.error;if(g!==null)return e(A,{error:g,testId:`${s}-error`});if(t===null)return e(c,{children:e(o,{className:"py-8 text-center text-muted-foreground","data-testid":`${s}-loading`,children:a("Loading…")})});const k=S(t.procedures);return r("div",{className:"space-y-4","data-testid":s,children:[e(c,{children:r(o,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[r("div",{children:[e("span",{className:u("text-4xl font-semibold tabular-nums",b[t.grade]),"data-testid":`${s}-score`,children:t.score}),e("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),e("span",{className:u("text-sm font-medium uppercase tracking-wide",b[t.grade]),"data-testid":`${s}-grade`,children:t.grade}),r("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${s}-summary`,children:[r("span",{className:n.clean,children:[t.summary.clean," ",a("clean")]}),r("span",{className:n.warned,children:[t.summary.warned," ",a("warned")]}),r("span",{className:n.failing,children:[t.summary.failing," ",a("failing")]}),r("span",{className:n.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&e(c,{children:r(o,{className:"py-4 text-sm","data-testid":`${s}-project`,children:[r("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),r("span",{className:"text-muted-foreground",children:[" — ",t.project.checks.map(d=>d.name).join(", ")]})]})}),e(c,{children:e(o,{className:"p-0",children:r(j,{children:[e(R,{children:r(f,{children:[e(i,{className:"w-20",children:a("Score")}),e(i,{children:a("Procedure")}),e(i,{className:"w-32",children:a("Kind")}),e(i,{children:a("Rules fired")})]})}),e($,{children:k.map(d=>r(f,{"data-testid":`${s}-row`,children:[e(m,{className:u("tabular-nums font-medium",n[d.coverage]),children:d.coverage==="exempt"?"—":d.score}),e(m,{className:"font-mono text-xs",children:d.id}),r(m,{className:"text-muted-foreground text-xs",children:[d.visibility," ",d.kind,d.sensitivity.level==="high"&&e("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),e(m,{className:"text-muted-foreground text-xs",children:d.coverage==="exempt"?E(d,a("no reason given")):d.checks.map(w=>w.name).join(", ")})]},d.id))})]})})})]})};export{Y as default};
@@ -0,0 +1 @@
1
+ import{c as L}from"react/compiler-runtime";import{useState as F}from"react";import{B as K}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import D from"../packem_shared/ApiDocsPanel-Py7C4ibM.mjs";import M from"../packem_shared/ApiReferencePanel-DlYVADAy.mjs";import W from"../packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs";import{jsx as r,jsxs as E}from"react/jsx-runtime";const _=["reference","snippets"],q=["openapi","openrpc"],k=V=>{const e=L(51),{functions:R,initialShardKey:N,openApiSpec:T,openRpcSpec:I}=V,t=Y(),[i,$]=F("reference"),[a,j]=F("openapi");let s;e[0]!==t?(s=t("Reference"),e[0]=t,e[1]=s):s=e[1];let o;e[2]!==t?(o=t("Snippets"),e[2]=t,e[3]=o):o=e[3];let w;e[4]!==s||e[5]!==o?(w={reference:s,snippets:o},e[4]=s,e[5]=o,e[6]=w):w=e[6];const O=w;let n;e[7]!==t?(n=t("OpenAPI"),e[7]=t,e[8]=n):n=e[8];let c;e[9]!==t?(c=t("OpenRPC"),e[9]=t,e[10]=c):c=e[10];let g;e[11]!==n||e[12]!==c?(g={openapi:n,openrpc:c},e[11]=n,e[12]=c,e[13]=g):g=e[13];const C=g;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=l=>{$(l.currentTarget.dataset.view)},e[14]=S):S=e[14];const z=S;let A;e[15]===Symbol.for("react.memo_cache_sentinel")?(A=l=>{j(l.currentTarget.dataset.format)},e[15]=A):A=e[15];const B=A;let p;e[16]!==t?(p=t("API view"),e[16]=t,e[17]=p):p=e[17];let f;e[18]!==i||e[19]!==O?(f=_.map(l=>r(K,{"aria-selected":i===l,"data-testid":`api-view-${l}`,"data-view":l,onClick:z,role:"tab",size:"sm",type:"button",variant:i===l?"default":"outline",children:O[l]},l)),e[18]=i,e[19]=O,e[20]=f):f=e[20];let m;e[21]!==f||e[22]!==p?(m=r("div",{"aria-label":p,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:f}),e[21]=f,e[22]=p,e[23]=m):m=e[23];let d;e[24]!==a||e[25]!==C||e[26]!==t||e[27]!==i?(d=i==="reference"&&r("div",{"aria-label":t("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:q.map(l=>r(K,{"aria-selected":a===l,"data-format":l,"data-testid":`api-format-${l}`,onClick:B,role:"tab",size:"sm",type:"button",variant:a===l?"default":"outline",children:C[l]},l))}),e[24]=a,e[25]=C,e[26]=t,e[27]=i,e[28]=d):d=e[28];let b;e[29]!==m||e[30]!==d?(b=E("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[m,d]}),e[29]=m,e[30]=d,e[31]=b):b=e[31];let v;e[32]!==R||e[33]!==N||e[34]!==i?(v=i==="snippets"&&r("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:r(D,{functions:R,initialShardKey:N})}),e[32]=R,e[33]=N,e[34]=i,e[35]=v):v=e[35];let h;e[36]!==a||e[37]!==T||e[38]!==i?(h=i==="reference"&&a==="openapi"&&r(M,{spec:T}),e[36]=a,e[37]=T,e[38]=i,e[39]=h):h=e[39];let u;e[40]!==a||e[41]!==I||e[42]!==i?(u=i==="reference"&&a==="openrpc"&&r(W,{spec:I}),e[40]=a,e[41]=I,e[42]=i,e[43]=u):u=e[43];let x;e[44]!==v||e[45]!==h||e[46]!==u?(x=E("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[v,h,u]}),e[44]=v,e[45]=h,e[46]=u,e[47]=x):x=e[47];let P;return e[48]!==b||e[49]!==x?(P=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[b,x]}),e[48]=b,e[49]=x,e[50]=P):P=e[50],P};export{k as default};
@@ -0,0 +1 @@
1
+ import{useVirtualizer as A,observeElementRect as B}from"@tanstack/react-virtual";import{useState as K,useMemo as w,useRef as M}from"react";import{E as V}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{L as _}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as j}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as U}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as q,a as D}from"../packem_shared/card-By2O8ULa.mjs";import{E as F}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as G}from"../packem_shared/input-CXhxesPC.mjs";import{T as W,a as J,b as N,c as s,d as P,e as l}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Q}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as Z}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Y}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as $,k as ee}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as i,jsx as e}from"react/jsx-runtime";const te=o=>o===void 0?"":JSON.stringify(o,ee),re=41,C=480,b=5,ae=(o,t)=>B(o,n=>{t(n.height>0?n:{height:C,width:n.width})}),we=({initialShardKey:o})=>{const t=X(),{queryShardKey:n,setShardKey:y,shardKey:T}=Z(o),[c,L]=K(""),{data:u,error:p,errorSource:R,isLoading:E,liveError:I}=Q(Y.getAuditLog,{},{live:!0,shardKey:n}),m=w(()=>u?.entries??[],[u]),d=w(()=>{const a=c.trim().toLowerCase();return a===""?m:m.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[m,c]),f=M(null),g=A({count:d.length,estimateSize:()=>re,getScrollElement:()=>f.current,initialRect:{height:C,width:800},observeElementRect:ae,overscan:8}),h=g.getVirtualItems(),H=g.getTotalSize(),v=h[0]?.start??0,x=H-(h.at(-1)?.end??0),O={height:v},k={height:x},z=a=>{L(a.target.value)};return i("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[i("div",{className:"flex flex-wrap items-center gap-2",children:[e(j,{onChange:y,testId:"au-shard-input",value:T}),e(_,{message:I,prefix:"au"}),e(G,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:z,placeholder:t("filter op, table, id"),value:c})]}),p!==null&&e(V,{error:R,testId:"au-error"}),p===null&&!E&&d.length===0&&e(F,{description:t("State-changing admin operations are recorded here."),icon:e("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:e("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),d.length>0&&e(q,{className:"overflow-hidden py-0",children:e(D,{className:"max-h-[30rem] overflow-auto px-0",ref:f,children:i(W,{"data-testid":"au-table",children:[e(J,{children:i(N,{children:[e(s,{children:t("time")}),e(s,{children:t("op")}),e(s,{children:t("table")}),e(s,{children:t("id")}),e(s,{children:t("detail")})]})}),i(P,{children:[v>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:O})}),h.map(a=>{const r=d[a.index],S=te(r.detail);return i(N,{"data-testid":"au-row",children:[e(l,{className:"text-muted-foreground tabular-nums",children:$(r.ts,"—")}),e(l,{children:e(U,{variant:"secondary",children:r.op})}),e(l,{className:"font-medium",children:r.table??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??e("span",{className:"text-muted-foreground",children:"—"})}),e(l,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||e("span",{className:"text-muted-foreground",children:"—"})})]},r.seq)}),x>0&&e("tr",{"aria-hidden":"true",children:e("td",{colSpan:b,style:k})})]})]})})})]})};export{we as AuditPanel};
@@ -0,0 +1 @@
1
+ import{c as ee}from"react/compiler-runtime";import{useLunora as te}from"@lunora/react";import{useQuery as re}from"@tanstack/react-query";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as J}from"../packem_shared/card-By2O8ULa.mjs";import{E as ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{S as X}from"../packem_shared/skeleton-DX1gfixl.mjs";import{useT as ie}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{h as oe}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as se}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as p,jsx as a}from"react/jsx-runtime";const de="/_lunora/health",ce="/_lunora/health/ready",me=(r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,pe=()=>{const r=te();return async e=>{const w=e==="ready"?ce:de,t=r.getAuthToken(),y=me(r.url,w);try{const i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}});let u=null;try{u=await i.json()}catch{u=null}return{body:u,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},ue={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},fe=r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok",Z=r=>{const e=ee(13),{label:w,level:t,testId:y,value:i}=r,u=ue[t];let o;e[0]!==u?(o=se("size-1.5 shrink-0 rounded-full",u),e[0]=u,e[1]=o):o=e[1];let d;e[2]!==o?(d=a("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=d):d=e[3];let c;e[4]!==w||e[5]!==d?(c=p("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[d,w]}),e[4]=w,e[5]=d,e[6]=c):c=e[6];let f;e[7]!==y||e[8]!==i?(f=a("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=f):f=e[9];let H;return e[10]!==c||e[11]!==f?(H=a(J,{className:"gap-0 py-0",children:p("div",{className:"flex flex-col gap-2.5 p-4",children:[c,f]})}),e[10]=c,e[11]=f,e[12]=H):H=e[12],H},Pe=r=>{const e=ee(107),{probe:w}=r,t=ie(),y=te(),i=pe(),u=w??i;let o;e[0]!==u?(o=async()=>{const[s,n]=await Promise.all([u("live"),u("ready")]);return{live:s,ready:n}},e[0]=u,e[1]=o):o=e[1];let d;e[2]!==y?(d=y.clientIdentifier(),e[2]=y,e[3]=d):d=e[3];let c;e[4]!==d?(c=["deployment-health",d],e[4]=d,e[5]=c):c=e[5];let f;e[6]!==o||e[7]!==c?(f={queryFn:o,queryKey:c},e[6]=o,e[7]=c,e[8]=f):f=e[8];const{data:H,isPending:le}=re(f),K=H?.live??null,ae=H?.ready??null;if(le){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=p("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[a(X,{className:"h-16 w-full"}),a(X,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}const l=K?.body??null;if(l===null){const s=K?.status===403;let n;e[10]!==s||e[11]!==K?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:K?.error??t("no response")}),e[10]=s,e[11]=K?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let g;return e[16]!==n||e[17]!==m?(g=a(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=g):g=e[18],g}let Y;e[19]!==l.status?(Y=fe(l.status),e[19]=l.status,e[20]=Y):Y=e[20];const Q=Y;let h;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],h=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],h=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],h=s}const T=ae?.ok??!1,W=T?"ok":"crit";let L,P,_,N,v,b,C,E,k,S;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==Q||e[32]!==W||e[33]!==T||e[34]!==h||e[35]!==t){const s=[...l.checks].toSorted(he);P="flex flex-col gap-6",_="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint — wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(N=a("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=N):N=e[49];let m;e[50]!==h?(m=a("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:h}),e[50]=h,e[51]=m):m=e[51];let g;e[52]!==l.appName||e[53]!==l.appVersion?(g=p("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," · ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=g):g=e[54];let A;e[55]!==m||e[56]!==g?(A=a("div",{className:"flex items-center gap-3",children:p("div",{className:"grid leading-tight",children:[m,g]})}),e[55]=m,e[56]=g,e[57]=A):A=e[57];let D;e[58]!==t?(D=t("Checked"),e[58]=t,e[59]=D):D=e[59];let V;e[60]!==D?(V=a("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:D}),e[60]=D,e[61]=V):V=e[61];let I;e[62]!==l.timestamp?(I=oe(l.timestamp),e[62]=l.timestamp,e[63]=I):I=e[63];let R;e[64]!==I?(R=a("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:I}),e[64]=I,e[65]=R):R=e[65];let $;e[66]!==V||e[67]!==R?($=p("div",{className:"text-end",children:[V,R]}),e[66]=V,e[67]=R,e[68]=$):$=e[68],e[69]!==A||e[70]!==$?(v=a(J,{className:"gap-0 py-0",children:p("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[A,$]})}),e[69]=A,e[70]=$,e[71]=v):v=e[71];let z;e[72]!==t?(z=t("Liveness"),e[72]=t,e[73]=z):z=e[73];let B;e[74]!==Q||e[75]!==h||e[76]!==z?(B=a(Z,{label:z,level:Q,testId:"dh-liveness",value:h}),e[74]=Q,e[75]=h,e[76]=z,e[77]=B):B=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let q;e[80]!==T||e[81]!==t?(q=t(T?"Ready":"Not ready"),e[80]=T,e[81]=t,e[82]=q):q=e[82];let O;e[83]!==W||e[84]!==U||e[85]!==q?(O=a(Z,{label:U,level:W,testId:"dh-readiness",value:q}),e[83]=W,e[84]=U,e[85]=q,e[86]=O):O=e[86],e[87]!==B||e[88]!==O?(b=p("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[B,O]}),e[87]=B,e[88]=O,e[89]=b):b=e[89],L=J,C="gap-0 py-0",E="dh-checks";let F;e[90]!==t?(F=t("Subsystem checks"),e[90]=t,e[91]=F):F=e[91],e[92]!==F?(k=a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:F})}),e[92]=F,e[93]=k):k=e[93],S=s.length===0?a("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):a("ul",{className:"divide-y divide-border",children:s.map(x=>p("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${x.name}`,children:[p("span",{className:"flex items-center gap-2",children:[a("span",{"aria-hidden":"true",className:se("size-1.5 shrink-0 rounded-full",x.status==="up"?"bg-success":"bg-destructive")}),a("span",{className:"font-mono text-foreground",children:x.name}),x.critical&&a(M,{variant:"outline",children:t("Critical")})]}),p("span",{className:"flex shrink-0 items-center gap-2",children:[x.message!==void 0&&a("span",{className:"text-muted-foreground",children:x.message}),a(M,{"data-testid":`dh-check-status-${x.name}`,variant:x.status==="up"?"secondary":"destructive",children:x.status==="up"?t("Up"):t("Down")})]})]},x.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=Q,e[32]=W,e[33]=T,e[34]=h,e[35]=t,e[36]=L,e[37]=P,e[38]=_,e[39]=N,e[40]=v,e[41]=b,e[42]=C,e[43]=E,e[44]=k,e[45]=S}else L=e[36],P=e[37],_=e[38],N=e[39],v=e[40],b=e[41],C=e[42],E=e[43],k=e[44],S=e[45];let j;e[94]!==L||e[95]!==C||e[96]!==E||e[97]!==k||e[98]!==S?(j=p(L,{className:C,"data-testid":E,children:[k,S]}),e[94]=L,e[95]=C,e[96]=E,e[97]=k,e[98]=S,e[99]=j):j=e[99];let G;return e[100]!==P||e[101]!==_||e[102]!==N||e[103]!==v||e[104]!==b||e[105]!==j?(G=p("div",{className:P,"data-testid":_,children:[N,v,b,j]}),e[100]=P,e[101]=_,e[102]=N,e[103]=v,e[104]=b,e[105]=j,e[106]=G):G=e[106],G};function he(r,e){return r.name.localeCompare(e.name)}export{Pe as DeploymentHealthPanel};
@@ -0,0 +1,6 @@
1
+ import{LunoraError as R}from"@lunora/errors";import{useLunora as oe}from"@lunora/react";import{encodeWire as W,decodeWire as se}from"@lunora/wire";import{useState as w}from"react";import{ConfirmButton as ne}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{ShardInput as le}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as D}from"../packem_shared/button-q0UYSmrn.mjs";import{C as P,a as K}from"../packem_shared/card-By2O8ULa.mjs";import{a as ae}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as ie}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as I}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as J,d as C,b as _,c as A}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as M}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{d as ce}from"../packem_shared/grid-features-CIdZ8Dqo.mjs";import{jsxs as m,jsx as l}from"react/jsx-runtime";const de=A(I.exportShard),pe=A(I.importShard),me=A(I.listTables),ue=a=>a.map(n=>JSON.stringify(W(n))).join(`
2
+ `),q=(a,n)=>{const t=a.trim();if(t==="")return;const e=se(JSON.parse(t));if(typeof e!="object"||e===null)throw new R("INTERNAL",`line ${n.toString()}: expected a { table, doc } object`);const r=e;if(typeof r.table!="string"||typeof r.doc!="object"||r.doc===null||Array.isArray(r.doc))throw new R("INTERNAL",`line ${n.toString()}: expected a { table, doc } object`);return r},F=1024*1024,U=async function*(a){const n=new TextDecoder("utf-8",{fatal:!0});let t="",e=0;for(let i=0;i<a.size;i+=F){const h=await a.slice(i,i+F).arrayBuffer(),c=`${t}${n.decode(h,{stream:!0})}`.split(`
3
+ `);t=c.pop()??"";for(const u of c)e+=1,yield{line:u,lineNumber:e}}const r=t+n.decode();r!==""&&(yield{line:r,lineNumber:e+1})},H=50,fe=500,L=9e5,z=a=>new TextEncoder().encode(JSON.stringify(W(a))).byteLength,O="application/x-ndjson",he=async a=>{let n=0;for await(const{line:t,lineNumber:e}of U(a)){const r=q(t,e);if(r!==void 0){if(z(r)>L)throw new R("INTERNAL",`line ${e.toString()}: a single row is over the ${L.toString()}-byte import limit`);n+=1}}return n},xe=async(a,n)=>{let t=[],e=0,r=0,i=0;for await(const{line:h,lineNumber:c}of U(a)){const u=q(h,c);if(u===void 0)continue;const x=z(u),j=c!==i+1;t.length>0&&(j||t.length===fe||e+x>L)&&(await n(t,r),t=[],e=0),t.length===0&&(r=c),t.push(u),e+=x,i=c}t.length>0&&await n(t,r)},Le=({initialShardKey:a})=>{const n=oe(),t=ae(),e=ie(),[r,i]=w(a??""),[h,c]=w(null),[u,x]=w(!1),[j,S]=w(null),[g,T]=w(null),[B,k]=w(null),[f,E]=w(null),Y=async()=>{const o=r;x(!0),S(null),T(null),E(null);try{const s=await n.query(me,{},C(o));let d=new Blob([],{type:O}),b=0;const N=[];for(const{name:p}of s){const{rows:v}=await n.query(de,{tables:[p]},C(o));if(v.length===0)continue;const y=ue(v);d=new Blob([d,`${y}
4
+ `],{type:O}),b+=v.length,N.length<H&&N.push(...y.split(`
5
+ `).slice(0,H-N.length))}M(o),E({blob:d,count:b,preview:N.join(`
6
+ `),shardKey:o})}catch(s){S(_(s))}},V=async o=>{const s={conflicts:0,errors:[],inserted:{}};let d;try{d=await he(o)}catch(p){return{failure:{message:e("Invalid NDJSON: {message}",{message:_(p)}),rows:0},total:s}}let b=0;const N=async(p,v)=>{k(e("Importing rows {from}–{to} of {total}…",{from:b+1,to:b+p.length,total:d}));const y=await n.query(pe,{rows:p,startLine:v},C(r));s.conflicts+=y.conflicts,s.errors.push(...y.errors);for(const[$,re]of Object.entries(y.inserted))s.inserted[$]=(s.inserted[$]??0)+re;b+=p.length};try{return await xe(o,N),{failure:void 0,total:s}}catch(p){return{failure:{message:_(p),rows:b},total:s}}},X=async o=>{x(!0),S(null),T(null),E(null);const{failure:s,total:d}=await V(o);s===void 0?(M(r),T(d)):s.rows>0?(T(d),S(e("Import stopped after {rows} rows: {message}. The counts below cover completed chunks only; the failed chunk may also have written rows.",{message:s.message,rows:s.rows}))):S(s.message),t(I.readTablePage),t(I.listTables)},G=g===null?0:Object.values(g.inserted).reduce((o,s)=>o+s,0),Q=()=>{J(Y().finally(()=>{x(!1)}))},Z=()=>{h!==null&&J(X(h).finally(()=>{k(null),x(!1)}))},ee=()=>{f!==null&&ce(`${f.shardKey.trim()===""?"shard":f.shardKey.trim()}.ndjson`,f.blob,O)},te=o=>{c(o.target.files?.[0]??null)};return m("div",{className:"flex flex-col gap-4","data-testid":"lunora-export-import",children:[m(P,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",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:e("Export")})}),m(K,{className:"flex flex-col gap-3 p-4",children:[m("div",{className:"flex flex-wrap items-center gap-2",children:[l(le,{onChange:i,testId:"ei-shard-input",value:r}),l(D,{"data-testid":"ei-export",disabled:u,onClick:Q,type:"button",children:e("Export")})]}),f!==null&&m("div",{className:"flex flex-col gap-2",children:[m("div",{className:"flex flex-wrap items-center gap-2",children:[l("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:e("Exported {count} rows.",{count:f.count})}),l(D,{"data-testid":"ei-download",onClick:ee,size:"sm",type:"button",variant:"outline",children:e("Download")})]}),f.preview!==""&&l("pre",{className:"max-h-60 overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"ei-preview",children:f.preview})]})]})]}),m(P,{className:"gap-0 py-0 rounded-xl border border-border bg-card shadow-xs",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:e("Import")})}),m(K,{className:"flex flex-col gap-3 p-4",children:[l("input",{accept:".ndjson,.jsonl,application/x-ndjson","aria-label":"NDJSON",className:"text-sm","data-testid":"ei-file",onChange:te,type:"file"}),l("div",{className:"flex flex-wrap items-center gap-2",children:l(ne,{confirmLabel:e("Import (writes rows)?"),disabled:u||h===null,onConfirm:Z,testId:"ei-import",children:e("Import")})}),B!==null&&l("p",{className:"text-sm text-muted-foreground","data-testid":"ei-progress",role:"status",children:B}),g!==null&&m("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[l("p",{className:"text-sm text-muted-foreground",children:e("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:g.conflicts,errors:g.errors.length,inserted:G})}),g.errors.length>0&&l("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:g.errors.map(o=>l("li",{className:"text-xs text-destructive",children:e("line {line} ({table}): {message}",{line:o.line,message:o.message,table:o.table})},`${o.table}-${o.line.toString()}`))})]})]})]}),j!==null&&l("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:j})]})};export{Le as ExportImportPanel};
@@ -0,0 +1,4 @@
1
+ import{c as U}from"react/compiler-runtime";import{useState as L,useEffect as ne,useRef as de,useMemo as ge,useCallback as ot}from"react";import{ShardInput as rt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as oe}from"../packem_shared/button-q0UYSmrn.mjs";import{E as Te}from"../packem_shared/empty-state-D7jEML_T.mjs";import{useT as it}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{S as at}from"../packem_shared/grid-features-CIdZ8Dqo.mjs";import{C as ct,a as dt}from"../packem_shared/card-By2O8ULa.mjs";import{C as Ee}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{c as le,a as ft,b as be,d as ut,T as ht,e as Q}from"../packem_shared/table-D0SBiDu-.mjs";import{n as _e,f as q,b as ie,d as Se,c as $e,g as mt}from"../packem_shared/internal-BXEjuLPN.mjs";import{ConfirmButton as pt}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{jsx as r,jsxs as R,Fragment as gt}from"react/jsx-runtime";import{I as bt}from"../packem_shared/input-CXhxesPC.mjs";import{d as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{useLunora as xt}from"@lunora/react";import{useAutoRefresh as vt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";const Re=(d,e,t)=>{const{onCopy:s,onDelete:n,onDownload:l,onToggleSelect:a}=t,c=()=>{s(d.key)},o=()=>{l(d.key)},f=()=>{n(d.key)},h=()=>{a(d.key)};return{copy:c,download:o,name:d.key.slice(e.length),remove:f,toggle:h}},ze=d=>{const e=U(31),{busy:t,buttonClassName:s,copied:n,objectKey:l,onCopy:a,onDelete:c,onDownload:o,t:f}=d,h=`storage-copy-${l}`;let u;e[0]!==n||e[1]!==f?(u=f(n?"Copied":"Copy URL"),e[0]=n,e[1]=f,e[2]=u):u=e[2];let m;e[3]!==t||e[4]!==s||e[5]!==a||e[6]!==h||e[7]!==u?(m=r(oe,{className:s,"data-testid":h,disabled:t,onClick:a,size:"sm",type:"button",variant:"ghost",children:u}),e[3]=t,e[4]=s,e[5]=a,e[6]=h,e[7]=u,e[8]=m):m=e[8];const k=`storage-download-${l}`;let i;e[9]!==f?(i=f("Download"),e[9]=f,e[10]=i):i=e[10];let v;e[11]!==t||e[12]!==s||e[13]!==o||e[14]!==k||e[15]!==i?(v=r(oe,{className:s,"data-testid":k,disabled:t,onClick:o,size:"sm",type:"button",variant:"ghost",children:i}),e[11]=t,e[12]=s,e[13]=o,e[14]=k,e[15]=i,e[16]=v):v=e[16];let S;e[17]!==f?(S=f("Delete object?"),e[17]=f,e[18]=S):S=e[18];const y=`storage-delete-${l}`;let g;e[19]!==f?(g=f("Delete"),e[19]=f,e[20]=g):g=e[20];let b;e[21]!==t||e[22]!==c||e[23]!==S||e[24]!==y||e[25]!==g?(b=r(pt,{confirmLabel:S,disabled:t,onConfirm:c,testId:y,children:g}),e[21]=t,e[22]=c,e[23]=S,e[24]=y,e[25]=g,e[26]=b):b=e[26];let x;return e[27]!==b||e[28]!==m||e[29]!==v?(x=R(gt,{children:[m,v,b]}),e[27]=b,e[28]=m,e[29]=v,e[30]=x):x=e[30],x},De=d=>{const e=U(14),{objectKey:t,references:s,t:n}=d;if(s===void 0)return null;if(s.length===0){const h=`storage-orphan-${t}`;let u;e[0]!==n?(u=n("Orphan"),e[0]=n,e[1]=u):u=e[1];let m;return e[2]!==h||e[3]!==u?(m=r(fe,{"data-testid":h,variant:"warning",children:u}),e[2]=h,e[3]=u,e[4]=m):m=e[4],m}let l;e[5]!==s?(l=s.map(kt).join(`
2
+ `),e[5]=s,e[6]=l):l=e[6];const a=l,c=`storage-refs-${t}`;let o;e[7]!==s.length||e[8]!==n?(o=s.length===1?n("1 record"):n("{count} records",{count:s.length}),e[7]=s.length,e[8]=n,e[9]=o):o=e[9];let f;return e[10]!==a||e[11]!==c||e[12]!==o?(f=r(fe,{"data-testid":c,title:a,variant:"secondary",children:o}),e[10]=a,e[11]=c,e[12]=o,e[13]=f):f=e[13],f},je=d=>{const e=U(7),{objectKey:t,onToggle:s,selected:n,t:l}=d;let a;e[0]!==l?(a=l("Select row"),e[0]=l,e[1]=a):a=e[1];const c=`storage-select-${t}`;let o;return e[2]!==s||e[3]!==n||e[4]!==a||e[5]!==c?(o=r(Ee,{"aria-label":a,checked:n,"data-testid":c,onCheckedChange:s}),e[2]=s,e[3]=n,e[4]=a,e[5]=c,e[6]=o):o=e[6],o};function kt(d){return`${d.table}·${d.id}`}const St=d=>{const e=U(10),{colSpan:t,name:s,onEnter:n}=d;let l;e[0]!==s||e[1]!==n?(l=()=>{n(s)},e[0]=s,e[1]=n,e[2]=l):l=e[2];const a=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=r("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})}),e[3]=c):c=e[3];let o;e[4]!==a||e[5]!==s?(o=R("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:a,type:"button",children:[c,s]}),e[4]=a,e[5]=s,e[6]=o):o=e[6];let f;return e[7]!==t||e[8]!==o?(f=r(be,{children:r(Q,{colSpan:t,children:o})}),e[7]=t,e[8]=o,e[9]=f):f=e[9],f},wt=d=>{const e=U(37),{busy:t,copiedKey:s,handlers:n,object:l,prefix:a,references:c,selected:o,showReferences:f,t:h}=d;let u;e[0]!==n||e[1]!==l||e[2]!==a?(u=Re(l,a,n),e[0]=n,e[1]=l,e[2]=a,e[3]=u):u=e[3];const{copy:m,download:k,name:i,remove:v,toggle:S}=u;let y;e[4]!==l.key||e[5]!==o||e[6]!==h||e[7]!==S?(y=r(Q,{className:"w-8",children:r(je,{objectKey:l.key,onToggle:S,selected:o,t:h})}),e[4]=l.key,e[5]=o,e[6]=h,e[7]=S,e[8]=y):y=e[8];let g;e[9]!==i?(g=r(Q,{className:"font-mono text-xs",children:i}),e[9]=i,e[10]=g):g=e[10];let b;e[11]!==l.size?(b=_e(l.size),e[11]=l.size,e[12]=b):b=e[12];let x;e[13]!==b?(x=r(Q,{className:"tabular-nums text-muted-foreground",children:b}),e[13]=b,e[14]=x):x=e[14];const N=l.httpMetadata?.contentType??"";let w;e[15]!==N?(w=r(Q,{children:N}),e[15]=N,e[16]=w):w=e[16];let C;e[17]!==l.key||e[18]!==c||e[19]!==f||e[20]!==h?(C=f&&r(Q,{children:r(De,{objectKey:l.key,references:c,t:h})}),e[17]=l.key,e[18]=c,e[19]=f,e[20]=h,e[21]=C):C=e[21];const E=s===l.key;let T;e[22]!==t||e[23]!==m||e[24]!==k||e[25]!==l.key||e[26]!==v||e[27]!==h||e[28]!==E?(T=r(Q,{className:"text-right",children:r("span",{className:"inline-flex items-center gap-1",children:r(ze,{busy:t,copied:E,objectKey:l.key,onCopy:m,onDelete:v,onDownload:k,t:h})})}),e[22]=t,e[23]=m,e[24]=k,e[25]=l.key,e[26]=v,e[27]=h,e[28]=E,e[29]=T):T=e[29];let F;return e[30]!==T||e[31]!==y||e[32]!==g||e[33]!==x||e[34]!==w||e[35]!==C?(F=R(be,{"data-testid":"fb-row",children:[y,g,x,w,C,T]}),e[30]=T,e[31]=y,e[32]=g,e[33]=x,e[34]=w,e[35]=C,e[36]=F):F=e[36],F},Ct=d=>{const e=U(65),{allSelected:t,busy:s,copiedKey:n,files:l,folders:a,handlers:c,onEnterFolder:o,prefix:f,references:h,selected:u,showReferences:m,someSelected:k,t:i,toggleSelectAll:v}=d;let S;e[0]!==i?(S=i("Select all rows"),e[0]=i,e[1]=S):S=e[1];let y;e[2]!==t||e[3]!==k||e[4]!==S||e[5]!==v?(y=r(le,{className:"w-8",children:r(Ee,{"aria-label":S,checked:t,"data-testid":"storage-select-all",indeterminate:k,onCheckedChange:v})}),e[2]=t,e[3]=k,e[4]=S,e[5]=v,e[6]=y):y=e[6];let g;e[7]!==i?(g=i("key"),e[7]=i,e[8]=g):g=e[8];let b;e[9]!==g?(b=r(le,{children:g}),e[9]=g,e[10]=b):b=e[10];let x;e[11]!==i?(x=i("size"),e[11]=i,e[12]=x):x=e[12];let N;e[13]!==x?(N=r(le,{children:x}),e[13]=x,e[14]=N):N=e[14];let w;e[15]!==i?(w=i("content-type"),e[15]=i,e[16]=w):w=e[16];let C;e[17]!==w?(C=r(le,{children:w}),e[17]=w,e[18]=C):C=e[18];let E;e[19]!==m||e[20]!==i?(E=m&&r(le,{children:i("used by")}),e[19]=m,e[20]=i,e[21]=E):E=e[21];let T;e[22]!==i?(T=i("Actions"),e[22]=i,e[23]=T):T=e[23];let F;e[24]!==T?(F=r(le,{"aria-label":T}),e[24]=T,e[25]=F):F=e[25];let _;e[26]!==F||e[27]!==y||e[28]!==b||e[29]!==N||e[30]!==C||e[31]!==E?(_=r(ft,{children:R(be,{children:[y,b,N,C,E,F]})}),e[26]=F,e[27]=y,e[28]=b,e[29]=N,e[30]=C,e[31]=E,e[32]=_):_=e[32];let z;if(e[33]!==a||e[34]!==o||e[35]!==m){let D;e[37]!==o||e[38]!==m?(D=K=>r(St,{colSpan:m?6:5,name:K,onEnter:o},K),e[37]=o,e[38]=m,e[39]=D):D=e[39],z=a.map(D),e[33]=a,e[34]=o,e[35]=m,e[36]=z}else z=e[36];let B;if(e[40]!==s||e[41]!==n||e[42]!==l||e[43]!==c||e[44]!==f||e[45]!==h||e[46]!==u||e[47]!==m||e[48]!==i){let D;e[50]!==s||e[51]!==n||e[52]!==c||e[53]!==f||e[54]!==h||e[55]!==u||e[56]!==m||e[57]!==i?(D=K=>r(wt,{busy:s,copiedKey:n,handlers:c,object:K,prefix:f,references:h[K.key],selected:u.has(K.key),showReferences:m,t:i},K.key),e[50]=s,e[51]=n,e[52]=c,e[53]=f,e[54]=h,e[55]=u,e[56]=m,e[57]=i,e[58]=D):D=e[58],B=l.map(D),e[40]=s,e[41]=n,e[42]=l,e[43]=c,e[44]=f,e[45]=h,e[46]=u,e[47]=m,e[48]=i,e[49]=B}else B=e[49];let j;e[59]!==z||e[60]!==B?(j=R(ut,{children:[z,B]}),e[59]=z,e[60]=B,e[61]=j):j=e[61];let I;return e[62]!==_||e[63]!==j?(I=r(ct,{className:"overflow-hidden py-0",children:r(dt,{className:"px-0",children:R(ht,{"data-testid":"fb-table",children:[_,j]})})}),e[62]=_,e[63]=j,e[64]=I):I=e[64],I},Nt=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],Tt=3600,we=(d,e)=>{if(e==="size")return d.size;if(e==="type")return d.httpMetadata?.contentType??"";if(e==="date"){if(d.uploaded===void 0)return 0;const t=new Date(d.uploaded).getTime();return Number.isNaN(t)?0:t}return e.startsWith("tag:")?d.customMetadata?.[e.slice(4)]??"":d.key},Et=(d,e,t)=>{const s=t==="desc"?-1:1;return d.toSorted((n,l)=>{const a=we(n,e),c=we(l,e);return(typeof a=="number"&&typeof c=="number"?a-c:String(a).localeCompare(String(c)))*s})},_t=(d,e)=>{const t=new Set,s=[];for(const n of d){const l=n.key.slice(e.length),a=l.indexOf("/");a===-1?s.push(n):t.add(l.slice(0,a+1))}return{files:s,folders:[...t].toSorted((n,l)=>n.localeCompare(l))}},$t=d=>{const e=U(59),{bucket:t,buckets:s,busy:n,draftPrefix:l,expiry:a,fileInputRef:c,onBucketChange:o,onExpiryChange:f,onFileChange:h,onList:u,onPrefixChange:m,onUploadClick:k,t:i}=d;let v;e[0]!==m?(v=G=>{m(G.target.value)},e[0]=m,e[1]=v):v=e[1];const S=v;let y;e[2]!==o?(y=G=>{o(G.target.value)},e[2]=o,e[3]=y):y=e[3];const g=y;let b;e[4]!==f?(b=G=>{f(Number.parseInt(G.target.value,10))},e[4]=f,e[5]=b):b=e[5];const x=b;let N;e[6]!==t||e[7]!==s||e[8]!==g||e[9]!==i?(N=s.length>0&&r("select",{"aria-label":i("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:g,value:t,children:s.map(Rt)}),e[6]=t,e[7]=s,e[8]=g,e[9]=i,e[10]=N):N=e[10];let w;e[11]!==i?(w=i("Key prefix"),e[11]=i,e[12]=w):w=e[12];let C;e[13]!==i?(C=i("key prefix (optional)"),e[13]=i,e[14]=C):C=e[14];let E;e[15]!==l||e[16]!==S||e[17]!==w||e[18]!==C?(E=r(bt,{"aria-label":w,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:S,placeholder:C,value:l}),e[15]=l,e[16]=S,e[17]=w,e[18]=C,e[19]=E):E=e[19];let T;e[20]!==i?(T=i("List"),e[20]=i,e[21]=T):T=e[21];let F;e[22]!==n||e[23]!==u||e[24]!==T?(F=r(oe,{"data-testid":"fb-list",disabled:n,onClick:u,size:"sm",type:"button",children:T}),e[22]=n,e[23]=u,e[24]=T,e[25]=F):F=e[25];let _;e[26]!==n||e[27]!==i?(_=i(n?"Uploading…":"Upload"),e[26]=n,e[27]=i,e[28]=_):_=e[28];let z;e[29]!==n||e[30]!==k||e[31]!==_?(z=r(oe,{"data-testid":"storage-upload",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:_}),e[29]=n,e[30]=k,e[31]=_,e[32]=z):z=e[32];let B;e[33]!==c||e[34]!==h?(B=r("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:c,type:"file"}),e[33]=c,e[34]=h,e[35]=B):B=e[35];let j;e[36]!==i?(j=i("Link expiry"),e[36]=i,e[37]=j):j=e[37];let I;e[38]!==i?(I=Nt.map(G=>r("option",{value:G.seconds,children:i(G.label)},G.seconds)),e[38]=i,e[39]=I):I=e[39];let D;e[40]!==a||e[41]!==x||e[42]!==I?(D=r("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:x,value:a,children:I}),e[40]=a,e[41]=x,e[42]=I,e[43]=D):D=e[43];let K;e[44]!==j||e[45]!==D?(K=R("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[j,D]}),e[44]=j,e[45]=D,e[46]=K):K=e[46];let A;e[47]!==i?(A=i("Open in Cloudflare"),e[47]=i,e[48]=A):A=e[48];let M;e[49]!==A?(M=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:A}),e[49]=A,e[50]=M):M=e[50];let H;return e[51]!==z||e[52]!==B||e[53]!==K||e[54]!==M||e[55]!==N||e[56]!==E||e[57]!==F?(H=R("div",{className:"flex flex-wrap items-center gap-2",children:[N,E,F,z,B,K,M]}),e[51]=z,e[52]=B,e[53]=K,e[54]=M,e[55]=N,e[56]=E,e[57]=F,e[58]=H):H=e[58],H},Ft=d=>{const e=U(66),{onSortKeyChange:t,onThumbSizeChange:s,showGrid:n,showList:l,sortDirection:a,sortKey:c,t:o,tagKeys:f,thumbSize:h,toggleSortDirection:u,view:m}=d;let k;e[0]!==t?(k=W=>{t(W.target.value)},e[0]=t,e[1]=k):k=e[1];const i=k;let v;e[2]!==s?(v=W=>{s(Number.parseInt(W.target.value,10))},e[2]=s,e[3]=v):v=e[3];const S=v,y=m==="list";let g;e[4]!==o?(g=o("List"),e[4]=o,e[5]=g):g=e[5];let b;e[6]!==l||e[7]!==y||e[8]!==g?(b=r("button",{"aria-pressed":y,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:l,type:"button",children:g}),e[6]=l,e[7]=y,e[8]=g,e[9]=b):b=e[9];const x=m==="grid";let N;e[10]!==o?(N=o("Grid"),e[10]=o,e[11]=N):N=e[11];let w;e[12]!==n||e[13]!==x||e[14]!==N?(w=r("button",{"aria-pressed":x,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:n,type:"button",children:N}),e[12]=n,e[13]=x,e[14]=N,e[15]=w):w=e[15];let C;e[16]!==b||e[17]!==w?(C=R("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[b,w]}),e[16]=b,e[17]=w,e[18]=C):C=e[18];let E;e[19]!==o?(E=o("Sort"),e[19]=o,e[20]=E):E=e[20];let T;e[21]!==o?(T=o("Name"),e[21]=o,e[22]=T):T=e[22];let F;e[23]!==T?(F=r("option",{value:"name",children:T}),e[23]=T,e[24]=F):F=e[24];let _;e[25]!==o?(_=o("size"),e[25]=o,e[26]=_):_=e[26];let z;e[27]!==_?(z=r("option",{value:"size",children:_}),e[27]=_,e[28]=z):z=e[28];let B;e[29]!==o?(B=o("Type"),e[29]=o,e[30]=B):B=e[30];let j;e[31]!==B?(j=r("option",{value:"type",children:B}),e[31]=B,e[32]=j):j=e[32];let I;e[33]!==o?(I=o("Modified"),e[33]=o,e[34]=I):I=e[34];let D;e[35]!==I?(D=r("option",{value:"date",children:I}),e[35]=I,e[36]=D):D=e[36];let K;e[37]!==f?(K=f.map(zt),e[37]=f,e[38]=K):K=e[38];let A;e[39]!==i||e[40]!==c||e[41]!==F||e[42]!==z||e[43]!==j||e[44]!==D||e[45]!==K?(A=R("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:i,value:c,children:[F,z,j,D,K]}),e[39]=i,e[40]=c,e[41]=F,e[42]=z,e[43]=j,e[44]=D,e[45]=K,e[46]=A):A=e[46];let M;e[47]!==E||e[48]!==A?(M=R("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[E,A]}),e[47]=E,e[48]=A,e[49]=M):M=e[49];let H;e[50]!==o?(H=o("Toggle sort direction"),e[50]=o,e[51]=H):H=e[51];const G=a==="asc"?"↑":"↓";let P;e[52]!==H||e[53]!==G||e[54]!==u?(P=r("button",{"aria-label":H,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:u,type:"button",children:G}),e[52]=H,e[53]=G,e[54]=u,e[55]=P):P=e[55];let Z;e[56]!==S||e[57]!==o||e[58]!==h||e[59]!==m?(Z=m==="grid"&&R("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[o("Thumbnail size"),r("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:S,step:8,type:"range",value:h})]}),e[56]=S,e[57]=o,e[58]=h,e[59]=m,e[60]=Z):Z=e[60];let ee;return e[61]!==M||e[62]!==P||e[63]!==Z||e[64]!==C?(ee=R("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[C,M,P,Z]}),e[61]=M,e[62]=P,e[63]=Z,e[64]=C,e[65]=ee):ee=e[65],ee};function Rt(d){return r("option",{value:d,children:d},d)}function zt(d){return r("option",{value:`tag:${d}`,children:d},d)}const Dt=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,jt=d=>(d.httpMetadata?.contentType??"").startsWith("image/")||Dt.test(d.key),Kt=()=>{const d=U(1);let e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(e=r("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:r("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"})}),d[0]=e):e=d[0],e},Lt=d=>{const e=U(13),{object:t,resolveUrl:s}=d,[n,l]=L(null),[a,c]=L(!1);let o;e[0]!==t?(o=jt(t),e[0]=t,e[1]=o):o=e[1];const f=o;let h,u;e[2]!==f||e[3]!==t.key||e[4]!==s?(h=()=>{if(!f)return;const v={cancelled:!1};return q((async()=>{try{const S=await s(t.key);v.cancelled||l(S)}catch{v.cancelled||c(!0)}})()),()=>{v.cancelled=!0}},u=[f,t.key,s],e[2]=f,e[3]=t.key,e[4]=s,e[5]=h,e[6]=u):(h=e[5],u=e[6]),ne(h,u);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{c(!0)},e[7]=m):m=e[7];const k=m;let i;return e[8]!==a||e[9]!==f||e[10]!==t.key||e[11]!==n?(i=r("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:f&&n!==null&&!a?r("img",{alt:t.key,className:"size-full object-cover",loading:"lazy",onError:k,src:n}):r(Kt,{})}),e[8]=a,e[9]=f,e[10]=t.key,e[11]=n,e[12]=i):i=e[12],i},Bt=d=>{const e=U(42),{busy:t,copiedKey:s,handlers:n,object:l,prefix:a,references:c,resolveUrl:o,selected:f,showReferences:h,t:u}=d;let m;e[0]!==n||e[1]!==l||e[2]!==a?(m=Re(l,a,n),e[0]=n,e[1]=l,e[2]=a,e[3]=m):m=e[3];const{copy:k,download:i,name:v,remove:S,toggle:y}=m;let g;e[4]!==l||e[5]!==o?(g=r(Lt,{object:l,resolveUrl:o}),e[4]=l,e[5]=o,e[6]=g):g=e[6];let b;e[7]!==l.key||e[8]!==f||e[9]!==u||e[10]!==y?(b=r("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:r(je,{objectKey:l.key,onToggle:y,selected:f,t:u})}),e[7]=l.key,e[8]=f,e[9]=u,e[10]=y,e[11]=b):b=e[11];let x;e[12]!==g||e[13]!==b?(x=R("div",{className:"relative",children:[g,b]}),e[12]=g,e[13]=b,e[14]=x):x=e[14];let N;e[15]!==v?(N=r("p",{className:"truncate font-mono text-xs",title:v,children:v}),e[15]=v,e[16]=N):N=e[16];let w;e[17]!==l.size?(w=_e(l.size),e[17]=l.size,e[18]=w):w=e[18];let C;e[19]!==w?(C=r("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:w}),e[19]=w,e[20]=C):C=e[20];let E;e[21]!==l.key||e[22]!==c||e[23]!==h||e[24]!==u?(E=h&&r("div",{className:"mt-1",children:r(De,{objectKey:l.key,references:c,t:u})}),e[21]=l.key,e[22]=c,e[23]=h,e[24]=u,e[25]=E):E=e[25];let T;e[26]!==N||e[27]!==C||e[28]!==E?(T=R("div",{className:"min-w-0",children:[N,C,E]}),e[26]=N,e[27]=C,e[28]=E,e[29]=T):T=e[29];const F=s===l.key;let _;e[30]!==t||e[31]!==k||e[32]!==i||e[33]!==l.key||e[34]!==S||e[35]!==u||e[36]!==F?(_=r("div",{className:"flex items-center gap-1",children:r(ze,{busy:t,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:l.key,onCopy:k,onDelete:S,onDownload:i,t:u})}),e[30]=t,e[31]=k,e[32]=i,e[33]=l.key,e[34]=S,e[35]=u,e[36]=F,e[37]=_):_=e[37];let z;return e[38]!==_||e[39]!==x||e[40]!==T?(z=R("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[x,T,_]}),e[38]=_,e[39]=x,e[40]=T,e[41]=z):z=e[41],z},It=d=>{const e=U(9),{name:t,onEnter:s}=d;let n;e[0]!==t||e[1]!==s?(n=()=>{s(t)},e[0]=t,e[1]=s,e[2]=n):n=e[2];const l=n;let a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:r("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"})})}),e[3]=a):a=e[3];let c;e[4]!==t?(c=r("span",{className:"truncate font-mono text-xs",title:t,children:t}),e[4]=t,e[5]=c):c=e[5];let o;return e[6]!==l||e[7]!==c?(o=R("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:l,type:"button",children:[a,c]}),e[6]=l,e[7]=c,e[8]=o):o=e[8],o},Ot=d=>{const e=U(34),{busy:t,copiedKey:s,files:n,folders:l,handlers:a,onEnterFolder:c,prefix:o,references:f,resolveUrl:h,selected:u,showReferences:m,size:k,t:i}=d;let v;e[0]!==k?(v=k.toString(),e[0]=k,e[1]=v):v=e[1];const S=`repeat(auto-fill, minmax(${v}px, 1fr))`;let y;e[2]!==S?(y={gridTemplateColumns:S},e[2]=S,e[3]=y):y=e[3];const g=y;let b;if(e[4]!==l||e[5]!==c){let w;e[7]!==c?(w=C=>r(It,{name:C,onEnter:c},C),e[7]=c,e[8]=w):w=e[8],b=l.map(w),e[4]=l,e[5]=c,e[6]=b}else b=e[6];let x;if(e[9]!==t||e[10]!==s||e[11]!==n||e[12]!==a||e[13]!==o||e[14]!==f||e[15]!==h||e[16]!==u||e[17]!==m||e[18]!==i){let w;e[20]!==t||e[21]!==s||e[22]!==a||e[23]!==o||e[24]!==f||e[25]!==h||e[26]!==u||e[27]!==m||e[28]!==i?(w=C=>r(Bt,{busy:t,copiedKey:s,handlers:a,object:C,prefix:o,references:f[C.key],resolveUrl:h,selected:u.has(C.key),showReferences:m,t:i},C.key),e[20]=t,e[21]=s,e[22]=a,e[23]=o,e[24]=f,e[25]=h,e[26]=u,e[27]=m,e[28]=i,e[29]=w):w=e[29],x=n.map(w),e[9]=t,e[10]=s,e[11]=n,e[12]=a,e[13]=o,e[14]=f,e[15]=h,e[16]=u,e[17]=m,e[18]=i,e[19]=x}else x=e[19];let N;return e[30]!==g||e[31]!==b||e[32]!==x?(N=R("div",{className:"grid gap-4","data-testid":"fb-gallery",style:g,children:[b,x]}),e[30]=g,e[31]=b,e[32]=x,e[33]=N):N=e[33],N},At=d=>{const e=U(23),{reference:t,t:s}=d,n=`fb-dangling-${t.table}-${t.id}-${t.column}`,l=`${t.table}·${t.id}`;let a;e[0]!==l?(a=r(fe,{variant:"secondary",children:l}),e[0]=l,e[1]=a):a=e[1];let c;e[2]!==t.column?(c=r("span",{className:"text-muted-foreground",children:t.column}),e[2]=t.column,e[3]=c):c=e[3];let o;e[4]!==s?(o=s("→"),e[4]=s,e[5]=o):o=e[5];let f;e[6]!==o?(f=r("span",{className:"text-muted-foreground/60",children:o}),e[6]=o,e[7]=f):f=e[7];let h;e[8]!==t.key?(h=r("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:t.key}),e[8]=t.key,e[9]=h):h=e[9];let u;e[10]!==a||e[11]!==c||e[12]!==f||e[13]!==h?(u=R("span",{className:"flex flex-wrap items-center gap-1.5",children:[a,c,f,h]}),e[10]=a,e[11]=c,e[12]=f,e[13]=h,e[14]=u):u=e[14];let m;e[15]!==s?(m=s("Missing object"),e[15]=s,e[16]=m):m=e[16];let k;e[17]!==m?(k=r(fe,{className:"border-destructive/40 text-destructive",variant:"outline",children:m}),e[17]=m,e[18]=k):k=e[18];let i;return e[19]!==n||e[20]!==k||e[21]!==u?(i=R("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":n,children:[u,k]}),e[19]=n,e[20]=k,e[21]=u,e[22]=i):i=e[22],i},Ut=d=>{const e=U(42),{busy:t,onCheck:s,references:n,t:l,truncated:a}=d;let c;e[0]!==l?(c=l("Integrity"),e[0]=l,e[1]=c):c=e[1];let o;e[2]!==c?(o=r("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:c}),e[2]=c,e[3]=o):o=e[3];let f;e[4]!==l?(f=l("Orphaned objects"),e[4]=l,e[5]=f):f=e[5];let h;e[6]!==f?(h=r("span",{className:"text-sm font-medium text-foreground",children:f}),e[6]=f,e[7]=h):h=e[7];let u;e[8]!==l?(u=l("Find records whose file reference points at an object the bucket no longer has."),e[8]=l,e[9]=u):u=e[9];let m;e[10]!==u?(m=r("span",{className:"text-xs text-muted-foreground",children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==o||e[13]!==h||e[14]!==m?(k=R("div",{className:"flex flex-col gap-1",children:[o,h,m]}),e[12]=o,e[13]=h,e[14]=m,e[15]=k):k=e[15];let i;e[16]!==t||e[17]!==l?(i=l(t?"Checking…":"Check for orphans"),e[16]=t,e[17]=l,e[18]=i):i=e[18];let v;e[19]!==t||e[20]!==s||e[21]!==i?(v=r(oe,{"data-testid":"fb-orphans-check",disabled:t,onClick:s,size:"sm",type:"button",variant:"outline",children:i}),e[19]=t,e[20]=s,e[21]=i,e[22]=v):v=e[22];let S;e[23]!==k||e[24]!==v?(S=R("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[k,v]}),e[23]=k,e[24]=v,e[25]=S):S=e[25];let y;e[26]!==n||e[27]!==l||e[28]!==a?(y=a&&r("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:n===void 0||n.length===0?l("The bucket is larger than the scan's key limit, so dangling references could not be checked."):l("Showing the first {count} dangling references — the scan was truncated.",{count:n.length})}),e[26]=n,e[27]=l,e[28]=a,e[29]=y):y=e[29];let g;e[30]!==n?.length||e[31]!==l||e[32]!==a?(g=n?.length===0&&!a&&r(Te,{description:l("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:l("No dangling references.")}),e[30]=n?.length,e[31]=l,e[32]=a,e[33]=g):g=e[33];let b;e[34]!==n||e[35]!==l?(b=n!==void 0&&n.length>0&&r("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:n.map(N=>r(At,{reference:N,t:l},`${N.table}·${N.id}·${N.column}`))}),e[34]=n,e[35]=l,e[36]=b):b=e[36];let x;return e[37]!==S||e[38]!==y||e[39]!==g||e[40]!==b?(x=R("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[S,y,g,b]}),e[37]=S,e[38]=y,e[39]=g,e[40]=b,e[41]=x):x=e[41],x},Mt=function(d,e){const t=U(18);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,t[0]=s):s=t[0];const[n,l]=L(s);let a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=y=>{l(g=>{const b=new Set(g);return b.has(y)?b.delete(y):b.add(y),b})},t[1]=a):a=t[1];const c=a;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{l(new Set)},t[2]=o):o=t[2];const f=o;let h,u,m;if(t[3]!==d||t[4]!==e||t[5]!==n){let y;t[9]!==e?(y=g=>e(g),t[9]=e,t[10]=y):y=t[10],u=d.map(y),h=u.length>0&&u.every(g=>n.has(g)),m=!h&&u.some(g=>n.has(g)),t[3]=d,t[4]=e,t[5]=n,t[6]=h,t[7]=u,t[8]=m}else h=t[6],u=t[7],m=t[8];const k=m;let i;t[11]!==u?(i=()=>{l(y=>u.every(g=>y.has(g))?new Set:new Set(u))},t[11]=u,t[12]=i):i=t[12];const v=i;let S;return t[13]!==h||t[14]!==n||t[15]!==k||t[16]!==v?(S={allSelected:h,clear:f,selected:n,someSelected:k,toggle:c,toggleAll:v},t[13]=h,t[14]=n,t[15]=k,t[16]=v,t[17]=S):S=t[17],S},Gt=$e(Fe.storageReferences),Ht=$e(Fe.storageOrphans),Ce=1e4,Pt=1e3,qt=async d=>{const e=[];let t,s=!0,n=!1;for(;s&&e.length<Ce;){const l=await d.list({cursor:t,limit:Pt}),a=Ce-e.length;for(const c of l.objects.slice(0,a))e.push(c.key);n||=l.objects.length>a,t=l.cursor,s=t!==void 0}return{liveKeys:e,truncated:n||s}},Wt=3600,Vt=(d,e)=>{if(!("document"in globalThis))return;const t=globalThis.document.createElement("a");t.href=d,t.download=e,t.rel="noopener",globalThis.document.body.append(t),t.click(),t.remove()},Zt=d=>d.key,Xt=({initialPrefix:d,pageSize:e})=>{const t=xt(),[s,n]=L(d??""),[l,a]=L(d??""),[c,o]=L(Tt),[f,h]=L("list"),[u,m]=L(128),[k,i]=L("name"),[v,S]=L("asc"),[y,g]=L(void 0),[b,x]=L(void 0),[N,w]=L(!1),[C,E]=L(void 0),[T,F]=L(void 0),[_,z]=L(""),[B,j]=L({}),[I,D]=L(!1),[K,A]=L(void 0),[M,H]=L(!1),[G,P]=L(!1),[Z,ee]=L([]),[W,ye]=L(""),te=de(0),X=de(0),ae=de(0);ne(()=>{const p={cancelled:!1};return q((async()=>{try{const $=await t.listStorageBuckets();if(!p.cancelled){ee($);const[O]=$;O!==void 0&&ye(J=>J===""?O:J)}}catch{}})()),()=>{p.cancelled=!0}},[t]);const V=ge(()=>({list:p=>t.listStorageObjects({...p,bucket:W}),remove:p=>t.deleteStorageObject(p,{bucket:W}),signedUrl:(p,$)=>t.signedStorageUrl(p,{...$,bucket:W}),upload:p=>t.uploadStorageObject({...p,bucket:W})}),[W,t]),Y=ot(async(p,$,O,J=!1)=>{te.current+=1;const pe=te.current;x(void 0),w(!0);try{const se=await V.list({cursor:$,limit:e,prefix:p});if(pe!==te.current)return;g(ke=>O&&ke!==void 0?[...ke,...se.objects]:se.objects),F(se.cursor)}catch(se){if(pe!==te.current)return;if(O||g(void 0),x(ie(se)),J)throw se}finally{pe===te.current&&w(!1)}},[e,V]);ne(()=>{q(Y(d??"",void 0,!1))},[Y,d]);const Ke=(y?.length??0)<=e;vt(()=>Y(s,void 0,!1,!0),Ke);const{files:ue,folders:Le}=_t(y??[],s),Be=ge(()=>{const p=new Set;for(const $ of ue)for(const O of Object.keys($.customMetadata??{}))p.add(O);return[...p].toSorted(($,O)=>$.localeCompare(O))},[ue]),ce=Et(ue,k,v),he=ge(()=>[...new Set(ce.map(p=>p.key))].toSorted((p,$)=>p.localeCompare($)).join(`
3
+ `),[ce]);ne(()=>{const p=he===""?[]:he.split(`
4
+ `);if(p.length===0){j({});return}const $={current:!0};return q((async()=>{try{const O=await t.query(Gt,{keys:p},Se(_));$.current&&(j(O.references??{}),D(Object.keys(O.storageColumns??{}).length>0))}catch{$.current&&(j({}),D(!1))}})()),()=>{$.current=!1}},[t,he,_]);const{allSelected:Ie,clear:re,selected:xe,someSelected:Oe,toggle:Ae,toggleAll:Ue}=Mt(ce,Zt),Me=()=>{n(l),re(),q(Y(l,void 0,!1))},Ge=()=>{q(Y(s,T,!0))},ve=p=>{n(p),a(p),re(),q(Y(p,void 0,!1))},He=p=>{ve(`${s}${p}`)},Pe=p=>V.signedUrl(p,{expiresInSeconds:Wt}),qe=()=>{h("list")},We=()=>{h("grid")},Ve=p=>{i(p)},Ze=()=>{S(p=>p==="asc"?"desc":"asc")},Xe=p=>{m(p)},Ye=p=>{o(p)},me=p=>{const $=ae.current;x(void 0),w(!0),q((async()=>{try{await p(),$===ae.current&&await Y(s,void 0,!1)}catch(O){x(ie(O))}$===ae.current&&w(!1)})())},Je=()=>{me(async()=>{for(const p of xe)await V.remove(p);re()})},Qe=p=>{x(void 0),q((async()=>{try{const $=await V.signedUrl(p,{expiresInSeconds:c});mt($)&&E(p)}catch($){x(ie($))}})())},et=p=>{x(void 0),q((async()=>{try{const $=await V.signedUrl(p,{expiresInSeconds:c}),O=p.slice(p.lastIndexOf("/")+1)||p;Vt($,O)}catch($){x(ie($))}})())};ne(()=>{if(C===void 0)return;const p=globalThis.setTimeout(()=>{E(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[C]);const tt=p=>{me(async()=>{await V.remove(p)})},st=p=>{const $=`${s}${p.name}`;me(async()=>{const O=await p.arrayBuffer();await V.upload({body:O,contentType:p.type===""?void 0:p.type,key:$})})};ne(()=>{X.current+=1,A(void 0),P(!1)},[_]);const lt=()=>{X.current+=1;const p=X.current;x(void 0),H(!0),q((async()=>{try{const{liveKeys:$,truncated:O}=await qt(V);if(O)p===X.current&&(A(void 0),P(!0));else{const J=await t.query(Ht,{liveKeys:$},Se(_));p===X.current&&(A(J.references??[]),P(J.truncated===!0))}}catch($){p===X.current&&(A(void 0),P(!1),x(ie($)))}p===X.current&&H(!1)})())},nt=p=>{te.current+=1,X.current+=1,ae.current+=1,ye(p),n(d??""),a(d??""),g(void 0),A(void 0),P(!1),re()};return{allSelected:Ie,bucket:W,buckets:Z,bulkDelete:Je,busy:N,checkOrphans:lt,clearSelection:re,copiedKey:C,danglingBusy:M,danglingReferences:K,danglingTruncated:G,draftPrefix:l,enterFolder:He,error:b,expiry:c,files:ce,folders:Le,hasObjects:y!==void 0&&y.length>0,hasStorageColumns:I,listFirst:Me,loaded:y!==void 0,loadMore:Ge,navigate:ve,nextCursor:T,onCopy:Qe,onDelete:tt,onDownload:et,onExpiryChange:Ye,onFile:st,onSortKeyChange:Ve,onThumbSizeChange:Xe,prefix:s,referenceShard:_,references:B,resolveUrl:Pe,selectBucket:nt,selected:xe,setDraftPrefix:a,setReferenceShard:z,showGrid:We,showList:qe,someSelected:Oe,sortDirection:v,sortKey:k,tagKeys:Be,thumbSize:u,toggleSelect:Ae,toggleSelectAll:Ue,toggleSortDirection:Ze,view:f}},Yt=100,Ne=d=>{const e=U(6),{label:t,onNavigate:s,target:n}=d;let l;e[0]!==s||e[1]!==n?(l=()=>{s(n)},e[0]=s,e[1]=n,e[2]=l):l=e[2];const a=l;let c;return e[3]!==a||e[4]!==t?(c=r("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:a,type:"button",children:t}),e[3]=a,e[4]=t,e[5]=c):c=e[5],c},Jt=d=>{const e=U(11),{onNavigate:t,prefix:s,t:n}=d;let l;if(e[0]!==t||e[1]!==s||e[2]!==n){const a=s.split("/").filter(Qt);let c;e[4]!==n?(c=n("Folder path"),e[4]=n,e[5]=c):c=e[5];let o;e[6]!==n?(o=n("root"),e[6]=n,e[7]=o):o=e[7];let f;e[8]!==t||e[9]!==o?(f=r(Ne,{label:o,onNavigate:t,target:""}),e[8]=t,e[9]=o,e[10]=f):f=e[10],l=R("nav",{"aria-label":c,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[f,a.map((h,u)=>R("span",{className:"flex items-center gap-0.5",children:[r("span",{className:"text-muted-foreground/50",children:"/"}),r(Ne,{label:h,onNavigate:t,target:`${a.slice(0,u+1).join("/")}/`})]},`${h}-${u.toString()}`))]}),e[0]=t,e[1]=s,e[2]=n,e[3]=l}else l=e[3];return l},xs=({initialPrefix:d,pageSize:e=Yt})=>{const t=it(),s=Xt({initialPrefix:d,pageSize:e}),n=de(null),{onCopy:l,onDelete:a,onDownload:c,onFile:o,toggleSelect:f}=s,h={onCopy:l,onDelete:a,onDownload:c,onToggleSelect:f},u=()=>{n.current?.click()},m=i=>{const v=i.target,S=v.files?.[0];v.value="",S&&o(S)},k=s.loaded&&!s.hasObjects;return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[r($t,{bucket:s.bucket,buckets:s.buckets,busy:s.busy,draftPrefix:s.draftPrefix,expiry:s.expiry,fileInputRef:n,onBucketChange:s.selectBucket,onExpiryChange:s.onExpiryChange,onFileChange:m,onList:s.listFirst,onPrefixChange:s.setDraftPrefix,onUploadClick:u,t}),s.loaded&&r(Jt,{onNavigate:s.navigate,prefix:s.prefix,t}),s.hasObjects&&r(Ft,{onSortKeyChange:s.onSortKeyChange,onThumbSizeChange:s.onThumbSizeChange,showGrid:s.showGrid,showList:s.showList,sortDirection:s.sortDirection,sortKey:s.sortKey,t,tagKeys:s.tagKeys,thumbSize:s.thumbSize,toggleSortDirection:s.toggleSortDirection,view:s.view}),s.hasStorageColumns&&R("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[r("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:t("References shard")}),r(rt,{id:"fb-reference-shard-input",onChange:s.setReferenceShard,testId:"fb-reference-shard-input",value:s.referenceShard}),r("span",{className:"text-xs text-muted-foreground",children:t("Which shard's records are checked for references to these files. Empty = root shard.")})]}),s.hasStorageColumns&&r(Ut,{busy:s.danglingBusy,onCheck:s.checkOrphans,references:s.danglingReferences,t,truncated:s.danglingTruncated}),s.selected.size>0&&r(at,{count:s.selected.size,editable:!0,onClear:s.clearSelection,onDelete:s.bulkDelete}),s.error!==void 0&&r("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:s.error}),k&&r(Te,{description:t("Objects you upload to your R2 buckets will appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[r("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"}),r("path",{d:"M12 11v5m-2.5-2.5h5"})]}),testId:"fb-empty",title:t("No objects.")}),s.hasObjects&&s.view==="list"&&r(Ct,{allSelected:s.allSelected,busy:s.busy,copiedKey:s.copiedKey,files:s.files,folders:s.folders,handlers:h,onEnterFolder:s.enterFolder,prefix:s.prefix,references:s.references,selected:s.selected,showReferences:s.hasStorageColumns,someSelected:s.someSelected,t,toggleSelectAll:s.toggleSelectAll}),s.hasObjects&&s.view==="grid"&&r(Ot,{busy:s.busy,copiedKey:s.copiedKey,files:s.files,folders:s.folders,handlers:h,onEnterFolder:s.enterFolder,prefix:s.prefix,references:s.references,resolveUrl:s.resolveUrl,selected:s.selected,showReferences:s.hasStorageColumns,size:s.thumbSize,t}),s.nextCursor!==void 0&&r("div",{children:r(oe,{"data-testid":"fb-next",disabled:s.busy,onClick:s.loadMore,size:"sm",type:"button",variant:"outline",children:t("Load more")})})]})};function Qt(d){return d!==""}export{xs as FileBrowser};
@@ -0,0 +1 @@
1
+ import{useLunora as ee}from"@lunora/react";import{encodeWire as U,decodeWire as te}from"@lunora/wire";import{useState as u,useEffect as re}from"react";import{ConfirmButton as ne}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{ShardInput as se}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as z}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as k}from"../packem_shared/button-q0UYSmrn.mjs";import{I as oe}from"../packem_shared/input-CXhxesPC.mjs";import{L as R}from"../packem_shared/label-DKFzyHq6.mjs";import{T as ae}from"../packem_shared/textarea--40GKAyz.mjs";import{useT as ie}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as J,h as le,f as de,k as ue,m as fe,c as he}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as pe}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{jsxs as d,jsx as a}from"react/jsx-runtime";const me=t=>t.kind==="id"?t.table===void 0?"id":`id<${t.table}>`:t.kind==="array"?t.element===void 0?"array":`${t.element}[]`:t.kind,ge=t=>t===void 0||t.length===0?"()":`(${t.map(e=>`${e.name}${e.optional?"?":""}: ${me(e)}`).join(", ")})`,be=t=>{switch(t){case"array":return[];case"bigint":return U(0n);case"boolean":return!1;case"bytes":return U(new ArrayBuffer(0));case"number":return 0;case"object":case"record":return{};default:return""}},xe=t=>{const e={};for(const r of t??[])r.optional||(e[r.name]=be(r.kind));return JSON.stringify(e,void 0,2)},ye=he(ce.runAs),m="«sensitive»",ve=t=>(t??[]).filter(e=>e.sensitive===!0).map(e=>e.name),Ne=(t,e)=>{if(e.length===0)return t;try{const r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return"";const i={...r};for(const s of e)Object.hasOwn(i,s)&&(i[s]=m);return JSON.stringify(i,null,2)}catch{return""}},Ae=4,Se=t=>{const e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}},we=t=>Array.isArray(t)?[]:Object.keys(t).filter(e=>e.length>0),ke=t=>{const e=[],r=new Set,i=[t];for(;i.length>0;){const s=i.pop();if(typeof s=="string")s.length>0&&e.push(s);else if(typeof s=="number"||typeof s=="bigint")e.push(String(s));else if(s instanceof ArrayBuffer||ArrayBuffer.isView(s)){const l=Se(s);l!==void 0&&l.length>0&&e.push(l)}else typeof s=="object"&&s!==null&&!r.has(s)&&(r.add(s),e.push(...we(s)),i.push(...Object.values(s)))}return e},Re=(t,e)=>{const r=[],i=new Set,s=[[t,e]];for(;s.length>0;){const[l,o]=s.pop()??[void 0,void 0];typeof o=="boolean"?r.push({key:l,text:o?"true":"false"}):typeof o=="object"&&o!==null&&!i.has(o)&&(i.add(o),Array.isArray(o)?s.push(...o.map(h=>[void 0,h])):s.push(...Object.entries(o)))}return r},P=t=>t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),Oe=(t,e)=>e.length>=Ae?t.replaceAll(e,m):t.replaceAll(new RegExp(`(?<![A-Za-z0-9])${P(e)}(?![A-Za-z0-9])`,"gu"),m),Ie=(t,e)=>{const r=t.replaceAll(`"${e.text}"`,m);if(e.key===void 0)return r;const i=P(e.key);return r.replaceAll(new RegExp(`(?<![A-Za-z0-9_])${i}=${e.text}(?![A-Za-z0-9_])`,"gu"),`${e.key}=${m}`).replaceAll(new RegExp(String.raw`"${i}":\s*${e.text}(?![A-Za-z0-9_])`,"gu"),`"${e.key}":${m}`)},$e=(t,e,r)=>{if(r.length===0||typeof e!="object"||e===null)return t;const i=r.flatMap(o=>Re(o,e[o])),s=r.flatMap(o=>ke(e[o])).flatMap(o=>{const h=JSON.stringify(o).slice(1,-1);return h===o?[o]:[o,h]}).toSorted((o,h)=>h.length-o.length);let l=t;for(const o of i)l=Ie(l,o);for(const o of s)l=Oe(l,o);return l},Te=10,Ee=t=>t===void 0?"undefined":JSON.stringify(t,ue,2),je=(t,e)=>[{argsText:Ne(e.argsText,e.sensitive),at:Date.now(),id:(t[0]?.id??0)+1,kind:e.selected.kind,path:e.selected.path,redacted:e.sensitive.length>0,shardKey:e.shardKey,status:e.runStatus},...t].slice(0,Te),Ge=({functions:t,runAsIdentity:e=!1}={})=>{const r=ie(),i=ee(),[s,l]=u(null),[o,h]=u(null),A=t??s??[],[O,I]=u(""),[y,S]=u("{}"),[g,$]=u(""),[b,V]=u(""),[w,x]=u("idle"),[Z,v]=u(void 0),[T,N]=u(null),[E,q]=u([]);re(()=>{if(t!==void 0)return;let n=!1;return i.listFunctions().then(f=>(n||l(f),f)).catch(f=>{n||h(J(f))}),()=>{n=!0}},[i,t]);const j=O===""?A[0]?.path??"":O,c=A.find(n=>n.path===j),H=async()=>{if(!c)return;let n;try{n=y.trim()===""?{}:te(JSON.parse(y))}catch(p){x("error"),v(void 0),N(r("Invalid JSON args: {message}",{message:p.message}));return}const f={__lunoraRef:c.path},F=g.trim()===""?{}:{shardKey:g.trim()},K=e?b.trim():"",D=ve(c.args),M=p=>{q(Q=>je(Q,{argsText:y,runStatus:p,selected:c,sensitive:D,shardKey:g}))};x("running"),N(null);try{const p=K===""?await fe(i,c.kind,f,n,F):await i.query(ye,{args:n,functionPath:c.path,userId:K},F);pe(g),v(p),x("success"),M("success")}catch(p){v(void 0),N($e(J(p),n,D)),x("error"),M("error")}},G=n=>{if(I(n.path),$(n.shardKey),n.redacted){v(void 0),N(r("Re-enter the sensitive values before running this again.")),x("error");return}S(n.argsText)},W=n=>{I(n.target.value)},X=n=>{S(n.target.value)},Y=n=>{V(n.target.value)},C=()=>{de(H())},B=e?b.trim():"",L=w==="running"||c===void 0,_=()=>{S(xe(c?.args))};return d("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[o!==null&&a("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:o}),d("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[d("div",{className:"flex flex-col gap-1.5",children:[a(R,{htmlFor:"function-select",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:W,value:j,children:A.map(n=>d("option",{value:n.path,children:[n.path," (",n.kind,")"]},n.path))}),c!==void 0&&d("p",{className:"text-xs text-muted-foreground",children:[a("span",{className:"mr-1.5 font-medium",children:r("Signature")}),a("code",{className:"font-mono","data-testid":"function-signature",children:ge(c.args)})]})]}),d("div",{className:"flex flex-col gap-1.5",children:[d("div",{className:"flex items-center justify-between gap-2",children:[a(R,{htmlFor:"args-input",children:r("Arguments")}),a(k,{"data-testid":"prefill-button",disabled:c===void 0,onClick:_,size:"xs",type:"button",variant:"ghost",children:r("Prefill")})]}),a(ae,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:X,value:y})]}),a(se,{onChange:$,testId:"shard-input",value:g}),e&&d("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[a(R,{htmlFor:"run-as-input",children:r("Run as identity (userId)")}),a(oe,{"aria-label":r("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:Y,placeholder:r("Leave empty to run as admin"),value:b}),a("p",{className:"text-[11px] text-muted-foreground",children:r("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),d("div",{className:"flex flex-wrap items-center gap-2",children:[B!==""&&c!==void 0&&c.kind!=="query"?a(ne,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:c.path,userId:B}),disabled:L,onConfirm:C,testId:"run-button",children:r("Run")}):a(k,{"data-testid":"run-button",disabled:L,onClick:C,type:"button",children:r("Run")}),c!==void 0&&a(z,{variant:"outline",children:c.kind}),e&&b.trim()!==""&&a(z,{"data-testid":"run-as-badge",variant:"secondary",children:r("as {userId}",{userId:b.trim()})})]})]}),w==="error"&&T!==null&&a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:T}),w==="success"&&a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:Ee(Z)}),E.length>0&&a("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:E.map((n,f)=>d("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[a("span",{className:n.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${f.toString()}`,children:n.status==="success"?"✓":"✗"})," ",d("span",{className:"font-mono text-xs",children:[n.path," (",n.kind,")"]})," ",a("time",{className:"text-xs text-muted-foreground",children:le(n.at)})," ",a(k,{className:"ml-auto","data-testid":`fn-history-load-${f.toString()}`,onClick:()=>{G(n)},size:"xs",type:"button",variant:"ghost",children:r("Load")})]},n.id))})]})};export{Ge as FunctionRunner};
@@ -0,0 +1 @@
1
+ import{c as Q}from"react/compiler-runtime";import{useState as U}from"react";import{E as V}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{L as W}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as G}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as J}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as Y,a as Z}from"../packem_shared/card-By2O8ULa.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as te,a as re,b as L,c as a,d as le,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as se}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as ae}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as ne}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as j}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as y}from"react/jsx-runtime";const ce={action:"outline",mutation:"default",query:"secondary"},q=r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,de=r=>r.calls===0?"—":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,me=r=>{const e=r.conflicts??0;return r.calls===0?"—":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},ue={calls:(r,e)=>e.calls-r.calls,recent:(r,e)=>e.lastCalledAt-r.lastCalledAt,slowest:(r,e)=>e.maxDurationMs-r.maxDurationMs},Ae=r=>{const e=Q(47),{functions:I,initialShardKey:P}=r,s=ne(),{queryShardKey:F,setShardKey:N,shardKey:S}=ae(P),[o,H]=U("recent");let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M={},e[0]=M):M=e[0];let T;e[1]!==F?(T={live:!0,shardKey:F},e[1]=F,e[2]=T):T=e[2];const{data:O,error:i,errorSource:b,liveError:v}=se(oe.getFunctionStats,M,T),k=O?.functions??null;let w;e[3]!==I?(w=new Map((I??[]).map(fe)),e[3]=I,e[4]=w):w=e[4];const _=w;let E;e[5]===Symbol.for("react.memo_cache_sentinel")?(E=C=>{H(C.currentTarget.dataset.sort)},e[5]=E):E=e[5];const z=E;let K;if(e[6]!==i||e[7]!==b||e[8]!==_||e[9]!==v||e[10]!==N||e[11]!==S||e[12]!==o||e[13]!==k||e[14]!==s){const C=k===null?[]:k.toSorted(ue[o]);let c;e[16]!==s?(c=s("Recent"),e[16]=s,e[17]=c):c=e[17];let d;e[18]!==c?(d={key:"recent",label:c},e[18]=c,e[19]=d):d=e[19];let m;e[20]!==s?(m=s("Most called"),e[20]=s,e[21]=m):m=e[21];let u;e[22]!==m?(u={key:"calls",label:m},e[22]=m,e[23]=u):u=e[23];let f;e[24]!==s?(f=s("Slowest"),e[24]=s,e[25]=f):f=e[25];let h;e[26]!==f?(h={key:"slowest",label:f},e[26]=f,e[27]=h):h=e[27];let $;e[28]!==h||e[29]!==d||e[30]!==u?($=[d,u,h],e[28]=h,e[29]=d,e[30]=u,e[31]=$):$=e[31];const D=$;let p;e[32]!==N||e[33]!==S?(p=t(G,{onChange:N,testId:"fs-shard-input",value:S}),e[32]=N,e[33]=S,e[34]=p):p=e[34];let x;e[35]!==v?(x=t(W,{message:v,prefix:"fs"}),e[35]=v,e[36]=x):x=e[36];let g;e[37]!==D||e[38]!==o?(g=t("div",{className:"ml-auto flex items-center gap-1",role:"group",children:D.map(l=>t(X,{"data-sort":l.key,"data-testid":`fs-sort-${l.key}`,onClick:z,size:"sm",type:"button",variant:o===l.key?"secondary":"ghost",children:l.label},l.key))}),e[37]=D,e[38]=o,e[39]=g):g=e[39];let A;e[40]!==p||e[41]!==x||e[42]!==g?(A=y("div",{className:"flex flex-wrap items-center gap-2",children:[p,x,g]}),e[40]=p,e[41]=x,e[42]=g,e[43]=A):A=e[43];let B;e[44]!==i||e[45]!==b?(B=i!==null&&t(V,{error:b,testId:"fs-error"}),e[44]=i,e[45]=b,e[46]=B):B=e[46],K=y("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[A,B,k!==null&&C.length===0&&i===null&&t(ee,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:y("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M3 3v18h18"}),t("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),C.length>0&&t(Y,{className:"overflow-hidden py-0",children:t(Z,{className:"px-0",children:y(te,{"data-testid":"fs-table",children:[t(re,{children:y(L,{children:[t(a,{children:s("function")}),t(a,{children:s("kind")}),t(a,{className:"text-right",children:s("calls")}),t(a,{className:"text-right",children:s("errors")}),t(a,{className:"text-right",children:s("conflicts")}),t(a,{className:"text-right",children:s("avg")}),t(a,{className:"text-right",children:s("max")}),t(a,{children:s("last run")}),t(a,{children:s("last error")})]})}),t(le,{children:C.map(l=>{const R=_.get(l.path);return y(L,{"data-testid":`fs-row-${l.path}`,children:[t(n,{className:"font-medium",children:l.path}),t(n,{children:R===void 0?t("span",{className:"text-muted-foreground",children:"—"}):t(J,{variant:ce[R],children:R})}),t(n,{className:"text-right tabular-nums",children:l.calls}),t(n,{className:j("text-right tabular-nums",l.errors>0&&"text-destructive"),children:de(l)}),t(n,{className:j("text-right tabular-nums",(l.conflicts??0)>0&&"text-warning"),children:me(l)}),t(n,{className:"text-right tabular-nums",children:l.calls===0?"—":q(l.totalDurationMs/l.calls)}),t(n,{className:"text-right tabular-nums",children:l.calls===0?"—":q(l.maxDurationMs)}),t(n,{className:"text-muted-foreground",children:ie(l.lastCalledAt,"—")}),t(n,{className:"max-w-[24ch] truncate text-destructive",title:l.lastErrorMessage??void 0,children:l.lastErrorMessage??t("span",{className:"text-muted-foreground",children:"—"})})]},l.path)})})]})})})]}),e[6]=i,e[7]=b,e[8]=_,e[9]=v,e[10]=N,e[11]=S,e[12]=o,e[13]=k,e[14]=s,e[15]=K}else K=e[15];return K};function fe(r){return[r.path,r.kind]}export{Ae as FunctionStatsPanel};
@@ -0,0 +1 @@
1
+ import{c as ae}from"react/compiler-runtime";import{useLunora as pe}from"@lunora/react";import{useState as S,useRef as j,useCallback as ge,useEffect as Z}from"react";import xe from"../packem_shared/ConnectionBadge-B8Hj5DaE.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as _}from"../packem_shared/card-By2O8ULa.mjs";import{u as Ne}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as R}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as be,f as K,d as ee,b as te,c as L}from"../packem_shared/internal-BXEjuLPN.mjs";import{l as we}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as M}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{shardsToAggregate as Ee}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as $}from"../packem_shared/sparkline-B_sPPO_8.mjs";const Se={crit:"destructive",ok:"secondary",warn:"default"},P=(s,e)=>e===0?"—":`${(s/e*100).toFixed(1)}%`,z=(s,e,r)=>Number.isNaN(s)?"ok":s>=r?"crit":s>=e?"warn":"ok",ne=.01,oe=.05,ye=s=>{const e=ae(36),{errorCount:r,logsError:t,topErrors:a,worstFunctions:m}=s,o=le();let n;e[0]!==o?(n=o("Functions by error rate"),e[0]=o,e[1]=n):n=e[1];let f;e[2]!==n?(f=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:n})}),e[2]=n,e[3]=f):f=e[3];let d;e[4]!==o||e[5]!==m?(d=m.length===0?l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:o("No function activity yet.")}):l("ul",{className:"divide-y divide-border",children:m.map(w=>u("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[l("span",{className:"truncate font-mono text-foreground",children:w.path}),u("span",{className:"flex shrink-0 items-center gap-2",children:[l("span",{className:"tabular-nums text-muted-foreground",children:o("{count} calls",{count:w.calls.toString()})}),l(G,{variant:Se[z(w.errors/w.calls,ne,oe)],children:P(w.errors,w.calls)})]})]},w.path))}),e[4]=o,e[5]=m,e[6]=d):d=e[6];let h;e[7]!==f||e[8]!==d?(h=u(_,{className:"gap-0 py-0","data-testid":"hl-functions",children:[f,d]}),e[7]=f,e[8]=d,e[9]=h):h=e[9];let x;e[10]!==o?(x=o("Recent errors"),e[10]=o,e[11]=x):x=e[11];let i;e[12]!==x?(i=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:x}),e[12]=x,e[13]=i):i=e[13];const c=r>0?"destructive":"outline";let p;e[14]!==r||e[15]!==c?(p=l(G,{"data-testid":"hl-error-count",variant:c,children:r}),e[14]=r,e[15]=c,e[16]=p):p=e[16];let g;e[17]!==i||e[18]!==p?(g=u("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[i,p]}),e[17]=i,e[18]=p,e[19]=g):g=e[19];let y;e[20]!==t?(y=t!==null&&l("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:t}),e[20]=t,e[21]=y):y=e[21];let T;e[22]!==t||e[23]!==o||e[24]!==a.length?(T=t===null&&a.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:o("No recent errors.")}),e[22]=t,e[23]=o,e[24]=a.length,e[25]=T):T=e[25];let A;e[26]!==a?(A=a.length>0&&l("ul",{className:"divide-y divide-border",children:a.map(Te)}),e[26]=a,e[27]=A):A=e[27];let N;e[28]!==y||e[29]!==T||e[30]!==A||e[31]!==g?(N=u(_,{className:"gap-0 py-0",children:[g,y,T,A]}),e[28]=y,e[29]=T,e[30]=A,e[31]=g,e[32]=N):N=e[32];let E;return e[33]!==N||e[34]!==h?(E=u("div",{className:"grid gap-3 lg:grid-cols-2",children:[h,N]}),e[33]=N,e[34]=h,e[35]=E):E=e[35],E};function Te(s,e){return u("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[u("span",{className:"flex items-center gap-2",children:[l("time",{className:"shrink-0 text-muted-foreground",children:be(s.timestamp)}),s.functionPath!==void 0&&l("span",{className:"truncate font-mono text-foreground",children:s.functionPath})]}),l("span",{className:"text-destructive",children:s.message})]},`${s.timestamp.toString()}-${e.toString()}`)}const re={completed:0,failed:2,in_progress:1},Ae=s=>{let e=0,r=0,t=0,a=0,m=!1;const o=[];for(const{metrics:n}of s){if(n===null){a+=1;continue}t+=1,e+=n.requests,r+=n.errors,o.push(...n.history??[]),m||=n.historyTruncated===!0}return{errors:r,failed:a,history:o,historyTruncated:m,reachable:t,requests:e}},ke=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.path);if(a===void 0){e.set(t.path,{...t});continue}a.calls+=t.calls,a.errors+=t.errors,a.totalDurationMs+=t.totalDurationMs,a.scans=(a.scans??0)+(t.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,t.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,t.lastCalledAt),(t.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=t.lastErrorAt,a.lastErrorMessage=t.lastErrorMessage)}return[...e.values()]},Re=s=>{const e=new Map;for(const r of s)for(const t of r){const a=e.get(t.id);if(a===void 0){e.set(t.id,t);continue}const m=re[t.status]-re[a.status];(m>0||m===0&&(t.updatedAt??0)>(a.updatedAt??0))&&e.set(t.id,t)}return[...e.values()]},Me=L(R.getAuthMetrics),_e=L(R.getFunctionStats),Le=L(R.getLogs),Ie=L(R.getMetrics),Ce=L(R.migrationStatus),qe=5,se=2e3,Oe=5,Fe=.1,De=.3,je=1,Ue=50,Pe=(s,e,r)=>s>=r?"crit":s>=e?"warn":"ok",Ge=s=>{const e=new Map;for(const t of s??[]){const a=e.get(t.bucketMs)??{calls:0,errors:0};a.calls+=t.calls,a.errors+=t.errors,e.set(t.bucketMs,a)}const r=[...e.entries()].toSorted((t,a)=>t[0]-a[0]);return{errors:r.map(([,t])=>t.errors),requests:r.map(([,t])=>t.calls)}},Ve=s=>{let e=0,r=0;for(const a of s)a.status==="failed"?e+=1:a.status==="in_progress"&&(r+=1);let t="ok";return e>0?t="crit":r>0&&(t="warn"),{failed:e,level:t,running:r}},Be=(s,e)=>s.failed>0?e("{count} failed",{count:s.failed.toString()}):s.running>0?e("{count} running",{count:s.running.toString()}):e("OK"),ie={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ce={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},He={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Ke=s=>s.includes("crit")?"crit":s.includes("warn")?"warn":"ok",U=s=>{const e=ae(19),{chart:r,label:t,level:a,testId:m,value:o}=s,n=ie[a];let f;e[0]!==n?(f=M("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=f):f=e[1];let d;e[2]!==f?(d=l("span",{"aria-hidden":"true",className:f}),e[2]=f,e[3]=d):d=e[3];let h;e[4]!==t||e[5]!==d?(h=u("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[d,t]}),e[4]=t,e[5]=d,e[6]=h):h=e[6];const x=ce[a];let i;e[7]!==x?(i=M("truncate text-2xl font-semibold tabular-nums",x),e[7]=x,e[8]=i):i=e[8];let c;e[9]!==i||e[10]!==m||e[11]!==o?(c=l("span",{className:i,"data-testid":m,children:o}),e[9]=i,e[10]=m,e[11]=o,e[12]=c):c=e[12];let p;e[13]!==r||e[14]!==c?(p=u("div",{className:"flex items-center justify-between gap-3",children:[c,r]}),e[13]=r,e[14]=c,e[15]=p):p=e[15];let g;return e[16]!==h||e[17]!==p?(g=l(_,{className:"gap-0 py-0",children:u("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]})}),e[16]=h,e[17]=p,e[18]=g):g=e[18],g},$e=async(s,e,r)=>{const t=await Promise.all(r.map(i=>{const c=ee(i);return Promise.allSettled([s.query(Ie,{},c),s.query(_e,{},c),s.query(Ce,{},c)])})),a=ee(e),m=typeof s.schedulerStatus=="function"?s.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[o,n,f]=await Promise.allSettled([s.query(Le,{},a),s.query(Me,{},a),m]),d=t.map(([i,c,p])=>({functions:c.status==="fulfilled"?c.value.functions:[],metrics:i.status==="fulfilled"?i.value:null,migrations:p.status==="fulfilled"?p.value.migrations:[]})),h=Ae(d),x=t[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:o.status==="fulfilled"?o.value.entries:[],functions:ke(d.map(i=>i.functions)),logsError:o.status==="rejected"?te(o.reason):null,metricsError:h.reachable===0&&x?.status==="rejected"?te(x.reason):null,migrations:Re(d.map(i=>i.migrations)),scheduler:f.status==="fulfilled"?f.value:null,totals:h}},ze=s=>{const e=s?.history??[];return{attempts:e.map(r=>r.attempts),failures:e.map(r=>r.failures)}},ut=({initialShardKey:s})=>{const e=pe(),r=le(),[t,a]=S([]),[m,o]=S(null),[n,f]=S(null),[d,h]=S(null),[x,i]=S([]),[c,p]=S(null),[g,y]=S(null),[T,A]=S([]),[N]=S(we),E=j(!1),w=j(0),V=j(0),k=j(null),I=s??"",C=ge(async()=>{if(E.current)return;E.current=!0;const v=w.current,b=await $e(e,I,Ee(I,N));v===w.current&&(f(b.totals),h(b.metricsError),i(b.functions),A(b.migrations),a(b.entries),o(b.logsError),p(b.auth),y(b.scheduler),E.current=!1)},[e,N,I]);Z(()=>(K(C()),()=>{w.current+=1,E.current=!1,k.current!==null&&(clearTimeout(k.current),k.current=null)}),[C]);const ue=()=>{const v=Date.now()-V.current;if(v>=se){V.current=Date.now(),K(C());return}k.current===null&&(k.current=setTimeout(()=>{k.current=null,V.current=Date.now(),K(C())},se-v))},{data:Q,liveError:de}=Ne(R.getMetrics,{},{live:!0,shardKey:I});Z(()=>{Q!==void 0&&ue()},[Q]);const W=t.filter(v=>v.level==="error"),me=W.slice(0,qe),q=Ge(n?.history),X=ze(c),fe=x.filter(v=>v.calls>0).toSorted((v,b)=>b.errors/b.calls-v.errors/v.calls||b.calls-v.calls).slice(0,Oe),B=Ve(T),he=n===null||n.requests===0?0:n.errors/n.requests,H=z(he,ne,oe),J=c===null?"ok":z(c.failureRate,Fe,De),Y=g===null?"ok":Pe(g.backlog,je,Ue),O=Ke([H,J,Y,B.level]);let F,D;return O==="crit"?(F=r("Critical"),D=r("One or more service levels are breached.")):O==="warn"?(F=r("Degraded"),D=r("Some service levels need attention.")):(F=r("All systems healthy"),D=r("All service levels are within target.")),u("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[u(_,{className:"gap-0 py-0",children:[u("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[u("div",{className:"flex items-center gap-3",children:[l("span",{"aria-hidden":"true",className:M("flex size-10 shrink-0 items-center justify-center rounded-full",He[O]),children:l("span",{className:M("size-3 rounded-full",ie[O])})}),u("div",{className:"grid leading-tight",children:[l("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:F}),l("span",{className:"text-[13px] text-muted-foreground",children:D})]})]}),u("div",{className:"flex flex-wrap items-center gap-4",children:[u("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Requests")}),u("div",{className:"flex items-center justify-end gap-2",children:[q.requests.length>=2&&l($,{ariaLabel:r("Requests over time"),className:"h-6 w-20 text-foreground",series:q.requests,testId:"hl-spark-requests"}),l("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),u("div",{className:"text-end",children:[l("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r("Error rate")}),l("div",{className:M("text-lg font-semibold tabular-nums",ce[H]),"data-testid":"hl-error-rate",children:n===null?"—":P(n.errors,n.requests)})]}),l("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),u("div",{className:"flex items-center gap-2",children:[l(xe,{}),l(ve,{message:de,prefix:"hl"})]})]})]}),d!==null&&l("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:d}),d===null&&n?.historyTruncated===!0&&l("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:r("Showing a partial request/error history — one or more shards have more data than the trend chart can display.")})]}),u("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[l(U,{chart:q.errors.length>=2?l($,{ariaLabel:r("Errors over time"),className:"h-7 w-20 text-destructive",series:q.errors,testId:"hl-spark-errors"}):void 0,label:r("Error rate"),level:H,testId:"hl-slo-errorrate",value:n===null?"—":P(n.errors,n.requests)}),l(U,{chart:X.failures.length>=2?l($,{ariaLabel:r("Auth failures over time"),className:"h-7 w-20 text-destructive",series:X.failures,testId:"hl-spark-auth"}):void 0,label:r("Auth failures"),level:J,testId:"hl-slo-auth",value:c===null?"—":P(c.failures,c.attempts)}),l(U,{label:r("Scheduler backlog"),level:Y,testId:"hl-slo-backlog",value:g===null?"—":g.backlog.toString()}),l(U,{label:r("Migrations"),level:B.level,testId:"hl-slo-migrations",value:Be(B,r)})]}),l(ye,{errorCount:W.length,logsError:m,topErrors:me,worstFunctions:fe}),u(_,{className:"gap-0 py-0",children:[u("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Shards seen")}),l(G,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&l("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(v=>l("li",{"data-testid":"hl-shard",children:l(G,{variant:"secondary",children:v})},v))})]})]})};export{ut as HealthPanel};
@@ -0,0 +1 @@
1
+ import{c as X}from"react/compiler-runtime";import{useLunora as se}from"@lunora/react";import{useNavigate as ae}from"@tanstack/react-router";import{useState as H,useRef as re,useEffectEvent as Q,useEffect as z,useCallback as oe,useMemo as N}from"react";import{ShardInput as ie}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as ce}from"../packem_shared/button-q0UYSmrn.mjs";import{u as B}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as le}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as w}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as k,d as E,c as M,n as de}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as ue}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{a as G,A as fe}from"../packem_shared/advisor-view-CXiPdw4B.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{jsx as v,jsxs as he}from"react/jsx-runtime";import{deriveInsights as pe}from"../packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs";import{runAdvisor as be,RUNTIME_LINTS as xe}from"@lunora/advisor";const ye=t=>{const{suggestedIndex:e,table:a}=t;if(typeof a!="string"||a.length===0||typeof e!="object"||e===null)return!1;const{fields:n,name:s}=e;return!Array.isArray(n)||n.length===0||n.some(i=>typeof i!="string"||i.length===0)?!1:typeof s=="string"&&s.length>0},ge=(t,e)=>`.index(${JSON.stringify(t)}, [${e.map(a=>JSON.stringify(a)).join(", ")}])`,ve=t=>{const e=X(19),{fields:a,indexName:n,table:s,testId:i}=t,l=K(),[f,d]=H(null);let m;e[0]!==a||e[1]!==n?(m=()=>{const b=ge(n,a),I="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(I===void 0){d({copied:!1,declaration:b});return}k(I.writeText(b).then(()=>(d({copied:!0,declaration:b}),!0)),()=>{d({copied:!1,declaration:b})})},e[0]=a,e[1]=n,e[2]=m):m=e[2];const S=m;if(f!==null){let b;return e[3]!==f.copied||e[4]!==f.declaration||e[5]!==l||e[6]!==s||e[7]!==i?(b=f.copied?v("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:l("Index declaration copied — add it to {table} in lunora/schema.ts.",{table:s})}):he("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[l("Could not reach the clipboard — add this to {table} in lunora/schema.ts:",{table:s}),v("code",{className:"font-mono break-all select-all",children:f.declaration})]}),e[3]=f.copied,e[4]=f.declaration,e[5]=l,e[6]=s,e[7]=i,e[8]=b):b=e[8],b}let u;e[9]!==l?(u=l("Copy?"),e[9]=l,e[10]=u):u=e[10];let h;e[11]!==l||e[12]!==s?(h=l("Copy index declaration for {table}",{table:s}),e[11]=l,e[12]=s,e[13]=h):h=e[13];let y;return e[14]!==S||e[15]!==u||e[16]!==h||e[17]!==i?(y=v(me,{confirmLabel:u,onConfirm:S,testId:i,children:h}),e[14]=S,e[15]=u,e[16]=h,e[17]=i,e[18]=y):y=e[18],y},Se=(t,e)=>{const a=new Map;for(const n of e){const s=`${n.table} ${n.index}`;a.set(s,(a.get(s)??0)+n.reads)}return t.map(n=>({index:n.index,reads:a.get(`${n.table} ${n.index}`)??0,table:n.table}))},Te=t=>{const e=new Map;for(const a of t)for(const n of a.scannedTables??[])e.set(n.table,(e.get(n.table)??0)+n.scans);return[...e].map(([a,n])=>({scans:n,table:a}))},P=(t,e)=>e.map(a=>({index:a.name,table:t})),we=t=>{const e=Se(t.declaredIndexes??[],t.indexHits??[]),a=Te(t.functions??[]),n=t.shardTraffic??[],s=t.analyticsMetrics,i=s&&s.indexHits.length>0?s.indexHits:e,l=s&&s.tableScans.length>0?s.tableScans:a,f=s&&s.shardTraffic.length>0?s.shardTraffic:n,d=be({indexHits:i,schema:{tables:[]},shardTraffic:f,tableScans:l},{lints:xe,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?d:d.filter(u=>!(u.metadata.kind==="hot_scan"&&typeof u.metadata.table=="string"&&m.has(u.metadata.table)))).map(u=>G(u))},Ie=M(w.listTables),$e=M(w.listTableIndexes),Ae=M(w.listTablesIndexes),L=t=>`${(t*100).toFixed(1)}%`,V=t=>`${(t/1e3).toFixed(2)}s`,Ne=t=>{if(t.length<=1)return t[0]??"";const e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},ke=(t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],U=(t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:L(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict — consider sharding to cut contention.",{rate:L(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:L(e.value)}),"missing-index":t("Slowest call took {duration} — it full-scanned {tables} with no index.",{duration:V(e.value),tables:Ne(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:V(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling — plan a .shardBy() migration while it still has runway.",{size:de(e.value)})})[e.kind],Be=t=>{const e=X(10),{onJump:a,table:n}=t,s=K();let i;e[0]!==a||e[1]!==n?(i=()=>{a(n)},e[0]=a,e[1]=n,e[2]=i):i=e[2];const l=i,f=`in-add-index-${n}`;let d;e[3]!==s||e[4]!==n?(d=s("Add index on {table}",{table:n}),e[3]=s,e[4]=n,e[5]=d):d=e[5];let m;return e[6]!==l||e[7]!==f||e[8]!==d?(m=v(ce,{"data-testid":f,onClick:l,size:"sm",type:"button",variant:"outline",children:d}),e[6]=l,e[7]=f,e[8]=d,e[9]=m):m=e[9],m},Ue=({initialShardKey:t,loadShardTraffic:e})=>{const a=se(),n=ae(),s=K(),{queryShardKey:i,setShardKey:l,shardKey:f}=le(t),[d,m]=H(null),[S,u]=H(null),h=re(""),y=B(w.getMetrics,{},{live:!0,shardKey:i}),b=B(w.getFunctionStats,{},{live:!0,shardKey:i}),I=B(w.getAdvisories,{},{live:!0,shardKey:i}),D=y.data??null,$=b.data?.functions??null,R=I.data?.advisories??null,C=y.data?.indexHits??null,j=y.error!==null&&b.error!==null?y.error:null,W=e??(r=>a.shardTraffic(r)),Y=async(r,x)=>{const g=r[0];if(g===void 0||g===""){h.current===x&&u(null);return}try{const o=await W(g);if(h.current!==x)return;const c=new Map;for(const p of o.shards)c.has(p.shardKey)||c.set(p.shardKey,{requests:p.requests,shardKey:p.shardKey});u([...c.values()])}catch{h.current===x&&u(null)}},Z=async(r,x)=>{const g=await Promise.allSettled(r.map(async c=>[c,await a.query($e,{table:c},E(x))])),o=[];for(const c of g)if(c.status==="fulfilled"){const[p,T]=c.value;o.push(...P(p,T.indexes))}return o},F=Q(async r=>{h.current=r;let x=[];try{const g=await a.query(Ie,{},E(r));if(h.current!==r)return;ue(r),x=g.map(c=>c.name);let o=[];if(x.length>0)try{const c=await a.query(Ae,{tables:x},E(r));if(h.current!==r)return;for(const[p,T]of Object.entries(c.indexesByTable))o.push(...P(p,T))}catch{if(o=await Z(x,r),h.current!==r)return}m(o)}catch{h.current===r&&m(null)}await Y(x,r)});z(()=>{k(F(i))},[i]);const _=Q(()=>{y.refetch(),b.refetch(),I.refetch(),k(F(i))});z(()=>{const r=()=>{document.visibilityState==="visible"&&_()};return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);const O=oe(r=>{k(n({search:{table:r},to:"/schema"}))},[n]),A=N(()=>pe(D,$),[$,D]),q=N(()=>new Set(A.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[A]),J=N(()=>we({declaredIndexes:d??[],functions:$,indexHits:C,shardTraffic:S,suppressHotScanTables:q}),[d,$,C,q,S]),ee=N(()=>{const r=A.map(o=>{const c=o.kind==="missing-index"?o.tables??[]:[];return{action:c.length>0?c.map(p=>v(Be,{onJump:O,table:p},p)):void 0,description:o.message===void 0?U(s,o):`${U(s,o)} — ${o.message}`,entity:o.fn,issueType:ke(s,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(R??[]).map(o=>{const c=G(o);if(x.has(o.name)&&ye(o.metadata)){const{table:p,suggestedIndex:T}=o.metadata,ne=`in-apply-index-${p}-${T.name}`;return{...c,action:v(ve,{fields:T.fields,indexName:T.name,table:p,testId:ne})}}return c}),...J,...r]},[R,A,O,J,s]),te=v(ie,{onChange:l,testId:"in-shard-input",value:f});return v(fe,{error:j,errorSource:j===null?void 0:y.errorSource,rows:ee,testId:"lunora-insights",toolbar:te})};export{Ue as InsightsPanel};
@@ -0,0 +1 @@
1
+ import{c as q}from"react/compiler-runtime";import{useVirtualizer as Ce}from"@tanstack/react-virtual";import{useState as F,useReducer as Le,useRef as ue,useEffect as me,useMemo as Ne}from"react";import{f as fe}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{E as Se}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as he}from"../packem_shared/badge-r_5B4LHP.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{u as le}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as Te}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as Ie}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as Re}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as ke}from"../packem_shared/virtual-rect-D_j7aLxX.mjs";import{useLunora as Pe}from"@lunora/react";import{B as Ee}from"../packem_shared/button-q0UYSmrn.mjs";import{I as D}from"../packem_shared/input-CXhxesPC.mjs";import{T as Oe,a as _e,b as ge,c as B,d as Fe,e as V}from"../packem_shared/table-D0SBiDu-.mjs";import ae from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{a as pe}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{f as ne,j as qe,b as ie}from"../packem_shared/internal-BXEjuLPN.mjs";import{a as Ae,L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{jsx as r,jsxs as E,Fragment as $e}from"react/jsx-runtime";import{c as H}from"../packem_shared/utils-bhneXptQ.mjs";import{L as Ue}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as Ke}from"../packem_shared/ShardInput-C6mjgAh4.mjs";const re=["trace","debug","log","info","warn","error","fatal"],Be="LOG_ARCHIVE_NOT_CONFIGURED",Ve={cursor:void 0,error:null,loading:!1,notConfigured:!1,rows:null},De=(i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},Qe=i=>{const e=q(33),{row:t}=i;let a;e[0]!==t.fields?(a=fe(t.fields),e[0]=t.fields,e[1]=a):a=e[1];const n=a,o=`lg-archive-row-${String(t.ts)}`;let d;e[2]!==t.ts?(d=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=d):d=e[3];let p;e[4]!==d?(p=r(V,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:d}),e[4]=d,e[5]=p):p=e[5];const m=Ae[t.level];let c;e[6]!==t.level||e[7]!==m?(c=r(V,{children:r(he,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=c):c=e[8];let s;e[9]!==t.functionPath?(s=r(V,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=s):s=e[10];let f;e[11]!==t.message?(f=r("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=f):f=e[12];let l;e[13]!==n?(l=n!==""&&r("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n,children:n}),e[13]=n,e[14]=l):l=e[14];let u;e[15]!==f||e[16]!==l?(u=E(V,{className:"max-w-md",children:[f,l]}),e[15]=f,e[16]=l,e[17]=u):u=e[17];const h=t.traceId??"—";let v;e[18]!==h?(v=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:h}),e[18]=h,e[19]=v):v=e[19];const b=t.shardKey??"—";let y;e[20]!==b?(y=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:b}),e[20]=b,e[21]=y):y=e[21];const w=t.userId??"—";let x;e[22]!==w?(x=r(V,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[22]=w,e[23]=x):x=e[23];let T;return e[24]!==u||e[25]!==v||e[26]!==y||e[27]!==x||e[28]!==o||e[29]!==p||e[30]!==c||e[31]!==s?(T=E(ge,{"data-testid":o,children:[p,c,s,u,v,y,x]}),e[24]=u,e[25]=v,e[26]=y,e[27]=x,e[28]=o,e[29]=p,e[30]=c,e[31]=s,e[32]=T):T=e[32],T},ze=({shardKey:i})=>{const e=Pe(),t=Q(),[a,n]=F(""),[o,d]=F(""),[p,m]=F(""),[{cursor:c,error:s,loading:f,notConfigured:l,rows:u},h]=Le(De,Ve),v=ae(a.trim(),400),b=ae(o.trim(),400),y={...v===""?{}:{functionPathPrefix:v},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...b===""?{}:{userId:b}},w=JSON.stringify(y),x=ue(w);me(()=>{const g={cancelled:!1};return x.current=w,ne((async()=>{h({type:"loading"});try{const C=await e.queryLogArchive(y);g.cancelled||h({cursor:C.nextCursor,rows:C.rows,type:"loaded"})}catch(C){g.cancelled||h(qe(C)===Be?{type:"notConfigured"}:{message:ie(C),type:"failed"})}})()),()=>{g.cancelled=!0}},[e,w]);const T=async()=>{if(c===void 0)return;const g=w;h({type:"loading"});try{const C=await e.queryLogArchive({...y,cursor:c});x.current===g&&h({cursor:C.nextCursor,rows:C.rows,type:"append"})}catch(C){x.current===g&&h({message:ie(C),type:"pageFailed"})}},R=g=>{n(g.target.value)},N=g=>{d(g.target.value)},L=g=>{m(g.target.value)},S=()=>{ne(T())};return l?r(ee,{action:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:pe,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline → R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):E("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[E("div",{className:"flex flex-wrap items-center gap-2",children:[r(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:R,placeholder:t("function path…"),value:a}),r(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:N,placeholder:t("user id…"),value:o}),E("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:L,value:p,children:[r("option",{value:"",children:t("min level")}),re.map(g=>r("option",{value:g,children:g},g))]})]}),s!==null&&r("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:s}),f&&u===null&&s===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading…")}),u!==null&&u.length===0&&r(ee,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&r("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:E(Oe,{"data-testid":"lg-archive-table",children:[r(_e,{children:E(ge,{children:[r(B,{children:t("Time")}),r(B,{children:t("Level")}),r(B,{children:t("Function")}),r(B,{children:t("Message")}),r(B,{children:t("Trace")}),r(B,{children:t("Shard")}),r(B,{children:t("User")})]})}),r(Fe,{children:u.map((g,C)=>r(Qe,{row:g},`${String(g.ts)}-${String(C)}`))})]})}),c!==void 0&&r("div",{children:r(Ee,{"data-testid":"lg-archive-more",disabled:f,onClick:S,size:"sm",variant:"outline",children:t(f?"Loading…":"Load more")})})]})},Ge=i=>{const e=q(11),{level:t,onToggle:a,selected:n}=i;let o;e[0]!==t||e[1]!==a?(o=()=>{a(t)},e[0]=t,e[1]=a,e[2]=o):o=e[2];const d=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground";let m;e[3]!==p?(m=H("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];const c=`logs-level-${t}`;let s;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==m||e[9]!==c?(s=r("button",{"aria-pressed":n,className:m,"data-testid":c,onClick:d,type:"button",children:t}),e[5]=t,e[6]=d,e[7]=n,e[8]=m,e[9]=c,e[10]=s):s=e[10],s},He=i=>{const e=q(68),{levelFilter:t,onLogPathChange:a,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:d,onToggleSummary:p,pathFilter:m,search:c,showSummary:s,timeRange:f}=i,l=Q();let u;e[0]!==l?(u=l("Search messages"),e[0]=l,e[1]=u):u=e[1];let h;e[2]!==l?(h=l("search message"),e[2]=l,e[3]=h):h=e[3];let v;e[4]!==n||e[5]!==c||e[6]!==u||e[7]!==h?(v=r(D,{"aria-label":u,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:h,value:c}),e[4]=n,e[5]=c,e[6]=u,e[7]=h,e[8]=v):v=e[8];let b;e[9]!==l?(b=l("Function path"),e[9]=l,e[10]=b):b=e[10];let y;e[11]!==l?(y=l("filter path"),e[11]=l,e[12]=y):y=e[12];let w;e[13]!==a||e[14]!==m||e[15]!==b||e[16]!==y?(w=r(D,{"aria-label":b,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:a,placeholder:y,value:m}),e[13]=a,e[14]=m,e[15]=b,e[16]=y,e[17]=w):w=e[17];let x;e[18]!==l?(x=l("Level filter"),e[18]=l,e[19]=x):x=e[19];let T;e[20]!==t||e[21]!==d?(T=re.map(G=>r(Ge,{level:G,onToggle:d,selected:t.has(G)},G)),e[20]=t,e[21]=d,e[22]=T):T=e[22];let R;e[23]!==x||e[24]!==T?(R=r("div",{"aria-label":x,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:T}),e[23]=x,e[24]=T,e[25]=R):R=e[25];let N;e[26]!==l?(N=l("Time range"),e[26]=l,e[27]=N):N=e[27];let L;e[28]!==l?(L=l("All time"),e[28]=l,e[29]=L):L=e[29];let S;e[30]!==L?(S=r("option",{value:"all",children:L}),e[30]=L,e[31]=S):S=e[31];let g;e[32]!==l?(g=l("Last 5m"),e[32]=l,e[33]=g):g=e[33];let C;e[34]!==g?(C=r("option",{value:"5m",children:g}),e[34]=g,e[35]=C):C=e[35];let k;e[36]!==l?(k=l("Last 15m"),e[36]=l,e[37]=k):k=e[37];let P;e[38]!==k?(P=r("option",{value:"15m",children:k}),e[38]=k,e[39]=P):P=e[39];let O;e[40]!==l?(O=l("Last hour"),e[40]=l,e[41]=O):O=e[41];let _;e[42]!==O?(_=r("option",{value:"1h",children:O}),e[42]=O,e[43]=_):_=e[43];let A;e[44]!==o||e[45]!==N||e[46]!==S||e[47]!==C||e[48]!==P||e[49]!==_||e[50]!==f?(A=E("select",{"aria-label":N,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:f,children:[S,C,P,_]}),e[44]=o,e[45]=N,e[46]=S,e[47]=C,e[48]=P,e[49]=_,e[50]=f,e[51]=A):A=e[51];const z=s?"border-border bg-muted font-medium":"border-input text-muted-foreground";let M;e[52]!==z?(M=H("h-8 rounded-md border px-3 text-sm",z),e[52]=z,e[53]=M):M=e[53];let U;e[54]!==s||e[55]!==l?(U=l(s?"List":"Summary"),e[54]=s,e[55]=l,e[56]=U):U=e[56];let $;e[57]!==p||e[58]!==s||e[59]!==M||e[60]!==U?($=r("button",{"aria-pressed":s,className:M,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=s,e[59]=M,e[60]=U,e[61]=$):$=e[61];let K;return e[62]!==A||e[63]!==$||e[64]!==v||e[65]!==w||e[66]!==R?(K=E("div",{className:"flex flex-wrap items-center gap-2",children:[v,w,R,A,$]}),e[62]=A,e[63]=$,e[64]=v,e[65]=w,e[66]=R,e[67]=K):K=e[67],K},We=i=>{const e=q(53),{onOutcomeChange:t,onPathChange:a,onTableChange:n,onUserChange:o,outcomeFilter:d,pathPrefix:p,tableFilter:m,userIdFilter:c}=i,s=Q();let f;e[0]!==s?(f=s("Function path"),e[0]=s,e[1]=f):f=e[1];let l;e[2]!==s?(l=s("file:function"),e[2]=s,e[3]=l):l=e[3];let u;e[4]!==a||e[5]!==p||e[6]!==f||e[7]!==l?(u=r(D,{"aria-label":f,className:"h-8 w-44","data-testid":"lg-req-path",onChange:a,placeholder:l,value:p}),e[4]=a,e[5]=p,e[6]=f,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==s?(h=s("User id"),e[9]=s,e[10]=h):h=e[10];let v;e[11]!==s?(v=s("userId"),e[11]=s,e[12]=v):v=e[12];let b;e[13]!==o||e[14]!==h||e[15]!==v||e[16]!==c?(b=r(D,{"aria-label":h,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:v,value:c}),e[13]=o,e[14]=h,e[15]=v,e[16]=c,e[17]=b):b=e[17];let y;e[18]!==s?(y=s("Table touched"),e[18]=s,e[19]=y):y=e[19];let w;e[20]!==s?(w=s("table"),e[20]=s,e[21]=w):w=e[21];let x;e[22]!==n||e[23]!==y||e[24]!==w||e[25]!==m?(x=r(D,{"aria-label":y,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:w,value:m}),e[22]=n,e[23]=y,e[24]=w,e[25]=m,e[26]=x):x=e[26];let T;e[27]!==s?(T=s("Outcome filter"),e[27]=s,e[28]=T):T=e[28];let R;e[29]!==s?(R=s("all"),e[29]=s,e[30]=R):R=e[30];let N;e[31]!==R?(N=r("option",{value:"all",children:R}),e[31]=R,e[32]=N):N=e[32];let L;e[33]!==s?(L=s("ok"),e[33]=s,e[34]=L):L=e[34];let S;e[35]!==L?(S=r("option",{value:"ok",children:L}),e[35]=L,e[36]=S):S=e[36];let g;e[37]!==s?(g=s("error"),e[37]=s,e[38]=g):g=e[38];let C;e[39]!==g?(C=r("option",{value:"error",children:g}),e[39]=g,e[40]=C):C=e[40];let k;e[41]!==t||e[42]!==d||e[43]!==T||e[44]!==N||e[45]!==S||e[46]!==C?(k=E("select",{"aria-label":T,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:d,children:[N,S,C]}),e[41]=t,e[42]=d,e[43]=T,e[44]=N,e[45]=S,e[46]=C,e[47]=k):k=e[47];let P;return e[48]!==k||e[49]!==u||e[50]!==b||e[51]!==x?(P=E("div",{className:"flex flex-wrap items-center gap-2",children:[u,b,x,k]}),e[48]=k,e[49]=u,e[50]=b,e[51]=x,e[52]=P):P=e[52],P},ve=i=>{const e=q(7),{bucket:t}=i;let a;e[0]!==t.key?(a=r("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=a):a=e[1];let n;e[2]!==t.count?(n=r("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==a||e[5]!==n?(o=E("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[a,n]}),e[4]=a,e[5]=n,e[6]=o):o=e[6],o},Ye=i=>{const e=q(31),{summary:t}=i,a=Q();let n;e[0]!==t.total||e[1]!==a?(n=a("{count} entries",{count:t.total}),e[0]=t.total,e[1]=a,e[2]=n):n=e[2];let o;e[3]!==n?(o=r("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let d;e[5]!==a?(d=a("By level"),e[5]=a,e[6]=d):d=e[6];let p;e[7]!==d?(p=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),e[7]=d,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(je),e[9]=t.byLevel,e[10]=m):m=e[10];let c;e[11]!==m?(c=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=c):c=e[12];let s;e[13]!==p||e[14]!==c?(s=E("div",{children:[p,c]}),e[13]=p,e[14]=c,e[15]=s):s=e[15];let f;e[16]!==a?(f=a("By function"),e[16]=a,e[17]=f):f=e[17];let l;e[18]!==f?(l=r("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f}),e[18]=f,e[19]=l):l=e[19];let u;e[20]!==t.byPath?(u=t.byPath.map(Je),e[20]=t.byPath,e[21]=u):u=e[21];let h;e[22]!==u?(h=r("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:u}),e[22]=u,e[23]=h):h=e[23];let v;e[24]!==h||e[25]!==l?(v=E("div",{children:[l,h]}),e[24]=h,e[25]=l,e[26]=v):v=e[26];let b;return e[27]!==v||e[28]!==o||e[29]!==s?(b=E("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,s,v]}),e[27]=v,e[28]=o,e[29]=s,e[30]=b):b=e[30],b};function je(i){return r(ve,{bucket:i},i.key)}function Je(i){return r(ve,{bucket:i},i.key)}const Xe=i=>{const e=q(46),{liveError:t,onShardKeyChange:a,onShowArchive:n,onShowErrors:o,onShowRequests:d,shardKey:p,view:m}=i,c=Q(),s=m==="requests",f=m==="requests"?"bg-muted font-medium":"text-muted-foreground";let l;e[0]!==f?(l=H("px-3 py-1 text-sm",f),e[0]=f,e[1]=l):l=e[1];let u;e[2]!==c?(u=c("Requests"),e[2]=c,e[3]=u):u=e[3];let h;e[4]!==d||e[5]!==s||e[6]!==l||e[7]!==u?(h=r("button",{"aria-selected":s,className:l,"data-testid":"lg-view-requests",onClick:d,role:"tab",type:"button",children:u}),e[4]=d,e[5]=s,e[6]=l,e[7]=u,e[8]=h):h=e[8];const v=m==="errors",b=m==="errors"?"bg-muted font-medium":"text-muted-foreground";let y;e[9]!==b?(y=H("px-3 py-1 text-sm",b),e[9]=b,e[10]=y):y=e[10];let w;e[11]!==c?(w=c("Errors"),e[11]=c,e[12]=w):w=e[12];let x;e[13]!==o||e[14]!==v||e[15]!==y||e[16]!==w?(x=r("button",{"aria-selected":v,className:y,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:w}),e[13]=o,e[14]=v,e[15]=y,e[16]=w,e[17]=x):x=e[17];const T=m==="archive",R=m==="archive"?"bg-muted font-medium":"text-muted-foreground";let N;e[18]!==R?(N=H("px-3 py-1 text-sm",R),e[18]=R,e[19]=N):N=e[19];let L;e[20]!==c?(L=c("Archive"),e[20]=c,e[21]=L):L=e[21];let S;e[22]!==n||e[23]!==T||e[24]!==N||e[25]!==L?(S=r("button",{"aria-selected":T,className:N,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:L}),e[22]=n,e[23]=T,e[24]=N,e[25]=L,e[26]=S):S=e[26];let g;e[27]!==x||e[28]!==S||e[29]!==h?(g=E("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[h,x,S]}),e[27]=x,e[28]=S,e[29]=h,e[30]=g):g=e[30];let C;e[31]!==a||e[32]!==p?(C=r(Ke,{onChange:a,testId:"lg-shard-input",value:p}),e[31]=a,e[32]=p,e[33]=C):C=e[33];let k;e[34]!==t||e[35]!==m?(k=m!=="archive"&&r(Ue,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=k):k=e[36];let P;e[37]!==c?(P=c("Open in Cloudflare"),e[37]=c,e[38]=P):P=e[38];let O;e[39]!==P?(O=r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:pe,rel:"noreferrer",target:"_blank",children:P}),e[39]=P,e[40]=O):O=e[40];let _;return e[41]!==g||e[42]!==C||e[43]!==k||e[44]!==O?(_=E("div",{className:"flex flex-wrap items-center gap-2",children:[g,C,k,O]}),e[41]=g,e[42]=C,e[43]=k,e[44]=O,e[45]=_):_=e[45],_},te=400,Ze=36,et={height:te,overflow:"auto"},be={left:0,position:"absolute",top:0,width:"100%"},tt={error:"destructive",ok:"secondary"},xe=i=>{const e=q(6),{onOpenTrace:t,traceId:a}=i,n=Q();let o;e[0]!==t||e[1]!==n||e[2]!==a?(o=a===void 0?null:r("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:()=>{t(a)},type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=a,e[3]=o):o=e[3];let d;return e[4]!==o?(d=r("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=d):d=e[5],d},rt=i=>{const e=q(13),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t?(s=r(Me,{entry:t}),e[2]=t,e[3]=s):s=e[3];let f;e[4]!==t.traceId||e[5]!==o?(f=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=f):f=e[6];let l;return e[7]!==a||e[8]!==n||e[9]!==c||e[10]!==s||e[11]!==f?(l=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-row",ref:n,role:"row",style:c,children:[s,f]}),e[7]=a,e[8]=n,e[9]=c,e[10]=s,e[11]=f,e[12]=l):l=e[12],l},ce=i=>i.length===0?"—":i.join(", "),st=i=>{const e=q(41),{entry:t,index:a,measureRef:n,onOpenTrace:o,start:d}=i,p=`translateY(${String(d)}px)`;let m;e[0]!==p?(m={...be,transform:p},e[0]=p,e[1]=m):m=e[1];const c=m;let s;e[2]!==t.ts?(s=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=s):s=e[3];let f;e[4]!==s?(f=r("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:s}),e[4]=s,e[5]=f):f=e[5];const l=tt[t.outcome];let u;e[6]!==t.outcome||e[7]!==l?(u=r("span",{className:"w-16 shrink-0",role:"gridcell",children:r(he,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=u):u=e[8];let h;e[9]!==t.functionPath?(h=r("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=h):h=e[10];const v=t.shardKey??"—";let b;e[11]!==v?(b=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:v}),e[11]=v,e[12]=b):b=e[12];const y=t.userId??"—";let w;e[13]!==y?(w=r("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:y}),e[13]=y,e[14]=w):w=e[14];let x;e[15]!==t.durationMs?(x=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=x):x=e[16];const T=`${String(x)}ms`;let R;e[17]!==T?(R=r("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:T}),e[17]=T,e[18]=R):R=e[18];let N;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(N=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ce(t.tablesRead)} · w:${ce(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=N):N=e[23];let L;e[24]!==N?(L=r("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:N}),e[24]=N,e[25]=L):L=e[25];let S;e[26]!==t.traceId||e[27]!==o?(S=r(xe,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=S):S=e[28];let g;return e[29]!==a||e[30]!==n||e[31]!==c||e[32]!==w||e[33]!==R||e[34]!==L||e[35]!==S||e[36]!==f||e[37]!==u||e[38]!==h||e[39]!==b?(g=E("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":a,"data-testid":"lg-req-row",ref:n,role:"row",style:c,children:[f,u,h,b,w,R,L,S]}),e[29]=a,e[30]=n,e[31]=c,e[32]=w,e[33]=R,e[34]=L,e[35]=S,e[36]=f,e[37]=u,e[38]=h,e[39]=b,e[40]=g):g=e[40],g},de=i=>{const{entries:e}=i??{};return Array.isArray(e)?e:[]},lt=i=>{const e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},ot={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},at=(i,e)=>{const t=e.search.trim().toLowerCase(),a=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-ot[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||a!==""&&!(o.functionPath??"").toLowerCase().includes(a)?!1:t===""||o.message.toLowerCase().includes(t)||fe(o.fields).toLowerCase().includes(t))},nt="—",it=i=>{const e=new Map,t=new Map;for(const o of i){e.set(o.level,(e.get(o.level)??0)+1);const d=o.functionPath??nt;t.set(d,(t.get(d)??0)+1)}const a=re.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:a,byPath:n,total:i.length}},Wt=({initialShardKey:i})=>{const e=Q(),[t,a]=F("requests"),{queryShardKey:n,setShardKey:o,shardKey:d}=Ie(i),[p,m]=F(""),[c,s]=F(()=>new Set),[f,l]=F(""),[u,h]=F("all"),[v,b]=F(!1),[y,w]=F(""),[x,T]=F(""),[R,N]=F(""),[L,S]=F("all"),g=lt({functionPathPrefix:y,outcome:L,tableTouched:R,userId:x}),C=le(oe.getRequestLog,g,{enabled:t==="requests",live:!0,shardKey:n}),k=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),P=t==="requests"?C:k,{error:O,errorSource:_,isLoading:A,liveError:z}=P,M=Te(n),U=de(k.data),$=de(C.data);me(()=>{P.data!==void 0&&Re(n)},[P.data,n]);const K=at(U,{levels:c,now:Date.now(),path:f,range:u,search:p}),G=it(K),J=t==="requests"?$.length:K.length,X=t==="errors"&&v,W=Ne(()=>O!==null?"error":J===0?A?X?"summary":"list":"empty":X?"summary":"list",[J,A,O,X]),se=ue(null),Y=Ce({count:J,estimateSize:()=>Ze,getScrollElement:()=>se.current,initialRect:{height:te,width:800},observeElementRect:(I,Z)=>ke(I,Z,te),overscan:8}),ye=Y.getVirtualItems(),we={height:Y.getTotalSize(),position:"relative",width:"100%"};return E("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[r(Xe,{liveError:z,onShardKeyChange:o,onShowArchive:()=>{a("archive"),b(!1)},onShowErrors:()=>{a("errors"),b(!1)},onShowRequests:()=>{a("requests"),b(!1)},shardKey:d,view:t}),t==="errors"&&r(He,{levelFilter:c,onLogPathChange:I=>{l(I.target.value)},onSearchChange:I=>{m(I.target.value)},onTimeRangeChange:I=>{h(I.target.value)},onToggleLevel:I=>{s(Z=>{const j=new Set(Z);return j.has(I)?j.delete(I):j.add(I),j})},onToggleSummary:()=>{b(I=>!I)},pathFilter:f,search:p,showSummary:v,timeRange:u}),t==="requests"&&r(We,{onOutcomeChange:I=>{S(I.target.value)},onPathChange:I=>{w(I.target.value)},onTableChange:I=>{N(I.target.value)},onUserChange:I=>{T(I.target.value)},outcomeFilter:L,pathPrefix:y,tableFilter:R,userIdFilter:x}),t==="archive"?r(ze,{shardKey:n}):E($e,{children:[W==="error"&&r(Se,{error:_,testId:"lg-error"}),W==="empty"&&r(ee,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),W==="summary"&&r(Ye,{summary:G}),W==="list"&&r("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:se,style:et,children:r("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:we,children:ye.map(I=>t==="requests"?r(st,{entry:$[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key):r(rt,{entry:K[I.index],index:I.index,measureRef:Y.measureElement,onOpenTrace:M,start:I.start},I.key))})})]})]})};export{Wt as LogsPanel,at as filterLogs,it as summarizeLogs};
@@ -0,0 +1,2 @@
1
+ import{E as se}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as oe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as g}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ie}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as pe}from"react/compiler-runtime";import{useLunora as fe}from"@lunora/react";import{useState as F}from"react";import{u as xe}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useAutoRefresh as be}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...o}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...o})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],v=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const o=e.trim().toLowerCase();return o===""?r:r.filter(i=>`${i.subject} ${v(i.to)} ${v(i.cc)}`.toLowerCase().includes(o))},Se=(r,e)=>{if(r.length!==0)return r.find(o=>o.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(36),{limit:o}=r,i=fe();let p;e[0]!==o?(p={limit:o},e[0]=o,e[1]=p):p=e[1];const{data:P,error:N,errorSource:w,isLoading:b,poll:R,refetch:m}=xe(J.getCapturedMail,p),[y,f]=F(null),[O,C]=F(null),[s,h]=F("html"),[x,H]=F(""),a=P?.entries??[],u=N??y,B=N===null?y:w;let S;e[2]!==i||e[3]!==m?(S=async()=>{f(null);try{await i.query(Te,{},X("")),C(null),m()}catch(d){f(Z(d))}},e[2]=i,e[3]=m,e[4]=S):S=e[4];const D=S;let T;e[5]!==i||e[6]!==m?(T=async()=>{f(null);try{await i.query(ke,{},X("")),m()}catch(d){f(Z(d))}},e[5]=i,e[6]=m,e[7]=T):T=e[7];const q=T;be(R,!0);let k;e[8]!==D?(k=()=>{ee(D())},e[8]=D,e[9]=k):k=e[9];const U=k;let A;e[10]!==q?(A=()=>{ee(q())},e[10]=q,e[11]=A):A=e[11];const W=A;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=d=>{H(d.currentTarget.value)},e[12]=E):E=e[12];const K=E;let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=d=>{const{id:c}=d.currentTarget.dataset;c!==void 0&&C(c)},e[13]=L):L=e[13];const Q=L;let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=d=>{const c=d.currentTarget.dataset.tab;(c==="headers"||c==="html"||c==="text")&&h(c)},e[14]=_):_=e[14];const V=_,M=Ce(a,x),I=Se(M,O),l=ye(I);let j;e[15]!==l?(j=()=>{l!==void 0&&he(l)},e[15]=l,e[16]=j):j=e[16];const Y=j;let $;e[17]!==l?($=()=>{l!==void 0&&"window"in globalThis&&globalThis.window.open(l,"_blank","noopener")},e[17]=l,e[18]=$):$=e[18];const G=$;let z;return e[19]!==a||e[20]!==u||e[21]!==B||e[22]!==x||e[23]!==b||e[24]!==l||e[25]!==U||e[26]!==Y||e[27]!==K||e[28]!==G||e[29]!==Q||e[30]!==V||e[31]!==W||e[32]!==I||e[33]!==s||e[34]!==M?(z={entries:a,error:u,errorSource:B,filter:x,isLoading:b,link:l,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:I,tab:s,visible:M},e[19]=a,e[20]=u,e[21]=B,e[22]=x,e[23]=b,e[24]=l,e[25]=U,e[26]=Y,e[27]=K,e[28]=G,e[29]=Q,e[30]=V,e[31]=W,e[32]=I,e[33]=s,e[34]=M,e[35]=z):z=e[35],z},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,Le=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:o,error:i,errorSource:p,filter:P,isLoading:N,link:w,onClear:b,onCopyLink:R,onFilterChange:m,onOpenLink:y,onSelectMessage:f,onSelectTab:O,onSendTest:C,selected:s,tab:h,visible:x}=Ae({limit:r}),H=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(g,{"data-testid":"mail-send-test",onClick:C,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(g,{"data-testid":"mail-clear",disabled:o.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),o.length>0&&t(oe,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:o.length})})]}),i!==null&&t(se,{error:p,testId:"mail-error"}),i===null&&!N&&o.length===0&&t(ie,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),o.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:m,placeholder:e("Filter messages"),type:"search",value:P}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:x.map(a=>{const u=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":a.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:v(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:v(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(g,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:R,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(g,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:y,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(g,{"aria-selected":h===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:O,role:"tab",size:"sm",type:"button",variant:h===a?"secondary":"ghost",children:H(a)},a))}),n("div",{className:"min-h-[12rem]",children:[h==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:Le(s.html),title:e("Email preview")})),h==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),h==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,u])=>`${a}: ${u}`).join(`
2
+ `)}))]})]})]})]})};export{Qe as MailPanel};
@@ -0,0 +1 @@
1
+ import{useLunora as ht}from"@lunora/react";import{useState as pe,useRef as Je,useEffect as et,useMemo as gt}from"react";import{L as pt}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as bt}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as vt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as xe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.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 qt,c as Tt}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _t,l as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as Le}from"react/compiler-runtime";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as Ze}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as he,a as ge,b as Pe,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as oe,T as ot,c as de,a as ct,d as dt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as mt}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as n,jsx as t,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as It,computeLatencyPercentiles as Dt,enrichQueryStats as $t,shardsToAggregate as At}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as me}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as rt,c as Lt,h as Et}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as st,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as zt,LineChart as Ot,Line as Kt}from"recharts";import{E as Bt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Pt}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,a)=>`${i}:${e}:${kt(a??{})}`,ft=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ft(i,e),Gt=i=>ft(i.kind,i),We=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Jt=i=>Array.isArray(i?.series)?i.series:[],Wt="FUNCTION_NOT_FOUND",Xt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const a of i.series)e.set(ut(a.kind,a.name,a.attributes),a.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=Le(18),{name:a,onOpenTrace:s,traceId:r}=i,f=xe();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let o;e[1]!==r?(o=r.slice(0,8),e[1]=r,e[2]=o):o=e[2];const l=o;if(s===void 0){const d=`mt-instrument-trace-${a}`;let p;return e[3]!==l||e[4]!==d||e[5]!==r?(p=t("span",{className:"text-muted-foreground","data-testid":d,title:r,children:l}),e[3]=l,e[4]=d,e[5]=r,e[6]=p):p=e[6],p}const h=`mt-instrument-trace-${a}`;let v;e[7]!==s||e[8]!==r?(v=()=>{s(r)},e[7]=s,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==f||e[11]!==r?(w=f("Open the exemplar trace {trace}",{trace:r}),e[10]=f,e[11]=r,e[12]=w):w=e[12];let g;return e[13]!==l||e[14]!==h||e[15]!==v||e[16]!==w?(g=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":h,onClick:v,title:w,type:"button",children:l}),e[13]=l,e[14]=h,e[15]=v,e[16]=w,e[17]=g):g=e[17],g},er=i=>{const e=Le(105),{onOpenTrace:a,shardKey:s}=i,r=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let o;e[1]!==s?(o={live:!0,shardKey:s},e[1]=s,e[2]=o):o=e[2];const{data:l,error:h,errorSource:v}=je(Fe.getMetricSeries,f,o);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let g;e[4]!==s?(g={live:!0,shardKey:s},e[4]=s,e[5]=g):g=e[5];const{data:d}=je(Fe.getMetricHistory,w,g);let p,y,q,C,c,T,x,b,_,R,u,M,k;if(e[6]!==l||e[7]!==h||e[8]!==v||e[9]!==d||e[10]!==a||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{const F=Jt(l),z=Nt(v)===Wt;if(h!==null&&!z){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let P;e[27]!==m?(P=t("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=P):P=e[28];let Q;e[29]!==h||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:h}),e[29]=h,e[30]=r,e[31]=Q):Q=e[31];let U;e[32]!==Q?(U=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=U):U=e[33];let j;e[34]!==P||e[35]!==U?(j=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[P,U]}),e[34]=P,e[35]=U,e[36]=j):j=e[36],b=j;break e}if(F.length===0){b=null;break e}const O=Xt(d);let L;e[37]!==r?(L=m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=L):L=e[38];const H=L;c="flex flex-col gap-2",T="mt-instruments";let B;e[39]!==r?(B=r("Instruments"),e[39]=r,e[40]=B):B=e[40],e[41]!==B?(x=t("h3",{className:"text-sm font-semibold text-foreground",children:B}),e[41]=B,e[42]=x):x=e[42],C=he,k="overflow-hidden py-0",q=ge,M="px-0",y=ot,R="mt-instruments-table";let E;e[43]!==r?(E=r("name"),e[43]=r,e[44]=E):E=e[44];let K;e[45]!==E?(K=t(de,{children:E}),e[45]=E,e[46]=K):K=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let J;e[49]!==G?(J=t(de,{children:G}),e[49]=G,e[50]=J):J=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let Z;e[57]!==Y?(Z=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=Z):Z=e[58];let ee;e[59]!==r?(ee=r("range"),e[59]=r,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=t(de,{className:"text-right",children:ee}),e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==r?(re=r("trend"),e[63]=r,e[64]=re):re=e[64];let se;e[65]!==re?(se=t(de,{children:re}),e[65]=re,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ae;e[69]!==le?(ae=t(de,{children:le}),e[69]=le,e[70]=ae):ae=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let ne;e[73]!==ie?(ne=t(de,{children:ie}),e[73]=ie,e[74]=ne):ne=e[74],e[75]!==K||e[76]!==J||e[77]!==X||e[78]!==Z||e[79]!==te||e[80]!==se||e[81]!==ae||e[82]!==ne?(u=t(ct,{children:n(Ve,{children:[K,J,X,Z,te,se,ae,ne]})}),e[75]=K,e[76]=J,e[77]=X,e[78]=Z,e[79]=te,e[80]=se,e[81]=ae,e[82]=ne,e[83]=u):u=e[83],p=dt,_=F.map(m=>{const P=Rt(m.attributes),Q=ut(m.kind,m.name,m.attributes),j=(O.get(Q)??[]).map(ue=>Vt(m.kind,ue));return n(Ve,{"data-testid":`mt-instrument-${m.name}`,children:[t(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),t(oe,{children:t(Ze,{variant:Yt[m.kind],children:H(m.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:We(Gt(m))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${We(m.min)}–${We(m.max)}`}),t(oe,{children:j.length>=2?t(mt,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:j,testId:`mt-instrument-trend-${m.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Zt,{name:m.name,onOpenTrace:a,traceId:m.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:P,children:P===""?"—":P})]},Q)})}e[6]=l,e[7]=h,e[8]=v,e[9]=d,e[10]=a,e[11]=r,e[12]=p,e[13]=y,e[14]=q,e[15]=C,e[16]=c,e[17]=T,e[18]=x,e[19]=b,e[20]=_,e[21]=R,e[22]=u,e[23]=M,e[24]=k}else p=e[12],y=e[13],q=e[14],C=e[15],c=e[16],T=e[17],x=e[18],b=e[19],_=e[20],R=e[21],u=e[22],M=e[23],k=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let I;e[84]!==p||e[85]!==_?(I=t(p,{children:_}),e[84]=p,e[85]=_,e[86]=I):I=e[86];let D;e[87]!==y||e[88]!==I||e[89]!==R||e[90]!==u?(D=n(y,{"data-testid":R,children:[u,I]}),e[87]=y,e[88]=I,e[89]=R,e[90]=u,e[91]=D):D=e[91];let S;e[92]!==q||e[93]!==D||e[94]!==M?(S=t(q,{className:M,children:D}),e[92]=q,e[93]=D,e[94]=M,e[95]=S):S=e[95];let N;e[96]!==C||e[97]!==S||e[98]!==k?(N=t(C,{className:k,children:S}),e[96]=C,e[97]=S,e[98]=k,e[99]=N):N=e[99];let A;return e[100]!==c||e[101]!==T||e[102]!==x||e[103]!==N?(A=n("section",{className:c,"data-testid":T,children:[x,N]}),e[100]=c,e[101]=T,e[102]=x,e[103]=N,e[104]=A):A=e[104],A},tr=i=>{const e=Le(74),{aggregate:a,shardResults:s}=i,r=xe();let f;e[0]!==r?(f=r("Shards"),e[0]=r,e[1]=f):f=e[1];let o;e[2]!==a.failed||e[3]!==a.reachable||e[4]!==r?(o=a.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:a.failed,reachable:a.reachable}):r("{reachable} reachable",{reachable:a.reachable}),e[2]=a.failed,e[3]=a.reachable,e[4]=r,e[5]=o):o=e[5];let l;e[6]!==f||e[7]!==o?(l=t(me,{label:f,testId:"mt-agg-shards",value:o}),e[6]=f,e[7]=o,e[8]=l):l=e[8];let h;e[9]!==r?(h=r("Total requests"),e[9]=r,e[10]=h):h=e[10];let v;e[11]!==a.totalRequests||e[12]!==h?(v=t(me,{label:h,testId:"mt-agg-requests",value:a.totalRequests}),e[11]=a.totalRequests,e[12]=h,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let g;e[16]!==a.totalErrors||e[17]!==w?(g=t(me,{label:w,testId:"mt-agg-errors",value:a.totalErrors}),e[16]=a.totalErrors,e[17]=w,e[18]=g):g=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let p;e[21]!==a.totalDatabaseSize?(p=Xe(a.totalDatabaseSize),e[21]=a.totalDatabaseSize,e[22]=p):p=e[22];let y;e[23]!==d||e[24]!==p?(y=t(me,{label:d,testId:"mt-agg-db-size",value:p}),e[23]=d,e[24]=p,e[25]=y):y=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let C;e[28]!==a.hitRate||e[29]!==r?(C=a.hitRate===null?r("no cache configured"):`${(a.hitRate*100).toFixed(1)}%`,e[28]=a.hitRate,e[29]=r,e[30]=C):C=e[30];let c;e[31]!==q||e[32]!==C?(c=t(me,{label:q,testId:"mt-agg-cache",value:C}),e[31]=q,e[32]=C,e[33]=c):c=e[33];let T;e[34]!==y||e[35]!==c||e[36]!==l||e[37]!==v||e[38]!==g?(T=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[l,v,g,y,c]}),e[34]=y,e[35]=c,e[36]=l,e[37]=v,e[38]=g,e[39]=T):T=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=t(de,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let R;e[46]!==_?(R=t(de,{children:_}),e[46]=_,e[47]=R):R=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let M;e[50]!==u?(M=t(de,{children:u}),e[50]=u,e[51]=M):M=e[51];let k;e[52]!==r?(k=r("db size"),e[52]=r,e[53]=k):k=e[53];let I;e[54]!==k?(I=t(de,{children:k}),e[54]=k,e[55]=I):I=e[55];let D;e[56]!==b||e[57]!==R||e[58]!==M||e[59]!==I?(D=t(ct,{children:n(Ve,{children:[b,R,M,I]})}),e[56]=b,e[57]=R,e[58]=M,e[59]=I,e[60]=D):D=e[60];let S;if(e[61]!==s||e[62]!==r){let z;e[64]!==r?(z=O=>n(Ve,{"data-testid":`mt-agg-row-${O.shard}`,children:[t(oe,{children:O.shard}),O.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:O.error??r("unreachable")}):n(Ye,{children:[t(oe,{className:"tabular-nums",children:O.metrics.requests}),t(oe,{className:"tabular-nums",children:O.metrics.errors}),t(oe,{className:"tabular-nums",children:Xe(O.metrics.databaseSize)})]})]},O.shard),e[64]=r,e[65]=z):z=e[65],S=s.map(z),e[61]=s,e[62]=r,e[63]=S}else S=e[63];let N;e[66]!==S?(N=t(dt,{children:S}),e[66]=S,e[67]=N):N=e[67];let A;e[68]!==D||e[69]!==N?(A=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(ot,{"data-testid":"mt-agg-table",children:[D,N]})})}),e[68]=D,e[69]=N,e[70]=A):A=e[70];let F;return e[71]!==T||e[72]!==A?(F=n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[T,A]}),e[71]=T,e[72]=A,e[73]=F):F=e[73],F},rr=i=>{const e=Le(75),{currentDelta:a,errorRate:s,history:r,latencyPercentiles:f,metrics:o}=i,l=xe(),{cache:h}=o;let v;e[0]!==r||e[1]!==l?(v=r.length>=2?t(mt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=l,e[2]=v):v=e[2];let w;e[3]!==a||e[4]!==r.length||e[5]!==l?(w=r.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${a.toLocaleString()}`})," ",l("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples…")}),e[3]=a,e[4]=r.length,e[5]=l,e[6]=w):w=e[6];let g;e[7]!==l?(g=l("Requests"),e[7]=l,e[8]=g):g=e[8];let d;e[9]!==o.requests||e[10]!==v||e[11]!==w||e[12]!==g?(d=t(me,{chart:v,footer:w,label:g,testId:"mt-requests",value:o.requests}),e[9]=o.requests,e[10]=v,e[11]=w,e[12]=g,e[13]=d):d=e[13];let p;e[14]!==s||e[15]!==l?(p=l("{rate} error rate",{rate:s}),e[14]=s,e[15]=l,e[16]=p):p=e[16];let y;e[17]!==l?(y=l("Errors"),e[17]=l,e[18]=y):y=e[18];let q;e[19]!==s||e[20]!==o.errors?(q=n(Ye,{children:[o.errors," (",s,")"]}),e[19]=s,e[20]=o.errors,e[21]=q):q=e[21];let C;e[22]!==p||e[23]!==y||e[24]!==q?(C=t(me,{footer:p,label:y,testId:"mt-errors",value:q}),e[22]=p,e[23]=y,e[24]=q,e[25]=C):C=e[25];let c;e[26]!==f.p90?(c=f.p90>0?`P90 ${rt(f.p90)}`:void 0,e[26]=f.p90,e[27]=c):c=e[27];let T;e[28]!==l?(T=l("P95 latency"),e[28]=l,e[29]=T):T=e[29];let x;e[30]!==f.p95?(x=f.p95>0?rt(f.p95):"—",e[30]=f.p95,e[31]=x):x=e[31];let b;e[32]!==T||e[33]!==x||e[34]!==c?(b=t(me,{footer:c,label:T,testId:"mt-p95",value:x}),e[32]=T,e[33]=x,e[34]=c,e[35]=b):b=e[35];let _;e[36]!==h||e[37]!==l?(_=h?`${h.entries.toLocaleString()} ${l("cache entries")}`:void 0,e[36]=h,e[37]=l,e[38]=_):_=e[38];let R;e[39]!==l?(R=l("Database size"),e[39]=l,e[40]=R):R=e[40];let u;e[41]!==o.databaseSize?(u=Xe(o.databaseSize),e[41]=o.databaseSize,e[42]=u):u=e[42];let M;e[43]!==_||e[44]!==R||e[45]!==u?(M=t(me,{footer:_,label:R,testId:"mt-db-size",value:u}),e[43]=_,e[44]=R,e[45]=u,e[46]=M):M=e[46];let k;e[47]!==l?(k=l("Shard"),e[47]=l,e[48]=k):k=e[48];let I;e[49]!==o.shard||e[50]!==k?(I=t(me,{label:k,testId:"mt-shard",value:o.shard}),e[49]=o.shard,e[50]=k,e[51]=I):I=e[51];let D;e[52]!==l?(D=l("Uptime"),e[52]=l,e[53]=D):D=e[53];let S;e[54]!==o.uptimeMs?(S=Lt(o.uptimeMs),e[54]=o.uptimeMs,e[55]=S):S=e[55];let N;e[56]!==D||e[57]!==S?(N=t(me,{label:D,testId:"mt-uptime",value:S}),e[56]=D,e[57]=S,e[58]=N):N=e[58];let A;e[59]!==l?(A=l("Cache hit rate"),e[59]=l,e[60]=A):A=e[60];let F;e[61]!==h||e[62]!==l?(F=h?l("{rate} ({count} entries)",{count:h.entries,rate:Et(h.hits,h.misses)}):l("no cache configured"),e[61]=h,e[62]=l,e[63]=F):F=e[63];let z;e[64]!==A||e[65]!==F?(z=t(me,{label:A,testId:"mt-cache",value:F}),e[64]=A,e[65]=F,e[66]=z):z=e[66];let O;return e[67]!==b||e[68]!==M||e[69]!==I||e[70]!==N||e[71]!==z||e[72]!==d||e[73]!==C?(O=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,C,b,M,I,N,z]}),e[67]=b,e[68]=M,e[69]=I,e[70]=N,e[71]=z,e[72]=d,e[73]=C,e[74]=O):O=e[74],O},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Ee=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(),sr=i=>{const e=Le(3),{level:a}=i;if(a==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(Ze,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(a==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=s):s=e[2],s},lr=(i,e)=>{const a=[...i];return a.sort((s,r)=>{switch(e){case"avgTime":return r.avgDurationMs-s.avgDurationMs;case"execCount":return r.execCount-s.execCount;case"rowsRead":return r.rowsRead-s.rowsRead;default:return r.totalDurationMs-s.totalDurationMs}}),a},ar=i=>{const e=Le(161),{queryStats:a}=i,s=xe(),[r,f]=pe("totalTime");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[l,h]=pe(o);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=k=>{k!==null&&f(k)},e[1]=v):v=e[1];const w=v;let g,d,p,y,q,C,c,T,x,b;if(e[2]!==l||e[3]!==a||e[4]!==r||e[5]!==s){p=Symbol.for("react.early_return_sentinel");e:{const k=lr(a,r);let I;e[16]!==a?(I=a.filter(ir),e[16]=a,e[17]=I):I=e[17];const D=I.length;let S;e[18]!==a?(S=a.filter(nr),e[18]=a,e[19]=S):S=e[19];const N=S.length;let A;e[20]!==a?(A=a.filter(or),e[20]=a,e[21]=A):A=e[21];const F=A.length;let z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z=$=>{h(ce=>{const V=new Set(ce);return V.has($)?V.delete($):V.add($),V})},e[22]=z):z=e[22];const O=z;if(a.length===0){let $;e[23]!==s?($=s("No query insights yet"),e[23]=s,e[24]=$):$=e[24];let ce;e[25]!==$?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:$}),e[25]=$,e[26]=ce):ce=e[26];let V;e[27]!==s?(V=s("Query insights appear once statements are executed against this shard."),e[27]=s,e[28]=V):V=e[28];let fe;e[29]!==V?(fe=t("p",{className:"mt-1 text-sm",children:V}),e[29]=V,e[30]=fe):fe=e[30];let Be;e[31]!==ce||e[32]!==fe?(Be=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[ce,fe]})})}),e[31]=ce,e[32]=fe,e[33]=Be):Be=e[33],p=Be;break e}c="space-y-4",T="qi-root";let L;e[34]!==s?(L=s("Critical queries"),e[34]=s,e[35]=L):L=e[35];let H;e[36]!==L?(H=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=H):H=e[37];let B;e[38]!==D?(B=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=B):B=e[39];let E;e[40]!==s?(E=s(">100ms avg execution"),e[40]=s,e[41]=E):E=e[41];let K;e[42]!==E?(K=t("p",{className:"text-xs text-muted-foreground",children:E}),e[42]=E,e[43]=K):K=e[43];let G;e[44]!==B||e[45]!==K?(G=n(ge,{children:[B,K]}),e[44]=B,e[45]=K,e[46]=G):G=e[46];let J;e[47]!==H||e[48]!==G?(J=n(he,{children:[H,G]}),e[47]=H,e[48]=G,e[49]=J):J=e[49];let W;e[50]!==s?(W=s("Moderate queries"),e[50]=s,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==N?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:N}),e[54]=N,e[55]=Y):Y=e[55];let Z;e[56]!==s?(Z=s("50–100ms avg execution"),e[56]=s,e[57]=Z):Z=e[57];let ee;e[58]!==Z?(ee=t("p",{className:"text-xs text-muted-foreground",children:Z}),e[58]=Z,e[59]=ee):ee=e[59];let te;e[60]!==Y||e[61]!==ee?(te=n(ge,{children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==X||e[64]!==te?(re=n(he,{children:[X,te]}),e[63]=X,e[64]=te,e[65]=re):re=e[65];let se;e[66]!==s?(se=s("Fast queries"),e[66]=s,e[67]=se):se=e[67];let le;e[68]!==se?(le=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ae;e[70]!==F?(ae=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:F}),e[70]=F,e[71]=ae):ae=e[71];let ie;e[72]!==s?(ie=s("<50ms avg execution"),e[72]=s,e[73]=ie):ie=e[73];let ne;e[74]!==ie?(ne=t("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=ne):ne=e[75];let m;e[76]!==ae||e[77]!==ne?(m=n(ge,{children:[ae,ne]}),e[76]=ae,e[77]=ne,e[78]=m):m=e[78];let P;e[79]!==le||e[80]!==m?(P=n(he,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=P):P=e[81],e[82]!==J||e[83]!==re||e[84]!==P?(x=n("div",{className:"grid gap-4 md:grid-cols-3",children:[J,re,P]}),e[82]=J,e[83]=re,e[84]=P,e[85]=x):x=e[85];let Q;e[86]!==s?(Q=s("Query leaderboard"),e[86]=s,e[87]=Q):Q=e[87];let U;e[88]!==Q?(U=t("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=U):U=e[89];let j;e[90]!==r||e[91]!==s?(j=s("Slow queries sorted by {sortField}",{sortField:s(r)}),e[90]=r,e[91]=s,e[92]=j):j=e[92];let ue;e[93]!==j?(ue=t("p",{className:"text-sm text-muted-foreground",children:j}),e[93]=j,e[94]=ue):ue=e[94];let be;e[95]!==U||e[96]!==ue?(be=n("div",{children:[U,ue]}),e[95]=U,e[96]=ue,e[97]=be):be=e[97];let ve;e[98]!==s?(ve=s("Sort by"),e[98]=s,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=t("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==s?(Ne=s("Sort queries by"),e[102]=s,e[103]=Ne):Ne=e[103];let ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(ze=t(Qt,{}),e[104]=ze):ze=e[104];let Se;e[105]!==Ne?(Se=t(Ht,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:ze}),e[105]=Ne,e[106]=Se):Se=e[106];let we;e[107]!==s?(we=s("Total time"),e[107]=s,e[108]=we):we=e[108];let qe;e[109]!==we?(qe=t(He,{value:"totalTime",children:we}),e[109]=we,e[110]=qe):qe=e[110];let Te;e[111]!==s?(Te=s("Avg time"),e[111]=s,e[112]=Te):Te=e[112];let _e;e[113]!==Te?(_e=t(He,{value:"avgTime",children:Te}),e[113]=Te,e[114]=_e):_e=e[114];let Ce;e[115]!==s?(Ce=s("Execution count"),e[115]=s,e[116]=Ce):Ce=e[116];let Re;e[117]!==Ce?(Re=t(He,{value:"execCount",children:Ce}),e[117]=Ce,e[118]=Re):Re=e[118];let Me;e[119]!==s?(Me=s("Rows read"),e[119]=s,e[120]=Me):Me=e[120];let ke;e[121]!==Me?(ke=t(He,{value:"rowsRead",children:Me}),e[121]=Me,e[122]=ke):ke=e[122];let Ie;e[123]!==qe||e[124]!==_e||e[125]!==Re||e[126]!==ke?(Ie=n(Ut,{children:[qe,_e,Re,ke]}),e[123]=qe,e[124]=_e,e[125]=Re,e[126]=ke,e[127]=Ie):Ie=e[127];let De;e[128]!==r||e[129]!==Se||e[130]!==Ie?(De=n(jt,{onValueChange:w,value:r,children:[Se,Ie]}),e[128]=r,e[129]=Se,e[130]=Ie,e[131]=De):De=e[131];let $e;e[132]!==ye||e[133]!==De?($e=n("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=$e):$e=e[134],e[135]!==be||e[136]!==$e?(b=n("div",{className:"flex items-center justify-between",children:[be,$e]}),e[135]=be,e[136]=$e,e[137]=b):b=e[137],d=he;let Ae;e[138]!==s?(Ae=s("Statements"),e[138]=s,e[139]=Ae):Ae=e[139];let Oe;e[140]!==Ae?(Oe=t(Qe,{children:Ae}),e[140]=Ae,e[141]=Oe):Oe=e[141],C=n(Pe,{children:[Oe,t(Mt,{children:s("{count} tracked statements",{count:k.length})})]}),g=ge,y="space-y-2";let Ke;e[142]!==l||e[143]!==s?(Ke=$=>{const ce=$.normalizedSql,V=l.has(ce),fe=Ge($.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":V,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{O(ce)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(sr,{level:fe}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:$.normalizedSql})]}),n("div",{className:"flex shrink-0 items-center gap-4",children:[n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("avg")})]}),$.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ue($.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:s("calls")})]})]})]}),V&&n("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[n("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:s("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:$.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[$.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:s("p50")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsWritten)})]})]})]})]},ce)},e[142]=l,e[143]=s,e[144]=Ke):Ke=e[144],q=k.map(Ke)}e[2]=l,e[3]=a,e[4]=r,e[5]=s,e[6]=g,e[7]=d,e[8]=p,e[9]=y,e[10]=q,e[11]=C,e[12]=c,e[13]=T,e[14]=x,e[15]=b}else g=e[6],d=e[7],p=e[8],y=e[9],q=e[10],C=e[11],c=e[12],T=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==y||e[146]!==q?(_=t("div",{className:y,children:q}),e[145]=y,e[146]=q,e[147]=_):_=e[147];let R;e[148]!==g||e[149]!==_?(R=t(g,{children:_}),e[148]=g,e[149]=_,e[150]=R):R=e[150];let u;e[151]!==d||e[152]!==R||e[153]!==C?(u=n(d,{children:[C,R]}),e[151]=d,e[152]=R,e[153]=C,e[154]=u):u=e[154];let M;return e[155]!==u||e[156]!==c||e[157]!==T||e[158]!==x||e[159]!==b?(M=n("div",{className:c,"data-testid":T,children:[x,b,u]}),e[155]=u,e[156]=c,e[157]=T,e[158]=x,e[159]=b,e[160]=M):M=e[160],M};function ir(i){return Ge(i.avgDurationMs)==="critical"}function nr(i){return Ge(i.avgDurationMs)==="warning"}function or(i){return Ge(i.avgDurationMs)==="good"}const cr=["1m","5m","15m","1h"],dr=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),mr=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:dr(e.bucketMs)})),ur=({shardKey:i=""})=>{const e=xe(),[a,s]=pe("15m"),f=je(Fe.getQueryInsights,{range:a},{live:!0,shardKey:i}).data,o=mr(f?.buckets??[]);return n("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cr.map(l=>t("button",{"aria-pressed":l===a,className:Pt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",l===a&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${l}`,onClick:()=>{s(l)},type:"button",children:l},l))}),f?.capped===!0&&t(Ze,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?t(Bt,{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.")}):n("div",{className:"grid gap-4 lg:grid-cols-2",children:[n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(st,{height:140,width:"100%",children:n(Ft,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(st,{height:140,width:"100%",children:n(Ot,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(ar,{queryStats:f?.entries??[]})]})},fr=Tt(Fe.getMetrics),hr=(i,e)=>i?e:"overview",Qr=({initialShardKey:i})=>{const e=ht(),a=xe(),{queryShardKey:s,setShardKey:r,shardKey:f}=vt(i),[o,l]=pe("overview"),[h,v]=pe([]),w=Je(null),g=Je(null),d=Je(!0);et(()=>(d.current=!0,()=>{d.current=!1}),[]);const p=bt(s),{data:y,error:q,liveError:C}=je(Fe.getMetrics,{},{live:!0,shardKey:s}),c=y??null;et(()=>{if(y===void 0)return;_t(s);const L=y,H=w.current,B=g.current!==null&&g.current!==L.shard;if(g.current=L.shard,w.current=L.requests,B){v([]);return}H!==null&&L.requests>=H&&v(E=>[...E,L.requests-H].slice(-30))},[y,s]);const[T,x]=pe(null),[b,_]=pe(!1),R=async()=>{_(!0);const L=f,H=At(L,Ct());try{const B=await Promise.all(H.map(async E=>{try{const K=await e.query(fr,{},wt(E));return{error:null,metrics:K,shard:E===""?K.shard:E}}catch(K){return{error:qt(K),metrics:null,shard:E===""?"__root__":E}}}));d.current&&x({results:B,shard:L})}finally{d.current&&_(!1)}},u=T?.shard===f?T.results:null,M=u===null?null:It(u),k=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,I=h.length>0?h.at(-1):0,D=c?Dt(c):{p90:0,p95:0},S=gt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[c]),N=hr(S!==void 0,o),A=()=>{St(R())},F=()=>{x(null)},z=()=>{l("overview")},O=()=>{l("query-insights")};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(xt,{onChange:r,testId:"mt-shard-input",value:f}),t(pt,{message:C,prefix:"mt"}),t(tt,{"data-testid":"mt-aggregate",disabled:b,onClick:A,size:"sm",type:"button",variant:"secondary",children:a(b?"Aggregating…":"All shards")}),u!==null&&t(tt,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:a("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:a("Open in Cloudflare")})]}),q!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),S!==void 0&&n("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:z,type:"button",children:a("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:O,type:"button",children:[a("Query insights"),S.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:S.length})]})]}),N==="query-insights"&&S!==void 0&&t(ur,{shardKey:s}),N==="overview"&&c!==null&&t(rr,{currentDelta:I,errorRate:k,history:h,latencyPercentiles:D,metrics:c}),N==="overview"&&c===null&&null,N==="overview"&&t(er,{onOpenTrace:p,shardKey:s}),N==="overview"&&M!==null&&u!==null&&t(tr,{aggregate:M,shardResults:u})]})};export{Qr as MetricsPanel};
@@ -0,0 +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-D-ftqyo-.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-I1uILsUP.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ee}from"../packem_shared/internal-BXEjuLPN.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};