@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
@@ -0,0 +1 @@
1
+ import{a as v}from"./chunk-NQ727GVM.js";import{b as w}from"./chunk-F2DVDJV6.js";import"./chunk-L27FKJTG.js";import{a as R}from"./chunk-JQBZDS6X.js";import"./chunk-4YEGXH2V.js";import{a as A,b as C,c as I,d as x,e as c,f as n}from"./chunk-4TGALJHR.js";import"./chunk-FPODRWDZ.js";import"./chunk-MNXXIISC.js";import"./chunk-EOFWXI3T.js";import{a as y}from"./chunk-LYVYUTQY.js";import{c as N}from"./chunk-YL5ZAR3P.js";import{a as S,e as $}from"./chunk-ZZ6ZCOD4.js";import"./chunk-KQVY73EU.js";import"./chunk-ZPQBVYNN.js";import{B as k}from"./chunk-VJQP4ARP.js";import"./chunk-PDBW6GTJ.js";import{a as E}from"./chunk-A6TVTNKO.js";import{b as O}from"./chunk-ADABTCDI.js";import{a as f,d as b}from"./chunk-5PEAXTYQ.js";var j=b(E(),1);var r=b(O(),1);var _=f((e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],"I"),T={delete:2,list:3,read:0,write:1},B=f(e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||T[t.on]-T[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),"O"),q=f(()=>{let e=(0,j.c)(14),t=k(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:i,errorSource:d}=N(y.storageRules,a),h=l!==void 0,m;if(e[1]!==l||e[2]!==i||e[3]!==d||e[4]!==h||e[5]!==t){let g=B(Array.isArray(l?.rules)?l.rules:[]),u;e[7]!==i||e[8]!==d?(u=i!==null&&(0,r.jsx)(R,{error:d,testId:"storage-rules-error"}),e[7]=i,e[8]=d,e[9]=u):u=e[9];let o;e[10]!==t?(o=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=o):o=e[11];let p;e[12]!==o?(p=(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:o}),e[12]=o,e[13]=p):p=e[13],m=(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[u,p,h&&g.length===0?(0,r.jsx)(v,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):(0,r.jsx)(S,{className:"overflow-hidden py-0",children:(0,r.jsx)($,{className:"px-0",children:(0,r.jsxs)(A,{"data-testid":"storage-rules-table",children:[(0,r.jsx)(C,{children:(0,r.jsxs)(x,{children:[(0,r.jsx)(c,{children:t("Bucket")}),(0,r.jsx)(c,{children:t("Operation")}),(0,r.jsx)(c,{children:t("Key prefix")}),(0,r.jsx)(c,{children:t("Guarded by")})]})}),(0,r.jsx)(I,{children:g.map(s=>(0,r.jsxs)(x,{"data-testid":`storage-rule-${s.bucket}-${s.on}-${s.prefix??""}`,children:[(0,r.jsx)(n,{className:"font-mono text-xs",children:s.bucket}),(0,r.jsx)(n,{children:(0,r.jsx)(w,{variant:"secondary",children:_(t,s.on)})}),(0,r.jsx)(n,{className:"font-mono text-xs",children:s.prefix??(0,r.jsx)("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),(0,r.jsx)(n,{className:"font-mono text-xs text-muted-foreground",children:s.procedure})]},`${s.bucket}:${s.on}:${s.prefix??""}:${s.procedure}`))})]})})})]}),e[1]=l,e[2]=i,e[3]=d,e[4]=h,e[5]=t,e[6]=m}else m=e[6];return m},"M");export{q as default};
@@ -0,0 +1,6 @@
1
+ import{a as P}from"./chunk-IMM6HPPD.js";import{a as V,b as F,c as J,d as K,e as B,f as A,g as I,h as M}from"./chunk-GDAZWXQW.js";import{a as z}from"./chunk-MTBY4GXM.js";import{B as L,p as D,r as U,s as Q,v as W}from"./chunk-VJQP4ARP.js";import{a as te}from"./chunk-A6TVTNKO.js";import{a as ee,b as le}from"./chunk-ADABTCDI.js";import{a as g,d as q}from"./chunk-5PEAXTYQ.js";var _=q(te(),1),E=q(ee(),1);var T="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",fe=`${T} aria-pressed:bg-accent aria-pressed:text-accent-foreground`;var s=q(le(),1);var X=g(l=>`"${l.replaceAll('"','""')}"`,"q"),ne=/["\n\r,]/u,oe=/^[=+\-@\t\r]/u,Y=g(l=>{if(l==null)return"";let e;return typeof l=="string"?e=oe.test(l)?` ${l}`:l:typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"?e=String(l):e=U(l),ne.test(e)?`"${e.replaceAll('"','""')}"`:e},"J"),ae=g((l,e)=>{let n=l.map(t=>Y(t)).join(","),o=e.map(t=>l.map(c=>Y(t[c])).join(","));return[n,...o].join(`
2
+ `)},"ne"),se=g(l=>JSON.stringify(l,D,2),"oe"),Z=500,re=g(l=>l==null?"NULL":typeof l=="number"?Number.isFinite(l)?String(l):"NULL":typeof l=="bigint"?String(l):typeof l=="boolean"?l?"1":"0":`'${(typeof l=="string"?l:U(l)).replaceAll("'","''")}'`,"K"),G="__doc__",ie=g((l,e,n,o)=>{if(e.length===0||n.length===0)return"";let t=o?.includes(G)===!0&&!e.includes(G)?e.filter(d=>!o.includes(d)):void 0,c=t===void 0?e:o,r=g((d,b)=>re(t===void 0||b!==G?d[b]:JSON.stringify(Object.fromEntries(t.map(u=>[u,d[u]])),D)),"i"),a=c.map(d=>X(d)).join(", "),i=[];for(let d=0;d<n.length;d+=Z){let b=n.slice(d,d+Z).map(u=>` (${c.map(m=>r(u,m)).join(", ")})`).join(`,
3
+ `);i.push(`INSERT INTO ${X(l)} (${a}) VALUES
4
+ ${b};`)}return i.join(`
5
+
6
+ `)},"se"),H=g((l,e,n)=>{if(!("document"in globalThis))return;let o=globalThis.URL.createObjectURL(new globalThis.Blob([e],{type:n})),t=globalThis.document.createElement("a");t.href=o,t.download=l,globalThis.document.body.append(t),t.click(),t.remove(),globalThis.URL.revokeObjectURL(o)},"M"),ce=g(l=>{let e=(0,_.c)(37),{columns:n,name:o,rows:t,sqlColumns:c}=l,r=L(),a;e[0]!==n||e[1]!==o||e[2]!==t?(a=g(()=>{H(`${o}.csv`,ae(n,t),"text/csv;charset=utf-8")},"s"),e[0]=n,e[1]=o,e[2]=t,e[3]=a):a=e[3];let i=a,d;e[4]!==o||e[5]!==t?(d=g(()=>{H(`${o}.json`,se(t),"application/json")},"a"),e[4]=o,e[5]=t,e[6]=d):d=e[6];let b=d,u;e[7]!==n||e[8]!==o||e[9]!==t||e[10]!==c?(u=g(()=>{H(`${o}.sql`,ie(o,n,t,c),"application/sql;charset=utf-8")},"f"),e[7]=n,e[8]=o,e[9]=t,e[10]=c,e[11]=u):u=e[11];let m=u,w=t.length===0,p;e[12]!==w?(p=(0,s.jsx)(F,{className:T,"data-testid":"grid-export",disabled:w,title:"Exports only the rows loaded on the current page, not the whole table",children:"Export page"}),e[12]=w,e[13]=p):p=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=(0,s.jsx)(B,{children:"Export loaded rows"}),e[14]=k):k=e[14];let h;e[15]!==r?(h=r("CSV"),e[15]=r,e[16]=h):h=e[16];let y;e[17]!==i||e[18]!==h?(y=(0,s.jsx)(A,{"data-testid":"grid-export-csv",onClick:i,children:h}),e[17]=i,e[18]=h,e[19]=y):y=e[19];let N;e[20]!==r?(N=r("JSON"),e[20]=r,e[21]=N):N=e[21];let x;e[22]!==b||e[23]!==N?(x=(0,s.jsx)(A,{"data-testid":"grid-export-json",onClick:b,children:N}),e[22]=b,e[23]=N,e[24]=x):x=e[24];let S;e[25]!==r?(S=r("SQL"),e[25]=r,e[26]=S):S=e[26];let f;e[27]!==m||e[28]!==S?(f=(0,s.jsx)(A,{"data-testid":"grid-export-sql",onClick:m,children:S}),e[27]=m,e[28]=S,e[29]=f):f=e[29];let C;e[30]!==x||e[31]!==f||e[32]!==y?(C=(0,s.jsxs)(J,{align:"end",children:[k,y,x,f]}),e[30]=x,e[31]=f,e[32]=y,e[33]=C):C=e[33];let v;return e[34]!==C||e[35]!==p?(v=(0,s.jsxs)(V,{children:[p,C]}),e[34]=C,e[35]=p,e[36]=v):v=e[36],v},"ie"),de=g(l=>{let e=(0,_.c)(9),{column:n}=l,o;e[0]!==n?(o=g(()=>{n.toggleVisibility()},"o"),e[0]=n,e[1]=o):o=e[1];let t=o,c;e[2]!==n?(c=n.getIsVisible(),e[2]=n,e[3]=c):c=e[3];let r=`grid-column-${n.id}`,a;return e[4]!==n.id||e[5]!==t||e[6]!==c||e[7]!==r?(a=(0,s.jsx)(I,{checked:c,closeOnClick:!1,"data-testid":r,onCheckedChange:t,children:n.id}),e[4]=n.id,e[5]=t,e[6]=c,e[7]=r,e[8]=a):a=e[8],a},"re"),me=[],ue=g(({backRelations:l=me,enabledBackRelations:e,onToggleBackRelation:n,table:o})=>{let t=L(),c=o.getIsAllColumnsVisible(),r=g(()=>{o.toggleAllColumnsVisible(!c)},"i");return(0,s.jsxs)(V,{children:[(0,s.jsx)(F,{className:T,"data-testid":"grid-columns",children:t("Columns")}),(0,s.jsxs)(J,{align:"end",className:"max-h-80 overflow-y-auto",children:[(0,s.jsxs)(K,{children:[(0,s.jsx)(B,{children:t("Columns")}),(0,s.jsx)(I,{checked:c,closeOnClick:!1,"data-testid":"grid-columns-all",onCheckedChange:r,children:t(c?"Hide all":"Show all")}),(0,s.jsx)(M,{}),o.getAllLeafColumns().filter(a=>!a.id.startsWith("__back__:")).map(a=>(0,s.jsx)(de,{column:a},a.id))]}),l.length>0&&n!==void 0&&(0,s.jsxs)(K,{children:[(0,s.jsx)(M,{}),(0,s.jsx)(B,{children:t("Related")}),l.map(a=>{let i=`${a.table}.${a.column}`;return(0,s.jsx)(I,{checked:e?.has(i)===!0,closeOnClick:!1,"data-testid":`grid-back-relation-${i}`,onCheckedChange:g(()=>{n(i)},"onCheckedChange"),children:`\u2190 ${a.table}.${a.column}`},i)})]})]})]})},"ae"),ge=g(l=>{let e=(0,_.c)(19),{count:n,editable:o,onClear:t,onDelete:c}=l,r=L(),a;e[0]!==n||e[1]!==r?(a=r("{count} selected",{count:n}),e[0]=n,e[1]=r,e[2]=a):a=e[2];let i;e[3]!==a?(i=(0,s.jsx)("span",{className:"font-medium tabular-nums","data-testid":"grid-selection-count",children:a}),e[3]=a,e[4]=i):i=e[4];let d;e[5]!==r?(d=r("Clear"),e[5]=r,e[6]=d):d=e[6];let b;e[7]!==t||e[8]!==d?(b=(0,s.jsx)("button",{className:T,"data-testid":"grid-selection-clear",onClick:t,type:"button",children:d}),e[7]=t,e[8]=d,e[9]=b):b=e[9];let u;e[10]!==n||e[11]!==o||e[12]!==c||e[13]!==r?(u=o&&(0,s.jsx)(z,{confirmLabel:r("Delete {count} rows and everything that cascades?",{count:n}),onConfirm:c,testId:"grid-selection-delete",children:r("Delete {count}",{count:n})}),e[10]=n,e[11]=o,e[12]=c,e[13]=r,e[14]=u):u=e[14];let m;return e[15]!==i||e[16]!==b||e[17]!==u?(m=(0,s.jsxs)("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,b,u]}),e[15]=i,e[16]=b,e[17]=u,e[18]=m):m=e[18],m},"de"),be=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,pe=g(l=>{let e=(0,_.c)(9),{bucket:n,objectKey:o,resolveUrl:t}=l,[c,r]=(0,E.useState)(null),[a,i]=(0,E.useState)(!1),d,b;e[0]!==n||e[1]!==o||e[2]!==t?(d=g(()=>{let p={cancelled:!1};return Q((async()=>{try{let k=await t(o,n);p.cancelled||r(k)}catch{p.cancelled||i(!0)}})()),()=>{p.cancelled=!0}},"a"),b=[n,o,t],e[0]=n,e[1]=o,e[2]=t,e[3]=d,e[4]=b):(d=e[3],b=e[4]),(0,E.useEffect)(d,b);let u;e[5]===Symbol.for("react.memo_cache_sentinel")?(u=g(()=>{i(!0)},"f"),e[5]=u):u=e[5];let m=u;if(c===null||a)return null;let w;return e[6]!==o||e[7]!==c?(w=(0,s.jsx)("div",{className:"flex max-h-64 shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:(0,s.jsx)("img",{alt:o,className:"max-h-64 object-contain","data-testid":"grid-cell-image",onError:m,src:c})}),e[6]=o,e[7]=c,e[8]=w):w=e[8],w},"me"),Se=g(l=>{let e=(0,_.c)(41),{bucket:n,column:o,onClose:t,onFilter:c,resolveUrl:r,value:a}=l,i=L(),[d,b]=(0,E.useState)(!1),u;e[0]!==a?(u=U(a),e[0]=a,e[1]=u):u=e[1];let m=u,w;e[2]!==m?(w=g(()=>{W(m)&&b(!0)},"N"),e[2]=m,e[3]=w):w=e[3];let p=w,k;e[4]!==i?(k=i("Cell value"),e[4]=i,e[5]=k):k=e[5];let h;e[6]!==o?(h=(0,s.jsx)("h2",{className:"truncate font-mono text-sm font-semibold text-foreground",children:o}),e[6]=o,e[7]=h):h=e[7];let y;e[8]!==c||e[9]!==i?(y=c!==void 0&&(0,s.jsx)("button",{className:T,"data-testid":"grid-cell-filter",onClick:c,type:"button",children:i("Filter by this value")}),e[8]=c,e[9]=i,e[10]=y):y=e[10];let N;e[11]!==d||e[12]!==i?(N=i(d?"Copied":"Copy"),e[11]=d,e[12]=i,e[13]=N):N=e[13];let x;e[14]!==p||e[15]!==N?(x=(0,s.jsx)("button",{className:T,"data-testid":"grid-cell-copy",onClick:p,type:"button",children:N}),e[14]=p,e[15]=N,e[16]=x):x=e[16];let S;e[17]!==i?(S=i("Close"),e[17]=i,e[18]=S):S=e[18];let f;e[19]!==t||e[20]!==S?(f=(0,s.jsx)("button",{className:T,"data-testid":"grid-cell-close",onClick:t,type:"button",children:S}),e[19]=t,e[20]=S,e[21]=f):f=e[21];let C;e[22]!==y||e[23]!==x||e[24]!==f?(C=(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[y,x,f]}),e[22]=y,e[23]=x,e[24]=f,e[25]=C):C=e[25];let v;e[26]!==C||e[27]!==h?(v=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[h,C]}),e[26]=C,e[27]=h,e[28]=v):v=e[28];let j;e[29]!==n||e[30]!==r||e[31]!==a?(j=r!==void 0&&typeof a=="string"&&be.test(a)&&(0,s.jsx)(pe,{bucket:n,objectKey:a,resolveUrl:r}),e[29]=n,e[30]=r,e[31]=a,e[32]=j):j=e[32];let $;e[33]!==m?($=(0,s.jsx)("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}),e[33]=m,e[34]=$):$=e[34];let R;return e[35]!==t||e[36]!==v||e[37]!==j||e[38]!==$||e[39]!==k?(R=(0,s.jsxs)(P,{className:"max-h-[70vh] w-[min(40rem,90vw)]",label:k,onClose:t,panelTestId:"grid-cell-dialog",testId:"grid-cell-dialog-overlay",variant:"dialog",children:[v,j,$]}),e[35]=t,e[36]=v,e[37]=j,e[38]=$,e[39]=k,e[40]=R):R=e[40],R},"ke"),je=g(l=>{let e=(0,_.c)(37),{backRelations:n,enabledBackRelations:o,onToggleBackRelation:t,columns:c,editable:r,name:a,onBulkDelete:i,onToggleTranspose:d,rows:b,sqlColumns:u,table:m,transposed:w}=l,p=L(),k;e[0]!==m?(k=m.getSelectedRowModel(),e[0]=m,e[1]=k):k=e[1];let h=k.rows,y;e[2]!==m?(y=g(()=>{m.resetRowSelection()},"y"),e[2]=m,e[3]=y):y=e[3];let N=y,x;e[4]!==i||e[5]!==h||e[6]!==m?(x=g(()=>{i(h.map(he)),m.resetRowSelection()},"x"),e[4]=i,e[5]=h,e[6]=m,e[7]=x):x=e[7];let S=x,f;e[8]!==c||e[9]!==a||e[10]!==b||e[11]!==u?(f=(0,s.jsx)(ce,{columns:c,name:a,rows:b,sqlColumns:u}),e[8]=c,e[9]=a,e[10]=b,e[11]=u,e[12]=f):f=e[12];let C;e[13]!==n||e[14]!==o||e[15]!==t||e[16]!==m?(C=(0,s.jsx)(ue,{backRelations:n,enabledBackRelations:o,onToggleBackRelation:t,table:m}),e[13]=n,e[14]=o,e[15]=t,e[16]=m,e[17]=C):C=e[17];let v;e[18]!==p?(v=p("Swap rows and columns"),e[18]=p,e[19]=v):v=e[19];let j;e[20]!==p?(j=p("Transpose"),e[20]=p,e[21]=j):j=e[21];let $;e[22]!==d||e[23]!==v||e[24]!==j||e[25]!==w?($=(0,s.jsx)("button",{"aria-pressed":w,className:T,"data-testid":"grid-transpose",onClick:d,title:v,type:"button",children:j}),e[22]=d,e[23]=v,e[24]=j,e[25]=w,e[26]=$):$=e[26];let R;e[27]!==r||e[28]!==N||e[29]!==S||e[30]!==h.length?(R=h.length>0&&(0,s.jsx)(ge,{count:h.length,editable:r,onClear:N,onDelete:S}),e[27]=r,e[28]=N,e[29]=S,e[30]=h.length,e[31]=R):R=e[31];let O;return e[32]!==f||e[33]!==C||e[34]!==$||e[35]!==R?(O=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"grid-actions",children:[f,C,$,R]}),e[32]=f,e[33]=C,e[34]=$,e[35]=R,e[36]=O):O=e[36],O},"Se");function he(l){return l.id}g(he,"ue");export{T as a,fe as b,H as c,ce as d,ge as e,Se as f,je as g};
@@ -0,0 +1,31 @@
1
+ import{a as nt,b as ot}from"./chunk-AY4DPAPO.js";import"./chunk-DWKKQ75U.js";import"./chunk-A2LKDNNA.js";import{d as tt}from"./chunk-UOFMFYZ7.js";import"./chunk-IMM6HPPD.js";import{a as Ae}from"./chunk-CVSIFPI5.js";import{a as Ze}from"./chunk-4E6DQHFK.js";import"./chunk-Y2YLTUMD.js";import"./chunk-GDAZWXQW.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as et}from"./chunk-DRHZZ7IN.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import"./chunk-R3RIZDUS.js";import{a as Ye}from"./chunk-RAJ327CY.js";import{b as Ve}from"./chunk-EDL46BPM.js";import"./chunk-MTBY4GXM.js";import{c as Xe,d as we,e as Ne,f as Ee,g as Me}from"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as ye}from"./chunk-V4JKKAAZ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-VGKDC2OQ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import{a as Je}from"./chunk-4YEGXH2V.js";import"./chunk-4TGALJHR.js";import{b as Ge}from"./chunk-MNXXIISC.js";import{a as ve}from"./chunk-LYVYUTQY.js";import"./chunk-YL5ZAR3P.js";import{n as Ce}from"./chunk-KQVY73EU.js";import"./chunk-ZPQBVYNN.js";import{B as J,h as ge,i as xe,j as Ke,r as Ue,s as le,x as ie}from"./chunk-VJQP4ARP.js";import"./chunk-PDBW6GTJ.js";import{a as Et}from"./chunk-A6TVTNKO.js";import{a as Nt,b as Lt}from"./chunk-ADABTCDI.js";import{a as d,d as De}from"./chunk-5PEAXTYQ.js";var V=De(Et(),1),j=De(Nt(),1);var u=De(Lt(),1);var Se=class{static{d(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),i=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(i,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=d(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),i=n.length,a=e.length,c=1,m=i+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,b=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(b[0],n,e,0,t);if(b[0].oldPos+1>=a&&g+1>=i)return l(this.buildValues(b[0].lastComponent,n,e));let k=-1/0,q=1/0,N=d(()=>{for(let h=Math.max(k,-c);h<=Math.min(q,c);h+=2){let S,x=b[h-1],v=b[h+1];x&&(b[h-1]=void 0);let y=!1;if(v){let E=v.oldPos-h;y=v&&0<=E&&E<i}let w=x&&x.oldPos+1<a;if(!y&&!w){b[h]=void 0;continue}if(!w||y&&x.oldPos<v.oldPos?S=this.addToPath(v,!0,!1,0,t):S=this.addToPath(x,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=i)return l(this.buildValues(S.lastComponent,n,e))||!0;b[h]=S,S.oldPos+1>=a&&(q=Math.min(q,h-1)),g+1>=i&&(k=Math.max(k,h+1))}c++},"execEditLength");if(o)d(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);N()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=N();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,i=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<i&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,i=0,a=0,c=0;for(;i<l;i++){let m=o[i];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,b){let g=t[c+b];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var $e=class extends Se{static{d(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=_t}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
2
+ `))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
3
+ `))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
4
+ `)&&(e=e.slice(0,-1)),n.endsWith(`
5
+ `)&&(n=n.slice(0,-1))),super.equals(e,n,t)}},rt=new $e;function Pe(s,e,n){return rt.diff(s,e,n)}d(Pe,"diffLines");function _t(s,e){e.stripTrailingCr&&(s=s.replace(/\r\n/g,`
6
+ `));let n=[],t=s.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(let o=0;o<t.length;o++){let r=t[o];o%2&&!e.newlineIsToken?n[n.length-1]+=r:n.push(r)}return n}d(_t,"tokenize");var Tt="x",st=" ",It={'"':'"',"'":"'","[":"]","`":"`"},ft=d((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
7
+ `;)n+=1;return n},"nt"),ht=d((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"st"),pt=d(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=It[t];if(t==="-"&&s[n+1]==="-"){let r=ft(s,n);e.fill(st,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=ht(s,n);if(r===-1)return;e.fill(st,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(Tt,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
8
+ `&&(e[t]=`
9
+ `);return e.join("")},"ot"),Rt="__lunora_admin_tokens__",je=new Set([Rt,"dbstat","sqlite_dbpage"]),bt="pragma_",Dt=d(s=>/[\p{L}_]/u.test(s)||(s.codePointAt(0)??0)>127,"It"),Mt=d(s=>/[\p{L}\p{N}_$]/u.test(s)||(s.codePointAt(0)??0)>127,"At"),At=/^pragma_\w+$/u,$t=d(s=>je.has(s)||At.test(s)?s:void 0,"Ot"),lt=d(s=>{if(je.has(s)||s.startsWith(bt))return s},"Ke"),it=d((s,e,n)=>{let t="",o=e+1;for(;o<s.length;){let r=s[o];if(r===n){if(n!=="]"&&s[o+1]===n){t+=n,o+=2;continue}return{end:o+1,text:t}}t+=r,o+=1}},"Ue"),at={'"':'"',"`":"`","[":"]"},Oe=d(s=>{let e=s.toLowerCase().replaceAll(/["'`[\]]/gu,"");for(let n of je)if(e.includes(n))return n;return/\bpragma_/u.test(e)?bt:void 0},"Ae"),Pt=d(s=>{let e=0;for(;e<s.length;){let n=s[e];if(/\s/u.test(n))e+=1;else if(n==="-"&&s[e+1]==="-"){let t=s.indexOf(`
10
+ `,e);e=t===-1?s.length:t+1}else if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);if(t===-1)return Oe(s.slice(e+2));e=t+2}else if(n==="'"){let t=it(s,e,"'");if(t===void 0)return Oe(s.slice(e+1));let o=$t(t.text.trim().toLowerCase());if(o!==void 0)return o;e=t.end}else if(n in at){let t=it(s,e,at[n]);if(t===void 0)return Oe(s.slice(e+1));let o=lt(t.text.toLowerCase());if(o!==void 0)return o;e=t.end}else if(Dt(n)){let t=e+1;for(;t<s.length&&Mt(s[t]);)t+=1;let o=s.slice(e,t).toLowerCase(),r=lt(o);if(r!==void 0)return r;e=t}else e+=1}},"Mt"),Ot=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,zt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,Ht=/^\w+/u,jt=/;\s*$/u,Wt=/\s/u,gt=d(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Wt.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ft(s,e);else if(n==="/"&&s[e+1]==="*"){let t=ht(s,e);if(t===-1)break;e=t}else break}return e},"rt"),Bt=d(s=>{let e=gt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(pt(n)??n).replace(jt,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let l="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Ot.test(o))return{code:"SQL_NOT_READONLY",length:Ht.exec(o)?.[0].length??1,message:l,offset:e};let i=zt.exec(o);if(i!==null)return{code:"SQL_NOT_READONLY",length:i[0].length,message:`${l} (\`${i[0].toUpperCase()}\` is not allowed)`,offset:e+i.index};let a=Pt(o);if(a!==void 0)return{code:"SQL_NOT_READONLY",message:`\`${a}\` is reserved framework storage and cannot be queried`}},"Ft"),Ft=/^explain\b/iu,Qt=d(s=>Ft.test(s.slice(gt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"jt"),He=d((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Bt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"Me"),xt=d(s=>{let e=pt(s);if(e===void 0)return He(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...He(s.slice(t,o),t)),t=o+1);return n},"it"),Kt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ut=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Re=String.fromCodePoint(0),Gt=new RegExp(`${Re}${String.raw`(\d+)`}${Re}`,"gu"),Xt=Kt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),Vt=Ut.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
11
+ ${s}`})),Yt=d(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${Re}${(e.length-1).toString()}${Re}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:t,replacement:o}of Xt)n=n.replaceAll(t,o);for(let{pattern:t,replacement:o}of Vt)n=n.replaceAll(t,o);return n=n.replaceAll(Gt,(t,o)=>e[Number(o)]??""),n},"Vt"),Jt=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Zt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,en=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),tn=/[^\n]/gu,nn=d((s,e)=>{let n=s[e];if(n==="'"){let t=e+1;for(;t<s.length&&s[t]!=="'";)t+=1;return Math.min(t+1,s.length)}if(n==="-"&&s[e+1]==="-"){let t=s.indexOf(`
12
+ `,e);return t===-1?s.length:t}if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);return t===-1?s.length:t+2}return-1},"tn"),on=d(s=>{let e="",n=0;for(;n<s.length;){let t=nn(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(tn," "),n=t)}return e},"nn"),rn=d(s=>{let e=new Set;for(let n of s.matchAll(Zt))e.add((n[1]??"").toLowerCase());return e},"sn"),sn=d((s,e)=>{let n=new Map;for(let t of s.matchAll(Jt)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!en.has(r)&&n.set(r,o))}return n},"on"),vt=d((s,e)=>{let n=on(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:rn(n),masked:n,targets:sn(n,t)}},"at"),ln=/^(?:__lunora|sqlite_)/iu,an=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,cn=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,dn=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),un=d((s,e,n)=>{let t=[];for(let o of s.matchAll(an)){let r=o[1]??"",l=r.toLowerCase();!e.has(l)&&!n.has(l)&&!dn.has(l)&&!ln.test(r)&&t.push({length:r.length,message:`unknown table \`${r}\``,offset:o.index+o[0].length-r.length,severity:"error",source:"schema"})}return t},"dn"),mn=d((s,e,n)=>{let t=[],o=new Map;for(let[r,l]of Object.entries(e.columns))o.set(r.toLowerCase(),new Set(l.map(i=>i.toLowerCase())));for(let r of s.matchAll(cn)){let l=(r[1]??"").toLowerCase(),i=r[2]??"",a=n.get(l),c=a===void 0?void 0:o.get(a);c!==void 0&&!c.has(i.toLowerCase())&&t.push({length:i.length,message:`\`${a??""}\` has no column \`${i}\``,offset:r.index+r[0].length-i.length,severity:"error",source:"schema"})}return t},"un"),fn=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,hn=/\bas\s+"?([a-z_][\w$]*)"?/giu,pn=d((s,e,n,t)=>{let o=[...new Set(n.values())],r=new Map,l=new Set;for(let c of o){for(let m of e.columns[c]??[])l.add(m.toLowerCase());for(let m of e.docFields?.[c]??[])r.set(m.toLowerCase(),m)}if(r.size===0)return[];let i=new Set([...s.matchAll(hn)].map(c=>(c[1]??"").toLowerCase())),a=[];for(let c of s.matchAll(fn)){let m=c[1],p=m??c[2]??"",f=p.toLowerCase(),b=r.get(f);b===void 0||l.has(f)||i.has(f)||t.has(f)||n.has(f)||a.push({length:p.length,message:`\`${b}\` is a \`__doc__\` field, not a column \u2014 use \`json_extract(__doc__, '$.${b}')\``,offset:c.index+(m===void 0?0:1),severity:"error",source:"schema"})}return a},"pn"),bn=d((s,e)=>{if(s.trim()==="")return[];let n=xt(s),t=new Set(e.tables.map(r=>r.toLowerCase())),o=[];for(let r of n){let{offset:l,rejection:i}=r;if(i!==void 0){o.push({length:i.length,message:i.message,offset:i.offset===void 0?l:l+i.offset,severity:"error",source:"gate"});continue}let{ctes:a,masked:c,targets:m}=vt(r.sql,e.tables);o.push(...[...un(c,t,a),...mn(c,e,m),...pn(c,e,m,a)].map(p=>({...p,offset:p.offset===void 0?l:l+p.offset})))}return o},"hn"),gn=ge(ve.lintSql),xn=600,vn=d((s,e,n)=>{let t=Ce(),[o,r]=(0,j.useState)([]),l=(0,j.useMemo)(()=>bn(s,e),[s,e]),i=et(s,xn),a=l.some(p=>p.source==="gate")||i.trim()==="",c=(0,j.useCallback)(async p=>{try{let f=await t.query(gn,{sql:i},xe(n));p.cancelled||r(f.diagnostics??[])}catch{p.cancelled||r([])}},[t,i,n]);(0,j.useEffect)(()=>{if(a){r([]);return}let p={cancelled:!1};return le(c(p)),()=>{p.cancelled=!0}},[c,a]);let m=i===s;return(0,j.useMemo)(()=>m?[...l,...o]:l,[l,o,m])},"xn"),Le=8,yn=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],wn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Sn=/[\w$]/,yt=d(s=>s!==void 0&&Sn.test(s),"ct"),wt=d(s=>{let e=s.length;for(;e>0&&yt(s[e-1]);)e-=1;return s.slice(e)},"dt"),St=d((s,e)=>{let n=e;for(;n>0&&yt(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"ut"),ct=d((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||wn.has(wt(n).toUpperCase())},"Ge"),qn=d((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=wt(t.slice(0,-1));if(o!=="")return vt(s,n).targets.get(o.toLowerCase())??o},"wn"),We=d((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"We"),dt=d((s,e,n,t)=>{let o=[];for(let r of s)if(We(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Ve"),kn=d((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let l of r)if(We(l,e)&&!t.has(l)&&(t.set(l,o),t.size>=n))return[...t].map(([i,a])=>({detail:a,kind:"column",label:i}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"Cn"),Cn=d((s,e,n)=>{let t=St(s,e),o=qn(s,t.start,n.tables);if(o!==void 0){let a=n.columns[o]??n.columns[o.toLowerCase()]??[];return dt(a,t.text,Le,c=>({detail:o,kind:"column",label:c}))}if(t.text===""&&!ct(s,t.start))return[];let r=dt(n.tables,t.text,Le,a=>({kind:"table",label:a})),l=kn(n,t.text,Le),i=yn.flatMap(a=>t.text!==""&&We(a,t.text)&&a.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(ct(s,t.start)?[...l,...r,...i]:[...r,...l,...i]).slice(0,Le)},"En"),Nn=d((s,e,n)=>{let t=St(s,e),o=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:o}},"Nn"),En=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Ln=d((s,e)=>{let n=globalThis.getComputedStyle(s),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let a of En)o[a]=n[a];t.textContent=s.value.slice(0,Math.max(0,e));let r=globalThis.document.createElement("span");r.textContent=s.value.slice(Math.max(0,e))||".",t.append(r),globalThis.document.body.append(t);let l=r.offsetLeft-s.scrollLeft,i=r.offsetTop-s.scrollTop;return t.remove(),{left:l,top:i}},"Tn"),_n=d((s,e,n)=>{let t=(0,V.c)(16),[o,r]=(0,j.useState)(null),l;t[0]!==s||t[1]!==e?(l=d((N,h)=>{let S=Cn(N,h,s);if(S.length===0){r(null);return}let x=e.current,{left:v,top:y}=x===null?{left:0,top:0}:Ln(x,h);r(w=>w!==null&&w.active===0&&w.left===v&&w.top===y&&w.suggestions.length===S.length&&w.suggestions.every((E,T)=>{let L=S.at(T);return E.kind===L?.kind&&E.label===L.label&&E.detail===L.detail})?w:{active:0,left:v,suggestions:S,top:y})},"r"),t[0]=s,t[1]=e,t[2]=l):l=t[2];let i=l,a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=d(()=>{r(null)},"c"),t[3]=a):a=t[3];let c=a,m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=d(N=>{r(h=>{if(h===null)return h;let S=h.suggestions.length,x=(h.active+N+S)%S;return{...h,active:x}})},"d"),t[4]=m):m=t[4];let p=m,f;t[5]!==n||t[6]!==o||t[7]!==e?(f=d(N=>{let h=e.current;if(o===null||h===null)return!1;let S=o.suggestions[N??o.active];if(S===void 0)return!1;let x=Nn(h.value,h.selectionStart,S);return n(x.value),r(null),requestAnimationFrame(()=>{let v=e.current;v!==null&&(v.focus(),v.setSelectionRange(x.caret,x.caret))}),!0},"f"),t[5]=n,t[6]=o,t[7]=e,t[8]=f):f=t[8];let b=f,g;t[9]!==b?(g=d(()=>b(),"g"),t[9]=b,t[10]=g):g=t[10];let k=g,q;return t[11]!==k||t[12]!==b||t[13]!==i||t[14]!==o?(q={close:c,commit:k,commitAt:b,move:p,refresh:i,state:o},t[11]=k,t[12]=b,t[13]=i,t[14]=o,t[15]=q):q=t[15],q},"Rn"),Tn={column:"column",keyword:"keyword",table:"table"},In=20,Rn=d(s=>{let e=(0,V.c)(17),{listboxId:n,onPick:t,state:o}=s,r=J(),l;e[0]!==o?(l=o===null?void 0:{left:o.left,top:o.top+In},e[0]=o,e[1]=l):l=e[1];let i=l;if(o===null)return null;let a;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==r){let m;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(m=d((p,f)=>(0,u.jsxs)("li",{"aria-selected":f===o.active,className:ie("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",f===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${f.toString()}`,onMouseDown:d(b=>{b.preventDefault(),t(f)},"onMouseDown"),role:"option",children:[(0,u.jsx)("span",{className:"truncate font-mono",children:p.label}),p.detail!==void 0&&(0,u.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:p.detail}),(0,u.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(Tn[p.kind])})]},`${p.kind}:${p.label}`),"d"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=m):m=e[12],a=o.suggestions.map(m),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=r,e[7]=a}else a=e[7];let c;return e[13]!==n||e[14]!==i||e[15]!==a?(c=(0,u.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:n,role:"listbox",style:i,children:a}),e[13]=n,e[14]=i,e[15]=a,e[16]=c):c=e[16],c},"qn"),Dn=ge(ve.listTables),Mn=ge(ve.readTablePage),An=d(s=>{let e=(0,V.c)(18),n=Ce(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,j.useState)(t),l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={},e[1]=l):l=e[1];let[i,a]=(0,j.useState)(l),c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={},e[2]=c):c=e[2];let[m,p]=(0,j.useState)(c),f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[3]=f):f=e[3];let b=(0,j.useRef)(f),g,k;e[4]!==n||e[5]!==s?(g=d(()=>{let v={cancelled:!1};return le((async()=>{try{let y=await n.query(Dn,{},xe(s));v.cancelled||(r(y.map(Pn)),a({}),p({}),b.current=new Set)}catch{v.cancelled||(r([]),a({}),p({}),b.current=new Set)}})()),()=>{v.cancelled=!0}},"g"),k=[n,s],e[4]=n,e[5]=s,e[6]=g,e[7]=k):(g=e[6],k=e[7]),(0,j.useEffect)(g,k);let q;e[8]!==n||e[9]!==s?(q=d(v=>{b.current.has(v)||(b.current.add(v),le((async()=>{try{let y=await n.query(Mn,{limit:1,offset:0,table:v},xe(s)),{sqlColumns:w}=y;if(w===void 0){b.current.delete(v);return}let E=new Set(w),T=y.columns.filter(L=>!E.has(L));a(L=>({...L,[v]:w})),p(L=>({...L,[v]:T}))}catch{b.current.delete(v)}})()))},"v"),e[8]=n,e[9]=s,e[10]=q):q=e[10];let N=q,h;e[11]!==i||e[12]!==m||e[13]!==o?(h={columns:i,docFields:m,tables:o},e[11]=i,e[12]=m,e[13]=o,e[14]=h):h=e[14];let S=h,x;return e[15]!==N||e[16]!==S?(x={probe:N,schema:S},e[15]=N,e[16]=S,e[17]=x):x=e[17],x},"Dn"),ze=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,$n=d(s=>{let e=new Set;ze.lastIndex=0;let n=ze.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=ze.exec(s);return[...e]},"On");function Pn(s){return s.name}d(Pn,"Mn");var On=d(s=>(s.metaKey||s.ctrlKey)&&!s.shiftKey&&!s.altKey&&s.key.toLowerCase()==="i","$n"),zn=d(s=>{let e=(0,V.c)(44),{inlineEditEnabled:n,onSubmit:t,probe:o,schema:r,setDraft:l}=s,i=(0,j.useId)(),[a,c]=(0,j.useState)(null),m=(0,j.useRef)(null),p=(0,j.useRef)(null),f=(0,j.useRef)(null),b=_n(r,f,l),{close:g,commit:k,commitAt:q,move:N,refresh:h,state:S}=b,x;e[0]!==q?(x=d($=>{q($)},"x"),e[0]=q,e[1]=x):x=e[1];let v=x,y;e[2]!==h?(y=d(()=>{let $=f.current;$!==null&&$===document.activeElement&&h($.value,$.selectionStart)},"y"),e[2]=h,e[3]=y):y=e[3];let w;e[4]!==h||e[5]!==r?(w=[h,r],e[4]=h,e[5]=r,e[6]=w):w=e[6],(0,j.useEffect)(y,w);let E;e[7]!==o||e[8]!==h||e[9]!==l?(E=d($=>{let{selectionStart:G,value:Z}=$.target;l(Z),c(null);for(let X of $n(Z))o(X);h(Z,G)},"w"),e[7]=o,e[8]=h,e[9]=l,e[10]=E):E=e[10];let T=E,L;e[11]!==h?(L=d($=>{let G=$.currentTarget;h(G.value,G.selectionStart)},"R"),e[11]=h,e[12]=L):L=e[12];let _=L,C;e[13]!==g||e[14]!==k||e[15]!==N?(C=d($=>$.key==="ArrowDown"?($.preventDefault(),N(1),!0):$.key==="ArrowUp"?($.preventDefault(),N(-1),!0):$.key==="Escape"?($.preventDefault(),g(),!0):($.key==="Enter"||$.key==="Tab")&&!$.metaKey&&!$.ctrlKey&&k()?($.preventDefault(),!0):!1,"k"),e[13]=g,e[14]=k,e[15]=N,e[16]=C):C=e[16];let I=C,R;e[17]!==S||e[18]!==g||e[19]!==n||e[20]!==I||e[21]!==t?(R=d($=>{if(!(S!==null&&I($))){if(($.metaKey||$.ctrlKey)&&$.key==="Enter"){$.preventDefault(),t();return}if(n&&On($)){$.preventDefault(),g();let{selectionEnd:G,selectionStart:Z,value:X}=$.currentTarget,[se,ae]=Z===G?[0,X.length]:[Z,G];c({end:ae,start:se,text:X.slice(se,ae)})}}},"q"),e[17]=S,e[18]=g,e[19]=n,e[20]=I,e[21]=t,e[22]=R):R=e[22];let M=R,z;e[23]!==g?(z=d(()=>{requestAnimationFrame(()=>{g()})},"$"),e[23]=g,e[24]=z):z=e[24];let H=z,W;e[25]===Symbol.for("react.memo_cache_sentinel")?(W=d($=>{let{scrollLeft:G,scrollTop:Z}=$.currentTarget;m.current!==null&&(m.current.scrollTop=Z),p.current!==null&&(p.current.scrollTop=Z,p.current.scrollLeft=G)},"B"),e[25]=W):W=e[25];let B=W,P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=d($=>{let G=f.current;G===null||$.offset===void 0||(G.focus(),G.setSelectionRange($.offset,$.offset+($.length??0)))},"P"),e[26]=P):P=e[26];let K=P,O;e[27]===Symbol.for("react.memo_cache_sentinel")?(O=d(()=>{c(null),f.current?.focus()},"M"),e[27]=O):O=e[27];let D=O,A;e[28]!==a||e[29]!==l?(A=d($=>{let G=f.current;if(a===null||G===null)return;let{end:Z,start:X,text:se}=a;if(G.value.slice(X,Z)!==se){c(null);return}l(G.value.slice(0,X)+$+G.value.slice(Z)),c(null),G.focus(),requestAnimationFrame(()=>{G.setSelectionRange(X,X+$.length)})},"D"),e[28]=a,e[29]=l,e[30]=A):A=e[30];let Q=A,F;e[31]!==T||e[32]!==H||e[33]!==M||e[34]!==_?(F={onBlur:H,onChange:T,onKeyDown:M,onScroll:B,onSelect:_},e[31]=T,e[32]=H,e[33]=M,e[34]=_,e[35]=F):F=e[35];let ee;return e[36]!==Q||e[37]!==S||e[38]!==g||e[39]!==a||e[40]!==i||e[41]!==v||e[42]!==F?(ee={acceptInlineEdit:Q,autocompleteState:S,closeAutocomplete:g,closeInlineEdit:D,inlineEdit:a,handlers:F,listboxId:i,onPickSuggestion:v,editorRef:f,gutterRef:m,overlayRef:p,revealDiagnostic:K},e[36]=Q,e[37]=S,e[38]=g,e[39]=a,e[40]=i,e[41]=v,e[42]=F,e[43]=ee):ee=e[43],ee},"Bn"),Hn="lunora-studio-sql-tabs",jn="lunora-studio-sql-active-tab",Be=12,qe=d((s="",e="")=>({activeId:null,id:Me("tab"),name:e,sql:s}),"Se"),Wn=d(()=>Ee(jn,""),"Hn"),Bn=d(s=>{let e=(0,V.c)(16),[n,t]=Ne(Hn),[o,r]=Wn(),[l]=(0,j.useState)(s),i,a;e[0]!==l||e[1]!==t||e[2]!==n.length?(i=d(()=>{n.length===0&&t([l])},"i"),a=[l,t,n.length],e[0]=l,e[1]=t,e[2]=n.length,e[3]=i,e[4]=a):(i=e[3],a=e[4]),(0,j.useEffect)(i,a);let c;e[5]!==l||e[6]!==n?(c=n.length===0?[l]:n,e[5]=l,e[6]=n,e[7]=c):c=e[7];let m=c,p;e[8]!==o||e[9]!==m?(p=m.some(g=>g.id===o)?o:m[0]?.id??"",e[8]=o,e[9]=m,e[10]=p):p=e[10];let f=p,b;return e[11]!==f||e[12]!==r||e[13]!==t||e[14]!==m?(b={activeId:f,setActiveId:r,setTabs:t,tabs:m},e[11]=f,e[12]=r,e[13]=t,e[14]=m,e[15]=b):b=e[15],b},"Fn"),qt=d(s=>s.activeId===null&&s.sql.trim()!=="","ft"),Fn=d((s,e)=>[...s,e].slice(-Be),"Qn"),Qn=d((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let o=s.filter(r=>r.id!==e);if(o.length===0){let r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},"jn"),Kn=d((s,e)=>{let n=s.filter(t=>t.id===e);return n.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:n}},"zn"),Un=d((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:n,tabs:[...s]};let o=s.slice(0,t+1);return{activeId:o.some(r=>r.id===n)?n:e,tabs:o}},"Kn"),Gn=d(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"Un"),Xn=d((s,e,n)=>{if(s==="others")return e.filter(t=>t.id!==n);if(s==="right"){let t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},"Yn"),ut={error:null,pane:"results",result:null,running:!1},Vn=d(s=>{let e=(0,V.c)(69),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=Bn(s),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let[i,a]=(0,j.useState)(l),[c,m]=(0,j.useState)(null),[p,f]=(0,j.useState)(null),b;e[1]!==n||e[2]!==r?(b=r.find(Y=>Y.id===n)??r[0]??qe(),e[1]=n,e[2]=r,e[3]=b):b=e[3];let g=b,k=i[g.id]??ut,q;e[4]!==g.id||e[5]!==o?(q=d(Y=>{o(te=>te.map(ne=>ne.id===g.id?{...ne,...Y}:ne))},"v"),e[4]=g.id,e[5]=o,e[6]=q):q=e[6];let N=q,h;e[7]!==g.id?(h=d(Y=>{a(te=>{let ne=te[g.id]??ut;return{...te,[g.id]:{...ne,...Y}}})},"p"),e[7]=g.id,e[8]=h):h=e[8];let S=h,x;e[9]!==t||e[10]!==o||e[11]!==r.length?(x=d(Y=>{if(r.length>=Be)return!1;let te=qe(Y);return o(ne=>Fn(ne,te)),t(te.id),!0},"x"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=x):x=e[12];let v=x,y;e[13]!==v?(y=d(()=>{v("")},"y"),e[13]=v,e[14]=y):y=e[14];let w=y,E;e[15]!==t||e[16]!==o?(E=d(Y=>{m(null),f(null),o(Y.tabs),t(Y.activeId);let te=new Set(Y.tabs.map(Yn));a(ne=>Object.fromEntries(Object.entries(ne).filter(U=>{let[oe]=U;return te.has(oe)})))},"w"),e[15]=t,e[16]=o,e[17]=E):E=e[17];let T=E,L;e[18]!==T||e[19]!==r?(L=d(Y=>{T(Qn(r,Y,qe))},"R"),e[18]=T,e[19]=r,e[20]=L):L=e[20];let _=L,C;e[21]!==n||e[22]!==T||e[23]!==r?(C=d((Y,te)=>{T(Y==="others"?Kn(r,te):Y==="right"?Un(r,te,n):Gn(qe))},"k"),e[21]=n,e[22]=T,e[23]=r,e[24]=C):C=e[24];let I=C,R;e[25]!==I||e[26]!==c||e[27]!==r?(R=d(Y=>{c!==null&&(Xn(Y,r,c.id).some(Jn)?f(Y):I(Y,c.id))},"q"),e[25]=I,e[26]=c,e[27]=r,e[28]=R):R=e[28];let M=R,z;e[29]===Symbol.for("react.memo_cache_sentinel")?(z=d((Y,te)=>{te.preventDefault(),f(null),m({id:Y,x:te.clientX,y:te.clientY})},"$"),e[29]=z):z=e[29];let H=z,W;e[30]===Symbol.for("react.memo_cache_sentinel")?(W=d(()=>{m(null),f(null)},"B"),e[30]=W):W=e[30];let B=W,P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=d(Y=>{Y.preventDefault(),m(null),f(null)},"P"),e[31]=P):P=e[31];let K=P,O;e[32]!==M?(O=d(()=>{M("others")},"M"),e[32]=M,e[33]=O):O=e[33];let D=O,A;e[34]!==M?(A=d(()=>{M("right")},"D"),e[34]=M,e[35]=A):A=e[35];let Q=A,F;e[36]!==M?(F=d(()=>{M("all")},"j"),e[36]=M,e[37]=F):F=e[37];let ee=F,$;e[38]!==I||e[39]!==p||e[40]!==c?($=d(()=>{c!==null&&p!==null&&I(p,c.id),f(null)},"O"),e[38]=I,e[39]=p,e[40]=c,e[41]=$):$=e[41];let G=$,Z;e[42]===Symbol.for("react.memo_cache_sentinel")?(Z=d(()=>{f(null)},"X"),e[42]=Z):Z=e[42];let X=Z,se;e[43]!==c?(se=c===null?void 0:{left:c.x,top:c.y},e[43]=c,e[44]=se):se=e[44];let ae=se,ue;e[45]!==o?(ue=d(Y=>{o(te=>te.map(ne=>ne.activeId===Y?{...ne,activeId:null}:ne))},"pe"),e[45]=o,e[46]=ue):ue=e[46];let pe=ue,me;e[47]!==o?(me=d((Y,te)=>{o(ne=>ne.map(U=>U.id===Y?{...U,name:te}:U))},"he"),e[47]=o,e[48]=me):me=e[48];let be=me,fe;return e[49]!==g||e[50]!==n||e[51]!==w||e[52]!==_||e[53]!==G||e[54]!==ee||e[55]!==D||e[56]!==Q||e[57]!==v||e[58]!==k||e[59]!==S||e[60]!==N||e[61]!==p||e[62]!==be||e[63]!==t||e[64]!==c||e[65]!==ae||e[66]!==r||e[67]!==pe?(fe={activeTab:g,activeTabId:n,addEditorTab:w,cancelBulk:X,closeEditorTab:_,closeTabMenu:B,confirmBulk:G,menuStyle:ae,onBackdropContextMenu:K,onCloseAll:ee,onCloseOthers:D,onCloseToRight:Q,openEditorTab:v,openTabMenu:H,output:k,patchActiveOutput:S,patchActiveTab:N,pendingBulk:p,renameTab:be,setActiveTabId:t,tabMenu:c,tabs:r,unlinkQuery:pe},e[49]=g,e[50]=n,e[51]=w,e[52]=_,e[53]=G,e[54]=ee,e[55]=D,e[56]=Q,e[57]=v,e[58]=k,e[59]=S,e[60]=N,e[61]=p,e[62]=be,e[63]=t,e[64]=c,e[65]=ae,e[66]=r,e[67]=pe,e[68]=fe):fe=e[68],fe},"Gn");function Yn(s){return s.id}d(Yn,"Vn");function Jn(s){return qt(s)}d(Jn,"Jn");var Zn="lunora-studio-sql-queries",he="lunora-studio-sql-history",eo="lunora-studio-sql-remember-history",to=25,no=d(s=>{let e=(0,V.c)(44),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=J(),[r,l]=Ne(Zn),[i,a]=Ee(eo,!1),[c,m]=Ne(he,i?"local":"session"),p,f;e[0]!==i?(p=d(()=>{i||we(he,"local")},"m"),f=[i],e[0]=i,e[1]=p,e[2]=f):(p=e[1],f=e[2]),(0,j.useEffect)(p,f);let[b,g]=(0,j.useState)(""),k=(0,j.useRef)(null),q;e[3]!==m?(q=d(D=>{m(A=>A[0]?.sql===D?A:[{at:Date.now(),sql:D},...A.filter(Q=>Q.sql!==D)].slice(0,to))},"v"),e[3]=m,e[4]=q):q=e[4];let N=q,h;e[5]!==n||e[6]!==l||e[7]!==o?(h=d(()=>{let D={id:Me("q"),name:o("Untitled query"),sql:""};l(A=>[D,...A]),n("",D.id)},"p"),e[5]=n,e[6]=l,e[7]=o,e[8]=h):h=e[8];let S=h,x;e[9]!==n||e[10]!==r?(x=d(D=>{let A=r.find(Q=>Q.id===D);A!==void 0&&(n(A.sql,D),k.current?.querySelector(`[data-testid="sql-query-${D}"]`)?.scrollIntoView({block:"nearest"}))},"x"),e[9]=n,e[10]=r,e[11]=x):x=e[11];let v=x,y;e[12]!==l||e[13]!==t?(y=d(D=>{l(A=>A.filter(Q=>Q.id!==D)),t(D)},"y"),e[12]=l,e[13]=t,e[14]=y):y=e[14];let w=y,E;e[15]!==n?(E=d(D=>{n(D.currentTarget.dataset.sql??"",null)},"w"),e[15]=n,e[16]=E):E=e[16];let T=E,L;e[17]!==n?(L=d(D=>{n(D.currentTarget.dataset.sql??"",null)},"R"),e[17]=n,e[18]=L):L=e[18];let _=L,C;e[19]!==m?(C=d(()=>{m([]),we(he,"local"),we(he,"session")},"k"),e[19]=m,e[20]=C):C=e[20];let I=C,R;e[21]!==c||e[22]!==a?(R=d(D=>{Xe(he,c,D?"local":"session"),D||we(he,"local"),a(D)},"q"),e[21]=c,e[22]=a,e[23]=R):R=e[23];let M=R,z;e[24]===Symbol.for("react.memo_cache_sentinel")?(z=d(D=>{g(D.target.value)},"$"),e[24]=z):z=e[24];let H=z,W;e[25]!==l?(W=d((D,A,Q)=>{l(F=>F.map(ee=>ee.id===D?{id:ee.id,name:A,sql:ee.sql,...Q===""?{}:{description:Q}}:ee))},"B"),e[25]=l,e[26]=W):W=e[26];let B=W,P;e[27]!==l?(P=d((D,A)=>{l(Q=>Q.map(F=>F.id===D?{...F,sql:A}:F))},"P"),e[27]=l,e[28]=P):P=e[28];let K=P,O;return e[29]!==I||e[30]!==w||e[31]!==c||e[32]!==_||e[33]!==T||e[34]!==S||e[35]!==r||e[36]!==N||e[37]!==i||e[38]!==B||e[39]!==b||e[40]!==v||e[41]!==M||e[42]!==K?(O={clearHistory:I,deleteQuery:w,history:c,listRef:k,loadFromHistory:_,loadTemplate:T,newQuery:S,onSearchChange:H,queries:r,recordHistory:N,rememberHistory:i,renameQuery:B,search:b,selectQuery:v,setRememberHistory:M,updateQuerySql:K},e[29]=I,e[30]=w,e[31]=c,e[32]=_,e[33]=T,e[34]=S,e[35]=r,e[36]=N,e[37]=i,e[38]=B,e[39]=b,e[40]=v,e[41]=M,e[42]=K,e[43]=O):O=e[43],O},"ts"),Fe="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",oo=d((s,e)=>{let n=[];for(let o of s){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;let r=Math.max(0,Math.min(o.offset,e)),l=Math.max(r,Math.min(o.offset+o.length,e));r!==l&&n.push({end:l,severity:o.severity,start:r})}n.sort((o,r)=>o.start-r.start);let t=[];for(let o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},"ns"),ro=d(s=>{let e=(0,V.c)(51),{rpc:n,failed:t,onGenerated:o}=s,r=J(),[l,i]=(0,j.useState)("");if(n.unavailable)return null;let a;e[0]!==n?(a=n.pending("sql"),e[0]=n,e[1]=a):a=e[1];let c=a,m;if(e[2]!==t||e[3]!==o||e[4]!==c||e[5]!==l||e[6]!==n||e[7]!==r){let p=n.reason("sql"),f;e[9]!==t||e[10]!==o||e[11]!==l||e[12]!==n?(f=d(_=>{let C=l.trim();C===""&&!_||le((async()=>{let I=await n.generate(C===""?"fix the failing statement":C,_?t:void 0);I!==void 0&&o(I)})())},"f"),e[9]=t,e[10]=o,e[11]=l,e[12]=n,e[13]=f):f=e[13];let b=f,g;e[14]!==r?(g=r("Describe the query you want"),e[14]=r,e[15]=g):g=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=d(_=>{i(_.target.value)},"L"),e[16]=k):k=e[16];let q;e[17]!==b?(q=d(_=>{_.key==="Enter"&&(_.preventDefault(),b(!1))},"v"),e[17]=b,e[18]=q):q=e[18];let N;e[19]!==r?(N=r("Describe the query you want"),e[19]=r,e[20]=N):N=e[20];let h;e[21]!==c||e[22]!==l||e[23]!==g||e[24]!==q||e[25]!==N?(h=(0,u.jsx)(ye,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:c,onChange:k,onKeyDown:q,placeholder:N,value:l}),e[21]=c,e[22]=l,e[23]=g,e[24]=q,e[25]=N,e[26]=h):h=e[26];let S=c&&"opacity-60",x;e[27]!==S?(x=ie("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",S),e[27]=S,e[28]=x):x=e[28];let v;e[29]!==c||e[30]!==l?(v=c||l.trim()==="",e[29]=c,e[30]=l,e[31]=v):v=e[31];let y;e[32]!==b?(y=d(()=>{b(!1)},"y"),e[32]=b,e[33]=y):y=e[33];let w;e[34]!==c||e[35]!==r?(w=r(c?"Thinking\u2026":"Draft SQL"),e[34]=c,e[35]=r,e[36]=w):w=e[36];let E;e[37]!==x||e[38]!==v||e[39]!==y||e[40]!==w?(E=(0,u.jsx)("button",{className:x,"data-testid":"sql-assistant-generate",disabled:v,onClick:y,type:"button",children:w}),e[37]=x,e[38]=v,e[39]=y,e[40]=w,e[41]=E):E=e[41];let T;e[42]!==t||e[43]!==c||e[44]!==b||e[45]!==r?(T=t!==void 0&&(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:c,onClick:d(()=>{b(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=c,e[44]=b,e[45]=r,e[46]=T):T=e[46];let L;e[47]!==E||e[48]!==T||e[49]!==h?(L=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[h,E,T]}),e[47]=E,e[48]=T,e[49]=h,e[50]=L):L=e[50],m=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[L,p!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ae(p,r)})]}),e[2]=t,e[3]=o,e[4]=c,e[5]=l,e[6]=n,e[7]=r,e[8]=m}else m=e[8];return m},"ss"),so=d(s=>{let e=(0,V.c)(8),{diagnostics:n,draft:t,scrollRef:o}=s,r,l;if(e[0]!==n||e[1]!==t){l=Symbol.for("react.early_return_sentinel");e:{let c=oo(n,t.length);if(c.length===0){l=null;break e}r=[];let m=0;for(let[p,f]of c.entries())f.start>m&&r.push(t.slice(m,f.start)),r.push((0,u.jsx)("span",{className:ie("decoration-wavy underline underline-offset-4",f.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(f.start,f.end)},`${f.start.toString()}-${p.toString()}`)),m=f.end;r.push(t.slice(m))}e[0]=n,e[1]=t,e[2]=r,e[3]=l}else r=e[2],l=e[3];if(l!==Symbol.for("react.early_return_sentinel"))return l;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=ie("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Fe),e[4]=i):i=e[4];let a;return e[5]!==r||e[6]!==o?(a=(0,u.jsx)("div",{"aria-hidden":"true",className:i,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=a):a=e[7],a},"os"),lo={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},io=d(s=>{let e=(0,V.c)(10),{diagnostics:n,onSelect:t}=s,o=J();if(n.length===0)return null;let r;e[0]!==o?(r=o("SQL problems"),e[0]=o,e[1]=r):r=e[1];let l;if(e[2]!==n||e[3]!==t){let a;e[5]!==t?(a=d((c,m)=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:d(()=>{t(c)},"onClick"),type:"button",children:[(0,u.jsx)("span",{className:ie("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",c.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:lo[c.source]}),(0,u.jsx)("span",{className:"min-w-0 text-muted-foreground",children:c.message})]})},`${c.source}-${(c.offset??m).toString()}-${m.toString()}`),"c"),e[5]=t,e[6]=a):a=e[6],l=n.map(a),e[2]=n,e[3]=t,e[4]=l}else l=e[4];let i;return e[7]!==r||e[8]!==l?(i=(0,u.jsx)("ul",{"aria-label":r,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:l}),e[7]=r,e[8]=l,e[9]=i):i=e[9],i},"rs"),ao=d(s=>(s.endsWith(`
13
+ `)?s.slice(0,-1):s).split(`
14
+ `),"is"),co=d((s,e)=>{let n=[],t=1,o=1;for(let r of Pe(s,e,{ignoreNewlineAtEof:!0}))for(let l of ao(r.value))r.added?(n.push({after:o,kind:"added",text:l}),o+=1):r.removed?(n.push({before:t,kind:"removed",text:l}),t+=1):(n.push({after:o,before:t,kind:"context",text:l}),t+=1,o+=1);return n},"as"),uo={added:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",context:"text-muted-foreground",removed:"bg-destructive/10 text-destructive"},mo={added:"+",context:" ",removed:"-"},fo=d(s=>{let e=(0,V.c)(11),{lines:n}=s,t=J(),o;e[0]!==t?(o=t("Proposed edit"),e[0]=t,e[1]=o):o=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=ie("max-h-48 overflow-auto rounded-md border border-border bg-background",Fe),e[2]=r):r=e[2];let l;if(e[3]!==n||e[4]!==t){let a;e[6]!==t?(a=d(c=>(0,u.jsxs)("li",{className:ie("flex gap-2",uo[c.kind]),"data-kind":c.kind,children:[(0,u.jsx)("span",{"aria-hidden":"true",className:"shrink-0 select-none opacity-60",children:mo[c.kind]}),c.kind!=="context"&&(0,u.jsx)("span",{className:"sr-only",children:c.kind==="added"?t("Added"):t("Removed")}),(0,u.jsx)("span",{className:"min-w-0",children:c.text===""?"\xA0":c.text})]},`${String(c.before)}:${String(c.after)}`),"c"),e[6]=t,e[7]=a):a=e[7],l=n.map(a),e[3]=n,e[4]=t,e[5]=l}else l=e[5];let i;return e[8]!==o||e[9]!==l?(i=(0,u.jsx)("ul",{"aria-label":o,className:r,"data-testid":"sql-inline-diff",children:l}),e[8]=o,e[9]=l,e[10]=i):i=e[10],i},"us"),_e="rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",ho=d(s=>{let e=(0,V.c)(41),{onAccept:n,onCancel:t,rpc:o,source:r,whole:l}=s,i=J(),a=(0,j.useRef)(null),c=(0,j.useRef)(null),[m,p]=(0,j.useState)(""),[f,b]=(0,j.useState)(null),g,k;if(e[0]!==f?(g=d(()=>{f===null?a.current?.focus():c.current?.focus()},"g"),k=[f],e[0]=f,e[1]=g,e[2]=k):(g=e[1],k=e[2]),(0,j.useEffect)(g,k),o.unavailable)return null;let q;e[3]!==o?(q=o.pending("sql"),e[3]=o,e[4]=q):q=e[4];let N=q,h;if(e[5]!==m||e[6]!==n||e[7]!==t||e[8]!==N||e[9]!==f||e[10]!==o||e[11]!==r||e[12]!==i||e[13]!==l){let S=o.reason("sql"),x;e[15]!==m||e[16]!==o||e[17]!==r?(x=d(()=>{let I=m.trim();I===""||r.trim()===""||le((async()=>{let R=await o.rewrite(I,r);R!==void 0&&b(R)})())},"x"),e[15]=m,e[16]=o,e[17]=r,e[18]=x):x=e[18];let v=x,y;e[19]!==t?(y=d(I=>{I.key==="Escape"&&(I.preventDefault(),t())},"y"),e[19]=t,e[20]=y):y=e[20];let w=y,E;e[21]!==i||e[22]!==l?(E=i(l?"Whole query":"Selection"),e[21]=i,e[22]=l,e[23]=E):E=e[23];let T;e[24]!==E?(T=(0,u.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] uppercase text-muted-foreground","data-testid":"sql-inline-edit-scope",children:E}),e[24]=E,e[25]=T):T=e[25];let L;e[26]!==m||e[27]!==n||e[28]!==t||e[29]!==w||e[30]!==N||e[31]!==f||e[32]!==v||e[33]!==i?(L=f===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(ye,{"aria-label":i("Tell the model what to change"),className:"h-7 flex-1 text-xs","data-testid":"sql-inline-edit-prompt",disabled:N,onChange:d(I=>{p(I.target.value)},"onChange"),onKeyDown:d(I=>{if(I.key==="Enter"){I.preventDefault(),v();return}w(I)},"onKeyDown"),placeholder:i("Tell the model what to change"),ref:a,value:m}),(0,u.jsx)("button",{className:ie(_e,N&&"opacity-60"),"data-testid":"sql-inline-edit-submit",disabled:N||m.trim()==="",onClick:v,onKeyDown:w,type:"button",children:i(N?"Thinking\u2026":"Rewrite")}),(0,u.jsx)("button",{className:_e,"data-testid":"sql-inline-edit-cancel",onClick:t,onKeyDown:w,type:"button",children:i("Cancel")})]}):(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("span",{className:"flex-1 text-xs text-muted-foreground",children:i("Proposed edit")}),(0,u.jsx)("button",{className:_e,"data-testid":"sql-inline-edit-accept",onClick:d(()=>{n(f)},"onClick"),onKeyDown:w,ref:c,type:"button",children:i("Accept")}),(0,u.jsx)("button",{className:_e,"data-testid":"sql-inline-edit-reject",onClick:d(()=>{b(null)},"onClick"),onKeyDown:w,type:"button",children:i("Reject")})]}),e[26]=m,e[27]=n,e[28]=t,e[29]=w,e[30]=N,e[31]=f,e[32]=v,e[33]=i,e[34]=L):L=e[34];let _;e[35]!==T||e[36]!==L?(_=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[T,L]}),e[35]=T,e[36]=L,e[37]=_):_=e[37];let C;e[38]!==f||e[39]!==r?(C=f!==null&&(0,u.jsx)(fo,{lines:co(r,f)}),e[38]=f,e[39]=r,e[40]=C):C=e[40],h=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border bg-muted/20 px-3 py-2","data-testid":"sql-inline-edit",children:[_,C,S!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-inline-edit-reason",role:"status",children:Ae(S,i)})]}),e[5]=m,e[6]=n,e[7]=t,e[8]=N,e[9]=f,e[10]=o,e[11]=r,e[12]=i,e[13]=l,e[14]=h}else h=e[14];return h},"fs"),po={minWidth:"2.75rem",paddingInline:"0.5rem"},bo=d(s=>{let e=(0,V.c)(75),{rpc:n,autocomplete:t,diagnostics:o,draft:r,failed:l,handlers:i,editorRef:a,gutterRef:c,inlineEdit:m,listboxId:p,onAcceptInlineEdit:f,onCancelInlineEdit:b,onGenerated:g,onPickSuggestion:k,onRevealDiagnostic:q,overlayRef:N}=s,h=J(),S,x,v,y,w,E,T,L,_;if(e[0]!==r||e[1]!==l||e[2]!==c||e[3]!==m||e[4]!==f||e[5]!==b||e[6]!==g||e[7]!==n){let A=r.split(`
15
+ `).length;T="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==l||e[18]!==g||e[19]!==n?(L=(0,u.jsx)(ro,{failed:l,onGenerated:g,rpc:n}),e[17]=l,e[18]=g,e[19]=n,e[20]=L):L=e[20],e[21]!==r.length||e[22]!==m||e[23]!==f||e[24]!==b||e[25]!==n?(_=m!==null&&(0,u.jsx)(ho,{onAccept:f,onCancel:b,rpc:n,source:m.text,whole:m.start===0&&m.end===r.length},`${m.start.toString()}-${m.end.toString()}`),e[21]=r.length,e[22]=m,e[23]=f,e[24]=b,e[25]=n,e[26]=_):_=e[26],E="flex min-h-0 min-w-0 flex-1",S="true",x="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",v=c,y=po,w=Array.from({length:A},go),e[0]=r,e[1]=l,e[2]=c,e[3]=m,e[4]=f,e[5]=b,e[6]=g,e[7]=n,e[8]=S,e[9]=x,e[10]=v,e[11]=y,e[12]=w,e[13]=E,e[14]=T,e[15]=L,e[16]=_}else S=e[8],x=e[9],v=e[10],y=e[11],w=e[12],E=e[13],T=e[14],L=e[15],_=e[16];let C;e[27]!==S||e[28]!==x||e[29]!==v||e[30]!==y||e[31]!==w?(C=(0,u.jsx)("div",{"aria-hidden":S,className:x,ref:v,style:y,children:w}),e[27]=S,e[28]=x,e[29]=v,e[30]=y,e[31]=w,e[32]=C):C=e[32];let I;e[33]!==o||e[34]!==r||e[35]!==N?(I=(0,u.jsx)(so,{diagnostics:o,draft:r,scrollRef:N}),e[33]=o,e[34]=r,e[35]=N,e[36]=I):I=e[36];let R;e[37]!==t||e[38]!==p?(R=t===null?void 0:`${p}-opt-${t.active.toString()}`,e[37]=t,e[38]=p,e[39]=R):R=e[39];let M=t===null?void 0:p,z=t!==null,H;e[40]!==h?(H=h("SQL query"),e[40]=h,e[41]=H):H=e[41];let W;e[42]!==r||e[43]!==a||e[44]!==i.onBlur||e[45]!==i.onChange||e[46]!==i.onKeyDown||e[47]!==i.onScroll||e[48]!==i.onSelect||e[49]!==R||e[50]!==M||e[51]!==z||e[52]!==H?(W=(0,u.jsx)("textarea",{"aria-activedescendant":R,"aria-autocomplete":"list","aria-controls":M,"aria-expanded":z,"aria-label":H,className:`relative size-full resize-none bg-transparent outline-none ${Fe}`,"data-testid":"sql-input",onBlur:i.onBlur,onChange:i.onChange,onKeyDown:i.onKeyDown,onScroll:i.onScroll,onSelect:i.onSelect,placeholder:"SELECT * FROM \u2026",ref:a,role:"combobox",spellCheck:!1,value:r}),e[42]=r,e[43]=a,e[44]=i.onBlur,e[45]=i.onChange,e[46]=i.onKeyDown,e[47]=i.onScroll,e[48]=i.onSelect,e[49]=R,e[50]=M,e[51]=z,e[52]=H,e[53]=W):W=e[53];let B;e[54]!==t||e[55]!==p||e[56]!==k?(B=(0,u.jsx)(Rn,{listboxId:p,onPick:k,state:t}),e[54]=t,e[55]=p,e[56]=k,e[57]=B):B=e[57];let P;e[58]!==I||e[59]!==W||e[60]!==B?(P=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[I,W,B]}),e[58]=I,e[59]=W,e[60]=B,e[61]=P):P=e[61];let K;e[62]!==C||e[63]!==P||e[64]!==E?(K=(0,u.jsxs)("div",{className:E,children:[C,P]}),e[62]=C,e[63]=P,e[64]=E,e[65]=K):K=e[65];let O;e[66]!==o||e[67]!==q?(O=(0,u.jsx)(io,{diagnostics:o,onSelect:q}),e[66]=o,e[67]=q,e[68]=O):O=e[68];let D;return e[69]!==K||e[70]!==O||e[71]!==T||e[72]!==L||e[73]!==_?(D=(0,u.jsxs)("div",{className:T,children:[L,_,K,O]}),e[69]=K,e[70]=O,e[71]=T,e[72]=L,e[73]=_,e[74]=D):D=e[74],D},"ps");function go(s,e){return(0,u.jsx)("div",{children:e+1},e)}d(go,"hs");var xo=d(s=>{let e=(0,V.c)(62),{onCancel:n,onSave:t,query:o,rpc:r}=s,l=J(),[i,a]=(0,j.useState)(o.name),[c,m]=(0,j.useState)(o.description??""),p;e[0]!==o.sql||e[1]!==r?(p=r!==void 0&&!r.unavailable&&o.sql.trim()!=="",e[0]=o.sql,e[1]=r,e[2]=p):p=e[2];let f=p,b;e[3]!==r?(b=r?.pending("name"),e[3]=r,e[4]=b):b=e[4];let g=b===!0,k;e[5]!==r?(k=r?.reason("name"),e[5]=r,e[6]=k):k=e[6];let q=k,N;e[7]!==c||e[8]!==i||e[9]!==o.sql||e[10]!==r?(N=d(()=>{if(r===void 0)return;let O=i,D=c;le((async()=>{let A=await r.nameQuery(o.sql);A!==void 0&&(a(Q=>Q===O?A.title:Q),m(Q=>Q===D?A.description:Q))})())},"S"),e[7]=c,e[8]=i,e[9]=o.sql,e[10]=r,e[11]=N):N=e[11];let h=N,S;e[12]!==c||e[13]!==i||e[14]!==t?(S=d(O=>{O.preventDefault();let D=i.trim();D!==""&&t(D,c.trim())},"N"),e[12]=c,e[13]=i,e[14]=t,e[15]=S):S=e[15];let x=S,v=`sql-query-rename-${o.id}`,y;e[16]!==l?(y=l("Query name"),e[16]=l,e[17]=y):y=e[17];let w;e[18]===Symbol.for("react.memo_cache_sentinel")?(w=d(O=>{a(O.target.value)},"C"),e[18]=w):w=e[18];let E;e[19]!==l?(E=l("Query name"),e[19]=l,e[20]=E):E=e[20];let T;e[21]!==i||e[22]!==y||e[23]!==E?(T=(0,u.jsx)(ye,{"aria-label":y,autoFocus:!0,className:"h-7 text-xs","data-testid":"sql-query-name",onChange:w,placeholder:E,value:i}),e[21]=i,e[22]=y,e[23]=E,e[24]=T):T=e[24];let L;e[25]!==l?(L=l("Query description"),e[25]=l,e[26]=L):L=e[26];let _;e[27]===Symbol.for("react.memo_cache_sentinel")?(_=d(O=>{m(O.target.value)},"T"),e[27]=_):_=e[27];let C;e[28]!==l?(C=l("Query description"),e[28]=l,e[29]=C):C=e[29];let I;e[30]!==c||e[31]!==L||e[32]!==C?(I=(0,u.jsx)(ye,{"aria-label":L,className:"h-7 text-xs","data-testid":"sql-query-description",onChange:_,placeholder:C,value:c}),e[30]=c,e[31]=L,e[32]=C,e[33]=I):I=e[33];let R;e[34]!==l?(R=l("Save"),e[34]=l,e[35]=R):R=e[35];let M;e[36]!==R?(M=(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-rename-save",type:"submit",children:R}),e[36]=R,e[37]=M):M=e[37];let z;e[38]!==l?(z=l("Cancel"),e[38]=l,e[39]=z):z=e[39];let H;e[40]!==n||e[41]!==z?(H=(0,u.jsx)("button",{className:"rounded-md px-2 py-0.5 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-query-rename-cancel",onClick:n,type:"button",children:z}),e[40]=n,e[41]=z,e[42]=H):H=e[42];let W;e[43]!==f||e[44]!==g||e[45]!==h||e[46]!==l?(W=f&&(0,u.jsx)("button",{className:"ms-auto rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-suggest-name",disabled:g,onClick:h,type:"button",children:l(g?"Thinking\u2026":"Suggest")}),e[43]=f,e[44]=g,e[45]=h,e[46]=l,e[47]=W):W=e[47];let B;e[48]!==M||e[49]!==H||e[50]!==W?(B=(0,u.jsxs)("div",{className:"flex items-center gap-1",children:[M,H,W]}),e[48]=M,e[49]=H,e[50]=W,e[51]=B):B=e[51];let P;e[52]!==q||e[53]!==l?(P=q!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-query-name-reason",role:"status",children:l(q==="ai-error"?"The model could not be reached.":"The model returned nothing usable.")}),e[52]=q,e[53]=l,e[54]=P):P=e[54];let K;return e[55]!==x||e[56]!==T||e[57]!==I||e[58]!==B||e[59]!==P||e[60]!==v?(K=(0,u.jsxs)("form",{className:"flex flex-col gap-1 rounded-md bg-sidebar-accent p-1.5","data-testid":v,onSubmit:x,children:[T,I,B,P]}),e[55]=x,e[56]=T,e[57]=I,e[58]=B,e[59]=P,e[60]=v,e[61]=K):K=e[61],K},"bs"),kt=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],vo=d(s=>{let e=(0,V.c)(44),{active:n,onDelete:t,onRename:o,onSelect:r,query:l}=s,i=J(),a;e[0]!==r||e[1]!==l.id?(a=d(()=>{r(l.id)},"c"),e[0]=r,e[1]=l.id,e[2]=a):a=e[2];let c=a,m;e[3]!==t||e[4]!==l.id?(m=d(R=>{R.stopPropagation(),t(l.id)},"d"),e[3]=t,e[4]=l.id,e[5]=m):m=e[5];let p=m,f;e[6]!==o||e[7]!==l.id?(f=d(R=>{R.stopPropagation(),o(l.id)},"f"),e[6]=o,e[7]=l.id,e[8]=f):f=e[8];let b=f,g=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",k;e[9]!==g?(k=ie("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[9]=g,e[10]=k):k=e[10];let q=`sql-query-${l.id}`,N;e[11]===Symbol.for("react.memo_cache_sentinel")?(N=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[11]=N):N=e[11];let h;e[12]!==l.name?(h=(0,u.jsx)("span",{className:"truncate",children:l.name}),e[12]=l.name,e[13]=h):h=e[13];let S;e[14]!==n||e[15]!==c||e[16]!==l.description||e[17]!==k||e[18]!==q||e[19]!==h?(S=(0,u.jsxs)("button",{"aria-pressed":n,className:k,"data-testid":q,onClick:c,title:l.description,type:"button",children:[N,h]}),e[14]=n,e[15]=c,e[16]=l.description,e[17]=k,e[18]=q,e[19]=h,e[20]=S):S=e[20];let x;e[21]!==i?(x=i("Rename query"),e[21]=i,e[22]=x):x=e[22];let v=`sql-query-rename-open-${l.id}`,y;e[23]!==i?(y=i("Rename query"),e[23]=i,e[24]=y):y=e[24];let w;e[25]===Symbol.for("react.memo_cache_sentinel")?(w=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M4 20h4L19 9l-4-4L4 16zM14 6l4 4"})}),e[25]=w):w=e[25];let E;e[26]!==b||e[27]!==x||e[28]!==v||e[29]!==y?(E=(0,u.jsx)("button",{"aria-label":x,className:"hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground group-hover/q:flex","data-testid":v,onClick:b,title:y,type:"button",children:w}),e[26]=b,e[27]=x,e[28]=v,e[29]=y,e[30]=E):E=e[30];let T;e[31]!==i?(T=i("Delete query"),e[31]=i,e[32]=T):T=e[32];let L;e[33]!==i?(L=i("Delete query"),e[33]=i,e[34]=L):L=e[34];let _;e[35]===Symbol.for("react.memo_cache_sentinel")?(_=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[35]=_):_=e[35];let C;e[36]!==p||e[37]!==T||e[38]!==L?(C=(0,u.jsx)("button",{"aria-label":T,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:p,title:L,type:"button",children:_}),e[36]=p,e[37]=T,e[38]=L,e[39]=C):C=e[39];let I;return e[40]!==E||e[41]!==C||e[42]!==S?(I=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[S,E,C]}),e[40]=E,e[41]=C,e[42]=S,e[43]=I):I=e[43],I},"gs"),mt="sql-history-remember",yo=d((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"xs"),wo=d(s=>{let e=(0,V.c)(53),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:l,onLoadHistory:i,onLoadTemplate:a,onNew:c,onRename:m,onSearchChange:p,onSelect:f,onToggleRememberHistory:b,queries:g,rememberHistory:k,rpc:q,search:N}=s,h=J(),S=yo(g,N),[x,v]=(0,j.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=d(()=>{v(null)},"y"),e[0]=y):y=e[0];let w=y,E;e[1]!==b?(E=d(X=>{b(X.target.checked)},"w"),e[1]=b,e[2]=E):E=e[2];let T=E,L="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",_;e[3]!==h?(_=h("Search queries\u2026"),e[3]=h,e[4]=_):_=e[4];let C;e[5]!==p||e[6]!==N||e[7]!==_?(C=(0,u.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:p,placeholder:_,type:"text",value:N}),e[5]=p,e[6]=N,e[7]=_,e[8]=C):C=e[8];let I;e[9]!==h?(I=h("New query"),e[9]=h,e[10]=I):I=e[10];let R;e[11]!==h?(R=h("New query"),e[11]=h,e[12]=R):R=e[12];let M;e[13]===Symbol.for("react.memo_cache_sentinel")?(M=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[13]=M):M=e[13];let z;e[14]!==c||e[15]!==I||e[16]!==R?(z=(0,u.jsx)("button",{"aria-label":I,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:c,title:R,type:"button",children:M}),e[14]=c,e[15]=I,e[16]=R,e[17]=z):z=e[17];let H;e[18]!==C||e[19]!==z?(H=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[C,z]}),e[18]=C,e[19]=z,e[20]=H):H=e[20];let W="flex flex-1 flex-col gap-4 overflow-y-auto p-2",B;e[21]!==h?(B=h("Private"),e[21]=h,e[22]=B):B=e[22];let P;e[23]!==B?(P=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:B}),e[23]=B,e[24]=P):P=e[24];let K=S.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:h("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:S.map(X=>x===X.id?(0,u.jsx)("li",{children:(0,u.jsx)(xo,{onCancel:w,onSave:d((se,ae)=>{m(X.id,se,ae),w()},"onSave"),query:X,rpc:q})},X.id):(0,u.jsx)(vo,{active:n===X.id,onDelete:l,onRename:v,onSelect:f,query:X},X.id))}),O;e[25]!==P||e[26]!==K?(O=(0,u.jsxs)("div",{children:[P,K]}),e[25]=P,e[26]=K,e[27]=O):O=e[27];let D;e[28]!==h?(D=h("Reference"),e[28]=h,e[29]=D):D=e[29];let A;e[30]!==D?(A=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D}),e[30]=D,e[31]=A):A=e[31];let Q;e[32]!==a?(Q=kt.map(X=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":X.sql,onClick:a,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),X.label]})},X.label)),e[32]=a,e[33]=Q):Q=e[33];let F;e[34]!==Q?(F=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:Q}),e[34]=Q,e[35]=F):F=e[35];let ee;e[36]!==A||e[37]!==F?(ee=(0,u.jsxs)("div",{children:[A,F]}),e[36]=A,e[37]=F,e[38]=ee):ee=e[38];let $;e[39]!==t||e[40]!==r||e[41]!==i||e[42]!==T||e[43]!==k||e[44]!==h?($=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h("History")}),(0,u.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:r,type:"button",children:h("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:mt,children:[(0,u.jsx)("input",{checked:k,"data-testid":"sql-history-remember",id:mt,onChange:T,type:"checkbox"}),h("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(X=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":X.sql,"data-testid":"sql-history-item",onClick:i,title:X.sql,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:X.sql})]})},`${X.at.toString()}:${X.sql}`))})]}),e[39]=t,e[40]=r,e[41]=i,e[42]=T,e[43]=k,e[44]=h,e[45]=$):$=e[45];let G;e[46]!==O||e[47]!==ee||e[48]!==$?(G=(0,u.jsxs)("div",{className:W,children:[O,ee,$]}),e[46]=O,e[47]=ee,e[48]=$,e[49]=G):G=e[49];let Z;return e[50]!==H||e[51]!==G?(Z=(0,u.jsxs)("aside",{className:L,children:[H,G]}),e[50]=H,e[51]=G,e[52]=Z):Z=e[52],Z},"vs"),Te=d(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"ke"),So=d(s=>{let e=(0,V.c)(16),{chatOpen:n,onToggle:t}=s,o=J(),r;e[0]!==o?(r=o("Ask about your data"),e[0]=o,e[1]=r):r=e[1];let l=`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${n?"bg-accent text-foreground":"text-muted-foreground"}`,i;e[2]!==o?(i=o("Ask about your data"),e[2]=o,e[3]=i):i=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),e[4]=a):a=e[4];let c;e[5]!==o?(c=o("Assistant"),e[5]=o,e[6]=c):c=e[6];let m;e[7]!==c?(m=(0,u.jsx)("span",{className:"text-xs",children:c}),e[7]=c,e[8]=m):m=e[8];let p;return e[9]!==n||e[10]!==t||e[11]!==r||e[12]!==l||e[13]!==i||e[14]!==m?(p=(0,u.jsxs)("button",{"aria-label":r,"aria-pressed":n,className:l,"data-testid":"sql-chat-toggle",onClick:t,title:i,type:"button",children:[a,m]}),e[9]=n,e[10]=t,e[11]=r,e[12]=l,e[13]=i,e[14]=m,e[15]=p):p=e[15],p},"ys"),qo=d(s=>{let e=(0,V.c)(11),{onToggle:n,splitView:t}=s,o=J(),r;e[0]!==o?(r=o("Split editor and results"),e[0]=o,e[1]=r):r=e[1];let l=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${t?"bg-accent text-foreground":"text-muted-foreground"}`,i;e[2]!==o?(i=o("Split editor and results"),e[2]=o,e[3]=i):i=e[3];let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=(0,u.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[4]=a):a=e[4];let c;return e[5]!==n||e[6]!==t||e[7]!==r||e[8]!==l||e[9]!==i?(c=(0,u.jsx)("button",{"aria-label":r,"aria-pressed":t,className:l,"data-testid":"sql-split-toggle",onClick:n,title:i,type:"button",children:a}),e[5]=n,e[6]=t,e[7]=r,e[8]=l,e[9]=i,e[10]=c):c=e[10],c},"Ss"),ko=d(s=>{let e=(0,V.c)(8),{disabled:n,onExplainPlan:t,onExplainSql:o,pane:r}=s,l=J();if(r==="explain"){let a;return e[0]!==n||e[1]!==t||e[2]!==l?(a=t===void 0?null:(0,u.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-explain-plan",disabled:n,onClick:t,type:"button",children:l("Read this plan")}),e[0]=n,e[1]=t,e[2]=l,e[3]=a):a=e[3],a}let i;return e[4]!==n||e[5]!==o||e[6]!==l?(i=o===void 0?null:(0,u.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-explain-query",disabled:n,onClick:o,type:"button",children:l("Explain this query")}),e[4]=n,e[5]=o,e[6]=l,e[7]=i):i=e[7],i},"ws"),Co=d(s=>{let e=(0,V.c)(8),{onRun:n,running:t}=s,o=J(),r;e[0]!==t||e[1]!==o?(r=o(t?"Running\u2026":"Run"),e[0]=t,e[1]=o,e[2]=r):r=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[3]=l):l=e[3];let i;return e[4]!==n||e[5]!==t||e[6]!==r?(i=(0,u.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:t,onClick:n,type:"button",children:[r,l]}),e[4]=n,e[5]=t,e[6]=r,e[7]=i):i=e[7],i},"Cs"),No=d(s=>{let e=(0,V.c)(35),{onInferChart:n,onShowChart:t,onShowExplain:o,onShowResults:r,pane:l,result:i,rpc:a}=s,c=J(),m=l==="results",p;e[0]!==m?(p=Te(m),e[0]=m,e[1]=p):p=e[1];let f;e[2]!==c?(f=c("Results"),e[2]=c,e[3]=f):f=e[3];let b;e[4]!==r||e[5]!==p||e[6]!==f?(b=(0,u.jsx)("button",{className:p,"data-testid":"sql-tab-results",onClick:r,type:"button",children:f}),e[4]=r,e[5]=p,e[6]=f,e[7]=b):b=e[7];let g=l==="chart",k;e[8]!==g?(k=Te(g),e[8]=g,e[9]=k):k=e[9];let q;e[10]!==c?(q=c("Chart"),e[10]=c,e[11]=q):q=e[11];let N;e[12]!==t||e[13]!==k||e[14]!==q?(N=(0,u.jsx)("button",{className:k,"data-testid":"sql-tab-chart",onClick:t,type:"button",children:q}),e[12]=t,e[13]=k,e[14]=q,e[15]=N):N=e[15];let h;e[16]!==n||e[17]!==l||e[18]!==i||e[19]!==a||e[20]!==c?(h=!a.unavailable&&l==="chart"&&i!==null&&(0,u.jsx)("button",{className:Te(!1),"data-testid":"sql-infer-chart",disabled:a.pending("chart"),onClick:n,type:"button",children:a.pending("chart")?c("Thinking\u2026"):c("Suggest chart")}),e[16]=n,e[17]=l,e[18]=i,e[19]=a,e[20]=c,e[21]=h):h=e[21];let S=l==="explain",x;e[22]!==S?(x=Te(S),e[22]=S,e[23]=x):x=e[23];let v;e[24]!==c?(v=c("Explain"),e[24]=c,e[25]=v):v=e[25];let y;e[26]!==o||e[27]!==x||e[28]!==v?(y=(0,u.jsx)("button",{className:x,"data-testid":"sql-tab-explain",onClick:o,type:"button",children:v}),e[26]=o,e[27]=x,e[28]=v,e[29]=y):y=e[29];let w;return e[30]!==y||e[31]!==b||e[32]!==N||e[33]!==h?(w=(0,u.jsxs)(u.Fragment,{children:[b,N,h,y]}),e[30]=y,e[31]=b,e[32]=N,e[33]=h,e[34]=w):w=e[34],w},"Es"),Eo=d(s=>{let e=(0,V.c)(9),{onSelectStatement:n,script:t}=s,o;if(e[0]!==n||e[1]!==t.runs||e[2]!==t.selected){let l;e[4]!==n||e[5]!==t.selected?(l=d((i,a)=>(0,u.jsx)("button",{"aria-pressed":a===t.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${a===t.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${i.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${a.toString()}`,onClick:d(()=>{n(a)},"onClick"),title:i.sql,type:"button",children:a+1},`${a.toString()}:${i.sql}`),"r"),e[4]=n,e[5]=t.selected,e[6]=l):l=e[6],o=t.runs.map(l),e[0]=n,e[1]=t.runs,e[2]=t.selected,e[3]=o}else o=e[3];let r;return e[7]!==o?(r=(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:o}),e[7]=o,e[8]=r):r=e[8],r},"Ns"),Lo=d(s=>{let e=(0,V.c)(9),{error:n,onDebugError:t,rpc:o}=s,r=J(),l;e[0]!==n?(l=(0,u.jsx)(Je,{className:"w-full font-mono text-xs",testId:"sql-error",variant:"destructive",children:n}),e[0]=n,e[1]=l):l=e[1];let i;e[2]!==t||e[3]!==o||e[4]!==r?(i=!o.unavailable&&t!==void 0&&(0,u.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-debug-error",disabled:o.pending("chat"),onClick:t,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),o.pending("chat")?r("Thinking\u2026"):r("Debug with AI")]}),e[2]=t,e[3]=o,e[4]=r,e[5]=i):i=e[5];let a;return e[6]!==l||e[7]!==i?(a=(0,u.jsxs)("div",{className:"m-3 flex flex-col items-start gap-2",children:[l,i]}),e[6]=l,e[7]=i,e[8]=a):a=e[8],a},"ks"),_o=d(s=>{let e=(0,V.c)(18),{chart:n,durationMs:t,pane:o,result:r}=s,l=J(),i;e[0]!==n||e[1]!==o||e[2]!==r?(i=o==="chart"?(0,u.jsx)(nt,{axes:n,result:r}):(0,u.jsx)(ot,{result:r}),e[0]=n,e[1]=o,e[2]=r,e[3]=i):i=e[3];let a;e[4]!==r.rowCount||e[5]!==r.rows||e[6]!==r.truncated||e[7]!==l?(a=r.truncated?l("Showing the first {max} rows.",{max:r.rows.length}):l("{count} rows",{count:r.rowCount}),e[4]=r.rowCount,e[5]=r.rows,e[6]=r.truncated,e[7]=l,e[8]=a):a=e[8];let c;e[9]!==t||e[10]!==l?(c=t!==void 0&&` \xB7 ${l("{ms} ms",{ms:Math.round(t)})}`,e[9]=t,e[10]=l,e[11]=c):c=e[11];let m;e[12]!==a||e[13]!==c?(m=(0,u.jsxs)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:[a,c]}),e[12]=a,e[13]=c,e[14]=m):m=e[14];let p;return e[15]!==i||e[16]!==m?(p=(0,u.jsxs)("div",{"data-testid":"sql-result",children:[i,m]}),e[15]=i,e[16]=m,e[17]=p):p=e[17],p},"Ts"),To=d(s=>{let e=(0,V.c)(13),{chart:n,durationMs:t,error:o,onDebugError:r,pane:l,result:i,rpc:a}=s,c=J();if(o!==null){let p;return e[0]!==o||e[1]!==r||e[2]!==a?(p=(0,u.jsx)(Lo,{error:o,onDebugError:r,rpc:a}),e[0]=o,e[1]=r,e[2]=a,e[3]=p):p=e[3],p}if(i===null){let p;e[4]!==c?(p=c("Click Run to execute your query."),e[4]=c,e[5]=p):p=e[5];let f;return e[6]!==p?(f=(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:p}),e[6]=p,e[7]=f):f=e[7],f}let m;return e[8]!==n||e[9]!==t||e[10]!==l||e[11]!==i?(m=(0,u.jsx)(_o,{chart:n,durationMs:t,pane:l,result:i}),e[8]=n,e[9]=t,e[10]=l,e[11]=i,e[12]=m):m=e[12],m},"Rs"),Io=d(s=>{let e=(0,V.c)(63),{rpc:n,chart:t,className:o,durationMs:r,error:l,onFormat:i,onInferChart:a,onRun:c,onSelectStatement:m,onShardKeyChange:p,onShowChart:f,onShowExplain:b,onShowResults:g,chatOpen:k,onDebugError:q,onExplainPlan:N,onExplainSql:h,onToggleChat:S,onToggleSplit:x,pane:v,result:y,running:w,script:E,shardKey:T,splitView:L}=s,_=J(),C;e[0]!==a||e[1]!==f||e[2]!==b||e[3]!==g||e[4]!==v||e[5]!==y||e[6]!==n?(C=(0,u.jsx)(No,{onInferChart:a,onShowChart:f,onShowExplain:b,onShowResults:g,pane:v,result:y,rpc:n}),e[0]=a,e[1]=f,e[2]=b,e[3]=g,e[4]=v,e[5]=y,e[6]=n,e[7]=C):C=e[7];let I;e[8]!==k||e[9]!==S?(I=S!==void 0&&(0,u.jsx)(So,{chatOpen:k,onToggle:S}),e[8]=k,e[9]=S,e[10]=I):I=e[10];let R;e[11]!==x||e[12]!==L?(R=(0,u.jsx)(qo,{onToggle:x,splitView:L}),e[11]=x,e[12]=L,e[13]=R):R=e[13];let M;e[14]!==y?(M=y!==null&&y.columns.length>0&&(0,u.jsx)(tt,{columns:y.columns,name:"query-result",rows:y.rows}),e[14]=y,e[15]=M):M=e[15];let z;e[16]!==_?(z=_("Format"),e[16]=_,e[17]=z):z=e[17];let H;e[18]!==i||e[19]!==w||e[20]!==z?(H=(0,u.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:w,onClick:i,type:"button",children:z}),e[18]=i,e[19]=w,e[20]=z,e[21]=H):H=e[21];let W;e[22]!==n||e[23]!==w?(W=w||n.pending("chat"),e[22]=n,e[23]=w,e[24]=W):W=e[24];let B;e[25]!==N||e[26]!==h||e[27]!==v||e[28]!==W?(B=(0,u.jsx)(ko,{disabled:W,onExplainPlan:N,onExplainSql:h,pane:v}),e[25]=N,e[26]=h,e[27]=v,e[28]=W,e[29]=B):B=e[29];let P;e[30]!==p||e[31]!==T?(P=(0,u.jsx)(Ye,{onChange:p,testId:"sql-shard-input",value:T}),e[30]=p,e[31]=T,e[32]=P):P=e[32];let K;e[33]!==c||e[34]!==w?(K=(0,u.jsx)(Co,{onRun:c,running:w}),e[33]=c,e[34]=w,e[35]=K):K=e[35];let O;e[36]!==K||e[37]!==I||e[38]!==R||e[39]!==M||e[40]!==H||e[41]!==B||e[42]!==P?(O=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[I,R,M,H,B,P,K]}),e[36]=K,e[37]=I,e[38]=R,e[39]=M,e[40]=H,e[41]=B,e[42]=P,e[43]=O):O=e[43];let D;e[44]!==C||e[45]!==O?(D=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[C,O]}),e[44]=C,e[45]=O,e[46]=D):D=e[46];let A;e[47]!==m||e[48]!==E?(A=E!==void 0&&(0,u.jsx)(Eo,{onSelectStatement:m,script:E}),e[47]=m,e[48]=E,e[49]=A):A=e[49];let Q;e[50]!==t||e[51]!==r||e[52]!==l||e[53]!==q||e[54]!==v||e[55]!==y||e[56]!==n?(Q=(0,u.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:(0,u.jsx)(To,{chart:t,durationMs:r,error:l,onDebugError:q,pane:v,result:y,rpc:n})}),e[50]=t,e[51]=r,e[52]=l,e[53]=q,e[54]=v,e[55]=y,e[56]=n,e[57]=Q):Q=e[57];let F;return e[58]!==o||e[59]!==D||e[60]!==A||e[61]!==Q?(F=(0,u.jsxs)("div",{className:o,children:[D,A,Q]}),e[58]=o,e[59]=D,e[60]=A,e[61]=Q,e[62]=F):F=e[62],F},"Ls"),Ro=d((s,e)=>s.trim()===""?e:(s.split(`
16
+ `)[0]??s).slice(0,24),"_s"),Do=d(s=>{s?.focus(),s?.select()},"qs"),Mo=d(s=>{let e=(0,V.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:l}=s,i=J(),a;e[0]!==o?(a=d(g=>{o(g.currentTarget.value.trim())},"c"),e[0]=o,e[1]=a):a=e[1];let c=a,m;e[2]!==t||e[3]!==o?(m=d(g=>{g.key==="Enter"?o(g.currentTarget.value.trim()):g.key==="Escape"&&t()},"d"),e[2]=t,e[3]=o,e[4]=m):m=e[4];let p=m,f;e[5]!==i?(f=i("Tab title"),e[5]=i,e[6]=f):f=e[6];let b;return e[7]!==n||e[8]!==c||e[9]!==p||e[10]!==r||e[11]!==f||e[12]!==l?(b=(0,u.jsx)("input",{"aria-label":f,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":l,defaultValue:n,onBlur:c,onKeyDown:p,placeholder:r,ref:Do,type:"text"}),e[7]=n,e[8]=c,e[9]=p,e[10]=r,e[11]=f,e[12]=l,e[13]=b):b=e[13],b},"Is"),Ao=d(s=>{let e=(0,V.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=J(),l=`sql-tab-close-prompt-${n}`,i;e[0]!==r?(i=r("Discard?"),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==i?(a=(0,u.jsx)("span",{className:"text-[11px] text-muted-foreground",children:i}),e[2]=i,e[3]=a):a=e[3];let c;e[4]!==r?(c=r("Discard changes"),e[4]=r,e[5]=c):c=e[5];let m=`sql-tab-close-confirm-${n}`,p;e[6]!==r?(p=r("Discard changes"),e[6]=r,e[7]=p):p=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=f):f=e[8];let b;e[9]!==t||e[10]!==c||e[11]!==m||e[12]!==p?(b=(0,u.jsx)("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":m,onClick:t,title:p,type:"button",children:f}),e[9]=t,e[10]=c,e[11]=m,e[12]=p,e[13]=b):b=e[13];let g;e[14]!==r?(g=r("Keep editing"),e[14]=r,e[15]=g):g=e[15];let k=`sql-tab-close-cancel-${n}`,q;e[16]!==r?(q=r("Keep editing"),e[16]=r,e[17]=q):q=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=N):N=e[18];let h;e[19]!==o||e[20]!==k||e[21]!==q||e[22]!==g?(h=(0,u.jsx)("button",{"aria-label":g,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":k,onClick:o,title:q,type:"button",children:N}),e[19]=o,e[20]=k,e[21]=q,e[22]=g,e[23]=h):h=e[23];let S;return e[24]!==l||e[25]!==h||e[26]!==a||e[27]!==b?(S=(0,u.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":l,role:"group",children:[a,b,h]}),e[24]=l,e[25]=h,e[26]=a,e[27]=b,e[28]=S):S=e[28],S},"As"),$o=d(s=>{let e=(0,V.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:l,onSelect:i,tab:a}=s,c=J(),[m,p]=(0,j.useState)(!1),[f,b]=(0,j.useState)(!1),g;e[0]!==r||e[1]!==a.id?(g=d(A=>{r(a.id,A)},"g"),e[0]=r,e[1]=a.id,e[2]=g):g=e[2];let k=g,q;e[3]!==i||e[4]!==a.id?(q=d(()=>{i(a.id)},"v"),e[3]=i,e[4]=a.id,e[5]=q):q=e[5];let N=q,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=d(()=>{p(!0)},"p"),e[6]=h):h=e[6];let S=h,x;e[7]!==o||e[8]!==a?(x=d(A=>{A.stopPropagation(),qt(a)?b(!0):o(a.id)},"x"),e[7]=o,e[8]=a,e[9]=x):x=e[9];let v=x,y;e[10]!==o||e[11]!==a.id?(y=d(A=>{A.stopPropagation(),b(!1),o(a.id)},"y"),e[10]=o,e[11]=a.id,e[12]=y):y=e[12];let w=y,E;e[13]===Symbol.for("react.memo_cache_sentinel")?(E=d(A=>{A.stopPropagation(),b(!1)},"w"),e[13]=E):E=e[13];let T=E,L;e[14]!==l||e[15]!==a.id?(L=d(A=>{l(a.id,A),p(!1)},"R"),e[14]=l,e[15]=a.id,e[16]=L):L=e[16];let _=L,C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=d(()=>{p(!1)},"k"),e[17]=C):C=e[17];let I=C,R;e[18]!==a.name?(R=a.name.trim(),e[18]=a.name,e[19]=R):R=e[19];let M=R,z;e[20]!==c||e[21]!==a.sql?(z=Ro(a.sql,c("Untitled")),e[20]=c,e[21]=a.sql,e[22]=z):z=e[22];let H=z,W=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",B;e[23]!==W?(B=ie("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",W),e[23]=W,e[24]=B):B=e[24];let P=`sql-tab-${a.id}`,K;e[25]!==n||e[26]!==_||e[27]!==M||e[28]!==H||e[29]!==m||e[30]!==N||e[31]!==c||e[32]!==a.id?(K=m?(0,u.jsx)(Mo,{initial:M,onCancel:I,onCommit:_,placeholder:H,testId:`sql-tab-rename-${a.id}`}):(0,u.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:N,onDoubleClick:S,title:c("Double-click to rename"),type:"button",children:M===""?H:M}),e[25]=n,e[26]=_,e[27]=M,e[28]=H,e[29]=m,e[30]=N,e[31]=c,e[32]=a.id,e[33]=K):K=e[33];let O;e[34]!==t||e[35]!==w||e[36]!==f||e[37]!==v||e[38]!==c||e[39]!==a.id?(O=t&&(f?(0,u.jsx)(Ao,{idBase:a.id,onDiscard:w,onKeep:T}):(0,u.jsx)("button",{"aria-label":c("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${a.id}`,onClick:v,title:c("Close tab"),type:"button",children:(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=w,e[36]=f,e[37]=v,e[38]=c,e[39]=a.id,e[40]=O):O=e[40];let D;return e[41]!==k||e[42]!==B||e[43]!==P||e[44]!==K||e[45]!==O?(D=(0,u.jsxs)("div",{className:B,"data-testid":P,onContextMenu:k,children:[K,O]}),e[41]=k,e[42]=B,e[43]=P,e[44]=K,e[45]=O,e[46]=D):D=e[46],D},"Ds"),Po=d(s=>{let e=(0,V.c)(43),{model:n,onSelect:t}=s,o=J(),{activeTab:r,addEditorTab:l,cancelBulk:i,closeEditorTab:a,closeTabMenu:c,confirmBulk:m,menuStyle:p,onBackdropContextMenu:f,onCloseAll:b,onCloseOthers:g,onCloseToRight:k,openTabMenu:q,pendingBulk:N,renameTab:h,tabMenu:S,tabs:x}=n,v;if(e[0]!==r||e[1]!==a||e[2]!==t||e[3]!==q||e[4]!==h||e[5]!==x){let R;e[7]!==r||e[8]!==a||e[9]!==t||e[10]!==q||e[11]!==h||e[12]!==x.length?(R=d(M=>(0,u.jsx)($o,{active:M.id===r.id,canClose:x.length>1,onClose:a,onMenu:q,onRename:h,onSelect:t,tab:M},M.id),"q"),e[7]=r,e[8]=a,e[9]=t,e[10]=q,e[11]=h,e[12]=x.length,e[13]=R):R=e[13],v=x.map(R),e[0]=r,e[1]=a,e[2]=t,e[3]=q,e[4]=h,e[5]=x,e[6]=v}else v=e[6];let y;e[14]!==o?(y=o("New tab"),e[14]=o,e[15]=y):y=e[15];let w=x.length>=Be,E;e[16]!==o?(E=o("New tab"),e[16]=o,e[17]=E):E=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let L;e[19]!==l||e[20]!==y||e[21]!==w||e[22]!==E?(L=(0,u.jsx)("button",{"aria-label":y,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:w,onClick:l,title:E,type:"button",children:T}),e[19]=l,e[20]=y,e[21]=w,e[22]=E,e[23]=L):L=e[23];let _;e[24]!==v||e[25]!==L?(_=(0,u.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[v,L]}),e[24]=v,e[25]=L,e[26]=_):_=e[26];let C;e[27]!==i||e[28]!==c||e[29]!==m||e[30]!==p||e[31]!==f||e[32]!==b||e[33]!==g||e[34]!==k||e[35]!==N||e[36]!==o||e[37]!==S||e[38]!==x?(C=S!==null&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:c,onContextMenu:f,role:"presentation"}),(0,u.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:p,children:N===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:x.length<=1,onClick:g,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:x.findIndex(R=>R.id===S.id)>=x.length-1,onClick:k,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:b,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,u.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,u.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:m,type:"button",children:o("Discard")}),(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:i,type:"button",children:o("Cancel")})]})]})})]}),e[27]=i,e[28]=c,e[29]=m,e[30]=p,e[31]=f,e[32]=b,e[33]=g,e[34]=k,e[35]=N,e[36]=o,e[37]=S,e[38]=x,e[39]=C):C=e[39];let I;return e[40]!==_||e[41]!==C?(I=(0,u.jsxs)(u.Fragment,{children:[_,C]}),e[40]=_,e[41]=C,e[42]=I):I=e[42],I},"Os"),Oo=ge(ve.runSql),zo="lunora-studio-sql-split-view",Ho=d(()=>qe(kt[0]?.sql??""),"Bs"),jo=d(()=>performance.now(),"Ps"),Wo=d(()=>{let s=(0,V.c)(2),e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,s[0]=e):e=s[0];let n=(0,j.useRef)(e),t;return s[1]===Symbol.for("react.memo_cache_sentinel")?(t={advance:d(o=>{n.current.set(o,(n.current.get(o)??0)+1)},"advance"),begin:d(o=>{let r=n.current.get(o)??0;return()=>(n.current.get(o)??0)===r},"begin")},s[1]=t):t=s[1],t},"Ws"),Bo=d((s,e)=>{let n=s.tables[0];return n===void 0?[e("What tables does this app have?")]:[e("What tables does this app have?"),e("Show me the most recent rows in {table}",{table:n}),e("Is anything wrong with my schema?")]},"Hs"),Ie=d(s=>s.tables.map(e=>({columns:[...s.columns[e]??[]],table:e})),"Te"),pr=d(({initialShardKey:s,now:e=jo})=>{let n=Ce(),t=Vn(Ho),{activeTab:o,openEditorTab:r,output:l,patchActiveOutput:i,patchActiveTab:a,setActiveTabId:c,unlinkQuery:m}=t,p=Wo(),f=no({loadIntoActiveTab:d((U,oe)=>{p.advance(o.id),a({activeId:oe,sql:U}),i({chart:void 0,durationMs:void 0,error:null,failed:void 0,result:null,running:!1,script:void 0})},"loadIntoActiveTab"),unlinkQuery:m}),{recordHistory:b,updateQuerySql:g}=f,k=o.sql,{activeId:q}=o,{chart:N,error:h,failed:S,result:x,running:v}=l,y=l.pane,[w,E]=(0,j.useState)(s??""),[T,L]=Ee(zo,!1),_=J(),C=Ge(),{probe:I,schema:R}=An(w),M=(0,j.useCallback)(U=>{a({sql:U}),q!==null&&g(q,U)},[q,a,g]),z=C?.setHasEditor;(0,j.useEffect)(()=>{if(z!==void 0)return z(!0),()=>{z(!1)}},[z]);let H=C?.insertRequest,W=C?.takeInsert;(0,j.useEffect)(()=>{H===void 0||W===void 0||(W(H.id),k.trim()===""&&q===null?M(H.sql):r(H.sql)||a({activeId:null,sql:k.trim()===""?H.sql:`${k.trimEnd()}
17
+
18
+ ${H.sql}`}))},[q,k,H,r,a,W,M]);let B=vn(k,R,w),P=Ze(w),K=d(()=>{x!==null&&le((async()=>{let U=await P.inferChart({columns:x.columns,rowCount:x.rowCount,types:Object.fromEntries(x.columns.map(oe=>[oe,typeof(x.rows[0]?.[oe]??"")]))});i({chart:U})})())},"M"),O=d(async U=>{let oe=e();try{let re=await n.query(Oo,{sql:U},xe(w)),ce=e()-oe;return b(U),{durationMs:ce,error:null,result:re,sql:U}}catch(re){return{error:Ke(re),result:null,sql:U}}},"I"),D=d(async U=>{if(k.trim()==="")return;let oe=p.begin(o.id);i({running:!0,...U==="explain"?{explained:k.trim()}:{}});let re=U==="explain"?He(Qt(k),0):xt(k),ce=[];for(let ke of re){let Ct={error:ke.rejection?.message??"",result:null,sql:ke.sql};ce.push(ke.rejection===void 0?await O(ke.sql):Ct)}if(Ve(w),!oe())return;let Qe=Math.max(ce.length-1,0),de=ce[Qe];i({chart:void 0,durationMs:de?.durationMs,error:de?.error??null,failed:de?.error===null||de===void 0?void 0:{error:de.error,sql:de.sql},pane:U,result:de?.result??null,running:!1,script:ce.length>1?{runs:ce,selected:Qe}:void 0})},"D"),A=d(U=>{let oe=l.script?.runs,re=oe?.[U];oe===void 0||re===void 0||i({chart:void 0,durationMs:re.durationMs,error:re.error,failed:re.error===null?void 0:{error:re.error,sql:re.sql},result:re.result,script:{runs:oe,selected:U}})},"z"),Q=d(()=>{le(D("results"))},"j"),F=zn({inlineEditEnabled:!P.unavailable,onSubmit:d(()=>{le(D(l.pane))},"onSubmit"),probe:I,schema:R,setDraft:M}),{closeAutocomplete:ee,closeInlineEdit:$}=F,G=d(()=>{M(Yt(k))},"X"),Z=d(U=>{ee(),$(),c(U)},"Y"),X=d(()=>{i({pane:"results"})},"oe"),se=d(()=>{le(D("explain"))},"re"),ae=d(()=>{i({pane:"chart"})},"pe"),ue=d(()=>{L(!T)},"ve"),pe=d(()=>{if(C!==void 0){if(C.open){C.close();return}C.openAssistant({schema:Ie(R),shardKey:w,suggestions:Bo(R,_),title:_("SQL console")})}},"he"),me=d(U=>{C?.rebindShard(w,U),E(U)},"ye"),be=d(()=>{S!==void 0&&C?.openAssistant({ask:_(`This statement failed:
19
+ {sql}
20
+
21
+ The database said: {error}
22
+
23
+ Why, and what should it be?`,{error:S.error,sql:S.sql}),schema:Ie(R),shardKey:w,title:_("Debug query")})},"be"),fe=d(()=>{let U=k.trim();U!==""&&C?.openAssistant({ask:_(`Explain what this query does, step by step:
24
+ {statement}`,{statement:U}),schema:Ie(R),shardKey:w,title:_("Explain query")})},"V"),Y=d(()=>{let U=l.explained;if(x===null||x.rows.length===0||U===void 0)return;let oe=x.rows.map(re=>x.columns.map(ce=>Ue(re[ce])).join(" | ")).join(`
25
+ `);C?.openAssistant({ask:_(`SQLite planned this query:
26
+ {statement}
27
+
28
+ as:
29
+ {plan}
30
+
31
+ What is it doing, and is anything here slow?`,{plan:oe,statement:U}),schema:Ie(R),shardKey:w,title:_("Read plan")})},"ee"),te=T?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",ne=T?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,u.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,u.jsx)(wo,{activeId:q,history:f.history,listRef:f.listRef,onClearHistory:f.clearHistory,onDelete:f.deleteQuery,onLoadHistory:f.loadFromHistory,onLoadTemplate:f.loadTemplate,onNew:f.newQuery,onRename:f.renameQuery,onSearchChange:f.onSearchChange,onSelect:f.selectQuery,onToggleRememberHistory:f.setRememberHistory,queries:f.queries,rememberHistory:f.rememberHistory,rpc:P,search:f.search}),(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,u.jsx)(Po,{model:t,onSelect:Z}),(0,u.jsxs)("div",{className:te,children:[(0,u.jsx)(bo,{autocomplete:F.autocompleteState,diagnostics:B,draft:k,editorRef:F.editorRef,failed:S,gutterRef:F.gutterRef,handlers:F.handlers,inlineEdit:F.inlineEdit,listboxId:F.listboxId,onAcceptInlineEdit:F.acceptInlineEdit,onCancelInlineEdit:F.closeInlineEdit,onGenerated:M,onPickSuggestion:F.onPickSuggestion,onRevealDiagnostic:F.revealDiagnostic,overlayRef:F.overlayRef,rpc:P}),(0,u.jsx)(Io,{chart:N,chatOpen:C?.open===!0,className:ne,durationMs:l.durationMs,error:h,onDebugError:S===void 0?void 0:be,onExplainPlan:C===void 0||C.unavailable||y!=="explain"?void 0:Y,onExplainSql:C===void 0||C.unavailable?void 0:fe,onFormat:G,onInferChart:K,onRun:Q,onSelectStatement:A,onShardKeyChange:me,onShowChart:ae,onShowExplain:se,onShowResults:X,onToggleChat:C===void 0||C.unavailable?void 0:pe,onToggleSplit:ue,pane:y,result:x,rpc:P,running:v,script:l.script,shardKey:w,splitView:T})]})]})]})},"ao");export{pr as SqlEditorPanel};
@@ -0,0 +1,3 @@
1
+ import{D as xe,I as Ge,J as Ce,K as Qe,L as Ze,M as et,N as tt,b as Q,d as He,f as qe,l as Xe}from"./chunk-4SY2N2RS.js";import{f as $e,u as L,v as O,w as ge}from"./chunk-OZID3UYF.js";import{a as ie,b as Je,d as be,g as M,i as ve,j as J}from"./chunk-L27FKJTG.js";import{x as ze}from"./chunk-VJQP4ARP.js";import{a as St}from"./chunk-A6TVTNKO.js";import{a as k,b as ae}from"./chunk-ADABTCDI.js";import{a as t,c as Mt,d as E}from"./chunk-5PEAXTYQ.js";var ht=E(St(),1);var Et=E(k(),1);var Te={};Mt(Te,{Control:()=>Ct,Description:()=>vt,Error:()=>bt,Item:()=>It,Label:()=>Rt,Root:()=>pt,Validity:()=>yt});var P=E(k(),1);var Fe=E(k(),1);var rt="data-valid",ot="data-invalid";var se={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ot={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},it={disabled:!1,...Ot},H={valid(r){return r===null?null:r?{[rt]:""}:{[ot]:""}}};var wt={invalid:void 0,name:void 0,validityData:{state:se,errors:[],error:"",value:"",initialValue:null},setValidityData:M,disabled:void 0,setTouched:M,setDirty:M,setFilled:M,setFocused:M,validationMode:"onSubmit",shouldValidateOnChange:t(()=>!1,"shouldValidateOnChange"),state:it,registerFieldControl:M,validation:{getValidationProps:t((r,e=ve)=>e,"getValidationProps"),inputRef:{current:null},registeredInputs:new Map,registerInput:M,getInputControl:t(()=>null,"getInputControl"),commit:t(async()=>{},"commit"),change:M}},Oe=Fe.createContext(wt);function Y(r=!0){let e=Fe.useContext(Oe);if(e.setValidityData===M&&!r)throw new Error(be(28));return e}t(Y,"useFieldRootContext");var ye=E(k(),1);var _t=ye.createContext(void 0);function nt(r=!1){let e=ye.useContext(_t);if(!e&&!r)throw new Error(be(86));return e}t(nt,"useFieldsetRootContext");var Ie=E(k(),1);var Pt=Ie.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:M,validationMode:"onSubmit",submitCountRef:{current:0}});function Z(){return Ie.useContext(Pt)}t(Z,"useFormContext");var ne=E(k(),1);var Ee=E(k(),1);var we=Ee.createContext({controlId:void 0,registerControlId:M,resetControlId:M,labelId:void 0,setLabelId:M,messageIds:[],setMessageIds:M,getDescriptionProps:t(r=>r,"getDescriptionProps")});function U(){return Ee.useContext(we)}t(U,"useLabelableContext");var at=E(ae(),1);var Ve=t(function(e){let o=Q(),[s,c]=ne.useState(o),[d,l]=ne.useState(),[R,f]=ne.useState([]),u=s===void 0?o:s,a=ie(()=>new Map),{messageIds:b}=U(),C=L((D,I)=>{let x=a.current;I===void 0?x.delete(D):x.set(D,I),c(w=>{if(x.size===0)return w;let A;for(let i of x.values()){if(i===w)return w;A===void 0&&(A=i)}return A})}),g=L(()=>{a.current.size===0&&c(o)}),v=ne.useCallback(D=>{let I=D["aria-describedby"]?D["aria-describedby"].split(" "):[];return I.push(...b,...R),{...D,"aria-describedby":Array.from(new Set(I)).join(" ")||void 0}},[b,R]),N=ne.useMemo(()=>({controlId:u,registerControlId:C,resetControlId:g,labelId:d,setLabelId:l,messageIds:R,setMessageIds:f,getDescriptionProps:v}),[u,C,g,d,l,R,f,v]);return(0,at.jsx)(we.Provider,{value:N,children:e.children})},"LabelableProvider");var _e=E(k(),1);function st(r={}){let{id:e,enabled:o=!0}=r,{controlId:s,registerControlId:c,resetControlId:d}=U(),l=Q(),R=ie(()=>Symbol()),f=_e.useRef(!1),u=_e.useRef(!1),a=L(()=>{!f.current||c===M||(f.current=!1,c(R.current,void 0))});return O(()=>{if(!o||c===M){a();return}let b;if(e!==void 0)u.current=!0,b=e;else if(u.current)b=l;else{d();return}if(b===void 0){a();return}f.current=!0,c(R.current,b)},[e,o,c,d,l,R,a]),O(()=>a,[a]),(o?s:void 0)??e??l}t(st,"useLabelableId");function lt(r,e){let o=Q(r);return O(()=>(e(o),()=>{e(s=>s===o?void 0:s)}),[o,e]),o}t(lt,"useRegisteredLabelId");function dt(r={}){let{id:e,fallbackControlId:o,native:s=!1,setLabelId:c,focusControl:d}=r,{controlId:l,setLabelId:R}=U(),f=L(g=>{R(g),c?.(g)}),u=lt(e,f),a=l??o;function b(g){if(d){d(g,a);return}if(!a)return;let v=ge(g.currentTarget).getElementById(a);$e(v)&&At(v)}t(b,"focusControl");function C(g){qe(g.nativeEvent)?.closest("button,input,select,textarea")||(!g.defaultPrevented&&g.detail>1&&g.preventDefault(),!s&&b(g))}return t(C,"handleInteraction"),s?{id:u,htmlFor:a,onMouseDown:C}:{id:u,onClick:C,onPointerDown(g){g.preventDefault()}}}t(dt,"useLabel");function At(r){r.focus({focusVisible:!0})}t(At,"focusElementWithVisible");var oe=E(k(),1);function le(r,e){return{...r,state:{...r.state,valid:!e&&r.state.valid}}}t(le,"getCombinedFieldValidityData");var Pe=Object.keys(se);function kt(r,e){return r.matches(":disabled")?!1:!e||r.form===e?!0:r.form===null&&!r.hasAttribute("form")}t(kt,"isEligibleInput");function ut(r,e){let o=null;for(let s of r.keys())if(kt(s,e)){if(!s.validity.valid)return s;o??=s}return o}t(ut,"findRepresentativeInput");function ct(r){return{...se,valid:!r,customError:r}}t(ct,"makeState");function Ae(r){return r&&r.validationMessage?[r.validationMessage]:[]}t(Ae,"getNativeErrors");function ft(r){let{elementRef:e,formRef:o}=Z(),{setValidityData:s,validate:c,validityData:d,validationDebounceTime:l,invalid:R,markedDirtyRef:f,state:u,shouldValidateOnChange:a,validationMode:b,registeredFieldIdRef:C}=r,{controlId:g,getDescriptionProps:v}=U(),N=xe(),D=oe.useRef(null),I=ie(()=>new Map).current,x=oe.useRef(0),w=oe.useRef(null),A=oe.useCallback((S,j)=>(I.set(S,j),()=>{I.delete(S)}),[I]),i=L(()=>{let S=ut(I,e.current);return S&&I.get(S)?.controlRef.current||null}),V=L(async(S,j=!1)=>{x.current+=1;let h=x.current;function $(n,m=R){let p=C.current??g;if(p==null)return;let y=o.current.fields.get(p);if(!y)return;let W=le(n,m);o.current.fields.set(p,{...y,validityData:W})}t($,"updateRegisteredFieldValidity");function ee(n,m){let p=n.valid===!1?m:[];return{value:S,state:n,error:p[0]??"",errors:p,initialValue:d.initialValue}}t(ee,"makeValidityData");function te(n,m){let p=n.validity.customError?n.validationMessage:"",y=m.replace(/\r\n?/g,`
2
+ `);n.setCustomValidity(y),w.current=[n,y,p]}t(te,"setCustomValidity");function X(){let n=w.current;w.current=null,n&&(!n[0].willValidate||n[0].validationMessage===n[1])&&n[0].setCustomValidity(n[2])}t(X,"clearCustomValidity");function _(n,m,p){let y=ee(n,m);$(y,p),s(y)}t(_,"publish");function q(n){let m=Pe.reduce((y,W)=>(y[W]=n.validity[W],y),{}),p=!1;for(let y of Pe)if(y!=="valid"){if(y==="valueMissing"&&m[y])p=!0;else if(m[y])return m}return p&&!f.current&&(m.valid=!0,m.valueMissing=!1),m}t(q,"getState");function re(){return I.size>0?ut(I,e.current):D.current}t(re,"resolveRepresentativeInput");let T=re();function G(){return T=re(),T?.willValidate?q(T):ct(!1)}if(t(G,"refreshState"),j){if(u.valid!==!1||!T)return;if(!T.validity.valueMissing){X();let n=re(),m=n?.validity.customError?Ae(n):[];_(ct(m.length>0),m,!1);return}for(let n of Pe)if(n!=="valid"&&n!=="valueMissing"&&n!=="customError"&&T.validity[n])return}N.clear(),X();let B=G(),K=Ae(T),ue=a();if(K.length===0||ue){let n=Array.from(o.current.fields.values()).reduce((y,W)=>(W.name&&(y[W.name]=W.getValue()),y),{}),m=c(S,n),p;if(typeof m=="object"&&m!==null&&"then"in m){if(B.valid===!1?_(B,K):(b==="onSubmit"||!d.state.customError)&&(B.valid=null,_(B,K)),p=await m,h!==x.current)return;B=G()}else p=m;K=p?[].concat(p).filter(Boolean):[],K.length>0?(B.valid=!1,B.customError=!0,T?.willValidate&&te(T,K.join(`
3
+ `))):K=Ae(T)}_(B,K)}),F=L((S,j=!1)=>{if(N.clear(),x.current+=1,j)return;let h=a();h&&S!==""&&l?N.start(l,()=>{V(S)}):V(S,!h)}),z=oe.useCallback((S,j={})=>Je(v(j),u.valid===!1&&!u.disabled&&!S?{"aria-invalid":!0}:ve),[v,u.disabled,u.valid]);return oe.useMemo(()=>({getValidationProps:z,inputRef:D,registeredInputs:I,registerInput:A,getInputControl:i,commit:V,change:F}),[z,I,A,i,V,F])}t(ft,"useFieldValidation");var he=E(k(),1);function mt(r){let{change:e,commit:o,invalid:s,markedDirtyRef:c,name:d,setRegisteredFieldName:l,registeredFieldIdRef:R,setValidityData:f,validityData:u}=r,{formRef:a}=Z(),b=he.useRef(null),C=he.useRef(null),g=he.useRef(!1),v=L(()=>{let i=C.current;if(i)return i.getValue?i.getValue():i.value});function N(i){return i.value===void 0?v():i.value}t(N,"getRegistrationValue");let D=L(()=>{let i=C.current;if(c.current=!0,!i){o(u.value);return}o(N(i))});function I(){let i=C.current;!i||!i.id||a.current.fields.set(i.id,{getValue:v,name:d??i.name,controlRef:i.controlRef,validityData:le(u,s),validate:D})}t(I,"refreshRegistration");function x(i=C.current?.id){i&&a.current.fields.delete(i)}t(x,"deleteRegistration");function w(i){if(g.current)return;g.current=!0;let V=N(i);f(F=>F.initialValue===V?F:{...F,initialValue:V})}t(w,"captureInitialValue"),O(()=>{let i=C.current;!i||!i.id||(l(d?void 0:i.name),a.current.fields.set(i.id,{getValue:v,name:d??i.name,controlRef:i.controlRef,validityData:le(u,s),validate:D}))},[a,v,s,d,l,D,u]),O(()=>{let i=a.current.fields;return()=>{let V=C.current?.id;V&&i.delete(V)}},[a]);let A=L((i,V)=>{if(!V){b.current===i&&(b.current=null,e(void 0,!0),x(),C.current=null,l(void 0),R.current=void 0);return}let F=C.current?.id,z=b.current;z&&z!==i&&e(void 0,!0),b.current=i,C.current=V,d||l(V.name),R.current=V.id,F&&F!==V.id&&x(F),w(V),I()});return[D,A]}t(mt,"useFieldControlRegistration");var De=E(ae(),1);var Ut=P.forwardRef(t(function(e,o){let{errors:s,validationMode:c,submitCountRef:d}=Z(),{render:l,className:R,validate:f,validationDebounceTime:u=0,validationMode:a=c,name:b,disabled:C=!1,invalid:g,dirty:v,touched:N,actionsRef:D,style:I,...x}=e,w=nt(!0)?.disabled,A=L(f||(()=>null)),i=w||C,[V,F]=P.useState(!1),[z,S]=P.useState(!1),[j,h]=P.useState(!1),[$,ee]=P.useState(!1),te=v??z,X=N??V,_=P.useRef(te),q=P.useRef(void 0),[re,T]=P.useState(),G=b??re;O(()=>{v!==void 0&&(_.current=v)},[v]);let B=L(Re=>{v===void 0&&(Re&&(_.current=!0),S(Re))}),K=L(Re=>{N===void 0&&F(Re)}),ue=L(()=>a==="onChange"||a==="onSubmit"&&d.current>0),n=G&&Object.hasOwn(s,G)?s[G]:null,m=!!(Array.isArray(n)?n.length:n),p=g===!0||m,[y,W]=P.useState({state:se,error:"",errors:[],value:null,initialValue:null}),We=!p&&(i?null:y.state.valid),me=P.useMemo(()=>({disabled:i,touched:X,dirty:te,valid:We,filled:j,focused:$}),[i,X,te,We,j,$]),pe=ft({setValidityData:W,validate:A,validityData:y,validationDebounceTime:u,invalid:p,markedDirtyRef:_,state:me,shouldValidateOnChange:ue,validationMode:a,registeredFieldIdRef:q}),[Ye,Ke]=mt({change:pe.change,commit:pe.commit,invalid:p,markedDirtyRef:_,name:b,setRegisteredFieldName:T,registeredFieldIdRef:q,setValidityData:W,validityData:y});P.useImperativeHandle(D,()=>({validate:Ye}),[Ye]);let Lt=P.useMemo(()=>({invalid:p,name:G,validityData:y,setValidityData:W,disabled:i,setTouched:K,setDirty:B,setFilled:h,setFocused:ee,validationMode:a,shouldValidateOnChange:ue,state:me,registerFieldControl:Ke,validation:pe}),[p,G,y,i,K,B,h,ee,a,ue,me,Ke,pe]),Nt=J("div",e,{ref:o,state:me,props:x,stateAttributesMapping:H});return(0,De.jsx)(Oe.Provider,{value:Lt,children:Nt})},"FieldRootInner")),pt=P.forwardRef(t(function(e,o){return(0,De.jsx)(Ve,{children:(0,De.jsx)(Ut,{...e,ref:o})})},"FieldRoot"));var ce=E(k(),1);var Le=E(k(),1);var ke=Le.createContext({disabled:!1});function Ne(){return Le.useContext(ke)}t(Ne,"useFieldItemContext");var Rt=ce.forwardRef(t(function(e,o){let{render:s,className:c,style:d,id:l,nativeLabel:R=!0,...f}=e,u=Y(!1),a=Ne(),{labelId:b}=U(),C={...u.state,disabled:u.disabled||a.disabled},g=ce.useRef(null),v=dt({id:b??l,native:R});return J("label",e,{ref:[o,g],state:C,props:[v,f],stateAttributesMapping:H})},"FieldLabel"));var de=E(k(),1);var Ue=E(ae(),1);var jt={...H,...Xe},bt=de.forwardRef(t(function(e,o){let{render:s,id:c,className:d,match:l,style:R,...f}=e,u=Q(c),{validityData:a,state:b,name:C}=Y(!1),{setMessageIds:g}=U(),{errors:v}=Z(),N=C&&Object.hasOwn(v,C)?v[C]:null,D=!!(Array.isArray(N)?N.length:N),I=typeof l=="string",x=!1;l===!0?x=!0:b.disabled?x=!1:I?x=!!a.state[l]:x=D||a.state.valid===!1;let{mounted:w,transitionStatus:A,setMounted:i}=Ce(x);O(()=>{if(!(!x||!u))return g(_=>_.concat(u)),()=>{g(_=>_.filter(q=>q!==u))}},[x,u,g]);let V=de.useRef(null),[F,z]=de.useState(null),[S,j]=de.useState(null),h=a.error;!I&&D?h=N:a.errors.length>1&&(h=a.errors);let $=h;Array.isArray(h)&&($=h.length>1?(0,Ue.jsx)("ul",{children:h.map(_=>(0,Ue.jsx)("li",{children:_},_))}):h[0]);let ee=Array.isArray(h)?JSON.stringify(h):h;x&&ee!==S&&(j(ee),z($)),Ge({open:x,ref:V,onComplete(){x||i(!1)}});let te={...b,transitionStatus:A},X=J("div",e,{ref:[o,V],state:te,props:[{id:u,children:x?$:F},f],stateAttributesMapping:jt,enabled:w});return w?X:null},"FieldError"));var gt=E(k(),1);var vt=gt.forwardRef(t(function(e,o){let{render:s,id:c,className:d,style:l,...R}=e,f=Q(c),u=Y(!1),a=Ne(),{setMessageIds:b}=U(),C={...u.state,disabled:u.disabled||a.disabled};return O(()=>{if(f)return b(v=>v.concat(f)),()=>{b(v=>v.filter(N=>N!==f))}},[f,b]),J("p",e,{ref:o,state:C,props:[{id:f},R],stateAttributesMapping:H})},"FieldDescription"));var Me=E(k(),1);function xt(r,e,o,s,c=!0,d){let{registerFieldControl:l}=Y(),R=ie(()=>Symbol());O(()=>{let f=R.current;if(!c){l(f,void 0);return}l(f,{controlRef:r,getValue:s,id:e,name:d,value:o})},[r,c,s,e,d,l,R,o]),O(()=>{let f=R.current;return()=>{l(f,void 0)}},[l,R])}t(xt,"useRegisterFieldControl");var Ct=Me.forwardRef(t(function(e,o){let{render:s,className:c,id:d,name:l,value:R,disabled:f=!1,onValueChange:u,defaultValue:a,autoFocus:b=!1,style:C,...g}=e,{state:v,name:N,disabled:D,setTouched:I,setDirty:x,validityData:w,setFocused:A,setFilled:i,validationMode:V,validation:F}=Y(),{clearErrors:z,elementRef:S,submitCountRef:j}=Z(),h=D||f,$=N??l,ee={...v,disabled:h},{labelId:te}=U(),X=st({id:d}),[_]=Qe({controlled:R,default:a,name:"FieldControl",state:"value"}),q=R!==void 0,re=q?_:void 0,T=re==null?void 0:String(re),G=L(()=>F.inputRef.current?.value);xt(F.inputRef,X,T,G,!h,l),O(()=>{let n=T??F.inputRef.current?.value;n!==void 0&&i(n!=="")},[T,F.inputRef,i]),Ze(T,()=>{T!==void 0&&(z($),x(T!==(w.initialValue??"")),F.change(T))});let B=Me.useRef(null),K=xe();return O(()=>{b&&B.current===He(ge(B.current))&&A(!0)},[b,A]),J("input",e,{ref:[o,B],state:ee,props:[{id:X,disabled:h,name:$,ref:F.inputRef,"aria-labelledby":te,autoFocus:b,...q?{value:re}:{defaultValue:a},onChange(n){let m=n.currentTarget.value,p=tt(et.none,n.nativeEvent);u?.(m,p),!q&&(x(m!==(w.initialValue??"")),i(m!==""),!n.nativeEvent.defaultPrevented&&!p.isCanceled&&(z($),F.change(m)))},onFocus(){A(!0)},onBlur(n){if(I(!0),A(!1),V==="onBlur"){let m=n.currentTarget.value;F.commit(m),q&&queueMicrotask(()=>{let p=F.inputRef.current?.value;p!==void 0&&p!==m&&p!==(w.initialValue??"")&&F.commit(p)})}},onKeyDown(n){if(n.currentTarget.tagName==="INPUT"&&n.key==="Enter"){I(!0);let m=n.currentTarget.value,p=n.currentTarget.form;if(p&&p===S.current&&!n.defaultPrevented){let y=n.currentTarget,W=j.current;K.start(0,()=>{j.current===W&&F.commit(y.value)})}else F.commit(m)}}},g,n=>F.getValidationProps(h,n)],stateAttributesMapping:H})},"FieldControl"));var fe=E(k(),1);var Ft=E(ae(),1);var yt=t(function(e){let{children:o}=e,{validityData:s,invalid:c}=Y(!1),d=fe.useMemo(()=>le(s,c),[s,c]),l=d.state.valid===!1,{transitionStatus:R}=Ce(l),f=fe.useMemo(()=>({...d,validity:d.state,transitionStatus:R}),[d,R]);return(0,Ft.jsx)(fe.Fragment,{children:o(f)})},"FieldValidity");var Se=E(k(),1);var je=E(ae(),1);var It=Se.forwardRef(t(function(e,o){let{render:s,className:c,style:d,disabled:l=!1,...R}=e,{state:f,disabled:u}=Y(!1),a=u||l,b={...f,disabled:a},C=Se.useMemo(()=>({disabled:a}),[a]),g=J("div",e,{ref:o,state:b,props:R,stateAttributesMapping:H});return(0,je.jsx)(Ve,{children:(0,je.jsx)(ke.Provider,{value:C,children:g})})},"FieldItem"));var Vt=E(ae(),1);var Be=Et.forwardRef(t(function(e,o){return(0,Vt.jsx)(Te.Control,{ref:o,...e})},"Input"));var Dt=E(ae(),1);function Pi(r){let e=(0,ht.c)(10),o,s,c;e[0]!==r?({className:o,type:c,...s}=r,e[0]=r,e[1]=o,e[2]=s,e[3]=c):(o=e[1],s=e[2],c=e[3]);let d;e[4]!==o?(d=ze("h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 md:text-xs dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",o),e[4]=o,e[5]=d):d=e[5];let l;return e[6]!==s||e[7]!==d||e[8]!==c?(l=(0,Dt.jsx)(Be,{type:c,"data-slot":"input",className:d,...s}),e[6]=s,e[7]=d,e[8]=c,e[9]=l):l=e[9],l}t(Pi,"m");export{H as a,Y as b,Z as c,U as d,st as e,dt as f,Ne as g,xt as h,Pi as i};
@@ -0,0 +1 @@
1
+ import{c as u}from"./chunk-SCTYLLJT.js";import{j as c}from"./chunk-L27FKJTG.js";import{a as l}from"./chunk-ZPQBVYNN.js";import{x as d}from"./chunk-VJQP4ARP.js";import{a as h,b as z}from"./chunk-ADABTCDI.js";import{a as t,d as o}from"./chunk-5PEAXTYQ.js";var p=o(h(),1);var a=p.forwardRef(t(function(e,r){let{render:n,className:k,disabled:s=!1,focusableWhenDisabled:g=!1,nativeButton:f=!0,style:B,...b}=e,{getButtonProps:m,buttonRef:x}=u({disabled:s,focusableWhenDisabled:g,native:f});return c("button",e,{state:{disabled:s},ref:[r,x],props:[b,m]})},"Button"));var v=o(z(),1);var y=l("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function W({className:i,variant:e="default",size:r="default",...n}){return(0,v.jsx)(a,{"data-slot":"button",className:d(y({variant:e,size:r,className:i})),...n})}t(W,"v");export{W as a};
@@ -0,0 +1,33 @@
1
+ import{a as be,b as Se}from"./chunk-PDBW6GTJ.js";import{a as st}from"./chunk-ADABTCDI.js";import{a as s,b as oe,d as Ae}from"./chunk-5PEAXTYQ.js";var Pe=oe((ke,Z)=>{(function(e,t){typeof define=="function"&&define.amd?define([],t):typeof Z=="object"&&Z.exports?Z.exports=t():e.moo=t()})(ke,function(){"use strict";var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=typeof new RegExp().sticky=="boolean";function a(i){return i&&t.call(i)==="[object RegExp]"}s(a,"isRegExp");function n(i){return i&&typeof i=="object"&&!a(i)&&!Array.isArray(i)}s(n,"isObject");function l(i){return i.replace(/[-\/\\^$*+?.()|[\]{}]/g,function(o){return o==="-"?"\\x2d":"\\"+o})}s(l,"reEscape");function u(i){var o=new RegExp("|"+i);return o.exec("").length-1}s(u,"reGroups");function g(i){return"("+i+")"}s(g,"reCapture");function w(i){if(!i.length)return"(?!)";var o=i.map(function(c){return"(?:"+c+")"}).join("|");return"(?:"+o+")"}s(w,"reUnion");function E(i){if(typeof i=="string")return"(?:"+l(i)+")";if(a(i)){if(i.ignoreCase)throw new Error("RegExp /i flag not allowed");if(i.global)throw new Error("RegExp /g flag is implied");if(i.sticky)throw new Error("RegExp /y flag is implied");if(i.multiline)throw new Error("RegExp /m flag is implied");return i.source}else throw new Error("Not a pattern: "+i)}s(E,"regexpOrLiteral");function I(i,o){return i.length>o?i:Array(o-i.length+1).join(" ")+i}s(I,"pad");function R(i,o){for(var c=i.length,d=0;;){var p=i.lastIndexOf(`
2
+ `,c-1);if(p===-1||(d++,c=p,d===o)||c===0)break}var h=d<o?0:c+1;return i.substring(h).split(`
3
+ `)}s(R,"lastNLines");function P(i){for(var o=Object.getOwnPropertyNames(i),c=[],d=0;d<o.length;d++){var p=o[d],h=i[p],m=[].concat(h);if(p==="include"){for(var y=0;y<m.length;y++)c.push({include:m[y]});continue}var _=[];m.forEach(function(f){n(f)?(_.length&&c.push(D(p,_)),c.push(D(p,f)),_=[]):_.push(f)}),_.length&&c.push(D(p,_))}return c}s(P,"objectToRules");function M(i){for(var o=[],c=0;c<i.length;c++){var d=i[c];if(d.include){for(var p=[].concat(d.include),h=0;h<p.length;h++)o.push({include:p[h]});continue}if(!d.type)throw new Error("Rule has no type: "+JSON.stringify(d));o.push(D(d.type,d))}return o}s(M,"arrayToRules");function D(i,o){if(n(o)||(o={match:o}),o.include)throw new Error("Matching rules cannot also include states");var c={defaultType:i,lineBreaks:!!o.error||!!o.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var d in o)e.call(o,d)&&(c[d]=o[d]);if(typeof c.type=="string"&&i!==c.type)throw new Error("Type transform cannot be a string (type '"+c.type+"' for token '"+i+"')");var p=c.match;return c.match=Array.isArray(p)?p:p?[p]:[],c.match.sort(function(h,m){return a(h)&&a(m)?0:a(m)?-1:a(h)?1:m.length-h.length}),c}s(D,"ruleOptions");function b(i){return Array.isArray(i)?M(i):P(i)}s(b,"toRules");var Q=D("error",{lineBreaks:!0,shouldThrow:!0});function F(i,o){for(var c=null,d=Object.create(null),p=!0,h=null,m=[],y=[],_=0;_<i.length;_++)i[_].fallback&&(p=!1);for(var _=0;_<i.length;_++){var f=i[_];if(f.include)throw new Error("Inheritance is not allowed in stateless lexers");if(f.error||f.fallback){if(c)throw!f.fallback==!c.fallback?new Error("Multiple "+(f.fallback?"fallback":"error")+" rules not allowed (for token '"+f.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+f.defaultType+"')");c=f}var O=f.match.slice();if(p)for(;O.length&&typeof O[0]=="string"&&O[0].length===1;){var U=O.shift();d[U.charCodeAt(0)]=f}if(f.pop||f.push||f.next){if(!o)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+f.defaultType+"')");if(f.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+f.defaultType+"')")}if(O.length!==0){p=!1,m.push(f);for(var L=0;L<O.length;L++){var x=O[L];if(a(x)){if(h===null)h=x.unicode;else if(h!==x.unicode&&f.fallback===!1)throw new Error("If one rule is /u then all must be")}}var G=w(O.map(E)),S=new RegExp(G);if(S.test(""))throw new Error("RegExp matches empty string: "+S);var W=u(G);if(W>0)throw new Error("RegExp has capture groups: "+S+`
4
+ Use (?: \u2026 ) instead`);if(!f.lineBreaks&&S.test(`
5
+ `))throw new Error("Rule should declare lineBreaks: "+S);y.push(g(G))}}var q=c&&c.fallback,K=r&&!q?"ym":"gm",z=r||q?"":"|";h===!0&&(K+="u");var at=new RegExp(w(y)+z,K);return{regexp:at,groups:m,fast:d,error:c||Q}}s(F,"compileRules");function H(i){var o=F(b(i));return new A({start:o},"start")}s(H,"compile");function B(i,o,c){var d=i&&(i.push||i.next);if(d&&!c[d])throw new Error("Missing state '"+d+"' (in token '"+i.defaultType+"' of state '"+o+"')");if(i&&i.pop&&+i.pop!=1)throw new Error("pop must be 1 (in token '"+i.defaultType+"' of state '"+o+"')")}s(B,"checkStateGroup");function ie(i,o){var c=i.$all?b(i.$all):[];delete i.$all;var d=Object.getOwnPropertyNames(i);o||(o=d[0]);for(var p=Object.create(null),h=0;h<d.length;h++){var m=d[h];p[m]=b(i[m]).concat(c)}for(var h=0;h<d.length;h++)for(var m=d[h],y=p[m],_=Object.create(null),f=0;f<y.length;f++){var O=y[f];if(O.include){var U=[f,1];if(O.include!==m&&!_[O.include]){_[O.include]=!0;var L=p[O.include];if(!L)throw new Error("Cannot include nonexistent state '"+O.include+"' (in state '"+m+"')");for(var x=0;x<L.length;x++){var G=L[x];y.indexOf(G)===-1&&U.push(G)}}y.splice.apply(y,U),f--}}for(var S=Object.create(null),h=0;h<d.length;h++){var m=d[h];S[m]=F(p[m],!0)}for(var h=0;h<d.length;h++){for(var W=d[h],q=S[W],K=q.groups,f=0;f<K.length;f++)B(K[f],W,S);for(var z=Object.getOwnPropertyNames(q.fast),f=0;f<z.length;f++)B(q.fast[z[f]],W,S)}return new A(S,o)}s(ie,"compileStates");function et(i){for(var o=typeof Map<"u",c=o?new Map:Object.create(null),d=Object.getOwnPropertyNames(i),p=0;p<d.length;p++){var h=d[p],m=i[h],y=Array.isArray(m)?m:[m];y.forEach(function(_){if(typeof _!="string")throw new Error("keyword must be string (in keyword '"+h+"')");o?c.set(_,h):c[_]=h})}return function(_){return o?c.get(_):c[_]}}s(et,"keywordTransform");var A=s(function(i,o){this.startState=o,this.states=i,this.buffer="",this.stack=[],this.reset()},"Lexer");A.prototype.reset=function(i,o){return this.buffer=i||"",this.index=0,this.line=o?o.line:1,this.col=o?o.col:1,this.queuedToken=o?o.queuedToken:null,this.queuedText=o?o.queuedText:"",this.queuedThrow=o?o.queuedThrow:null,this.setState(o?o.state:this.startState),this.stack=o&&o.stack?o.stack.slice():[],this},A.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedText:this.queuedText,queuedThrow:this.queuedThrow}},A.prototype.setState=function(i){if(!(!i||this.state===i)){this.state=i;var o=this.states[i];this.groups=o.groups,this.error=o.error,this.re=o.regexp,this.fast=o.fast}},A.prototype.popState=function(){this.setState(this.stack.pop())},A.prototype.pushState=function(i){this.stack.push(this.state),this.setState(i)};var tt=r?function(i,o){return i.exec(o)}:function(i,o){var c=i.exec(o);return c[0].length===0?null:c};A.prototype._getGroup=function(i){for(var o=this.groups.length,c=0;c<o;c++)if(i[c+1]!==void 0)return this.groups[c];throw new Error("Cannot find token type for matched text")};function rt(){return this.value}if(s(rt,"tokenToString"),A.prototype.next=function(){var i=this.index;if(this.queuedGroup){var o=this._token(this.queuedGroup,this.queuedText,i);return this.queuedGroup=null,this.queuedText="",o}var c=this.buffer;if(i!==c.length){var m=this.fast[c.charCodeAt(i)];if(m)return this._token(m,c.charAt(i),i);var d=this.re;d.lastIndex=i;var p=tt(d,c),h=this.error;if(p==null)return this._token(h,c.slice(i,c.length),i);var m=this._getGroup(p),y=p[0];return h.fallback&&p.index!==i?(this.queuedGroup=m,this.queuedText=y,this._token(h,c.slice(i,p.index),i)):this._token(m,y,i)}},A.prototype._token=function(i,o,c){var d=0;if(i.lineBreaks){var p=/\n/g,h=1;if(o===`
6
+ `)d=1;else for(;p.exec(o);)d++,h=p.lastIndex}var m={type:typeof i.type=="function"&&i.type(o)||i.defaultType,value:typeof i.value=="function"?i.value(o):o,text:o,toString:rt,offset:c,lineBreaks:d,line:this.line,col:this.col},y=o.length;if(this.index+=y,this.line+=d,d!==0?this.col=y-h+1:this.col+=y,i.shouldThrow){var _=new Error(this.formatError(m,"invalid syntax"));throw _}return i.pop?this.popState():i.push?this.pushState(i.push):i.next&&this.setState(i.next),m},typeof Symbol<"u"&&Symbol.iterator){var ne=s(function(i){this.lexer=i},"LexerIterator");ne.prototype.next=function(){var i=this.lexer.next();return{value:i,done:!i}},ne.prototype[Symbol.iterator]=function(){return this},A.prototype[Symbol.iterator]=function(){return new ne(this)}}return A.prototype.formatError=function(i,o){if(i==null)var c=this.buffer.slice(this.index),i={text:c,offset:this.index,lineBreaks:c.indexOf(`
7
+ `)===-1?0:1,line:this.line,col:this.col};var d=2,p=Math.max(i.line-d,1),h=i.line+d,m=String(h).length,y=R(this.buffer,this.line-i.line+d+1).slice(0,5),_=[];_.push(o+" at line "+i.line+" col "+i.col+":"),_.push("");for(var f=0;f<y.length;f++){var O=y[f],U=p+f;_.push(I(String(U),m)+" "+O),U===i.line&&_.push(I("",m+i.col+1)+"^")}return _.join(`
8
+ `)},A.prototype.clone=function(){return new A(this.states,this.state)},A.prototype.has=function(i){return!0},{compile:H,states:ie,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:et}})});var Me=oe(v=>{"use strict";var yt=v&&v.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(v,"__esModule",{value:!0});v.lexer=v.states=void 0;var Tt=yt(Pe());v.states={body:{doubleapos:{match:"''",value:s(()=>"'","value")},quoted:{lineBreaks:!0,match:/'[{}#](?:[^']|'')*'(?!')/u,value:s(e=>e.slice(1,-1).replace(/''/g,"'"),"value")},argument:{lineBreaks:!0,match:/\{\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,push:"arg",value:s(e=>e.substring(1).trim(),"value")},octothorpe:"#",end:{match:"}",pop:1},content:{lineBreaks:!0,match:/[^][^{}#']*/u}},arg:{select:{lineBreaks:!0,match:/,\s*(?:plural|select|selectordinal)\s*,\s*/u,next:"select",value:s(e=>e.split(",")[1].trim(),"value")},"func-args":{lineBreaks:!0,match:/,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*,/u,next:"body",value:s(e=>e.split(",")[1].trim(),"value")},"func-simple":{lineBreaks:!0,match:/,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,value:s(e=>e.substring(1).trim(),"value")},end:{match:"}",pop:1}},select:{offset:{lineBreaks:!0,match:/\s*offset\s*:\s*\d+\s*/u,value:s(e=>e.split(":")[1].trim(),"value")},case:{lineBreaks:!0,match:/\s*(?:=\d+|[^\p{Pat_Syn}\p{Pat_WS}]+)\s*\{/u,push:"body",value:s(e=>e.substring(0,e.indexOf("{")).trim(),"value")},end:{match:/\s*\}/u,pop:1}}};v.lexer=Tt.default.states(v.states)});var Be=oe($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.ParseError=void 0;$.parse=It;var He=Me(),ee=s(e=>({offset:e.offset,line:e.line,col:e.col,text:e.text,lineBreaks:e.lineBreaks}),"getContext"),pe=s(e=>e==="plural"||e==="select"||e==="selectordinal","isSelectType");function wt(e,t){let r="",a="";for(let l of t){let u=l.ctx.text;switch(a+=u,l.type){case"content":r+=l.value;break;case"argument":case"function":case"octothorpe":r+=u;break;default:throw new T(e,`Unsupported part in strict mode function arg style: ${u}`)}}return[{type:"content",value:r.trim(),ctx:Object.assign({},t[0].ctx,{text:a})}]}s(wt,"strictArgStyleParam");var Ot=["number","date","time","spellout","ordinal","duration"],Fe=["zero","one","two","few","many","other"],T=class extends Error{static{s(this,"ParseError")}constructor(t,r){super(He.lexer.formatError(t,r))}};$.ParseError=T;var me=class{static{s(this,"Parser")}constructor(t,r){var a,n,l,u;this.lexer=He.lexer.reset(t),this.cardinalKeys=(a=r?.cardinal)!==null&&a!==void 0?a:Fe,this.ordinalKeys=(n=r?.ordinal)!==null&&n!==void 0?n:Fe,this.strict=(l=r?.strict)!==null&&l!==void 0?l:!1,this.strictPluralKeys=(u=r?.strictPluralKeys)!==null&&u!==void 0?u:!0}parse(){return this.parseBody(!1,!0)}checkSelectKey(t,r,a){if(a[0]==="="){if(r==="select")throw new T(t,`The case ${a} is not valid with select`)}else if(r!=="select"){let n=r==="plural"?this.cardinalKeys:this.ordinalKeys;if(this.strictPluralKeys&&n.length>0&&!n.includes(a)){let l=`The ${r} case ${a} is not valid in this locale`;throw new T(t,l)}}}parseSelect({value:t},r,a,n){let l={type:n,arg:t,cases:[],ctx:a};n==="plural"||n==="selectordinal"?r=!0:this.strict&&(r=!1);for(let u of this.lexer)switch(u.type){case"offset":if(n==="select")throw new T(u,"Unexpected plural offset for select");if(l.cases.length>0)throw new T(u,"Plural offset must be set before cases");l.pluralOffset=Number(u.value),a.text+=u.text,a.lineBreaks+=u.lineBreaks;break;case"case":{this.checkSelectKey(u,n,u.value),l.cases.push({key:u.value,tokens:this.parseBody(r),ctx:ee(u)});break}case"end":return l;default:throw new T(u,`Unexpected lexer token: ${u.type}`)}throw new T(null,"Unexpected message end")}parseArgToken(t,r){let a=ee(t),n=this.lexer.next();if(!n)throw new T(null,"Unexpected message end");if(a.text+=n.text,a.lineBreaks+=n.lineBreaks,this.strict&&(n.type==="func-simple"||n.type==="func-args")&&!Ot.includes(n.value)){let l=`Invalid strict mode function arg type: ${n.value}`;throw new T(t,l)}switch(n.type){case"end":return{type:"argument",arg:t.value,ctx:a};case"func-simple":{let l=this.lexer.next();if(!l)throw new T(null,"Unexpected message end");if(l.type!=="end")throw new T(l,`Unexpected lexer token: ${l.type}`);if(a.text+=l.text,pe(n.value.toLowerCase()))throw new T(n,`Invalid type identifier: ${n.value}`);return{type:"function",arg:t.value,key:n.value,ctx:a}}case"func-args":{if(pe(n.value.toLowerCase())){let u=`Invalid type identifier: ${n.value}`;throw new T(n,u)}let l=this.parseBody(this.strict?!1:r);return this.strict&&l.length>0&&(l=wt(t,l)),{type:"function",arg:t.value,key:n.value,param:l,ctx:a}}case"select":if(pe(n.value))return this.parseSelect(t,r,a,n.value);throw new T(n,`Unexpected select type ${n.value}`);default:throw new T(n,`Unexpected lexer token: ${n.type}`)}}parseBody(t,r){let a=[],n=null;for(let l of this.lexer)if(l.type==="argument")n&&(n=null),a.push(this.parseArgToken(l,t));else if(l.type==="octothorpe"&&t)n&&(n=null),a.push({type:"octothorpe",ctx:ee(l)});else{if(l.type==="end"&&!r)return a;{let u=l.value;if(!t&&l.type==="quoted"&&u[0]==="#"){if(u.includes("{")){let g=`Unsupported escape pattern: ${u}`;throw new T(l,g)}u=l.text}n?(n.value+=u,n.ctx.text+=l.text,n.ctx.lineBreaks+=l.lineBreaks):(n={type:"content",value:u,ctx:ee(l)},a.push(n))}}if(r)return a;throw new T(null,"Unexpected message end")}};function It(e,t={}){return new me(e,t).parse()}s(It,"parse")});var le={BAD_REQUEST:{status:400,title:"Bad request"},INVALID_CURSOR:{status:400,title:"Invalid cursor"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},INVALID_TRANSITION:{status:409,title:"Invalid state transition"},DELIVERY_FENCED:{status:409,title:"Delivery authorization changed"},DELIVERY_RECEIPT_FENCED:{status:409,title:"Committed receipt authorization changed"},CONFLICT:{status:409,title:"Conflict"},NOT_UNIQUE:{status:400,title:"Query matched more than one document"},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:{status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},RUN_KIND_FORBIDDEN:{status:500,title:"Function kind may not be composed from a query"},TRANSACTION_LIMIT_EXCEEDED:{status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},MIGRATION_DRIFT:{status:409,title:"Migration drift"},MIGRATION_DESTRUCTIVE:{status:409,title:"Destructive migration not confirmed"},MIGRATION_ROOT_REQUIRED:{status:403,title:"Root admin token required for this migration"},SQL_MIGRATIONS_NOT_CONFIGURED:{status:400,title:"SQL migrations not configured"},UNIQUE_INDEX_DUPLICATES:{status:503,title:"Unique index blocked by duplicate rows"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},SHARD_TIMEOUT:{status:504,title:"Shard timeout"},SHARD_HTTP_ERROR:{status:502,title:"Shard HTTP error"},SHARD_DRY_RUN_UNSUPPORTED:{status:501,title:"Shard cannot dry-run an import"},SUBSCRIPTION_PERSIST_FAILED:{status:500,title:"Subscription persist failed"},SUBSCRIPTION_SEED_FAILED:{status:500,title:"Subscription seed failed"},TOO_MANY_SUBSCRIPTIONS:{status:429,title:"Too many subscriptions"},LIVE_CONTROL_SUPERSEDED:{status:409,title:"A later live control call already applied"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},OFFLINE_QUEUE_OVERFLOW:{status:503,title:"Offline queue full, oldest write dropped"},OFFLINE_NOT_QUEUED:{status:503,title:"Offline, write not queued"},IDENTITY_MISMATCH:{status:409,title:"Session changed since the write was queued"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},PROJECT_CONFIG_INVALID:{status:500,title:"lunora.config has an unknown key, a mistyped value or no default export"},JURISDICTION_MOVE:{status:422,title:"Unacknowledged jurisdiction move"},INDEX_FIELD_NESTED_PATH:{status:500,title:"Index field is a nested path"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},X402_FACILITATOR_ERROR:{internal:!0,status:502,title:"Payment facilitator error"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},PRIVACY_COVERAGE:{status:500,title:"Privacy coverage check failed"},PRIVACY_REQUEST_OPEN:{status:409,title:"A privacy request is already open"},PRIVACY_SESSION_NOT_FRESH:{status:403,title:"Recent sign-in required"},EMAIL_DOMAIN_BLOCKED:{status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_QUERY_ERROR:{status:502,title:"Analytics SQL query error"},BROWSER_RUN_ERROR:{status:502,title:"Browser Run API error"},BROWSER_TOO_MANY_REDIRECTS:{status:502,title:"Too many redirects"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},CONFIG_INVALID:{internal:!0,status:500,title:"Payment configuration invalid"},CURRENCY_MISMATCH:{status:400,title:"Currency mismatch"},PROVIDER_ERROR:{status:502,title:"Payment provider error"},WEBHOOK_EVENT_ID_MISSING:{status:400,title:"Webhook event id missing"},WEBHOOK_SIGNATURE_INVALID:{status:400,title:"Webhook signature invalid"},WEBHOOK_TIMESTAMP_INVALID:{status:400,title:"Webhook timestamp outside tolerance"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_ROOT_REQUIRED:{status:403,title:"Root admin token required"},ADMIN_SCOPE_REQUIRED:{status:403,title:"Migrations scope required"},ADMIN_TOKEN_EXISTS:{status:409,title:"Admin token name already in use"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_MIGRATOR_UNSUPPORTED:{status:500,title:"Auth migrator cannot drive the configured database"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},AUTH_CIMD_FETCH_NOT_PUBLIC:{status:500,title:"CIMD transport needs the global_fetch_strictly_public flag"},AUTH_MCP_RESOURCE_AMBIGUOUS:{status:500,title:"MCP resource cannot be told apart from the provider's other resources"},AUTH_MCP_RESOURCE_INVALID:{status:500,title:"MCP resource missing or not an absolute URL"},MCP_STEP_UP_MISCONFIGURED:{status:500,title:"MCP step-up misconfigured"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},BACKUP_RETENTION_NOT_CONFIGURED:{status:400,title:"Backup retention window not configured"},BACKUP_TOO_LARGE:{status:507,title:"Backup too large to assemble in a Worker"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_IN_FLIGHT:{status:409,title:"Cron job is already running"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},DEPLOYMENT_PAUSED:{status:503,title:"Deployment is paused"},EXPORT_SHARD_FAILED:{status:502,title:"Export failed on one or more shards"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},ID_COLLISION:{status:409,title:"Document id already belongs to another table"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PAUSE_INSTANCES_FAILED:{status:502,title:"Pause did not reach every scheduler instance"},PAUSE_NOT_CONFIGURED:{status:400,title:"Deployment pause not configured"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_CHECKSUM_MISMATCH:{status:400,title:"Storage checksum mismatch"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_DOWNLOAD_NOT_CONFIGURED:{status:400,title:"Storage download not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_OBJECT_NOT_FOUND:{status:404,title:"Storage object not found"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},AI_UNKNOWN_IMAGE_MODEL:{status:400,title:"Unknown image model"},RAG_DIMENSION_MISMATCH:{status:409,title:"Embedding dimension mismatch"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},AUTH_MOVE_NOT_CONFIGURED:{status:400,title:"Auth jurisdiction move not configured"},AUTH_MOVE_TARGET_NOT_EMPTY:{status:409,title:"Pinned auth object is not empty"},AUTH_MOVE_CONFLICT:{status:409,title:"Auth copy conflict"},AUTH_MOVE_SOURCE_CHANGED:{status:409,title:"Un-pinned auth object changed since the copy"},AUTH_MOVE_SOURCE_PURGED:{status:409,title:"Un-pinned auth object already purged"},AUTH_MOVE_INCOMPLETE:{status:409,title:"Auth copy not finished"},AUTH_MOVE_FAILED:{status:500,title:"Auth jurisdiction move failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_ROOM_NAME:{status:500,title:"Duplicate room name"},ROOM_NAME_NOT_LITERAL:{status:500,title:"Room name is not a string literal"},DUPLICATE_SOCKET_PATH:{status:500,title:"Duplicate socket route path"},SOCKET_AUTH_NOT_LITERAL:{status:500,title:"Socket route auth is not a literal boolean"},SOCKET_PATH_INVALID:{status:500,title:"Socket route path is not a plain URL path"},SOCKET_PATH_NOT_LITERAL:{status:500,title:"Socket route path is not a string literal"},LIVE_STREAM_DUPLICATE:{status:500,title:"Duplicate live stream id or export name"},LIVE_STREAM_NOT_EXPORTED:{status:500,title:"Live stream is not a named export"},LIVE_STREAM_NOT_LITERAL:{status:500,title:"Live stream declaration is not a literal"},LIVE_TOPIC_INVALID:{status:500,title:"Live topic name or key field is not allowed"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},WORKFLOW_EVENT_DUPLICATE:{status:500,title:"Duplicate workflow event type"},WORKFLOW_EVENT_NOT_LITERAL:{status:500,title:"Workflow event type is not a string literal"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},PUBLISHED_FUNCTION_UNSUPPORTED:{status:500,title:"Published function cannot be registered from its declaration"},PUBLISHED_FUNCTION_VISIBILITY_UNKNOWN:{status:500,title:"Published function does not declare its visibility"},PROCEDURE_META_UNLOADED:{status:500,title:"Procedure meta is not loaded"},AI_CHAT_FAILED:{status:500,title:"Assistant turn failed"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},SUBSCRIPTION_FUNCTION_REQUIRED:{status:400,title:"Subscription needs a function path"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CASCADE_LIMIT:{status:400,title:"Cascade limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},DISPATCH_UNAUTHENTICATED:{status:403,title:"Dispatch caller not authenticated"},DISPATCH_IN_PROGRESS:{status:409,title:"Dispatch already in progress"},STALE_CREDENTIAL:{status:409,title:"Stale credential"},IDENTITY_CHANGED:{status:409,title:"Socket identity changed"},IDENTITY_STALE:{status:409,title:"Socket identity stale"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},GLOBAL_SEARCH_SCORES_UNSUPPORTED:{status:400,title:"collectWithScores() is unsupported on a global table"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},FORBIDDEN_TOPIC:{status:403,title:"Live topic publish forbidden"},GLOBAL_DRY_RUN_UNSUPPORTED:{status:400,title:"Global table dry run not supported"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},INVALID_SCHEDULE_ID:{status:400,title:"Invalid schedule id"},RATE_LIMITED:{status:429,title:"Rate limited"},REPLICA_NOT_READY:{status:421,title:"Replica not caught up"},REPLICA_READ_ONLY:{status:421,title:"Replica is read-only"},SEARCH_INDEX_BUILDING:{status:503,title:"Search index is still building"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_MEMORY_TABLE:{status:400,title:"Shape over a memory table is unsupported"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},SHAPE_RELATION_PREDICATE:{status:400,title:"Shape filtered by a relation is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},WIRE_DECODE_FAILED:{status:502,title:"Could not decode a server frame"},WIRE_ENCODE_FAILED:{status:500,title:"Could not encode a return value"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},CDC_LOG_TRIMMED:{status:409,title:"CDC log trimmed"},CDC_TIMELINE_FORKED:{status:409,title:"CDC timeline forked"},CDC_PAYLOAD_COMPACTED:{status:409,title:"CDC payloads compacted"},EXPIRED:{status:404,title:"Session expired"},GLOBAL_TRANSACTION_UNSUPPORTED:{status:500,title:"Global transaction unsupported by driver"},LIVE_CONNECTION_LIMIT:{status:503,title:"Live connection limit reached"},LIVE_CONNECTION_NOT_FOUND:{status:404,title:"Live connection not found"},LIVE_STREAMS_UNSUPPORTED:{status:501,title:"Live streams are not served by this worker"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SHAPE_REQUIRES_CDC:{status:409,title:"Shape requires change-data-capture"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},STREAM_ID_IN_USE:{status:409,title:"Stream id already in use"},STREAM_IDLE:{status:504,title:"Stream went idle"},STREAM_INTERRUPTED:{status:503,title:"Durable stream interrupted"},STREAM_TOO_LONG:{status:507,title:"Durable stream exceeded its chunk ceiling"},SUBSCRIPTION_RESULT_TOO_LARGE:{status:413,title:"Subscription result too large"},TOKEN_EXPIRED:{status:401,title:"Authentication token expired"},TOO_MANY_LIVE_TOPICS:{status:429,title:"Too many live topics"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},TOO_MANY_WHISPER_TOPICS:{status:429,title:"Too many whisper topics"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},RELAY_SHAPE_UNROUTABLE:{status:500,title:"Relay shape unroutable"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_CALLBACK:{status:500,title:"HTTP stream callback threw"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"},LOCAL_DEPENDENCY_MISSING:{status:500,title:"Required local tool not found"}},ue=s(e=>Object.hasOwn(le,e)?le[e]:void 0,"s");var Ne=Symbol.for("@lunora/errors/LunoraError"),ce=class e extends Error{static{s(this,"s")}static[Symbol.hasInstance](t){return this!==e?Function.prototype[Symbol.hasInstance].call(this,t):typeof t=="object"&&t!==null&&t[Ne]===!0}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;why;constructor(t,r,a={}){let n=ue(t);super(r??t,a.cause===void 0?void 0:{cause:a.cause}),this.name=a.name??"LunoraError",this.hint=a.hint,this.title=a.title??n?.title,this.loc=a.location,this.code=t,this.status=a.status??n?.status??500,this.docsUrl=a.docsUrl,this.data=a.data,this.why=a.why,Object.defineProperty(this,Ne,{value:!0}),a.internal!==void 0&&Object.defineProperty(this,"internal",{value:a.internal}),a.headers!==void 0&&Object.defineProperty(this,"headers",{value:a.headers})}};var k="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",j="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",it=/string or blob too big/iu,ve=["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."],de={DELIVERY_FENCED:"The operation may have committed. Retry with the same transport key; a committed result from an older authority epoch returns DELIVERY_RECEIPT_FENCED. Do not automatically retry with a new transport key.",DELIVERY_RECEIPT_FENCED:"The operation committed, but its stored result belongs to an older authority epoch. Do not automatically retry with a new transport ID. Recover through the application's durable operation key under current authorization.",CONFLICT:ve,INVALID_CURSOR:"The page cursor was refused: its format prefix is one the engine no longer reads, its payload is not one the server minted, or it carries fewer sort keys than the query orders by now. The engine bumps the prefix whenever a format change would otherwise read old cursors as the wrong rows, so this usually follows a deploy. `usePaginatedQuery` restarts the feed from its first page when a page fails with this code; a hand-written pager should do the same rather than retry the cursor.",GLOBAL_TRANSACTION_UNSUPPORTED:"A `.global()` write commits its row and companion rows in one transaction. Pass a postgres.js client that has `begin()`, or a mysql2 pool (`createPool`) rather than a single connection.",NOT_UNIQUE:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],RLS_REQUIRED:["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."],TRANSACTION_LIMIT_EXCEEDED:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class.","","A transaction that reaches 80% of a ceiling without crossing it logs one `warn` line (event `lunora.transaction.near_limit`) naming the limit, so a function that only gets close on development data shows up before production data pushes it over. A single read or write that jumps past the ceiling from below 80% fails without that warning."],MIGRATION_DRIFT:["An applied SQL migration is never re-run, so the runner stopped before applying anything.","","- **Its text changed after it ran:** revert the edit and put the change in a new migration. If the edit is inert (a comment, whitespace, line endings), record the new hash with the `UPDATE` the message prints.","- **Tracking rows predate versions and match no migration:** set each row's `version` with the `UPDATE` the message prints, so the runner can tell what already ran."],MIGRATION_DESTRUCTIVE:["A pending SQL migration drops, renames, truncates or replaces, and nothing in it says that is intended, so the runner stopped before applying anything.","","If it is intended, put a `-- lunora:allow-destructive` line comment on its own line before the statement and run again. Only migrations that have not run yet are checked, so never add the comment to one that already ran: that changes its hash and is refused as drift."],UNIQUE_INDEX_DUPLICATES:["The index was not built, so requests to its store are refused until it is.","","Make one row keep each key. For a shard table, write a `defineMigration` in `lunora/migrations.ts` that deletes or merges the duplicates, deploy it, then run `lunora migrate up <id>` with that migration's id; the `lunora-migration-helper` skill covers the pattern. A `.global()` table lives in your SQL database, not a shard, so `defineMigration` does not reach it: delete or merge the duplicate rows directly in the database. Either way the index build is retried on its own, so no second deploy is needed."],OFFLINE_QUEUE_OVERFLOW:"The client held `offlineQueue.maxItems` writes (1000 by default) while offline, so it dropped the oldest one to make room and rejected it with this code. The dropped write was never sent. Raise `maxItems` on the `LunoraClient`, or stop issuing writes while the connection is down; `client.onMutationSettled` reports every dropped write, including one restored after a reload. See [offline-first](/docs/concepts/offline-first).",SUBSCRIPTION_SEED_FAILED:"The query behind a subscription threw on its first run, and the error was not a `LunoraError` with a non-internal code, so its message was redacted before it reached the client. The shard logs the real error with `console.error`, prefixed `[@lunora/do] subscription seed failed for <function path>`: read it with `lunora logs` (or `wrangler tail`) in production, or in the `lunora dev` terminal locally. Studio's Logs tab shows only the redacted entry. A query that throws a `LunoraError` with a non-internal code keeps its own code and message instead; an internal-coded one arrives under its own code rather than this one, with its message redacted and the real error logged the same way.",OFFLINE_NOT_QUEUED:"A mutation sent with `onlineOnly: true` found its connection down or reconnecting (the shard had connected before), or, on a shard that has never connected, its request failed on the wire. It was refused instead of queued. Nothing was persisted or replayed; issue the call again once the connection is back. See [keeping a write off the queue](/docs/concepts/offline-first#keeping-a-write-off-the-queue).",IDENTITY_MISMATCH:["A write queued offline was replayed on a session that now belongs to someone else (a sign-out, or another user's sign-in, while it waited), so the worker refused it rather than commit it as them.","","`@lunora/client` re-resolves the session on this refusal and settles the write itself. If every replay is refused while the same user stays signed in, your worker's `resolveIdentity` returns a different `userId` than better-auth's `user.id`, or the RPC request carries no session cookie."],JURISDICTION_MOVE:["The schema declares `.jurisdiction(...)` and the project has DO-backed auth (`.auth({ namespace })`). Pinning the auth object to the jurisdiction resolves it to a new, empty one: every user, account and session stays in the unpinned object until copied across. Voice sessions are pinned without an acknowledgement: they store nothing, and their transcripts are rows in the already-pinned shards.","",'Acknowledge with `.jurisdiction("eu", { pinAuth: true })` and deploy, then copy the auth tables across with the `__lunora_admin__:copyAuthToJurisdiction` admin op and, once the counts check out, purge the unpinned copy with `__lunora_admin__:purgeUnpinnedAuth` (see [Pinning auth and voice](/docs/concepts/data-residency#pinning-auth-and-voice)). For D1-mode auth the acknowledgement changes nothing.'],INDEX_FIELD_NESTED_PATH:"Indexes cover top-level columns only. Denormalise the nested value into its own column, index that, and keep it in sync with a table `.triggers()` beforeInsert/beforeUpdate.",EMAIL_DOMAIN_BLOCKED:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` in the `EmailGateConfig` you hand `assertEmailAllowed` / `classifyEmail` / `emailGateMiddleware` (`@lunora/auth/email-guard`)."],EMAIL_UNDELIVERABLE:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],AUTH_MIGRATOR_UNSUPPORTED:["better-auth migrates only through its Kysely adapter, so `ensureMigrated` / `compileMigrationsSql` need the raw D1 binding as `database` \u2014 a custom adapter (`lunoraD1Adapter`, `lunoraAuthAdapter`, `lunoraDoAdapter`) cannot be migrated through, and neither can an absent `database`.","","Build a SECOND, migration-only instance over the raw binding \u2014 `createMigrationAuth({ ...options, database: env.DB })` (from `@lunora/auth/migrate`) \u2014 and hand that one to `ensureMigrated`. Keep the adapter on the instance that serves requests: the adapter exists to dodge a dev-runner hang in `$context`, which the migration instance never resolves.","","To compile the SQL off-platform (`compileMigrationsSql`), diff against an empty local database \u2014 `new DatabaseSync(':memory:')` from `node:sqlite` \u2014 rather than passing no `database` at all."],AUTH_CIMD_FETCH_NOT_PUBLIC:'Add "global_fetch_strictly_public" to "compatibility_flags" in wrangler.jsonc, so CIMD metadata fetches cannot reach private addresses. `lunora doctor` reports it as `cimd-fetch-not-strictly-public`.',AUTH_MCP_RESOURCE_AMBIGUOUS:'Use `mcp` from "@lunora/auth/plugins" (not `@better-auth/mcp`) and pass the plugin object as is: it records its `resource`, which the worker needs to serve the protected-resource metadata when the provider names several resources.',AUTH_MCP_RESOURCE_INVALID:"Pass `resource` to `requireMcpAuth` (and `mcp()`) as the absolute URL of the MCP route, e.g. `https://app.example.com/mcp`: issued tokens are audience-bound to it.",MCP_STEP_UP_MISCONFIGURED:"Give `createAuthedMcpFetchHandler`'s `stepUp` a non-empty `scope` (such as `lunora:write`) and a `challenge` (`createInsufficientScopeError` from `@lunora/auth/plugins`), or leave `stepUp` out.",BACKUP_RETENTION_NOT_CONFIGURED:["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.","","Nothing was deleted. A default is deliberately not invented here \u2014 retention deleting on its own is exactly what this command exists to replace."],BACKUP_TOO_LARGE:["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.","","The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.","","Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help \u2014 every run is a full snapshot."],EXPORT_SHARD_FAILED:["One or more shards failed to export, so the snapshot would have been short. Nothing is written when this fires \u2014 a partial export must never be mistaken for a complete one.","","The message names each failed shard key and its error. Re-run the export once those shards are reachable; a shard that fails repeatedly is usually over the per-request memory budget, which `backupTables` narrows."],ID_COLLISION:["The imported row carries an `_id` that is already held by a DIFFERENT table in this shard. Ids are per-table, so inserting it would leave two tables claiming one id and make a later lookup resolve to whichever one it reached first.","","This is reported per row rather than aborting the import: the remaining rows still apply. Re-mint the id on the source side, or import that table into a shard that does not already hold it.","","Only shard tables raise it. A `.global()` table names its table on every by-id call, so the same id in two global tables is two separate rows and the import accepts it."],STORAGE_CHECKSUM_MISMATCH:["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written \u2014 this check fails closed.","","Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."],STORAGE_DOWNLOAD_NOT_CONFIGURED:["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` \u2014 forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.","","Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."],RAG_DIMENSION_MISMATCH:["A stored vector and the query embedding have different widths, so they cannot be compared.","","This is what changing a RAG index's `embeddingModel` (or a provider's `dimensions` option) without reindexing looks like. Either put the previous model back, or reindex the namespace under the new one \u2014 bump `embeddingModelVersion` so the index rebuilds instead of mixing widths."],AUTH_MOVE_NOT_CONFIGURED:"The copy needs DO-backed auth (`.auth({ namespace })`) pinned with `.jurisdiction(\u2026, { pinAuth: true })`, and the auth object's `internalSecret` set.",AUTH_MOVE_TARGET_NOT_EMPTY:"The pinned auth object holds users the copy did not write (someone signed up there), so copying into it would merge two user bases. Pass `force: true` to copy anyway: a copied row that collides with one of the pinned object's rows is left out and counted under `conflicts`.",AUTH_MOVE_CONFLICT:"A copied row has the same key or unique value (such as an email) as a row the pinned auth object holds on its own, or the pinned object changed a row the source changed too. Nothing from that page was written. Pass `force: true` to keep the pinned object's rows and count the collisions under `conflicts`.",AUTH_MOVE_SOURCE_CHANGED:"The un-pinned auth object changed after the copy read it (an update, a delete, or a new row), for example during a gradual rollout or a rollback. Run the copy again: it reconciles the changed tables. Then purge.",AUTH_MOVE_SOURCE_PURGED:"The un-pinned auth object was already purged. Its tables may exist again (a rollback served requests there), but they hold only rows written since, so the copy refuses rather than read them as deletions and remove the pinned object's users. Nothing is left to copy.",AUTH_MOVE_INCOMPLETE:"Run `__lunora_admin__:copyAuthToJurisdiction` until it answers `done: true`, check the per-table counts, then purge.",AUTH_MOVE_FAILED:"The message names the step, the table and the class of the SQLite error; the auth object's log has the full error. The copy resumes where it stopped once the cause is fixed.",DISPATCH_UNAUTHENTICATED:"The scheduler could not authenticate to the worker. Check that `LUNORA_SCHEDULER_SECRET` matches on both sides, or that `LUNORA_ADMIN_TOKEN` is set and current.",DISPATCH_IN_PROGRESS:"A dispatch with this idempotency id is still running on the shard. Retry it; once the first attempt settles the same id is served from the replay cache.",TOKEN_EXPIRED:["The caller's credential verified but its expiry has passed. The worker refuses an HTTP call with this code before it runs; a shard drops a socket with close code `4001` and the same code.","","It is a refusal of the credential, not of the call: `@lunora/client` holds a queued write, fires `onTokenExpired`, and re-sends it after `setAuthToken`. The held write survives the refresh only if you pass the same `subject` (the user id) with the new token, `setAuthToken(freshToken, user.id)`; without one a refresh reads as a user switch and the write is rejected `OFFLINE_IDENTITY_CHANGED`. Under a cookie session there is no token to replace: renew the cookie and the write is re-sent on a backoff. The worker can only tell expired from anonymous if your `resolveIdentity` returns the identity with its past `exp` (or `expiresAtMs`), or throws a `LunoraError` with this code. Returning `null` runs the call anonymous."],TOO_MANY_WHISPER_TOPICS:"Reuse a stable set of whisper topic names, or reconnect \u2014 the per-socket verdict memo is in-memory, so a new connection starts empty. Leaving a topic does not free its entry.",HTTP_STREAM_NO_BODY:["The `fetch` implementation resolved with a response that exposes neither a `body` stream nor a `text()` read \u2014 a broken `fetch` substitute, not a runtime limitation.","A response with no `body` stream that can still be read as text (React Native's `whatwg-fetch` polyfill) is buffered through `text()` instead and never raises this code. Check the `fetch` override passed to the client or the `httpStream` call."],LOCAL_DEPENDENCY_MISSING:["The command Lunora tried to run is not on your PATH, so nothing ran.","","Install it (or put it on PATH) and retry \u2014 `wrangler` ships as a dependency of a Lunora app, so `pnpm install` usually fixes that one; `git` and `docker` are installed separately."]},De=s(e=>Object.hasOwn(de,e)?de[e]:void 0,"m"),Ce=[{body:["A single row exceeded the storage engine's per-row ceiling \u2014 2 MB on a Durable Object's SQLite, and 2,000,000 bytes on D1.","","The limit is on the STORED bytes, which are UTF-8: a document of multi-byte text (CJK, emoji) costs up to 3x its character count. `v.bytes()` and `v.bigint()` columns cost more again on a shard-local table, where the row stores both a SQL-comparable projection and the original.","","Keep the large payload out of the row and store a reference to it:","","```ts","const key = `uploads/${crypto.randomUUID()}`;","await ctx.storage.uploads.put(key, bytes);",'await ctx.db.insert("documents", { storageKey: key, title });',"```","","R2 has no practical object-size ceiling, and the row stays small enough to read, index, and replicate."].join(`
9
+ `),header:"Row too large for the storage engine",id:"lunora-row-too-big",test:s(e=>it.test(e),"test")},{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(`
10
+ `),header:"No Lunora schema found",id:"lunora-schema-missing",test:s(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(`
11
+ `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:s(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 `ctx.db` member (the error names the one it hit) \u2014 e.g. `userAccounts` instead of `insert`, or `pageViews` instead of `count`."].join(`
12
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:s(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(`
13
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:s(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(`
14
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:s(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(`
15
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:s(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(`
16
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:s(e=>e.includes("not exported by your worker entry"),"test")},{body:["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.`].join(`
17
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:s(e=>e.includes("unique constraint violation on"),"test")},{body:ve.join(`
18
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:s(e=>e.includes("optimistic concurrency conflict"),"test")}],he=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:k,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:k,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:k,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:k,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:k,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:k,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:k,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:j,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:j,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:j,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:j,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:j,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:j,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],fe=s(e=>e!==void 0&&e>="0"&&e<="9","s"),nt=s((e,t)=>{for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+t.length))if(!fe(e[r-1])&&!fe(e[r+t.length]))return!0;return!1},"g"),ot=s((e,t)=>{for(let r of[`error ${t}`,`error: ${t}`])for(let a=e.indexOf(r);a!==-1;a=e.indexOf(r,a+r.length))if(!fe(e[a+r.length]))return!0;return!1},"w"),lt=/error|cloudflare/iu,Re=s(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
19
+ `),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),Ue=s(e=>{if(!lt.test(e))return;let t=e.toLowerCase(),r=t.includes("error"),a=t.includes("cloudflare");if(r){for(let n of he)if(ot(t,n.code))return Re(n)}if(a){for(let n of he)if(nt(t,n.code))return Re(n)}},"y"),ut=s(e=>(typeof e=="string"?e:e.join(`
20
+ `)).split(`
21
+ `).filter(t=>!t.startsWith("```")).join(`
22
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"T"),X=s(e=>{for(let t of Ce)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"d"),ct=s(e=>X(e)??Ue(e),"v"),J=s(e=>{if(typeof e=="string")return X(e)?.body;if(e.hint!==void 0)return e.hint;if(e.code!==void 0){let t=De(e.code);if(t!==void 0)return t}return e.message===void 0?void 0:X(e.message)?.body},"x");var dt="A mutation sent with `onlineOnly: true` found its connection down or reconnecting (the shard had connected before), or, on a shard that has never connected, its request failed on the wire. It was refused instead of queued. Nothing was persisted or replayed; issue the call again once the connection is back. See [keeping a write off the queue](/docs/concepts/offline-first#keeping-a-write-off-the-queue).",ht=["The `fetch` implementation resolved with a response that exposes neither a `body` stream nor a `text()` read \u2014 a broken `fetch` substitute, not a runtime limitation.","A response with no `body` stream that can still be read as text (React Native's `whatwg-fetch` polyfill) is buffered through `text()` instead and never raises this code. Check the `fetch` override passed to the client or the `httpStream` call."];var ft=s(e=>{if(typeof e=="string")return[e];if(!Array.isArray(e))return;let t=e.filter(r=>typeof r=="string");return t.length>0?t:void 0},"a"),Le=s(e=>{if(e!==void 0)return typeof e=="string"?e:e.join(`
23
+ `)},"s"),pt=new Set(["ADMIN_FORBIDDEN","FORBIDDEN","UNAUTHORIZED"]),ur=s((e,t,r,a,n)=>{switch(t){case"action":return e.action(r,a,n);case"mutation":return e.mutation(r,a,{...n,onlineOnly:!0});default:return e.query(r,a,n)}},"p"),cr=s(e=>({__lunoraRef:e}),"m"),dr=s(e=>{let t=e.trim();return t===""?{}:{shardKey:t}},"h"),hr=s(e=>e instanceof Error?e.message:String(e),"b"),mt=s(e=>{if(e===null||typeof e!="object"||!("code"in e))return;let{code:t}=e;return typeof t=="string"?t:void 0},"u"),fr=s(e=>{let t=mt(e);return t!==void 0&&pt.has(t)},"B"),pr=s(e=>{if(typeof e=="string")return Le(J(e));if(e===null||typeof e!="object")return;let{code:t,hint:r,message:a}=e;return Le(J({code:typeof t=="string"?t:void 0,hint:ft(r),message:typeof a=="string"?a:void 0}))},"w"),mr=s(e=>{if(e===null||typeof e!="object"||!("docsUrl"in e))return;let t=e.docsUrl;if(typeof t=="string")try{let{protocol:r}=new URL(t);return r==="http:"||r==="https:"?t:void 0}catch{return}},"T"),xe=s(e=>{if(e==null)return"\u2014";if(e<1024)return`${e.toString()} B`;let t=["KB","MB","GB","TB"],r=e/1024,a=0;for(;r>=1024&&a<t.length-1;)r/=1024,a+=1;return`${r.toFixed(1)} ${t[a]??"TB"}`},"c"),gt=s((e,t)=>typeof t=="bigint"?t.toString():t instanceof ArrayBuffer||ArrayBuffer.isView(t)?`<bytes: ${xe(t.byteLength)}>`:t,"d"),gr=s(e=>typeof e=="bigint"?e.toString():e,"S"),_r=s(e=>{if(e==null)return"";switch(typeof e){case"bigint":case"boolean":case"number":return e.toString();case"string":return e;case"symbol":return e.toString();default:return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?`<bytes: ${xe(e.byteLength)}>`:JSON.stringify(e,gt)}},"A"),_t=s((e,t)=>{e.catch(r=>{t?.(r)})},"g"),Et=s(e=>{if(e!==void 0&&e!=="")return e;let t=globalThis.location;return t?.origin!==void 0&&t.origin!==""?t.origin:"http://localhost:5173"},"l"),Er=s(e=>{let t=Et(e);for(;t.endsWith("/");)t=t.slice(0,-1);return t},"D"),yr=s(e=>{let t="navigator"in globalThis?globalThis.navigator.clipboard:void 0;return t===void 0?!1:(_t(t.writeText(e)),!0)},"N"),Tr=s((e,t="")=>{if(e==null||e==="")return t;let r=new Date(e);return Number.isNaN(r.getTime())?String(e):r.toLocaleString()},"O");function br(...e){return Se(be(e))}s(br,"m");var je=Ae(Be(),1);var N=class extends Error{static{s(this,"DateFormatError")}constructor(t,r,a){super(t),this.token=r,this.type=a||"error"}},Ge=s(e=>e<4?"short":e===4?"long":"narrow","alpha"),Y=s(e=>e%2===0?"2-digit":"numeric","numeric");function At(e,t){switch(e.char){case"y":return{year:Y(e.width)};case"r":return{calendar:"gregory",year:"numeric"};default:return t(`${e.desc} is not supported; falling back to year:numeric`,N.WARNING),{year:"numeric"}}}s(At,"yearOptions");function bt(e,t){switch(e.width){case 1:return"numeric";case 2:return"2-digit";case 3:return"short";case 4:return"long";case 5:return"narrow";default:t(`${e.desc} is not supported with width ${e.width}`);return}}s(bt,"monthStyle");function St(e,t){let{char:r,desc:a,width:n}=e;if(r==="d")return Y(n);t(`${a} is not supported`)}s(St,"dayStyle");function Nt(e,t){let{char:r,desc:a,width:n}=e;if((r==="c"||r==="e")&&n<3){let l=`Numeric value is not supported for ${a}; falling back to weekday:short`;t(l,N.WARNING)}return Ge(n)}s(Nt,"weekdayStyle");function Rt(e){let t=Y(e.width),r;switch(e.char){case"h":r="h12";break;case"H":r="h23";break;case"k":r="h24";break;case"K":r="h11";break}return r?{hour:t,hourCycle:r}:{hour:t}}s(Rt,"hourOptions");function vt(e,t){let{char:r,desc:a,width:n}=e;switch(r){case"v":case"z":return n===4?"long":"short";case"V":if(n===4)return"long";t(`${a} is not supported with width ${n}`);return;case"X":t(`${a} is not supported`);return}return"short"}s(vt,"timeZoneNameStyle");function Dt(e,t){switch(e.field){case"era":return{era:Ge(e.width)};case"year":return At(e,t);case"month":return{month:bt(e,t)};case"day":return{day:St(e,t)};case"weekday":return{weekday:Nt(e,t)};case"period":return;case"hour":return Rt(e);case"min":return{minute:Y(e.width)};case"sec":return{second:Y(e.width)};case"tz":return{timeZoneName:vt(e,t)};case"quarter":case"week":case"sec-frac":case"ms":t(`${e.desc} is not supported`)}}s(Dt,"compileOptions");function ge(e,t,r=a=>{throw a}){let a={timeZone:t},n=[];for(let l of e){let{error:u,field:g,str:w}=l;if(u){let I=new N(u.message,l);I.stack=u.stack,r(I)}if(w){let I=`Ignoring string part: ${w}`;r(new N(I,l,N.WARNING))}g&&(n.indexOf(g)===-1?n.push(g):r(new N(`Duplicate ${g} token`,l)));let E=Dt(l,(I,R)=>r(new N(I,l,R)));E&&Object.assign(a,E)}return a}s(ge,"getDateFormatOptions");var Ct={G:{field:"era",desc:"Era"},y:{field:"year",desc:"Year"},Y:{field:"year",desc:'Year of "Week of Year"'},u:{field:"year",desc:"Extended year"},U:{field:"year",desc:"Cyclic year name"},r:{field:"year",desc:"Related Gregorian year"},Q:{field:"quarter",desc:"Quarter"},q:{field:"quarter",desc:"Stand-alone quarter"},M:{field:"month",desc:"Month in year"},L:{field:"month",desc:"Stand-alone month in year"},w:{field:"week",desc:"Week of year"},W:{field:"week",desc:"Week of month"},d:{field:"day",desc:"Day in month"},D:{field:"day",desc:"Day of year"},F:{field:"day",desc:"Day of week in month"},g:{field:"day",desc:"Modified julian day"},E:{field:"weekday",desc:"Day of week"},e:{field:"weekday",desc:"Local day of week"},c:{field:"weekday",desc:"Stand-alone local day of week"},a:{field:"period",desc:"AM/PM marker"},b:{field:"period",desc:"AM/PM/noon/midnight marker"},B:{field:"period",desc:"Flexible day period"},h:{field:"hour",desc:"Hour in AM/PM (1~12)"},H:{field:"hour",desc:"Hour in day (0~23)"},k:{field:"hour",desc:"Hour in day (1~24)"},K:{field:"hour",desc:"Hour in AM/PM (0~11)"},j:{field:"hour",desc:"Hour in preferred cycle"},J:{field:"hour",desc:"Hour in preferred cycle without marker"},C:{field:"hour",desc:"Hour in preferred cycle with flexible marker"},m:{field:"min",desc:"Minute in hour"},s:{field:"sec",desc:"Second in minute"},S:{field:"sec-frac",desc:"Fractional second"},A:{field:"ms",desc:"Milliseconds in day"},z:{field:"tz",desc:"Time Zone: specific non-location"},Z:{field:"tz",desc:"Time Zone"},O:{field:"tz",desc:"Time Zone: localized"},v:{field:"tz",desc:"Time Zone: generic non-location"},V:{field:"tz",desc:"Time Zone: ID"},X:{field:"tz",desc:"Time Zone: ISO8601 with Z"},x:{field:"tz",desc:"Time Zone: ISO8601"}},qe=s(e=>e>="A"&&e<="Z"||e>="a"&&e<="z","isLetter");function Ut(e,t){let r=e[t],a=1;for(;e[++t]===r;)++a;let n=Ct[r];if(!n){let l=`The letter ${r} is not a valid field identifier`;return{char:r,error:new Error(l),width:a}}return{char:r,field:n.field,desc:n.desc,width:a}}s(Ut,"readFieldToken");function Lt(e,t){let r=e[++t],a=2;if(r==="'")return{char:"'",str:r,width:a};for(;;){let n=e[++t];if(++a,n===void 0){let l=`Unterminated quoted literal in pattern: ${r||e}`;return{char:"'",error:new Error(l),str:r,width:a}}else if(n==="'"){if(e[++t]!=="'")return{char:"'",str:r,width:a};++a}r+=n}}s(Lt,"readQuotedToken");function xt(e,t){let r=e[t];if(!r)return null;if(qe(r))return Ut(e,t);if(r==="'")return Lt(e,t);let a=r,n=1;for(;;){let l=e[++t];if(!l||qe(l)||l==="'")return{char:r,str:a,width:n};a+=l,n+=1}}s(xt,"readToken");function te(e){let t=[],r=0;for(;;){let a=xt(e,r);if(!a)return t;t.push(a),r+=a.width}}s(te,"parseDateTokens");function Ve(e,t){return e.filter(r=>r.type!=="content").length?e.map(r=>{if(r.type==="content")return t(r.value);if(r.type==="octothorpe")return"#";if(r.type==="argument")return[r.arg];if(r.type==="function"){let l=r?.param?.[0];if(r.key==="date"&&l){let u=kt(l.value.trim(),g=>{throw new Error(`Unable to compile date expression: ${g.message}`)});return[r.arg,r.key,u]}return l?[r.arg,r.key,l.value.trim()]:[r.arg,r.key]}let a=r.pluralOffset,n={};return r.cases.forEach(({key:l,tokens:u})=>{let g=l[0]==="="?l.slice(1):l;n[g]=Ve(u,t)}),[r.arg,r.type,{offset:a,...n}]}):e.map(r=>t(r.value))}s(Ve,"processTokens");function kt(e,t){if(/^::/.test(e)){let r=te(e.substring(2));return ge(r,void 0,t)}return e}s(kt,"compileDateExpression");function Pt(e,t=r=>r){return Ve((0,je.parse)(e),t)}s(Pt,"compileMessageOrThrow");function We(e,t=r=>r){try{return Pt(e,t)}catch(r){return console.error(`${r.message}
24
+
25
+ Message: ${e}`),[e]}}s(We,"compileMessage");var C=s(e=>typeof e=="string","isString"),_e=s(e=>typeof e=="function","isFunction"),Ke=new Map,Qe="en";function we(e){return[...Array.isArray(e)?e:[e],Qe]}s(we,"normalizeLocales");function Oe(e,t,r){let a=we(e);r||(r="default");let n;if(typeof r=="string")switch(n={day:"numeric",month:"short",year:"numeric"},r){case"full":n.weekday="long";case"long":n.month="long";break;case"short":n.month="numeric";break}else n=r;return re(()=>ae("date",a,r),()=>new Intl.DateTimeFormat(a,n)).format(C(t)?new Date(t):t)}s(Oe,"date");function Mt(e,t,r){let a;if(r||(r="default"),typeof r=="string")switch(a={second:"numeric",minute:"numeric",hour:"numeric"},r){case"full":case"long":a.timeZoneName="short";break;case"short":delete a.second}else a=r;return Oe(e,t,a)}s(Mt,"time");function Ee(e,t,r){let a=we(e);return re(()=>ae("number",a,r),()=>new Intl.NumberFormat(a,r)).format(t)}s(Ee,"number");function $e(e,t,r,{offset:a=0,...n}){let l=we(e),u=t?re(()=>ae("plural-ordinal",l),()=>new Intl.PluralRules(l,{type:"ordinal"})):re(()=>ae("plural-cardinal",l),()=>new Intl.PluralRules(l,{type:"cardinal"}));return n[r]??n[u.select(r-a)]??n.other}s($e,"plural");function re(e,t){let r=e(),a=Ke.get(r);return a||(a=t(),Ke.set(r,a)),a}s(re,"getMemoized");function ae(e,t,r){let a=t.join("-");return`${e}-${a}-${JSON.stringify(r)}`}s(ae,"cacheKey");var ze=/\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/,Xe=s(e=>e.replace(/\\u([a-fA-F0-9]{4})|\\x([a-fA-F0-9]{2})/g,(t,r,a)=>{if(r){let n=parseInt(r,16);return String.fromCharCode(n)}else{let n=parseInt(a,16);return String.fromCharCode(n)}}),"decodeEscapeSequences"),Je="%__lingui_octothorpe__%",Ft=s((e,t,r={})=>{let a=t||e,n=s(u=>typeof u=="object"?u:r[u],"style"),l=s((u,g)=>{let w=Object.keys(r).length?n("number"):void 0,E=Ee(a,u,w);return g.replace(new RegExp(Je,"g"),E)},"replaceOctothorpe");return{plural:s((u,g)=>{let{offset:w=0}=g,E=$e(a,!1,u,g);return l(u-w,E)},"plural"),selectordinal:s((u,g)=>{let{offset:w=0}=g,E=$e(a,!0,u,g);return l(u-w,E)},"selectordinal"),select:Ht,number:s((u,g)=>Ee(a,u,n(g)||{style:g}),"number"),date:s((u,g)=>Oe(a,u,n(g)||g),"date"),time:s((u,g)=>Mt(a,u,n(g)||g),"time")}},"getDefaultFormats"),Ye=s((e,t)=>e&&Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0,"getOwnProperty"),Ht=s((e,t)=>(Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0)??t.other,"selectFormatter");function Bt(e,t,r){return(a={},n,l)=>{let u=Ft(t,r,n),g=s(I=>{let R=Ye(l,I);return Ye(a,I)??(_e(R)?R():R)},"getValue"),w=s((I,R=!1)=>Array.isArray(I)?I.reduce((P,M)=>{if(M==="#"&&R)return P+Je;if(C(M))return P+M;let[D,b,Q]=M,F={};b==="plural"||b==="selectordinal"||b==="select"?Object.entries(Q).forEach(([B,ie])=>{F[B]=w(ie,b==="plural"||b==="selectordinal")}):F=Q;let H;if(b){let B=u[b];H=B(g(D),F)}else H=g(D);return H==null?P:P+H},""):I,"formatMessage"),E=w(e);return C(E)&&ze.test(E)?Xe(E):C(E)?E:E?String(E):""}}s(Bt,"interpolate");var ye=class{static{s(this,"EventEmitter")}_events={};on(t,r){return this._events[t]??=new Set,this._events[t].add(r),()=>this.removeListener(t,r)}removeListener(t,r){let a=this._events[t];a?.delete(r),a?.size===0&&delete this._events[t]}emit(t,...r){let a=this._events[t];if(a)for(let n of[...a])n.apply(this,r)}},Te=class extends ye{static{s(this,"I18n")}_locale="";_locales;_messages=Object.create(null);_variables={};_missing;_messageCompiler;constructor(t){super(),t.missing!=null&&(this._missing=t.missing),t.messages!=null&&this.load(t.messages),t.variables!=null&&(this._variables={...t.variables}),(typeof t.locale=="string"||t.locales)&&this.activate(t.locale??Qe,t.locales)}get locale(){return this._locale}get locales(){return this._locales}get messages(){return this._messages[this._locale]??{}}get variables(){return this._variables}setVariable(t,r){return r===void 0?delete this._variables[t]:this._variables[t]=r,this.emit("change"),this}setVariables(t){return this._variables={..._e(t)?t(this._variables):t},this.emit("change"),this}setMessagesCompiler(t){return this._messageCompiler=t,this}_load(t,r){let a=Object.prototype.hasOwnProperty.call(this._messages,t)?this._messages[t]:void 0;a?Object.assign(a,r):this._messages[t]=r}load(t,r){typeof t=="string"&&typeof r=="object"?this._load(t,r):Object.entries(t).forEach(([a,n])=>this._load(a,n)),this.emit("change")}loadAndActivate({locale:t,locales:r,messages:a}){this._locale=t,this._locales=r||void 0,this._messages[this._locale]=a,this.emit("change")}activate(t,r){this._locale=t,this._locales=r,this.emit("change")}_(t,r,a){if(!this.locale)throw new Error("Lingui: Attempted to call a translation function without setting a locale.\nMake sure to call `i18n.activate(locale)` before using Lingui functions.\nThis issue may also occur due to a race condition in your initialization logic.");let n=a?.message;t||(t=""),C(t)||(r=t.values||r,n=t.message,t=t.id);let l=this.messages,u=Object.prototype.hasOwnProperty.call(l,t)?l[t]:void 0,g=u===void 0,w=this._missing;if(w&&g)return _e(w)?w(this._locale,t):w;g&&this.emit("missing",{id:t,locale:this._locale});let E=u||n||t;return C(E)&&(this._messageCompiler?E=this._messageCompiler(E):console.warn(`Uncompiled message detected! Message:
26
+
27
+ > ${E}
28
+
29
+ That means you use raw catalog or your catalog doesn't have a translation for the message and fallback was used.
30
+ ICU features such as interpolation and plurals will not work properly for that message.
31
+
32
+ Please compile your catalog first.
33
+ `)),C(E)&&ze.test(E)?Xe(E):C(E)?E:Bt(E,this._locale,this._locales)(r,a?.formats,this._variables)}t=this._.bind(this);date(t,r){return Oe(this._locales||this._locale,t,r)}number(t,r){return Ee(this._locales||this._locale,t,r)}};function Ie(e={}){return new Te(e)}s(Ie,"setupI18n");var Xr=Ie();var se=Ae(st(),1);var Gt={},Ze="en",qt={en:Gt},V=new Map,jt=1e4,Vt=s(e=>{let t=V.get(e);return t===void 0?(t=We(e),V.size>=jt&&V.delete(V.keys().next().value)):V.delete(e),V.set(e,t),t},"I"),Wt=s((e=Ze,t=qt)=>{let r=Ie();r.setMessagesCompiler(Vt);for(let[a,n]of Object.entries(t))r.load(a,n);return r.activate(t[e]===void 0?Ze:e),r},"M"),Kt=Wt(),$t=(0,se.createContext)(Kt),ra=s(()=>{let e=(0,se.use)($t);return(t,r)=>e._(t,r)},"S");export{le as a,ce as b,dt as c,ht as d,ut as e,ct as f,ur as g,cr as h,dr as i,hr as j,mt as k,fr as l,pr as m,mr as n,xe as o,gt as p,gr as q,_r as r,_t as s,Et as t,Er as u,yr as v,Tr as w,br as x,Wt as y,Kt as z,$t as A,ra as B};