@lunora/studio 1.0.0-alpha.38 → 1.0.0-alpha.381

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 (491) hide show
  1. package/LICENSE.md +201 -104
  2. package/README.md +7 -7
  3. package/dist/index.d.mts +1647 -0
  4. package/dist/index.d.ts +1039 -809
  5. package/dist/index.mjs +1 -0
  6. package/dist/mount.d.mts +23 -0
  7. package/dist/mount.d.ts +13 -11
  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 +10 -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 +26 -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-knowledge.mjs +1 -0
  31. package/dist/packem_chunks/ai-usage-panel.mjs +1 -0
  32. package/dist/packem_chunks/analytics-panel.mjs +1 -0
  33. package/dist/packem_chunks/architecture-panel.mjs +1 -0
  34. package/dist/packem_chunks/assistant-panel.mjs +3 -0
  35. package/dist/packem_chunks/auth-audit-panel.mjs +1 -0
  36. package/dist/packem_chunks/auth-config-panel.mjs +1 -0
  37. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -0
  38. package/dist/packem_chunks/containers-panel.mjs +1 -0
  39. package/dist/packem_chunks/dashboards-panel.mjs +1 -0
  40. package/dist/packem_chunks/evals-panel.mjs +1 -0
  41. package/dist/packem_chunks/fanout-panel.mjs +1 -0
  42. package/dist/packem_chunks/flags-panel.mjs +1 -0
  43. package/dist/packem_chunks/issues-panel.mjs +1 -0
  44. package/dist/packem_chunks/kv-browser.mjs +1 -0
  45. package/dist/packem_chunks/log-drains-panel.mjs +4 -0
  46. package/dist/packem_chunks/migrations-route.mjs +1 -0
  47. package/dist/packem_chunks/organizations-panel.mjs +1 -0
  48. package/dist/packem_chunks/payments-panel.mjs +1 -0
  49. package/dist/packem_chunks/permissions-panel.mjs +1 -0
  50. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -0
  51. package/dist/packem_chunks/queues-panel.mjs +1 -0
  52. package/dist/packem_chunks/reactors-panel.mjs +1 -0
  53. package/dist/packem_chunks/rls-panel.mjs +1 -0
  54. package/dist/packem_chunks/schedule-panel.mjs +1 -0
  55. package/dist/packem_chunks/storage-rules-panel.mjs +1 -0
  56. package/dist/packem_chunks/subscriptions-panel.mjs +1 -0
  57. package/dist/packem_chunks/sync-client-panel.mjs +1 -0
  58. package/dist/packem_chunks/theme-indicator.mjs +1 -0
  59. package/dist/packem_chunks/traces-panel.mjs +1 -0
  60. package/dist/packem_chunks/users-panel.mjs +1 -0
  61. package/dist/packem_chunks/vector-browser.mjs +1 -0
  62. package/dist/packem_chunks/workflows-panel.mjs +1 -0
  63. package/dist/packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs +1 -0
  64. package/dist/packem_shared/ApiDocsPanel-sEDqUNQq.mjs +2 -0
  65. package/dist/packem_shared/ApiReferencePanel-CQxU1Ocx.mjs +1 -0
  66. package/dist/packem_shared/CommandPalette-BZCHLpst.mjs +1 -0
  67. package/dist/packem_shared/ConfirmButton-CIXYF6Mg.mjs +1 -0
  68. package/dist/packem_shared/ConnectionBadge-BfcoN-VE.mjs +1 -0
  69. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs +1 -0
  70. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs +1 -0
  71. package/dist/packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs +1 -0
  72. package/dist/packem_shared/DataBrowser-CkVOu6py.mjs +4 -0
  73. package/dist/packem_shared/DataFilters--ocFTVT2.mjs +1 -0
  74. package/dist/packem_shared/ErrorBoundary-BWNF98VF.mjs +1 -0
  75. package/dist/packem_shared/GlobalDataBrowser-l2ECwXCm.mjs +1 -0
  76. package/dist/packem_shared/HomePanel-c7as4tvl.mjs +1 -0
  77. package/dist/packem_shared/MigrationsPanel-BQol4Un1.mjs +1 -0
  78. package/dist/packem_shared/OpenRpcReferencePanel-BFDG91tn.mjs +1 -0
  79. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs +1 -0
  80. package/dist/packem_shared/ScheduledJobs-Du8ZGL7v.mjs +1 -0
  81. package/dist/packem_shared/ShardInput-CoySruKZ.mjs +1 -0
  82. package/dist/packem_shared/Studio-BmbkaUrx.mjs +1 -0
  83. package/dist/packem_shared/StudioApp-CsyDnrg2.mjs +1 -0
  84. package/dist/packem_shared/StudioI18nProvider-CGXCPnQn.mjs +1 -0
  85. package/dist/packem_shared/advisor-view-gtf_DhUU.mjs +5 -0
  86. package/dist/packem_shared/aggregateMetrics-DKFJc-o5.mjs +1 -0
  87. package/dist/packem_shared/alert-PB5W11MM.mjs +1 -0
  88. package/dist/packem_shared/app.d-DpxFQ0qO.d.mts +374 -0
  89. package/dist/packem_shared/app.d-DpxFQ0qO.d.ts +374 -0
  90. package/dist/packem_shared/assistant-provider-Dw0roZh3.mjs +1 -0
  91. package/dist/packem_shared/assistant-reason-D6EwMCxT.mjs +1 -0
  92. package/dist/packem_shared/auth-pager-DW77WeZw.mjs +1 -0
  93. package/dist/packem_shared/badge-r_5B4LHP.mjs +1 -0
  94. package/dist/packem_shared/bar-chart-BCsEIQoQ.mjs +6 -0
  95. package/dist/packem_shared/browser-storage-BH1MxLZs.mjs +1 -0
  96. package/dist/packem_shared/button-q0UYSmrn.mjs +1 -0
  97. package/dist/packem_shared/card-By2O8ULa.mjs +1 -0
  98. package/dist/packem_shared/cf-links-BPy1pJRO.mjs +1 -0
  99. package/dist/packem_shared/checkbox-CnS9cyCz.mjs +1 -0
  100. package/dist/packem_shared/control-button-BOZ5K-FC.mjs +1 -0
  101. package/dist/packem_shared/data-grid-B5m1OosL.mjs +1 -0
  102. package/dist/packem_shared/data-view-params-C-_G-biH.mjs +1 -0
  103. package/dist/packem_shared/diagram-export-panel-Vdt-DZnO.mjs +2 -0
  104. package/dist/packem_shared/dropdown-menu-jLZenfWH.mjs +2 -0
  105. package/dist/packem_shared/empty-state-D7jEML_T.mjs +1 -0
  106. package/dist/packem_shared/error-alert-3AR_-s_s.mjs +6 -0
  107. package/dist/packem_shared/grid-features-Drvfswwy.mjs +6 -0
  108. package/dist/packem_shared/grid-pagination-DY2erU65.mjs +1 -0
  109. package/dist/packem_shared/home-panel-TpxiaHgB.mjs +3 -0
  110. package/dist/packem_shared/input-CXhxesPC.mjs +1 -0
  111. package/dist/packem_shared/internal-hIuTpSbx.mjs +2 -0
  112. package/dist/packem_shared/label-DKFzyHq6.mjs +1 -0
  113. package/dist/packem_shared/live-status-D1GasNsH.mjs +1 -0
  114. package/dist/packem_shared/log-fields-CV-9O0nh.mjs +8 -0
  115. package/dist/packem_shared/log-line-CYJQf6P-.mjs +1 -0
  116. package/dist/packem_shared/metrics-format-1sNGG47R.mjs +1 -0
  117. package/dist/packem_shared/modal-shell-CDztwLnv.mjs +1 -0
  118. package/dist/packem_shared/operation-console-provider-DoloEvon.mjs +1 -0
  119. package/dist/packem_shared/recording-client-z4CBi0y8.mjs +1 -0
  120. package/dist/packem_shared/reference-view-DENugPcj.mjs +13 -0
  121. package/dist/packem_shared/schema-diagram-CtVPhOGj.mjs +2 -0
  122. package/dist/packem_shared/scroll-area-CXCQH7VT.mjs +2 -0
  123. package/dist/packem_shared/select-DPyS18Vy.mjs +2 -0
  124. package/dist/packem_shared/shard-history-CaO3C4KQ.mjs +1 -0
  125. package/dist/packem_shared/shortcuts-B9gDaXmw.mjs +1 -0
  126. package/dist/packem_shared/skeleton-DX1gfixl.mjs +1 -0
  127. package/dist/packem_shared/sparkline-B_sPPO_8.mjs +1 -0
  128. package/dist/packem_shared/sql-result-table-DCwooMGW.mjs +1 -0
  129. package/dist/packem_shared/stat-card-BAv73QtB.mjs +1 -0
  130. package/dist/packem_shared/storage-tier-C2mKwYRj.mjs +1 -0
  131. package/dist/packem_shared/studio-DZlpp4Vx.mjs +2 -0
  132. package/dist/packem_shared/table-D0SBiDu-.mjs +2 -0
  133. package/dist/packem_shared/table-list-sidebar-Bfmg04MD.mjs +1 -0
  134. package/dist/packem_shared/textarea--40GKAyz.mjs +1 -0
  135. package/dist/packem_shared/trace-handoff-BV3EWqy_.mjs +1 -0
  136. package/dist/packem_shared/use-admin-query-CaOm4JS3.mjs +1 -0
  137. package/dist/packem_shared/use-admin-spec-CK7mk3Ui.mjs +1 -0
  138. package/dist/packem_shared/use-assistant-rpc-AKu8hvPm.mjs +1 -0
  139. package/dist/packem_shared/use-async-submit-D0r7-m2J.mjs +1 -0
  140. package/dist/packem_shared/use-auth-config-DameIc6y.mjs +1 -0
  141. package/dist/packem_shared/use-mirrored-ref-CVDf2z1M.mjs +1 -0
  142. package/dist/packem_shared/use-open-trace-BJKMJjeS.mjs +1 -0
  143. package/dist/packem_shared/use-shard-key-BsP3o5wT.mjs +1 -0
  144. package/dist/packem_shared/use-studio-client-DCA50tF2.mjs +1 -0
  145. package/dist/packem_shared/useDebounced-DVeQ5-oW.mjs +1 -0
  146. package/dist/packem_shared/utils-bhneXptQ.mjs +1 -0
  147. package/dist/packem_shared/virtual-rect-D_j7aLxX.mjs +1 -0
  148. package/dist/standalone/chunk-274SZA4F.js +1 -0
  149. package/dist/standalone/chunk-2DKLUTH2.js +1 -0
  150. package/dist/standalone/chunk-2KREOMPV.js +1 -0
  151. package/dist/standalone/chunk-2KTN53PK.js +1 -0
  152. package/dist/standalone/chunk-2NUCBQFU.js +1 -0
  153. package/dist/standalone/chunk-2VGEYQJ5.js +1 -0
  154. package/dist/standalone/chunk-337EJGCU.js +1 -0
  155. package/dist/standalone/chunk-3NYU3CCO.js +1 -0
  156. package/dist/standalone/chunk-3QNDJXLL.js +1 -0
  157. package/dist/standalone/chunk-4AG356VE.js +1 -0
  158. package/dist/standalone/chunk-4E6DQHFK.js +1 -0
  159. package/dist/standalone/chunk-4KPATTV6.js +1 -0
  160. package/dist/standalone/chunk-4SY2N2RS.js +1 -0
  161. package/dist/standalone/chunk-4TGALJHR.js +1 -0
  162. package/dist/standalone/chunk-4W7SB3SF.js +1 -0
  163. package/dist/standalone/chunk-4YEGXH2V.js +1 -0
  164. package/dist/standalone/chunk-5MIJ3KEK.js +1 -0
  165. package/dist/standalone/chunk-5NPU6VPX.js +1 -0
  166. package/dist/standalone/chunk-5PEAXTYQ.js +1 -0
  167. package/dist/standalone/chunk-5QK3ZHNZ.js +1 -0
  168. package/dist/standalone/chunk-66IUCD6W.js +1 -0
  169. package/dist/standalone/chunk-76D454G5.js +1 -0
  170. package/dist/standalone/chunk-7MQQPZQC.js +1 -0
  171. package/dist/standalone/chunk-7VZFX5O4.js +1 -0
  172. package/dist/standalone/chunk-7WGZSDRS.js +2 -0
  173. package/dist/standalone/chunk-A2LKDNNA.js +1 -0
  174. package/dist/standalone/chunk-A4F3YMBV.js +1 -0
  175. package/dist/standalone/chunk-A6TVTNKO.js +1 -0
  176. package/dist/standalone/chunk-ADABTCDI.js +1 -0
  177. package/dist/standalone/chunk-AE3ABYCE.js +1 -0
  178. package/dist/standalone/chunk-AFLNQEZ5.js +1 -0
  179. package/dist/standalone/chunk-AQ6LY5RO.js +14 -0
  180. package/dist/standalone/chunk-AWFFXR6S.js +1 -0
  181. package/dist/standalone/chunk-AY4DPAPO.js +1 -0
  182. package/dist/standalone/chunk-CL3JOU6F.js +1 -0
  183. package/dist/standalone/chunk-CVSIFPI5.js +1 -0
  184. package/dist/standalone/chunk-D2LGOQ32.js +1 -0
  185. package/dist/standalone/chunk-DA2CAFXI.js +1 -0
  186. package/dist/standalone/chunk-DELDS72W.js +1 -0
  187. package/dist/standalone/chunk-DJPK4PZV.js +1 -0
  188. package/dist/standalone/chunk-DRHZZ7IN.js +1 -0
  189. package/dist/standalone/chunk-DWKKQ75U.js +59 -0
  190. package/dist/standalone/chunk-EDL46BPM.js +1 -0
  191. package/dist/standalone/chunk-ELWBGGS7.js +2 -0
  192. package/dist/standalone/chunk-EOFWXI3T.js +1 -0
  193. package/dist/standalone/chunk-EVUVQB4Q.js +1 -0
  194. package/dist/standalone/chunk-F2DVDJV6.js +1 -0
  195. package/dist/standalone/chunk-FKOAI6VV.js +1 -0
  196. package/dist/standalone/chunk-FPODRWDZ.js +1 -0
  197. package/dist/standalone/chunk-FWM5Z6CH.js +1 -0
  198. package/dist/standalone/chunk-GCYQOJYI.js +1 -0
  199. package/dist/standalone/chunk-GDAZWXQW.js +1 -0
  200. package/dist/standalone/chunk-H6VTIXVB.js +1 -0
  201. package/dist/standalone/chunk-HBEZGCPB.js +1 -0
  202. package/dist/standalone/chunk-I626YY7T.js +4 -0
  203. package/dist/standalone/chunk-I7PUGF3D.js +1 -0
  204. package/dist/standalone/chunk-IMM6HPPD.js +1 -0
  205. package/dist/standalone/chunk-IQ5CIBXJ.js +1 -0
  206. package/dist/standalone/chunk-JELTLAEP.js +8 -0
  207. package/dist/standalone/chunk-JNWK5MJC.js +1 -0
  208. package/dist/standalone/chunk-JQBZDS6X.js +6 -0
  209. package/dist/standalone/chunk-JXUU3BD2.js +1 -0
  210. package/dist/standalone/chunk-K7GU4AIX.js +1 -0
  211. package/dist/standalone/chunk-KQVY73EU.js +7 -0
  212. package/dist/standalone/chunk-KVQ2GMJR.js +1 -0
  213. package/dist/standalone/chunk-KXUK7CSR.js +1 -0
  214. package/dist/standalone/chunk-L27FKJTG.js +1 -0
  215. package/dist/standalone/chunk-LHQFTCOS.js +1 -0
  216. package/dist/standalone/chunk-LJLNIVUA.js +8 -0
  217. package/dist/standalone/chunk-LMCBMC2V.js +1 -0
  218. package/dist/standalone/chunk-LYNQHGQ4.js +1 -0
  219. package/dist/standalone/chunk-LYVYUTQY.js +1 -0
  220. package/dist/standalone/chunk-MGYRQPAY.js +1 -0
  221. package/dist/standalone/chunk-MHZNDDGI.js +1 -0
  222. package/dist/standalone/chunk-MICDQTTJ.js +1 -0
  223. package/dist/standalone/chunk-ML6YSDEQ.js +4 -0
  224. package/dist/standalone/chunk-MNXXIISC.js +1 -0
  225. package/dist/standalone/chunk-MTBY4GXM.js +1 -0
  226. package/dist/standalone/chunk-MULFKWTQ.js +1 -0
  227. package/dist/standalone/chunk-N7FOBAV3.js +1 -0
  228. package/dist/standalone/chunk-NDIEUO4N.js +1 -0
  229. package/dist/standalone/chunk-NPZG7XK5.js +1 -0
  230. package/dist/standalone/chunk-NQ727GVM.js +1 -0
  231. package/dist/standalone/chunk-NYLSD5LR.js +1 -0
  232. package/dist/standalone/chunk-O4SDDSDL.js +1 -0
  233. package/dist/standalone/chunk-O5QATFN3.js +159 -0
  234. package/dist/standalone/chunk-O65QTRXU.js +1 -0
  235. package/dist/standalone/chunk-ODEIAS3V.js +1 -0
  236. package/dist/standalone/chunk-OJO6ERJ4.js +1 -0
  237. package/dist/standalone/chunk-OOUGGYHQ.js +1 -0
  238. package/dist/standalone/chunk-OR4RO6V4.js +1 -0
  239. package/dist/standalone/chunk-OVPS52RO.js +3 -0
  240. package/dist/standalone/chunk-OWRWDDJT.js +1 -0
  241. package/dist/standalone/chunk-OZID3UYF.js +1 -0
  242. package/dist/standalone/chunk-PDBW6GTJ.js +1 -0
  243. package/dist/standalone/chunk-Q7KRCKCE.js +1 -0
  244. package/dist/standalone/chunk-QCG2G6IF.js +1 -0
  245. package/dist/standalone/chunk-QF743FSL.js +1 -0
  246. package/dist/standalone/chunk-QHVUXMRV.js +1 -0
  247. package/dist/standalone/chunk-QLZGKBOW.js +1 -0
  248. package/dist/standalone/chunk-QOK2UU3L.js +1 -0
  249. package/dist/standalone/chunk-R3RIZDUS.js +1 -0
  250. package/dist/standalone/chunk-R6NJ4ER6.js +1 -0
  251. package/dist/standalone/chunk-RAJ327CY.js +1 -0
  252. package/dist/standalone/chunk-RIAOZECW.js +1 -0
  253. package/dist/standalone/chunk-RK3HQKPW.js +1 -0
  254. package/dist/standalone/chunk-RPRNYCFT.js +1 -0
  255. package/dist/standalone/chunk-SADHW6WJ.js +5 -0
  256. package/dist/standalone/chunk-SBQT2ZSX.js +1 -0
  257. package/dist/standalone/chunk-SCTYLLJT.js +1 -0
  258. package/dist/standalone/chunk-T7UKRA6J.js +1 -0
  259. package/dist/standalone/chunk-UAXX2RXT.js +1 -0
  260. package/dist/standalone/chunk-UFFUDDK7.js +1 -0
  261. package/dist/standalone/chunk-UOFMFYZ7.js +6 -0
  262. package/dist/standalone/chunk-UUOEHNMP.js +31 -0
  263. package/dist/standalone/chunk-V4JKKAAZ.js +3 -0
  264. package/dist/standalone/chunk-VGKDC2OQ.js +1 -0
  265. package/dist/standalone/chunk-VJQP4ARP.js +33 -0
  266. package/dist/standalone/chunk-VTTS5L36.js +1 -0
  267. package/dist/standalone/chunk-W3WGVJNJ.js +1 -0
  268. package/dist/standalone/chunk-W7CLOQOU.js +1 -0
  269. package/dist/standalone/chunk-WDR3BJ2C.js +1 -0
  270. package/dist/standalone/chunk-WONKLAKW.js +3 -0
  271. package/dist/standalone/chunk-WU2ST74V.js +1 -0
  272. package/dist/standalone/chunk-WVURFBJS.js +1 -0
  273. package/dist/standalone/chunk-X474JV2D.js +1 -0
  274. package/dist/standalone/chunk-XBHRAFJA.js +1 -0
  275. package/dist/standalone/chunk-XEIJUQ4B.js +1 -0
  276. package/dist/standalone/chunk-XOLTLG4I.js +5 -0
  277. package/dist/standalone/chunk-XSFGXEYO.js +1 -0
  278. package/dist/standalone/{chunk-BJGBHGK3.js → chunk-Y2YLTUMD.js} +1 -1
  279. package/dist/standalone/chunk-Y6OVSHPH.js +1 -0
  280. package/dist/standalone/chunk-YL5ZAR3P.js +1 -0
  281. package/dist/standalone/chunk-YNCZVYCO.js +1 -0
  282. package/dist/standalone/chunk-YTLKHICM.js +1 -0
  283. package/dist/standalone/chunk-YYJGL32M.js +1 -0
  284. package/dist/standalone/chunk-Z4BLDRDD.js +10 -0
  285. package/dist/standalone/chunk-ZBLG4UAV.js +1 -0
  286. package/dist/standalone/chunk-ZHZHI6KX.js +1 -0
  287. package/dist/standalone/chunk-ZPQBVYNN.js +1 -0
  288. package/dist/standalone/chunk-ZPQFM3A7.js +1 -0
  289. package/dist/standalone/chunk-ZZ6ZCOD4.js +1 -0
  290. package/dist/standalone/chunk-ZZA6VQDG.js +1 -0
  291. package/dist/standalone/studio.js +9 -214
  292. package/dist/styles.css +2 -2
  293. package/package.json +28 -23
  294. package/dist/index.js +0 -41
  295. package/dist/mount.js +0 -27
  296. package/dist/packem_chunks/ApiTab.js +0 -251
  297. package/dist/packem_chunks/AuditPanel.js +0 -200
  298. package/dist/packem_chunks/ExportImportPanel.js +0 -198
  299. package/dist/packem_chunks/FileBrowser.js +0 -2932
  300. package/dist/packem_chunks/FunctionRunner.js +0 -343
  301. package/dist/packem_chunks/FunctionStatsPanel.js +0 -377
  302. package/dist/packem_chunks/HealthPanel.js +0 -648
  303. package/dist/packem_chunks/InsightsPanel.js +0 -462
  304. package/dist/packem_chunks/LogsPanel.js +0 -827
  305. package/dist/packem_chunks/MailPanel.js +0 -353
  306. package/dist/packem_chunks/MetricsPanel.js +0 -1344
  307. package/dist/packem_chunks/MigrationsPanel.js +0 -239
  308. package/dist/packem_chunks/PitrPanel.js +0 -252
  309. package/dist/packem_chunks/SchemaViewer.js +0 -2513
  310. package/dist/packem_chunks/SecurityAdvisorPanel.js +0 -95
  311. package/dist/packem_chunks/SettingsPanel.js +0 -391
  312. package/dist/packem_chunks/SqlEditorPanel.js +0 -2323
  313. package/dist/packem_chunks/TableEditor.js +0 -313
  314. package/dist/packem_chunks/analytics-panel.js +0 -261
  315. package/dist/packem_chunks/auth-config-panel.js +0 -365
  316. package/dist/packem_chunks/auth-sessions-panel.js +0 -175
  317. package/dist/packem_chunks/containers-panel.js +0 -247
  318. package/dist/packem_chunks/dashboards-panel.js +0 -780
  319. package/dist/packem_chunks/fanout-panel.js +0 -482
  320. package/dist/packem_chunks/flags-panel.js +0 -176
  321. package/dist/packem_chunks/kv-browser.js +0 -1896
  322. package/dist/packem_chunks/log-drains-panel.js +0 -273
  323. package/dist/packem_chunks/organizations-panel.js +0 -3178
  324. package/dist/packem_chunks/payments-panel.js +0 -186
  325. package/dist/packem_chunks/permissions-panel.js +0 -805
  326. package/dist/packem_chunks/queues-panel.js +0 -1052
  327. package/dist/packem_chunks/rls-panel.js +0 -315
  328. package/dist/packem_chunks/schedule-panel.js +0 -831
  329. package/dist/packem_chunks/sparkline.js +0 -79
  330. package/dist/packem_chunks/storage-rules-panel.js +0 -140
  331. package/dist/packem_chunks/subscriptions-panel.js +0 -238
  332. package/dist/packem_chunks/users-panel.js +0 -1731
  333. package/dist/packem_chunks/vector-browser.js +0 -281
  334. package/dist/packem_chunks/workflows-panel.js +0 -562
  335. package/dist/packem_shared/ADMIN_FUNCTIONS-BHHJi3Gb.js +0 -52
  336. package/dist/packem_shared/ApiDocsPanel-D4CJf2ad.js +0 -842
  337. package/dist/packem_shared/ApiReferencePanel-Co_wpRF2.js +0 -230
  338. package/dist/packem_shared/CommandPalette-BUPpbpMc.js +0 -373
  339. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  340. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  341. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  342. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  343. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  344. package/dist/packem_shared/DataBrowser-BeVNxSVm.js +0 -4493
  345. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  346. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  347. package/dist/packem_shared/GlobalDataBrowser-ErfvIs1S.js +0 -289
  348. package/dist/packem_shared/HomePanel-D9MQk8I7.js +0 -14
  349. package/dist/packem_shared/OpenRpcReferencePanel-DLWzrIx9.js +0 -192
  350. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  351. package/dist/packem_shared/ScheduledJobs-ClaNpZsg.js +0 -262
  352. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  353. package/dist/packem_shared/Studio-C48P1K5W.js +0 -16
  354. package/dist/packem_shared/StudioApp-Cqh-SYm2.js +0 -657
  355. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  356. package/dist/packem_shared/advisor-view-D3-U4kRR.js +0 -159
  357. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  358. package/dist/packem_shared/alert-CdAET2K_.js +0 -68
  359. package/dist/packem_shared/app.d-CNLRTrWw.d.ts +0 -300
  360. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  361. package/dist/packem_shared/bar-chart-DSwcWIRy.js +0 -3246
  362. package/dist/packem_shared/browser-storage-tLOxkIHd.js +0 -185
  363. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  364. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  365. package/dist/packem_shared/cf-links-BZfRdxSE.js +0 -8
  366. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  367. package/dist/packem_shared/data-grid-Jz8FqQ2C.js +0 -183
  368. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +0 -96
  369. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  370. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  371. package/dist/packem_shared/error-alert-BBT6D22d.js +0 -114
  372. package/dist/packem_shared/grid-features-CUr8Z1_O.js +0 -745
  373. package/dist/packem_shared/home-panel-CoGxi-oj.js +0 -1639
  374. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  375. package/dist/packem_shared/internal-DTsYVn-g.js +0 -97
  376. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  377. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  378. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +0 -100
  379. package/dist/packem_shared/reference-view-CSKyUyPl.js +0 -2141
  380. package/dist/packem_shared/scroll-area-DLhcy-ml.js +0 -93
  381. package/dist/packem_shared/select-UkNYCT3s.js +0 -273
  382. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  383. package/dist/packem_shared/skeleton-CGhL0p20.js +0 -45
  384. package/dist/packem_shared/sparkline-BnA1kC9X.js +0 -93
  385. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  386. package/dist/packem_shared/studio-CPHA_-3I.js +0 -4015
  387. package/dist/packem_shared/table-DsCa9Qp9.js +0 -246
  388. package/dist/packem_shared/table-list-sidebar-B5psdSV1.js +0 -832
  389. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  390. package/dist/packem_shared/use-admin-query-BHPKmPuj.js +0 -106
  391. package/dist/packem_shared/use-async-submit-BWMDwRa4.js +0 -91
  392. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  393. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  394. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
  395. package/dist/standalone/chunk-2F4VYKM6.js +0 -1
  396. package/dist/standalone/chunk-2GFAOIC3.js +0 -8
  397. package/dist/standalone/chunk-2K47A3P6.js +0 -1
  398. package/dist/standalone/chunk-2NGUNNGW.js +0 -1
  399. package/dist/standalone/chunk-2SAZ5BZ5.js +0 -4
  400. package/dist/standalone/chunk-2SE7II7A.js +0 -1
  401. package/dist/standalone/chunk-34OQUHSV.js +0 -1
  402. package/dist/standalone/chunk-3CJW6NWG.js +0 -4
  403. package/dist/standalone/chunk-3DBG4RIV.js +0 -1
  404. package/dist/standalone/chunk-3OA7PECS.js +0 -6
  405. package/dist/standalone/chunk-3UFZCRWL.js +0 -1
  406. package/dist/standalone/chunk-4FL3EDN5.js +0 -2
  407. package/dist/standalone/chunk-4JOKDSPU.js +0 -1
  408. package/dist/standalone/chunk-4QHKBC77.js +0 -1
  409. package/dist/standalone/chunk-5OIBXYZM.js +0 -1
  410. package/dist/standalone/chunk-6GFEVKJP.js +0 -1
  411. package/dist/standalone/chunk-7FF76BYY.js +0 -1
  412. package/dist/standalone/chunk-7TJJXVSE.js +0 -1
  413. package/dist/standalone/chunk-7YXOPTWI.js +0 -1
  414. package/dist/standalone/chunk-AHILM3ZP.js +0 -1
  415. package/dist/standalone/chunk-AJIUI7DD.js +0 -1
  416. package/dist/standalone/chunk-AJKR6PY7.js +0 -1
  417. package/dist/standalone/chunk-BOXSWNXZ.js +0 -1
  418. package/dist/standalone/chunk-CKSHCYGC.js +0 -2
  419. package/dist/standalone/chunk-DC72CQY4.js +0 -76
  420. package/dist/standalone/chunk-DWDILV2E.js +0 -1
  421. package/dist/standalone/chunk-FA3CCTXK.js +0 -1
  422. package/dist/standalone/chunk-FCSPAJW4.js +0 -1
  423. package/dist/standalone/chunk-GLUNBZRI.js +0 -1
  424. package/dist/standalone/chunk-GM4NPF3W.js +0 -1
  425. package/dist/standalone/chunk-GMSGZDDH.js +0 -13
  426. package/dist/standalone/chunk-GTM65MVX.js +0 -1
  427. package/dist/standalone/chunk-HLZ4YLRK.js +0 -1
  428. package/dist/standalone/chunk-HV7G6DFP.js +0 -5
  429. package/dist/standalone/chunk-I3VXCZZL.js +0 -1
  430. package/dist/standalone/chunk-IJPFHUJK.js +0 -2
  431. package/dist/standalone/chunk-IQ466Q6W.js +0 -1
  432. package/dist/standalone/chunk-IU6GTBPD.js +0 -1
  433. package/dist/standalone/chunk-IXDH4GL5.js +0 -1
  434. package/dist/standalone/chunk-J6J54MBP.js +0 -1
  435. package/dist/standalone/chunk-JSEXCW5Q.js +0 -1
  436. package/dist/standalone/chunk-JTTVXBLU.js +0 -1
  437. package/dist/standalone/chunk-K3GNLVYK.js +0 -1
  438. package/dist/standalone/chunk-KEGAWN6Y.js +0 -1
  439. package/dist/standalone/chunk-KJJ3WM6H.js +0 -4
  440. package/dist/standalone/chunk-KQTCLPLO.js +0 -4
  441. package/dist/standalone/chunk-KSKXW5PX.js +0 -1
  442. package/dist/standalone/chunk-KZ6INM5M.js +0 -1
  443. package/dist/standalone/chunk-L7SK4ZZD.js +0 -1
  444. package/dist/standalone/chunk-LAK5VSPI.js +0 -1
  445. package/dist/standalone/chunk-LEHGGJP2.js +0 -1
  446. package/dist/standalone/chunk-LNZIB2MD.js +0 -1
  447. package/dist/standalone/chunk-MZ756AFF.js +0 -1
  448. package/dist/standalone/chunk-N7G5I47W.js +0 -1
  449. package/dist/standalone/chunk-NV6RHG5L.js +0 -1
  450. package/dist/standalone/chunk-O3I57FXK.js +0 -1
  451. package/dist/standalone/chunk-O3NAGRTR.js +0 -1
  452. package/dist/standalone/chunk-OES45DFG.js +0 -13
  453. package/dist/standalone/chunk-OIC7EJWI.js +0 -1
  454. package/dist/standalone/chunk-OLE2AYTD.js +0 -1
  455. package/dist/standalone/chunk-P3ZMBPCY.js +0 -1
  456. package/dist/standalone/chunk-P5JW7HKP.js +0 -1
  457. package/dist/standalone/chunk-PVZI3CXP.js +0 -19
  458. package/dist/standalone/chunk-PZ7HD5T2.js +0 -1
  459. package/dist/standalone/chunk-Q3PTSVVU.js +0 -3
  460. package/dist/standalone/chunk-Q52CHOSY.js +0 -1
  461. package/dist/standalone/chunk-QAFAJBAW.js +0 -1
  462. package/dist/standalone/chunk-QBAT52GB.js +0 -1
  463. package/dist/standalone/chunk-QKQABJBE.js +0 -1
  464. package/dist/standalone/chunk-R5OQZYSW.js +0 -4
  465. package/dist/standalone/chunk-RRCPZMC2.js +0 -22
  466. package/dist/standalone/chunk-SE2TQAHJ.js +0 -1
  467. package/dist/standalone/chunk-SEU5V7I6.js +0 -1
  468. package/dist/standalone/chunk-SG3ALJJU.js +0 -1
  469. package/dist/standalone/chunk-TAD43CG5.js +0 -1
  470. package/dist/standalone/chunk-TBMYIZIO.js +0 -1
  471. package/dist/standalone/chunk-TDL7NEWA.js +0 -1
  472. package/dist/standalone/chunk-TI7SE33D.js +0 -1
  473. package/dist/standalone/chunk-TQ36RWOP.js +0 -1
  474. package/dist/standalone/chunk-UK64ZSUW.js +0 -1
  475. package/dist/standalone/chunk-VFJPO4UO.js +0 -1
  476. package/dist/standalone/chunk-VLXV72QE.js +0 -1
  477. package/dist/standalone/chunk-VON7JUPG.js +0 -1
  478. package/dist/standalone/chunk-WI7GWFEG.js +0 -1
  479. package/dist/standalone/chunk-WXPWVBIY.js +0 -1
  480. package/dist/standalone/chunk-X7RPB4K4.js +0 -1
  481. package/dist/standalone/chunk-XFSUINL3.js +0 -1
  482. package/dist/standalone/chunk-XGUOXHX4.js +0 -1
  483. package/dist/standalone/chunk-XNJNSCLM.js +0 -1
  484. package/dist/standalone/chunk-Y2ZPNDL7.js +0 -4
  485. package/dist/standalone/chunk-YAECF5LW.js +0 -1
  486. package/dist/standalone/chunk-ZHVTQ37P.js +0 -1
  487. package/dist/standalone/chunk-ZIGWVHCS.js +0 -1
  488. package/dist/standalone/chunk-ZL4E2WVF.js +0 -1
  489. package/dist/standalone/chunk-ZPP2KOR4.js +0 -1
  490. package/dist/standalone/chunk-ZPUO7FNI.js +0 -1
  491. package/dist/standalone/chunk-ZYRGPDZB.js +0 -1
@@ -1 +0,0 @@
1
- import{a as _}from"./chunk-3OA7PECS.js";import{a as n,e as E,f as S}from"./chunk-RRCPZMC2.js";var u=E(_(),1),o="base-ui-disable-scrollbar",d={className:o,getElement(t){return(0,u.jsx)("style",{nonce:t,href:o,precedence:"base-ui:low",children:`.${o}{scrollbar-width:none}.${o}::-webkit-scrollbar{display:none}`})}};d.getElement.displayName="styleDisableScrollbar.getElement";var s=E(S(),1);var p=s.createContext(void 0);p.displayName="CSPContext";var N={disableStyleElements:!1};function C(){return s.useContext(p)??N}n(C,"useCSPContext");function f(t,e=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,r))}n(f,"clamp");var m=1;function h(t,e){return Math.max(0,t-e)}n(h,"getMaxScrollOffset");function O(t,e){if(e<=0)return 0;let r=f(t,0,e),c=r,l=e-r,a=c<=m,i=l<=m;return a&&i?c<=l?0:e:a?0:i?e:r}n(O,"normalizeScrollOffset");export{d as a,C as b,f as c,m as d,h as e,O as f};
@@ -1 +0,0 @@
1
- import{a as k,b as j}from"./chunk-KJJ3WM6H.js";import{a as D}from"./chunk-WXPWVBIY.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as _,b as z,c as B,d as f,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as M}from"./chunk-K3GNLVYK.js";import"./chunk-TBMYIZIO.js";import{R as L}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as H}from"./chunk-BOXSWNXZ.js";import{a as I}from"./chunk-TAD43CG5.js";import{b as A}from"./chunk-OIC7EJWI.js";import{a as y,e as E}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as C,n as R}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as i,e as w,f as ee,h as te}from"./chunk-RRCPZMC2.js";var o=w(ee(),1);var e=w(te(),1);var K=80,ae=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>K?`${t.slice(0,K)}\u2026`:t},"formatDetail"),re=41,F=480,U=5,oe=i((s,t)=>k(s,d=>{t(d.height>0?d:{height:F,width:d.width})}),"observeViewportRect"),Se=i(({initialShardKey:s})=>{let t=C(),[d,G]=(0,o.useState)(s??""),[m,W]=(0,o.useState)(""),q=O(d.trim(),400),{data:v,error:p,errorSource:J,isLoading:P,liveError:Q}=A(H.getAuditLog,{},{live:!0,shardKey:q}),u=(0,o.useMemo)(()=>v?.entries??[],[v]),c=(0,o.useMemo)(()=>{let r=m.trim().toLowerCase();return r===""?u:u.filter(a=>a.op.toLowerCase().includes(r)||(a.table??"").toLowerCase().includes(r)||(a.id??"").toLowerCase().includes(r))},[u,m]),g=(0,o.useRef)(null),x=j({count:c.length,estimateSize:i(()=>re,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:F,width:800},observeElementRect:oe,overscan:8}),h=x.getVirtualItems(),X=x.getTotalSize(),S=h[0]?.start??0,b=X-(h.at(-1)?.end??0),Z={height:S},$={height:b},Y=i(r=>{W(r.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:G,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(D,{message:Q,prefix:"au"},void 0,!1),(0,e.jsxDEV)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:m},void 0,!1)]},void 0,!0),p!==null&&(0,e.jsxDEV)(V,{error:J,testId:"au-error"},void 0,!1),p===null&&!P&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("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"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(_,{"data-testid":"au-table",children:[(0,e.jsxDEV)(z,{children:(0,e.jsxDEV)(f,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(B,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:Z},void 0,!1)},void 0,!1),h.map(r=>{let a=c[r.index],N=ae(a.detail);return(0,e.jsxDEV)(f,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:$},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{Se as AuditPanel};
@@ -1 +0,0 @@
1
- import{a as k,b as N,c as O,d as x,e as q,f as D}from"./chunk-GTM65MVX.js";import{a as C}from"./chunk-TAD43CG5.js";import{a as g}from"./chunk-SEU5V7I6.js";import{d as T,g as I,j as _,k as w}from"./chunk-PVZI3CXP.js";import{b as L}from"./chunk-GMSGZDDH.js";import{a as d,e as b,f as U,g as Y,h as F}from"./chunk-RRCPZMC2.js";var M=b(Y(),1);var H="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"AnalyticsSqlError")}constructor(e,f){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(e)}: ${f}`,{name:"AnalyticsSqlError",status:e})}},v=d(t=>{let e=t.fetch??globalThis.fetch,f=`${H}/${encodeURIComponent(t.accountId)}/analytics_engine/sql`;return{query:d(async s=>{let l=await e(f,{body:s,headers:{Authorization:`Bearer ${t.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let n;try{n=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let o=n,a=o.data??[];return{columns:o.meta??[],rowCount:o.rows??a.length,rows:a}},"query")}},"createAnalyticsSqlClient");var m=b(U(),1);var r=b(F(),1);var W="ANALYTICS",P=[{key:"volume",sql:d(t=>`SELECT blob2 AS fn, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(t=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(t=>`SELECT blob3 AS shard, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=d(t=>{let e=(0,M.c)(27),{state:f,title:p}=t,s=T(),{error:l,loading:n,result:o}=f,a=`analytics-panel-${p}`,i;e[0]!==s||e[1]!==p?(i=s(p),e[0]=s,e[1]=p,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1)},void 0,!1),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==n||e[6]!==s?(u=n&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:s("Loading\u2026")},void 0,!1),e[5]=n,e[6]=s,e[7]=u):u=e[7];let y;e[8]!==l||e[9]!==n?(y=!n&&l!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l},void 0,!1),e[8]=l,e[9]=n,e[10]=y):y=e[10];let h;e[11]!==l||e[12]!==n||e[13]!==o||e[14]!==s?(h=!n&&l===null&&o!==null&&o.rows.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:s("No data points yet.")},void 0,!1),e[11]=l,e[12]=n,e[13]=o,e[14]=s,e[15]=h):h=e[15];let A;e[16]!==l||e[17]!==n||e[18]!==o?(A=!n&&l===null&&o!==null&&o.rows.length>0&&(0,r.jsxDEV)(k,{children:[(0,r.jsxDEV)(N,{children:(0,r.jsxDEV)(x,{children:o.columns.map(Q)},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{children:o.rows.map((B,$)=>(0,r.jsxDEV)(x,{children:o.columns.map(R=>(0,r.jsxDEV)(D,{className:"font-mono text-xs",children:_(B[R.name])},R.name,!1))},$,!1))},void 0,!1)]},void 0,!0),e[16]=l,e[17]=n,e[18]=o,e[19]=A):A=e[19];let S;return e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==y||e[24]!==h||e[25]!==A?(S=(0,r.jsxDEV)(g,{className:"gap-0 py-0","data-testid":a,children:[c,u,y,h,A]},void 0,!0),e[20]=a,e[21]=c,e[22]=u,e[23]=y,e[24]=h,e[25]=A,e[26]=S):S=e[26],S},"PanelResult"),re=d(({config:t,dataset:e=W,runQuery:f}={})=>{let p=T(),[s,l]=(0,m.useState)({}),n=(0,m.useMemo)(()=>{if(f!==void 0)return f;if(t===void 0)return null;let a=v({accountId:t.accountId,apiToken:t.apiToken});return i=>a.query(i)},[t,f]),o=(0,m.useCallback)(async a=>{if(n!==null)for(let i of P){if(a.cancelled)return;l(c=>({...c,[i.key]:{error:null,loading:!0,result:null}}));try{let c=await n(i.sql(e));a.cancelled||l(u=>({...u,[i.key]:{error:null,loading:!1,result:c}}))}catch(c){a.cancelled||l(u=>({...u,[i.key]:{error:I(c),loading:!1,result:null}}))}}},[n,e]);return(0,m.useEffect)(()=>{let a={cancelled:!1};return w(o(a)),()=>{a.cancelled=!0}},[o]),n===null?(0,r.jsxDEV)(C,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"},void 0,!1)},void 0,!1),testId:"analytics-not-configured",title:p("Analytics is not configured.")},void 0,!1):(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:P.map(a=>(0,r.jsxDEV)(G,{state:s[a.key]??j,title:a.title},a.key,!1))},void 0,!1)},"AnalyticsPanel");function Q(t){return(0,r.jsxDEV)(q,{children:t.name},t.name,!1)}d(Q,"_temp");export{re as AnalyticsPanel};
@@ -1 +0,0 @@
1
- import{a as it}from"./chunk-3OA7PECS.js";import{b as m}from"./chunk-GMSGZDDH.js";import{a as o,e as R,f as q,g as nt,h as ar}from"./chunk-RRCPZMC2.js";var Dt=R(nt(),1);var x=class{static{o(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var cr=class extends x{static{o(this,"FocusManager")}#t;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#t!==t&&(this.#t=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},z=new cr;var ur={setTimeout:o((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:o(t=>clearTimeout(t),"clearTimeout"),setInterval:o((t,e)=>setInterval(t,e),"setInterval"),clearInterval:o(t=>clearInterval(t),"clearInterval")},hr=class{static{o(this,"TimeoutManager")}#t=ur;#e=!1;setTimeoutProvider(t){this.#e&&t!==this.#t&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#t,provider:t}),this.#t=t,this.#e=!1}setTimeout(t,e){return this.#e=!0,this.#t.setTimeout(t,e)}clearTimeout(t){this.#t.clearTimeout(t)}setInterval(t,e){return this.#e=!0,this.#t.setInterval(t,e)}clearInterval(t){this.#t.clearInterval(t)}},L=new hr;function ot(t){setTimeout(t,0)}o(ot,"systemSetTimeoutZero");var Fe=typeof window>"u"||"Deno"in globalThis;function S(){}o(S,"noop");function ut(t,e){return typeof t=="function"?t(e):t}o(ut,"functionalUpdate");function re(t){return typeof t=="number"&&t>=0&&t!==1/0}o(re,"isValidTimeout");function ye(t,e){return Math.max(t+(e||0)-Date.now(),0)}o(ye,"timeUntilStale");function P(t,e){return typeof t=="function"?t(e):t}o(P,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}o(I,"resolveQueryBoolean");function ge(t,e){let{type:r="all",exact:s,fetchStatus:n,predicate:i,queryKey:a,stale:u}=t;if(a){if(s){if(e.queryHash!==se(a,e.options))return!1}else if(!K(e.queryKey,a))return!1}if(r!=="all"){let c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof u=="boolean"&&e.isStale()!==u||n&&n!==e.state.fetchStatus||i&&!i(e))}o(ge,"matchQuery");function ve(t,e){let{exact:r,status:s,predicate:n,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(B(e.options.mutationKey)!==B(i))return!1}else if(!K(e.options.mutationKey,i))return!1}return!(s&&e.state.status!==s||n&&!n(e))}o(ve,"matchMutation");function se(t,e){return(e?.queryKeyHashFn||B)(t)}o(se,"hashQueryKeyByOptions");function B(t){return JSON.stringify(t,(e,r)=>Le(r)?Object.keys(r).sort().reduce((s,n)=>(s[n]=r[n],s),{}):r)}o(B,"hashKey");function K(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>K(t[r],e[r])):!1}o(K,"partialMatchKey");var dr=Object.prototype.hasOwnProperty;function pe(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=at(t)&&at(e);if(!s&&!(Le(t)&&Le(e)))return e;let i=(s?t:Object.keys(t)).length,a=s?e:Object.keys(e),u=a.length,c=s?new Array(u):{},h=0;for(let d=0;d<u;d++){let l=s?d:a[d],f=t[l],p=e[l];if(f===p){c[l]=f,(s?d<i:dr.call(t,l))&&h++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){c[l]=p;continue}let g=pe(f,p,r+1);c[l]=g,g===f&&h++}return i===u&&h===i?t:c}o(pe,"replaceEqualDeep");function be(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}o(be,"shallowEqualObjects");function at(t){return Array.isArray(t)&&t.length===Object.keys(t).length}o(at,"isPlainArray");function Le(t){if(!ct(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!ct(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}o(Le,"isPlainObject");function ct(t){return Object.prototype.toString.call(t)==="[object Object]"}o(ct,"hasObjectPrototype");function ht(t){return new Promise(e=>{L.setTimeout(e,t)})}o(ht,"sleep");function ne(t,e,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(t,e);if(r.structuralSharing!==!1){try{return pe(t,e)}catch(s){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${s}`),s}return pe(t,e)}return e}o(ne,"replaceData");function lr(t){return t}o(lr,"keepPreviousData");function dt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}o(dt,"addToEnd");function lt(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}o(lt,"addToStart");var j=Symbol();function Se(t,e){return t.queryFn===j&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${t.queryHash}'`),!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===j?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}o(Se,"ensureQueryFn");function we(t,e){return typeof t=="function"?t(...e):!!t}o(we,"shouldThrowError");function ft(t,e,r){let s=!1,n;return Object.defineProperty(t,"signal",{enumerable:!0,get:o(()=>(n??=e(),s||(s=!0,n.aborted?r():n.addEventListener("abort",r,{once:!0})),n),"get")}),t}o(ft,"addConsumeAwareSignal");var F=(()=>{let t=o(()=>Fe,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function ie(){let t,e,r=new Promise((n,i)=>{t=n,e=i});r.status="pending",r.catch(()=>{});function s(n){Object.assign(r,n),delete r.resolve,delete r.reject}return o(s,"finalize"),r.resolve=n=>{s({status:"fulfilled",value:n}),t(n)},r.reject=n=>{s({status:"rejected",reason:n}),e(n)},r}o(ie,"pendingThenable");var mt=ot;function fr(){let t=[],e=0,r=o(u=>{u()},"notifyFn"),s=o(u=>{u()},"batchNotifyFn"),n=mt,i=o(u=>{e?t.push(u):n(()=>{r(u)})},"schedule"),a=o(()=>{let u=t;t=[],u.length&&n(()=>{s(()=>{u.forEach(c=>{r(c)})})})},"flush");return{batch:o(u=>{let c;e++;try{c=u()}finally{e--,e||a()}return c},"batch"),batchCalls:o(u=>(...c)=>{i(()=>{u(...c)})},"batchCalls"),schedule:i,setNotifyFunction:o(u=>{r=u},"setNotifyFunction"),setBatchNotifyFunction:o(u=>{s=u},"setBatchNotifyFunction"),setScheduler:o(u=>{n=u},"setScheduler")}}o(fr,"createNotifyManager");var v=fr();var mr=class extends x{static{o(this,"OnlineManager")}#t=!0;#e;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=o(()=>t(!0),"onlineListener"),r=o(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#e||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(t){this.#r=t,this.#e?.(),this.#e=t(this.setOnline.bind(this))}setOnline(t){this.#t!==t&&(this.#t=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#t}},W=new mr;function pr(t){return Math.min(1e3*2**t,3e4)}o(pr,"defaultRetryDelay");function Me(t){return(t??"online")==="online"?W.isOnline():!0}o(Me,"canFetch");var Ee=class extends Error{static{o(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Te(t){let e=!1,r=0,s,n=ie(),i=o(()=>n.status!=="pending","isResolved"),a=o(y=>{if(!i()){let b=new Ee(y);f(b),t.onCancel?.(b)}},"cancel"),u=o(()=>{e=!0},"cancelRetry"),c=o(()=>{e=!1},"continueRetry"),h=o(()=>z.isFocused()&&(t.networkMode==="always"||W.isOnline())&&t.canRun(),"canContinue"),d=o(()=>Me(t.networkMode)&&t.canRun(),"canStart"),l=o(y=>{i()||(s?.(),n.resolve(y))},"resolve"),f=o(y=>{i()||(s?.(),n.reject(y))},"reject"),p=o(()=>new Promise(y=>{s=o(b=>{(i()||h())&&y(b)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,i()||t.onContinue?.()}),"pause"),g=o(()=>{if(i())return;let y,b=r===0?t.initialPromise:void 0;try{y=b??t.fn()}catch(E){y=Promise.reject(E)}Promise.resolve(y).then(l).catch(E=>{if(i())return;let A=t.retry??(F.isServer()?0:3),M=t.retryDelay??pr,Q=typeof M=="function"?M(r,E):M,H=A===!0||typeof A=="number"&&r<A||typeof A=="function"&&A(r,E);if(e||!H){f(E);return}r++,t.onFail?.(r,E),ht(Q).then(()=>h()?void 0:p()).then(()=>{e?f(E):g()})})},"run");return{promise:n,status:o(()=>n.status,"status"),cancel:a,continue:o(()=>(s?.(),n),"continue"),cancelRetry:u,continueRetry:c,canStart:d,start:o(()=>(d()?g():p().then(g),n),"start")}}o(Te,"createRetryer");var Ce=class{static{o(this,"Removable")}#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),re(this.gcTime)&&(this.#t=L.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(F.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#t!==void 0&&(L.clearTimeout(this.#t),this.#t=void 0)}};function yt(t){return{onFetch:o((e,r)=>{let s=e.options,n=e.fetchOptions?.meta?.fetchMore?.direction,i=e.state.data?.pages||[],a=e.state.data?.pageParams||[],u={pages:[],pageParams:[]},c=0,h=o(async()=>{let d=!1,l=o(g=>{ft(g,()=>e.signal,()=>d=!0)},"addSignalProperty"),f=Se(e.options,e.fetchOptions),p=o(async(g,y,b)=>{if(d)return Promise.reject(e.signal.reason);if(y==null&&g.pages.length)return Promise.resolve(g);let A=o(()=>{let xe={client:e.client,queryKey:e.queryKey,pageParam:y,direction:b?"backward":"forward",meta:e.options.meta};return l(xe),xe},"createQueryFnContext")(),M=await f(A),{maxPages:Q}=e.options,H=b?lt:dt;return{pages:H(g.pages,M,Q),pageParams:H(g.pageParams,y,Q)}},"fetchPage");if(n&&i.length){let g=n==="backward",y=g?yr:pt,b={pages:i,pageParams:a},E=y(s,b);u=await p(b,E,g)}else{let g=t??i.length;do{let y=c===0?a[0]??s.initialPageParam:pt(s,u);if(c>0&&y==null)break;u=await p(u,y),c++}while(c<g)}return u},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=h},"onFetch")}}o(yt,"infiniteQueryBehavior");function pt(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}o(pt,"getNextPageParam");function yr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}o(yr,"getPreviousPageParam");var bt=class extends Ce{static{o(this,"Query")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#i=t.client,this.#s=this.#i.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#e=vt(this.options),this.state=t.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#t}get promise(){return this.#n?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#t=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=vt(this.options);e.data!==void 0&&(this.setState(gt(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ne(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#n?.promise;return this.#n?.cancel(t),e?e.then(S).catch(S):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>P(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!ye(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#n&&(this.#o||this.#h()?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(t&&this.setOptions(t),!this.options.queryFn){let c=this.observers.find(h=>h.options.queryFn);c&&this.setOptions(c.options)}Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let r=new AbortController,s=o(c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:o(()=>(this.#o=!0,r.signal),"get")})},"addSignalProperty"),n=o(()=>{let c=Se(this.options,e),d=o(()=>{let l={client:this.#i,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#o=!1,this.options.persister?this.options.persister(c,d,this):c(d)},"fetchFn"),a=o(()=>{let c={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:n};return s(c),c},"createFetchContext")();(this.#t==="infinite"?yt(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=Te({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o(c=>{c instanceof Ee&&c.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:o((c,h)=>{this.#c({type:"failed",failureCount:c,error:h})},"onFail"),onPause:o(()=>{this.#c({type:"pause"})},"onPause"),onContinue:o(()=>{this.#c({type:"continue"})},"onContinue"),retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:o(()=>!0,"canRun")});try{let c=await this.#n.start();if(c===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(c),this.#s.config.onSuccess?.(c,this),this.#s.config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Ee){if(c.silent)return this.#n.promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw this.#c({type:"error",error:c}),this.#s.config.onError?.(c,this),this.#s.config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}#c(t){let e=o(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Ne(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...gt(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let n=t.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),v.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function Ne(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Me(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}o(Ne,"fetchState");function gt(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}o(gt,"successState");function vt(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}o(vt,"getDefaultState");var Ue=class extends x{static{o(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#t=t,this.#o=null,this.#a=ie(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#r=void 0;#s=void 0;#i;#n;#a;#o;#h;#c;#m;#d;#l;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),St(this.#e,this.options)?this.#f():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return De(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return De(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#e.removeObserver(this)}setOptions(t){let e=this.options,r=this.#e;if(this.options=this.#t.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#E(),this.#e.setOptions(this.options),e._defaulted&&!be(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});let s=this.hasListeners();s&&wt(this.#e,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||P(this.options.staleTime,this.#e)!==P(e.staleTime,this.#e))&&this.#y();let n=this.#g();s&&(this.#e!==r||I(this.options.enabled,this.#e)!==I(e.enabled,this.#e)||n!==this.#u)&&this.#v(n)}getOptimisticResult(t){let e=this.#t.getQueryCache().build(this.#t,t),r=this.createResult(e,t);return vr(this,r)&&(this.#s=r,this.#n=this.options,this.#i=this.#e.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:o((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#e}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#t.defaultQueryOptions(t),r=this.#t.getQueryCache().build(this.#t,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#E();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(S)),e}#y(){this.#S();let t=P(this.options.staleTime,this.#e);if(F.isServer()||this.#s.isStale||!re(t))return;let r=ye(this.#s.dataUpdatedAt,t)+1;this.#d=L.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#v(t){this.#w(),this.#u=t,!(F.isServer()||I(this.options.enabled,this.#e)===!1||!re(this.#u)||this.#u===0)&&(this.#l=L.setInterval(()=>{(this.options.refetchIntervalInBackground||z.isFocused())&&this.#f()},this.#u))}#b(){this.#y(),this.#v(this.#g())}#S(){this.#d!==void 0&&(L.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(L.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#e,s=this.options,n=this.#s,i=this.#i,a=this.#n,c=t!==r?t.state:this.#r,{state:h}=t,d={...h},l=!1,f;if(e._optimisticResults){let k=this.hasListeners(),te=!k&&St(t,e),le=k&&wt(t,r,e,s);(te||le)&&(d={...d,...Ne(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:y}=d;f=d.data;let b=!1;if(e.placeholderData!==void 0&&f===void 0&&y==="pending"){let k;n?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(k=n.data,b=!0):k=typeof e.placeholderData=="function"?e.placeholderData(this.#m?.state.data,this.#m):e.placeholderData,k!==void 0&&(y="success",f=ne(n?.data,k,e),l=!0)}if(e.select&&f!==void 0&&!b)if(n&&f===i?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ne(n?.data,f,e),this.#c=f,this.#o=null}catch(k){this.#o=k}this.#o&&(p=this.#o,f=this.#c,g=Date.now(),y="error");let E=d.fetchStatus==="fetching",A=y==="pending",M=y==="error",Q=A&&E,H=f!==void 0,D={status:y,fetchStatus:d.fetchStatus,isPending:A,isSuccess:y==="success",isError:M,isInitialLoading:Q,isLoading:Q,data:f,dataUpdatedAt:d.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:E,isRefetching:E&&!A,isLoadingError:M&&!H,isPaused:d.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:M&&H,isStale:Qe(t,e),refetch:this.refetch,promise:this.#a,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let k=D.data!==void 0,te=D.status==="error"&&!k,le=o(me=>{te?me.reject(D.error):k&&me.resolve(D.data)},"finalizeThenableIfPossible"),st=o(()=>{let me=this.#a=D.promise=ie();le(me)},"recreateThenable"),fe=this.#a;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(te||D.data!==fe.value)&&st();break;case"rejected":(!te||D.error!==fe.reason)&&st();break}}return D}updateResult(){let t=this.#s,e=this.createResult(this.#e,this.options);if(this.#i=this.#e.state,this.#n=this.options,this.#i.data!==void 0&&(this.#m=this.#e),be(e,t))return;this.#s=e;let r=o(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,n=typeof s=="function"?s():s;if(n==="all"||!n&&!this.#p.size)return!0;let i=new Set(n??this.#p);return this.options.throwOnError&&i.add("error"),Object.keys(this.#s).some(a=>{let u=a;return this.#s[u]!==t[u]&&i.has(u)})},"shouldNotifyListeners");this.#T({listeners:r()})}#E(){let t=this.#t.getQueryCache().build(this.#t,this.options);if(t===this.#e)return;let e=this.#e;this.#e=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#T(t){v.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function gr(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}o(gr,"shouldLoadOnMount");function St(t,e){return gr(t,e)||t.state.data!==void 0&&De(t,e,e.refetchOnMount)}o(St,"shouldFetchOnMount");function De(t,e,r){if(I(e.enabled,t)!==!1&&P(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&Qe(t,e)}return!1}o(De,"shouldFetchOn");function wt(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&Qe(t,r)}o(wt,"shouldFetchOptionally");function Qe(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(P(e.staleTime,t))}o(Qe,"isStale");function vr(t,e){return!be(t.getCurrentResult(),e)}o(vr,"shouldAssignObserverCurrentProperties");var Et=class extends Ce{static{o(this,"Mutation")}#t;#e;#r;#s;constructor(t){super(),this.#t=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#e=[],this.state=t.state||br(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#e.includes(t)||(this.#e.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#e=this.#e.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=o(()=>{this.#i({type:"continue"})},"onContinue"),r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Te({fn:o(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:o((i,a)=>{this.#i({type:"failed",failureCount:i,error:a})},"onFail"),onPause:o(()=>{this.#i({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:o(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",n=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:n}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let a=await this.options.onMutate?.(t,r);a!==this.state.context&&this.#i({type:"pending",context:a,variables:t,isPaused:n})}let i=await this.#s.start();return await this.#r.config.onSuccess?.(i,t,this.state.context,this,r),await this.options.onSuccess?.(i,t,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,t,this.state.context,r),this.#i({type:"success",data:i}),i}catch(i){try{await this.#r.config.onError?.(i,t,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onError?.(i,t,this.state.context,r)}catch(a){Promise.reject(a)}try{await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r)}catch(a){Promise.reject(a)}try{await this.options.onSettled?.(void 0,i,t,this.state.context,r)}catch(a){Promise.reject(a)}throw this.#i({type:"error",error:i}),i}finally{this.#r.runNext(this)}}#i(t){let e=o(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),v.batch(()=>{this.#e.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function br(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}o(br,"getDefaultState");var Tt=class extends x{static{o(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#t=new Set,this.#e=new Map,this.#r=0}#t;#e;#r;build(t,e,r){let s=new Et({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#t.add(t);let e=Ae(t);if(typeof e=="string"){let r=this.#e.get(e);r?r.push(t):this.#e.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#t.delete(t)){let e=Ae(t);if(typeof e=="string"){let r=this.#e.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#e.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ae(t);if(typeof e=="string"){let s=this.#e.get(e)?.find(n=>n.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ae(t);return typeof e=="string"?this.#e.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){v.batch(()=>{this.#t.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ve(e,r))}findAll(t={}){return this.getAll().filter(e=>ve(t,e))}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return v.batch(()=>Promise.all(t.map(e=>e.continue().catch(S))))}};function Ae(t){return t.options.scope?.id}o(Ae,"scopeFor");var Ct=class extends x{static{o(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,r){let s=e.queryKey,n=e.queryHash??se(s,e),i=this.get(n);return i||(i=new bt({client:t,queryKey:s,queryHash:n,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(i)),i}add(t){this.#t.has(t.queryHash)||(this.#t.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#t.get(t.queryHash);e&&(t.destroy(),e===t&&this.#t.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){v.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#t.get(t)}getAll(){return[...this.#t.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ge(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ge(t,r)):e}notify(t){v.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){v.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){v.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var He=class{static{o(this,"QueryClient")}#t;#e;#r;#s;#i;#n;#a;#o;constructor(t={}){this.#t=t.queryCache||new Ct,this.#e=t.mutationCache||new Tt,this.#r=t.defaultOptions||{},this.#s=new Map,this.#i=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#a=z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#o=W.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#t.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#t.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(P(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#t.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),i=this.#t.get(s.queryHash)?.state.data,a=ut(e,i);if(a!==void 0)return this.#t.build(this,s).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return v.batch(()=>this.#t.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#t.get(e.queryHash)?.state}removeQueries(t){let e=this.#t;v.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#t;return v.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=v.batch(()=>this.#t.findAll(t).map(n=>n.cancel(r)));return Promise.all(s).then(S).catch(S)}invalidateQueries(t,e={}){return v.batch(()=>(this.#t.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=v.batch(()=>this.#t.findAll(t).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(S)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(S)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#t.build(this,e);return r.isStaleByTime(P(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(S).catch(S)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(S).catch(S)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return W.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(B(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{K(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#i.set(B(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#i.values()],r={};return e.forEach(s=>{K(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=se(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===j&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}};var J=R(q(),1),At=R(it(),1);var oe=J.createContext(void 0),qe=o(t=>{let e=J.useContext(oe);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Be=o(({client:t,children:e})=>(J.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,At.jsx)(oe.Provider,{value:t,children:e})),"QueryClientProvider");var Ie=R(q(),1);var It=Ie.createContext(!1),_t=o(()=>Ie.useContext(It),"useIsRestoring"),so=It.Provider;var ae=R(q(),1),Sr=R(it(),1);function wr(){let t=!1;return{clearReset:o(()=>{t=!1},"clearReset"),reset:o(()=>{t=!0},"reset"),isReset:o(()=>t,"isReset")}}o(wr,"createValue");var Er=ae.createContext(wr()),kt=o(()=>ae.useContext(Er),"useQueryErrorResetBoundary");var Rt=R(q(),1);var Ot=o((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?we(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),Pt=o(t=>{Rt.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),xt=o(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:n})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(n&&t.data===void 0||we(r,[t.error,s])),"getHasError");var Lt=o(t=>{if(t.suspense){let r=o(n=>n==="static"?n:Math.max(n??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...n)=>r(s(...n)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),Ft=o((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Mt=o((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),je=o((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");var U=R(q(),1);function Nt(t,e,r){if(typeof t!="object"||Array.isArray(t))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let s=_t(),n=kt(),i=qe(r),a=i.defaultQueryOptions(t);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a);let u=i.getQueryCache().get(a.queryHash);a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`);let c=t.subscribed!==!1;a._optimisticResults=s?"isRestoring":c?"optimistic":void 0,Lt(a),Ot(a,n,u),Pt(n);let h=!i.getQueryCache().get(a.queryHash),[d]=U.useState(()=>new e(i,a)),l=d.getOptimisticResult(a),f=!s&&c;if(U.useSyncExternalStore(U.useCallback(p=>{let g=f?d.subscribe(v.batchCalls(p)):S;return d.updateResult(),g},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),U.useEffect(()=>{d.setOptions(a)},[a,d]),Mt(a,l))throw je(a,d,n);if(xt({result:l,errorResetBoundary:n,throwOnError:a.throwOnError,query:u,suspense:a.suspense}))throw l.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,l),a.experimental_prefetchInRender&&!F.isServer()&&Ft(l,s)&&(h?je(a,d,n):u?.promise)?.catch(S).finally(()=>{d.updateResult()}),a.notifyOnChangeProps?l:d.trackResult(l)}o(Nt,"useBaseQuery");function Tr(t,e){return Nt(t,Ue,e)}o(Tr,"useQuery");var $=R(q(),1),Ke=R(ar(),1);var Ut=(0,$.createContext)(null),Cr=o(()=>new He({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"createDefaultQueryClient"),Ar=o(t=>{let e=(0,Dt.c)(9),{children:r,client:s,queryClient:n}=t,i=(0,$.use)(oe),a;e[0]!==i||e[1]!==n?(a=o(()=>n??i??Cr(),"t1"),e[0]=i,e[1]=n,e[2]=a):a=e[2];let[u]=(0,$.useState)(a),c=n??i??u;if(!c)throw new m("INTERNAL","LunoraProvider: failed to resolve a QueryClient");let h;e[3]!==r||e[4]!==s?(h=(0,Ke.jsxDEV)(Ut,{value:s,children:r},void 0,!1),e[3]=r,e[4]=s,e[5]=h):h=e[5];let d=h;if(i===c)return d;let l;return e[6]!==d||e[7]!==c?(l=(0,Ke.jsxDEV)(Be,{client:c,children:d},void 0,!1),e[6]=d,e[7]=c,e[8]=l):l=e[8],l},"LunoraProvider"),$e=o(()=>{let t=(0,$.use)(Ut);if(!t)throw new m("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"useLunora");var Qt=R(nt(),1),Ht=R(q(),1);var Ir=o(()=>{let t=(0,Qt.c)(4),e=$e(),r,s,n;return t[0]!==e?(r=o(i=>e.onConnectionStatus(()=>{i()}),"t0"),s=o(()=>e.connectionStatus(),"t1"),n=o(()=>e.connectionStatus(),"t2"),t[0]=e,t[1]=r,t[2]=s,t[3]=n):(r=t[1],s=t[2],n=t[3]),(0,Ht.useSyncExternalStore)(r,s,n)},"useConnectionStatus");var qt=o(()=>{let t=null;return{get:o(()=>t,"get"),set:o(e=>{t=e},"set")}},"createInMemoryBookmarkStorage");var Bt="_creationTime",_r=o(t=>{if(typeof t!="object"||t===null)return;let e=t._id;return typeof e=="string"?e:void 0},"rowId"),kr=o((t,e)=>{let r=e[Bt];if(typeof r!="number")return t.length;for(let[s,n]of t.entries()){let i=n[Bt];if(typeof i=="number"&&i>r)return s}return t.length},"insertionIndex"),jt=o(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"isMutationDelta"),Kt=o((t,e)=>{if(!Array.isArray(t))return;let r=[];for(let c of t){if(_r(c)===void 0)return;r.push(c)}let{key:s,op:n,row:i}=e;if(n==="delete"){let c=r.filter(h=>h._id!==s);return c.length===r.length?[...r]:c}if(i===void 0)return;let a=r.findIndex(c=>c._id===s);if(a===-1){let c=[...r];return c.splice(kr(r,i),0,i),c}let u=[...r];return u[a]=i,u},"applyDelta");var _e=o((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"foldOptimistic"),ce=o((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"notifySubscription"),Ge=o((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),ce(t,r);let n=o(()=>{let a=t.optimisticLayers.findIndex(u=>u.id===s.id);return a===-1?!1:(t.optimisticLayers.splice(a,1),!0)},"remove"),i=o(()=>{ce(t,_e(t.serverBase,t.optimisticLayers))},"refold");return{confirm:o(a=>{if(a===void 0){n();return}s.commitCursor=a,t.serverCursor!==void 0&&t.serverCursor>=a&&n()&&i()},"confirm"),rollback:o(()=>{n()&&i()},"rollback")}},"applyOptimisticLayer"),Ve=o((t,e)=>{if(e===void 0||t.optimisticLayers.length===0)return!1;let r=t.optimisticLayers.length;return t.optimisticLayers=t.optimisticLayers.filter(s=>s.commitCursor===void 0||s.commitCursor>e),t.optimisticLayers.length!==r},"dropConfirmedLayers"),$t=o((t,e,r)=>{let s=[],n=[],i=o((u,c)=>{for(let h of t.all())if(h.fn.__lunoraRef===u&&h.shardKey===e&&h.argsKey===c)return h},"findState");return{confirms:s,rollbacks:n,store:{getAllQueries:o(u=>{let c=[];for(let h of t.all())h.fn.__lunoraRef===u.__lunoraRef&&h.shardKey===e&&c.push({args:h.args,value:h.lastValue});return c},"getAllQueries"),getQuery:o((u,c)=>i(u.__lunoraRef,r(c??{}))?.lastValue,"getQuery"),setQuery:o((u,c,h)=>{let d=i(u.__lunoraRef,r(c??{}));if(!d)return;let l=Ge(d,()=>h);l&&(s.push(l.confirm),n.push(l.rollback))},"setQuery")}}},"createLocalStore");var Rr=o((t,e)=>t<e?-1:t>e?1:0,"compareKeys"),X=o(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) \u2014 pass it as a string");if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(i=>X(i)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let i=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a cache key (query/subscription/shape args) \u2014 only plain objects, arrays, and JSON primitives are supported`)}let r=t,s=Object.keys(r).toSorted(Rr),n=[];for(let i of s){let a=r[i];a!==void 0&&n.push(`${JSON.stringify(i)}:${X(a)}`)}return`{${n.join(",")}}`},"stableStringify"),Y=class t{static{o(this,"SubscriptionRegistry")}static key(e,r,s){return`${e}::${X(r)}::${s??""}`}byKey=new Map;byId=new Map;get(e){return this.byKey.get(e)}getById(e){return this.byId.get(e)}add(e){this.byKey.set(t.key(e.fn.__lunoraRef,e.args,e.shardKey),e),this.byId.set(e.id,e)}remove(e){this.byKey.delete(t.key(e.fn.__lunoraRef,e.args,e.shardKey)),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var ze=o((t,e)=>t!==void 0&&e!==t,"isStaleVersion"),Gt=0,Re=o(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();Gt+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?[...crypto.getRandomValues(new Uint8Array(8))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`m_${Date.now().toString(36)}_${Gt.toString(36)}_${t}`},"nextId"),Z=o((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"reportPersistenceError"),ke=class{static{o(this,"OfflineQueue")}queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(e={},r={}){this.maxItems=e.maxItems??1e3,this.queueBeforeFirstConnect=e.queueBeforeFirstConnect??!1,this.onPersistenceError=e.onPersistenceError,this.persistence=r.persistence,this.onEvict=r.onEvict,this.onSizeChange=r.onSizeChange,this.version=r.version}get size(){return this.items.length}enqueue(e){let r=e;for(r.id??=Re(),this.items.push(r),this.persistence?.append({args:r.args,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{Z(this.onPersistenceError,"append",s,r.id)});this.items.length>this.maxItems;){let s=this.items.shift();if(s){s.id&&this.persistence?.remove(s.id).catch(i=>{Z(this.onPersistenceError,"remove",i,s.id)});let n=new Error("offline queue overflow");n.code="OFFLINE_QUEUE_OVERFLOW",s.reject(n),this.onEvict?.(s,n)}}this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(s){throw Z(this.onPersistenceError,"load",s),s}let r=new Set;for(let s of e)if(!this.items.some(n=>n.id===s.id)){if(ze(this.version,s.version)){this.persistence.remove(s.id).catch(n=>{Z(this.onPersistenceError,"remove",n,s.id)});continue}this.items.push({args:s.args,functionPath:s.functionPath,id:s.id,identity:s.identity,reject:o(()=>{},"reject"),resolve:o(()=>{},"resolve"),shardKey:s.shardKey}),r.add(s.shardKey)}return this.notifySize(),[...r]}drain(e){if(!e){let n=[...this.items];return this.items.length=0,this.notifySize(),n}let r=[],s=[];for(let n of this.items)(e(n)?r:s).push(n);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}clear(){for(let e of this.items){let r=new Error("CLIENT_CLOSED");r.code="CLIENT_CLOSED",e.reject(r)}this.items.length=0,this.notifySize()}notifySize(){this.onSizeChange?.(this.items.length)}};var Or="lunora-outbox",Pr="offline-mutations",Vt="by_id",ue=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),xr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new m("INTERNAL","createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??Or,s=t.storeName??Pr,n,i=o(()=>n||(n=new Promise((u,c)=>{let h=e.open(r,1);h.addEventListener("upgradeneeded",()=>{let d=h.result;d.objectStoreNames.contains(s)||d.createObjectStore(s,{autoIncrement:!0}).createIndex(Vt,"id",{unique:!0})}),h.addEventListener("success",()=>{u(h.result)}),h.addEventListener("error",()=>{c(h.error??new Error("IndexedDB open failed"))})}),n),"openDatabase"),a=o(async(u,c)=>{let d=(await i()).transaction(s,u),l=await c(d.objectStore(s));return await new Promise((f,p)=>{d.addEventListener("complete",()=>{f()}),d.addEventListener("error",()=>{p(d.error??new Error("IndexedDB transaction failed"))}),d.addEventListener("abort",()=>{p(d.error??new Error("IndexedDB transaction aborted"))})}),l},"withStore");return{append:o(async u=>{await a("readwrite",c=>ue(c.add(u)))},"append"),clear:o(async()=>{await a("readwrite",u=>ue(u.clear()))},"clear"),load:o(async()=>a("readonly",u=>ue(u.getAll())),"load"),remove:o(async u=>{await a("readwrite",async c=>{let h=await ue(c.index(Vt).getKey(u));h!==void 0&&await ue(c.delete(h))})},"remove")}},"createIndexedDbPersistence"),zt=o((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return xr()}},"resolvePersistenceAdapter");var We=o((t,e,r)=>`${t}::${e}::${r??""}`,"queryCacheKey"),Lr=500;var Fr="lunora-query-cache",Mr="query-cache",Wt="by_ts",Nr=1,he=o(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"promisifyRequest"),Dr=o((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new m("INTERNAL","createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??Fr,s=t.storeName??Mr,n=t.maxEntries??Lr,i,a=o(()=>i||(i=new Promise((h,d)=>{let l=e.open(r,Nr);l.addEventListener("upgradeneeded",()=>{let f=l.result;f.objectStoreNames.contains(s)||f.createObjectStore(s,{keyPath:"key"}).createIndex(Wt,"ts",{unique:!1})}),l.addEventListener("success",()=>{h(l.result)}),l.addEventListener("error",()=>{d(l.error??new Error("IndexedDB open failed"))})}),i),"openDatabase"),u=o(async(h,d)=>{let f=(await a()).transaction(s,h),p=await d(f.objectStore(s));return await new Promise((g,y)=>{f.addEventListener("complete",()=>{g()}),f.addEventListener("error",()=>{y(f.error??new Error("IndexedDB transaction failed"))}),f.addEventListener("abort",()=>{y(f.error??new Error("IndexedDB transaction aborted"))})}),p},"withStore"),c=o(async h=>{let l=await he(h.count())-n;l<=0||await new Promise((f,p)=>{let g=h.index(Wt).openCursor();g.addEventListener("success",()=>{let y=g.result;if(!y||l<=0){f();return}y.delete(),l-=1,y.continue()}),g.addEventListener("error",()=>{p(g.error??new Error("IndexedDB eviction failed"))})})},"evict");return{clear:o(async()=>{await u("readwrite",h=>he(h.clear()))},"clear"),load:o(async()=>u("readonly",h=>he(h.getAll())),"load"),put:o(async(h,d)=>{await u("readwrite",async l=>{await he(l.put({...d,key:h})),await c(l)})},"put"),remove:o(async h=>{await u("readwrite",d=>he(d.delete(h)))},"remove")}},"createIndexedDbQueryCache"),Jt=o(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return Dr()}},"resolveQueryCacheAdapter");var Je=o((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,n=t.jitter??!0,i=0;return{next(){let a=Math.min(s,r*2**i);if(i+=1,!n)return a;let u=a/2;return Math.floor(u+e()*(a-u))},reset(){i=0}}},"createReconnect");var Xt=o(t=>{let e=t.maxBuffer??1024,r=[],s=[],n=!1,i,a=!1,u=o(()=>{let l=s.shift();if(!l)return!1;if(i)return l.reject(i),!0;if(r.length>0){let f=r.shift();return l.resolve({done:!1,value:f}),!0}return n?(l.resolve({done:!0,value:void 0}),!0):(s.unshift(l),!1)},"flushOne"),c={complete(){if(!(n||i))for(n=!0;u(););},fail(l){if(!(n||i))for(i=l,r.length=0;u(););},push(l){if(!(n||i||a)){if(r.length>=e){c.fail(Object.assign(new Error(`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`),{code:"STREAM_BACKPRESSURE"}));return}r.push(l),u()}}},h=o(()=>{if(!a){a=!0,n=!0,r.length=0;try{t.onCancel()}catch{}for(;u(););}},"cancel");return{handle:c,iterable:{cancel:h,[Symbol.asyncIterator](){return{next(){if(i)return Promise.reject(i);if(r.length>0){let l=r.shift();return Promise.resolve({done:!1,value:l})}return n?Promise.resolve({done:!0,value:void 0}):new Promise((l,f)=>{s.push({reject:f,resolve:l})})},return(){return h(),Promise.resolve({done:!0,value:void 0})}}}}}},"createStream");var Xe=500,C="$lunora.wire$",Pe=64,Yt=1024,Zt="__proto__",er={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},tr={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},Ye=o(t=>{let e="";for(let s=0;s<t.length;s+=32768)e+=String.fromCharCode(...t.subarray(s,s+32768));return btoa(e)},"toBase64"),Ur=o(t=>{let e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s+=1)r[s]=e.codePointAt(s)??0;return r},"fromBase64"),N=o((t,e=0)=>{if(e>Pe)throw new RangeError(`wire-codec: value nesting exceeds the ${Pe}-level limit`);if(t===void 0)return[C,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[C,"bigint",t.toString()];if(r==="number"){let a=t;return Number.isNaN(a)?[C,"nan"]:a===1/0?[C,"inf"]:a===-1/0?[C,"-inf"]:a}if(r!=="object")return t;if(t instanceof Date)return[C,"date",N(t.getTime(),e+1)];if(t instanceof Error){let a=t,u={};for(let h of Object.keys(a))a[h]!==void 0&&(u[h]=N(a[h],e+1));let c=[C,"error",a.name,a.message,u];return a.cause!==void 0&&c.push(N(a.cause,e+1)),c}if(t instanceof URL)return[C,"url",t.href];if(t instanceof Map)return[C,"map",[...t.entries()].map(([a,u])=>[N(a,e+1),N(u,e+1)])];if(t instanceof Set)return[C,"set",[...t].map(a=>N(a,e+1))];if(t instanceof ArrayBuffer)return[C,"bytes",Ye(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let a=t,u=a.constructor.name,c=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);return u==="Uint8Array"?[C,"bytes",Ye(c)]:[C,"bytes",Ye(c),u]}if(Array.isArray(t)){let a=t.map(u=>N(u,e+1));return a.length>0&&a[0]===C?[C,"arr",a]:a}let s=Object.getPrototypeOf(t);if(s!==null&&s!==Object.prototype){let a=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${a} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let n=t,i={};for(let a of Object.keys(n)){let u=n[a];u!==void 0&&(i[a]=N(u,e+1))}return i},"encodeWire"),w=o((t,e=0)=>{if(e>Pe)throw new RangeError(`wire-codec: value nesting exceeds the ${Pe}-level limit`);if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===C)switch(t[1]){case"-inf":return-1/0;case"arr":return t[2].map(i=>w(i,e+1));case"bigint":{let i=t[2];if(typeof i!="string"||i.length>Yt||!/^-?\d+$/.test(i))throw new RangeError(`wire-codec: invalid or over-long bigint (max ${Yt} digits)`);return BigInt(i)}case"date":return new Date(w(t[2],e+1));case"map":return new Map(t[2].map(([i,a])=>[w(i,e+1),w(a,e+1)]));case"set":return new Set(t[2].map(i=>w(i,e+1)));case"url":return new URL(t[2]);case"error":{let i=t[2],a=t[3],u=(Object.hasOwn(tr,i)?tr[i]:void 0)??Error,c=new u(a);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let h=w(t[4],e+1);for(let d of Object.keys(h))d===Zt?Object.defineProperty(c,d,{configurable:!0,enumerable:!0,value:h[d],writable:!0}):c[d]=h[d];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:w(t[5],e+1),writable:!0}),c}case"bytes":{let i=Ur(t[2]),a=t[3]??"Uint8Array";if(a==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let u=Object.hasOwn(er,a)?er[a]:void 0;return u?new u(i.slice().buffer):i}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return t.map(i=>w(i,e+1))}return t.map(n=>w(n,e+1))}let r=t,s={};for(let n of Object.keys(r)){let i=w(r[n],e+1);n===Zt?Object.defineProperty(s,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):s[n]=i}return s},"decodeWire"),V=class{static{o(this,"Listeners")}listeners=new Set;add(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(...e){let[r]=e;for(let s of this.listeners)try{s(r)}catch{}}clear(){this.listeners.clear()}},Qr="/_lunora/rpc",rr="/_lunora/rpc-batch",Hr="/_lunora/ws",Ze=o(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"bucketQuery"),et=o(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"rollbackOptimistic"),qr=o((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"applyRowOpsToView"),Br="lunora-ping",jr=3e4,Kr=1e4,$r=250,Gr=64,Vr="/_lunora/admin/shard-traffic",zr="/_lunora/admin/scheduled",Wr="/_lunora/admin/scheduled/status",Jr="/_lunora/admin/scheduled/ws",Xr="/_lunora/admin/scheduled/cancel",Yr="/_lunora/admin/scheduled/dead",Zr="/_lunora/admin/scheduled/dead/retry",es="/_lunora/admin/scheduled/dead/cancel",ts="/_lunora/admin/workflows/instances",rs="/_lunora/admin/workflows/instance",ss="/_lunora/admin/workflows/status",Oe="/_lunora/admin/storage",ns="/_lunora/admin/storage/url",is="/_lunora/admin/storage/buckets",os="/_lunora/admin/functions",as="/_lunora/admin/cron-jobs",cs="/_lunora/admin/cron-jobs/run",us="/_lunora/admin/openapi",hs="/_lunora/admin/openrpc",ds="/_lunora/admin/global/tables",ls="/_lunora/admin/global/table",fs="/_lunora/admin/global/facet",ms="/_lunora/admin/vector/indexes",ps="/_lunora/admin/vector/query",ys="/_lunora/admin/kv/namespaces",gs="/_lunora/admin/kv/keys",tt="/_lunora/admin/kv/value",vs="/_lunora/admin/auth/users",sr="/_lunora/admin/auth/sessions",bs="/_lunora/admin/auth/users/create",Ss="/_lunora/admin/auth/users/role",ws="/_lunora/admin/auth/users/ban",Es="/_lunora/admin/auth/users/unban",Ts="/_lunora/admin/auth/users/password",Cs="/_lunora/admin/auth/users/remove",As="/_lunora/admin/auth/users/impersonate",Is="/_lunora/admin/auth/sessions/revoke",_s="/_lunora/admin/auth/sessions/revoke-all",ks="/_lunora/admin/auth/capabilities",Rs="/_lunora/admin/auth/users/update",Os="/_lunora/admin/auth/accounts",Ps="/_lunora/admin/auth/accounts/unlink",xs="/_lunora/admin/auth/passkeys",Ls="/_lunora/admin/auth/passkeys/delete",Fs="/_lunora/admin/auth/two-factor/disable",Ms="/_lunora/admin/auth/organizations",Ns="/_lunora/admin/auth/organizations/members",Ds="/_lunora/admin/auth/organizations/invitations",Us="/_lunora/admin/auth/organizations/members/remove",Qs="/_lunora/admin/auth/organizations/invitations/cancel",Hs="/_lunora/admin/auth/config",qs="/_lunora/admin/auth/organizations/create",Bs="/_lunora/admin/auth/organizations/update",js="/_lunora/admin/auth/organizations/remove",Ks="/_lunora/admin/auth/organizations/members/add",$s="/_lunora/admin/auth/organizations/members/invite",Gs="/_lunora/admin/auth/organizations/members/role",Vs="/_lunora/admin/auth/organizations/teams",zs="/_lunora/admin/auth/organizations/teams/create",Ws="/_lunora/admin/auth/organizations/teams/update",Js="/_lunora/admin/auth/organizations/teams/remove",Xs="/_lunora/admin/auth/organizations/teams/members",Ys="/_lunora/admin/auth/organizations/teams/members/add",Zs="/_lunora/admin/auth/organizations/teams/members/remove",en="/_lunora/admin/auth/organizations/roles",tn="/_lunora/admin/auth/organizations/roles/create",rn="/_lunora/admin/auth/organizations/roles/update",sn="/_lunora/admin/auth/organizations/roles/remove",nn="/api/auth",on="/get-session",nr=o(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"deriveWsUrl"),G=o((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"joinUrl"),O=o((t,e)=>{let r=new URLSearchParams;for(let[n,i]of Object.entries(e))i!==void 0&&i!==""&&r.set(n,String(i));let s=r.toString();return s===""?t:`${t}?${s}`},"withQuery"),T=o(t=>t??"","connectionKey"),an=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0,n=(typeof t.message=="string"?t.message:void 0)??s??"stream error";return Object.assign(new Error(n),r===void 0?void 0:{code:r})},"buildStreamError"),ir=o(t=>{let e=t.error,r=typeof e?.code=="string"?e.code:void 0,s=typeof e?.message=="string"?e.message:void 0;return{message:(typeof t.message=="string"?t.message:void 0)??s??"subscription error",...r===void 0?{}:{code:r}}},"buildSubscriptionError"),or=o((t,e)=>{for(let r of t)try{r(e)}catch{}},"fanSubscriptionError"),cn=new TextDecoder,un=o(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return cn.decode(t)},"decodeServerFrame"),_=o((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"sendOn"),de=o(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=w(t.data)),t.hint!==void 0&&(e.hint=t.hint),t.docsUrl!==void 0&&(e.docsUrl=t.docsUrl),e},"reconstructError"),ee=o((t,e)=>{try{return N(t)}catch(r){let s=r instanceof Error?r.message:String(r);throw new TypeError(`LunoraClient: cannot encode ${e} \u2014 ${s}`,r instanceof Error?{cause:r}:void 0)}},"encodeCallArgs"),hn=o((t,e)=>{let r=Array.from({length:e});for(let s of t){if(typeof s.id!="number"||s.id<0||s.id>=e)continue;let n=s.body;r[s.id]=n&&"error"in n&&n.error?{error:de(n.error),ok:!1}:{ok:!0,value:w(n?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"demuxBatchResults"),dn=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),rt=class t{static{o(this,"LunoraClient")}static MAX_POKE_BUFFERS=256;url;wsUrl;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new Y;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;closed=!1;authTokenListeners=new V;statusListeners=new V;tokenExpiredListeners=new V;mutationSettledListeners=new V;pendingChangeListeners=new V;whisperHandlers=new Map;lastStatus="idle";nextSubId=0;nextStreamId=0;streams=new Map;shapeSubscriptions=new Map;pokeBuffers=new Map;nextShapeId=0;constructor(e){this.url=e.url,this.wsUrl=e.wsUrl??G(nr(e.url),Hr),this.wsToken=e.wsToken;let r=e.authBasePath??nn;this.authBasePath=r.endsWith("/")?r.slice(0,-1):r,this.fetchImpl=e.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0),this.WebSocketImpl=e.WebSocket??(typeof WebSocket=="function"?WebSocket:void 0),this.bookmark=e.bookmarkStorage??qt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??jr,this.connectTimeoutMs=e.connectTimeoutMs??Kr,this.defaultConnectionContext=e.connectionContext,this.persistence=zt(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=Jt(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.offlineQueue=new ke(e.offlineQueue,{onEvict:o((s,n)=>{this.emitItemSettled(s,"rejected",n)},"onEvict"),onSizeChange:o(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${Re()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{this.hydrateQueryCache().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,n=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let i=this.identityFingerprint();i!==n&&(s?this.rejectQueuedForIdentityChange():this.restampQueuedIdentity(n,i)),s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(e??"")??0}async callMutator(e,r,s){let n=s?.clientSeq;if(n!==void 0&&(!Number.isInteger(n)||n<=0))throw new m("INTERNAL",`callMutator: clientSeq must be a positive integer, got ${String(n)}`);let i=s?.shardKey??"",a,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:n,onMutationAck:o(h=>{a=h},"onMutationAck")});return a!==void 0&&a>(this.clientWatermarks.get(i)??0)&&this.clientWatermarks.set(i,a),{applied:a===void 0||a===n,result:u}}onAuthTokenChange(e){return this.authTokenListeners.add(e)}async getCurrentUser(){if(this.closed||!this.fetchImpl)return null;let e={};this.authToken&&(e.authorization=`Bearer ${this.authToken}`);try{let r=await this.fetchImpl(G(this.url,`${this.authBasePath}${on}`),{credentials:"include",headers:e,method:"GET"});return r.ok?(await r.json())?.user??null:null}catch{return null}}setWsToken(e){if(this.wsToken!==e){this.wsToken=e;for(let r of this.connections.values())if(r.socket)try{r.socket.close()}catch{}}}setConnectionContext(e,r={}){let s=T(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=T(r.shardKey),n={context:e},i=this.connectionContextHolders.get(s);i?i.push(n):this.connectionContextHolders.set(s,[n]),this.refreshConnectionContext(s);let a=!1;return()=>{if(a)return;a=!0;let u=this.connectionContextHolders.get(s);if(!u)return;let c=u.indexOf(n);c!==-1&&u.splice(c,1),u.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let n=T(s.shardKey),i=this.whisperHandlers.get(n);i||(i=new Map,this.whisperHandlers.set(n,i));let a=i.get(e),u=a===void 0;if(a||(a=new Set,i.set(e,a)),a.add(r),this.ensureSocket(s.shardKey),u){let c=this.getConnection(s.shardKey);c&&_(c,{topic:e,type:"whisper_subscribe"})}return()=>{let c=this.whisperHandlers.get(n),h=c?.get(e);if(!h?.delete(r)||h.size>0)return;c?.delete(e),c?.size===0&&this.whisperHandlers.delete(n);let d=this.getConnection(s.shardKey);d&&_(d,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let n=this.getConnection(s.shardKey);n&&_(n,{data:ee(r??null,`whisper data for topic '${e}'`),topic:e,type:"whisper"})}onTokenExpired(e){return this.tokenExpiredListeners.add(e)}connectionStatus(){return this.computeStatus()}onConnectionStatus(e){let r=this.statusListeners.add(e);return e(this.computeStatus()),r}pendingCount(){return this.offlineQueue.size}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}async query(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl(G(this.url,rr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args??{},`args for batch call '${i.fn.__lunoraRef}'`),functionPath:i.fn.__lunoraRef,id:a,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{throw new m("INTERNAL",`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||n.error&&!n.results)throw n.error?de(n.error):new m("INTERNAL",`LunoraClient: batch request failed (status ${r.status.toString()})`);return hn(n.results??[],e.length)}async mutation(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let n=r,i=s.mutationId??Re(),{confirms:a,rollbacks:u}=this.applyOptimisticUpdates(e.__lunoraRef,n,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,u,a);let c=this.getConnection(s.shardKey),h=c?.wsState??"idle",d=c?.socket!==void 0,l=c?.wasEverConnected??!1,{queueBeforeFirstConnect:f}=this.offlineQueue,p=l||f,g=this.WebSocketImpl!==void 0&&p;if(h!=="open"&&!d&&g||h==="connecting"&&p)return this.enqueueOfflineMutation(e,n,s.shardKey,i,u,a);try{let b,E=await this.rpc(e.__lunoraRef,n,s.shardKey,{captureBookmark:!0,mutationId:i,onCommitCursor:o(A=>{b=A},"onCommitCursor")});for(let A of a)A(b);return E}catch(b){throw et(u),b}}async action(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.rpc(e.__lunoraRef,r,s.shardKey)}async shardTraffic(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(Vr,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(zr,"GET")).records??[]}async schedulerStatus(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let e=await this.adminFetch(Wr,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{cancelled:(await this.adminFetch(Xr,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(Yr,"GET")).records??[]}async retryDeadJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{retried:(await this.adminFetch(Zr,"POST",{id:e})).retried===!0}}async removeDeadJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{removed:(await this.adminFetch(es,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({name:e.name});e.status!==void 0&&r.set("status",e.status),e.page!==void 0&&r.set("page",String(e.page)),e.perPage!==void 0&&r.set("perPage",String(e.perPage));let s=await this.adminFetch(`${ts}?${r.toString()}`,"GET");return{configured:s.configured,instances:s.instances??[],page:s.page??1,perPage:s.perPage??e.perPage??0,totalCount:s.totalCount}}async getWorkflowInstance(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${rs}?${r.toString()}`,"GET");return{createdOn:s.createdOn,endedOn:s.endedOn,error:s.error,id:s.id??e.id,output:s.output,params:s.params,startedOn:s.startedOn,status:s.status??"unknown",steps:s.steps??[]}}async setWorkflowInstanceStatus(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return{status:(await this.adminFetch(ss,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)return()=>{};let r=G(nr(this.url),Jr),s=Je(this.reconnectOptions),n,i,a=!1,u=o(()=>{if(a||this.WebSocketImpl===void 0)return;let c=this.wsToken===void 0?r:`${r}?token=${encodeURIComponent(this.wsToken)}`;n=new this.WebSocketImpl(c),n.addEventListener("open",()=>{s.reset()}),n.addEventListener("message",h=>{try{let d=JSON.parse(typeof h.data=="string"?h.data:"");d.type==="jobs"&&Array.isArray(d.records)&&e(d.records)}catch{}}),n.addEventListener("close",()=>{n=void 0,a||(i=setTimeout(u,s.next()))}),n.addEventListener("error",()=>{})},"connect");return u(),()=>{a=!0,i!==void 0&&clearTimeout(i),n?.close()}}async listFunctions(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(os,"GET")).functions??[]}async getCronJobs(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(as,"GET")).jobs??[]}async runCronJob(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=await this.adminFetch(cs,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(us,"GET")}async fetchOpenRpc(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(hs,"GET")}async listStorageObjects(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.prefix!==void 0&&e.prefix!==""&&r.set("prefix",e.prefix),e.cursor!==void 0&&e.cursor!==""&&r.set("cursor",e.cursor),e.limit!==void 0&&r.set("limit",String(e.limit)),e.bucket!==void 0&&e.bucket!==""&&r.set("bucket",e.bucket);let s=r.toString(),n=s===""?Oe:`${Oe}?${s}`,i=await this.adminFetch(n,"GET");return{cursor:i.cursor,objects:i.objects??[]}}async deleteStorageObject(e,r){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let s=`${Oe}?key=${encodeURIComponent(e)}${Ze(r?.bucket)}`,n=await this.adminFetch(s,"DELETE");return{deleted:n.deleted??!0,key:n.key??e}}async listStorageBuckets(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(is,"GET")).buckets??[]}async uploadStorageObject(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=`${Oe}?key=${encodeURIComponent(e.key)}${Ze(e.bucket)}`,s=await this.adminFetch(r,"PUT",e.body,e.contentType);return{etag:s.etag,key:s.key??e.key}}async signedStorageUrl(e,r){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let s=r?.expiresInSeconds,n=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,i=`${ns}?key=${encodeURIComponent(e)}${n}${Ze(r?.bucket)}`,a=await this.adminFetch(i,"GET");if(typeof a.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return a.url}async listGlobalTables(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return await this.adminFetch(ds,"GET")}async readGlobalTablePage(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${ls}?${r.toString()}`,"GET")}async facetGlobalColumn(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams({column:e.column,table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${fs}?${r.toString()}`,"GET")}async listVectorIndexes(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ms,"GET")).indexes??[]}async queryVectorIndex(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ps,"POST",e)).matches??[]}async listKvNamespaces(){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");return(await this.adminFetch(ys,"GET")).namespaces??[]}async listKvKeys(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(gs,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(tt,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");await this.adminFetch(tt,"PUT",e)}async deleteKvKey(e){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(tt,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=O(vs,{filterField:e.filterField,filterValue:e.filterValue,limit:e.limit,offset:e.offset,search:e.search,searchField:e.searchField,sortBy:e.sortBy,sortDirection:e.sortDirection});return await this.adminFetch(r,"GET")}async createAuthUser(e){return await this.adminFetch(bs,"POST",e)}async setAuthUserRole(e){return await this.adminFetch(Ss,"POST",e)}async banAuthUser(e){return await this.adminFetch(ws,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(Es,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(Ts,"POST",e)}async removeAuthUser(e){await this.adminFetch(Cs,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(As,"POST",e)}async revokeAuthSession(e){await this.adminFetch(Is,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(_s,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(ks,"GET")}async updateAuthUser(e){return await this.adminFetch(Rs,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(O(Os,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(Ps,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(O(xs,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(Ls,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(Fs,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(O(Ms,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=O(Ns,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=O(Ds,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(Us,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(Qs,"POST",e)}async getAuthConfig(){return await this.adminFetch(Hs,"GET")}async createAuthOrganization(e){return await this.adminFetch(qs,"POST",e)}async updateAuthOrganization(e){return await this.adminFetch(Bs,"POST",e)}async deleteAuthOrganization(e){await this.adminFetch(js,"POST",e)}async addAuthOrgMember(e){return await this.adminFetch(Ks,"POST",e)}async inviteAuthOrgMember(e){return await this.adminFetch($s,"POST",e)}async setAuthOrgMemberRole(e){return await this.adminFetch(Gs,"POST",e)}async listAuthOrgTeams(e){let r=O(Vs,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgTeam(e){return await this.adminFetch(zs,"POST",e)}async updateAuthOrgTeam(e){return await this.adminFetch(Ws,"POST",e)}async removeAuthOrgTeam(e){await this.adminFetch(Js,"POST",e)}async listAuthOrgTeamMembers(e){let r=O(Xs,{limit:e.limit,offset:e.offset,teamId:e.teamId});return await this.adminFetch(r,"GET")}async addAuthOrgTeamMember(e){return await this.adminFetch(Ys,"POST",e)}async removeAuthOrgTeamMember(e){await this.adminFetch(Zs,"POST",e)}async listAuthOrgRoles(e){let r=O(en,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgRole(e){return await this.adminFetch(tn,"POST",e)}async updateAuthOrgRole(e){return await this.adminFetch(rn,"POST",e)}async deleteAuthOrgRole(e){await this.adminFetch(sn,"POST",e)}async listAuthSessions(e={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let r=new URLSearchParams;e.userId!==void 0&&e.userId!==""&&r.set("userId",e.userId),e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset));let s=r.toString();return await this.adminFetch(s===""?sr:`${sr}?${s}`,"GET")}subscribe(e,r,s,n={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");let i=r??{},a=Y.key(e.__lunoraRef,i,n.shardKey),u=this.subscriptions.get(a),c=s,h=n.onError;if(!u){this.nextSubId+=1;let l=`sub_${this.nextSubId.toString()}`,f=X(i),p=this.takeHydratedCache(e.__lunoraRef,f,n.shardKey);u={acked:!1,args:i,argsKey:f,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:l,lastValue:p?.value,optimisticLayers:[],serverBase:p?.value,serverCursor:p?.serverCursor,shardKey:n.shardKey,...p?.serverEpoch===void 0?{}:{serverEpoch:p.serverEpoch}},this.subscriptions.add(u)}if(u.callbacks.add(c),h&&u.errorCallbacks.add(h),n.onCheckpoint&&u.checkpointCallbacks.add(n.onCheckpoint),u.lastValue!==void 0)try{c(u.lastValue)}catch{}this.ensureSocket(n.shardKey),this.sendSubscribeIfOpen(u);let d=u;return()=>{if(d.callbacks.delete(c),h&&d.errorCallbacks.delete(h),n.onCheckpoint&&d.checkpointCallbacks.delete(n.onCheckpoint),d.callbacks.size===0){let l=this.getConnection(d.shardKey);!(l&&_(l,{id:d.id,type:"unsubscribe"}))&&l&&l.pendingUnsubscribes.push({id:d.id,type:"unsubscribe"}),this.subscriptions.remove(d)}}}subscribeShape(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");this.nextShapeId+=1;let n=`shape_${this.nextShapeId.toString()}`,i={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:n,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey};return this.shapeSubscriptions.set(n,i),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(i),()=>{this.shapeSubscriptions.delete(n);let a=this.getConnection(i.shardKey);!(a&&_(a,{id:n,type:"shape_unsubscribe"}))&&a&&a.pendingUnsubscribes.push({id:n,type:"shape_unsubscribe"})}}stream(e,r,s={}){if(this.closed)throw new m("INTERNAL","LunoraClient is closed");if(this.WebSocketImpl===void 0)throw new m("INTERNAL","LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let n=`stream_${this.nextStreamId.toString()}`,{shardKey:i}=s,a=r??{},{handle:u,iterable:c}=Xt({maxBuffer:s.maxBuffer,onCancel:o(()=>{let f=this.getConnection(i);f&&_(f,{id:n,type:"unsubscribe"}),this.streams.delete(n)},"onCancel")});this.streams.set(n,{handle:u,shardKey:i}),this.ensureSocket(i);let h=this.getConnection(i),d={id:n,query:{args:ee(a,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:i},type:"stream"};if(!(h?.wsState==="open"&&_(h,d))&&h){for(h.pendingStreams=h.pendingStreams??[];h.pendingStreams.length>=Gr;){let p=h.pendingStreams.shift()?.id,g=p?this.streams.get(p):void 0;g&&(g.handle.fail(Object.assign(new Error("stream-start frame evicted while socket was unreachable"),{code:"STREAM_QUEUE_OVERFLOW"})),this.streams.delete(p))}h.pendingStreams.push(d)}return c}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(Object.assign(new Error("LunoraClient closed"),{code:"CLIENT_CLOSED"}));this.streams.clear();for(let e of this.connections.values()){if(e.reconnectTimer!==void 0&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=void 0),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),this.stopHeartbeat(e),e.socket){try{e.socket.close()}catch{}e.socket=void 0}e.wsState="closed"}this.offlineQueue.clear(),this.queuedIdentities.clear(),this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.size>0&&this.flushQueryCacheWrites().catch(()=>{}),this.authTokenListeners.clear(),this.statusListeners.clear(),this.tokenExpiredListeners.clear(),this.mutationSettledListeners.clear(),this.pendingChangeListeners.clear(),this.whisperHandlers.clear(),this.shapeSubscriptions.clear(),this.pokeBuffers.clear()}async enqueueOfflineMutation(e,r,s,n,i,a){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let c=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(c)}`,identity:u,mutationId:c,shardKey:s})}catch(h){throw et(i),h instanceof Error?h:new Error(String(h))}for(let h of a)h(void 0);return}return new Promise((c,h)=>{let d={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:n,identity:u,onCommit:o(l=>{for(let f of a)f(l)},"onCommit"),reject:o(l=>{this.queuedIdentities.delete(n),et(i),h(l instanceof Error?l:new Error(String(l)))},"reject"),resolve:c,shardKey:s};this.offlineQueue.enqueue(d),d.id!==void 0&&this.queuedIdentities.set(d.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=o(()=>{this.hydratePersistedQueue().catch(()=>{})},"hydrate"),r=globalThis.navigator?.locks;if(!r){e();return}r.request(`lunora:outbox-leader:${this.url}`,()=>(this.closed||e(),new Promise(s=>{if(this.closed){s();return}this.outboxLeaderRelease=s}))).catch(e)}async hydrateQueryCache(){if(this.queryCache)try{let e=await this.queryCache.load();for(let{key:r,...s}of e){if(ze(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let n=We(e,r,s),i=this.hydratedQueryCache.get(n);if(i!==void 0)return this.hydratedQueryCache.delete(n),i.identity===this.identityFingerprint()?i:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=We(e.fn.__lunoraRef,e.argsKey,e.shardKey);this.pendingCacheWrites.set(s,{identity:this.identityFingerprint(),serverCursor:e.serverCursor,ts:Date.now(),value:r,...e.serverEpoch===void 0?{}:{serverEpoch:e.serverEpoch},...this.persistenceVersion===void 0?{}:{version:this.persistenceVersion}}),this.cacheFlushTimer??=setTimeout(()=>{this.flushQueryCacheWrites().catch(()=>{})},$r)}async flushQueryCacheWrites(){this.cacheFlushTimer=void 0;let{queryCache:e}=this;if(!e){this.pendingCacheWrites.clear();return}let r=[...this.pendingCacheWrites.entries()];this.pendingCacheWrites.clear(),await Promise.allSettled(r.map(([s,n])=>e.put(s,n)))}computeStatus(){let e=[...this.connections.values()];return e.length===0?"idle":e.some(r=>r.wsState==="open")?"connected":e.some(r=>r.wsState==="connecting")?"connecting":"offline"}emitConnectionStatus(){let e=this.computeStatus();e!==this.lastStatus&&(this.lastStatus=e,this.statusListeners.emit(e))}emitItemSettled(e,r,s){this.mutationSettledListeners.emit({args:e.args,code:s===void 0?void 0:s.code,error:s,functionPath:e.functionPath,hadAwaiter:e.liveAwaiter??!1,id:e.id??"",shardKey:e.shardKey,status:r})}applyOptimisticUpdates(e,r,s,n){let i=[],a=[];if(!n)return{confirms:i,rollbacks:a};let u=Y.key(e,r,s),c=this.subscriptions.get(u);if(c){let h=Ge(c,n);h&&(i.push(h.confirm),a.push(h.rollback))}return{confirms:i,rollbacks:a}}applyOptimisticUpdate(e,r,s,n,i){let{confirms:a,rollbacks:u,store:c}=$t(this.subscriptions,s,X);try{e(c,r)}catch{for(let h=u.length-1;h>=0;h-=1)u[h]?.();return}n.push(...u),i.push(...a)}getConnection(e){return this.connections.get(T(e))}getOrCreateConnection(e){let r=T(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,pendingUnsubscribes:[],reconnect:Je(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e){let r=[];if(e!==void 0&&r.push(`shard=${encodeURIComponent(e)}`),this.wsToken!==void 0&&r.push(`token=${encodeURIComponent(this.wsToken)}`),r.length===0)return this.wsUrl;let s=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${s}${r.join("&")}`}rpcRequestHeaders(e){let r={"content-type":"application/json"};if(this.authToken&&(r.authorization=`Bearer ${this.authToken}`),e.mutationId&&(r["x-lunora-mutation-id"]=e.mutationId),e.clientId!==void 0&&(r["x-lunora-client-id"]=e.clientId),e.clientSeq!==void 0&&(r["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let s=this.bookmark.get();s&&(r["x-d1-bookmark"]=s)}return r}async rpc(e,r,s,n={}){if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");let i=this.rpcRequestHeaders(n),a=await this.fetchImpl(G(this.url,Qr),{body:JSON.stringify({args:ee(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:i,method:"POST"});if(n.captureBookmark){let c=a.headers.get("x-d1-bookmark");c&&this.bookmark.set(c)}let u;try{u=await a.json()}catch{let c=a.statusText?` ${a.statusText}`:"";throw new m("INTERNAL",`LunoraClient: response was not JSON (status ${a.status.toString()}${c})`)}if("error"in u)throw de(u.error);if(!a.ok){let c=a.statusText?` ${a.statusText}`:"";throw new m("INTERNAL",`LunoraClient: request failed (status ${a.status.toString()}${c})`)}return n.onMutationAck?.(u.lastMutationId),n.onCommitCursor?.(u.commitCursor),w(u.result)}async adminFetch(e,r,s,n){if(!this.fetchImpl)throw new m("INTERNAL","LunoraClient: no `fetch` implementation available");let i={};this.authToken&&(i.authorization=`Bearer ${this.authToken}`);let a=s instanceof ArrayBuffer||s instanceof Blob,u;s===void 0?u=void 0:a?(u=s,n!==void 0&&(i["content-type"]=n)):(u=JSON.stringify(s),i["content-type"]="application/json");let c=await this.fetchImpl(G(this.url,e),{body:u,headers:i,method:r}),h;try{h=await c.json()}catch{let d=c.statusText?` ${c.statusText}`:"";throw new m("INTERNAL",`LunoraClient: response was not JSON (status ${c.status.toString()}${d})`)}if(typeof h=="object"&&h!==null&&"error"in h){let d=h.error,l=new Error(d.message??"admin request failed");throw l.code=d.code,l}if(!c.ok){let d=c.statusText?` ${c.statusText}`:"";throw new m("INTERNAL",`LunoraClient: admin request failed (status ${c.status.toString()}${d})`)}return h}effectiveConnectionContext(e){let r=this.connectionContextHolders.get(e);return r&&r.length>0?r[r.length-1]?.context:this.connectionContexts.get(e)??this.defaultConnectionContext}refreshConnectionContext(e){let r=this.connections.get(e);r?.wsState==="open"&&this.sendConnectEnvelope(r)}sendConnectEnvelope(e){let r=this.effectiveConnectionContext(T(e.shardKey));_(e,{clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())T(r.shardKey)===T(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0)return;let r=this.getOrCreateConnection(e);if(r.wsState==="open"||r.wsState==="connecting")return;r.wsState="connecting",this.emitConnectionStatus();let s=new this.WebSocketImpl(this.wsUrlFor(e));r.socket=s,this.connectTimeoutMs>0&&(r.connectTimer=setTimeout(()=>{if(r.connectTimer=void 0,!(r.socket!==s||r.wsState!=="connecting")){try{s.close()}catch{}this.handleDisconnect(r)}},this.connectTimeoutMs)),s.addEventListener("open",()=>{if(r.socket!==s)return;r.connectTimer!==void 0&&(clearTimeout(r.connectTimer),r.connectTimer=void 0),r.wsState="open",r.wasEverConnected=!0,r.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(r),this.markShardPendingAck(e);for(let i of this.subscriptions.all())T(i.shardKey)===T(e)&&this.sendSubscribeIfOpen(i);if(this.resendShapeSubscriptions(e),r.pendingUnsubscribes.length>0){let i=r.pendingUnsubscribes;r.pendingUnsubscribes=[];for(let{id:a,type:u}of i)_(r,{id:a,type:u})}if(r.pendingStreams&&r.pendingStreams.length>0){let i=r.pendingStreams;r.pendingStreams=[];for(let a of i)_(r,a)}let n=this.whisperHandlers.get(T(e));if(n)for(let i of n.keys())_(r,{topic:i,type:"whisper_subscribe"});this.flushOfflineQueue(e).catch(()=>{}),this.startHeartbeat(r)}),s.addEventListener("message",n=>{this.handleServerMessage(n.data,e)}),s.addEventListener("close",n=>{r.socket===s&&(n?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(r))}),s.addEventListener("error",()=>{r.socket===s&&(r.wsState==="connecting"||r.wsState==="open")&&this.handleDisconnect(r)})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed"||(this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket=void 0,e.wsState="idle",this.emitConnectionStatus(),this.markShardPendingAck(e.shardKey),this.WebSocketImpl===void 0))return;let r=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},r)}startHeartbeat(e){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!(e.wsState!=="open"||!e.socket))try{e.socket.send(Br)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=T(e);for(let s of this.subscriptions.all())T(s.shardKey)===r&&(s.acked=!1)}sendSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);if(r?.wsState!=="open"||e.acked)return;let s=e.fn.__lunoraTable??e.fn.__lunoraRef;_(r,{id:e.id,query:{args:e.args,functionPath:e.fn.__lunoraRef,table:s,...e.serverCursor===void 0?{}:{sinceSeq:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}},type:"subscribe"})}sendShapeSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);r?.wsState==="open"&&_(r,{id:e.id,shape:{name:e.name,...e.args===void 0?{}:{args:e.args}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=un(e);if(s===void 0)return;let n;try{n=JSON.parse(s)}catch{return}switch(n.type){case"ack":{let i=this.subscriptions.getById(n.id);i&&(i.acked=!0);return}case"chunk":{let{data:i,id:a}=n;this.streams.get(a)?.handle.push(w(i));return}case"complete":{this.handleCompleteMessage(n.id);return}case"data":case"delta":{this.handleDataMessage(n);return}case"error":{this.handleErrorMessage(n);break}case"pokeEnd":{this.handlePokeEnd(n);break}case"pokePart":{this.handlePokePart(n);break}case"pokeStart":{this.handlePokeStart(n);break}case"resume":{this.handleResumeMessage(n);break}case"settled":{this.handleSettledMessage(n);break}case"whisper":{this.dispatchWhisper(n,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:s}=e,n=s===void 0?void 0:this.streams.get(s);if(n&&s!==void 0){n.handle.fail(an(e)),this.streams.delete(s);return}let i=s===void 0?void 0:this.subscriptions.getById(s);if(i){or(i.errorCallbacks,ir(e));return}let a=s===void 0?void 0:this.shapeSubscriptions.get(s);a&&or(a.errorCallbacks,ir(e))}handlePokeStart(e){if(this.pokeBuffers.size>=t.MAX_POKE_BUFFERS){let r=this.pokeBuffers.keys().next().value;r!==void 0&&this.pokeBuffers.delete(r)}this.pokeBuffers.set(e.pokeId,{baseCheckpoint:e.baseCheckpoint,epoch:e.epoch,lastMutationId:new Map,parts:new Map})}handlePokePart(e){let r=this.pokeBuffers.get(e.pokeId);if(!r)return;let s=r.parts.get(e.shapeId)??[];for(let n of e.rowsPatch)s.push(n.value===void 0?n:{...n,value:w(n.value)});r.parts.set(e.shapeId,s),e.lastMutationId!==void 0&&r.lastMutationId.set(e.shapeId,e.lastMutationId)}handlePokeEnd(e){let r=this.pokeBuffers.get(e.pokeId);if(r){this.pokeBuffers.delete(e.pokeId);for(let[s,n]of r.parts){let i=this.shapeSubscriptions.get(s);if(!i)continue;let a=r.epoch!==void 0&&i.serverEpoch!==void 0&&r.epoch!==i.serverEpoch,u=r.baseCheckpoint!==void 0&&i.serverCursor!==void 0&&i.serverCursor!==r.baseCheckpoint;if(a||u){i.rows.clear(),i.serverCursor=void 0,i.serverEpoch=void 0,this.emitShapeRows(i),this.sendShapeSubscribeIfOpen(i);continue}qr(i.rows,n),e.checkpoint!==void 0&&(i.serverCursor=e.checkpoint),e.epoch!==void 0&&(i.serverEpoch=e.epoch);let c=r.lastMutationId.get(s);c!==void 0&&(i.lastMutationId=c),this.emitShapeRows(i),i.onCheckpoint?.({checkpoint:i.serverCursor,mutationId:i.lastMutationId})}}}emitShapeRows(e){let r=[...e.rows.values()];for(let s of e.callbacks)try{s(r)}catch{}}handleDataMessage(e){let{id:r}=e,s=r?this.subscriptions.getById(r):void 0;if(!s)return;let n=this.resolveDataPayload(e,s);s.serverBase=n,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),this.persistQueryValue(s),Ve(s,s.serverCursor),ce(s,s.optimisticLayers.length===0?n:_e(n,s.optimisticLayers))}handleResumeMessage(e){let r=this.subscriptions.getById(e.id);r&&this.ackAndAdvanceCursor(r,e.cursor,e.epoch)}handleSettledMessage(e){let r=this.subscriptions.getById(e.id);if(r){this.ackAndAdvanceCursor(r,e.cursor,e.epoch),e.lastMutationId!==void 0&&(r.lastMutationId=e.lastMutationId);for(let s of r.checkpointCallbacks)s({checkpoint:r.serverCursor,mutationId:r.lastMutationId})}}ackAndAdvanceCursor(e,r,s){e.acked=!0,(r!==void 0&&r!==e.serverCursor||s!==void 0&&s!==e.serverEpoch)&&(r!==void 0&&(e.serverCursor=r),s!==void 0&&(e.serverEpoch=s),this.persistQueryValue(e),Ve(e,e.serverCursor)&&ce(e,_e(e.serverBase,e.optimisticLayers)))}resolveDataPayload(e,r){if("data"in e&&e.data!==void 0)return w(e.data);let s=w(e.delta);if(jt(s)&&r.serverBase!==void 0){let n=Kt(r.serverBase,s);if(n!==void 0)return n}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(T(r))?.get(e.topic);if(!s)return;let n=w(e.data);for(let i of s)try{i(n,e.from)}catch{}}notifyTokenExpired(){this.tokenExpiredListeners.emit()}handleCompleteMessage(e){let r=this.streams.get(e);if(r){r.handle.complete(),this.streams.delete(e);return}let s=this.subscriptions.getById(e);s&&this.subscriptions.remove(s)}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{Z(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;if(e===null)return null;let r=2166136261,s=5381;for(let n=0;n<e.length;n+=1){let i=e.charCodeAt(n);r^=i,r=Math.imul(r,16777619),s=Math.imul(s,33)+i}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}rejectQueuedForIdentityChange(){let e=this.offlineQueue.drain();for(let r of e){this.queuedIdentities.delete(r.id??""),this.unpersist(r.id);let s=new Error("offline mutation discarded: auth identity changed before replay");s.code="OFFLINE_IDENTITY_CHANGED",r.reject(s),this.emitItemSettled(r,"rejected",s)}this.clearQueryCacheForIdentityChange()}restampQueuedIdentity(e,r){for(let[s,n]of this.queuedIdentities)n===e&&this.queuedIdentities.set(s,r)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}async flushOfflineQueue(e){let r=T(e),s=this.offlineQueue.drain(c=>T(c.shardKey)===r);if(s.length===0)return;let n=this.identityFingerprint(),i=[];for(let c of s)this.passesReplayIdentityGate(c,n)&&i.push(c);if(i.length===0)return;let a=this.encodableOrSettleTerminal(i);if(a.length===0)return;if(a.length===1){await this.replaySequential(a);return}let u=[];for(let c=0;c<a.length;c+=Xe){let h=a.slice(c,c+Xe),d=await this.replayBatched(h);if(u.push(...d.requeue),d.stop){u.push(...a.slice(c+Xe));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{ee(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(n){this.settleReplayTerminal(s,n instanceof Error?n:new Error(String(n)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),n=s===void 0?e.identity:s;if(n!==void 0&&n!==r){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let i=new Error("offline mutation skipped: auth identity changed before replay");return i.code="OFFLINE_IDENTITY_CHANGED",e.reject(i),this.emitItemSettled(e,"rejected",i),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}settleReplayTerminal(e,r){this.unpersist(e.id),e.reject(r),this.emitItemSettled(e,"rejected",r)}async replaySequential(e){for(let r=0;r<e.length;r+=1){let s=e[r];if(s)try{let n,i=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,mutationId:s.id,onCommitCursor:o(a=>{n=a},"onCommitCursor")});this.settleReplaySuccess(s,i,n)}catch(n){if(n.code!==void 0){this.settleReplayTerminal(s,n);continue}this.offlineQueue.requeue(e.slice(r));return}}}async replayBatched(e){if(!this.fetchImpl)return{requeue:e,stop:!0};let r;try{r=await this.fetchImpl(G(this.url,rr),{body:JSON.stringify({calls:e.map((i,a)=>({args:ee(i.args,`args for '${i.functionPath}'`),functionPath:i.functionPath,id:a,mutationId:i.id,shardKey:i.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"})}catch{return{requeue:e,stop:!0}}let s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let n;try{n=await r.json()}catch{return{requeue:e,stop:!0}}if(!n.results){if(n.error){let i=de(n.error);for(let a of e)this.settleReplayTerminal(a,i);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,n.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let i of r)typeof i.id=="number"&&i.body!==void 0&&s.set(i.id,i.body);let n=[];for(let[i,a]of e.entries()){let u=s.get(i);u===void 0?n.push(a):"error"in u?dn.has(u.error.code)?n.push(a):this.settleReplayTerminal(a,de(u.error)):this.settleReplaySuccess(a,w(u.result),u.commitCursor)}return n}};export{rt as a,lr as b,qe as c,Tr as d,Ar as e,$e as f,Ir as g};
@@ -1 +0,0 @@
1
- import{a as y}from"./chunk-OIC7EJWI.js";import{f as m}from"./chunk-GLUNBZRI.js";import{g as d,k as g}from"./chunk-PVZI3CXP.js";import{a as o,e as f,f as A,g as b}from"./chunk-RRCPZMC2.js";var p=f(b(),1);var c=f(A(),1);var h={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},L=o(()=>{let e=(0,p.c)(6),t=m(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],e[0]=a):a=e[0];let s;e[1]!==t?(s=o(()=>t.getAuthConfig(),"t1"),e[1]=t,e[2]=s):s=e[2];let{data:u,isLoading:i}=y(a,s),r=u??h,l=!i,n;return e[3]!==r||e[4]!==l?(n={config:r,ready:l},e[3]=r,e[4]=l,e[5]=n):n=e[5],n},"useAuthConfig"),w=o(()=>{let[e,t]=(0,c.useState)(!1),[a,s]=(0,c.useState)(null);return{busy:e,error:a,run:o(i=>{g((async()=>{t(!0),s(null);try{await i()}catch(r){s(d(r))}finally{t(!1)}})())},"run")}},"useAsyncSubmit");export{L as a,w as b};
@@ -1,13 +0,0 @@
1
- import{a as t}from"./chunk-RRCPZMC2.js";var a={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`],status:400,title:"Unique constraint violation"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{status:500,title:"Auth headers missing"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}};var l=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
2
- `),header:"No Lunora schema found",id:"lunora-schema-missing",test:t(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
3
- `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:t(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
4
- `),header:"Table name is reserved",id:"lunora-table-reserved",test:t(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
5
- `),header:"Duplicate table name",id:"lunora-table-duplicate",test:t(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
6
- `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:t(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
7
- `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:t(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
8
- `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:t(e=>e.includes("not exported by your worker entry"),"test")},{body:a.NOT_UNIQUE.hint.join(`
9
- `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:t(e=>e.includes("unique constraint violation on"),"test")},{body:a.CONFLICT.hint.join(`
10
- `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:t(e=>e.includes("optimistic concurrency conflict"),"test")}],d=t(e=>(Array.isArray(e)?e.join(`
11
- `):e).split(`
12
- `).filter(n=>!n.startsWith("```")).join(`
13
- `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"flattenHint");var o=class extends Error{static{t(this,"LunoraError")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(n,s,i={}){let r=a[n];super(s??n,{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??r?.hint,this.title=i.title??r?.title,this.loc=i.location,this.code=n,this.status=i.status??r?.status??500,this.docsUrl=i.docsUrl??r?.docsUrl,this.data=i.data}};export{d as a,o as b};
@@ -1 +0,0 @@
1
- import{a as i,e as n,f,g as b,h as p,j as d}from"./chunk-RRCPZMC2.js";var c=n(b(),1),m=n(f(),1);var r=n(p(),1);function h(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,r.jsxDEV)("table",{"data-slot":"table",className:a,...l},void 0,!1)},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(h,"Table");function x(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("thead",{"data-slot":"table-header",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(x,"TableHeader");function N(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("tbody",{"data-slot":"table-body",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(N,"TableBody");function v(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("tr",{"data-slot":"table-row",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(v,"TableRow");function w(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("th",{"data-slot":"table-head",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(w,"TableHead");function g(o){let e=(0,c.c)(8),t,l;e[0]!==o?({className:t,...l}=o,e[0]=o,e[1]=t,e[2]=l):(t=e[1],l=e[2]);let a;e[3]!==t?(a=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=a):a=e[4];let s;return e[5]!==l||e[6]!==a?(s=(0,r.jsxDEV)("td",{"data-slot":"table-cell",className:a,...l},void 0,!1),e[5]=l,e[6]=a,e[7]=s):s=e[7],s}i(g,"TableCell");export{h as a,x as b,N as c,v as d,w as e,g as f};
@@ -1 +0,0 @@
1
- import{a as le}from"./chunk-LAK5VSPI.js";import{b as ae}from"./chunk-KJJ3WM6H.js";import{a as ne}from"./chunk-TQ36RWOP.js";import{a as oe}from"./chunk-WXPWVBIY.js";import{a as re}from"./chunk-2K47A3P6.js";import{a as se}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as te}from"./chunk-K3GNLVYK.js";import{b as ee}from"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as U}from"./chunk-BOXSWNXZ.js";import{a as Z}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-OIC7EJWI.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as X}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as i,e as z,f as Te,g as qe,h as Pe,j as R}from"./chunk-RRCPZMC2.js";var T=z(qe(),1);var m=z(Te(),1);var r=z(Pe(),1);var Y=400,Me=36,Oe={height:Y,overflow:"auto"},ue={left:0,position:"absolute",top:0,width:"100%"},Ae={debug:"secondary",error:"destructive",info:"outline",warn:"secondary"},Fe={error:"destructive",ok:"secondary"},_e=i(a=>{let e=(0,T.c)(21),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.timestamp?(u=new Date(t.timestamp).toLocaleString(),e[2]=t.timestamp,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Ae[t.level],g;e[6]!==t.level||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.level},void 0,!1)},void 0,!1),e[6]=t.level,e[7]=y,e[8]=g):g=e[8];let b=t.functionPath??"\u2014",p;e[9]!==b?(p=(0,r.jsxDEV)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b},void 0,!1),e[9]=b,e[10]=p):p=e[10];let h;e[11]!==t.message?(h=(0,r.jsxDEV)("span",{className:"flex-1 truncate",role:"gridcell",children:t.message},void 0,!1),e[11]=t.message,e[12]=h):h=e[12];let x;return e[13]!==l||e[14]!==n||e[15]!==f||e[16]!==c||e[17]!==g||e[18]!==p||e[19]!==h?(x=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-row",ref:n,role:"row",style:f,children:[c,g,p,h]},void 0,!0),e[13]=l,e[14]=n,e[15]=f,e[16]=c,e[17]=g,e[18]=p,e[19]=h,e[20]=x):x=e[20],x},"LogRow"),ie=i(a=>a.length===0?"\u2014":a.join(", "),"tablesLabel"),Ve=i(a=>{let e=(0,T.c)(37),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.ts?(u=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Fe[t.outcome],g;e[6]!==t.outcome||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.outcome},void 0,!1)},void 0,!1),e[6]=t.outcome,e[7]=y,e[8]=g):g=e[8];let b;e[9]!==t.functionPath?(b=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath},void 0,!1),e[9]=t.functionPath,e[10]=b):b=e[10];let p=t.shardKey??"\u2014",h;e[11]!==p?(h=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p},void 0,!1),e[11]=p,e[12]=h):h=e[12];let x=t.userId??"\u2014",L;e[13]!==x?(L=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x},void 0,!1),e[13]=x,e[14]=L):L=e[14];let k;e[15]!==t.durationMs?(k=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=k):k=e[16];let I=`${String(k)}ms`,w;e[17]!==I?(w=(0,r.jsxDEV)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:I},void 0,!1),e[17]=I,e[18]=w):w=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ie(t.tablesRead)} \xB7 w:${ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let N;e[24]!==S?(N=(0,r.jsxDEV)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S},void 0,!1),e[24]=S,e[25]=N):N=e[25];let C;return e[26]!==l||e[27]!==n||e[28]!==f||e[29]!==L||e[30]!==w||e[31]!==N||e[32]!==c||e[33]!==g||e[34]!==b||e[35]!==h?(C=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-req-row",ref:n,role:"row",style:f,children:[c,g,b,h,L,w,N]},void 0,!0),e[26]=l,e[27]=n,e[28]=f,e[29]=L,e[30]=w,e[31]=N,e[32]=c,e[33]=g,e[34]=b,e[35]=h,e[36]=C):C=e[36],C},"RequestRow"),de=i(a=>{let{entries:e}=a??{};return Array.isArray(e)?e:[]},"entriesOf"),$e=i(a=>{let e={};return a.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=a.functionPathPrefix.trim()),a.userId.trim()!==""&&(e.userId=a.userId.trim()),a.tableTouched.trim()!==""&&(e.tableTouched=a.tableTouched.trim()),(a.outcome==="ok"||a.outcome==="error")&&(e.outcome=a.outcome),e},"buildRequestQuery"),me=["debug","info","warn","error"],Be={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ze=i((a,e)=>{let t=e.search.trim().toLowerCase(),l=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-Be[e.range];return a.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||l!==""&&!(o.functionPath??"").toLowerCase().includes(l)?!1:t===""||o.message.toLowerCase().includes(t))},"filterLogs"),De="\u2014",Ke=i(a=>{let e=new Map,t=new Map;for(let o of a){e.set(o.level,(e.get(o.level)??0)+1);let d=o.functionPath??De;t.set(d,(t.get(d)??0)+1)}let l=me.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:l,byPath:n,total:a.length}},"summarizeLogs"),Ue=i(a=>{let e=(0,T.c)(11),{level:t,onToggle:l,selected:n}=a,o;e[0]!==t||e[1]!==l?(o=i(()=>{l(t)},"t1"),e[0]=t,e[1]=l,e[2]=o):o=e[2];let d=o,v=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==v?(f=R("rounded-md border px-2 py-1 text-xs",v),e[3]=v,e[4]=f):f=e[4];let u=`logs-level-${t}`,c;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==f||e[9]!==u?(c=(0,r.jsxDEV)("button",{"aria-pressed":n,className:f,"data-testid":u,onClick:d,type:"button",children:t},void 0,!1),e[5]=t,e[6]=d,e[7]=n,e[8]=f,e[9]=u,e[10]=c):c=e[10],c},"LevelToggle"),ce=i(a=>{let e=(0,T.c)(7),{bucket:t}=a,l;e[0]!==t.key?(l=(0,r.jsxDEV)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key},void 0,!1),e[0]=t.key,e[1]=l):l=e[1];let n;e[2]!==t.count?(n=(0,r.jsxDEV)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count},void 0,!1),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==l||e[5]!==n?(o=(0,r.jsxDEV)("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:[l,n]},void 0,!0),e[4]=l,e[5]=n,e[6]=o):o=e[6],o},"SummaryBucketRow"),nt=i(({initialShardKey:a})=>{let e=X(),[t,l]=(0,m.useState)("requests"),[n,o]=(0,m.useState)(a??""),[d,v]=(0,m.useState)(""),[f,u]=(0,m.useState)(()=>new Set),[c,y]=(0,m.useState)(""),[g,b]=(0,m.useState)("all"),[p,h]=(0,m.useState)(!1),[x,L]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[w,S]=(0,m.useState)(""),[N,C]=(0,m.useState)("all"),q=re(n.trim(),400),fe=$e({functionPathPrefix:x,outcome:N,tableTouched:w,userId:k}),Q=K(U.getRequestLog,fe,{enabled:t==="requests",live:!0,shardKey:q}),W=K(U.getLogs,{},{enabled:t==="errors",live:!0,shardKey:q}),A=t==="requests"?Q:W,{error:G,errorSource:he,isLoading:H,liveError:ge}=A,ve=de(W.data),j=de(Q.data);(0,m.useEffect)(()=>{A.data!==void 0&&ee(q)},[A.data,q]);let F=ze(ve,{levels:f,now:Date.now(),path:c,range:g,search:d}),_=Ke(F),V=t==="requests"?j.length:F.length,$=t==="errors"&&p,P=(0,m.useMemo)(()=>G!==null?"error":V===0?H?$?"summary":"list":"empty":$?"summary":"list",[V,H,G,$]),J=(0,m.useRef)(null),M=ae({count:V,estimateSize:i(()=>Me,"estimateSize"),getScrollElement:i(()=>J.current,"getScrollElement"),initialRect:{height:Y,width:800},observeElementRect:i((s,B)=>le(s,B,Y),"observeElementRect"),overscan:8}),pe=M.getVirtualItems(),be={height:M.getTotalSize(),position:"relative",width:"100%"},xe=i(s=>{v(s.target.value)},"onSearchChange"),ye=i(s=>{u(B=>{let O=new Set(B);return O.has(s)?O.delete(s):O.add(s),O})},"toggleLevel"),we=i(s=>{y(s.target.value)},"onLogPathChange"),Ne=i(s=>{b(s.target.value)},"onTimeRangeChange"),Le=i(()=>{h(s=>!s)},"toggleSummary"),Se=i(s=>{L(s.target.value)},"onPathChange"),ke=i(s=>{I(s.target.value)},"onUserChange"),Ce=i(s=>{S(s.target.value)},"onTableChange"),Ee=i(s=>{C(s.target.value)},"onOutcomeChange"),Ie=i(()=>{l("requests"),h(!1)},"showRequests"),Re=i(()=>{l("errors"),h(!1)},"showErrors");return(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[(0,r.jsxDEV)("button",{"aria-selected":t==="requests",className:R("px-3 py-1 text-sm",t==="requests"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-requests",onClick:Ie,role:"tab",type:"button",children:e("Requests")},void 0,!1),(0,r.jsxDEV)("button",{"aria-selected":t==="errors",className:R("px-3 py-1 text-sm",t==="errors"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-errors",onClick:Re,role:"tab",type:"button",children:e("Errors")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(te,{onChange:o,testId:"lg-shard-input",value:n},void 0,!1),(0,r.jsxDEV)(oe,{message:ge,prefix:"lg"},void 0,!1),(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:e("Open in Cloudflare")},void 0,!1)]},void 0,!0),t==="errors"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Search messages"),className:"h-8 w-48","data-testid":"lg-search",onChange:xe,placeholder:e("search message"),value:d},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-40","data-testid":"logs-path-filter",onChange:we,placeholder:e("filter path"),value:c},void 0,!1),(0,r.jsxDEV)("div",{"aria-label":e("Level filter"),className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:me.map(s=>(0,r.jsxDEV)(Ue,{level:s,onToggle:ye,selected:f.has(s)},s,!1))},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Time range"),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:Ne,value:g,children:[(0,r.jsxDEV)("option",{value:"all",children:e("All time")},void 0,!1),(0,r.jsxDEV)("option",{value:"5m",children:e("Last 5m")},void 0,!1),(0,r.jsxDEV)("option",{value:"15m",children:e("Last 15m")},void 0,!1),(0,r.jsxDEV)("option",{value:"1h",children:e("Last hour")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("button",{"aria-pressed":p,className:R("h-8 rounded-md border px-3 text-sm",p?"border-border bg-muted font-medium":"border-input text-muted-foreground"),"data-testid":"logs-summary-toggle",onClick:Le,type:"button",children:e(p?"List":"Summary")},void 0,!1)]},void 0,!0),t==="requests"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-44","data-testid":"lg-req-path",onChange:Se,placeholder:e("file:function"),value:x},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("User id"),className:"h-8 w-32","data-testid":"lg-req-user",onChange:ke,placeholder:e("userId"),value:k},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Table touched"),className:"h-8 w-32","data-testid":"lg-req-table",onChange:Ce,placeholder:e("table"),value:w},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Outcome filter"),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:Ee,value:N,children:[(0,r.jsxDEV)("option",{value:"all",children:e("all")},void 0,!1),(0,r.jsxDEV)("option",{value:"ok",children:e("ok")},void 0,!1),(0,r.jsxDEV)("option",{value:"error",children:e("error")},void 0,!1)]},void 0,!0)]},void 0,!0),P==="error"&&(0,r.jsxDEV)(se,{error:he,testId:"lg-error"},void 0,!1),P==="empty"&&(0,r.jsxDEV)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M4 5h16M4 12h16M4 19h10"},void 0,!1)},void 0,!1),testId:"lg-empty",title:e("No logs.")},void 0,!1),P==="summary"&&(0,r.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[(0,r.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:e("{count} entries",{count:_.total})},void 0,!1),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By level")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:_.byLevel.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By function")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:_.byPath.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0)]},void 0,!0),P==="list"&&(0,r.jsxDEV)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:J,style:Oe,children:(0,r.jsxDEV)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:be,children:pe.map(s=>t==="requests"?(0,r.jsxDEV)(Ve,{entry:j[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1):(0,r.jsxDEV)(_e,{entry:F[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1))},void 0,!1)},void 0,!1)]},void 0,!0)},"LogsPanel");export{nt as LogsPanel,ze as filterLogs,Ke as summarizeLogs};
@@ -1,5 +0,0 @@
1
- import{a as s,c as m,f as S}from"./chunk-RRCPZMC2.js";var O=m(o=>{"use strict";(function(){function c(){}s(c,"noop");function y(t){return""+t}s(y,"testStringCoercion");function _(t,e,r){var a=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;try{y(a);var l=!1}catch{l=!0}return l&&(console.error("The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object"),y(a)),{$$typeof:E,key:a==null?null:""+a,children:t,containerInfo:e,implementation:r}}s(_,"createPortal$1");function d(t,e){if(t==="font")return"";if(typeof e=="string")return e==="use-credentials"?e:""}s(d,"getCrossOriginStringAs");function i(t){return t===null?"`null`":t===void 0?"`undefined`":t===""?"an empty string":'something with type "'+typeof t+'"'}s(i,"getValueDescriptorExpectingObjectForWarning");function u(t){return t===null?"`null`":t===void 0?"`undefined`":t===""?"an empty string":typeof t=="string"?JSON.stringify(t):typeof t=="number"?"`"+t+"`":'something with type "'+typeof t+'"'}s(u,"getValueDescriptorExpectingEnumForWarning");function p(){var t=f.H;return t===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
2
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
3
- 2. You might be breaking the Rules of Hooks
4
- 3. You might have more than one copy of React in the same app
5
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),t}s(p,"resolveDispatcher"),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var v=S(),n={d:{f:c,r:s(function(){throw Error("Invalid form element. requestFormReset must be passed a form that was rendered by React.")},"r"),D:c,C:c,L:c,m:c,X:c,S:c,M:c},p:0,findDOMNode:null},E=Symbol.for("react.portal"),f=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;typeof Map=="function"&&Map.prototype!=null&&typeof Map.prototype.forEach=="function"&&typeof Set=="function"&&Set.prototype!=null&&typeof Set.prototype.clear=="function"&&typeof Set.prototype.forEach=="function"||console.error("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),o.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=n,o.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)throw Error("Target container is not a DOM element.");return _(t,e,null,r)},o.flushSync=function(t){var e=f.T,r=n.p;try{if(f.T=null,n.p=2,t)return t()}finally{f.T=e,n.p=r,n.d.f()&&console.error("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.")}},o.preconnect=function(t,e){typeof t=="string"&&t?e!=null&&typeof e!="object"?console.error("ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",u(e)):e!=null&&typeof e.crossOrigin!="string"&&console.error("ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",i(e.crossOrigin)):console.error("ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t)),typeof t=="string"&&(e?(e=e.crossOrigin,e=typeof e=="string"?e==="use-credentials"?e:"":void 0):e=null,n.d.C(t,e))},o.prefetchDNS=function(t){if(typeof t!="string"||!t)console.error("ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t));else if(1<arguments.length){var e=arguments[1];typeof e=="object"&&e.hasOwnProperty("crossOrigin")?console.error("ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",u(e)):console.error("ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",u(e))}typeof t=="string"&&n.d.D(t)},o.preinit=function(t,e){if(typeof t=="string"&&t?e==null||typeof e!="object"?console.error("ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",u(e)):e.as!=="style"&&e.as!=="script"&&console.error('ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',u(e.as)):console.error("ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",i(t)),typeof t=="string"&&e&&typeof e.as=="string"){var r=e.as,a=d(r,e.crossOrigin),l=typeof e.integrity=="string"?e.integrity:void 0,g=typeof e.fetchPriority=="string"?e.fetchPriority:void 0;r==="style"?n.d.S(t,typeof e.precedence=="string"?e.precedence:void 0,{crossOrigin:a,integrity:l,fetchPriority:g}):r==="script"&&n.d.X(t,{crossOrigin:a,integrity:l,fetchPriority:g,nonce:typeof e.nonce=="string"?e.nonce:void 0})}},o.preinitModule=function(t,e){var r="";typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e!==void 0&&typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":e&&"as"in e&&e.as!=="script"&&(r+=" The `as` option encountered was "+u(e.as)+"."),r?console.error("ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",r):(r=e&&typeof e.as=="string"?e.as:"script",r)==="script"||(r=u(r),console.error('ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',r,t)),typeof t=="string"&&(typeof e=="object"&&e!==null?(e.as==null||e.as==="script")&&(r=d(e.as,e.crossOrigin),n.d.M(t,{crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0})):e==null&&n.d.M(t))},o.preload=function(t,e){var r="";if(typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e==null||typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":typeof e.as=="string"&&e.as||(r+=" The `as` option encountered was "+i(e.as)+"."),r&&console.error('ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',r),typeof t=="string"&&typeof e=="object"&&e!==null&&typeof e.as=="string"){r=e.as;var a=d(r,e.crossOrigin);n.d.L(t,r,{crossOrigin:a,integrity:typeof e.integrity=="string"?e.integrity:void 0,nonce:typeof e.nonce=="string"?e.nonce:void 0,type:typeof e.type=="string"?e.type:void 0,fetchPriority:typeof e.fetchPriority=="string"?e.fetchPriority:void 0,referrerPolicy:typeof e.referrerPolicy=="string"?e.referrerPolicy:void 0,imageSrcSet:typeof e.imageSrcSet=="string"?e.imageSrcSet:void 0,imageSizes:typeof e.imageSizes=="string"?e.imageSizes:void 0,media:typeof e.media=="string"?e.media:void 0})}},o.preloadModule=function(t,e){var r="";typeof t=="string"&&t||(r+=" The `href` argument encountered was "+i(t)+"."),e!==void 0&&typeof e!="object"?r+=" The `options` argument encountered was "+i(e)+".":e&&"as"in e&&typeof e.as!="string"&&(r+=" The `as` option encountered was "+i(e.as)+"."),r&&console.error('ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',r),typeof t=="string"&&(e?(r=d(e.as,e.crossOrigin),n.d.m(t,{as:typeof e.as=="string"&&e.as!=="script"?e.as:void 0,crossOrigin:r,integrity:typeof e.integrity=="string"?e.integrity:void 0})):n.d.m(t))},o.requestFormReset=function(t){n.d.r(t)},o.unstable_batchedUpdates=function(t,e){return t(e)},o.useFormState=function(t,e,r){return p().useFormState(t,e,r)},o.useFormStatus=function(){return p().useHostTransitionStatus()},o.version="19.2.7",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var b=m((R,h)=>{"use strict";h.exports=O()});export{b as a};
@@ -1 +0,0 @@
1
- import{a as R}from"./chunk-WXPWVBIY.js";import{a as w,b as O,c as D,d as C,e as v,f as h}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-BOXSWNXZ.js";import{a as S}from"./chunk-TAD43CG5.js";import{b as _}from"./chunk-OIC7EJWI.js";import{a as A,e as I}from"./chunk-SEU5V7I6.js";import{b as E}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as u,e as T,f as M,g as P,h as V}from"./chunk-RRCPZMC2.js";var B=T(P(),1),K=T(M(),1);var t=T(V(),1);var k="container:",F={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},H=u(e=>{let r=e.indexOf(":");if(r===-1)return{event:e.trim()};let a=e.slice(r+1).trim(),s=e.slice(0,r).trim();return a===""?{event:s}:{detail:a,event:s}},"parseContainerMessage"),W=u(e=>{let r=new Map;for(let a of e){let s=a.functionPath??"";if(!s.startsWith(k))continue;let n=s.slice(k.length);if(n==="")continue;let i=r.get(n);if(i!==void 0&&i.timestamp>=a.timestamp)continue;let{detail:x,event:o}=H(a.message);r.set(n,{detail:x,event:o,level:a.level,name:n,state:F[o]??"unknown",timestamp:a.timestamp})}return[...r.values()].toSorted((a,s)=>a.name.localeCompare(s.name))},"foldContainerInstances"),$={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},j=u(e=>{let{entries:r}=e??{};return Array.isArray(r)?r:[]},"entriesOf"),ee=u(()=>{let e=(0,B.c)(23),r=b(),a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);let{data:n,error:i,liveError:x}=_(L.getLogs,a,s),o=n!==void 0,N;e[2]!==n?(N=W(j(n)),e[2]=n,e[3]=N):N=e[3];let g=N,l;e[4]!==i?(l=i!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:i},void 0,!1),e[4]=i,e[5]=l):l=e[5];let c;e[6]!==r?(c=r("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per container \u2014 ports and health checks aren't carried in that stream."),e[6]=r,e[7]=c):c=e[7];let d;e[8]!==c?(d=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:c},void 0,!1),e[8]=c,e[9]=d):d=e[9];let m;e[10]!==x?(m=(0,t.jsxDEV)(R,{message:x,prefix:"containers"},void 0,!1),e[10]=x,e[11]=m):m=e[11];let f;e[12]!==d||e[13]!==m?(f=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[d,m]},void 0,!0),e[12]=d,e[13]=m,e[14]=f):f=e[14];let p;e[15]!==o||e[16]!==g||e[17]!==r?(p=o&&g.length===0?(0,t.jsxDEV)(S,{description:r("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:r("No container activity")},void 0,!1):(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(I,{className:"px-0",children:(0,t.jsxDEV)(w,{"data-testid":"containers-table",children:[(0,t.jsxDEV)(O,{children:(0,t.jsxDEV)(C,{children:[(0,t.jsxDEV)(v,{children:r("Container")},void 0,!1),(0,t.jsxDEV)(v,{children:r("State")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Last event")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Detail")},void 0,!1),(0,t.jsxDEV)(v,{children:r("When")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(D,{children:g.map(G)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[15]=o,e[16]=g,e[17]=r,e[18]=p):p=e[18];let y;return e[19]!==l||e[20]!==f||e[21]!==p?(y=(0,t.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[l,f,p]},void 0,!0),e[19]=l,e[20]=f,e[21]=p,e[22]=y):y=e[22],y},"ContainersPanel");function G(e){return(0,t.jsxDEV)(C,{"data-testid":`containers-row-${e.name}`,children:[(0,t.jsxDEV)(h,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,t.jsxDEV)(h,{children:(0,t.jsxDEV)(E,{variant:$[e.state],children:e.state},void 0,!1)},void 0,!1),(0,t.jsxDEV)(h,{className:"font-mono text-xs text-muted-foreground",children:e.event},void 0,!1),(0,t.jsxDEV)(h,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"},void 0,!1),(0,t.jsxDEV)(h,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()},void 0,!1)]},e.name,!0)}u(G,"_temp");export{ee as ContainersPanel};
@@ -1,2 +0,0 @@
1
- import{a as O,b as $,c as E,d as J,e as R,f as _,g as L,h as U}from"./chunk-LNZIB2MD.js";import{a as B}from"./chunk-AHILM3ZP.js";import{a as I}from"./chunk-TDL7NEWA.js";import{d as D,j as V,k as A}from"./chunk-PVZI3CXP.js";import{a as C,e as j,f as Q,g as q,h as z}from"./chunk-RRCPZMC2.js";var S=j(q(),1),H=j(Q(),1);var a=j(z(),1);var k="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",K=/["\n,]/u,G=C(n=>{if(n==null)return"";let e;return typeof n=="string"?e=n:typeof n=="number"||typeof n=="boolean"||typeof n=="bigint"?e=String(n):e=JSON.stringify(n),K.test(e)?`"${e.replaceAll('"','""')}"`:e},"csvCell"),P=C((n,e)=>{let t=n.map(s=>G(s)).join(","),o=e.map(s=>n.map(l=>G(s[l])).join(","));return[t,...o].join(`
2
- `)},"toCsv"),W=C(n=>JSON.stringify(n,null,2),"toJson"),F=C((n,e,t)=>{if(!("document"in globalThis))return;let o=globalThis.URL.createObjectURL(new globalThis.Blob([e],{type:t})),s=globalThis.document.createElement("a");s.href=o,s.download=n,globalThis.document.body.append(s),s.click(),s.remove(),globalThis.URL.revokeObjectURL(o)},"downloadFile"),X=C(n=>{let e=(0,S.c)(26),{columns:t,name:o,rows:s}=n,l=D(),r;e[0]!==t||e[1]!==o||e[2]!==s?(r=C(()=>{F(`${o}.csv`,P(t,s),"text/csv;charset=utf-8")},"t1"),e[0]=t,e[1]=o,e[2]=s,e[3]=r):r=e[3];let u=r,i;e[4]!==o||e[5]!==s?(i=C(()=>{F(`${o}.json`,W(s),"application/json")},"t2"),e[4]=o,e[5]=s,e[6]=i):i=e[6];let m=i,c=s.length===0,f;e[7]!==c?(f=(0,a.jsxDEV)($,{className:k,"data-testid":"grid-export",disabled:c,title:"Exports only the rows loaded on the current page, not the whole table",children:"Export page"},void 0,!1),e[7]=c,e[8]=f):f=e[8];let d;e[9]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsxDEV)(R,{children:"Export loaded rows"},void 0,!1),e[9]=d):d=e[9];let p;e[10]!==l?(p=l("CSV"),e[10]=l,e[11]=p):p=e[11];let v;e[12]!==u||e[13]!==p?(v=(0,a.jsxDEV)(_,{"data-testid":"grid-export-csv",onClick:u,children:p},void 0,!1),e[12]=u,e[13]=p,e[14]=v):v=e[14];let g;e[15]!==l?(g=l("JSON"),e[15]=l,e[16]=g):g=e[16];let b;e[17]!==m||e[18]!==g?(b=(0,a.jsxDEV)(_,{"data-testid":"grid-export-json",onClick:m,children:g},void 0,!1),e[17]=m,e[18]=g,e[19]=b):b=e[19];let h;e[20]!==v||e[21]!==b?(h=(0,a.jsxDEV)(E,{align:"end",children:[d,v,b]},void 0,!0),e[20]=v,e[21]=b,e[22]=h):h=e[22];let x;return e[23]!==h||e[24]!==f?(x=(0,a.jsxDEV)(O,{children:[f,h]},void 0,!0),e[23]=h,e[24]=f,e[25]=x):x=e[25],x},"ExportMenu"),Y=C(n=>{let e=(0,S.c)(9),{column:t}=n,o;e[0]!==t?(o=C(()=>{t.toggleVisibility()},"t1"),e[0]=t,e[1]=o):o=e[1];let s=o,l;e[2]!==t?(l=t.getIsVisible(),e[2]=t,e[3]=l):l=e[3];let r=`grid-column-${t.id}`,u;return e[4]!==t.id||e[5]!==s||e[6]!==l||e[7]!==r?(u=(0,a.jsxDEV)(L,{checked:l,closeOnClick:!1,"data-testid":r,onCheckedChange:s,children:t.id},void 0,!1),e[4]=t.id,e[5]=s,e[6]=l,e[7]=r,e[8]=u):u=e[8],u},"ColumnToggle"),Z=C(n=>{let e=(0,S.c)(30),{table:t}=n,o=D(),s;e[0]!==t?(s=t.getIsAllColumnsVisible(),e[0]=t,e[1]=s):s=e[1];let l=s,r;e[2]!==l||e[3]!==t?(r=C(()=>{t.toggleAllColumnsVisible(!l)},"t2"),e[2]=l,e[3]=t,e[4]=r):r=e[4];let u=r,i;e[5]!==o?(i=o("Columns"),e[5]=o,e[6]=i):i=e[6];let m;e[7]!==i?(m=(0,a.jsxDEV)($,{className:k,"data-testid":"grid-columns",children:i},void 0,!1),e[7]=i,e[8]=m):m=e[8];let c;e[9]!==o?(c=o("Columns"),e[9]=o,e[10]=c):c=e[10];let f;e[11]!==c?(f=(0,a.jsxDEV)(R,{children:c},void 0,!1),e[11]=c,e[12]=f):f=e[12];let d;e[13]!==l||e[14]!==o?(d=o(l?"Hide all":"Show all"),e[13]=l,e[14]=o,e[15]=d):d=e[15];let p;e[16]!==l||e[17]!==u||e[18]!==d?(p=(0,a.jsxDEV)(L,{checked:l,closeOnClick:!1,"data-testid":"grid-columns-all",onCheckedChange:u,children:d},void 0,!1),e[16]=l,e[17]=u,e[18]=d,e[19]=p):p=e[19];let v;e[20]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsxDEV)(U,{},void 0,!1),e[20]=v):v=e[20];let g;e[21]!==t?(g=t.getAllLeafColumns().map(te),e[21]=t,e[22]=g):g=e[22];let b;e[23]!==g||e[24]!==f||e[25]!==p?(b=(0,a.jsxDEV)(E,{align:"end",className:"max-h-80 overflow-y-auto",children:(0,a.jsxDEV)(J,{children:[f,p,v,g]},void 0,!0)},void 0,!1),e[23]=g,e[24]=f,e[25]=p,e[26]=b):b=e[26];let h;return e[27]!==b||e[28]!==m?(h=(0,a.jsxDEV)(O,{children:[m,b]},void 0,!0),e[27]=b,e[28]=m,e[29]=h):h=e[29],h},"ColumnsMenu"),ee=C(n=>{let e=(0,S.c)(19),{count:t,editable:o,onClear:s,onDelete:l}=n,r=D(),u;e[0]!==t||e[1]!==r?(u=r("{count} selected",{count:t}),e[0]=t,e[1]=r,e[2]=u):u=e[2];let i;e[3]!==u?(i=(0,a.jsxDEV)("span",{className:"font-medium tabular-nums","data-testid":"grid-selection-count",children:u},void 0,!1),e[3]=u,e[4]=i):i=e[4];let m;e[5]!==r?(m=r("Clear"),e[5]=r,e[6]=m):m=e[6];let c;e[7]!==s||e[8]!==m?(c=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-selection-clear",onClick:s,type:"button",children:m},void 0,!1),e[7]=s,e[8]=m,e[9]=c):c=e[9];let f;e[10]!==t||e[11]!==o||e[12]!==l||e[13]!==r?(f=o&&(0,a.jsxDEV)(I,{confirmLabel:r("Delete {count} rows?",{count:t}),onConfirm:l,testId:"grid-selection-delete",children:r("Delete {count}",{count:t})},void 0,!1),e[10]=t,e[11]=o,e[12]=l,e[13]=r,e[14]=f):f=e[14];let d;return e[15]!==i||e[16]!==c||e[17]!==f?(d=(0,a.jsxDEV)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-accent/40 px-3 py-1.5 text-xs","data-testid":"grid-selection-bar",children:[i,c,f]},void 0,!0),e[15]=i,e[16]=c,e[17]=f,e[18]=d):d=e[18],d},"SelectionBar"),ae=C(n=>{let e=(0,S.c)(32),{column:t,onClose:o,value:s}=n,l=D(),[r,u]=(0,H.useState)(!1),i;e[0]!==s?(i=V(s),e[0]=s,e[1]=i):i=e[1];let m=i,c;e[2]!==m?(c=C(()=>{let T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;T!==void 0&&(A(T.writeText(m)),u(!0))},"t2"),e[2]=m,e[3]=c):c=e[3];let f=c,d;e[4]!==l?(d=l("Cell value"),e[4]=l,e[5]=d):d=e[5];let p;e[6]!==t?(p=(0,a.jsxDEV)("h2",{className:"truncate font-mono text-sm font-semibold text-foreground",children:t},void 0,!1),e[6]=t,e[7]=p):p=e[7];let v;e[8]!==r||e[9]!==l?(v=l(r?"Copied":"Copy"),e[8]=r,e[9]=l,e[10]=v):v=e[10];let g;e[11]!==f||e[12]!==v?(g=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-cell-copy",onClick:f,type:"button",children:v},void 0,!1),e[11]=f,e[12]=v,e[13]=g):g=e[13];let b;e[14]!==l?(b=l("Close"),e[14]=l,e[15]=b):b=e[15];let h;e[16]!==o||e[17]!==b?(h=(0,a.jsxDEV)("button",{className:k,"data-testid":"grid-cell-close",onClick:o,type:"button",children:b},void 0,!1),e[16]=o,e[17]=b,e[18]=h):h=e[18];let x;e[19]!==g||e[20]!==h?(x=(0,a.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[g,h]},void 0,!0),e[19]=g,e[20]=h,e[21]=x):x=e[21];let w;e[22]!==p||e[23]!==x?(w=(0,a.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,x]},void 0,!0),e[22]=p,e[23]=x,e[24]=w):w=e[24];let y;e[25]!==m?(y=(0,a.jsxDEV)("pre",{className:"min-h-0 flex-1 overflow-auto rounded-md border border-border bg-muted/30 p-3 font-mono text-xs whitespace-pre-wrap","data-testid":"grid-cell-value",children:m},void 0,!1),e[25]=m,e[26]=y):y=e[26];let N;return e[27]!==o||e[28]!==w||e[29]!==y||e[30]!==d?(N=(0,a.jsxDEV)(B,{className:"max-h-[70vh] w-[min(40rem,90vw)]",label:d,onClose:o,panelTestId:"grid-cell-dialog",testId:"grid-cell-dialog-overlay",variant:"dialog",children:[w,y]},void 0,!0),e[27]=o,e[28]=w,e[29]=y,e[30]=d,e[31]=N):N=e[31],N},"CellDetailDialog"),de=C(n=>{let e=(0,S.c)(33),{columns:t,editable:o,name:s,onBulkDelete:l,onToggleTranspose:r,rows:u,table:i,transposed:m}=n,c=D(),f;e[0]!==i?(f=i.getSelectedRowModel(),e[0]=i,e[1]=f):f=e[1];let d=f.rows,p;e[2]!==i?(p=C(()=>{i.resetRowSelection()},"t2"),e[2]=i,e[3]=p):p=e[3];let v=p,g;e[4]!==l||e[5]!==d||e[6]!==i?(g=C(()=>{l(d.map(le)),i.resetRowSelection()},"t3"),e[4]=l,e[5]=d,e[6]=i,e[7]=g):g=e[7];let b=g,h;e[8]!==t||e[9]!==s||e[10]!==u?(h=(0,a.jsxDEV)(X,{columns:t,name:s,rows:u},void 0,!1),e[8]=t,e[9]=s,e[10]=u,e[11]=h):h=e[11];let x;e[12]!==i?(x=(0,a.jsxDEV)(Z,{table:i},void 0,!1),e[12]=i,e[13]=x):x=e[13];let w;e[14]!==c?(w=c("Swap rows and columns"),e[14]=c,e[15]=w):w=e[15];let y;e[16]!==c?(y=c("Transpose"),e[16]=c,e[17]=y):y=e[17];let N;e[18]!==r||e[19]!==w||e[20]!==y||e[21]!==m?(N=(0,a.jsxDEV)("button",{"aria-pressed":m,className:k,"data-testid":"grid-transpose",onClick:r,title:w,type:"button",children:y},void 0,!1),e[18]=r,e[19]=w,e[20]=y,e[21]=m,e[22]=N):N=e[22];let T;e[23]!==o||e[24]!==v||e[25]!==b||e[26]!==d.length?(T=d.length>0&&(0,a.jsxDEV)(ee,{count:d.length,editable:o,onClear:v,onDelete:b},void 0,!1),e[23]=o,e[24]=v,e[25]=b,e[26]=d.length,e[27]=T):T=e[27];let M;return e[28]!==h||e[29]!==x||e[30]!==N||e[31]!==T?(M=(0,a.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"grid-actions",children:[h,x,N,T]},void 0,!0),e[28]=h,e[29]=x,e[30]=N,e[31]=T,e[32]=M):M=e[32],M},"GridActionsBar");function te(n){return(0,a.jsxDEV)(Y,{column:n},n.id,!1)}C(te,"_temp");function le(n){return n.id}C(le,"_temp2");export{X as a,ee as b,ae as c,de as d};
@@ -1 +0,0 @@
1
- import{a as Oe,b as Je}from"./chunk-GM4NPF3W.js";import{a as Ke}from"./chunk-7YXOPTWI.js";import{a as qe}from"./chunk-AHILM3ZP.js";import{a as We}from"./chunk-J6J54MBP.js";import"./chunk-L7SK4ZZD.js";import{a as Ge}from"./chunk-2K47A3P6.js";import{a as De,b as Re,c as Pe,d as j,e as D,f as R}from"./chunk-GTM65MVX.js";import{a as V}from"./chunk-JSEXCW5Q.js";import"./chunk-4QHKBC77.js";import{R as B}from"./chunk-3CJW6NWG.js";import{c as U}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Qe}from"./chunk-TAD43CG5.js";import{a as Ze}from"./chunk-OIC7EJWI.js";import{a as we,e as Ce}from"./chunk-SEU5V7I6.js";import{b as $}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as H}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as Y,g as ze,j as Ae,k as Ue,n as Fe}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as i,e as je,f as _e,g as et,h as tt}from"./chunk-RRCPZMC2.js";var k=je(_e(),1);var Q=je(et(),1);var t=je(tt(),1);var st=i(()=>{let u=(0,Q.c)(3),{config:e,ready:a}=Oe(),l;return u[0]!==e.capabilities||u[1]!==a?(l={capabilities:e.capabilities,ready:a},u[0]=e.capabilities,u[1]=a,u[2]=l):l=u[2],l},"useAuthCapabilities"),lt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},at=i((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"isFieldFilled"),it=i((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let a=typeof e=="string"?e.trim():"";if(a!==""){if(u.type==="number"){let l=Number(a);return Number.isNaN(l)?void 0:{value:l}}return{value:a}}},"coerceFieldValue"),ot=i(u=>{let e=(0,Q.c)(105),{onClose:a,onCreated:l}=u,c=H(),s=Y(),{config:r}=Oe(),{busy:o,error:n,run:f}=Je(),[w,S]=(0,k.useState)(""),[x,C]=(0,k.useState)(""),[y,F]=(0,k.useState)(""),[v,g]=(0,k.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[h,d]=(0,k.useState)(p),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{S(m.target.value)},"t2"),e[1]=A):A=e[1];let b=A,I;e[2]===Symbol.for("react.memo_cache_sentinel")?(I=i(m=>{C(m.target.value)},"t3"),e[2]=I):I=e[2];let M=I,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=i(m=>{F(m.target.value)},"t4"),e[3]=E):E=e[3];let Be=E,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=i(m=>{g(m.target.value)},"t5"),e[4]=Z):Z=e[4];let $e=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=i((m,P)=>{d(q=>({...q,[m]:P}))},"t6"),e[5]=G):G=e[5];let Ee=G,W;e[6]!==h?(W=i(m=>h[m.name]??(m.type==="boolean"?!1:""),"t7"),e[6]=h,e[7]=W):W=e[7];let T=W,J;if(e[8]!==r.userFields||e[9]!==T){let m;e[11]!==T?(m=i(P=>!P.required||at(P,T(P)),"t92"),e[11]=T,e[12]=m):m=e[12],J=r.userFields.every(m),e[8]=r.userFields,e[9]=T,e[10]=J}else J=e[10];let Ie=J,K;e[13]!==o||e[14]!==w||e[15]!==x||e[16]!==Ie?(K=!o&&w.trim()!==""&&x.trim()!==""&&Ie,e[13]=o,e[14]=w,e[15]=x,e[16]=Ie,e[17]=K):K=e[17];let Ve=K,X;e[18]!==r.userFields||e[19]!==T?(X=i(()=>{let m={};for(let P of r.userFields){let q=it(P,T(P));q!==void 0&&(m[P.name]=q.value)}return Object.keys(m).length===0?void 0:m},"t10"),e[18]=r.userFields,e[19]=T,e[20]=X):X=e[20];let Se=X,_;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==x||e[25]!==a||e[26]!==l||e[27]!==y||e[28]!==v||e[29]!==f?(_=i(()=>{f(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:x.trim(),password:y===""?void 0:y,role:v.trim()===""?void 0:v.trim()}),l(),a()})},"t11"),e[21]=Se,e[22]=c,e[23]=w,e[24]=x,e[25]=a,e[26]=l,e[27]=y,e[28]=v,e[29]=f,e[30]=_):_=e[30];let N=_,z;e[31]!==s?(z=s("Create user"),e[31]=s,e[32]=z):z=e[32];let L;e[33]!==s?(L=s("Create user"),e[33]=s,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:L},void 0,!1),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==s?(ee=s("email"),e[37]=s,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsxDEV)(V,{htmlFor:"uc-email",children:ee},void 0,!1),e[39]=ee,e[40]=te):te=e[40];let se;e[41]!==w?(se=(0,t.jsxDEV)(B,{"data-testid":"uc-email",id:"uc-email",onChange:b,type:"email",value:w},void 0,!1),e[41]=w,e[42]=se):se=e[42];let le;e[43]!==te||e[44]!==se?(le=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[te,se]},void 0,!0),e[43]=te,e[44]=se,e[45]=le):le=e[45];let ae;e[46]!==s?(ae=s("name"),e[46]=s,e[47]=ae):ae=e[47];let ie;e[48]!==ae?(ie=(0,t.jsxDEV)(V,{htmlFor:"uc-name",children:ae},void 0,!1),e[48]=ae,e[49]=ie):ie=e[49];let oe;e[50]!==x?(oe=(0,t.jsxDEV)(B,{"data-testid":"uc-name",id:"uc-name",onChange:M,value:x},void 0,!1),e[50]=x,e[51]=oe):oe=e[51];let ne;e[52]!==ie||e[53]!==oe?(ne=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ie,oe]},void 0,!0),e[52]=ie,e[53]=oe,e[54]=ne):ne=e[54];let de;e[55]!==s?(de=s("Password (optional)"),e[55]=s,e[56]=de):de=e[56];let re;e[57]!==de?(re=(0,t.jsxDEV)(V,{htmlFor:"uc-password",children:de},void 0,!1),e[57]=de,e[58]=re):re=e[58];let ce;e[59]!==y?(ce=(0,t.jsxDEV)(B,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:y},void 0,!1),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==re||e[62]!==ce?(ue=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[re,ce]},void 0,!0),e[61]=re,e[62]=ce,e[63]=ue):ue=e[63];let fe;e[64]!==s?(fe=s("Role (optional)"),e[64]=s,e[65]=fe):fe=e[65];let ve;e[66]!==fe?(ve=(0,t.jsxDEV)(V,{htmlFor:"uc-role",children:fe},void 0,!1),e[66]=fe,e[67]=ve):ve=e[67];let me;e[68]!==v?(me=(0,t.jsxDEV)(B,{"data-testid":"uc-role",id:"uc-role",onChange:$e,value:v},void 0,!1),e[68]=v,e[69]=me):me=e[69];let he;e[70]!==ve||e[71]!==me?(he=(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[ve,me]},void 0,!0),e[70]=ve,e[71]=me,e[72]=he):he=e[72];let pe;e[73]!==r.userFields||e[74]!==T||e[75]!==s?(pe=r.userFields.length>0&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")},void 0,!1),r.userFields.map(m=>{let P=`uc-field-${m.name}`,q=m.required?"":` (${s("optional")})`;if(m.type==="boolean"){let Le=T(m)===!0;return(0,t.jsxDEV)("label",{className:"flex items-center gap-2",htmlFor:P,children:[(0,t.jsxDEV)(Ke,{checked:Le,"data-testid":P,id:P,onCheckedChange:i(Xe=>{Ee(m.name,Xe)},"onCheckedChange")},void 0,!1),(0,t.jsxDEV)("span",{className:"text-sm",children:[m.name,q]},void 0,!0)]},m.name,!0)}let Ye=T(m);return(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:P,children:[m.name,q]},void 0,!0),(0,t.jsxDEV)(B,{"data-testid":P,id:P,onChange:i(Le=>{Ee(m.name,Le.target.value)},"onChange"),type:lt[m.type],value:typeof Ye=="string"?Ye:""},void 0,!1)]},m.name,!0)})]},void 0,!0),e[73]=r.userFields,e[74]=T,e[75]=s,e[76]=pe):pe=e[76];let be;e[77]!==n?(be=n!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n},void 0,!1),e[77]=n,e[78]=be):be=e[78];let xe;e[79]!==s?(xe=s("Cancel"),e[79]=s,e[80]=xe):xe=e[80];let ye;e[81]!==a||e[82]!==xe?(ye=(0,t.jsxDEV)(U,{"data-testid":"uc-cancel",onClick:a,size:"sm",type:"button",variant:"outline",children:xe},void 0,!1),e[81]=a,e[82]=xe,e[83]=ye):ye=e[83];let Me=!Ve,ge;e[84]!==o||e[85]!==s?(ge=s(o?"Creating\u2026":"Create"),e[84]=o,e[85]=s,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==Me||e[89]!==ge?(Ne=(0,t.jsxDEV)(U,{"data-testid":"uc-submit",disabled:Me,onClick:N,size:"sm",type:"button",children:ge},void 0,!1),e[87]=N,e[88]=Me,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]},void 0,!0),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let Te;return e[94]!==a||e[95]!==z||e[96]!==O||e[97]!==le||e[98]!==ne||e[99]!==ue||e[100]!==he||e[101]!==pe||e[102]!==be||e[103]!==ke?(Te=(0,t.jsxDEV)(qe,{label:z,onClose:a,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,le,ne,ue,he,pe,be,ke]},void 0,!0),e[94]=a,e[95]=z,e[96]=O,e[97]=le,e[98]=ne,e[99]=ue,e[100]=he,e[101]=pe,e[102]=be,e[103]=ke,e[104]=Te):Te=e[104],Te},"UserCreateDialog"),He=i(u=>{let e=(0,Q.c)(2),{children:a}=u,l;return e[0]!==a?(l=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a},void 0,!1),e[0]=a,e[1]=l):l=e[1],l},"SectionHeading"),nt=i(u=>{let e=(0,Q.c)(29),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{let b=await r.listAuthSessions({limit:50,userId:c});f(b.rows)}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l?(y=i(b=>{l(()=>r.revokeAuthSession({sessionId:b}))},"t3"),e[7]=r,e[8]=l,e[9]=y):y=e[9];let F=y,v;e[10]!==o?(v=o("Sessions"),e[10]=o,e[11]=v):v=e[11];let g;e[12]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[12]=v,e[13]=g):g=e[13];let p;e[14]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w},void 0,!1),e[14]=w,e[15]=p):p=e[15];let h;e[16]!==n||e[17]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:o("No active sessions.")},void 0,!1),e[16]=n,e[17]=o,e[18]=h):h=e[18];let d;e[19]!==a||e[20]!==F||e[21]!==n||e[22]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("expires")},void 0,!1),(0,t.jsxDEV)(D,{children:o("ip")},void 0,!1),(0,t.jsxDEV)(D,{children:o("user agent")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>(0,t.jsxDEV)(j,{"data-testid":`ud-session-${b.id}`,children:[(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.expiresAt)},void 0,!1),(0,t.jsxDEV)(R,{children:b.ipAddress??""},void 0,!1),(0,t.jsxDEV)(R,{className:"max-w-40 truncate",children:b.userAgent??""},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-revoke-${b.id}`,disabled:a,onClick:i(()=>{F(b.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Revoke")},void 0,!1)},void 0,!1)]},b.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=a,e[20]=F,e[21]=n,e[22]=o,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==p||e[26]!==h||e[27]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,p,h,d]},void 0,!0),e[24]=g,e[25]=p,e[26]=h,e[27]=d,e[28]=A):A=e[28],A},"UserSessionsPanel"),dt=i(u=>{let e=(0,Q.c)(30),{busy:a,runAction:l,userId:c,version:s}=u,r=H(),o=Y(),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),x;e[0]!==r||e[1]!==c?(x=i(()=>{Ue((async()=>{S(null);try{f(await r.listAuthAccounts({userId:c}))}catch(b){let I=b;f(null),S(ze(I))}})())},"t1"),e[0]=r,e[1]=c,e[2]=x):x=e[2];let C;e[3]!==r||e[4]!==c||e[5]!==s?(C=[r,c,s],e[3]=r,e[4]=c,e[5]=s,e[6]=C):C=e[6],(0,k.useEffect)(x,C);let y;e[7]!==r||e[8]!==l||e[9]!==c?(y=i(b=>{l(()=>r.unlinkAuthAccount({accountId:b,userId:c}))},"t3"),e[7]=r,e[8]=l,e[9]=c,e[10]=y):y=e[10];let F=y,v;e[11]!==o?(v=o("Linked accounts"),e[11]=o,e[12]=v):v=e[12];let g;e[13]!==v?(g=(0,t.jsxDEV)(He,{children:v},void 0,!1),e[13]=v,e[14]=g):g=e[14];let p;e[15]!==w?(p=w!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:w},void 0,!1),e[15]=w,e[16]=p):p=e[16];let h;e[17]!==n||e[18]!==o?(h=n!==null&&n.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No linked accounts.")},void 0,!1),e[17]=n,e[18]=o,e[19]=h):h=e[19];let d;e[20]!==n||e[21]!==a||e[22]!==F||e[23]!==o?(d=n!==null&&n.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:o("provider")},void 0,!1),(0,t.jsxDEV)(D,{children:o("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:n.map(b=>{let I=Ae(b.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-account-${I}`,children:[(0,t.jsxDEV)(R,{children:Ae(b.providerId)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(b.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-unlink-${I}`,disabled:a,onClick:i(()=>{F(I)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Unlink")},void 0,!1)},void 0,!1)]},I,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=n,e[21]=a,e[22]=F,e[23]=o,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==p||e[27]!==h||e[28]!==d?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,p,h,d]},void 0,!0),e[25]=g,e[26]=p,e[27]=h,e[28]=d,e[29]=A):A=e[29],A},"UserAccountsPanel"),rt=i(u=>{let e=(0,Q.c)(40),{busy:a,capabilities:l,runAction:c,userId:s,version:r}=u,o=H(),n=Y(),[f,w]=(0,k.useState)(null),S;e[0]!==l.passkey||e[1]!==o||e[2]!==s?(S=i(()=>{l.passkey&&Ue((async()=>{try{w(await o.listAuthPasskeys({userId:s}))}catch{w(null)}})())},"t1"),e[0]=l.passkey,e[1]=o,e[2]=s,e[3]=S):S=e[3];let x;e[4]!==l.passkey||e[5]!==o||e[6]!==s||e[7]!==r?(x=[l.passkey,o,s,r],e[4]=l.passkey,e[5]=o,e[6]=s,e[7]=r,e[8]=x):x=e[8],(0,k.useEffect)(S,x);let C;e[9]!==o||e[10]!==c||e[11]!==s?(C=i(()=>{c(()=>o.disableAuthTwoFactor({userId:s}))},"t3"),e[9]=o,e[10]=c,e[11]=s,e[12]=C):C=e[12];let y=C,F;e[13]!==o||e[14]!==c?(F=i(I=>{c(()=>o.deleteAuthPasskey({passkeyId:I}))},"t4"),e[13]=o,e[14]=c,e[15]=F):F=e[15];let v=F,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let p;e[18]!==g?(p=(0,t.jsxDEV)(He,{children:g},void 0,!1),e[18]=g,e[19]=p):p=e[19];let h;e[20]!==a||e[21]!==l.twoFactor||e[22]!==y||e[23]!==n?(h=l.twoFactor&&(0,t.jsxDEV)(U,{"data-testid":"ud-disable-2fa",disabled:a,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")},void 0,!1),e[20]=a,e[21]=l.twoFactor,e[22]=y,e[23]=n,e[24]=h):h=e[24];let d;e[25]!==l.passkey||e[26]!==f||e[27]!==n?(d=l.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")},void 0,!1),e[25]=l.passkey,e[26]=f,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==a||e[30]!==l.passkey||e[31]!==v||e[32]!==f||e[33]!==n?(A=l.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:n("name")},void 0,!1),(0,t.jsxDEV)(D,{children:n("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":n("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:f.map(I=>{let M=Ae(I.id);return(0,t.jsxDEV)(j,{"data-testid":`ud-passkey-${M}`,children:[(0,t.jsxDEV)(R,{children:Ae(I.name)||M},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(I.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`ud-delete-passkey-${M}`,disabled:a,onClick:i(()=>{v(M)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")},void 0,!1)},void 0,!1)]},M,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=a,e[30]=l.passkey,e[31]=v,e[32]=f,e[33]=n,e[34]=A):A=e[34];let b;return e[35]!==p||e[36]!==h||e[37]!==d||e[38]!==A?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,h,d,A]},void 0,!0),e[35]=p,e[36]=h,e[37]=d,e[38]=A,e[39]=b):b=e[39],b},"UserSecurityPanel"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=i((u,e)=>typeof e=="number"&&ct.test(u)?Fe(e):Ae(e),"formatField"),vt=i(({capabilities:u,onChanged:e,onClose:a,user:l})=>{let c=H(),s=Y(),r=l.banned===!0,[o,n]=(0,k.useState)(null),[f,w]=(0,k.useState)(!1),[S,x]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof l.role=="string"?l.role:""),[F,v]=(0,k.useState)(""),[g,p]=(0,k.useState)(""),[h,d]=(0,k.useState)(""),[A,b]=(0,k.useState)(null),[I,M]=(0,k.useState)(!1),E=i((N,z)=>{Ue((async()=>{w(!0),n(null);try{let L=await N();z?.refresh!==!1&&(x(O=>O+1),e()),z?.onResult?.(L)}catch(L){n(ze(L))}finally{w(!1)}})())},"runAction"),Be=i(N=>{y(N.target.value)},"onRoleInputChange"),Z=i(N=>{v(N.target.value)},"onBanReasonChange"),$e=i(N=>{p(N.target.value)},"onBanDaysChange"),G=i(N=>{d(N.target.value)},"onNewPasswordChange"),Ee=i(()=>{let N=C.trim();N!==""&&E(async()=>{await c.setAuthUserRole({role:N,userId:l.id})})},"onSetRole"),W=i(()=>{let N=Number.parseInt(g,10),z=Number.isFinite(N)&&N>0?N*86400:void 0;E(async()=>{await c.banAuthUser({expiresInSeconds:z,reason:F.trim()===""?void 0:F.trim(),userId:l.id})})},"onBan"),T=i(()=>{E(async()=>{await c.unbanAuthUser({userId:l.id})})},"onUnban"),J=i(()=>{E(async()=>{await c.setAuthUserPassword({newPassword:h,userId:l.id}),d("")})},"onSetPassword"),Ie=i(()=>{E(()=>c.impersonateAuthUser({userId:l.id}),{onResult:i(N=>{b(N.token)},"onResult"),refresh:!1})},"onImpersonate"),K=i(()=>{E(async()=>{await c.revokeAuthUserSessions({userId:l.id})})},"onRevokeAll"),Ve=i(()=>{E(async()=>{await c.removeAuthUser({userId:l.id}),a()})},"onDelete"),X=i(()=>{M(!0)},"onConfirmDelete"),Se=i(()=>{M(!1)},"onCancelDelete"),_=Object.entries(l).filter(([N])=>!ut.has(N));return(0,t.jsxDEV)(qe,{label:s("User details"),onClose:a,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsxDEV)($,{variant:"secondary",children:l.role},void 0,!1),r?(0,t.jsxDEV)($,{variant:"destructive",children:s("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("Active")},void 0,!1),l.emailVerified===!0?(0,t.jsxDEV)($,{variant:"secondary",children:s("verified")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:s("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-close",onClick:a,size:"sm",type:"button",variant:"ghost",children:s("Close")},void 0,!1)]},void 0,!0),o!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:o},void 0,!1),u.admin&&(0,t.jsxDEV)(we,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(Ce,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-role",children:s("Role")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:C},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-role",disabled:f||C.trim()==="",onClick:Ee,size:"sm",type:"button",variant:"outline",children:s("Set role")},void 0,!1)]},void 0,!0),r?(0,t.jsxDEV)(U,{"data-testid":"ud-unban",disabled:f,onClick:T,size:"sm",type:"button",variant:"outline",children:s("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-reason",children:s("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:F},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-ban-days",children:s("Days")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:$e,type:"number",value:g},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-ban",disabled:f,onClick:W,size:"sm",type:"button",variant:"destructive",children:s("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-password",children:s("New password")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:h},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(U,{"data-testid":"ud-set-password",disabled:f||h==="",onClick:J,size:"sm",type:"button",variant:"outline",children:s("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(U,{"data-testid":"ud-impersonate",disabled:f,onClick:Ie,size:"sm",type:"button",variant:"outline",children:s("Impersonate")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-revoke-all",disabled:f,onClick:K,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")},void 0,!1),I?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(U,{"data-testid":"ud-delete-confirm",disabled:f,onClick:Ve,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:s("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(U,{"data-testid":"ud-delete",disabled:f,onClick:X,size:"sm",type:"button",variant:"destructive",children:s("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(V,{htmlFor:"ud-token",children:s("Impersonation token")},void 0,!1),(0,t.jsxDEV)(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(nt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),u.accounts&&(0,t.jsxDEV)(dt,{busy:f,runAction:E,userId:l.id,version:S},void 0,!1),(u.twoFactor||u.passkey)&&(0,t.jsxDEV)(rt,{busy:f,capabilities:u,runAction:E,userId:l.id,version:S},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:_.map(([N,z])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(N,z)},void 0,!1)]},N,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),mt=50,Rt=i(({pageSize:u=mt}={})=>{let e=H(),a=Y(),[l,c]=(0,k.useState)(""),[s,r]=(0,k.useState)(""),o=Ge(l),[n,f]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:x}=st(),C=o.trim(),y=s.trim(),F=Ze(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),v=F.data?.rows??null,g=F.error,p=i(()=>{F.refetch()},"reloadUsers");We(()=>{F.refetch()},!0);let h=n===null?null:v?.find(d=>d.id===n)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(B,{"aria-label":a("Search users"),className:"w-56","data-testid":"us-search",onChange:i(d=>{c(d.target.value)},"onChange"),placeholder:a("Search by email or name\u2026"),value:l},void 0,!1),(0,t.jsxDEV)(B,{"aria-label":a("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i(d=>{r(d.target.value)},"onChange"),placeholder:a("Filter by role"),value:s},void 0,!1),(0,t.jsxDEV)(U,{"data-testid":"us-new",onClick:i(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:a("New user")},void 0,!1)]},void 0,!0),g!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g},void 0,!1),v!==null&&v.length===0&&(0,t.jsxDEV)(Qe,{description:a("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"},void 0,!1)},void 0,!1),testId:"us-empty",title:a("No users.")},void 0,!1),v!==null&&v.length>0&&(0,t.jsxDEV)(we,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Ce,{className:"px-0",children:(0,t.jsxDEV)(De,{"data-testid":"us-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(D,{children:a("id")},void 0,!1),(0,t.jsxDEV)(D,{children:a("email")},void 0,!1),(0,t.jsxDEV)(D,{children:a("name")},void 0,!1),(0,t.jsxDEV)(D,{children:a("role")},void 0,!1),(0,t.jsxDEV)(D,{children:a("status")},void 0,!1),(0,t.jsxDEV)(D,{children:a("verified")},void 0,!1),(0,t.jsxDEV)(D,{children:a("created")},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":a("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Pe,{children:v.map(d=>(0,t.jsxDEV)(j,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsxDEV)(R,{className:"font-mono text-xs",children:d.id},void 0,!1),(0,t.jsxDEV)(R,{children:d.email??""},void 0,!1),(0,t.jsxDEV)(R,{children:d.name??""},void 0,!1),(0,t.jsxDEV)(R,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsxDEV)($,{variant:"secondary",children:d.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(R,{children:d.banned===!0?(0,t.jsxDEV)($,{variant:"destructive",children:a("Banned")},void 0,!1):(0,t.jsxDEV)($,{variant:"success",children:a("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{children:d.emailVerified===!0?(0,t.jsxDEV)($,{variant:"success",children:a("yes")},void 0,!1):(0,t.jsxDEV)($,{variant:"outline",children:a("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(R,{className:"text-muted-foreground tabular-nums",children:Fe(d.createdAt)},void 0,!1),(0,t.jsxDEV)(R,{children:(0,t.jsxDEV)(U,{"data-testid":`us-manage-${d.id}`,onClick:i(()=>{f(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Manage")},void 0,!1)},void 0,!1)]},d.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),h!==null&&(0,t.jsxDEV)(vt,{capabilities:x,onChanged:p,onClose:i(()=>{f(null)},"onClose"),user:h},void 0,!1),w&&(0,t.jsxDEV)(ot,{onClose:i(()=>{S(!1)},"onClose"),onCreated:p},void 0,!1)]},void 0,!0)},"UsersPanel");export{Rt as UsersPanel};
@@ -1 +0,0 @@
1
- import{a as $,b as F,c as D,d as p,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as se}from"./chunk-VLXV72QE.js";import{R as te}from"./chunk-3CJW6NWG.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as K}from"./chunk-BOXSWNXZ.js";import{a as B}from"./chunk-TAD43CG5.js";import{b as ae}from"./chunk-OIC7EJWI.js";import{a as R,e as _}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as Q}from"./chunk-GLUNBZRI.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as V,e as X,f as Y,g as E,k as W}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as r,e as ee,f as re,h as le}from"./chunk-RRCPZMC2.js";var n=ee(re(),1);var e=ee(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],ne=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=r(c=>typeof c=="object"&&c!==null&&c.code===de,"isNotConfigured"),fe=r(c=>{let s=c.error??c.output;if(s===void 0)return"\u2014";try{return JSON.stringify(s)}catch{return"(unserializable)"}},"formatStepPayload"),ue=r(({loadDetail:c,loadInstances:s,readOnly:y,runAction:L,workflowName:v})=>{let A=Q(),o=V(),[x,N]=(0,n.useState)(null),[k,I]=(0,n.useState)(null),[w,P]=(0,n.useState)(""),[g,h]=(0,n.useState)(null),[U,S]=(0,n.useState)(!1),[z,J]=(0,n.useState)(null),m=c??(a=>A.getWorkflowInstance(a)),O=y?void 0:L??(s===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),j=r(async()=>{h(null),S(!1);let a=w===""?void 0:w;try{if(s===void 0){let d=await A.listWorkflowInstances({name:v,status:a});if(d.configured===!1){N(null),S(!0);return}N(d.instances);return}N(await s({name:v,status:a}))}catch(d){N(null),ce(d)?S(!0):h(E(d))}},"load");(0,n.useEffect)(()=>{I(null),W(j())},[v,w]);let G=r(async a=>{h(null);try{I(await m({id:a,name:v}))}catch(d){h(E(d))}},"openDetail"),H=r(async(a,d)=>{if(O!==void 0){J(a),h(null);try{await O({action:d,id:a,name:v}),await j()}catch(M){h(E(M))}finally{J(null)}}},"act");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:o("Instance history")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":o("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:r(a=>{P(a.target.value)},"onChange"),value:w,children:[(0,e.jsxDEV)("option",{value:"",children:o("All statuses")},void 0,!1),ie.map(a=>(0,e.jsxDEV)("option",{value:a,children:a},a,!1))]},void 0,!0)]},void 0,!0),g!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:g},void 0,!1),U&&(0,e.jsxDEV)(B,{description:o("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:o("Workflow inspection not configured")},void 0,!1),!U&&x!==null&&x.length===0&&(0,e.jsxDEV)(B,{description:o("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:o("No instances")},void 0,!1),x!==null&&x.length>0&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflow-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Created")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Ended")},void 0,!1),(0,e.jsxDEV)(l,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:x.map(a=>(0,e.jsxDEV)(p,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.status},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-right",children:(0,e.jsxDEV)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:r(()=>{W(G(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Steps")},void 0,!1),O!==void 0&&ne.map(d=>(0,e.jsxDEV)(T,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:z===a.id,onClick:r(()=>{W(H(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:o(d)},d,!1))]},void 0,!0)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),k!==null&&(0,e.jsxDEV)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxDEV)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[o("Steps")," \xB7 ",k.id]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"workflow-instance-detail-close",onClick:r(()=>{I(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Close")},void 0,!1)]},void 0,!0),k.steps.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:o("This instance has no recorded steps yet.")},void 0,!1):(0,e.jsxDEV)($,{"data-testid":"workflow-instance-steps",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:o("Step")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Type")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Attempts")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Started")},void 0,!1),(0,e.jsxDEV)(l,{children:o("Output")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:k.steps.map((a,d)=>(0,e.jsxDEV)(p,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:a.name},void 0,!1),(0,e.jsxDEV)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"tabular-nums",children:a.attempts??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:fe(a)},void 0,!1)]},`${a.name}:${String(d)}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0)},"WorkflowInstanceHistory"),me=X(K.createWorkflowInstance),ve=X(K.getWorkflowInstanceStatus),he=r(c=>{if(c.error)return`${c.error.name}: ${c.error.message}`;if(c.output===void 0)return"\u2014";try{return JSON.stringify(c.output)}catch{return"(unserializable)"}},"formatPayload"),Oe=r(()=>{let c=Q(),s=V(),{data:y,error:L}=ae(K.listWorkflows,{}),[v,A]=(0,n.useState)(""),[o,x]=(0,n.useState)(""),[N,k]=(0,n.useState)(""),[I,w]=(0,n.useState)(!1),[P,g]=(0,n.useState)(null),[h,U]=(0,n.useState)([]),[S,z]=(0,n.useState)(null),J=y!==void 0,m=(0,n.useMemo)(()=>Array.isArray(y?.workflows)?[...y.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],[y]),C=(0,n.useMemo)(()=>m.some(t=>t.exportName===v)?v:m[0]?.exportName??"",[m,v]),q=(0,n.useMemo)(()=>m.find(t=>t.exportName===C),[m,C]),O=r(t=>{U(u=>{let f=u.filter(b=>!(b.exportName===t.exportName&&b.id===t.id));return[t,...f]})},"upsertInstance"),j=r(async()=>{let t=C;if(t==="")return;let u,f=N.trim();if(f!=="")try{u=JSON.parse(f)}catch{g(s("Params must be valid JSON"));return}w(!0),g(null);try{let b=o.trim(),Z=await c.query(me,{exportName:t,id:b===""?void 0:b,params:u},Y(""));O({exportName:t,id:Z.id,status:Z.status}),x("")}catch(b){g(E(b))}finally{w(!1)}},"start"),G=r(()=>{W(j())},"startInstance"),H=r(async(t,u)=>{z(u);try{let f=await c.query(ve,{exportName:t,id:u},Y(""));O({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){g(E(f))}finally{z(null)}},"refreshInstance"),a=r(t=>{A(t.target.value)},"onSelectedExportChange"),d=r(t=>{x(t.target.value)},"onInstanceIdChange"),M=r(t=>{k(t.target.value)},"onParamsChange"),oe=r(t=>{let{export:u,id:f}=t.currentTarget.dataset;u!==void 0&&f!==void 0&&W(H(u,f))},"onRefreshClick");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[L!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:L},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:s("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")},void 0,!1),J&&m.length===0?(0,e.jsxDEV)(B,{description:s("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:s("No workflows defined")},void 0,!1):(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Export")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Name")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Class")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Binding")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:m.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding},void 0,!1)]},t.exportName,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),m.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Start instance")},void 0,!1),P!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:P},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)("select",{"aria-label":s("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:a,value:C,children:m.map(t=>(0,e.jsxDEV)("option",{value:t.exportName,children:t.exportName},t.exportName,!1))},void 0,!1),(0,e.jsxDEV)(te,{"aria-label":s("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:d,placeholder:s("Instance id (optional)"),value:o},void 0,!1),(0,e.jsxDEV)(T,{"data-testid":"workflows-start-button",disabled:I||C==="",onClick:G,children:s(I?"Starting\u2026":"Start instance")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(se,{"aria-label":s("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:M,placeholder:s("Params (JSON, optional)"),value:N},void 0,!1)]},void 0,!0),h.length>0&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsxDEV)("h3",{className:"text-sm font-medium",children:s("Instances")},void 0,!1),(0,e.jsxDEV)(R,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(_,{className:"px-0",children:(0,e.jsxDEV)($,{"data-testid":"workflows-instances-table",children:[(0,e.jsxDEV)(F,{children:(0,e.jsxDEV)(p,{children:[(0,e.jsxDEV)(l,{children:s("Workflow")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Instance id")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Status")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Output")},void 0,!1),(0,e.jsxDEV)(l,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(D,{children:h.map(t=>(0,e.jsxDEV)(p,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.exportName},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs",children:t.status},void 0,!1),(0,e.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:he(t)},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(T,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:S===t.id,onClick:oe,size:"xs",variant:"outline",children:S===t.id?s("Refreshing\u2026"):s("Refresh")},void 0,!1)},void 0,!1)]},`${t.exportName}:${t.id}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),q!==void 0&&(0,e.jsxDEV)(ue,{workflowName:q.name},void 0,!1)]},void 0,!0)},"WorkflowsPanel");export{Oe as default};