@lunora/studio 1.0.0-alpha.12 → 1.0.0-alpha.120

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 (326) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.ts +836 -786
  3. package/dist/index.js +1 -41
  4. package/dist/mount.d.ts +10 -10
  5. package/dist/mount.js +1 -26
  6. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -0
  7. package/dist/packem_chunks/ApiTab.js +1 -0
  8. package/dist/packem_chunks/AuditPanel.js +1 -0
  9. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
  10. package/dist/packem_chunks/ExportImportPanel.js +3 -0
  11. package/dist/packem_chunks/FileBrowser.js +4 -0
  12. package/dist/packem_chunks/FunctionRunner.js +1 -0
  13. package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
  14. package/dist/packem_chunks/HealthPanel.js +1 -0
  15. package/dist/packem_chunks/InsightsPanel.js +1 -0
  16. package/dist/packem_chunks/LogsPanel.js +1 -0
  17. package/dist/packem_chunks/MailPanel.js +2 -0
  18. package/dist/packem_chunks/MetricsPanel.js +1 -0
  19. package/dist/packem_chunks/NotificationsPanel.js +1 -0
  20. package/dist/packem_chunks/PitrPanel.js +1 -0
  21. package/dist/packem_chunks/SchemaViewer.js +1 -0
  22. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -0
  23. package/dist/packem_chunks/SettingsPanel.js +1 -0
  24. package/dist/packem_chunks/SqlEditorPanel.js +9 -0
  25. package/dist/packem_chunks/TableEditor.js +1 -0
  26. package/dist/packem_chunks/agents-panel.js +1 -0
  27. package/dist/packem_chunks/analytics-panel.js +1 -0
  28. package/dist/packem_chunks/auth-audit-panel.js +1 -0
  29. package/dist/packem_chunks/auth-config-panel.js +1 -0
  30. package/dist/packem_chunks/auth-sessions-panel.js +1 -0
  31. package/dist/packem_chunks/containers-panel.js +1 -0
  32. package/dist/packem_chunks/dashboards-panel.js +1 -0
  33. package/dist/packem_chunks/evals-panel.js +1 -0
  34. package/dist/packem_chunks/fanout-panel.js +1 -0
  35. package/dist/packem_chunks/flags-panel.js +1 -0
  36. package/dist/packem_chunks/issues-panel.js +1 -0
  37. package/dist/packem_chunks/kv-browser.js +1 -0
  38. package/dist/packem_chunks/log-drains-panel.js +4 -0
  39. package/dist/packem_chunks/migrations-route.js +1 -0
  40. package/dist/packem_chunks/organizations-panel.js +1 -0
  41. package/dist/packem_chunks/payments-panel.js +1 -0
  42. package/dist/packem_chunks/permissions-panel.js +1 -0
  43. package/dist/packem_chunks/queues-panel.js +1 -0
  44. package/dist/packem_chunks/reactors-panel.js +1 -0
  45. package/dist/packem_chunks/rls-panel.js +1 -0
  46. package/dist/packem_chunks/schedule-panel.js +1 -0
  47. package/dist/packem_chunks/sparkline.js +1 -0
  48. package/dist/packem_chunks/storage-rules-panel.js +1 -0
  49. package/dist/packem_chunks/subscriptions-panel.js +1 -0
  50. package/dist/packem_chunks/sync-client-panel.js +1 -0
  51. package/dist/packem_chunks/traces-panel.js +1 -0
  52. package/dist/packem_chunks/users-panel.js +1 -0
  53. package/dist/packem_chunks/vector-browser.js +1 -0
  54. package/dist/packem_chunks/workflows-panel.js +1 -0
  55. package/dist/packem_shared/ADMIN_FUNCTIONS-B6z7VLYt.js +1 -0
  56. package/dist/packem_shared/ApiDocsPanel-BMzLPgvv.js +2 -0
  57. package/dist/packem_shared/ApiReferencePanel-DXrGI45U.js +1 -0
  58. package/dist/packem_shared/CommandPalette-kQLn0xlS.js +1 -0
  59. package/dist/packem_shared/ConfirmButton-Cj2SOapE.js +1 -0
  60. package/dist/packem_shared/ConnectionBadge-Bh16X9-u.js +1 -0
  61. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js +1 -0
  62. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-1Lrg55IV.js +1 -0
  63. package/dist/packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js +1 -0
  64. package/dist/packem_shared/DataBrowser-C68K5QHO.js +4 -0
  65. package/dist/packem_shared/DataFilters-3nbW0uax.js +1 -0
  66. package/dist/packem_shared/ErrorBoundary-BWNF98VF.js +1 -0
  67. package/dist/packem_shared/GlobalDataBrowser-BHFgEqMl.js +1 -0
  68. package/dist/packem_shared/HomePanel-B-tcMcTZ.js +1 -0
  69. package/dist/packem_shared/MigrationsPanel-CLRWwPyL.js +1 -0
  70. package/dist/packem_shared/OpenRpcReferencePanel-DkYBLJGb.js +1 -0
  71. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
  72. package/dist/packem_shared/ScheduledJobs-DRmOKtDa.js +1 -0
  73. package/dist/packem_shared/ShardInput-CdawpUiS.js +1 -0
  74. package/dist/packem_shared/Studio-BYdUxnM5.js +1 -0
  75. package/dist/packem_shared/StudioApp-Bxmtp-Fi.js +1 -0
  76. package/dist/packem_shared/StudioI18nProvider-Bl547evf.js +1 -0
  77. package/dist/packem_shared/advisor-view-CqCG22DB.js +1 -0
  78. package/dist/packem_shared/aggregateMetrics-A-Y7OH6R.js +1 -0
  79. package/dist/packem_shared/alert-C2SEhYS9.js +1 -0
  80. package/dist/packem_shared/app.d-D1bPR8FO.d.ts +252 -0
  81. package/dist/packem_shared/badge-cAk9Di1Q.js +1 -0
  82. package/dist/packem_shared/bar-chart-B6gzp_f9.js +6 -0
  83. package/dist/packem_shared/browser-storage-BH1MxLZs.js +1 -0
  84. package/dist/packem_shared/button-BOPLD1un.js +1 -0
  85. package/dist/packem_shared/card-BGlQzQY-.js +1 -0
  86. package/dist/packem_shared/cf-links-CBJ5SywP.js +1 -0
  87. package/dist/packem_shared/checkbox-C5w53W-E.js +1 -0
  88. package/dist/packem_shared/data-grid-pjv4t5Yi.js +1 -0
  89. package/dist/packem_shared/data-view-params-qoSTqjAj.js +1 -0
  90. package/dist/packem_shared/dropdown-menu-U7Tjg1Nb.js +2 -0
  91. package/dist/packem_shared/empty-state-B939z6K2.js +1 -0
  92. package/dist/packem_shared/error-alert-CKqB2CiN.js +1 -0
  93. package/dist/packem_shared/grid-features-AzpmpR3Q.js +6 -0
  94. package/dist/packem_shared/home-panel-ecz6-nHV.js +3 -0
  95. package/dist/packem_shared/input-CY5W3wzv.js +1 -0
  96. package/dist/packem_shared/internal-7bgd8inO.js +2 -0
  97. package/dist/packem_shared/label-BOUo-DP0.js +1 -0
  98. package/dist/packem_shared/live-status-Bf7rR8o8.js +1 -0
  99. package/dist/packem_shared/log-fields-SBxKyBug.js +1 -0
  100. package/dist/packem_shared/log-line-D0XBZaDn.js +1 -0
  101. package/dist/packem_shared/modal-shell-wGW4CKEW.js +1 -0
  102. package/dist/packem_shared/operation-console-provider-DoloEvon.js +1 -0
  103. package/dist/packem_shared/recording-client-BPY8sYUl.js +1 -0
  104. package/dist/packem_shared/reference-view-CxW7paCK.js +12 -0
  105. package/dist/packem_shared/schema-diagram-DLhppqVE.js +2 -0
  106. package/dist/packem_shared/scroll-area-DSJftwu_.js +2 -0
  107. package/dist/packem_shared/select-BPISLTcv.js +2 -0
  108. package/dist/packem_shared/shard-history-DU5b3QDI.js +1 -0
  109. package/dist/packem_shared/shortcuts-lH4Vaqjc.js +1 -0
  110. package/dist/packem_shared/skeleton-DFBBaJU6.js +1 -0
  111. package/dist/packem_shared/sparkline-CYbJzfA1.js +1 -0
  112. package/dist/packem_shared/sql-result-table-blxdNVJ0.js +1 -0
  113. package/dist/packem_shared/stat-card-B9uIvAHg.js +1 -0
  114. package/dist/packem_shared/storage-tier-C2mKwYRj.js +1 -0
  115. package/dist/packem_shared/studio-Cvdwfzxm.js +2 -0
  116. package/dist/packem_shared/table-BMsuYFhk.js +2 -0
  117. package/dist/packem_shared/table-list-sidebar-BCxqrZ0s.js +1 -0
  118. package/dist/packem_shared/textarea-DpO3i-Qo.js +1 -0
  119. package/dist/packem_shared/trace-handoff-z9sy89Ci.js +1 -0
  120. package/dist/packem_shared/use-admin-query-DV9xmFl8.js +1 -0
  121. package/dist/packem_shared/use-async-submit-C9xXjXWX.js +1 -0
  122. package/dist/packem_shared/use-auth-config-DIAyVsa3.js +1 -0
  123. package/dist/packem_shared/use-open-trace-ClAdPkGD.js +1 -0
  124. package/dist/packem_shared/use-shard-key-BsP3o5wT.js +1 -0
  125. package/dist/packem_shared/use-sql-assistant-CXgVX_PP.js +1 -0
  126. package/dist/packem_shared/useDebounced-DVeQ5-oW.js +1 -0
  127. package/dist/packem_shared/utils-bhneXptQ.js +1 -0
  128. package/dist/packem_shared/virtual-rect-D_j7aLxX.js +1 -0
  129. package/dist/packem_shared/wire-codec-Dl3VeNrd.js +1 -0
  130. package/dist/standalone/chunk-27IF4PXG.js +1 -0
  131. package/dist/standalone/chunk-2EJQ7SPV.js +1 -0
  132. package/dist/standalone/chunk-2F6FYL5O.js +1 -0
  133. package/dist/standalone/chunk-2QLWSNDL.js +1 -0
  134. package/dist/standalone/chunk-2RASQG3R.js +1 -0
  135. package/dist/standalone/chunk-2SFSTQS4.js +1 -0
  136. package/dist/standalone/chunk-2VLBFSIX.js +1 -0
  137. package/dist/standalone/chunk-4DJQV5UA.js +1 -0
  138. package/dist/standalone/chunk-4LVLLM6B.js +4 -0
  139. package/dist/standalone/chunk-4PVSXT34.js +1 -0
  140. package/dist/standalone/chunk-4Y2QHI65.js +1 -0
  141. package/dist/standalone/chunk-4YTSKL4R.js +1 -0
  142. package/dist/standalone/chunk-57VX76PR.js +1 -0
  143. package/dist/standalone/chunk-5COHJLQF.js +1 -0
  144. package/dist/standalone/chunk-5HICO276.js +1 -0
  145. package/dist/standalone/chunk-5JF2HAU4.js +1 -0
  146. package/dist/standalone/chunk-5JLIP2HH.js +1 -0
  147. package/dist/standalone/chunk-5QAT5NQ4.js +1 -0
  148. package/dist/standalone/chunk-5XMZP64Z.js +1 -0
  149. package/dist/standalone/chunk-6AJONHNM.js +1 -0
  150. package/dist/standalone/chunk-6J5TEYI5.js +3 -0
  151. package/dist/standalone/chunk-6KJLNWPJ.js +1 -0
  152. package/dist/standalone/chunk-6QKKYBML.js +1 -0
  153. package/dist/standalone/chunk-6UN4V2HB.js +1 -0
  154. package/dist/standalone/chunk-74ASA4WU.js +1 -0
  155. package/dist/standalone/chunk-7CVIN6KU.js +6 -0
  156. package/dist/standalone/chunk-7PIHTTND.js +1 -0
  157. package/dist/standalone/chunk-7SROZWKL.js +1 -0
  158. package/dist/standalone/chunk-A44VDLY3.js +1 -0
  159. package/dist/standalone/chunk-AFKLFS74.js +1 -0
  160. package/dist/standalone/chunk-AOAJGSYZ.js +2 -0
  161. package/dist/standalone/chunk-ATGYWQUI.js +1 -0
  162. package/dist/standalone/chunk-B3BKR5ZW.js +1 -0
  163. package/dist/standalone/chunk-BKM6PMSO.js +19 -0
  164. package/dist/standalone/chunk-BKW7FMAU.js +2 -0
  165. package/dist/standalone/chunk-BQK2C2Z4.js +1 -0
  166. package/dist/standalone/chunk-BWEXJENB.js +1 -0
  167. package/dist/standalone/chunk-BYJZGWWY.js +1 -0
  168. package/dist/standalone/chunk-CAOUXOL7.js +1 -0
  169. package/dist/standalone/chunk-CKTKI4IY.js +1 -0
  170. package/dist/standalone/chunk-CN2AINNY.js +1 -0
  171. package/dist/standalone/chunk-CP4ZFBVW.js +1 -0
  172. package/dist/standalone/chunk-CYX3OHJ3.js +1 -0
  173. package/dist/standalone/chunk-D3ZLKFO4.js +1 -0
  174. package/dist/standalone/chunk-D52S7TOI.js +1 -0
  175. package/dist/standalone/chunk-DKSLOJDQ.js +1 -0
  176. package/dist/standalone/chunk-DPNEFSEC.js +1 -0
  177. package/dist/standalone/chunk-DUDQV6XJ.js +1 -0
  178. package/dist/standalone/chunk-DYKGLIBC.js +1 -0
  179. package/dist/standalone/chunk-DZGOHOOE.js +1 -0
  180. package/dist/standalone/chunk-E6P2ERQV.js +1 -0
  181. package/dist/standalone/chunk-EDHW2EEG.js +1 -0
  182. package/dist/standalone/chunk-EYGF6TQS.js +1 -0
  183. package/dist/standalone/chunk-F7JOSNAT.js +1 -0
  184. package/dist/standalone/chunk-FJ6G6FNE.js +1 -0
  185. package/dist/standalone/chunk-G3NGXYJY.js +1 -0
  186. package/dist/standalone/chunk-GK2UBSBQ.js +1 -0
  187. package/dist/standalone/chunk-GTEXP4P3.js +1 -0
  188. package/dist/standalone/chunk-INQICZYC.js +1 -0
  189. package/dist/standalone/chunk-IYWVSMAY.js +1 -0
  190. package/dist/standalone/chunk-J2GQE4PW.js +1 -0
  191. package/dist/standalone/chunk-JIPVSPSG.js +1 -0
  192. package/dist/standalone/chunk-JUWOEHDD.js +1 -0
  193. package/dist/standalone/chunk-JV7KTJPY.js +1 -0
  194. package/dist/standalone/chunk-KPQROFH5.js +1 -0
  195. package/dist/standalone/chunk-KVSQKUWD.js +1 -0
  196. package/dist/standalone/chunk-KWGHNORP.js +1 -0
  197. package/dist/standalone/chunk-L4EZAHCD.js +1 -0
  198. package/dist/standalone/chunk-L6ATKZKO.js +1 -0
  199. package/dist/standalone/chunk-M3NNNOD5.js +1 -0
  200. package/dist/standalone/chunk-MCLM2QJI.js +1 -0
  201. package/dist/standalone/chunk-METRMDIQ.js +1 -0
  202. package/dist/standalone/chunk-MG7VPUFA.js +1 -0
  203. package/dist/standalone/chunk-MLYZZD5C.js +4 -0
  204. package/dist/standalone/chunk-NIX2QSSN.js +1 -0
  205. package/dist/standalone/chunk-NXXGISFB.js +1 -0
  206. package/dist/standalone/chunk-P4QIDUCY.js +1 -0
  207. package/dist/standalone/chunk-P54YTPHL.js +1 -0
  208. package/dist/standalone/chunk-PRWFHSHC.js +1 -0
  209. package/dist/standalone/chunk-PS66CRK5.js +9 -0
  210. package/dist/standalone/chunk-PZ4QDWTI.js +1 -0
  211. package/dist/standalone/chunk-QDGAB4R2.js +1 -0
  212. package/dist/standalone/chunk-QKN5EHEF.js +1 -0
  213. package/dist/standalone/chunk-QLG2EJU3.js +1 -0
  214. package/dist/standalone/chunk-QXLU6YPU.js +1 -0
  215. package/dist/standalone/chunk-R3G55P4J.js +1 -0
  216. package/dist/standalone/chunk-R52YOHVU.js +1 -0
  217. package/dist/standalone/chunk-R5ZTCHCE.js +1 -0
  218. package/dist/standalone/chunk-RCZTUWG3.js +1 -0
  219. package/dist/standalone/chunk-RK5XWYUL.js +1 -0
  220. package/dist/standalone/chunk-RSG2DVHH.js +1 -0
  221. package/dist/standalone/chunk-SPDZUX4P.js +1 -0
  222. package/dist/standalone/chunk-T5SC5RAD.js +1 -0
  223. package/dist/standalone/chunk-T7DJP5HM.js +1 -0
  224. package/dist/standalone/chunk-TCKQ4E5Y.js +1 -0
  225. package/dist/standalone/chunk-TFMQSCGC.js +1 -0
  226. package/dist/standalone/chunk-TNKECJW4.js +1 -0
  227. package/dist/standalone/chunk-TPAZM36C.js +1 -0
  228. package/dist/standalone/chunk-UANVABQG.js +1 -0
  229. package/dist/standalone/chunk-UBT2FIU5.js +8 -0
  230. package/dist/standalone/chunk-VDSFYFDH.js +1 -0
  231. package/dist/standalone/chunk-VR3UJA7B.js +1 -0
  232. package/dist/standalone/chunk-VYW2PAWC.js +15 -0
  233. package/dist/standalone/chunk-VZCS5GXZ.js +1 -0
  234. package/dist/standalone/chunk-W2JBKQNU.js +1 -0
  235. package/dist/standalone/chunk-W3PCX3TU.js +1 -0
  236. package/dist/standalone/chunk-WFABZPAK.js +1 -0
  237. package/dist/standalone/chunk-WIFYD4A6.js +1 -0
  238. package/dist/standalone/chunk-WUW4ZHRL.js +1 -0
  239. package/dist/standalone/chunk-WYSR5F77.js +1 -0
  240. package/dist/standalone/chunk-XFU6YBYL.js +1 -0
  241. package/dist/standalone/chunk-XJSWM47N.js +1 -0
  242. package/dist/standalone/chunk-XL2OT5WB.js +59 -0
  243. package/dist/standalone/chunk-XOA5TTRA.js +1 -0
  244. package/dist/standalone/chunk-XQS7KSHL.js +1 -0
  245. package/dist/standalone/chunk-XRC7KEEN.js +3 -0
  246. package/dist/standalone/chunk-XTNSQYXW.js +13 -0
  247. package/dist/standalone/chunk-XUX7B54Z.js +1 -0
  248. package/dist/standalone/chunk-YMVKAXBC.js +1 -0
  249. package/dist/standalone/chunk-YN2KHW3B.js +7 -0
  250. package/dist/standalone/chunk-YTYRZTG6.js +11 -0
  251. package/dist/standalone/chunk-ZHPDAJBM.js +1 -0
  252. package/dist/standalone/chunk-ZPGNTTQ3.js +1 -0
  253. package/dist/standalone/chunk-ZSOLGJFC.js +1 -0
  254. package/dist/standalone/studio.js +9 -378
  255. package/dist/styles.css +2 -2
  256. package/package.json +16 -15
  257. package/dist/packem_shared/ADMIN_FUNCTIONS-CZJCZ4c7.js +0 -47
  258. package/dist/packem_shared/ApiDocsPanel-yEz0fiof.js +0 -842
  259. package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
  260. package/dist/packem_shared/ApiTab-DdubReQI.js +0 -251
  261. package/dist/packem_shared/AuditPanel-CE5ofjCc.js +0 -200
  262. package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
  263. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  264. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  265. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  266. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  267. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  268. package/dist/packem_shared/DataBrowser-DpL8U-Nf.js +0 -4475
  269. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  270. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  271. package/dist/packem_shared/ExportImportPanel-ChsSUCYZ.js +0 -197
  272. package/dist/packem_shared/FileBrowser-DsRBnVhZ.js +0 -2932
  273. package/dist/packem_shared/FunctionRunner-D4cZ6fuA.js +0 -343
  274. package/dist/packem_shared/FunctionStatsPanel-BVelWgNv.js +0 -375
  275. package/dist/packem_shared/GlobalDataBrowser-3X9uRfdO.js +0 -289
  276. package/dist/packem_shared/HealthPanel-CxUVKfvo.js +0 -648
  277. package/dist/packem_shared/HomePanel-tfqpZxuu.js +0 -1334
  278. package/dist/packem_shared/InsightsPanel-DNg3K9XN.js +0 -461
  279. package/dist/packem_shared/LogsPanel-B4LoSRj0.js +0 -827
  280. package/dist/packem_shared/MailPanel-CcpdyWYs.js +0 -440
  281. package/dist/packem_shared/MetricsPanel-CxoyWbNb.js +0 -1611
  282. package/dist/packem_shared/MigrationsPanel-DGwJGWDA.js +0 -239
  283. package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
  284. package/dist/packem_shared/PitrPanel-CKUzyyHi.js +0 -252
  285. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  286. package/dist/packem_shared/ScheduledJobs-BWNwIN3I.js +0 -262
  287. package/dist/packem_shared/SchemaViewer-RclXFo9Q.js +0 -2512
  288. package/dist/packem_shared/SecurityAdvisorPanel-Dqql1Z5O.js +0 -92
  289. package/dist/packem_shared/SettingsPanel-D5iTY0YE.js +0 -390
  290. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  291. package/dist/packem_shared/SqlEditorPanel-Dj-In-B3.js +0 -13
  292. package/dist/packem_shared/Studio-VWvKNOw4.js +0 -33
  293. package/dist/packem_shared/StudioApp-BhQ6T2pn.js +0 -657
  294. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  295. package/dist/packem_shared/TableEditor-BY8bTpCl.js +0 -11
  296. package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
  297. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  298. package/dist/packem_shared/app.d-BVJFkXyj.d.ts +0 -300
  299. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  300. package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
  301. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  302. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  303. package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
  304. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  305. package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
  306. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  307. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  308. package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
  309. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  310. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  311. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  312. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  313. package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
  314. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  315. package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
  316. package/dist/packem_shared/sql-editor-panel-CMdxstu5.js +0 -2562
  317. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  318. package/dist/packem_shared/studio-D8ry3tJR.js +0 -11043
  319. package/dist/packem_shared/table-_RzNvy3R.js +0 -246
  320. package/dist/packem_shared/table-editor-CWx68ZCg.js +0 -407
  321. package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
  322. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  323. package/dist/packem_shared/use-admin-query-BkbdNFNz.js +0 -105
  324. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  325. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  326. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
@@ -0,0 +1,11 @@
1
+ import{c as p}from"./chunk-VYW2PAWC.js";import{a,d as P,e as H,f as mt,g as Ue}from"./chunk-R5ZTCHCE.js";var L=class{static{a(this,"Subscribable")}constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var gr=class extends L{static{a(this,"FocusManager")}#e;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(),"listener");return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){let t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},X=new gr;var vr={setTimeout:a((t,e)=>setTimeout(t,e),"setTimeout"),clearTimeout:a(t=>clearTimeout(t),"clearTimeout"),setInterval:a((t,e)=>setInterval(t,e),"setInterval"),clearInterval:a(t=>clearInterval(t),"clearInterval")},Sr=class{static{a(this,"TimeoutManager")}#e=vr;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},Q=new Sr;function yt(t){setTimeout(t,0)}a(yt,"systemSetTimeoutZero");var Ne=typeof window>"u"||"Deno"in globalThis;function v(){}a(v,"noop");function vt(t,e){return typeof t=="function"?t(e):t}a(vt,"functionalUpdate");function ie(t){return typeof t=="number"&&t>=0&&t!==1/0}a(ie,"isValidTimeout");function me(t,e){return Math.max(t+(e||0)-Date.now(),0)}a(me,"timeUntilStale");function x(t,e){return typeof t=="function"?t(e):t}a(x,"resolveStaleTime");function I(t,e){return typeof t=="function"?t(e):t}a(I,"resolveQueryBoolean");function ye(t,e){let{type:r="all",exact:s,fetchStatus:i,predicate:n,queryKey:o,stale:c}=t;if(o){if(s){if(e.queryHash!==ne(o,e.options))return!1}else if(!N(e.queryKey,o))return!1}if(r!=="all"){let u=e.isActive();if(r==="active"&&!u||r==="inactive"&&u)return!1}return!(typeof c=="boolean"&&e.isStale()!==c||i&&i!==e.state.fetchStatus||n&&!n(e))}a(ye,"matchQuery");function be(t,e){let{exact:r,status:s,predicate:i,mutationKey:n}=t;if(n){if(!e.options.mutationKey)return!1;if(r){if(z(e.options.mutationKey)!==z(n))return!1}else if(!N(e.options.mutationKey,n))return!1}return!(s&&e.state.status!==s||i&&!i(e))}a(be,"matchMutation");function ne(t,e){return(e?.queryKeyHashFn||z)(t)}a(ne,"hashQueryKeyByOptions");function z(t){return JSON.stringify(t,(e,r)=>qe(r)?Object.keys(r).sort().reduce((s,i)=>(s[i]=r[i],s),{}):r)}a(z,"hashKey");function N(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(Array.isArray(t)&&Array.isArray(e)){for(let s=0;s<e.length;s++)if(!N(t[s],e[s]))return!1;return!0}let r=Object.keys(e);for(let s of r)if(!N(t[s],e[s]))return!1;return!0}return!1}a(N,"partialMatchKey");var wr=Object.prototype.hasOwnProperty;function Ke(t,e,r=0){if(t===e)return t;if(r>500)return e;let s=bt(t)&&bt(e);if(!s&&!(qe(t)&&qe(e)))return e;let n=(s?t:Object.keys(t)).length,o=s?e:Object.keys(e),c=o.length,u=s?new Array(c):{},h=0;for(let d=0;d<c;d++){let l=s?d:o[d],f=t[l],m=e[l];if(f===m){u[l]=f,(s?d<n:wr.call(t,l))&&h++;continue}if(f===null||m===null||typeof f!="object"||typeof m!="object"){u[l]=m;continue}let y=Ke(f,m,r+1);u[l]=y,y===f&&h++}return n===c&&h===n?t:u}a(Ke,"replaceEqualDeep");function ge(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}a(ge,"shallowEqualObjects");function bt(t){return Array.isArray(t)&&t.length===Object.keys(t).length}a(bt,"isPlainArray");function qe(t){if(!gt(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!gt(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}a(qe,"isPlainObject");function gt(t){return Object.prototype.toString.call(t)==="[object Object]"}a(gt,"hasObjectPrototype");function St(t){return new Promise(e=>{Q.setTimeout(e,t)})}a(St,"sleep");function ae(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Ke(t,e):e}a(ae,"replaceData");function Cr(t){return t}a(Cr,"keepPreviousData");function wt(t,e,r=0){let s=[...t,e];return r&&s.length>r?s.slice(1):s}a(wt,"addToEnd");function Ct(t,e,r=0){let s=[e,...t];return r&&s.length>r?s.slice(0,-1):s}a(Ct,"addToStart");var Y=Symbol();function ve(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Y?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}a(ve,"ensureQueryFn");function Se(t,e){return typeof t=="function"?t(...e):!!t}a(Se,"shouldThrowError");function kt(t,e,r){let s=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:a(()=>(i??=e(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i),"get")}),t}a(kt,"addConsumeAwareSignal");var D=(()=>{let t=a(()=>Ne,"isServerFn");return{isServer(){return t()},setIsServer(e){t=e}}})();function oe(){let t,e,r=new Promise((i,n)=>{t=i,e=n});r.status="pending",r.catch(()=>{});function s(i){Object.assign(r,i),delete r.resolve,delete r.reject}return a(s,"finalize"),r.resolve=i=>{s({status:"fulfilled",value:i}),t(i)},r.reject=i=>{s({status:"rejected",reason:i}),e(i)},r}a(oe,"pendingThenable");var It=yt;function kr(){let t=[],e=0,r=a(c=>{c()},"notifyFn"),s=a(c=>{c()},"batchNotifyFn"),i=It,n=a(c=>{e?t.push(c):i(()=>{r(c)})},"schedule"),o=a(()=>{let c=t;t=[],c.length&&i(()=>{s(()=>{c.forEach(u=>{r(u)})})})},"flush");return{batch:a(c=>{let u;e++;try{u=c()}finally{e--,e||o()}return u},"batch"),batchCalls:a(c=>(...u)=>{n(()=>{c(...u)})},"batchCalls"),schedule:n,setNotifyFunction:a(c=>{r=c},"setNotifyFunction"),setBatchNotifyFunction:a(c=>{s=c},"setBatchNotifyFunction"),setScheduler:a(c=>{i=c},"setScheduler")}}a(kr,"createNotifyManager");var g=kr();var Ir=class extends L{static{a(this,"OnlineManager")}#e=!0;#t;#r;constructor(){super(),this.#r=t=>{if(typeof window<"u"&&window.addEventListener){let e=a(()=>t(!0),"onlineListener"),r=a(()=>t(!1),"offlineListener");return window.addEventListener("online",e,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#r=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(r=>{r(t)}))}isOnline(){return this.#e}},Z=new Ir;function Er(t){return Math.min(1e3*2**t,3e4)}a(Er,"defaultRetryDelay");function Be(t){return(t??"online")==="online"?Z.isOnline():!0}a(Be,"canFetch");var we=class extends Error{static{a(this,"CancelledError")}constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Ce(t){let e=!1,r=0,s,i=oe(),n=a(()=>i.status!=="pending","isResolved"),o=a(b=>{if(!n()){let w=new we(b);f(w),t.onCancel?.(w)}},"cancel"),c=a(()=>{e=!0},"cancelRetry"),u=a(()=>{e=!1},"continueRetry"),h=a(()=>X.isFocused()&&(t.networkMode==="always"||Z.isOnline())&&t.canRun(),"canContinue"),d=a(()=>Be(t.networkMode)&&t.canRun(),"canStart"),l=a(b=>{n()||(s?.(),i.resolve(b))},"resolve"),f=a(b=>{n()||(s?.(),i.reject(b))},"reject"),m=a(()=>new Promise(b=>{s=a(w=>{(n()||h())&&b(w)},"continueFn"),t.onPause?.()}).then(()=>{s=void 0,n()||t.onContinue?.()}),"pause"),y=a(()=>{if(n())return;let b,w=r===0?t.initialPromise:void 0;try{b=w??t.fn()}catch(E){b=Promise.reject(E)}Promise.resolve(b).then(l).catch(E=>{if(n())return;let M=t.retry??(D.isServer()?0:3),U=t.retryDelay??Er,j=typeof U=="function"?U(r,E):U,$=M===!0||typeof M=="number"&&r<M||typeof M=="function"&&M(r,E);if(e||!$){f(E);return}r++,t.onFail?.(r,E),St(j).then(()=>h()?void 0:m()).then(()=>{e?f(E):y()})})},"run");return{promise:i,status:a(()=>i.status,"status"),cancel:o,continue:a(()=>(s?.(),i),"continue"),cancelRetry:c,continueRetry:u,canStart:d,start:a(()=>(d()?y():m().then(y),i),"start")}}a(Ce,"createRetryer");var ke=class{static{a(this,"Removable")}#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ie(this.gcTime)&&(this.#e=Q.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(D.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Q.clearTimeout(this.#e),this.#e=void 0)}};function Tt(t){return{onFetch:a((e,r)=>{let s=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,n=e.state.data?.pages||[],o=e.state.data?.pageParams||[],c={pages:[],pageParams:[]},u=0,h=a(async()=>{let d=!1,l=a(y=>{kt(y,()=>e.signal,()=>d=!0)},"addSignalProperty"),f=ve(e.options,e.fetchOptions),m=a(async(y,b,w)=>{if(d)return Promise.reject(e.signal.reason);if(b==null&&y.pages.length)return Promise.resolve(y);let M=a(()=>{let De={client:e.client,queryKey:e.queryKey,pageParam:b,direction:w?"backward":"forward",meta:e.options.meta};return l(De),De},"createQueryFnContext")(),U=await f(M),{maxPages:j}=e.options,$=w?Ct:wt;return{pages:$(y.pages,U,j),pageParams:$(y.pageParams,b,j)}},"fetchPage");if(i&&n.length){let y=i==="backward",b=y?Tr:Et,w={pages:n,pageParams:o},E=b(s,w);c=await m(w,E,y)}else{let y=t??n.length;do{let b=u===0?o[0]??s.initialPageParam:Et(s,c);if(u>0&&b==null)break;c=await m(c,b),u++}while(u<y)}return c},"fetchFn");e.options.persister?e.fetchFn=()=>e.options.persister?.(h,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=h},"onFetch")}}a(Tt,"infiniteQueryBehavior");function Et(t,{pages:e,pageParams:r}){let s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,r[s],r):void 0}a(Et,"getNextPageParam");function Tr(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}a(Tr,"getPreviousPageParam");var Pt=class extends ke{static{a(this,"Query")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t){super(),this.#a=!1,this.#o=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#n=t.client,this.#s=this.#n.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=Rt(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(t){if(this.options={...this.#o,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Rt(this.options);e.data!==void 0&&(this.setState(Ot(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(t,e){let r=ae(this.state.data,t,this.options);return this.#c({data:r,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),r}setState(t){this.#c({type:"setState",state:t})}cancel(t){let e=this.#i?.promise;return this.#i?.cancel(t),e?e.then(v).catch(v):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>I(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Y||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>x(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!me(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#i&&(this.#a||this.#h()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#h(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#c({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(t&&this.setOptions(t),!this.options.queryFn){let u=this.observers.find(h=>h.options.queryFn);u&&this.setOptions(u.options)}let r=new AbortController,s=a(u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:a(()=>(this.#a=!0,r.signal),"get")})},"addSignalProperty"),i=a(()=>{let u=ve(this.options,e),d=a(()=>{let l={client:this.#n,queryKey:this.queryKey,meta:this.meta};return s(l),l},"createQueryFnContext")();return this.#a=!1,this.options.persister?this.options.persister(u,d,this):u(d)},"fetchFn"),o=a(()=>{let u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#n,state:this.state,fetchFn:i};return s(u),u},"createFetchContext")();(this.#e==="infinite"?Tt(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#r=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#c({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=Ce({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:a(u=>{u instanceof we&&u.revert&&this.setState({...this.#r,fetchStatus:"idle"}),r.abort()},"onCancel"),onFail:a((u,h)=>{this.#c({type:"failed",failureCount:u,error:h})},"onFail"),onPause:a(()=>{this.#c({type:"pause"})},"onPause"),onContinue:a(()=>{this.#c({type:"continue"})},"onContinue"),retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:a(()=>!0,"canRun")});try{let u=await this.#i.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#s.config.onSuccess?.(u,this),this.#s.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof we){if(u.silent)return this.#i.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#c({type:"error",error:u}),this.#s.config.onError?.(u,this),this.#s.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#c(t){let e=a(r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...je(r.data,this.options),fetchMeta:t.meta??null};case"success":let s={...r,...Ot(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#r=t.manual?s:void 0,s;case"error":let i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}},"reducer");this.state=e(this.state),g.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:t})})}};function je(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Be(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}a(je,"fetchState");function Ot(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}a(Ot,"successState");function Rt(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,s=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}a(Rt,"getDefaultState");var He=class extends L{static{a(this,"QueryObserver")}constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=oe(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#r=void 0;#s=void 0;#n;#i;#o;#a;#h;#c;#p;#d;#l;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),At(this.#t,this.options)?this.#f():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return $e(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return $e(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(t){let e=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#C(),this.#t.setOptions(this.options),e._defaulted&&!ge(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let s=this.hasListeners();s&&Ft(this.#t,r,this.options,e)&&this.#f(),this.updateResult(),s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||x(this.options.staleTime,this.#t)!==x(e.staleTime,this.#t))&&this.#y();let i=this.#b();s&&(this.#t!==r||I(this.options.enabled,this.#t)!==I(e.enabled,this.#t)||i!==this.#u)&&this.#g(i)}getOptimisticResult(t){let e=this.#e.getQueryCache().build(this.#e,t),r=this.createResult(e,t);return Rr(this,r)&&(this.#s=r,this.#i=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#s}trackResult(t,e){return new Proxy(t,{get:a((r,s)=>(this.trackProp(s),e?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s)),"get")})}trackProp(t){this.#m.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let e=this.#e.defaultQueryOptions(t),r=this.#e.getQueryCache().build(this.#e,e);return r.fetch().then(()=>this.createResult(r,e))}fetch(t){return this.#f({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#s))}#f(t){this.#C();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(v)),e}#y(){this.#S();let t=x(this.options.staleTime,this.#t);if(D.isServer()||this.#s.isStale||!ie(t))return;let r=me(this.#s.dataUpdatedAt,t)+1;this.#d=Q.setTimeout(()=>{this.#s.isStale||this.updateResult()},r)}#b(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#g(t){this.#w(),this.#u=t,!(D.isServer()||I(this.options.enabled,this.#t)===!1||!ie(this.#u)||this.#u===0)&&(this.#l=Q.setInterval(()=>{(this.options.refetchIntervalInBackground||X.isFocused())&&this.#f()},this.#u))}#v(){this.#y(),this.#g(this.#b())}#S(){this.#d!==void 0&&(Q.clearTimeout(this.#d),this.#d=void 0)}#w(){this.#l!==void 0&&(Q.clearInterval(this.#l),this.#l=void 0)}createResult(t,e){let r=this.#t,s=this.options,i=this.#s,n=this.#n,o=this.#i,u=t!==r?t.state:this.#r,{state:h}=t,d={...h},l=!1,f;if(e._optimisticResults){let R=this.hasListeners(),se=!R&&At(t,e),le=R&&Ft(t,r,e,s);(se||le)&&(d={...d,...je(h.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:y,status:b}=d;f=d.data;let w=!1;if(e.placeholderData!==void 0&&f===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,w=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,R!==void 0&&(b="success",f=ae(i?.data,R,e),l=!0)}if(e.select&&f!==void 0&&!w)if(i&&f===n?.data&&e.select===this.#h)f=this.#c;else try{this.#h=e.select,f=e.select(f),f=ae(i?.data,f,e),this.#c=f,this.#a=null}catch(R){this.#a=R}this.#a&&(m=this.#a,f=this.#c,y=Date.now(),b="error");let E=d.fetchStatus==="fetching",M=b==="pending",U=b==="error",j=M&&E,$=f!==void 0,q={status:b,fetchStatus:d.fetchStatus,isPending:M,isSuccess:b==="success",isError:U,isInitialLoading:j,isLoading:j,data:f,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:y,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>u.dataUpdateCount||d.errorUpdateCount>u.errorUpdateCount,isFetching:E,isRefetching:E&&!M,isLoadingError:U&&!$,isPaused:d.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:U&&$,isStale:ze(t,e),refetch:this.refetch,promise:this.#o,isEnabled:I(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){let R=q.data!==void 0,se=q.status==="error"&&!R,le=a(pe=>{se?pe.reject(q.error):R&&pe.resolve(q.data)},"finalizeThenableIfPossible"),pt=a(()=>{let pe=this.#o=q.promise=oe();le(pe)},"recreateThenable"),fe=this.#o;switch(fe.status){case"pending":t.queryHash===r.queryHash&&le(fe);break;case"fulfilled":(se||q.data!==fe.value)&&pt();break;case"rejected":(!se||q.error!==fe.reason)&&pt();break}}return q}updateResult(){let t=this.#s,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#i=this.options,this.#n.data!==void 0&&(this.#p=this.#t),ge(e,t))return;this.#s=e;let r=a(()=>{if(!t)return!0;let{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!this.#m.size)return!0;let n=new Set(i??this.#m);return this.options.throwOnError&&n.add("error"),Object.keys(this.#s).some(o=>{let c=o;return this.#s[c]!==t[c]&&n.has(c)})},"shouldNotifyListeners");this.#k({listeners:r()})}#C(){let t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;let e=this.#t;this.#t=t,this.#r=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#k(t){g.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#s)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function Or(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}a(Or,"shouldLoadOnMount");function At(t,e){return Or(t,e)||t.state.data!==void 0&&$e(t,e,e.refetchOnMount)}a(At,"shouldFetchOnMount");function $e(t,e,r){if(I(e.enabled,t)!==!1&&x(e.staleTime,t)!=="static"){let s=typeof r=="function"?r(t):r;return s==="always"||s!==!1&&ze(t,e)}return!1}a($e,"shouldFetchOn");function Ft(t,e,r,s){return(t!==e||I(s.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ze(t,r)}a(Ft,"shouldFetchOptionally");function ze(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(x(e.staleTime,t))}a(ze,"isStale");function Rr(t,e){return!ge(t.getCurrentResult(),e)}a(Rr,"shouldAssignObserverCurrentProperties");var Mt=class extends ke{static{a(this,"Mutation")}#e;#t;#r;#s;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#r=t.mutationCache,this.#t=[],this.state=t.state||Pr(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){let e=a(()=>{this.#n({type:"continue"})},"onContinue"),r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#s=Ce({fn:a(()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),"fn"),onFail:a((n,o)=>{this.#n({type:"failed",failureCount:n,error:o})},"onFail"),onPause:a(()=>{this.#n({type:"pause"})},"onPause"),onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:a(()=>this.#r.canRun(this),"canRun")});let s=this.state.status==="pending",i=!this.#s.canStart();try{if(s)e();else{this.#n({type:"pending",variables:t,isPaused:i}),this.#r.config.onMutate&&await this.#r.config.onMutate(t,this,r);let o=await this.options.onMutate?.(t,r);o!==this.state.context&&this.#n({type:"pending",context:o,variables:t,isPaused:i})}let n=await this.#s.start();return await this.#r.config.onSuccess?.(n,t,this.state.context,this,r),await this.options.onSuccess?.(n,t,this.state.context,r),await this.#r.config.onSettled?.(n,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(n,null,t,this.state.context,r),this.#n({type:"success",data:n}),n}catch(n){try{await this.#r.config.onError?.(n,t,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onError?.(n,t,this.state.context,r)}catch(o){Promise.reject(o)}try{await this.#r.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,r)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,n,t,this.state.context,r)}catch(o){Promise.reject(o)}throw this.#n({type:"error",error:n}),n}finally{this.#r.runNext(this)}}#n(t){let e=a(r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}},"reducer");this.state=e(this.state),g.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(t)}),this.#r.notify({mutation:this,type:"updated",action:t})})}};function Pr(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}a(Pr,"getDefaultState");var xt=class extends L{static{a(this,"MutationCache")}constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(t,e,r){let s=new Mt({client:t,mutationCache:this,mutationId:++this.#r,options:t.defaultMutationOptions(e),state:r});return this.add(s),s}add(t){this.#e.add(t);let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);r?r.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){let e=Ie(t);if(typeof e=="string"){let r=this.#t.get(e);if(r)if(r.length>1){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){let e=Ie(t);if(typeof e=="string"){let s=this.#t.get(e)?.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){let e=Ie(t);return typeof e=="string"?this.#t.get(e)?.find(s=>s!==t&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){g.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){let e={exact:!0,...t};return this.getAll().find(r=>be(e,r))}findAll(t={}){return this.getAll().filter(e=>be(t,e))}notify(t){g.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){let t=this.getAll().filter(e=>e.state.isPaused);return g.batch(()=>Promise.all(t.map(e=>e.continue().catch(v))))}};function Ie(t){return t.options.scope?.id}a(Ie,"scopeFor");var _t=class extends L{static{a(this,"QueryCache")}constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,r){let s=e.queryKey,i=e.queryHash??ne(s,e),n=this.get(i);return n||(n=new Pt({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(e),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(n)),n}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){let e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){g.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){let e={exact:!0,...t};return this.getAll().find(r=>ye(e,r))}findAll(t={}){let e=this.getAll();return Object.keys(t).length>0?e.filter(r=>ye(t,r)):e}notify(t){g.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){g.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){g.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}};var We=class{static{a(this,"QueryClient")}#e;#t;#r;#s;#n;#i;#o;#a;constructor(t={}){this.#e=t.queryCache||new _t,this.#t=t.mutationCache||new xt,this.#r=t.defaultOptions||{},this.#s=new Map,this.#n=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#o=X.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#a=Z.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=this.#e.build(this,e),s=r.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(x(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:r})=>{let s=r.data;return[e,s]})}setQueryData(t,e,r){let s=this.defaultQueryOptions({queryKey:t}),n=this.#e.get(s.queryHash)?.state.data,o=vt(e,n);if(o!==void 0)return this.#e.build(this,s).setData(o,{...r,manual:!0})}setQueriesData(t,e,r){return g.batch(()=>this.#e.findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){let e=this.#e;g.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=this.#e;return g.batch(()=>(r.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},s=g.batch(()=>this.#e.findAll(t).map(i=>i.cancel(r)));return Promise.all(s).then(v).catch(v)}invalidateQueries(t,e={}){return g.batch(()=>(this.#e.findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},s=g.batch(()=>this.#e.findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,r);return r.throwOnError||(n=n.catch(v)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(s).then(v)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=this.#e.build(this,e);return r.isStaleByTime(x(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(v).catch(v)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(v).catch(v)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Z.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(t){this.#r=t}setQueryDefaults(t,e){this.#s.set(z(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...this.#s.values()],r={};return e.forEach(s=>{N(t,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(t,e){this.#n.set(z(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...this.#n.values()],r={};return e.forEach(s=>{N(t,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...this.#r.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=ne(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Y&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#r.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}};var K=P(H(),1);var ee=P(H(),1),Lt=P(Ue(),1);var ce=ee.createContext(void 0),Ve=a(t=>{let e=ee.useContext(ce);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},"useQueryClient"),Ge=a(({client:t,children:e})=>(ee.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),(0,Lt.jsx)(ce.Provider,{value:t,children:e})),"QueryClientProvider");var ue=P(H(),1),Ar=P(Ue(),1);function Fr(){let t=!1;return{clearReset:a(()=>{t=!1},"clearReset"),reset:a(()=>{t=!0},"reset"),isReset:a(()=>t,"isReset")}}a(Fr,"createValue");var Mr=ue.createContext(Fr()),Qt=a(()=>ue.useContext(Mr),"useQueryErrorResetBoundary");var Dt=P(H(),1);var Ut=a((t,e,r)=>{let s=r?.state.error&&typeof t.throwOnError=="function"?Se(t.throwOnError,[r.state.error,r]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},"ensurePreventErrorBoundaryRetry"),qt=a(t=>{Dt.useEffect(()=>{t.clearReset()},[t])},"useClearResetErrorBoundary"),Nt=a(({result:t,errorResetBoundary:e,throwOnError:r,query:s,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(i&&t.data===void 0||Se(r,[t.error,s])),"getHasError");var Ee=P(H(),1);var Kt=Ee.createContext(!1),Bt=a(()=>Ee.useContext(Kt),"useIsRestoring"),Qa=Kt.Provider;var jt=a(t=>{if(t.suspense){let r=a(i=>i==="static"?i:Math.max(i??1e3,1e3),"clamp"),s=t.staleTime;t.staleTime=typeof s=="function"?(...i)=>r(s(...i)):r(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},"ensureSuspenseTimers"),$t=a((t,e)=>t.isLoading&&t.isFetching&&!e,"willFetch"),Ht=a((t,e)=>t?.suspense&&e.isPending,"shouldSuspend"),Je=a((t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()}),"fetchOptimistic");function zt(t,e,r){let s=Bt(),i=Qt(),n=Ve(r),o=n.defaultQueryOptions(t);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let c=n.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=s?"isRestoring":u?"optimistic":void 0,jt(o),Ut(o,i,c),qt(i);let h=!n.getQueryCache().get(o.queryHash),[d]=K.useState(()=>new e(n,o)),l=d.getOptimisticResult(o),f=!s&&u;if(K.useSyncExternalStore(K.useCallback(m=>{let y=f?d.subscribe(g.batchCalls(m)):v;return d.updateResult(),y},[d,f]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),K.useEffect(()=>{d.setOptions(o)},[o,d]),Ht(o,l))throw Je(o,d,i);if(Nt({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:c,suspense:o.suspense}))throw l.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!D.isServer()&&$t(l,s)&&(h?Je(o,d,i):c?.promise)?.catch(v).finally(()=>{d.updateResult()}),o.notifyOnChangeProps?l:d.trackResult(l)}a(zt,"useBaseQuery");function xr(t,e){return zt(t,He,e)}a(xr,"useQuery");var Wt=P(mt(),1);var W=P(H(),1),Xe=P(Ue(),1);var Vt=(0,W.createContext)(null),_r=a(()=>new We({defaultOptions:{mutations:{retry:0},queries:{gcTime:5*6e4,retry:0,staleTime:Number.POSITIVE_INFINITY}}}),"Q"),Lr=a(t=>{let e=(0,Wt.c)(9),{children:r,client:s,queryClient:i}=t,n=(0,W.use)(ce),o;e[0]!==n||e[1]!==i?(o=a(()=>i??n??_r(),"o"),e[0]=n,e[1]=i,e[2]=o):o=e[2];let[c]=(0,W.useState)(o),u=i??n??c,h;e[3]!==r||e[4]!==s?(h=(0,Xe.jsx)(Vt,{value:s,children:r}),e[3]=r,e[4]=s,e[5]=h):h=e[5];let d=h;if(n===u)return d;let l;return e[6]!==d||e[7]!==u?(l=(0,Xe.jsx)(Ge,{client:u,children:d}),e[6]=d,e[7]=u,e[8]=l):l=e[8],l},"b"),Ye=a(()=>{let t=(0,W.use)(Vt);if(!t)throw new p("INTERNAL","useLunora must be used inside <LunoraProvider />");return t},"q");var Ze=a(t=>{let e="";for(let r=0;r<t.length;r+=32768)e+=String.fromCharCode(...t.subarray(r,r+32768));return btoa(e)},"A"),Qr=a(t=>{let e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s+=1)r[s]=e.codePointAt(s)??0;return r},"E"),k="$lunora.wire$",et="__proto__",Gt={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},Jt={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},tt=a(t=>{if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.prototype},"p"),O=a((t,e=0)=>{if(e>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(t===void 0)return[k,"undefined"];if(t===null)return null;let r=typeof t;if(r==="bigint")return[k,"bigint",t.toString()];if(r==="number"){let n=t;return Number.isNaN(n)?[k,"nan"]:n===1/0?[k,"inf"]:n===-1/0?[k,"-inf"]:n}if(r!=="object")return t;if(t instanceof Date)return[k,"date",O(t.getTime(),e+1)];if(t instanceof Error){let n=t,o={};for(let u of Object.keys(n))n[u]!==void 0&&(o[u]=O(n[u],e+1));let c=[k,"error",n.name,n.message,o];return n.cause!==void 0&&c.push(O(n.cause,e+1)),c}if(t instanceof URL)return[k,"url",t.href];if(t instanceof Map)return[k,"map",[...t.entries()].map(([n,o])=>[O(n,e+1),O(o,e+1)])];if(t instanceof Set)return[k,"set",[...t].map(n=>O(n,e+1))];if(t instanceof ArrayBuffer)return[k,"bytes",Ze(new Uint8Array(t)),"ArrayBuffer"];if(ArrayBuffer.isView(t)){let n=t,o=n.constructor.name,c=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return o==="Uint8Array"?[k,"bytes",Ze(c)]:[k,"bytes",Ze(c),o]}if(Array.isArray(t)){let n=t.map(o=>O(o,e+1));return n.length>0&&n[0]===k?[k,"arr",n]:n}if(!tt(t)){let n=t.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${n} over the Lunora wire \u2014 only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}let s=t,i={};for(let n of Object.keys(s)){let o=s[n];if(o===void 0)continue;let c=O(o,e+1);n===et?Object.defineProperty(i,n,{configurable:!0,enumerable:!0,value:c,writable:!0}):i[n]=c}return i},"u"),S=a((t,e=0)=>{if(e>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(t===null||typeof t!="object")return t;if(Array.isArray(t)){if(t[0]===k)switch(t[1]){case"-inf":return-1/0;case"arr":return t[2].map(i=>S(i,e+1));case"bigint":{let i=t[2];if(typeof i!="string"||i.length>1024||!/^-?\d+$/.test(i))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(i)}case"date":return new Date(S(t[2],e+1));case"map":return new Map(t[2].map(([i,n])=>[S(i,e+1),S(n,e+1)]));case"set":return new Set(t[2].map(i=>S(i,e+1)));case"url":return new URL(t[2]);case"error":{let i=t[2],n=t[3],o=(Object.hasOwn(Jt,i)?Jt[i]:void 0)??Error,c=new o(n);c.name!==i&&Object.defineProperty(c,"name",{configurable:!0,value:i,writable:!0});let u=S(t[4],e+1);for(let h of Object.keys(u))h===et?Object.defineProperty(c,h,{configurable:!0,enumerable:!0,value:u[h],writable:!0}):c[h]=u[h];return t.length>5&&Object.defineProperty(c,"cause",{configurable:!0,value:S(t[5],e+1),writable:!0}),c}case"bytes":{let i=Qr(t[2]),n=t[3]??"Uint8Array";if(n==="ArrayBuffer")return i.buffer.byteLength===i.byteLength?i.buffer:i.slice().buffer;let o=Object.hasOwn(Gt,n)?Gt[n]:void 0;return o?new o(i.slice().buffer):i}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return t.map(i=>S(i,e+1))}return t.map(i=>S(i,e+1))}let r=t,s={};for(let i of Object.keys(r)){let n=S(r[i],e+1);i===et?Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):s[i]=n}return s},"y");var A=a(t=>new Promise((e,r)=>{t.addEventListener("success",()=>{e(t.result)}),t.addEventListener("error",()=>{r(t.error??new Error("IndexedDB request failed"))})}),"c"),Te=a((t,e,r,s)=>{let i;return()=>i||(i=new Promise((n,o)=>{let c=t.open(e,r);c.addEventListener("upgradeneeded",()=>{s(c.result)}),c.addEventListener("success",()=>{n(c.result)}),c.addEventListener("error",()=>{o(c.error??new Error("IndexedDB open failed"))})}),i)},"E"),Oe=a((t,e)=>async(r,s)=>{let i=(await t()).transaction(e,r),n=await s(i.objectStore(e));return await new Promise((o,c)=>{i.addEventListener("complete",()=>{o()}),i.addEventListener("error",()=>{c(i.error??new Error("IndexedDB transaction failed"))}),i.addEventListener("abort",()=>{c(i.error??new Error("IndexedDB transaction aborted"))})}),n},"u");var Re=a((t,e,r)=>`${t}::${e}::${r??""}`,"T"),Dr=500,Ur=a((t,e)=>{if(!Number.isInteger(t)||t<1)throw new p("INTERNAL",`${e}: maxEntries must be a positive integer, got ${String(t)}`);return t},"E");var qr="lunora-query-cache",Nr="query-cache",Xt="by_ts",Kr=1,Br=a((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new p("INTERNAL","createIndexedDbQueryCache: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryQueryCache()");let r=t.databaseName??qr,s=t.storeName??Nr,i=Ur(t.maxEntries??Dr,"createIndexedDbQueryCache"),n=Te(e,r,Kr,u=>{u.objectStoreNames.contains(s)||u.createObjectStore(s,{keyPath:"key"}).createIndex(Xt,"ts",{unique:!1})}),o=Oe(n,s),c=a(async u=>{let h=await A(u.count())-i;h<=0||await new Promise((d,l)=>{let f=u.index(Xt).openCursor();f.addEventListener("success",()=>{let m=f.result;if(!m||h<=0){d();return}m.delete(),h-=1,m.continue()}),f.addEventListener("error",()=>{l(f.error??new Error("IndexedDB eviction failed"))})})},"y");return{clear:a(async()=>{await o("readwrite",u=>A(u.clear()))},"clear"),load:a(async()=>o("readonly",u=>A(u.getAll())),"load"),put:a(async(u,h)=>{await o("readwrite",async d=>{await A(d.put({...h,key:u})),await c(d)})},"put"),remove:a(async u=>{await o("readwrite",h=>A(h.delete(u)))},"remove")}},"N"),Yt=a(t=>{if(t!==!1){if(t)return t;if(!(typeof indexedDB>"u"))return Br()}},"L");var Zt=a(()=>{let t=null;return{get:a(()=>t,"get"),set:a(e=>{t=e},"set")}},"r");var Pe=class{static{a(this,"u")}values=new Map;subscribers=new Map;get(e){return this.values.has(e.key)?this.values.get(e.key):e.defaultValue}set(e,r){if(r===void 0){this.reset(e);return}this.values.set(e.key,r),this.notify(e.key,r)}reset(e){this.values.delete(e.key),this.notify(e.key,e.defaultValue)}subscribe(e,r){let s=this.subscribers.get(e.key);return s||(s=new Set,this.subscribers.set(e.key,s)),s.add(r),()=>{s.delete(r),s.size===0&&this.subscribers.delete(e.key)}}notify(e,r){let s=this.subscribers.get(e);if(s)for(let i of s)try{i(r)}catch{}}};var er=0,jr="lunora-bridge",$r=1e3,Hr=3e3,Ae=class{static{a(this,"c")}bc;tabId;heartbeatInterval;leaderTimeout;knownLeader=void 0;leader=!1;running=!1;promotionPending=!1;lastHeartbeat=0;heartbeatTimer=void 0;leaderCheckTimer=void 0;onBecomeLeader;onStopBeingLeader;onConnectionStatus;onSubscriptionData;onSubscriptionError;onSubscriptionSettled;constructor(e={}){if(er+=1,this.tabId=`tab_${String(er)}_${crypto.randomUUID()}`,this.heartbeatInterval=e.heartbeatInterval??$r,this.leaderTimeout=e.leaderTimeout??Hr,this.onBecomeLeader=e.onBecomeLeader,this.onStopBeingLeader=e.onStopBeingLeader,this.onConnectionStatus=e.onConnectionStatus,this.onSubscriptionData=e.onSubscriptionData,this.onSubscriptionError=e.onSubscriptionError,this.onSubscriptionSettled=e.onSubscriptionSettled,typeof BroadcastChannel>"u"){this.bc=void 0;return}this.bc=new BroadcastChannel(e.channelName??jr),this.bc.addEventListener("message",r=>{this.handleMessage(r.data)})}start(){if(!this.running){if(this.running=!0,this.bc===void 0){this.becomeLeader();return}this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout),this.leaderCheckTimer=setInterval(()=>{this.checkLeaderHealth()},this.leaderTimeout),this.heartbeatTimer=setInterval(()=>{this.sendHeartbeat()},this.heartbeatInterval)}}stop(){this.running=!1,this.leader&&(this.broadcast({type:"yield-leadership",tabId:this.tabId}),this.leader=!1,this.knownLeader=void 0,this.onStopBeingLeader?.()),this.heartbeatTimer!==void 0&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0),this.leaderCheckTimer!==void 0&&(clearInterval(this.leaderCheckTimer),this.leaderCheckTimer=void 0),this.bc?.close()}isLeader(){return this.leader}promoteImmediately(){this.running&&this.becomeLeader()}get leaderTabId(){return this.knownLeader}get id(){return this.tabId}get isRunning(){return this.running}broadcastSubscriptionData(e,r,s,i,n){this.leader&&this.broadcast({type:"subscription-data",tabId:this.tabId,key:e,data:r,...s===void 0?{}:{cursor:s},...i===void 0?{}:{epoch:i},...n===void 0?{}:{identity:n}})}broadcastSubscriptionError(e,r){this.leader&&this.broadcast({type:"subscription-error",tabId:this.tabId,key:e,error:r})}broadcastSubscriptionSettled(e,r,s,i,n,o){this.leader&&this.broadcast({type:"subscription-settled",tabId:this.tabId,key:e,...r===void 0?{}:{cursor:r},...s===void 0?{}:{epoch:s},...i===void 0?{}:{lastMutationId:i},...n===void 0?{}:{clientId:n},...o===void 0?{}:{identity:o}})}broadcastConnectionStatus(e,r){this.leader&&this.broadcast({type:"connection-status",tabId:this.tabId,status:e,...r===void 0?{}:{identity:r}})}broadcast(e){this.bc?.postMessage(e)}handleMessage(e){switch(e.type){case"claim-leadership":{this.handleClaimLeadership(e);break}case"connection-status":{if(this.leader||e.tabId===this.tabId)break;this.onConnectionStatus?.(e.status,e.identity);break}case"heartbeat":{this.handleHeartbeat(e);break}case"subscription-data":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionData?.(e.key,e.data,e.cursor,e.epoch,e.identity);break}case"subscription-error":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionError?.(e.key,e.error);break}case"subscription-settled":{if(this.leader||e.tabId===this.tabId)break;this.onSubscriptionSettled?.(e.key,e.cursor,e.epoch,e.lastMutationId,e.clientId,e.identity);break}case"yield-leadership":{this.knownLeader===e.tabId&&(this.knownLeader=void 0,this.running&&!this.leader&&this.claimAndPromote());break}}}handleClaimLeadership(e){if(e.tabId!==this.tabId){if(this.leader){this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()});return}this.knownLeader===void 0&&e.tabId<this.tabId&&(this.knownLeader=e.tabId,this.lastHeartbeat=e.ts)}}handleHeartbeat(e){if(e.tabId!==this.tabId){if(this.leader){this.resolveLeaderVsLeaderTieBreak(e);return}this.lastHeartbeat=e.ts,this.knownLeader=e.tabId}}resolveLeaderVsLeaderTieBreak(e){e.tabId<this.tabId?(this.leader=!1,this.knownLeader=e.tabId,this.lastHeartbeat=e.ts,this.onStopBeingLeader?.()):this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}becomeLeader(){this.leader||(this.leader=!0,this.knownLeader=this.tabId,this.lastHeartbeat=Date.now(),this.onBecomeLeader?.(),this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()}))}sendHeartbeat(){this.leader&&this.broadcast({type:"heartbeat",tabId:this.tabId,ts:Date.now()})}checkLeaderHealth(){if(!(!this.running||this.leader)){if(this.knownLeader===void 0){this.claimAndPromote();return}Date.now()-this.lastHeartbeat>this.leaderTimeout&&(this.knownLeader=void 0,this.claimAndPromote())}}claimAndPromote(){this.promotionPending||(this.promotionPending=!0,this.broadcast({type:"claim-leadership",tabId:this.tabId,ts:Date.now()}),setTimeout(()=>{this.promotionPending=!1,this.running&&this.knownLeader===void 0&&this.becomeLeader()},this.leaderTimeout))}};var rt="_id",st="_creationTime",it="page",tr="pageDelta",zr=a(t=>{if(Array.isArray(t))return t;if(tt(t)&&Array.isArray(t[it]))return t[it]},"y"),Wr=a(t=>{let e;for(let r of t){let s=r[st];if(typeof s=="number"){if(e!==void 0){if(s<e)return!0;if(s>e)return!1}e=s}}return!1},"l"),Vr=a((t,e)=>{let r=e[st];if(typeof r!="number")return t.length;let s=Wr(t);for(let[i,n]of t.entries()){let o=n[st];if(typeof o=="number"&&(s?o<r:o>r))return i}return t.length},"x"),Gr=a(t=>{if(typeof t!="object"||t===null)return;let e=t[rt];return typeof e=="string"?e:void 0},"A"),rr=a(t=>{if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.key=="string"&&typeof e.table=="string"&&(e.op==="insert"||e.op==="update"||e.op==="delete")},"b"),Jr=a((t,e)=>{let r=[];for(let u of t){if(Gr(u)===void 0)return;r.push(u)}let{key:s,op:i,row:n}=e;if(i==="delete"){let u=r.filter(h=>h[rt]!==s);return u.length===r.length?[...r]:u}if(n===void 0)return;let o=[...r],c=r.findIndex(u=>u[rt]===s);return c===-1?o.splice(Vr(r,n),0,n):o[c]=n,o},"I"),sr=a((t,e)=>{let r=zr(t);if(r===void 0)return;let s=Jr(r,e);return s===void 0||Array.isArray(t)?s:{...t,[it]:s}},"E");var Xr=1024,Fe=a(t=>{let e=t.maxBuffer??Xr,r=[],s=[],i=!1,n,o=!1,c=a(()=>{let d=s.shift();if(!d)return!1;if(n)return d.reject(n),!0;if(r.length>0){let l=r.shift();return d.resolve({done:!1,value:l}),!0}return i?(d.resolve({done:!0,value:void 0}),!0):(s.unshift(d),!1)},"u"),u={complete(){if(!(i||n))for(i=!0;c(););},fail(d){if(!(i||n))for(n=d,r.length=0;c(););},push(d){if(!(i||n||o)){if(r.length>=e){u.fail(new p("STREAM_BACKPRESSURE",`stream buffer overflow (max=${e.toString()}); the consumer cannot keep up with the producer`));return}r.push(d),c()}}},h=a(()=>{if(!o){o=!0,i=!0,r.length=0;try{t.onCancel()}catch{}for(;c(););}},"c");return{handle:u,iterable:{cancel:h,[Symbol.asyncIterator](){return{next(){if(n)return Promise.reject(n);if(r.length>0){let d=r.shift();return Promise.resolve({done:!1,value:d})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((d,l)=>{s.push({reject:l,resolve:d})})},return(){return h(),Promise.resolve({done:!0,value:void 0})}}}}}},"p");var ir=/^ /u,nr=a(t=>typeof t=="object"&&t!==null?JSON.stringify(t):String(t),"h"),Yr=a(t=>{let e="",r=[];for(let s of t.split(`
2
+ `))s.startsWith("event:")?e=s.slice(6).replace(ir,""):s.startsWith("data:")&&r.push(s.slice(5).replace(ir,""));return{data:r.join(`
3
+ `),event:e}},"u"),Zr=a((t,e,r)=>{let s=e.params??{},i=t.path.split("/").map(c=>{if(!c.startsWith(":"))return c;let u=c.slice(1),h=s[u];if(h===void 0)throw new p("HTTP_STREAM_MISSING_PARAM",`httpStream: missing path param ":${u}" for route ${t.path}`);return encodeURIComponent(nr(h))}).join("/"),n=new URLSearchParams;for(let[c,u]of Object.entries(e.searchParams??{}))u!==void 0&&n.set(c,nr(u));let o=n.toString();return`${r.endsWith("/")?r.slice(0,-1):r}${i}${o===""?"":`?${o}`}`},"S"),es=a((t,e)=>{if(t.event==="complete")return e.complete(),!0;if(t.event==="error"){let r={};try{r=JSON.parse(t.data)}catch{}let s=typeof r.message=="string"?r.message:"stream error",i=typeof r.code=="string"?r.code:"HTTP_STREAM_ERROR";return e.fail(new p(i,s)),!0}if((t.event===""||t.event==="message")&&t.data!=="")try{e.push(JSON.parse(t.data))}catch{return e.fail(new p("HTTP_STREAM_BAD_CHUNK","httpStream: malformed SSE chunk (invalid JSON)")),!0}return!1},"T"),ts=a(async(t,e)=>{let r=t.getReader(),s=new TextDecoder,i="",n=a(()=>{let o=i.indexOf(`
4
+
5
+ `);for(;o!==-1;){let c=Yr(i.slice(0,o));if(i=i.slice(o+2),es(c,e))return!0;o=i.indexOf(`
6
+
7
+ `)}return!1},"i");for(;;){let{done:o,value:c}=await r.read();if(o)break;if(i+=s.decode(c,{stream:!0}).replaceAll(`\r
8
+ `,`
9
+ `),n()){await r.cancel().catch(()=>{});return}}i+=s.decode().replaceAll(`\r
10
+ `,`
11
+ `),n()||e.fail(new p("HTTP_STREAM_INTERRUPTED","httpStream: stream ended without a complete frame"))},"E"),ar=a((t,e,r={})=>{let s=r.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0);if(!s)throw new p("INTERNAL","httpStream: no `fetch` implementation available");let i=Zr(t,e??{},r.baseUrl??""),n=new AbortController,o;r.signal&&(r.signal.aborted?n.abort():(o=a(()=>{n.abort()},"s"),r.signal.addEventListener("abort",o,{once:!0})));let c=a(()=>{o&&r.signal?.removeEventListener("abort",o)},"d"),{handle:u,iterable:h}=Fe({maxBuffer:r.maxBuffer,onCancel:a(()=>{n.abort()},"onCancel")});return(async()=>{try{let d=await s(i,{headers:{accept:"text/event-stream",...r.headers},method:t.method,signal:n.signal});if(!d.ok){await d.body?.cancel().catch(()=>{}),u.fail(new p("HTTP_STREAM_STATUS",`httpStream: request failed (status ${d.status.toString()})`,{status:d.status}));return}if(!d.body){u.fail(new p("HTTP_STREAM_NO_BODY","httpStream: response has no body"));return}await ts(d.body,u)}finally{c()}})().catch(d=>{if(n.signal.aborted){u.complete();return}if(d instanceof Error&&"code"in d){u.fail(d);return}u.fail(new p("HTTP_STREAM_TRANSPORT",d instanceof Error?d.message:String(d),{cause:d}))}),h},"w");var rs=a((t,e)=>t<e?-1:t>e?1:0,"f"),nt=a(t=>{if(t===void 0)return"null";if(typeof t=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(typeof t=="number"){if(Number.isNaN(t))return"nan";if(t===1/0)return"inf";if(t===-1/0)return"-inf";if(Object.is(t,-0))return"-0"}if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(n=>nt(n)).join(",")}]`;let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype){let n=t.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${n} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let r=t,s=Object.keys(r).toSorted(rs),i=[];for(let n of s){let o=r[n];o!==void 0&&i.push(`${JSON.stringify(n)}:${nt(o)}`)}return`{${i.join(",")}}`},"e"),B=a(t=>nt(O(t)),"p");var _=class t{static{a(this,"r")}static key(e,r,s){return`${e}::${B(r)}::${s??""}`}byKey=new Map;byId=new Map;get(e){return this.byKey.get(e)}getById(e){return this.byId.get(e)}add(e){this.byKey.set(t.key(e.fn.__lunoraRef,e.args,e.shardKey),e),this.byId.set(e.id,e)}remove(e){let r=t.key(e.fn.__lunoraRef,e.args,e.shardKey);this.byKey.get(r)===e&&this.byKey.delete(r),this.byId.delete(e.id)}all(){return[...this.byKey.values()]}};var he=a((t,e)=>{let r=t;for(let s of e)try{r=s.transform(r)}catch{}return r},"p"),te=a((t,e)=>{if(e!==t.lastValue){t.lastValue=e;for(let r of t.callbacks)try{r(e)}catch{}}},"u"),at=a((t,e)=>{let r;try{r=e(t.lastValue)}catch{return}let s={id:Symbol("optimistic"),transform:e};t.optimisticLayers.push(s),te(t,r);let i=a(()=>{let o=t.optimisticLayers.findIndex(c=>c.id===s.id);return o===-1?!1:(t.optimisticLayers.splice(o,1),!0)},"c"),n=a(()=>{te(t,he(t.serverBase,t.optimisticLayers))},"a");return{confirm:a(o=>{if(o===void 0){i();return}s.commitCursor=o,t.serverCursor!==void 0&&t.serverCursor>=o&&i()&&n()},"confirm"),rollback:a(()=>{i()&&n()},"rollback")}},"y"),Me=a((t,e)=>{if(e===void 0||t.optimisticLayers.length===0)return!1;let r=t.optimisticLayers.length;return t.optimisticLayers=t.optimisticLayers.filter(s=>s.commitCursor===void 0||s.commitCursor>e),t.optimisticLayers.length!==r},"h"),or=a((t,e)=>{let r=[],s=[],i=a((n,o)=>t.get(_.key(n,o,e)),"c");return{confirms:r,rollbacks:s,store:{getAllQueries:a(n=>{let o=[];for(let c of t.all())c.fn.__lunoraRef===n.__lunoraRef&&(c.shardKey??"")===(e??"")&&o.push({args:c.args,value:c.lastValue});return o},"getAllQueries"),getQuery:a((n,o)=>i(n.__lunoraRef,o??{})?.lastValue,"getQuery"),setQuery:a((n,o,c)=>{let u=i(n.__lunoraRef,o??{});if(!u)return;let h=at(u,()=>c);h&&(r.push(h.confirm),s.push(h.rollback))},"setQuery")}}},"L");var cr=0,ss=a(()=>{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();cr+=1;let t=typeof crypto<"u"&&typeof crypto.getRandomValues=="function"?Array.from(crypto.getRandomValues(new Uint8Array(8)),e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(16).slice(2,12);return`id_${Date.now().toString(36)}_${cr.toString(36)}_${t}`},"a"),ot=a((t,e)=>t!==void 0&&e!==t,"f"),_e=ss,re=a((t,e,r,s)=>{if(t){t({error:r,mutationId:s,operation:e});return}console.warn(`[lunora] offline-queue persistence ${e} failed`,r)},"o"),xe=class{static{a(this,"m")}queueBeforeFirstConnect;maxItems;onPersistenceError;persistence;onEvict;onSizeChange;version;items=[];constructor(e={},r={}){this.maxItems=e.maxItems??1e3,this.queueBeforeFirstConnect=e.queueBeforeFirstConnect??!1,this.onPersistenceError=e.onPersistenceError,this.persistence=r.persistence,this.onEvict=r.onEvict,this.onSizeChange=r.onSizeChange,this.version=r.version}get size(){return this.items.length}enqueue(e){let r=e;r.id??=_e(),this.items.push(r),this.persistence?.append({args:r.args,clientId:r.clientId,functionPath:r.functionPath,id:r.id,identity:r.identity,shardKey:r.shardKey,...this.version===void 0?{}:{version:this.version}}).catch(s=>{re(this.onPersistenceError,"append",s,r.id)}),this.evictOverflow(),this.notifySize()}async hydrate(){if(!this.persistence)return[];let e;try{e=await this.persistence.load()}catch(o){throw re(this.onPersistenceError,"load",o),o}let r=[],s=new Set(this.items.map(o=>o.id));for(let o of e)if(!s.has(o.id)){if(ot(this.version,o.version)){this.persistence.remove(o.id).catch(c=>{re(this.onPersistenceError,"remove",c,o.id)});continue}s.add(o.id),r.push({args:o.args,clientId:o.clientId,functionPath:o.functionPath,id:o.id,identity:o.identity,reject:a(()=>{},"reject"),resolve:a(()=>{},"resolve"),shardKey:o.shardKey})}this.items.unshift(...r),this.evictOverflow(),this.notifySize();let i=new Set(this.items),n=new Set;for(let o of r)i.has(o)&&n.add(o.shardKey);return[...n]}drain(e){if(!e){let i=[...this.items];return this.items.length=0,this.notifySize(),i}let r=[],s=[];for(let i of this.items)(e(i)?r:s).push(i);return this.items.length=0,this.items.push(...s),this.notifySize(),r}requeue(e){e.length!==0&&(this.items.unshift(...e),this.notifySize())}drainConflict(){let e=[],r=[];for(let s of this.items)if(s.precondition!==void 0&&!s.precondition()){let i=new Error("offline mutation skipped: precondition failed before replay");i.code="OFFLINE_PRECONDITION_FAILED",s.reject(i),e.push(s)}else r.push(s);return e.length>0&&(this.items.length=0,this.items.push(...r),this.notifySize()),e}clear(){for(let e of this.items){let r=new Error("CLIENT_CLOSED");r.code="CLIENT_CLOSED",e.reject(r)}this.items.length=0,this.notifySize()}evictOverflow(){for(;this.items.length>this.maxItems;){let e=this.items.shift();if(e){e.id&&this.persistence?.remove(e.id).catch(s=>{re(this.onPersistenceError,"remove",s,e.id)});let r=new Error("offline queue overflow");r.code="OFFLINE_QUEUE_OVERFLOW",e.reject(r),this.onEvict?.(e,r)}}}notifySize(){this.onSizeChange?.(this.items.length)}};var is="lunora-outbox",ns="offline-mutations",ur="by_id",as=a((t={})=>{let e=t.indexedDB??(typeof indexedDB>"u"?void 0:indexedDB);if(!e)throw new p("INTERNAL","createIndexedDbPersistence: no IndexedDB available \u2014 pass `indexedDB` or use createInMemoryPersistence()");let r=t.databaseName??is,s=t.storeName??ns,i=Te(e,r,1,o=>{o.objectStoreNames.contains(s)||o.createObjectStore(s,{autoIncrement:!0}).createIndex(ur,"id",{unique:!0})}),n=Oe(i,s);return{append:a(async o=>{await n("readwrite",c=>A(c.add(o)))},"append"),clear:a(async()=>{await n("readwrite",o=>A(o.clear()))},"clear"),load:a(async()=>n("readonly",o=>A(o.getAll())),"load"),remove:a(async o=>{await n("readwrite",async c=>{let u=await A(c.index(ur).getKey(o));u!==void 0&&await A(c.delete(u))})},"remove")}},"p"),hr=a((t,e=!0)=>{if(t!==!1){if(t)return t;if(!(!e||typeof indexedDB>"u"))return as()}},"b");var ct=a((t={},e=Math.random)=>{let r=t.initialDelayMs??250,s=t.maxDelayMs??3e4,i=t.jitter??!0,n=0;return{next(){let o=Math.min(s,r*2**n);if(n+=1,!i)return o;let c=o/2;return Math.floor(c+e()*(o-c))},reset(){n=0}}},"s");var dr=a((t,e,r,s)=>{let i=t.peekActiveQuerySnapshot(e.__lunoraRef,r,s),n=i.present?B(i.value):void 0;return()=>{let o=t.peekActiveQuerySnapshot(e.__lunoraRef,r,s);return!i.present||!o.present?!0:B(o.value)===n}},"c");var ut=500,os=a((t,e)=>{if(t.size<e)return;let r=t.keys().next().value;r!==void 0&&t.delete(r)},"he"),J=class{static{a(this,"C")}listeners=new Set;add(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(...e){let[r]=e;for(let s of this.listeners)try{s(r)}catch{}}clear(){this.listeners.clear()}},cs="/_lunora/rpc",lr="/_lunora/rpc-batch",us="/_lunora/ws",ht=a(t=>t===void 0||t===""?"":`&bucket=${encodeURIComponent(t)}`,"L"),Le=a(t=>{for(let e=t.length-1;e>=0;e-=1)t[e]?.()},"E"),hs=a((t,e)=>{for(let r of e)r.op==="delete"?t.delete(r.key):r.value!==void 0&&t.set(r.key,r.value)},"le"),ds="lunora-ping",ls=3e4,fs=1e4,ps=250,ms=64,ys="/_lunora/admin/shard-traffic",bs="/_lunora/admin/scheduled",gs="/_lunora/admin/scheduled/status",vs="/_lunora/admin/scheduled/ws",Ss="/_lunora/admin/scheduled/cancel",ws="/_lunora/admin/scheduled/dead",Cs="/_lunora/admin/scheduled/dead/retry",ks="/_lunora/admin/scheduled/dead/cancel",Is="/_lunora/admin/workflows/instances",Es="/_lunora/admin/workflows/instance",Ts="/_lunora/admin/workflows/status",dt="/_lunora/admin/storage",Os="/_lunora/admin/storage/url",Rs="/_lunora/admin/storage/buckets",Ps="/_lunora/admin/functions",As="/_lunora/admin/cron-jobs",Fs="/_lunora/admin/cron-jobs/run",Ms="/_lunora/admin/openapi",xs="/_lunora/admin/openrpc",_s="/_lunora/admin/global/tables",Ls="/_lunora/admin/global/table",Qs="/_lunora/admin/global/facet",Ds="/_lunora/admin/vector/indexes",Us="/_lunora/admin/vector/query",qs="/_lunora/admin/logs/archive",Ns="/_lunora/admin/kv/namespaces",Ks="/_lunora/admin/kv/keys",lt="/_lunora/admin/kv/value",Bs="/_lunora/admin/auth/users",js="/_lunora/admin/auth/sessions",$s="/_lunora/admin/auth/users/create",Hs="/_lunora/admin/auth/users/role",zs="/_lunora/admin/auth/users/ban",Ws="/_lunora/admin/auth/users/unban",Vs="/_lunora/admin/auth/users/password",Gs="/_lunora/admin/auth/users/remove",Js="/_lunora/admin/auth/users/impersonate",Xs="/_lunora/admin/auth/sessions/revoke",Ys="/_lunora/admin/auth/sessions/revoke-all",Zs="/_lunora/admin/auth/capabilities",ei="/_lunora/admin/auth/users/update",ti="/_lunora/admin/auth/accounts",ri="/_lunora/admin/auth/accounts/unlink",si="/_lunora/admin/auth/passkeys",ii="/_lunora/admin/auth/passkeys/delete",ni="/_lunora/admin/auth/two-factor/disable",ai="/_lunora/admin/auth/organizations",oi="/_lunora/admin/auth/organizations/members",ci="/_lunora/admin/auth/organizations/invitations",ui="/_lunora/admin/auth/organizations/members/remove",hi="/_lunora/admin/auth/organizations/invitations/cancel",di="/_lunora/admin/auth/config",li="/_lunora/admin/auth/organizations/create",fi="/_lunora/admin/auth/organizations/update",pi="/_lunora/admin/auth/organizations/remove",mi="/_lunora/admin/auth/organizations/members/add",yi="/_lunora/admin/auth/organizations/members/invite",bi="/_lunora/admin/auth/organizations/members/role",gi="/_lunora/admin/auth/organizations/teams",vi="/_lunora/admin/auth/organizations/teams/create",Si="/_lunora/admin/auth/organizations/teams/update",wi="/_lunora/admin/auth/organizations/teams/remove",Ci="/_lunora/admin/auth/organizations/teams/members",ki="/_lunora/admin/auth/organizations/teams/members/add",Ii="/_lunora/admin/auth/organizations/teams/members/remove",Ei="/_lunora/admin/auth/organizations/roles",Ti="/_lunora/admin/auth/organizations/roles/create",Oi="/_lunora/admin/auth/organizations/roles/update",Ri="/_lunora/admin/auth/organizations/roles/remove",Pi="/api/auth",Ai="/get-session",fr=a(t=>t.startsWith("https://")?`wss://${t.slice(8)}`:t.startsWith("http://")?`ws://${t.slice(7)}`:t,"W"),V=a((t,e)=>`${t.endsWith("/")?t.slice(0,-1):t}${e}`,"k"),T=a((t,e)=>{let r=new URLSearchParams;for(let[i,n]of Object.entries(e))n!==void 0&&n!==""&&r.set(i,String(n));let s=r.toString();return s===""?t:`${t}?${s}`},"y"),Fi=[tr],C=a(t=>t??"","m"),mr=a((t,e)=>{let r=t.error,s=typeof r?.code=="string"?r.code:void 0,i=typeof r?.message=="string"?r.message:void 0;return{code:s,messageText:(typeof t.message=="string"?t.message:void 0)??i??e}},"$"),Mi=a(t=>{let{code:e,messageText:r}=mr(t,"stream error");return e===void 0?new Error(r):new p(e,r)},"Lt"),pr=a(t=>{let{code:e,messageText:r}=mr(t,"subscription error");return{message:r,...e===void 0?{}:{code:e}}},"q"),Qe=a((t,e)=>{for(let r of t)try{r(e)}catch{}},"A"),xi=new TextDecoder,_i=a(t=>{if(typeof t=="string")return t;if(t instanceof ArrayBuffer)return xi.decode(t)},"Ut"),F=a((t,e)=>{if(!t.socket||t.wsState!=="open")return!1;try{return t.socket.send(JSON.stringify(e)),!0}catch{return!1}},"S"),de=a(t=>{let e=new Error(t.message??"request failed");return e.code=t.code,t.data!==void 0&&(e.data=S(t.data)),t.hint!==void 0&&(e.hint=t.hint),t.docsUrl!==void 0&&(e.docsUrl=t.docsUrl),e},"_"),G=a((t,e)=>{try{return O(t)}catch(r){let s=r instanceof Error?r.message:String(r);throw new TypeError(`LunoraClient: cannot encode ${e} \u2014 ${s}`,r instanceof Error?{cause:r}:void 0)}},"v"),Li=a((t,e)=>{let r=Array.from({length:e});for(let s of t){if(typeof s.id!="number"||s.id<0||s.id>=e)continue;let i=s.body;r[s.id]=i&&"error"in i&&i.error?{error:de(i.error),ok:!1}:{ok:!0,value:S(i?.result)}}return r.map(s=>s??{error:new Error("batch call returned no result"),ok:!1})},"xt"),Qi=new Set(["SHARD_ERROR","SHARD_UNAVAILABLE"]),Di=Promise.resolve(),ft=class t{static{a(this,"Q")}static MAX_POKE_BUFFERS=256;static createClientQuery(e,r){return{defaultValue:r,key:e}}url;wsUrl;clientQueryStore;wsToken;authBasePath;fetchImpl;WebSocketImpl;bookmark;reconnectOptions;connectTimeoutMs;heartbeatIntervalMs;offlineQueue;outbox;clientId;shardCursors=new Map;defaultShardKey;readyResolved=!1;readyResolve;readyPromise;clientWatermarks=new Map;outboxMutationCounter=0;onPersistenceError;persistence;persistenceVersion;outboxLeaderRelease;queryCache;hydratedQueryCache=new Map;pendingCacheWrites=new Map;cacheFlushTimer;subscriptions=new _;tabCoordinator;leaderStatus;leaderWasEverConnected=!1;connections=new Map;defaultConnectionContext;connectionContexts=new Map;connectionContextHolders=new Map;authToken=null;authSubject=void 0;queuedIdentities=new Map;queuedOfflineShardKeys=new Set;closed=!1;authTokenListeners=new J;statusListeners=new J;tokenExpiredListeners=new J;mutationSettledListeners=new J;pendingChangeListeners=new J;whisperHandlers=new Map;lastStatus="idle";nextSubId=0;nextStreamId=0;streams=new Map;shapeSubscriptions=new Map;pokeBuffers=new Map;nextShapeId=0;constructor(e){this.url=e.url,this.wsUrl=e.wsUrl??V(fr(e.url),us),this.wsToken=e.wsToken;let r=e.authBasePath??Pi;this.authBasePath=r.endsWith("/")?r.slice(0,-1):r,this.fetchImpl=e.fetch??(typeof fetch=="function"?fetch.bind(globalThis):void 0),this.WebSocketImpl=e.WebSocket??(typeof WebSocket=="function"?WebSocket:void 0),this.bookmark=e.bookmarkStorage??Zt(),this.reconnectOptions=e.reconnect,this.heartbeatIntervalMs=e.heartbeatIntervalMs??ls,this.connectTimeoutMs=e.connectTimeoutMs??fs,this.defaultConnectionContext=e.connectionContext,this.persistence=hr(e.persistence,e.outbox===void 0),this.persistenceVersion=e.persistenceVersion,this.queryCache=Yt(e.queryCache),this.onPersistenceError=e.offlineQueue?.onPersistenceError,this.clientQueryStore=new Pe,e.crossTabSync?(this.tabCoordinator=this.createTabCoordinator(),this.tabCoordinator.start()):this.tabCoordinator=void 0,e.hydrateOnStart&&this.queryCache?this.readyPromise=new Promise(s=>{this.readyResolve=s}):(this.readyResolved=!0,this.readyPromise=Di),this.offlineQueue=new xe(e.offlineQueue,{onEvict:a((s,i)=>{this.emitItemSettled(s,"rejected",i)},"onEvict"),onSizeChange:a(s=>{this.pendingChangeListeners.emit(s)},"onSizeChange"),persistence:this.persistence,version:e.persistenceVersion}),this.outbox=e.outbox,this.clientId=e.clientId??`client-${_e()}`,this.persistence&&queueMicrotask(()=>{this.hydrateAsOutboxLeader()}),this.queryCache&&queueMicrotask(()=>{(async()=>{try{await this.hydrateQueryCache()}catch{}finally{this.readyResolved=!0,this.readyResolve?.()}})().catch(()=>{})})}setAuthToken(e,r){let s=this.authToken!==e,i=this.identityFingerprint();this.authToken=e,r!==void 0&&(this.authSubject=r);let n=this.identityFingerprint();if(n!==i&&(s?this.rejectQueuedForIdentityChange():(this.restampQueuedIdentity(i,n),this.restampWatermarks(i,n)),this.tabCoordinator)){let o=this.tabCoordinator.isLeader();this.tabCoordinator.stop(),this.tabCoordinator=this.createTabCoordinator(),this.tabCoordinator.start(),o&&this.tabCoordinator.promoteImmediately()}s&&this.authTokenListeners.emit(e)}getAuthToken(){return this.authToken}currentIdentity(){return this.identityFingerprint()}clientIdentifier(){return this.clientId}confirmedMutationWatermark(e){return this.clientWatermarks.get(this.identityFingerprint()??"")?.get(e??"")??0}async callMutator(e,r,s){let i=s?.clientSeq;if(i!==void 0&&(!Number.isInteger(i)||i<=0))throw new p("INTERNAL",`callMutator: clientSeq must be a positive integer, got ${String(i)}`);let n=s?.shardKey??"",o=this.identityFingerprint(),c,u=await this.rpc(e,r,s?.shardKey,{captureBookmark:!0,clientId:this.clientId,clientSeq:i,onMutationAck:a(h=>{c=h},"onMutationAck")});if(c!==void 0&&c>(this.clientWatermarks.get(o??"")?.get(n)??0)){let h=this.clientWatermarks.get(o??"");h===void 0&&(h=new Map,this.clientWatermarks.set(o??"",h)),h.set(n,c)}return{applied:c===void 0||c===i,result:u}}onAuthTokenChange(e){return this.authTokenListeners.add(e)}async getCurrentUser(){if(this.closed||!this.fetchImpl)return null;let e={};this.authToken&&(e.authorization=`Bearer ${this.authToken}`);try{let r=await this.fetchImpl(V(this.url,`${this.authBasePath}${Ai}`),{credentials:"include",headers:e,method:"GET"});return r.ok?(await r.json())?.user??null:null}catch{return null}}setWsToken(e){if(this.wsToken!==e){this.wsToken=e;for(let r of this.connections.values())if(r.socket)try{r.socket.close()}catch{}}}setConnectionContext(e,r={}){let s=C(r.shardKey);e===void 0?this.connectionContexts.delete(s):this.connectionContexts.set(s,e),this.refreshConnectionContext(s)}acquireConnectionContext(e,r={}){let s=C(r.shardKey),i={context:e},n=this.connectionContextHolders.get(s);n?n.push(i):this.connectionContextHolders.set(s,[i]),this.refreshConnectionContext(s);let o=!1;return()=>{if(o)return;o=!0;let c=this.connectionContextHolders.get(s);if(!c)return;let u=c.indexOf(i);u!==-1&&c.splice(u,1),c.length===0&&this.connectionContextHolders.delete(s),this.refreshConnectionContext(s)}}whisperSubscribe(e,r,s={}){let i=C(s.shardKey),n=this.whisperHandlers.get(i);n||(n=new Map,this.whisperHandlers.set(i,n));let o=n.get(e),c=o===void 0;if(o||(o=new Set,n.set(e,o)),o.add(r),this.ensureSocket(s.shardKey),c){let u=this.getConnection(s.shardKey);u&&F(u,{topic:e,type:"whisper_subscribe"})}return()=>{let u=this.whisperHandlers.get(i),h=u?.get(e);if(!h?.delete(r)||h.size>0)return;u?.delete(e),u?.size===0&&this.whisperHandlers.delete(i);let d=this.getConnection(s.shardKey);d&&F(d,{topic:e,type:"whisper_unsubscribe"})}}whisper(e,r,s={}){this.ensureSocket(s.shardKey);let i=this.getConnection(s.shardKey);i&&F(i,{data:G(r??null,`whisper data for topic '${e}'`),topic:e,type:"whisper"})}onTokenExpired(e){return this.tokenExpiredListeners.add(e)}connectionStatus(){return this.computeStatus()}onConnectionStatus(e){let r=this.statusListeners.add(e);return e(this.computeStatus()),r}pendingCount(){return this.offlineQueue.size}debug(){let e=[],r=this.clientWatermarks.get(this.identityFingerprint()??""),s=new Set([...this.connections.keys(),...r?.keys()??[]]);for(let n of s){let o=this.connections.get(n);e.push({confirmedMutationWatermark:r?.get(n)??0,hasSocket:o?.socket!==void 0,shardKey:n===""?void 0:n,wasEverConnected:o?.wasEverConnected??!1,wsState:o?.wsState??"idle"})}let i=this.subscriptions.all().map(n=>({acked:n.acked,functionPath:n.fn.__lunoraRef,id:n.id,kind:"query",lastMutationId:n.lastMutationId,pendingOptimisticLayers:n.optimisticLayers.length,serverCursor:n.serverCursor,shardKey:n.shardKey,subscriberCount:n.callbacks.size}));for(let n of this.shapeSubscriptions.values())i.push({acked:n.serverCursor!==void 0,functionPath:`shape:${n.name}`,id:n.id,kind:"shape",lastMutationId:n.lastMutationId,pendingOptimisticLayers:0,rowCount:n.rows.size,serverCursor:n.serverCursor,shardKey:n.shardKey,subscriberCount:n.callbacks.size});return{clientId:this.clientId,closed:this.closed,connectionStatus:this.computeStatus(),pendingWrites:this.offlineQueue.size,shards:e.toSorted((n,o)=>(n.shardKey??"").localeCompare(o.shardKey??"")),subscriptions:i.toSorted((n,o)=>n.functionPath.localeCompare(o.functionPath))}}onPendingChange(e){let r=this.pendingChangeListeners.add(e);return e(this.offlineQueue.size),r}onMutationSettled(e){return this.mutationSettledListeners.add(e)}getWebSocketImpl(){return this.WebSocketImpl}getClientQuery(e){return this.clientQueryStore.get(e)}setClientQuery(e,r){this.clientQueryStore.set(e,r)}subscribeClientQuery(e,r){return this.clientQueryStore.subscribe(e,r)}resetClientQuery(e){this.clientQueryStore.reset(e)}snapshotPrecondition(e,r,s){return dr(this,e,r,s)}whenReady(){return this.readyPromise}get isReady(){return this.readyResolved}peekHydratedQuery(e,r,s){if(!this.readyResolved)return;let i=B(r),n=Re(e,i,s),o=this.hydratedQueryCache.get(n);if(o!==void 0)return o.identity===this.identityFingerprint()?o.value:void 0}peekActiveQuerySnapshot(e,r,s){let i=_.key(e,r,s),n=this.subscriptions.get(i);return{present:n!==void 0,value:n?.lastValue}}async query(e,r,s={}){return this.assertOpen(),await this.rpc(e.__lunoraRef,r,s.shardKey,{attachBookmark:!0})}async batch(e){if(this.assertOpen(),!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");if(e.length===0)return[];let r=await this.fetchImpl(V(this.url,lr),{body:JSON.stringify({calls:e.map((n,o)=>({args:G(n.args??{},`args for batch call '${n.fn.__lunoraRef}'`),functionPath:n.fn.__lunoraRef,id:o,shardKey:n.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"}),s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let i;try{i=await r.json()}catch{throw new p("INTERNAL",`LunoraClient: batch response was not JSON (status ${r.status.toString()})`)}if(!r.ok||i.error&&!i.results)throw i.error?de(i.error):new p("INTERNAL",`LunoraClient: batch request failed (status ${r.status.toString()})`);for(let n of i.results??[]){let o=n.body?.commitCursor;typeof n.id=="number"&&typeof o=="number"&&this.recordShardCursor(e[n.id]?.shardKey,o)}return Li(i.results??[],e.length)}async mutation(e,r,s={}){this.assertOpen();let i=r,n=s.mutationId??_e(),{confirms:o,rollbacks:c}=this.applyOptimisticUpdates(e.__lunoraRef,i,s.shardKey,s.optimistic);s.optimisticUpdate&&this.applyOptimisticUpdate(s.optimisticUpdate,r,s.shardKey,c,o);let{hasSocket:u,wasEverConnected:h,wsState:d}=this.connectionGateState(s.shardKey),{queueBeforeFirstConnect:l}=this.offlineQueue,f=h||l,m=this.WebSocketImpl!==void 0&&f;if(d!=="open"&&!u&&m||d==="connecting"&&f)return this.enqueueOfflineMutation(e,i,s.shardKey,n,c,o,s.precondition);try{let y,b=await this.rpc(e.__lunoraRef,i,s.shardKey,{captureBookmark:!0,mutationId:n,onCommitCursor:a(w=>{y=w},"onCommitCursor")});for(let w of o)w(y);return b}catch(y){throw Le(c),y}}async action(e,r,s={}){return this.assertOpen(),await this.rpc(e.__lunoraRef,r,s.shardKey)}async importRows(e,r,s={}){this.assertOpen();let i=Math.max(1,Math.trunc(s.chunkSize??500)),n=s.toArgs??(h=>({rows:h})),o=r.length,c=0,u=0;for(let h=0;h<o;h+=i){let d=r.slice(h,h+i),l=u;await this.mutation(e,n(d),{...s.importId===void 0?{}:{mutationId:`${s.importId}:${String(l)}`},shardKey:s.shardKey}),u+=1,c+=d.length,s.onProgress?.({done:c,total:o})}return{chunks:u,imported:c}}async shardTraffic(e){this.assertOpen();let r=await this.adminFetch(ys,"POST",{table:e});return{failed:r.failed??0,ok:r.ok??0,shards:r.shards??[]}}async listScheduledJobs(){return this.assertOpen(),(await this.adminFetch(bs,"GET")).records??[]}async schedulerStatus(){this.assertOpen();let e=await this.adminFetch(gs,"GET");return{backlog:e.backlog??0,inFlight:e.inFlight??0,pools:e.pools??[]}}async cancelScheduledJob(e){return this.assertOpen(),{cancelled:(await this.adminFetch(Ss,"POST",{id:e})).cancelled===!0}}async listDeadJobs(){return this.assertOpen(),(await this.adminFetch(ws,"GET")).records??[]}async retryDeadJob(e){return this.assertOpen(),{retried:(await this.adminFetch(Cs,"POST",{id:e})).retried===!0}}async removeDeadJob(e){return this.assertOpen(),{removed:(await this.adminFetch(ks,"POST",{id:e})).removed===!0}}async listWorkflowInstances(e){this.assertOpen();let r=new URLSearchParams({name:e.name});e.status!==void 0&&r.set("status",e.status),e.page!==void 0&&r.set("page",String(e.page)),e.perPage!==void 0&&r.set("perPage",String(e.perPage));let s=await this.adminFetch(`${Is}?${r.toString()}`,"GET");return{configured:s.configured,instances:s.instances??[],page:s.page??1,perPage:s.perPage??e.perPage??0,totalCount:s.totalCount}}async getWorkflowInstance(e){this.assertOpen();let r=new URLSearchParams({id:e.id,name:e.name}),s=await this.adminFetch(`${Es}?${r.toString()}`,"GET");return{createdOn:s.createdOn,endedOn:s.endedOn,error:s.error,id:s.id??e.id,output:s.output,params:s.params,startedOn:s.startedOn,status:s.status??"unknown",steps:s.steps??[]}}async setWorkflowInstanceStatus(e){return this.assertOpen(),{status:(await this.adminFetch(Ts,"POST",{action:e.action,id:e.id,name:e.name})).status??"unknown"}}subscribeScheduledJobs(e){if(this.assertOpen(),this.WebSocketImpl===void 0)return()=>{};let r=V(fr(this.url),vs),s=ct(this.reconnectOptions),i={connectTimer:void 0,heartbeatTimer:void 0,lastFrameAt:0,socket:void 0},n,o=!1,c=a(()=>{o||(n=setTimeout(d,s.next()))},"a"),u=a(l=>{if(o||this.WebSocketImpl===void 0)return;let f=l===void 0?r:`${r}?token=${encodeURIComponent(l)}`;this.openManagedSocket(i,f,this.connectTimeoutMs,{onClose:a(()=>{c()},"onClose"),onMessage:a(m=>{try{let y=JSON.parse(typeof m.data=="string"?m.data:"");y.type==="jobs"&&Array.isArray(y.records)&&e(y.records)}catch{}},"onMessage"),onOpen:a(()=>{s.reset()},"onOpen")})},"o"),h=a(async l=>{let f;try{f=await l()}catch{c();return}u(f)},"c"),d=a(()=>{if(o||this.WebSocketImpl===void 0)return;let{wsToken:l}=this;if(typeof l=="function"){h(l).catch(()=>{});return}u(l)},"d");return d(),()=>{o=!0,n!==void 0&&clearTimeout(n),i.connectTimer!==void 0&&(clearTimeout(i.connectTimer),i.connectTimer=void 0),this.stopHeartbeat(i),i.socket?.close()}}async listFunctions(){return this.assertOpen(),(await this.adminFetch(Ps,"GET")).functions??[]}async getCronJobs(){return this.assertOpen(),(await this.adminFetch(As,"GET")).jobs??[]}async runCronJob(e){this.assertOpen();let r=await this.adminFetch(Fs,"POST",{name:e});return{name:r.name??e,ran:r.ran===!0}}async fetchOpenApi(){return this.assertOpen(),await this.adminFetch(Ms,"GET")}async fetchOpenRpc(){return this.assertOpen(),await this.adminFetch(xs,"GET")}async listStorageObjects(e={}){this.assertOpen();let r=T(dt,{bucket:e.bucket,cursor:e.cursor,limit:e.limit,prefix:e.prefix}),s=await this.adminFetch(r,"GET");return{cursor:s.cursor,objects:s.objects??[]}}async deleteStorageObject(e,r){this.assertOpen();let s=`${dt}?key=${encodeURIComponent(e)}${ht(r?.bucket)}`,i=await this.adminFetch(s,"DELETE");return{deleted:i.deleted??!0,key:i.key??e}}async listStorageBuckets(){return this.assertOpen(),(await this.adminFetch(Rs,"GET")).buckets??[]}async uploadStorageObject(e){this.assertOpen();let r=`${dt}?key=${encodeURIComponent(e.key)}${ht(e.bucket)}`,s=await this.adminFetch(r,"PUT",e.body,e.contentType);return{etag:s.etag,key:s.key??e.key}}async signedStorageUrl(e,r){this.assertOpen();let s=r?.expiresInSeconds,i=s===void 0?"":`&expiresIn=${encodeURIComponent(s.toString())}`,n=`${Os}?key=${encodeURIComponent(e)}${i}${ht(r?.bucket)}`,o=await this.adminFetch(n,"GET");if(typeof o.url!="string")throw new TypeError("LunoraClient: storage URL endpoint returned no `url`");return o.url}async listGlobalTables(){return this.assertOpen(),await this.adminFetch(_s,"GET")}async readGlobalTablePage(e){this.assertOpen();let r=new URLSearchParams({table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.offset!==void 0&&r.set("offset",String(e.offset)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${Ls}?${r.toString()}`,"GET")}async facetGlobalColumn(e){this.assertOpen();let r=new URLSearchParams({column:e.column,table:e.table});return e.limit!==void 0&&r.set("limit",String(e.limit)),e.filters!==void 0&&e.filters.length>0&&r.set("filters",JSON.stringify(e.filters)),await this.adminFetch(`${Qs}?${r.toString()}`,"GET")}async listVectorIndexes(){return this.assertOpen(),(await this.adminFetch(Ds,"GET")).indexes??[]}async queryVectorIndex(e){return this.assertOpen(),(await this.adminFetch(Us,"POST",e)).matches??[]}async queryLogArchive(e={}){this.assertOpen();let r=await this.adminFetch(qs,"POST",e);return{nextCursor:r.nextCursor,rows:r.rows??[]}}async listKvNamespaces(){return this.assertOpen(),(await this.adminFetch(Ns,"GET")).namespaces??[]}async listKvKeys(e){this.assertOpen();let r=T(Ks,{cursor:e.cursor,limit:e.limit,namespace:e.namespace,prefix:e.prefix});return await this.adminFetch(r,"GET")}async getKvValue(e){this.assertOpen();let r=T(lt,{key:e.key,namespace:e.namespace});return await this.adminFetch(r,"GET")}async putKvValue(e){this.assertOpen(),await this.adminFetch(lt,"PUT",e)}async deleteKvKey(e){this.assertOpen();let r=T(lt,{key:e.key,namespace:e.namespace});await this.adminFetch(r,"DELETE")}async listAuthUsers(e={}){this.assertOpen();let r=T(Bs,{filterField:e.filterField,filterValue:e.filterValue,limit:e.limit,offset:e.offset,search:e.search,searchField:e.searchField,sortBy:e.sortBy,sortDirection:e.sortDirection});return await this.adminFetch(r,"GET")}async createAuthUser(e){return await this.adminFetch($s,"POST",e)}async setAuthUserRole(e){return await this.adminFetch(Hs,"POST",e)}async banAuthUser(e){return await this.adminFetch(zs,"POST",e)}async unbanAuthUser(e){return await this.adminFetch(Ws,"POST",e)}async setAuthUserPassword(e){await this.adminFetch(Vs,"POST",e)}async removeAuthUser(e){await this.adminFetch(Gs,"POST",e)}async impersonateAuthUser(e){return await this.adminFetch(Js,"POST",e)}async revokeAuthSession(e){await this.adminFetch(Xs,"POST",e)}async revokeAuthUserSessions(e){await this.adminFetch(Ys,"POST",e)}async getAuthCapabilities(){return await this.adminFetch(Zs,"GET")}async updateAuthUser(e){return await this.adminFetch(ei,"POST",e)}async listAuthAccounts(e){return await this.adminFetch(T(ti,{userId:e.userId}),"GET")}async unlinkAuthAccount(e){await this.adminFetch(ri,"POST",e)}async listAuthPasskeys(e){return await this.adminFetch(T(si,{userId:e.userId}),"GET")}async deleteAuthPasskey(e){await this.adminFetch(ii,"POST",e)}async disableAuthTwoFactor(e){await this.adminFetch(ni,"POST",e)}async listAuthOrganizations(e={}){return await this.adminFetch(T(ai,{limit:e.limit,offset:e.offset}),"GET")}async listAuthOrgMembers(e){let r=T(oi,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async listAuthOrgInvitations(e){let r=T(ci,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async removeAuthOrgMember(e){await this.adminFetch(ui,"POST",e)}async cancelAuthOrgInvitation(e){await this.adminFetch(hi,"POST",e)}async getAuthConfig(){return await this.adminFetch(di,"GET")}async createAuthOrganization(e){return await this.adminFetch(li,"POST",e)}async updateAuthOrganization(e){return await this.adminFetch(fi,"POST",e)}async deleteAuthOrganization(e){await this.adminFetch(pi,"POST",e)}async addAuthOrgMember(e){return await this.adminFetch(mi,"POST",e)}async inviteAuthOrgMember(e){return await this.adminFetch(yi,"POST",e)}async setAuthOrgMemberRole(e){return await this.adminFetch(bi,"POST",e)}async listAuthOrgTeams(e){let r=T(gi,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgTeam(e){return await this.adminFetch(vi,"POST",e)}async updateAuthOrgTeam(e){return await this.adminFetch(Si,"POST",e)}async removeAuthOrgTeam(e){await this.adminFetch(wi,"POST",e)}async listAuthOrgTeamMembers(e){let r=T(Ci,{limit:e.limit,offset:e.offset,teamId:e.teamId});return await this.adminFetch(r,"GET")}async addAuthOrgTeamMember(e){return await this.adminFetch(ki,"POST",e)}async removeAuthOrgTeamMember(e){await this.adminFetch(Ii,"POST",e)}async listAuthOrgRoles(e){let r=T(Ei,{limit:e.limit,offset:e.offset,organizationId:e.organizationId});return await this.adminFetch(r,"GET")}async createAuthOrgRole(e){return await this.adminFetch(Ti,"POST",e)}async updateAuthOrgRole(e){return await this.adminFetch(Oi,"POST",e)}async deleteAuthOrgRole(e){await this.adminFetch(Ri,"POST",e)}async listAuthSessions(e={}){this.assertOpen();let r=T(js,{limit:e.limit,offset:e.offset,userId:e.userId});return await this.adminFetch(r,"GET")}subscribe(e,r,s,i={}){this.assertOpen();let n=r??{},o=_.key(e.__lunoraRef,n,i.shardKey),c=this.subscriptions.get(o),u=s,h=i.onError;if(!c){this.nextSubId+=1;let l=`sub_${this.nextSubId.toString()}`,f=B(n),m=this.takeHydratedCache(e.__lunoraRef,f,i.shardKey);c={acked:!1,args:n,argsKey:f,callbacks:new Set,checkpointCallbacks:new Set,errorCallbacks:new Set,fn:e,id:l,lastValue:m?.value,optimisticLayers:[],serverBase:m?.value,serverCursor:m?.serverCursor,shardKey:i.shardKey,...m?.serverEpoch===void 0?{}:{serverEpoch:m.serverEpoch}},this.subscriptions.add(c)}if(c.callbacks.add(u),h&&c.errorCallbacks.add(h),i.onCheckpoint&&c.checkpointCallbacks.add(i.onCheckpoint),c.lastValue!==void 0)try{u(c.lastValue)}catch{}this.ensureSocket(i.shardKey),this.sendSubscribeIfOpen(c);let d=c;return()=>{d.callbacks.delete(u),h&&d.errorCallbacks.delete(h),i.onCheckpoint&&d.checkpointCallbacks.delete(i.onCheckpoint),d.callbacks.size===0&&(this.sendOrQueueUnsubscribe(d.shardKey,d.id,"unsubscribe"),this.subscriptions.remove(d))}}subscribeShape(e,r,s={}){this.assertOpen(),this.nextShapeId+=1;let i=`shape_${this.nextShapeId.toString()}`,n={args:e.args,callbacks:new Set([r]),errorCallbacks:s.onError?new Set([s.onError]):new Set,id:i,name:e.name,onCheckpoint:s.onCheckpoint,rows:new Map,shardKey:s.shardKey,wireArgs:e.args===void 0?void 0:G(e.args,`shape args for '${e.name}'`)};return this.shapeSubscriptions.set(i,n),this.ensureSocket(s.shardKey),this.sendShapeSubscribeIfOpen(n),()=>{this.shapeSubscriptions.delete(i),this.sendOrQueueUnsubscribe(n.shardKey,i,"shape_unsubscribe")}}stream(e,r,s={}){if(this.assertOpen(),this.WebSocketImpl===void 0)throw new p("INTERNAL","LunoraClient: streams require a WebSocket implementation");this.nextStreamId+=1;let i=`stream_${this.nextStreamId.toString()}`,{shardKey:n}=s,o=r??{},{handle:c,iterable:u}=Fe({maxBuffer:s.maxBuffer,onCancel:a(()=>{let l=this.getConnection(n);l&&F(l,{id:i,type:"unsubscribe"}),this.streams.delete(i)},"onCancel")});this.ensureSocket(n);let h=this.getConnection(n),d={id:i,query:{args:G(o,`stream args for '${e.__lunoraRef}'`),functionPath:e.__lunoraRef,shardKey:n},type:"stream"};if(this.streams.set(i,{durable:s.durable===!0,handle:c,lastSeq:0,message:d,shardKey:n}),!(h?.wsState==="open"&&F(h,d))&&h){for(h.pendingStreams=h.pendingStreams??[];h.pendingStreams.length>=ms;){let l=h.pendingStreams.shift()?.id,f=l?this.streams.get(l):void 0;f&&(f.handle.fail(new p("STREAM_QUEUE_OVERFLOW","stream-start frame evicted while socket was unreachable")),this.streams.delete(l))}h.pendingStreams.push(d)}return u}httpStream(e,r,s={}){if(this.closed)throw new p("CLIENT_CLOSED","LunoraClient is closed");if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let i={...this.authToken?{authorization:`Bearer ${this.authToken}`}:{},...s.headers};return ar(e,r,{baseUrl:this.url,fetch:this.fetchImpl,headers:i,maxBuffer:s.maxBuffer,signal:s.signal})}close(){this.closed=!0,this.outboxLeaderRelease?.(),this.outboxLeaderRelease=void 0;for(let e of this.streams.values())e.handle.fail(new p("CLIENT_CLOSED","LunoraClient closed"));this.streams.clear();for(let e of this.connections.values())this.teardownConnection(e);this.offlineQueue.clear(),this.queuedIdentities.clear(),this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.size>0&&this.flushQueryCacheWrites().catch(()=>{}),this.authTokenListeners.clear(),this.statusListeners.clear(),this.tokenExpiredListeners.clear(),this.mutationSettledListeners.clear(),this.pendingChangeListeners.clear(),this.whisperHandlers.clear(),this.shapeSubscriptions.clear(),this.pokeBuffers.clear(),this.tabCoordinator?.stop(),this.tabCoordinator=void 0}assertOpen(){if(this.closed)throw new p("INTERNAL","LunoraClient is closed")}teardownConnection(e){if(e.reconnectTimer!==void 0&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=void 0),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),this.stopHeartbeat(e),e.socket){try{e.socket.close()}catch{}e.socket=void 0}e.wsState="closed"}createTabCoordinator(){let e=`lunora-bridge::${this.url}::${this.identityFingerprint()??"anon"}`;return new Ae({channelName:e,onBecomeLeader:a(()=>{for(let r of this.subscriptions.all())this.ensureSocket(r.shardKey),this.sendSubscribeIfOpen(r);this.tabCoordinator?.broadcastConnectionStatus(this.computeStatus(),this.identityFingerprint())},"onBecomeLeader"),onStopBeingLeader:a(()=>{for(let[r,s]of this.connections)this.teardownConnection(s),this.connections.delete(r);this.leaderStatus=void 0,this.leaderWasEverConnected=!1},"onStopBeingLeader"),onConnectionStatus:a((r,s)=>{if(s!==void 0&&s!==this.identityFingerprint())return;let i=r==="connected"&&this.leaderStatus!=="connected";this.leaderStatus=r,r==="connected"&&(this.leaderWasEverConnected=!0),this.emitConnectionStatus(),i&&this.flushAllOfflineQueues()},"onConnectionStatus"),onSubscriptionData:a((r,s,i,n,o)=>{if(o!==void 0&&o!==this.identityFingerprint())return;let c=this.subscriptions.get(r);c&&(c.serverBase=s,i!==void 0&&(c.serverCursor=i,n!==void 0&&(c.serverEpoch=n),Me(c,i)),te(c,he(s,c.optimisticLayers)))},"onSubscriptionData"),onSubscriptionError:a((r,s)=>{let i=this.subscriptions.get(r);i&&Qe(i.errorCallbacks,s)},"onSubscriptionError"),onSubscriptionSettled:a((r,s,i,n,o,c)=>{if(c!==void 0&&c!==this.identityFingerprint())return;let u=this.subscriptions.get(r);if(u){this.ackAndAdvanceCursor(u,s,i),n!==void 0&&o===this.clientId&&(u.lastMutationId=Math.max(u.lastMutationId??0,n));for(let h of u.checkpointCallbacks)h({checkpoint:u.serverCursor,mutationId:u.lastMutationId})}},"onSubscriptionSettled")})}async enqueueOfflineMutation(e,r,s,i,n,o,c){let u=this.identityFingerprint();if(this.outbox){this.outboxMutationCounter+=1;let h=this.outboxMutationCounter;try{await this.outbox.enqueue({args:r,clientId:this.clientId,functionPath:e.__lunoraRef,idempotencyKey:`${this.clientId}:${String(h)}`,identity:u,mutationId:h,shardKey:s})}catch(d){throw Le(n),d instanceof Error?d:new Error(String(d))}for(let d of o)d(void 0);return}return new Promise((h,d)=>{let l={args:r,functionPath:e.__lunoraRef,liveAwaiter:!0,id:i,clientId:this.clientId,identity:u,precondition:c,onCommit:a(f=>{for(let m of o)m(f)},"onCommit"),reject:a(f=>{this.queuedIdentities.delete(i),Le(n),d(f instanceof Error?f:new Error(String(f)))},"reject"),resolve:h,shardKey:s};this.offlineQueue.enqueue(l),this.queuedOfflineShardKeys.add(s),l.id!==void 0&&this.queuedIdentities.set(l.id,u)})}async hydratePersistedQueue(){try{let e=await this.offlineQueue.hydrate();for(let r of e)this.queuedOfflineShardKeys.add(r),this.ensureSocket(r)}catch{}}hydrateAsOutboxLeader(){let e=a(()=>{this.hydratePersistedQueue().catch(()=>{})},"e"),r=globalThis.navigator?.locks;if(!r){e();return}r.request(`lunora:outbox-leader:${this.url}`,()=>(this.closed||e(),new Promise(s=>{if(this.closed){s();return}this.outboxLeaderRelease=s}))).catch(e)}async hydrateQueryCache(){if(this.queryCache)try{let e=await this.queryCache.load();for(let{key:r,...s}of e){if(ot(this.persistenceVersion,s.version)){this.queryCache.remove(r).catch(()=>{});continue}this.hydratedQueryCache.set(r,s)}}catch{}}takeHydratedCache(e,r,s){let i=Re(e,r,s),n=this.hydratedQueryCache.get(i);if(n!==void 0)return this.hydratedQueryCache.delete(i),n.identity===this.identityFingerprint()?n:void 0}persistQueryValue(e){let r=e.serverBase;if(!this.queryCache||r===void 0)return;let s=Re(e.fn.__lunoraRef,e.argsKey,e.shardKey);this.pendingCacheWrites.set(s,{identity:this.identityFingerprint(),serverCursor:e.serverCursor,ts:Date.now(),value:r,...e.serverEpoch===void 0?{}:{serverEpoch:e.serverEpoch},...this.persistenceVersion===void 0?{}:{version:this.persistenceVersion}}),this.cacheFlushTimer??=setTimeout(()=>{this.flushQueryCacheWrites().catch(()=>{})},ps)}async flushQueryCacheWrites(){this.cacheFlushTimer=void 0;let{queryCache:e}=this;if(!e){this.pendingCacheWrites.clear();return}let r=[...this.pendingCacheWrites.entries()];this.pendingCacheWrites.clear(),await Promise.allSettled(r.map(async([s,i])=>e.put(s,i)))}computeStatus(){if(this.tabCoordinator&&!this.tabCoordinator.isLeader())return this.leaderStatus??"idle";let e=[...this.connections.values()];return e.length===0?"idle":e.some(r=>r.wsState==="open")?"connected":e.some(r=>r.wsState==="connecting")?"connecting":"offline"}emitConnectionStatus(){let e=this.computeStatus();e!==this.lastStatus&&(this.lastStatus=e,this.statusListeners.emit(e),this.tabCoordinator?.isLeader()&&this.tabCoordinator.broadcastConnectionStatus(e,this.identityFingerprint()))}emitItemSettled(e,r,s){this.mutationSettledListeners.emit({args:e.args,code:s===void 0?void 0:s.code,error:s,functionPath:e.functionPath,hadAwaiter:e.liveAwaiter??!1,id:e.id??"",shardKey:e.shardKey,status:r})}applyOptimisticUpdates(e,r,s,i){let n=[],o=[];if(!i)return{confirms:n,rollbacks:o};let c=_.key(e,r,s),u=this.subscriptions.get(c);if(u){let h=at(u,i);h&&(n.push(h.confirm),o.push(h.rollback))}return{confirms:n,rollbacks:o}}applyOptimisticUpdate(e,r,s,i,n){let{confirms:o,rollbacks:c,store:u}=or(this.subscriptions,s);try{e(u,r)}catch{Le(c);return}i.push(...c),n.push(...o)}getConnection(e){return this.connections.get(C(e))}sendOrQueueUnsubscribe(e,r,s){let i=this.getConnection(e);i&&!F(i,{id:r,type:s})&&i.pendingUnsubscribes.push({id:r,type:s})}connectionGateState(e){if(this.tabCoordinator&&!this.tabCoordinator.isLeader()){let s="idle";return this.leaderStatus==="connected"?s="open":this.leaderStatus==="connecting"&&(s="connecting"),{hasSocket:!1,wasEverConnected:this.leaderWasEverConnected,wsState:s}}let r=this.getConnection(e);return{hasSocket:r?.socket!==void 0,wasEverConnected:r?.wasEverConnected??!1,wsState:r?.wsState??"idle"}}getOrCreateConnection(e){let r=C(e),s=this.connections.get(r);return s||(s={connectTimer:void 0,heartbeatTimer:void 0,lastFrameAt:0,pendingUnsubscribes:[],reconnect:ct(this.reconnectOptions),reconnectTimer:void 0,shardKey:e,socket:void 0,wasEverConnected:!1,wsState:"idle"},this.connections.set(r,s)),s}wsUrlFor(e,r){let s=[];if(e!==void 0&&s.push(`shard=${encodeURIComponent(e)}`),r!==void 0&&s.push(`token=${encodeURIComponent(r)}`),s.length===0)return this.wsUrl;let i=this.wsUrl.includes("?")?"&":"?";return`${this.wsUrl}${i}${s.join("&")}`}rpcRequestHeaders(e,r){let s={"content-type":"application/json"},i=this.shardCursors.get(this.cursorKeyFor(r));if(i!==void 0&&(s["x-lunora-min-seq"]=i.toString()),this.authToken&&(s.authorization=`Bearer ${this.authToken}`),e.mutationId&&(s["x-lunora-mutation-id"]=e.mutationId),(e.clientId!==void 0||e.mutationId!==void 0)&&(s["x-lunora-client-id"]=e.clientId??this.clientId),e.clientSeq!==void 0&&(s["x-lunora-client-seq"]=e.clientSeq.toString()),e.attachBookmark){let n=this.bookmark.get();n&&(s["x-d1-bookmark"]=n)}return s}async rpc(e,r,s,i={}){if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let n=this.rpcRequestHeaders(i,s),o=await this.fetchImpl(V(this.url,cs),{body:JSON.stringify({args:G(r,`args for '${e}'`),functionPath:e,shardKey:s}),headers:n,method:"POST"});if(i.captureBookmark){let u=o.headers.get("x-d1-bookmark");u&&this.bookmark.set(u)}let c;try{c=await o.json()}catch{let u=o.statusText?` ${o.statusText}`:"";throw new p("INTERNAL",`LunoraClient: response was not JSON (status ${o.status.toString()}${u})`)}if("error"in c)throw de(c.error);if(!o.ok){let u=o.statusText?` ${o.statusText}`:"";throw new p("INTERNAL",`LunoraClient: request failed (status ${o.status.toString()}${u})`)}return i.onMutationAck?.(c.lastMutationId),i.onCommitCursor?.(c.commitCursor),this.learnDefaultShardKey(o,s),this.recordShardCursor(s,c.commitCursor),S(c.result)}async adminFetch(e,r,s,i){if(!this.fetchImpl)throw new p("INTERNAL","LunoraClient: no `fetch` implementation available");let n={};this.authToken&&(n.authorization=`Bearer ${this.authToken}`);let o=s instanceof ArrayBuffer||s instanceof Blob,c;s===void 0?c=void 0:o?(c=s,i!==void 0&&(n["content-type"]=i)):(c=JSON.stringify(s),n["content-type"]="application/json");let u=await this.fetchImpl(V(this.url,e),{body:c,headers:n,method:r}),h;try{h=await u.json()}catch{let d=u.statusText?` ${u.statusText}`:"";throw new p("INTERNAL",`LunoraClient: response was not JSON (status ${u.status.toString()}${d})`)}if(typeof h=="object"&&h!==null&&"error"in h){let d=h.error,l=new Error(d.message??"admin request failed");throw l.code=d.code,l}if(!u.ok){let d=u.statusText?` ${u.statusText}`:"";throw new p("INTERNAL",`LunoraClient: admin request failed (status ${u.status.toString()}${d})`)}return h}effectiveConnectionContext(e){let r=this.connectionContextHolders.get(e);return r&&r.length>0?r[r.length-1]?.context:this.connectionContexts.get(e)??this.defaultConnectionContext}refreshConnectionContext(e){let r=this.connections.get(e);r?.wsState==="open"&&this.sendConnectEnvelope(r)}sendConnectEnvelope(e){let r=this.effectiveConnectionContext(C(e.shardKey));F(e,{caps:Fi,clientId:this.clientId,id:"connect",type:"connect",...r===void 0?{}:{context:r}})}resendShapeSubscriptions(e){for(let r of this.shapeSubscriptions.values())C(r.shardKey)===C(e)&&this.sendShapeSubscribeIfOpen(r)}ensureSocket(e){if(this.closed||this.WebSocketImpl===void 0||this.tabCoordinator&&!this.tabCoordinator.isLeader())return;let r=this.getOrCreateConnection(e);if(!(r.wsState==="open"||r.wsState==="connecting")){if(r.wsState="connecting",this.emitConnectionStatus(),typeof this.wsToken=="function"){this.openSocketWithProvidedToken(r,e,this.wsToken).catch(()=>{});return}this.openSocket(r,e,this.wsToken)}}async openSocketWithProvidedToken(e,r,s){let i;try{i=await s()}catch{this.handleDisconnect(e);return}this.closed||this.WebSocketImpl===void 0||e.wsState!=="connecting"||e.socket!==void 0||this.openSocket(e,r,i)}openManagedSocket(e,r,s,i){let{WebSocketImpl:n}=this;if(n===void 0)throw new p("INTERNAL","no WebSocket implementation available");let o=new n(r);e.socket=o;let c=a(()=>{this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket===o&&(e.socket=void 0)},"a"),u=a(h=>{c(),i.onClose(h)},"o");s>0&&(e.connectTimer=setTimeout(()=>{if(e.connectTimer=void 0,e.socket===o){try{o.close()}catch{}u()}},s)),o.addEventListener("open",()=>{e.socket===o&&(e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.lastFrameAt=Date.now(),i.onOpen(),this.startHeartbeat(e,u))}),o.addEventListener("message",h=>{e.socket===o&&(e.lastFrameAt=Date.now(),i.onMessage(h))}),o.addEventListener("close",h=>{e.socket===o&&u(h)}),o.addEventListener("error",()=>{e.socket===o&&u()})}openSocket(e,r,s){this.WebSocketImpl!==void 0&&this.openManagedSocket(e,this.wsUrlFor(r,s),this.connectTimeoutMs,{onClose:a(i=>{i?.code===4001&&this.notifyTokenExpired(),this.handleDisconnect(e)},"onClose"),onMessage:a(i=>{this.handleServerMessage(i.data,r)},"onMessage"),onOpen:a(()=>{e.wsState="open",e.wasEverConnected=!0,e.reconnect.reset(),this.emitConnectionStatus(),this.sendConnectEnvelope(e),this.markShardPendingAck(r);for(let n of this.subscriptions.all())C(n.shardKey)===C(r)&&this.sendSubscribeIfOpen(n);if(this.resendShapeSubscriptions(r),e.pendingUnsubscribes.length>0){let n=e.pendingUnsubscribes;e.pendingUnsubscribes=[];for(let{id:o,type:c}of n)F(e,{id:o,type:c})}if(e.pendingStreams&&e.pendingStreams.length>0){let n=e.pendingStreams;e.pendingStreams=[];for(let o of n)F(e,o)}let i=this.whisperHandlers.get(C(r));if(i)for(let n of i.keys())F(e,{topic:n,type:"whisper_subscribe"});this.flushOfflineQueue(r).catch(()=>{})},"onOpen")})}handleDisconnect(e){if(this.closed||e.wsState==="idle"||e.wsState==="closed")return;this.stopHeartbeat(e),e.connectTimer!==void 0&&(clearTimeout(e.connectTimer),e.connectTimer=void 0),e.socket=void 0,e.wsState="idle",this.emitConnectionStatus(),this.markShardPendingAck(e.shardKey);let r=new Set((e.pendingStreams??[]).map(i=>i.id));for(let[i,n]of this.streams)if(!(C(n.shardKey)!==C(e.shardKey)||r.has(i))){if(n.durable){let o={...n.message,sinceChunk:n.lastSeq};n.message=o,e.pendingStreams=[...(e.pendingStreams??[]).filter(c=>c.id!==i),o];continue}n.handle.fail(new p("STREAM_DISCONNECTED","stream terminated: WebSocket disconnected")),this.streams.delete(i)}if(this.WebSocketImpl===void 0)return;let s=e.reconnect.next();e.reconnectTimer=setTimeout(()=>{e.reconnectTimer=void 0,this.ensureSocket(e.shardKey)},s)}startHeartbeat(e,r){this.stopHeartbeat(e),!(this.heartbeatIntervalMs<=0)&&(e.heartbeatTimer=setInterval(()=>{if(!e.socket)return;let{socket:s}=e;if(Date.now()-e.lastFrameAt>this.heartbeatIntervalMs*2.5){try{s.close()}catch{}r();return}try{s.send(ds)}catch{}},this.heartbeatIntervalMs))}stopHeartbeat(e){e.heartbeatTimer!==void 0&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=void 0)}markShardPendingAck(e){let r=C(e);for(let s of this.subscriptions.all())C(s.shardKey)===r&&(s.acked=!1)}sendSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);if(r?.wsState!=="open"||e.acked)return;let s=e.fn.__lunoraTable??e.fn.__lunoraRef;F(r,{id:e.id,query:{args:O(e.args),functionPath:e.fn.__lunoraRef,table:s,...e.serverCursor===void 0?{}:{sinceSeq:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}},type:"subscribe"})}sendShapeSubscribeIfOpen(e){let r=this.getConnection(e.shardKey);r?.wsState==="open"&&F(r,{id:e.id,shape:{name:e.name,...e.wireArgs===void 0?{}:{args:e.wireArgs}},type:"shape_subscribe",...e.serverCursor===void 0?{}:{sinceCheckpoint:e.serverCursor},...e.serverEpoch===void 0?{}:{sinceEpoch:e.serverEpoch}})}handleServerMessage(e,r){let s=_i(e);if(s===void 0)return;let i;try{i=JSON.parse(s)}catch{return}switch(i.type){case"ack":{let n=this.subscriptions.getById(i.id);n&&(n.acked=!0);return}case"chunk":{let{data:n,id:o,seq:c}=i,u=this.streams.get(o);u&&typeof c=="number"&&(u.lastSeq=c,u.durable=!0),u?.handle.push(S(n));return}case"complete":{this.handleCompleteMessage(i.id);return}case"data":case"delta":{this.handleDataMessage(i);return}case"error":{this.handleErrorMessage(i);break}case"pokeEnd":{this.handlePokeEnd(i);break}case"pokePart":{this.handlePokePart(i);break}case"pokeStart":{this.handlePokeStart(i);break}case"resume":{this.handleResumeMessage(i);break}case"settled":{this.handleSettledMessage(i);break}case"whisper":{this.dispatchWhisper(i,r);break}}}handleErrorMessage(e){if(e.error?.code==="TOKEN_EXPIRED"){this.notifyTokenExpired();return}let{id:r}=e,s=r===void 0?void 0:this.streams.get(r);if(s&&r!==void 0){s.handle.fail(Mi(e)),this.streams.delete(r);return}let i=r===void 0?void 0:this.subscriptions.getById(r);if(i){Qe(i.errorCallbacks,pr(e));return}let n=r===void 0?void 0:this.shapeSubscriptions.get(r);n&&Qe(n.errorCallbacks,pr(e))}handlePokeStart(e){os(this.pokeBuffers,t.MAX_POKE_BUFFERS),this.pokeBuffers.set(e.pokeId,{baseCheckpoint:e.baseCheckpoint,epoch:e.epoch,lastMutationId:new Map,parts:new Map})}handlePokePart(e){let r=this.pokeBuffers.get(e.pokeId);if(!r)return;let s=r.parts.get(e.shapeId)??[];for(let i of e.rowsPatch)s.push(i.value===void 0?i:{...i,value:S(i.value)});r.parts.set(e.shapeId,s),e.lastMutationId!==void 0&&r.lastMutationId.set(e.shapeId,e.lastMutationId)}handlePokeEnd(e){let r=this.pokeBuffers.get(e.pokeId);if(r){this.pokeBuffers.delete(e.pokeId);for(let[s,i]of r.parts){let n=this.shapeSubscriptions.get(s);if(!n)continue;let o=r.epoch!==void 0&&n.serverEpoch!==void 0&&r.epoch!==n.serverEpoch,c=r.baseCheckpoint!==void 0&&n.serverCursor!==void 0&&n.serverCursor!==r.baseCheckpoint;if(o||c){n.rows.clear(),n.serverCursor=void 0,n.serverEpoch=void 0,this.emitShapeRows(n),this.sendShapeSubscribeIfOpen(n);continue}hs(n.rows,i),e.checkpoint!==void 0&&(n.serverCursor=e.checkpoint),e.epoch!==void 0&&(n.serverEpoch=e.epoch);let u=r.lastMutationId.get(s);u!==void 0&&(n.lastMutationId=u),this.emitShapeRows(n),n.onCheckpoint?.({checkpoint:n.serverCursor,mutationId:n.lastMutationId})}}}emitShapeRows(e){let r=[...e.rows.values()];for(let s of e.callbacks)try{s(r)}catch{}}handleDataMessage(e){let{id:r}=e,s=r?this.subscriptions.getById(r):void 0;if(!s)return;let i=this.resolveDataPayload(e,s);if(s.serverBase=i,e.cursor!==void 0&&(s.serverCursor=e.cursor),e.epoch!==void 0&&(s.serverEpoch=e.epoch),e.lastMutationId!==void 0){s.lastMutationId=Math.max(s.lastMutationId??0,e.lastMutationId);for(let n of s.checkpointCallbacks)n({checkpoint:s.serverCursor,mutationId:s.lastMutationId})}if(this.persistQueryValue(s),Me(s,s.serverCursor),te(s,he(i,s.optimisticLayers)),this.tabCoordinator?.isLeader()){let n=_.key(s.fn.__lunoraRef,s.args,s.shardKey);this.tabCoordinator.broadcastSubscriptionData(n,i,s.serverCursor,s.serverEpoch,this.identityFingerprint())}}handleResumeMessage(e){let r=this.subscriptions.getById(e.id);r&&this.ackAndAdvanceCursor(r,e.cursor,e.epoch)}handleSettledMessage(e){let r=this.subscriptions.getById(e.id);if(r){this.ackAndAdvanceCursor(r,e.cursor,e.epoch),e.lastMutationId!==void 0&&(r.lastMutationId=e.lastMutationId);for(let s of r.checkpointCallbacks)s({checkpoint:r.serverCursor,mutationId:r.lastMutationId});if(this.tabCoordinator?.isLeader()){let s=_.key(r.fn.__lunoraRef,r.args,r.shardKey);this.tabCoordinator.broadcastSubscriptionSettled(s,r.serverCursor,r.serverEpoch,r.lastMutationId,this.clientId,this.identityFingerprint())}}}ackAndAdvanceCursor(e,r,s){e.acked=!0,(r!==void 0&&r!==e.serverCursor||s!==void 0&&s!==e.serverEpoch)&&(r!==void 0&&(e.serverCursor=r),s!==void 0&&(e.serverEpoch=s),this.persistQueryValue(e),Me(e,e.serverCursor)&&te(e,he(e.serverBase,e.optimisticLayers)))}resolveDataPayload(e,r){if("data"in e&&e.data!==void 0)return S(e.data);let s=S(e.delta);if(rr(s)&&r.serverBase!==void 0){let i=sr(r.serverBase,s);if(i!==void 0)return i}return s}dispatchWhisper(e,r){let s=this.whisperHandlers.get(C(r))?.get(e.topic);if(!s)return;let i=S(e.data);for(let n of s)try{n(i,e.from)}catch{}}notifyTokenExpired(){this.tokenExpiredListeners.emit()}handleCompleteMessage(e){let r=this.streams.get(e);if(r){r.handle.complete(),this.streams.delete(e);return}let s=this.subscriptions.getById(e);s&&(s.acked=!1,Qe(s.errorCallbacks,{code:"SUBSCRIPTION_CANCELLED",message:"subscription was cancelled by the server"}))}unpersist(e){e&&this.persistence?.remove(e).catch(r=>{re(this.onPersistenceError,"remove",r,e)})}identityFingerprint(){if(this.authSubject!==void 0)return this.authSubject===null?null:`subj:${this.authSubject}`;let e=this.authToken;return e===null?null:this.hashToken(e)}hashToken(e){let r=2166136261,s=5381;for(let i=0;i<e.length;i+=1){let n=e.charCodeAt(i);r^=n,r=Math.imul(r,16777619),s=Math.imul(s,33)+n}return`${e.length.toString(36)}:${(r>>>0).toString(36)}:${(s>>>0).toString(36)}`}isSameCredentialUnderTokenHash(e){if(e===null||e.startsWith("subj:"))return!1;let r=this.authToken;return r===null?!1:this.hashToken(r)===e}rejectQueuedForIdentityChange(){let e=this.offlineQueue.drain();for(let r of e){this.queuedIdentities.delete(r.id??""),this.unpersist(r.id);let s=new Error("offline mutation discarded: auth identity changed before replay");s.code="OFFLINE_IDENTITY_CHANGED",r.reject(s),this.emitItemSettled(r,"rejected",s)}this.clearQueryCacheForIdentityChange()}restampQueuedIdentity(e,r){for(let[s,i]of this.queuedIdentities)i===e&&this.queuedIdentities.set(s,r)}restampWatermarks(e,r){let s=e??"",i=this.clientWatermarks.get(s);if(i===void 0)return;this.clientWatermarks.delete(s);let n=r??"",o=this.clientWatermarks.get(n);if(o===void 0)this.clientWatermarks.set(n,i);else for(let[c,u]of i)o.set(c,u)}clearQueryCacheForIdentityChange(){this.cacheFlushTimer!==void 0&&(clearTimeout(this.cacheFlushTimer),this.cacheFlushTimer=void 0),this.pendingCacheWrites.clear(),this.hydratedQueryCache.clear(),this.queryCache?.clear().catch(()=>{})}flushAllOfflineQueues(){for(let e of this.queuedOfflineShardKeys)this.flushOfflineQueue(e).catch(()=>{})}async flushOfflineQueue(e){let r=this.offlineQueue.drainConflict();for(let h of r){this.unpersist(h.id),this.queuedIdentities.delete(h.id??"");let d=new Error("offline mutation skipped: precondition failed before replay");d.code="OFFLINE_PRECONDITION_FAILED",this.emitItemSettled(h,"rejected",d)}let s=C(e),i=this.offlineQueue.drain(h=>C(h.shardKey)===s);if(i.length===0)return;let n=this.identityFingerprint(),o=[];for(let h of i)this.passesReplayIdentityGate(h,n)&&o.push(h);if(o.length===0)return;let c=this.encodableOrSettleTerminal(o);if(c.length===0)return;if(c.length===1){await this.replaySequential(c);return}let u=[];for(let h=0;h<c.length;h+=ut){let d=c.slice(h,h+ut),l=await this.replayBatched(d);if(u.push(...l.requeue),l.stop){u.push(...c.slice(h+ut));break}}u.length>0&&this.offlineQueue.requeue(u)}encodableOrSettleTerminal(e){let r=[];for(let s of e)try{G(s.args,`args for '${s.functionPath}'`),r.push(s)}catch(i){this.settleReplayTerminal(s,i instanceof Error?i:new Error(String(i)))}return r}passesReplayIdentityGate(e,r){let s=e.id===void 0?void 0:this.queuedIdentities.get(e.id),i=s===void 0?e.identity:s;if(i!==void 0&&i!==r&&!this.isSameCredentialUnderTokenHash(i)){this.queuedIdentities.delete(e.id??""),this.unpersist(e.id);let n=new Error("offline mutation skipped: auth identity changed before replay");return n.code="OFFLINE_IDENTITY_CHANGED",e.reject(n),this.emitItemSettled(e,"rejected",n),!1}return this.queuedIdentities.delete(e.id??""),!0}settleReplaySuccess(e,r,s){this.unpersist(e.id),this.recordShardCursor(e.shardKey,s),e.onCommit?.(s),e.resolve(r),this.emitItemSettled(e,"committed")}cursorKeyFor(e){return e??this.defaultShardKey??""}learnDefaultShardKey(e,r){let s=e.headers.get("x-lunora-shard-key");if(s===null||r!==void 0||this.defaultShardKey===s)return;this.defaultShardKey=s;let i=this.shardCursors.get("");i!==void 0&&(this.shardCursors.set(s,Math.max(this.shardCursors.get(s)??0,i)),this.shardCursors.delete(""))}recordShardCursor(e,r){if(typeof r!="number")return;let s=this.cursorKeyFor(e);this.shardCursors.set(s,Math.max(this.shardCursors.get(s)??0,r))}settleReplayTerminal(e,r){this.unpersist(e.id),e.reject(r),this.emitItemSettled(e,"rejected",r)}async replaySequential(e){for(let r=0;r<e.length;r+=1){let s=e[r];if(s)try{let i,n=await this.rpc(s.functionPath,s.args,s.shardKey,{captureBookmark:!0,clientId:s.clientId??this.clientId,mutationId:s.id,onCommitCursor:a(o=>{i=o},"onCommitCursor")});this.settleReplaySuccess(s,n,i)}catch(i){if(i.code!==void 0){this.settleReplayTerminal(s,i);continue}this.offlineQueue.requeue(e.slice(r));return}}}async replayBatched(e){if(!this.fetchImpl)return{requeue:e,stop:!0};let r;try{r=await this.fetchImpl(V(this.url,lr),{body:JSON.stringify({calls:e.map((n,o)=>({args:G(n.args,`args for '${n.functionPath}'`),functionPath:n.functionPath,id:o,clientId:n.clientId??this.clientId,mutationId:n.id,shardKey:n.shardKey}))}),headers:this.rpcRequestHeaders({attachBookmark:!0}),method:"POST"})}catch{return{requeue:e,stop:!0}}let s=r.headers.get("x-d1-bookmark");s&&this.bookmark.set(s);let i;try{i=await r.json()}catch{return{requeue:e,stop:!0}}if(!i.results){if(i.error){let n=de(i.error);for(let o of e)this.settleReplayTerminal(o,n);return{requeue:[],stop:!1}}return{requeue:e,stop:!0}}return{requeue:this.settleReplayBatchSlots(e,i.results),stop:!1}}settleReplayBatchSlots(e,r){let s=new Map;for(let n of r)typeof n.id=="number"&&n.body!==void 0&&s.set(n.id,n.body);let i=[];for(let[n,o]of e.entries()){let c=s.get(n);c===void 0?i.push(o):"error"in c?Qi.has(c.error.code)?i.push(o):this.settleReplayTerminal(o,de(c.error)):this.settleReplaySuccess(o,S(c.result),c.commitCursor)}return i}};var yr=P(mt(),1),br=P(H(),1);var Ui=a(()=>{let t=(0,yr.c)(4),e=Ye(),r,s,i;return t[0]!==e?(r=a(n=>e.onConnectionStatus(()=>{n()}),"o"),s=a(()=>e.connectionStatus(),"e"),i=a(()=>e.connectionStatus(),"c"),t[0]=e,t[1]=r,t[2]=s,t[3]=i):(r=t[1],s=t[2],i=t[3]),(0,br.useSyncExternalStore)(r,s,i)},"S");export{ft as a,Cr as b,Ve as c,xr as d,Lr as e,Ye as f,Ui as g};
@@ -0,0 +1 @@
1
+ import{a as c,d as p,e as b,f as v}from"./chunk-R5ZTCHCE.js";var h=p(v(),1),g=p(b(),1);var y=c((a="local")=>{try{return a==="local"?globalThis.localStorage:globalThis.sessionStorage}catch{return}},"d"),S=c(function(a,s="local"){try{let r=y(s)?.getItem(a)??void 0,t=r===void 0?[]:JSON.parse(r);return Array.isArray(t)?t:[]}catch{return[]}},"g"),I=c((a,s,r="local")=>{let t=y(r);if(t!==void 0)try{t.setItem(a,JSON.stringify(s))}catch{}},"I"),A=c((a,s="local")=>{try{y(s)?.removeItem(a)}catch{}},"A"),T=c(function(a,s){let r=(0,h.c)(10),t=s===void 0?"local":s,u;r[0]!==a||r[1]!==t?(u=c(()=>S(a,t),"i"),r[0]=a,r[1]=t,r[2]=u):u=r[2];let[n,f]=(0,g.useState)(u),i=(0,g.useRef)(`${t}:${a}`),e,l;r[3]!==a||r[4]!==t||r[5]!==n?(e=c(()=>{let m=`${t}:${a}`;if(i.current!==m){i.current=m,f(S(a,t));return}I(a,n,t)},"c"),l=[a,t,n],r[3]=a,r[4]=t,r[5]=n,r[6]=e,r[7]=l):(e=r[6],l=r[7]),(0,g.useEffect)(e,l);let o;return r[8]!==n?(o=[n,f],r[8]=n,r[9]=o):o=r[9],o},"J"),J=c(function(a,s,r){let t=(0,h.c)(6),u="local",[n,f]=T(a,u),i;t[0]!==s||t[1]!==f?(i=c(m=>{f($=>{let d=$[0]??s;return[typeof m=="function"?m(d):m]})},"a"),t[0]=s,t[1]=f,t[2]=i):i=t[2];let e=i,l=n[0]??s,o;return t[3]!==e||t[4]!==l?(o=[l,e],t[3]=e,t[4]=l,t[5]=o):o=t[5],o},"O"),O=c(a=>globalThis.crypto?.randomUUID?.()??`${a}-${globalThis.performance.now().toString(36)}`,"V");export{y as a,S as b,I as c,A as d,T as e,J as f,O as g};
@@ -0,0 +1 @@
1
+ import{a as f}from"./chunk-IYWVSMAY.js";import{a as u,d as x,f as h,g as N}from"./chunk-R5ZTCHCE.js";var b=x(h(),1);var t=x(N(),1);var v=u(g=>{let e=(0,b.c)(16),{chart:c,footer:n,label:i,testId:m,value:p}=g,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==m||e[3]!==p?(a=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":m,children:p}),e[2]=m,e[3]=p,e[4]=a):a=e[4];let s;e[5]!==c||e[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,c]}),e[5]=c,e[6]=a,e[7]=s):s=e[7];let l;e[8]!==r||e[9]!==s?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[r,s]}),e[8]=r,e[9]=s,e[10]=l):l=e[10];let o;e[11]!==n?(o=n!=null&&(0,t.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}),e[11]=n,e[12]=o):o=e[12];let d;return e[13]!==l||e[14]!==o?(d=(0,t.jsxs)(f,{className:"justify-between gap-0 py-0",children:[l,o]}),e[13]=l,e[14]=o,e[15]=d):d=e[15],d},"j");export{v as a};
@@ -0,0 +1 @@
1
+ import{a as q,b as Eo}from"./chunk-DUDQV6XJ.js";import{a as ho,c as Ro}from"./chunk-VZCS5GXZ.js";import{A as Ke,B as Ne,D as fo,E as Ct,F as pt,H as mo,I as Rr,J as po,K as go,N as te,O as fe,d as yt,h as Ce,i as co,j as Zt,k as en,l as gr,m as Cn,n as ke,o as B,p as Te,q as bt,r as Pn,s as lo,t as Bt,u as hr,v as tn,w as ao,x as nn,z as uo}from"./chunk-AOAJGSYZ.js";import{a as us,b as fs}from"./chunk-INQICZYC.js";import{a as wn}from"./chunk-TFMQSCGC.js";import{a as V,c as X,d as Ae,e as Pe,f as mt,g as oo,h as ee,i as ye,j as Vt,k as Jt,l as io,m as On,n as dr,o as so,p as mr,q as xt,r as We,s as Qt,t as Ot,u as Wt,v as pr,w as re}from"./chunk-XQS7KSHL.js";import{c as no,d as Qe,e as fr,f as vn,g as Sn,h as ro,i as ct,j as Tn}from"./chunk-7PIHTTND.js";import{a as i,d as ne,e as he,g as Ht}from"./chunk-R5ZTCHCE.js";function ze(e){e.preventDefault(),e.stopPropagation()}i(ze,"stopEvent");function yo(e){return"nativeEvent"in e}i(yo,"isReactEvent");function In(e){return e.pointerType===""&&e.isTrusted?!0:Ce.os.android&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}i(In,"isVirtualClick");function Yt(e){return Ce.env.jsdom?!1:!Ce.os.android&&e.width===0&&e.height===0||Ce.os.android&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}i(Yt,"isVirtualPointerEvent");function tt(e,t){let n=["mouse","pen"];return t||n.push("",void 0),n.includes(e)}i(tt,"isMouseLikePointerType");function xo(e){let t=e.type;return t==="click"||t==="mousedown"||t==="keydown"||t==="keyup"}i(xo,"isClickLikeEvent");var wt=Math.min,nt=Math.max,on=Math.round,sn=Math.floor,lt=i(e=>({x:e,y:e}),"createCoords"),ds={left:"right",right:"left",bottom:"top",top:"bottom"};function An(e,t,n){return nt(e,wt(t,n))}i(An,"clamp");function at(e,t){return typeof e=="function"?e(t):e}i(at,"evaluate");function Ye(e){return e.split("-")[0]}i(Ye,"getSide");function rt(e){return e.split("-")[1]}i(rt,"getAlignment");function kn(e){return e==="x"?"y":"x"}i(kn,"getOppositeAxis");function cn(e){return e==="y"?"height":"width"}i(cn,"getAxisLength");function $e(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}i($e,"getSideAxis");function ln(e){return kn($e(e))}i(ln,"getAlignmentAxis");function vo(e,t,n){n===void 0&&(n=!1);let r=rt(e),o=ln(e),s=cn(o),c=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(c=rn(c)),[c,rn(c)]}i(vo,"getAlignmentSides");function So(e){let t=rn(e);return[Mn(e),t,Mn(t)]}i(So,"getExpandedPlacements");function Mn(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}i(Mn,"getOppositeAlignmentPlacement");var bo=["left","right"],wo=["right","left"],ms=["top","bottom"],ps=["bottom","top"];function gs(e,t,n){switch(e){case"top":case"bottom":return n?t?wo:bo:t?bo:wo;case"left":case"right":return t?ms:ps;default:return[]}}i(gs,"getSideList");function To(e,t,n,r){let o=rt(e),s=gs(Ye(e),n==="start",r);return o&&(s=s.map(c=>c+"-"+o),t&&(s=s.concat(s.map(Mn)))),s}i(To,"getOppositeAxisPlacements");function rn(e){let t=Ye(e);return ds[t]+e.slice(t.length)}i(rn,"getOppositePlacement");function hs(e){var t,n,r,o;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(r=e.bottom)!=null?r:0,left:(o=e.left)!=null?o:0}}i(hs,"expandPaddingObject");function Fn(e){return typeof e!="number"?hs(e):{top:e,right:e,bottom:e,left:e}}i(Fn,"getPaddingObject");function Pt(e){let{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}i(Pt,"rectToClientRect");function Rs(e,t){return t!=null&&!tt(t)?0:typeof e=="function"?e():e}i(Rs,"resolveValue");function gt(e,t,n){let r=Rs(e,n);return typeof r=="number"?r:r?.[t]}i(gt,"getDelay");function Er(e){return typeof e=="function"?e():e}i(Er,"getRestMs");function Dn(e,t){return t||e==="click"||e==="mousedown"}i(Dn,"isClickLikeOpenEvent");function Oo(e){return e?.includes("mouse")&&e!=="mousedown"}i(Oo,"isHoverOpenEvent");var Be=ne(he(),1);var Co=ne(Ht(),1);var Po=Be.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Ke,currentIdRef:{current:null},currentContextRef:{current:null}});function Es(e,t){e.current=t.current}i(Es,"resetDelayRef");function ys(e){let{children:t,delay:n,timeoutMs:r=0}=e,o=Be.useRef(n),s=Be.useRef(n),c=Be.useRef(null),l=Be.useRef(null),d=Ne();return V(()=>{if(s.current=n,!c.current){o.current=n;return}o.current={open:gt(o.current,"open"),close:gt(n,"close")}},[n,c,o,s]),(0,Co.jsx)(Po.Provider,{value:Be.useMemo(()=>({hasProvider:!0,delayRef:o,initialDelayRef:s,currentIdRef:c,timeoutMs:r,currentContextRef:l,timeout:d}),[r,d]),children:t})}i(ys,"FloatingDelayGroup");function xs(e,t={open:!1}){let{open:n}=t,r="rootStore"in e?e.rootStore:e,o=r.useState("floatingId"),s=Be.useContext(Po),{currentIdRef:c,delayRef:l,timeoutMs:d,initialDelayRef:a,currentContextRef:f,hasProvider:g,timeout:u}=s,[m,R]=Be.useState(!1),p=Be.useRef(n);return V(()=>{p.current=n},[n]),V(()=>{function h(){f.current?.setIsInstantPhase(!1),c.current=null,f.current=null,l.current=a.current,u.clear()}if(i(h,"unset"),!!c.current&&!n&&c.current===o){if(R(!1),d){let E=o;return u.start(d,()=>{r.select("open")||c.current&&c.current!==E||h()}),()=>{(p.current||c.current!==E)&&u.clear()}}h()}},[n,o,c,l,d,a,f,u,r]),V(()=>{if(!n)return;let h=f.current,E=c.current;u.clear(),f.current={onOpenChange:r.setOpen,setIsInstantPhase:R},c.current=o,l.current={open:0,close:gt(a.current,"close")},E!==null&&E!==o?(R(!0),h?.setIsInstantPhase(!0),h?.onOpenChange(!1,fe(te.none))):(R(!1),h?.setIsInstantPhase(!1))},[n,o,r,c,l,a,f,u]),V(()=>()=>{if(c.current===o){if(f.current=null,!p.current)return;c.current=null,Es(l,a),u.clear()}},[f,c,l,o,a,u]),Be.useMemo(()=>({hasProvider:g,delayRef:l,isInstantPhase:m}),[g,l,m])}i(xs,"useDelayGroup");function Oe(e){let t=Qe(bs,e).current;return t.next=e,V(t.effect),t}i(Oe,"useValueAsRef");function bs(e){let t={current:e,next:e,effect:i(()=>{t.current=t.next},"effect")};return t}i(bs,"createLatestRef");var Ln=ne(he(),1);var Io=ne(Ht(),1);var $t=Ln.forwardRef(i(function(t,n){let[r,o]=Ln.useState();return V(()=>{Ce.screenReader.voiceOver&&Ce.engine.webkit&&o("button")},[]),(0,Io.jsx)("span",{...t,ref:n,style:ho,"aria-hidden":r?void 0:!0,...{tabIndex:0,role:r},"data-base-ui-focus-guard":""})},"FocusGuard"));var Mo={style:{transition:"none"}},Ao="data-base-ui-click-trigger",ws="data-base-ui-swipe-ignore",vs="data-swipe-ignore",Il=`[${ws}]`,Ml=`[${vs}]`,Al={fallbackAxisSide:"none"},kl={fallbackAxisSide:"end"},ko={clipPath:"inset(50%)",position:"fixed",top:0,left:0};var we=ne(he(),1),Or=ne(wn(),1);function _e(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}i(_e,"mergeCleanups");function yr(e,t){return t<0||t>=e.length}i(yr,"isIndexOutOfListBounds");function Nn(e,t){return It(e.current,{disabledIndices:t})}i(Nn,"getMinListIndex");function xr(e,t){return It(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}i(xr,"getMaxListIndex");function It(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:o=1}={}){let s=t;do s+=n?-o:o;while(s>=0&&s<=e.length-1&&br(e,s,r));return s}i(It,"findNonDisabledListIndex");function br(e,t,n){if(typeof n=="function"?n(t):n?.includes(t)??!1)return!0;let o=e[t];return o?!Mt(o)||o.matches(":disabled")?!0:!n&&(o.hasAttribute("disabled")||o.getAttribute("aria-disabled")==="true"):!1}i(br,"isListIndexDisabled");function Ss(e){return e.visibility==="hidden"||e.visibility==="collapse"}i(Ss,"isHiddenByStyles");function Mt(e,t=e?We(e):null){return!e||!e.isConnected||!t||Ss(t)?!1:typeof e.checkVisibility=="function"?e.checkVisibility():t.display!=="none"&&t.display!=="contents"}i(Mt,"isElementVisible");var Ts='a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';function Os(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return Vt(n)?n.host:null}i(Os,"getParentElement");function vr(e){for(let t of Array.from(e.children))if(Ae(t)==="summary")return t;return null}i(vr,"getDetailsSummary");function Cs(e,t){let n=vr(t);return!!n&&(e===n||B(n,e))}i(Cs,"isWithinOpenDetailsSummary");function Fo(e){let t=e?Ae(e):"";return e!=null&&e.matches(Ts)&&(t!=="summary"||e.parentElement!=null&&Ae(e.parentElement)==="details"&&vr(e.parentElement)===e)&&(t!=="details"||vr(e)==null)&&(t!=="input"||e.type!=="hidden")}i(Fo,"isFocusableCandidate");function Do(e){if(!Fo(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=Os(t)){let n=t!==e,r=Ae(t)==="slot";if(t.hasAttribute("inert")||n&&Ae(t)==="details"&&!t.open&&!Cs(e,t)||t.hasAttribute("hidden")||!r&&!Ps(t,n))return!1}return!0}i(Do,"isFocusableElement");function Ps(e,t){let n=We(e);return t?n.display!=="none":Mt(e,n)}i(Ps,"isVisibleInTabbableTree");function Lo(e){let t=e.tabIndex;if(t<0){let n=Ae(e);if(n==="details"||n==="audio"||n==="video"||ye(e)&&e.isContentEditable)return 0}return t}i(Lo,"getTabIndex");function wr(e){if(Ae(e)!=="input")return null;let t=e;return t.type==="radio"&&t.name!==""?t:null}i(wr,"getNamedRadioInput");function Is(e,t){let n=wr(e);if(!n)return!0;let r=t.find(o=>{let s=wr(o);return s?.name===n.name&&s.form===n.form&&s.checked});return r?r===n:t.find(o=>{let s=wr(o);return s?.name===n.name&&s.form===n.form})===n}i(Is,"isTabbableRadio");function No(e){if(ye(e)&&Ae(e)==="slot"){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return ye(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}i(No,"getComposedChildren");function _o(e,t){No(e).forEach(n=>{Fo(n)&&t.push(n),_o(n,t)})}i(_o,"appendCandidates");function Ho(e,t,n){No(e).forEach(r=>{ye(r)&&r.matches(t)&&n.push(r),Ho(r,t,n)})}i(Ho,"appendMatchingElements");function _n(e){return Do(e)&&Lo(e)>=0}i(_n,"isTabbable");function Sr(e){let t=[];return _o(e,t),t.filter(Do)}i(Sr,"focusable");function Gt(e){let t=Sr(e);return t.filter(n=>Lo(n)>=0&&Is(n,t))}i(Gt,"tabbable");function Vo(e,t){let n=Gt(e),r=n.length;if(r===0)return;let o=ke(re(e)),s=n.indexOf(o),c=s===-1?t===1?0:r-1:s+t;return n[c]}i(Vo,"getTabbableIn");function Hn(e){return Vo(re(e).body,1)||e}i(Hn,"getNextTabbable");function Vn(e){return Vo(re(e).body,-1)||e}i(Vn,"getPreviousTabbable");function Wo(e,t){if(!e)return null;let n=Gt(re(e).body),r=n.length;if(r===0)return null;let o=n.indexOf(e);if(o===-1)return null;let s=(o+t+r)%r;return n[s]}i(Wo,"getTabbableNearElement");function $l(e){return Wo(e,1)}i($l,"getTabbableAfterElement");function Gl(e){return Wo(e,-1)}i(Gl,"getTabbableBeforeElement");function At(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!B(n,r)}i(At,"isOutsideEvent");function Bo(e){Gt(e).forEach(n=>{n.dataset.tabindex=n.getAttribute("tabindex")||"",n.setAttribute("tabindex","-1")})}i(Bo,"disableFocusInside");function Tr(e){let t=[];Ho(e,"[data-tabindex]",t),t.forEach(n=>{let r=n.dataset.tabindex;delete n.dataset.tabindex,r?n.setAttribute("tabindex",r):n.removeAttribute("tabindex")})}i(Tr,"enableFocusInside");function ht(e){return`data-base-ui-${e}`}i(ht,"createAttribute");var kt=ne(Ht(),1);var Yo=we.createContext(null),Cr=i(()=>we.useContext(Yo),"usePortalContext"),Ms=ht("portal");function $o(e={}){let{ref:t,container:n,componentProps:r=ct,elementProps:o}=e,s=yt(),l=Cr()?.portalNode,[d,a]=we.useState(null),[f,g]=we.useState(null),u=X(h=>{h!==null&&g(h)}),m=we.useRef(null);V(()=>{if(n===null){m.current&&(m.current=null,g(null),a(null));return}let h=(n&&(oo(n)?n:n.current))??l??document.body;if(h==null){m.current&&(m.current=null,g(null),a(null));return}m.current!==h&&(m.current=h,g(null),a(h))},[n,l]);let R=Tn("div",r,{ref:[t,u],props:[{id:s,[Ms]:""},o]}),p=d&&R?Or.createPortal(R,d):null;return{node:f,nodeId:we.isValidElement(R)?R.props.id:void 0,subtree:p}}i($o,"useFloatingPortalNode");var As=we.forwardRef(i(function(t,n){let{render:r,className:o,style:s,children:c,container:l,...d}=t,{node:a,nodeId:f,subtree:g}=$o({container:l,ref:n,componentProps:t,elementProps:d}),u=we.useRef(null),m=we.useRef(null),R=we.useRef(null),p=we.useRef(null),[h,E]=we.useState(null),y=we.useRef(!1),x=h?.modal,b=h?.open,T=!!h&&!h.modal&&h.open&&!!a;we.useEffect(()=>{if(!a||x)return;function v(O){a&&O.relatedTarget&&At(O)&&(O.type==="focusin"?y.current&&(Tr(a),y.current=!1):(Bo(a),y.current=!0))}return i(v,"onFocus"),_e(q(a,"focusin",v,!0),q(a,"focusout",v,!0))},[a,x]),V(()=>{!a||b!==!0||!y.current||(Tr(a),y.current=!1)},[b,a]);let P=we.useMemo(()=>({beforeOutsideRef:u,afterOutsideRef:m,beforeInsideRef:R,afterInsideRef:p,portalNode:a,setFocusManagerState:E}),[a]);return(0,kt.jsxs)(we.Fragment,{children:[g,(0,kt.jsxs)(Yo.Provider,{value:P,children:[T&&a&&(0,kt.jsx)($t,{"data-type":"outside",ref:u,onFocus:i(v=>{if(At(v,a))R.current?.focus();else{let O=h?h.domReference:null;Vn(O)?.focus()}},"onFocus")}),T&&a&&(0,kt.jsx)("span",{"aria-owns":f,style:ko}),a&&Or.createPortal(c,a),T&&a&&(0,kt.jsx)($t,{"data-type":"outside",ref:m,onFocus:i(v=>{if(At(v,a))p.current?.focus();else{let O=h?h.domReference:null;Hn(O)?.focus(),h?.closeOnFocusOut&&h?.onOpenChange(!1,fe(te.focusOut,v.nativeEvent))}},"onFocus")})]})]})},"FloatingPortal"));var vt=ne(he(),1);function Wn(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(r=>r(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}i(Wn,"createEventEmitter");var Bn=class{static{i(this,"FloatingTreeStore")}nodesRef={current:[]};events=Wn();addNode(t){this.nodesRef.current.push(t)}removeNode(t){let n=this.nodesRef.current.findIndex(r=>r===t);n!==-1&&this.nodesRef.current.splice(n,1)}};var Pr=ne(Ht(),1);var Go=vt.createContext(null),Xo=vt.createContext(null),ot=i(()=>vt.useContext(Go)?.id||null,"useFloatingParentNodeId"),Ge=i(e=>{let t=vt.useContext(Xo);return e??t},"useFloatingTree");function ks(e){let t=yt(),n=Ge(e),r=ot();return V(()=>{if(!t)return;let o={id:t,parentId:r};return n?.addNode(o),()=>{n?.removeNode(o)}},[n,t,r]),t}i(ks,"useFloatingNodeId");function Fs(e){let{children:t,id:n}=e,r=ot();return(0,Pr.jsx)(Go.Provider,{value:vt.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}i(Fs,"FloatingNode");function Ds(e){let{children:t,externalTree:n}=e,r=Qe(()=>n??new Bn).current;return(0,Pr.jsx)(Xo.Provider,{value:r,children:t})}i(Ds,"FloatingTree");var He=ne(he(),1);function Ze(e,t,n=!0){return e.filter(o=>o.parentId===t).flatMap(o=>[...!n||o.context?.open?[o]:[],...Ze(e,o.id,n)])}i(Ze,"getNodeChildren");function Ir(e,t){let n=[],r=e.find(o=>o.id===t)?.parentId;for(;r;){let o=e.find(s=>s.id===r);r=o?.parentId,o&&(n=n.concat(o))}return n}i(Ir,"getNodeAncestors");var Yn=0;function Xt(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:o}=t;cancelAnimationFrame(Yn);function s(){o&&!o()||e?.focus({preventScroll:n})}if(i(s,"exec"),r)return s(),Sn;let c=requestAnimationFrame(s);return Yn=c,()=>{Yn===c&&(cancelAnimationFrame(c),Yn=0)}}i(Xt,"enqueueFocus");var Mr={inert:new WeakMap,"aria-hidden":new WeakMap},Uo="data-base-ui-inert",kr={inert:new WeakSet,"aria-hidden":new WeakSet},an=new WeakMap,Ar=0;function Ls(e){return kr[e]}i(Ls,"getUncontrolledElementsSet");function qo(e){return e?Vt(e)?e.host:qo(e.parentNode):null}i(qo,"unwrapHost");var Ko=i((e,t)=>t.map(n=>{if(e.contains(n))return n;let r=qo(n);return e.contains(r)?r:null}).filter(n=>n!=null),"correctElements"),zo=i(e=>{let t=new Set;return e.forEach(n=>{let r=n;for(;r&&!t.has(r);)t.add(r),r=r.parentNode}),t},"buildKeepSet"),jo=i((e,t,n)=>{let r=[],o=i(s=>{!s||n.has(s)||Array.from(s.children).forEach(c=>{Ae(c)!=="script"&&(t.has(c)?o(c):r.push(c))})},"walk");return o(e),r},"collectOutsideElements");function Ns(e,t,n,r,{mark:o=!0}){let s=null;r?s="inert":n&&(s="aria-hidden");let c=null,l=null,d=Ko(t,e),a=o?jo(t,zo(d),new Set(d)):[],f=[],g=[];if(s){let u=Mr[s],m=Ls(s);l=m,c=u;let R=Ko(t,Array.from(t.querySelectorAll("[aria-live]"))),p=d.concat(R);jo(t,zo(p),new Set(p)).forEach(E=>{let y=E.getAttribute(s),x=y!==null&&y!=="false",b=(u.get(E)||0)+1;u.set(E,b),f.push(E),b===1&&x&&m.add(E),x||E.setAttribute(s,s==="inert"?"":"true")})}return o&&a.forEach(u=>{let m=(an.get(u)||0)+1;an.set(u,m),g.push(u),m===1&&u.setAttribute(Uo,"")}),Ar+=1,()=>{c&&f.forEach(u=>{let R=(c.get(u)||0)-1;c.set(u,R),R||(!l?.has(u)&&s&&u.removeAttribute(s),l?.delete(u))}),o&&g.forEach(u=>{let m=(an.get(u)||0)-1;an.set(u,m),m||u.removeAttribute(Uo)}),Ar-=1,Ar||(Mr.inert=new WeakMap,Mr["aria-hidden"]=new WeakMap,kr.inert=new WeakSet,kr["aria-hidden"]=new WeakSet,an=new WeakMap)}}i(Ns,"applyAttributeToOthers");function Fr(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:o=!0}=t,s=re(e[0]).body;return Ns(e,s,n,r,{mark:o})}i(Fr,"markOthers");var un=ne(Ht(),1);function _s(e,t){let n=Pe(Te(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(e.detail===0?"keyboard":"mouse"):""}i(_s,"getEventType");var Jo=20,St=[];function Dr(){St=St.filter(e=>e.deref()?.isConnected)}i(Dr,"clearDisconnectedPreviouslyFocusedElements");function Qo(e){Dr(),e&&Ae(e)!=="body"&&(St.push(new WeakRef(e)),St.length>Jo&&(St=St.slice(-Jo)))}i(Qo,"addPreviouslyFocusedElement");function Zo(){return Dr(),St[St.length-1]?.deref()}i(Zo,"getPreviouslyFocusedElement");function Hs(e){return e?_n(e)?e:Gt(e)[0]||e:null}i(Hs,"getFirstTabbableElement");function ei(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex")||!e.getAttribute("role")?.includes("dialog"))return;let n=Sr(e).filter(o=>{let s=o.getAttribute("data-tabindex")||"";return _n(o)||o.hasAttribute("data-tabindex")&&!s.startsWith("-")}),r=e.getAttribute("tabindex");n.length===0?r!=="0"&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):(r!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}i(ei,"handleTabIndex");function Vs(e){let{context:t,children:n,disabled:r=!1,initialFocus:o=!0,returnFocus:s=!0,restoreFocus:c=!1,modal:l=!0,closeOnFocusOut:d=!0,openInteractionType:a="",nextFocusableElement:f,previousFocusableElement:g,beforeContentFocusGuardRef:u,externalTree:m,getInsideElements:R}=e,p="rootStore"in t?t.rootStore:t,h=p.useState("open"),E=p.useState("domReferenceElement"),y=p.useState("floatingElement"),{events:x,dataRef:b}=p.context,T=X(()=>b.current.floatingContext?.nodeId),P=o===!1,v=tn(E)&&P,O=Oe(o),A=Oe(s),N=Oe(a),G=Oe(h),Y=Ge(m),L=Cr(),M=He.useRef(!1),I=He.useRef(!1),_=He.useRef(!1),F=He.useRef(null),C=He.useRef(""),W=He.useRef(""),Q=He.useRef(null),Z=He.useRef(null),D=fr(Q,u,L?.beforeInsideRef),$=fr(Z,L?.afterInsideRef),z=Ne(),ce=Ne(),j=Ct(),xe=L!=null,H=nn(y),ie=X((J=H)=>J?Gt(J):[]),ae=X(()=>R?.().filter(J=>J!=null)??[]);He.useEffect(()=>{if(r||!l)return;function J(Ee){Ee.key==="Tab"&&B(H,ke(re(H)))&&ie().length===0&&!v&&ze(Ee)}i(J,"onKeyDown");let me=re(H);return q(me,"keydown",J)},[r,H,l,v,ie]),He.useEffect(()=>{if(r||!h)return;let J=re(H);function me(){_.current=!1}i(me,"clearPointerDownOutside");function Ee(ve){let U=Te(ve),ue=ae(),K=B(y,U)||B(E,U)||B(L?.portalNode,U)||ue.some(pe=>pe===U||B(pe,U));_.current=!K,W.current=ve.pointerType||"keyboard",U?.closest(`[${Ao}]`)&&(I.current=!0,ce.start(0,()=>{I.current=!1}))}i(Ee,"onPointerDown");function ge(){W.current="keyboard"}return i(ge,"onKeyDown"),_e(q(J,"pointerdown",Ee,!0),q(J,"pointerup",me,!0),q(J,"pointercancel",me,!0),q(J,"keydown",ge,!0),me)},[r,y,E,H,h,L,ce,ae]),He.useEffect(()=>{if(r||!d)return;let J=re(H);function me(){I.current=!0,ce.start(0,()=>{I.current=!1})}i(me,"handlePointerDown");function Ee(ue){let K=Te(ue);_n(K)&&(F.current=K)}i(Ee,"handleFocusIn");function ge(ue){let K=ue.relatedTarget,pe=ue.currentTarget,be=Te(ue);l&&K==null&&be!=null&&B(y,be)&&Qo(be),queueMicrotask(()=>{let le=T(),Me=p.context.triggerElements,w=ae(),S=K?.hasAttribute(ht("focus-guard"))&&[Q.current,Z.current,L?.beforeInsideRef.current,L?.afterInsideRef.current,L?.beforeOutsideRef.current,L?.afterOutsideRef.current,pt(g),pt(f)].includes(K),se=!(B(E,K)||B(y,K)||B(K,y)||B(L?.portalNode,K)||w.some(k=>k===K||B(k,K))||Me.hasMatchingElement(k=>B(k,K))||S||Y&&(Ze(Y.nodesRef.current,le).find(k=>B(k.context?.elements.floating,K)||B(k.context?.elements.domReference,K))||Ir(Y.nodesRef.current,le).find(k=>[k.context?.elements.floating,nn(k.context?.elements.floating)].includes(K)||k.context?.elements.domReference===K)));if(pe===E&&H&&ei(H),c&&pe!==E&&!Mt(be)&&ke(J)===J.body){if(ye(H)&&(H.focus(),c==="popup")){j.request(()=>{H.focus()});return}let k=ie(),oe=F.current,Fe=(oe&&k.includes(oe)?oe:null)||k[k.length-1]||H;ye(Fe)&&Fe.focus()}if(b.current.insideReactTree){b.current.insideReactTree=!1;return}(v||!l)&&K&&se&&!I.current&&(v||K!==Zo())&&(M.current=!0,p.setOpen(!1,fe(te.focusOut,ue)))})}i(ge,"handleFocusOutside");function ve(){_.current||(b.current.insideReactTree=!0,z.start(0,()=>{b.current.insideReactTree=!1}))}i(ve,"markInsideReactTree");let U=ye(E)?E:null;if(!(!y&&!U))return _e(U&&q(U,"focusout",ge),U&&q(U,"pointerdown",me),y&&q(y,"focusin",Ee),y&&q(y,"focusout",ge),y&&L&&q(y,"focusout",ve,!0))},[r,E,y,H,l,Y,L,p,d,c,ie,v,T,b,z,ce,j,f,g,ae]),He.useEffect(()=>{if(r||!y||!h)return;let J=Array.from(L?.portalNode?.querySelectorAll(`[${ht("portal")}]`)||[]),Ee=(Y?Ir(Y.nodesRef.current,T()):[]).find(pe=>tn(pe.context?.elements.domReference||null))?.context?.elements.domReference,ve=[...[y,...J,Q.current,Z.current,L?.beforeOutsideRef.current,L?.afterOutsideRef.current,...ae()],Ee,pt(g),pt(f),v?E:null].filter(pe=>pe!=null),U=Fr(ve,{ariaHidden:l||v,mark:!1}),ue=[y,...J].filter(pe=>pe!=null),K=Fr(ue);return()=>{K(),U()}},[h,r,E,y,l,L,v,Y,T,f,g,ae]),V(()=>{if(!h||r||!ye(H))return;C.current="",W.current="";let J=re(H),me=ke(J);queueMicrotask(()=>{let Ee=O.current,ge=typeof Ee=="function"?Ee(N.current||""):Ee;if(ge===void 0||ge===!1||B(H,me))return;let U=null,ue=i(()=>(U==null&&(U=ie(H)),U[0]||H),"getDefaultFocusElement"),K;ge===!0||ge===null?K=ue():K=pt(ge),K=K||ue();let pe=B(H,ke(J));Xt(K,{preventScroll:K===H,shouldFocus(){if(!G.current)return!1;if(pe)return!0;let be=ke(J);return!(be!==K&&B(H,be))}})})},[r,h,H,ie,O,N,G]),V(()=>{if(r||!H)return;let J=re(H),me=ke(J),Ee=N.current==null;Qo(me);function ge(U){if(U.open||(C.current=_s(U.nativeEvent,W.current)),U.reason===te.triggerHover&&U.nativeEvent.type==="mouseleave"&&(M.current=!0),U.reason===te.outsidePress)if(U.nested)M.current=!1;else if(In(U.nativeEvent)||Yt(U.nativeEvent))M.current=!1;else{let ue=!1;re(H).createElement("div").focus({get preventScroll(){return ue=!0,!1}}),ue?M.current=!1:M.current=!0}}i(ge,"onOpenChangeLocal"),x.on("openchange",ge);function ve(U){let ue=A.current,K=typeof ue=="function"?ue(U):ue;if(K===void 0||K===!1)return null;K===null&&(K=!0);let pe=E?.isConnected?E:null,be=me?.isConnected&&Ae(me)!=="body"?me:null,le=Ee?be||pe:pe||be;return le||(le=Zo()||null),typeof K=="boolean"?le:pt(K)||le||null}return i(ve,"getReturnElement"),()=>{x.off("openchange",ge);let U=ke(J),ue=ae(),K=B(y,U)||ue.some(Me=>Me===U||B(Me,U))||Y&&Ze(Y.nodesRef.current,T(),!1).some(Me=>B(Me.context?.elements.floating,U)),pe=A.current,be=C.current,le=ve(be);queueMicrotask(()=>{let Me=Hs(le),w=typeof pe!="boolean";if(pe&&!M.current&&ye(Me)&&(!(!w&&Me!==U&&U!==J.body)||K)){let S={preventScroll:!0};be==="keyboard"&&(S.focusVisible=!0),Me.focus(S)}M.current=!1})}},[r,y,H,A,N,x,Y,E,T,ae]),V(()=>{if(!Ce.engine.webkit||h||!y)return;let J=ke(re(y));!ye(J)||!Bt(J)||B(y,J)&&J.blur()},[h,y]),V(()=>{if(!(r||!L))return L.setFocusManagerState({modal:l,closeOnFocusOut:d,open:h,onOpenChange:p.setOpen,domReference:E}),()=>{L.setFocusManagerState(null)}},[r,L,l,h,p,d,E]),V(()=>{if(!(r||!H))return ei(H),()=>{queueMicrotask(Dr)}},[r,H]);let Se=!r&&(l?!v:!0)&&(xe||l);return(0,un.jsxs)(He.Fragment,{children:[Se&&(0,un.jsx)($t,{"data-type":"inside",ref:D,onFocus:i(J=>{if(l){let me=ie();Xt(me[me.length-1])}else L?.portalNode&&(M.current=!1,At(J,L.portalNode)?Hn(E)?.focus():pt(g??L.beforeOutsideRef)?.focus())},"onFocus")}),n,Se&&(0,un.jsx)($t,{"data-type":"inside",ref:$,onFocus:i(J=>{l?Xt(ie()[0]):L?.portalNode&&(d&&(M.current=!0),At(J,L.portalNode)?Vn(E)?.focus():pt(f??L.afterOutsideRef)?.focus())},"onFocus")})]})}i(Vs,"FloatingFocusManager");var fn=ne(he(),1);function Ws(e,t={}){let{enabled:n=!0,event:r="click",toggle:o=!0,ignoreMouse:s=!1,stickIfOpen:c=!0,touchOpenDelay:l=0,reason:d=te.triggerPress}=t,a="rootStore"in e?e.rootStore:e,f=a.context.dataRef,g=fn.useRef(void 0),u=Ct(),m=Ne(),R=fn.useMemo(()=>{function p(E,y,x,b){let T=fe(d,y,x);E&&b==="touch"&&l>0?m.start(l,()=>{a.setOpen(!0,T)}):a.setOpen(E,T)}i(p,"setOpenWithTouchDelay");function h(E,y,x){let b=f.current.openEvent,T=a.select("domReferenceElement")!==y;return E&&T||!E||!o?!0:b&&c?!x(b.type):!1}return i(h,"getNextOpen"),{onPointerDown(E){g.current=tt(E.pointerType,!0)&&Yt(E.nativeEvent)?"virtual":E.pointerType},onMouseDown(E){let y=g.current,x=E.nativeEvent,b=a.select("open");if(E.button!==0||r==="click"||tt(y,!0)&&s)return;let T=h(b,E.currentTarget,O=>O==="click"||O==="mousedown"),P=Te(x);if(Bt(P)){p(T,x,P,y);return}let v=E.currentTarget;u.request(()=>{p(T,x,v,y)})},onClick(E){if(r==="mousedown-only")return;let y=g.current;if(r==="mousedown"&&y){g.current=void 0;return}if(tt(y,!0)&&s)return;let x=a.select("open"),b=h(x,E.currentTarget,T=>T==="click"||T==="mousedown"||T==="keydown"||T==="keyup");p(b,E.nativeEvent,E.currentTarget,y)},onKeyDown(){g.current=void 0}}},[f,r,s,d,a,c,o,u,m,l]);return fn.useMemo(()=>n?{reference:R}:ct,[n,R])}i(Ws,"useClick");var Xe=ne(he(),1);function Bs(e,t){let n=null,r=null,o=!1;return{contextElement:e||void 0,getBoundingClientRect(){let s=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},c=t.axis==="x"||t.axis==="both",l=t.axis==="y"||t.axis==="both",d=["mouseenter","mousemove"].includes(t.dataRef.current.openEvent?.type||"")&&t.pointerType!=="touch",a=s.width,f=s.height,g=s.x,u=s.y;return n==null&&t.x&&c&&(n=s.x-t.x),r==null&&t.y&&l&&(r=s.y-t.y),g-=n||0,u-=r||0,a=0,f=0,!o||d?(a=t.axis==="y"?s.width:0,f=t.axis==="x"?s.height:0,g=c&&t.x!=null?t.x:g,u=l&&t.y!=null?t.y:u):o&&!d&&(f=t.axis==="x"?s.height:f,a=t.axis==="y"?s.width:a),o=!0,{width:a,height:f,x:g,y:u,top:u,right:g+a,bottom:u+f,left:g}}}}i(Bs,"createVirtualElement");function ti(e){return e!=null&&e.clientX!=null}i(ti,"isMouseBasedEvent");function Ys(e,t={}){let{enabled:n=!0,axis:r="both"}=t,o="rootStore"in e?e.rootStore:e,s=o.useState("open"),c=o.useState("floatingElement"),l=o.useState("domReferenceElement"),d=o.context.dataRef,a=Xe.useRef(!1),f=Xe.useRef(null),[g,u]=Xe.useState(),[m,R]=Xe.useState([]),p=X(b=>{o.set("positionReference",b)}),h=X((b,T,P)=>{a.current||d.current.openEvent&&!ti(d.current.openEvent)||o.set("positionReference",Bs(P??l,{x:b,y:T,axis:r,dataRef:d,pointerType:g}))}),E=X(b=>{s?f.current||(h(b.clientX,b.clientY,b.currentTarget),R([])):h(b.clientX,b.clientY,b.currentTarget)}),y=tt(g)?c:s;Xe.useEffect(()=>{if(!n){p(l);return}if(!y)return;function b(){f.current?.(),f.current=null}i(b,"cleanupListener");let T=Pe(c);function P(v){let O=Te(v);B(c,O)?b():h(v.clientX,v.clientY)}return i(P,"handleMouseMove"),!d.current.openEvent||ti(d.current.openEvent)?f.current=q(T,"mousemove",P):p(l),b},[y,n,c,d,l,o,h,p,m]),Xe.useEffect(()=>()=>{o.set("positionReference",null)},[o]),Xe.useEffect(()=>{n&&!c&&(a.current=!1)},[n,c]),Xe.useEffect(()=>{!n&&s&&(a.current=!0)},[n,s]);let x=Xe.useMemo(()=>{function b(T){u(T.pointerType)}return i(b,"setPointerTypeRef"),{onPointerDown:b,onPointerEnter:b,onMouseMove:E,onMouseEnter:E}},[E]);return Xe.useMemo(()=>n?{reference:x,trigger:x}:{},[n,x])}i(Ys,"useClientPoint");var je=ne(he(),1);function $s(){return!1}i($s,"alwaysFalse");function Gs(e){return{escapeKey:typeof e=="boolean"?e:e?.escapeKey??!1,outsidePress:typeof e=="boolean"?e:e?.outsidePress??!0}}i(Gs,"normalizeProp");function Xs(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:o=!0,outsidePressEvent:s="sloppy",referencePress:c=$s,bubbles:l,externalTree:d}=t,a="rootStore"in e?e.rootStore:e,f=a.useState("open"),g=a.useState("floatingElement"),{dataRef:u}=a.context,m=Ge(d),R=X(typeof o=="function"?o:()=>!1),p=typeof o=="function"?R:o,h=p!==!1,E=X(()=>s),{escapeKey:y,outsidePress:x}=Gs(l),b=je.useRef(!1),T=je.useRef(!1),P=je.useRef(!1),v=je.useRef(!1),O=je.useRef(""),A=je.useRef(null),N=Ne(),G=Ne(),Y=X(()=>{G.clear(),u.current.insideReactTree=!1}),L=X(D=>{let $=u.current.floatingContext?.nodeId;return(m?Ze(m.nodesRef.current,$):[]).some(ce=>ce.context?.open&&!ce.context.dataRef.current[D])}),M=X(D=>Pn(D,a.select("floatingElement"))||Pn(D,a.select("domReferenceElement"))),I=X(D=>{c()&&a.setOpen(!1,fe(te.triggerPress,D.nativeEvent))}),_=X(D=>{if(!f||!n||!r||D.key!=="Escape"||v.current||!y&&L("__escapeKeyBubbles"))return;let $=yo(D)?D.nativeEvent:D,z=fe(te.escapeKey,$);a.setOpen(!1,z),z.isCanceled||D.preventDefault(),!y&&!z.isPropagationAllowed&&D.stopPropagation()}),F=X(()=>{u.current.insideReactTree=!0,G.start(0,Y)}),C=X(D=>{if(!f||!n||D.button!==0)return;let $=Te(D.nativeEvent);B(a.select("floatingElement"),$)&&(b.current||(b.current=!0,T.current=!1))}),W=X(D=>{!f||!n||(D.defaultPrevented||D.nativeEvent.defaultPrevented)&&b.current&&(T.current=!0)});je.useEffect(()=>{if(!f||!n)return Y;u.current.__escapeKeyBubbles=y,u.current.__outsidePressBubbles=x;let D=new Ke,$=new Ke;function z(){D.clear(),v.current=!0}i(z,"handleCompositionStart");function ce(){D.start(Ce.engine.webkit?5:0,()=>{v.current=!1})}i(ce,"handleCompositionEnd");function j(){P.current=!0,$.start(0,()=>{P.current=!1})}i(j,"suppressImmediateOutsideClickAfterPreventedStart");function xe(){b.current=!1,T.current=!1}i(xe,"resetPressStartState");function H(){let w=O.current,S=w==="pen"||!w?"mouse":w,se=E(),k=typeof se=="function"?se():se;return typeof k=="string"?k:k[S]}i(H,"getOutsidePressEvent");function ie(w){let S=H();return S==="intentional"&&w.type!=="click"||S==="sloppy"&&w.type==="click"}i(ie,"shouldIgnoreEvent");function ae(w){let S=u.current.floatingContext?.nodeId,se=m&&Ze(m.nodesRef.current,S).some(k=>Pn(w,k.context?.elements.floating));return M(w)||se}i(ae,"isEventWithinFloatingTree");function Se(w){if(ie(w)){w.type!=="click"&&!M(w)&&($.clear(),P.current=!1),Y();return}if(u.current.insideReactTree){Y();return}let S=Te(w),se=`[${ht("inert")}]`,k=ee(S)?S.getRootNode():null,oe=Array.from((Vt(k)?k:re(a.select("floatingElement"))).querySelectorAll(se)),Fe=a.context.triggerElements;if(S&&(Fe.hasElement(S)||Fe.hasMatchingElement(Le=>B(Le,S))))return;let et=ee(S)?S:null;for(;et&&!xt(et);){let Le=Ot(et);if(xt(Le)||!ee(Le))break;et=Le}if(!(oe.length&&ee(S)&&!lo(S)&&!B(S,a.select("floatingElement"))&&oe.every(Le=>!B(et,Le)))){if(ye(S)&&!("touches"in w)){let Le=xt(S),Rt=We(S),ft=/auto|scroll/,gn=Le||ft.test(Rt.overflowX),_t=Le||ft.test(Rt.overflowY),Et=gn&&S.clientWidth>0&&S.scrollWidth>S.clientWidth,hn=_t&&S.clientHeight>0&&S.scrollHeight>S.clientHeight,Rn=Rt.direction==="rtl",En=hn&&(Rn?w.offsetX<=S.offsetWidth-S.clientWidth:w.offsetX>S.clientWidth),yn=Et&&w.offsetY>S.clientHeight;if(En||yn)return}if(!ae(w)){if(H()==="intentional"&&P.current){$.clear(),P.current=!1;return}typeof p=="function"&&!p(w)||L("__outsidePressBubbles")||(a.setOpen(!1,fe(te.outsidePress,w)),Y())}}}i(Se,"closeOnPressOutside");function J(w){H()!=="sloppy"||w.pointerType==="touch"||!a.select("open")||!n||M(w)||Se(w)}i(J,"handlePointerDown");function me(w){if(H()!=="sloppy"||!a.select("open")||!n||M(w))return;let S=w.touches[0];S&&(A.current={startTime:Date.now(),startX:S.clientX,startY:S.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},N.start(1e3,()=>{A.current&&(A.current.dismissOnTouchEnd=!1,A.current.dismissOnMouseDown=!1)}))}i(me,"handleTouchStart");function Ee(w,S){let se=Te(w);if(!se)return;let k=q(se,w.type,()=>{S(w),k()})}i(Ee,"addTargetEventListenerOnce");function ge(w){O.current="touch",Ee(w,me)}i(ge,"handleTouchStartCapture");function ve(w){N.clear(),w.type==="pointerdown"&&(O.current=w.pointerType),!(w.type==="mousedown"&&A.current&&!A.current.dismissOnMouseDown)&&Ee(w,S=>{S.type==="pointerdown"?J(S):Se(S)})}i(ve,"closeOnPressOutsideCapture");function U(w){if(!b.current)return;let S=T.current;if(xe(),H()==="intentional"){if(w.type==="pointercancel"){S&&j();return}if(!ae(w)){if(S){j();return}typeof p=="function"&&!p(w)||($.clear(),P.current=!0,Y())}}}i(U,"handlePressEndCapture");function ue(w){if(H()!=="sloppy"||!A.current||M(w))return;let S=w.touches[0];if(!S)return;let se=Math.abs(S.clientX-A.current.startX),k=Math.abs(S.clientY-A.current.startY),oe=Math.sqrt(se*se+k*k);oe>5&&(A.current.dismissOnTouchEnd=!0),oe>10&&(Se(w),N.clear(),A.current=null)}i(ue,"handleTouchMove");function K(w){Ee(w,ue)}i(K,"handleTouchMoveCapture");function pe(w){H()!=="sloppy"||!A.current||M(w)||(A.current.dismissOnTouchEnd&&Se(w),N.clear(),A.current=null)}i(pe,"handleTouchEnd");function be(w){Ee(w,pe)}i(be,"handleTouchEndCapture");let le=re(g),Me=_e(r&&_e(q(le,"keydown",_),q(le,"compositionstart",z),q(le,"compositionend",ce)),h&&_e(q(le,"click",ve,!0),q(le,"pointerdown",ve,!0),q(le,"pointerup",U,!0),q(le,"pointercancel",U,!0),q(le,"mousedown",ve,!0),q(le,"mouseup",U,!0),q(le,"touchstart",ge,!0),q(le,"touchmove",K,!0),q(le,"touchend",be,!0)));return()=>{Me(),D.clear(),$.clear(),xe(),P.current=!1,Y()}},[u,g,r,h,p,f,n,y,x,_,Y,E,L,M,m,a,N]);let Q=je.useMemo(()=>({onKeyDown:_,onPointerDown:I,onClick:I}),[_,I]),Z=je.useMemo(()=>({onKeyDown:_,onPointerDown:W,onMouseDown:W,onClickCapture:F,onMouseDownCapture(D){F(),C(D)},onPointerDownCapture(D){F(),C(D)},onMouseUpCapture:F,onTouchEndCapture:F,onTouchMoveCapture:F}),[_,F,C,W]);return je.useMemo(()=>n?{reference:Q,floating:Z,trigger:Q}:{},[n,Q,Z])}i(Xs,"useDismiss");function ni(e,t,n){let{reference:r,floating:o}=e,s=$e(t),c=ln(t),l=cn(c),d=Ye(t),a=s==="y",f=r.x+r.width/2-o.width/2,g=r.y+r.height/2-o.height/2,u=r[l]/2-o[l]/2,m;switch(d){case"top":m={x:f,y:r.y-o.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:g};break;case"left":m={x:r.x-o.width,y:g};break;default:m={x:r.x,y:r.y}}let R=rt(t);return R&&(m[c]+=u*(R==="end"?1:-1)*(n&&a?-1:1)),m}i(ni,"computeCoordsFromPlacement");async function ri(e,t){var n;t===void 0&&(t={});let{x:r,y:o,platform:s,rects:c,elements:l,strategy:d}=e,{boundary:a="clippingAncestors",rootBoundary:f="viewport",elementContext:g="floating",altBoundary:u=!1,padding:m=0}=at(t,e),R=Fn(m),h=l[u?g==="floating"?"reference":"floating":g],E=Pt(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(h)))==null||n?h:h.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:a,rootBoundary:f,strategy:d})),y=g==="floating"?{x:r,y:o,width:c.floating.width,height:c.floating.height}:c.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),b=await(s.isElement==null?void 0:s.isElement(x))&&await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1},T=Pt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:x,strategy:d}):y);return{top:(E.top-T.top+R.top)/b.y,bottom:(T.bottom-E.bottom+R.bottom)/b.y,left:(E.left-T.left+R.left)/b.x,right:(T.right-E.right+R.right)/b.x}}i(ri,"detectOverflow");var Us=50,oi=i(async(e,t,n)=>{let{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:c}=n,l=c.detectOverflow?c:{...c,detectOverflow:ri},d=await(c.isRTL==null?void 0:c.isRTL(t)),a=await c.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:g}=ni(a,r,d),u=r,m=0,R={};for(let p=0;p<s.length;p++){let h=s[p];if(!h)continue;let{name:E,fn:y}=h,{x,y:b,data:T,reset:P}=await y({x:f,y:g,initialPlacement:r,placement:u,strategy:o,middlewareData:R,rects:a,platform:l,elements:{reference:e,floating:t}});f=x??f,g=b??g,R[E]={...R[E],...T},P&&m<Us&&(m++,typeof P=="object"&&(P.placement&&(u=P.placement),P.rects&&(a=P.rects===!0?await c.getElementRects({reference:e,floating:t,strategy:o}):P.rects),{x:f,y:g}=ni(a,u,d)),p=-1)}return{x:f,y:g,placement:u,strategy:o,middlewareData:R}},"computePosition");var ii=i(function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;let{placement:o,middlewareData:s,rects:c,initialPlacement:l,platform:d,elements:a}=t,{mainAxis:f=!0,crossAxis:g=!0,fallbackPlacements:u,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:R="none",flipAlignment:p=!0,...h}=at(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};let E=Ye(o),y=$e(l),x=Ye(l)===l,b=await(d.isRTL==null?void 0:d.isRTL(a.floating)),T=u||(x||!p?[rn(l)]:So(l)),P=R!=="none";!u&&P&&T.push(...To(l,p,R,b));let v=[l,...T],O=await d.detectOverflow(t,h),A=[],N=((r=s.flip)==null?void 0:r.overflows)||[];if(f&&A.push(O[E]),g){let M=vo(o,c,b);A.push(O[M[0]],O[M[1]])}if(N=[...N,{placement:o,overflows:A}],!A.every(M=>M<=0)){var G,Y;let M=(((G=s.flip)==null?void 0:G.index)||0)+1,I=v[M];if(I&&(!(g==="alignment"?y!==$e(I):!1)||N.every(C=>$e(C.placement)===y?C.overflows[0]>0:!0)))return{data:{index:M,overflows:N},reset:{placement:I}};let _=(Y=N.filter(F=>F.overflows[0]<=0).sort((F,C)=>F.overflows[1]-C.overflows[1])[0])==null?void 0:Y.placement;if(!_)switch(m){case"bestFit":{var L;let F=(L=N.filter(C=>{if(P){let W=$e(C.placement);return W===y||W==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(W=>W>0).reduce((W,Q)=>W+Q,0)]).sort((C,W)=>C[1]-W[1])[0])==null?void 0:L[0];F&&(_=F);break}case"initialPlacement":_=l;break}if(o!==_)return{reset:{placement:_}}}return{}}}},"flip");var si=new Set(["left","top"]);async function Ks(e,t){let{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),c=Ye(n),l=rt(n),d=$e(n)==="y",a=si.has(c)?-1:1,f=s&&d?-1:1,g=at(t,e),{mainAxis:u,crossAxis:m,alignmentAxis:R}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof R=="number"&&(m=l==="end"?R*-1:R),d?{x:m*f,y:u*a}:{x:u*a,y:m*f}}i(Ks,"convertValueToCoords");var ci=i(function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;let{x:o,y:s,placement:c,middlewareData:l}=t,d=await Ks(t,e);return c===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+d.x,y:s+d.y,data:{...d,placement:c}}}}},"offset"),li=i(function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:r,placement:o,platform:s}=t,{mainAxis:c=!0,crossAxis:l=!1,limiter:d={fn:i(y=>{let{x,y:b}=y;return{x,y:b}},"fn")},...a}=at(e,t),f={x:n,y:r},g=await s.detectOverflow(t,a),u=$e(o),m=kn(u),R=f[m],p=f[u],h=i((y,x)=>An(x+g[y==="y"?"top":"left"],x,x-g[y==="y"?"bottom":"right"]),"clampCoord");c&&(R=h(m,R)),l&&(p=h(u,p));let E=d.fn({...t,[m]:R,[u]:p});return{...E,data:{x:E.x-n,y:E.y-r,enabled:{[m]:c,[u]:l}}}}}},"shift"),ai=i(function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,r;let{x:o,y:s,placement:c,rects:l,middlewareData:d}=t,{offset:a=0,mainAxis:f=!0,crossAxis:g=!0}=at(e,t),u={x:o,y:s},m=$e(c),R=kn(m),p=u[R],h=u[m],E=at(a,t),y=typeof E=="number"?{mainAxis:E,crossAxis:0}:{mainAxis:(n=E.mainAxis)!=null?n:0,crossAxis:(r=E.crossAxis)!=null?r:0};if(f){let T=R==="y"?"height":"width",P=l.reference[R]-l.floating[T]+y.mainAxis,v=l.reference[R]+l.reference[T]-y.mainAxis;p<P?p=P:p>v&&(p=v)}if(g){var x,b;let T=R==="y"?"width":"height",P=si.has(Ye(c)),v=l.reference[m]-l.floating[T]+(P&&((x=d.offset)==null?void 0:x[m])||0)+(P?0:y.crossAxis),O=l.reference[m]+l.reference[T]+(P?0:((b=d.offset)==null?void 0:b[m])||0)-(P?y.crossAxis:0);h<v?h=v:h>O&&(h=O)}return{[R]:p,[m]:h}}}},"limitShift"),ui=i(function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:r,platform:o,elements:s}=t,{apply:c=i(()=>{},"apply"),...l}=at(e,t),d=await o.detectOverflow(t,l),a=Ye(n),f=rt(n),g=$e(n)==="y",{width:u,height:m}=r.floating,R,p;a==="top"||a==="bottom"?(R=a,p=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(p=a,R=f==="end"?"top":"bottom");let h=m-d.top-d.bottom,E=u-d.left-d.right,y=wt(m-d[R],h),x=wt(u-d[p],E),b=t.middlewareData.shift,T=!b,P=y,v=x;b!=null&&b.enabled.x&&(v=E),b!=null&&b.enabled.y&&(P=h),T&&!f&&(g?v=u-2*nt(d.left,d.right):P=m-2*nt(d.top,d.bottom)),await c({...t,availableWidth:v,availableHeight:P});let O=await o.getDimensions(s.floating);return u!==O.width||m!==O.height?{reset:{rects:!0}}:{}}}},"size");function mi(e){let t=We(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,o=ye(e),s=o?e.offsetWidth:n,c=o?e.offsetHeight:r,l=on(n)!==s||on(r)!==c;return l&&(n=s,r=c),{width:n,height:r,$:l}}i(mi,"getCssDimensions");function Nr(e){return ee(e)?e:e.contextElement}i(Nr,"unwrapElement");function Ut(e){let t=Nr(e);if(!ye(t))return lt(1);let n=t.getBoundingClientRect(),{width:r,height:o,$:s}=mi(t),c=(s?on(n.width):n.width)/r,l=(s?on(n.height):n.height)/o;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}i(Ut,"getScale");var zs=lt(0);function pi(e){let t=Pe(e);return!mr()||!t.visualViewport?zs:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}i(pi,"getVisualOffsets");function js(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Pe(e)}i(js,"shouldAddVisualOffsets");function Ft(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let o=e.getBoundingClientRect(),s=Nr(e),c=lt(1);t&&(r?ee(r)&&(c=Ut(r)):c=Ut(e));let l=js(s,n,r)?pi(s):lt(0),d=(o.left+l.x)/c.x,a=(o.top+l.y)/c.y,f=o.width/c.x,g=o.height/c.y;if(s&&r){let u=Pe(s),m=ee(r)?Pe(r):r,R=u,p=pr(R);for(;p&&m!==R;){let h=Ut(p),E=p.getBoundingClientRect(),y=We(p),x=E.left+(p.clientLeft+parseFloat(y.paddingLeft))*h.x,b=E.top+(p.clientTop+parseFloat(y.paddingTop))*h.y;d*=h.x,a*=h.y,f*=h.x,g*=h.y,d+=x,a+=b,R=Pe(p),p=pr(R)}}return Pt({width:f,height:g,x:d,y:a})}i(Ft,"getBoundingClientRect");function $n(e,t){let n=Qt(e).scrollLeft;return t?t.left+n:Ft(mt(e)).left+n}i($n,"getWindowScrollBarX");function gi(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-$n(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}i(gi,"getHTMLOffset");function qs(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e,s=o==="fixed",c=mt(r),l=t?On(t.floating):!1;if(r===c||l&&s)return n;let d={scrollLeft:0,scrollTop:0},a=lt(1),f=lt(0),g=ye(r);if((g||!s)&&((Ae(r)!=="body"||Jt(c))&&(d=Qt(r)),g)){let m=Ft(r);a=Ut(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}let u=c&&!g&&!s?gi(c,d):lt(0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-d.scrollLeft*a.x+f.x+u.x,y:n.y*a.y-d.scrollTop*a.y+f.y+u.y}}i(qs,"convertOffsetParentRelativeRectToViewportRelativeRect");function Js(e){return e.getClientRects?Array.from(e.getClientRects()):[]}i(Js,"getClientRects");function Qs(e){let t=Qt(e),n=e.ownerDocument.body,r=nt(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=nt(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),s=-t.scrollLeft+$n(e),c=-t.scrollTop;return We(n).direction==="rtl"&&(s+=nt(e.clientWidth,n.clientWidth)-r),{width:r,height:o,x:s,y:c}}i(Qs,"getDocumentRect");var Zs=25;function ec(e,t,n){n===void 0&&(n="viewport");let r=n==="layoutViewport",o=Pe(e),s=mt(e),c=o.visualViewport,l=s.clientWidth,d=s.clientHeight,a=0,f=0;if(c){let u=!mr()||t==="fixed";r?u||(a=-c.offsetLeft,f=-c.offsetTop):(l=c.width,d=c.height,u&&(a=c.offsetLeft,f=c.offsetTop))}if($n(s)<=0){let u=s.ownerDocument,m=u.body,R=getComputedStyle(m),p=u.compatMode==="CSS1Compat"&&parseFloat(R.marginLeft)+parseFloat(R.marginRight)||0,h=Math.abs(s.clientWidth-m.clientWidth-p),E=getComputedStyle(s).scrollbarGutter==="stable both-edges"?h/2:h;E<=Zs&&(l-=E)}return{width:l,height:d,x:a,y:f}}i(ec,"getViewportRect");function tc(e,t){let n=Ft(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Ut(e),c=e.clientWidth*s.x,l=e.clientHeight*s.y,d=o*s.x,a=r*s.y;return{width:c,height:l,x:d,y:a}}i(tc,"getInnerBoundingClientRect");function fi(e,t,n){let r;if(t==="viewport"||t==="layoutViewport")r=ec(e,n,t);else if(t==="document")r=Qs(mt(e));else if(ee(t))r=tc(t,n);else{let o=pi(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Pt(r)}i(fi,"getClientRectFromClippingAncestor");function nc(e,t){let n=t.get(e);if(n)return n;let r=Wt(e,[],!1).filter(l=>ee(l)&&Ae(l)!=="body"),o=null,s=We(e).position==="fixed",c=s?Ot(e):e;for(;ee(c)&&!xt(c);){let l=We(c),d=dr(c),a=o?o.position:s?"fixed":"";!d&&(a==="fixed"||a==="absolute"&&l.position==="static")?r=r.filter(g=>g!==c):o=l,c=Ot(c)}return t.set(e,r),r}i(nc,"getClippingElementAncestors");function rc(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e,c=[...n==="clippingAncestors"?On(t)?[]:nc(t,this._c):[].concat(n),r],l=fi(t,c[0],o),d=l.top,a=l.right,f=l.bottom,g=l.left;for(let u=1;u<c.length;u++){let m=fi(t,c[u],o);d=nt(m.top,d),a=wt(m.right,a),f=wt(m.bottom,f),g=nt(m.left,g)}return{width:a-g,height:f-d,x:g,y:d}}i(rc,"getClippingRect");function oc(e){let{width:t,height:n}=mi(e);return{width:t,height:n}}i(oc,"getDimensions");function ic(e,t,n){let r=ye(t),o=mt(t),s=n==="fixed",c=Ft(e,!0,s,t),l={scrollLeft:0,scrollTop:0},d=lt(0);if((r||!s)&&((Ae(t)!=="body"||Jt(o))&&(l=Qt(t)),r)){let u=Ft(t,!0,s,t);d.x=u.x+t.clientLeft,d.y=u.y+t.clientTop}!r&&o&&(d.x=$n(o));let a=o&&!r&&!s?gi(o,l):lt(0),f=c.left+l.scrollLeft-d.x-a.x,g=c.top+l.scrollTop-d.y-a.y;return{x:f,y:g,width:c.width,height:c.height}}i(ic,"getRectRelativeToOffsetParent");function Lr(e){return We(e).position==="static"}i(Lr,"isStaticPositioned");function di(e,t){if(!ye(e)||We(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return mt(e)===n&&(n=n.ownerDocument.body),n}i(di,"getTrueOffsetParent");function hi(e,t){let n=Pe(e);if(On(e))return n;if(!ye(e)){let o=Ot(e);for(;o&&!xt(o);){if(ee(o)&&!Lr(o))return o;o=Ot(o)}return n}let r=di(e,t);for(;r&&io(r)&&Lr(r);)r=di(r,t);return r&&xt(r)&&Lr(r)&&!dr(r)?n:r||so(e)||n}i(hi,"getOffsetParent");var sc=i(async function(e){let t=this.getOffsetParent||hi,n=this.getDimensions,r=await n(e.floating);return{reference:ic(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},"getElementRects");function cc(e){return We(e).direction==="rtl"}i(cc,"isRTL");var _r={convertOffsetParentRelativeRectToViewportRelativeRect:qs,getDocumentElement:mt,getClippingRect:rc,getOffsetParent:hi,getElementRects:sc,getClientRects:Js,getDimensions:oc,getScale:Ut,isElement:ee,isRTL:cc};function Ri(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}i(Ri,"rectsAreEqual");function lc(e,t,n){let r=null,o,s=mt(e);function c(){var f;clearTimeout(o),(f=r)==null||f.disconnect(),r=null}i(c,"cleanup");function l(f,g){f===void 0&&(f=!1),g===void 0&&(g=1),c();let u=e.getBoundingClientRect(),{left:m,top:R,width:p,height:h}=u;if(f||t(),!p||!h)return;let E=sn(R),y=sn(s.clientWidth-(m+p)),x=sn(s.clientHeight-(R+h)),b=sn(m),P={rootMargin:-E+"px "+-y+"px "+-x+"px "+-b+"px",threshold:nt(0,wt(1,g))||1},v=!0;function O(A){let N=A[0].intersectionRatio;if(!Ri(u,e.getBoundingClientRect()))return l();if(N!==g){if(!v)return l();N?l(!1,N):o=setTimeout(()=>{l(!1,1e-7)},1e3)}v=!1}i(O,"handleObserve");try{r=new IntersectionObserver(O,{...P,root:s.ownerDocument})}catch{r=new IntersectionObserver(O,P)}r.observe(e)}i(l,"refresh");let d=Pe(e),a=i(()=>l(n),"handleResize");return d.addEventListener("resize",a),l(!0),()=>{d.removeEventListener("resize",a),c()}}i(lc,"observeMove");function dn(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:d=!1}=r,a=Nr(e),f=o||s?[...a?Wt(a):[],...t?Wt(t):[]]:[];f.forEach(E=>{o&&E.addEventListener("scroll",n),s&&E.addEventListener("resize",n)});let g=a&&l?lc(a,n,s):null,u=-1,m=null;c&&(m=new ResizeObserver(E=>{let[y]=E;y&&y.target===a&&m&&t&&(m.unobserve(t),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),a&&!d&&m.observe(a),t&&m.observe(t));let R,p=d?Ft(e):null;d&&h();function h(){let E=Ft(e);p&&!Ri(p,E)&&n(),p=E,R=requestAnimationFrame(h)}return i(h,"frameLoop"),n(),()=>{var E;f.forEach(y=>{o&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),g?.(),(E=m)==null||E.disconnect(),m=null,d&&cancelAnimationFrame(R)}}i(dn,"autoUpdate");var Ei=ci;var yi=li,xi=ii,bi=ui;var wi=ai,Gn=i((e,t,n)=>{let r=new Map,o=n??{},s={..._r,...o.platform,_c:r};return oi(e,t,{...o,platform:s})},"computePosition");var Ie=ne(he(),1),Si=ne(he(),1),Ti=ne(wn(),1);var uc=typeof document<"u",fc=i(function(){},"noop"),Xn=uc?Si.useLayoutEffect:fc;function Un(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Un(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){let s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Un(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}i(Un,"deepEqual");function Oi(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}i(Oi,"getDPR");function vi(e,t){let n=Oi(e);return Math.round(t*n)/n}i(vi,"roundByDPR");function Hr(e){let t=Ie.useRef(e);return Xn(()=>{t.current=e}),t}i(Hr,"useLatestRef");function Ci(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:c}={},transform:l=!0,whileElementsMounted:d,open:a}=e,[f,g]=Ie.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[u,m]=Ie.useState(r);Un(u,r)||m(r);let[R,p]=Ie.useState(null),[h,E]=Ie.useState(null),y=Ie.useCallback(C=>{C!==P.current&&(P.current=C,p(C))},[]),x=Ie.useCallback(C=>{C!==v.current&&(v.current=C,E(C))},[]),b=s||R,T=c||h,P=Ie.useRef(null),v=Ie.useRef(null),O=Ie.useRef(f),A=d!=null,N=Hr(d),G=Hr(o),Y=Hr(a),L=Ie.useCallback(()=>{if(!P.current||!v.current)return;let C={placement:t,strategy:n,middleware:u};G.current&&(C.platform=G.current),Gn(P.current,v.current,C).then(W=>{let Q={...W,isPositioned:Y.current!==!1};M.current&&!Un(O.current,Q)&&(O.current=Q,Ti.flushSync(()=>{g(Q)}))})},[u,t,n,G,Y]);Xn(()=>{a===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,g(C=>({...C,isPositioned:!1})))},[a]);let M=Ie.useRef(!1);Xn(()=>(M.current=!0,()=>{M.current=!1}),[]),Xn(()=>{if(b&&(P.current=b),T&&(v.current=T),b&&T){if(N.current)return N.current(b,T,L);L()}},[b,T,L,N,A]);let I=Ie.useMemo(()=>({reference:P,floating:v,setReference:y,setFloating:x}),[y,x]),_=Ie.useMemo(()=>({reference:b,floating:T}),[b,T]),F=Ie.useMemo(()=>{let C={position:n,left:0,top:0};if(!_.floating)return C;let W=vi(_.floating,f.x),Q=vi(_.floating,f.y);return l?{...C,transform:"translate("+W+"px, "+Q+"px)",...Oi(_.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:Q}},[n,l,_.floating,f.x,f.y]);return Ie.useMemo(()=>({...f,update:L,refs:I,elements:_,floatingStyles:F}),[f,L,I,_,F])}i(Ci,"useFloating");var Vr=i((e,t)=>{let n=Ei(e);return{name:n.name,fn:n.fn,options:[e,t]}},"offset"),Wr=i((e,t)=>{let n=yi(e);return{name:n.name,fn:n.fn,options:[e,t]}},"shift"),Br=i((e,t)=>({fn:wi(e).fn,options:[e,t]}),"limitShift"),Yr=i((e,t)=>{let n=xi(e);return{name:n.name,fn:n.fn,options:[e,t]}},"flip"),$r=i((e,t)=>{let n=bi(e);return{name:n.name,fn:n.fn,options:[e,t]}},"size");var Pi=ne(he(),1);var Gr=[],Xr;function Ii(){return Xr}i(Ii,"getInstance");function Mi(e){Gr.push(e)}i(Mi,"register");function dc(e){let t=i((n,r)=>{let o=Qe(mc).current,s;try{Xr=o;for(let c of Gr)c.before(o);s=e(n,r);for(let c of Gr)c.after(o);o.didInitialize=!0}finally{Xr=void 0}return s},"FastComponent");return t.displayName=e.displayName||e.name,t}i(dc,"fastComponent");function lf(e){return Pi.forwardRef(dc(e))}i(lf,"fastComponentRef");function mc(){return{didInitialize:!1}}i(mc,"createInstance");var Ai=ne(he(),1),Ur=ne(us(),1),ki=ne(fs(),1);var pc=vn(19),gc=pc?Rc:Ec;function Kn(e,t,n,r,o){return gc(e,t,n,r,o)}i(Kn,"useStore");function hc(e,t,n,r,o){let s=Ai.useCallback(()=>t(e.getSnapshot(),n,r,o),[e,t,n,r,o]);return(0,Ur.useSyncExternalStore)(e.subscribe,s,s)}i(hc,"useStoreR19");Mi({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let o of e.syncHooks)n.add(o.store);let r=[];for(let o of n)r.push(o.subscribe(t));return()=>{for(let o of r)o()}}),(0,Ur.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function Rc(e,t,n,r,o){let s=Ii();if(!s)return hc(e,t,n,r,o);let c=s.syncIndex;s.syncIndex+=1;let l;return s.didInitialize?(l=s.syncHooks[c],(l.store!==e||l.selector!==t||!Object.is(l.a1,n)||!Object.is(l.a2,r)||!Object.is(l.a3,o))&&(l.store!==e&&(s.didChangeStore=!0),l.store=e,l.selector=t,l.a1=n,l.a2=r,l.a3=o,l.value=t(e.getSnapshot(),n,r,o))):(l={store:e,selector:t,a1:n,a2:r,a3:o,value:t(e.getSnapshot(),n,r,o)},s.syncHooks.push(l)),l.value}i(Rc,"useStoreFast");function Ec(e,t,n,r,o){return(0,ki.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,s=>t(s,n,r,o))}i(Ec,"useStoreLegacy");var Dt=ne(he(),1);var zn=class{static{i(this,"Store")}constructor(t){this.state=t,this.listeners=new Set,this.updateTick=0}subscribe=i(t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}),"subscribe");getSnapshot=i(()=>this.state,"getSnapshot");setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;let n=this.updateTick;for(let r of this.listeners){if(n!==this.updateTick)return;r(t)}}update(t){for(let n in t)if(!Object.is(this.state[n],t[n])){this.setState({...this.state,...t});return}}set(t,n){Object.is(this.state[t],n)||this.setState({...this.state,[t]:n})}notifyAll(){let t={...this.state};this.setState(t)}use(t,n,r,o){return Kn(this,t,n,r,o)}};var jn=class extends zn{static{i(this,"ReactStore")}constructor(t,n={},r){super(t),this.context=n,this.selectors=r}useSyncedValue(t,n){Dt.useDebugValue(t);let r=this;V(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(t,n){let r=this;V(()=>(r.state[t]!==n&&r.set(t,n),()=>{r.set(t,void 0)}),[r,t,n])}useSyncedValues(t){let n=this,r=Object.values(t);V(()=>{n.update(t)},[n,...r])}useControlledProp(t,n){Dt.useDebugValue(t);let r=this,o=n!==void 0;V(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o])}select(t,n,r,o){let s=this.selectors[t];return s(this.state,n,r,o)}useState(t,n,r,o){return Dt.useDebugValue(t),Kn(this,this.selectors[t],n,r,o)}useContextCallback(t,n){Dt.useDebugValue(t);let r=X(n??Sn);this.context[t]=r}useStateSetter(t){let n=Dt.useRef(void 0);return n.current===void 0&&(n.current=r=>{this.set(t,r)}),n.current}observe(t,n){let r;typeof t=="function"?r=t:r=this.selectors[t];let o=r(this.state);return n(o,o,this),this.subscribe(s=>{let c=r(s);if(!Object.is(o,c)){let l=o;o=c,n(c,l,this)}})}};var Lt=ne(he(),1),Di=ne(wn(),1);var Fi=ne(he(),1);var yc={open:i(e=>e.open,"open"),transitionStatus:i(e=>e.transitionStatus,"transitionStatus"),domReferenceElement:i(e=>e.domReferenceElement,"domReferenceElement"),referenceElement:i(e=>e.positionReference??e.referenceElement,"referenceElement"),floatingElement:i(e=>e.floatingElement,"floatingElement"),floatingId:i(e=>e.floatingId,"floatingId")},Kt=class extends jn{static{i(this,"FloatingRootStore")}constructor(t){let{syncOnly:n,nested:r,onOpenChange:o,triggerElements:s,...c}=t;super({...c,positionReference:c.referenceElement,domReferenceElement:c.referenceElement},{onOpenChange:o,dataRef:{current:{}},events:Wn(),nested:r,triggerElements:s},yc),this.syncOnly=n}syncOpenEvent=i((t,n)=>{(!t||!this.state.open||n!=null&&xo(n))&&(this.context.dataRef.current.openEvent=t?n:void 0)},"syncOpenEvent");dispatchOpenChange=i((t,n)=>{this.syncOpenEvent(t,n.event);let r={open:t,reason:n.reason,nativeEvent:n.event,nested:this.context.nested,triggerElement:n.trigger};this.context.events.emit("openchange",r)},"dispatchOpenChange");setOpen=i((t,n)=>{if(this.syncOnly){this.context.onOpenChange?.(t,n);return}this.dispatchOpenChange(t,n),this.context.onOpenChange?.(t,n)},"setOpen")};function Kr(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:o,nested:s,onOpenChange:c}=e,l=t.useState("open"),d=t.useState("activeTriggerElement"),a=t.useState(n?"popupElement":"positionerElement"),f=t.context.triggerElements,g=c,u=Fi.useRef(null);r===void 0&&u.current===null&&(u.current=new Kt({open:l,transitionStatus:void 0,referenceElement:d,floatingElement:a,triggerElements:f,onOpenChange:g,floatingId:o,syncOnly:!0,nested:s}));let m=r??u.current;return t.useSyncedValue("floatingId",o),V(()=>{let R={open:l,floatingId:o,referenceElement:d,floatingElement:a};ee(d)&&(R.domReferenceElement=d),m.state.positionReference===m.state.referenceElement&&(R.positionReference=d),m.update(R)},[l,o,d,a,m]),m.context.onOpenChange=g,m.context.nested=s,m}i(Kr,"useSyncedFloatingRootContext");var Kf={tabIndex:-1,[co]:""};function zf(e){return t=>t==="touch"?e.current:!0}i(zf,"createDefaultInitialFocus");function jf(e,t=!1){let n=yt(),r=ot()!=null,o=Qe(()=>e(n,r)).current;return Kr({popupStore:o,treatPopupAsFloatingElement:t,floatingRootContext:o.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:o.setOpen}),o}i(jf,"usePopupRootStore");function qf({handle:e,store:t}){return V(()=>e.attachStore(t),[e,t]),null}i(qf,"PopupHandleAttachment");function xc(e,t){let n=Lt.useRef(null),r=Lt.useRef(null);return Lt.useCallback(o=>{if(e===void 0)return;let s=!1;if(n.current!==null){let c=n.current,l=r.current,d=t.context.triggerElements.getById(c);l&&d===l&&(t.context.triggerElements.delete(c),s=!0),n.current=null,r.current=null}if(o!==null&&(n.current=e,r.current=o,t.context.triggerElements.add(e,o),s=!0),s){let c=t.context.triggerElements.size;t.select("open")&&t.state.triggerCount!==c&&t.set("triggerCount",c)}},[t,e])}i(xc,"useTriggerRegistration");function bc(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);let o=n?.id??null;(o||t)&&(e.activeTriggerId=o,e.activeTriggerElement=n??null)}i(bc,"setPopupOpenState");function wc(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}i(wc,"attachPreventUnmountOnClose");function Jf(e,t,n,r={}){let o=n.reason,s=o===te.triggerHover,c=t&&o===te.triggerFocus,l=!t&&(o===te.triggerPress||o===te.escapeKey),d=wc(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let a=i(()=>{let f={...r.extraState,open:t};c?f.instantType="focus":l?f.instantType="dismiss":s&&(f.instantType=void 0),bc(f,t,n.trigger,d()),e.update(f)},"changeState");s?Di.flushSync(a):a()}i(Jf,"applyPopupOpenChange");function Qf(e,t,n,r){let o=n.useState("isMountedByTrigger",e),s=xc(e,n),c=X(d=>{let a=n.select("open"),f=n.select("activeTriggerId");if(f===e){n.update({activeTriggerElement:d,...a?r:null});return}f==null&&a&&n.update({activeTriggerId:e,activeTriggerElement:d,...r})}),l=Lt.useCallback(d=>{s(d),d&&c(d)},[s,c]);return V(()=>{o&&n.update({activeTriggerElement:t.current,...r})},[o,n,t,...Object.values(r)]),{registerTrigger:l,isMountedByThisTrigger:o}}i(Qf,"useTriggerDataForwarding");function Zf(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=Lt.useRef(null),o=e.useState("open"),s=e.useState("triggerCount"),c=e.useState("activeTriggerId"),l=e.useState("activeTriggerElement");V(()=>{if(!o){r.current=null,e.state.triggerCount!==0&&e.set("triggerCount",0);return}let d=e.context.triggerElements.size,a={};e.state.triggerCount!==d&&(a.triggerCount=d);let f=e.select("activeTriggerId"),g=null;if(f){let u=e.context.triggerElements.getById(f);if(u)r.current=f,u!==e.state.activeTriggerElement&&(a.activeTriggerElement=u);else{for(let[m,R]of e.context.triggerElements.entries())if(R===e.state.activeTriggerElement){a.activeTriggerId=m,a.activeTriggerElement=R,r.current=m;break}a.activeTriggerId===void 0&&(r.current===f?g=f:r.current=null)}}else r.current=null;if(!g&&!f&&d===1){let u=e.context.triggerElements.entries().next();if(!u.done){let[m,R]=u.value;a.activeTriggerId=m,a.activeTriggerElement=R,r.current=m}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),g&&n&&queueMicrotask(()=>{if(e.select("open")&&e.select("activeTriggerId")===g&&!e.context.triggerElements.getById(g)){let u=fe(te.none);e.setOpen(!1,u),u.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[o,e,s,c,l,n])}i(Zf,"useImplicitActiveTrigger");function ed(e,t,n){let{mounted:r,setMounted:o,transitionStatus:s}=go(e),c=t.useState("preventUnmountingOnClose"),l=e?!1:c;t.useSyncedValues({mounted:r,transitionStatus:s,preventUnmountingOnClose:l});let d=X(()=>{o(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return mo({enabled:r&&!e&&!l,open:e,ref:t.context.popupRef,onComplete(){e||d()}}),{forceUnmount:d,transitionStatus:s}}i(ed,"useOpenStateTransitions");function td(e,t){e.useSyncedValues(t),V(()=>()=>{e.update({activeTriggerProps:ct,inactiveTriggerProps:ct,popupProps:ct})},[e])}i(td,"usePopupInteractionProps");function nd(e,t){V(()=>{!t&&e.state.openMethod!==null&&e.set("openMethod",null)},[t,e]),V(()=>()=>{e.state.openMethod!==null&&e.set("openMethod",null)},[e])}i(nd,"usePopupRootSync");var qn=class{static{i(this,"PopupTriggerMap")}constructor(){this.idMap=new Map}add(t,n){this.idMap.set(t,n)}delete(t){this.idMap.delete(t)}hasElement(t){for(let n of this.idMap.values())if(n===t)return!0;return!1}hasMatchingElement(t){for(let n of this.idMap.values())if(t(n))return!0;return!1}getById(t){return this.idMap.get(t)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function vc(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,o=yt(),s=ot()!=null,c=Qe(()=>new Kt({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new qn,floatingId:o,syncOnly:!1,nested:s})).current;return V(()=>{let l={open:t,floatingId:o};r.reference!==void 0&&(l.referenceElement=r.reference,l.domReferenceElement=ee(r.reference)?r.reference:null),r.floating!==void 0&&(l.floatingElement=r.floating),c.update(l)},[t,o,r.reference,r.floating,c]),c.context.onOpenChange=n,c.context.nested=s,c}i(vc,"useFloatingRootContext");var ut=ne(he(),1);var zr=Ce.os.mac&&Ce.engine.webkit;function Sc(e,t={}){let{enabled:n=!0,delay:r}=t,o="rootStore"in e?e.rootStore:e,{events:s,dataRef:c}=o.context,l=ut.useRef(!1),d=ut.useRef(null),a=ut.useRef(!0),f=Ne();ut.useEffect(()=>{let u=o.select("domReferenceElement");if(!n)return;let m=Pe(u);function R(){let E=o.select("domReferenceElement");!o.select("open")&&ye(E)&&E===ke(re(E))&&(l.current=!0)}i(R,"onBlur");function p(){a.current=!0}i(p,"onKeyDown");function h(){a.current=!1}return i(h,"onPointerDown"),_e(q(m,"blur",R),zr&&q(m,"keydown",p,!0),zr&&q(m,"pointerdown",h,!0))},[o,n]),ut.useEffect(()=>{if(!n)return;function u(m){if(m.reason===te.triggerPress||m.reason===te.escapeKey){let R=o.select("domReferenceElement");ee(R)&&(d.current=R,l.current=!0)}}return i(u,"onOpenChangeLocal"),s.on("openchange",u),()=>{s.off("openchange",u)}},[s,n,o]);let g=ut.useMemo(()=>{function u(){l.current=!1,d.current=null}return i(u,"resetBlockedFocus"),{onMouseLeave(){u()},onFocus(m){let R=m.currentTarget;if(l.current){if(d.current===R)return;u()}let p=Te(m.nativeEvent);if(ee(p)){if(zr&&!m.relatedTarget){if(!a.current&&!Bt(p))return}else if(!ao(p))return}let h=bt(m.relatedTarget,o.context.triggerElements),{nativeEvent:E,currentTarget:y}=m,x=typeof r=="function"?r():r;if(o.select("open")&&h||x===0||x===void 0){o.setOpen(!0,fe(te.triggerFocus,E,y));return}f.start(x,()=>{l.current||o.setOpen(!0,fe(te.triggerFocus,E,y))})},onBlur(m){u();let R=m.relatedTarget,p=m.nativeEvent,h=ee(R)&&R.hasAttribute(ht("focus-guard"))&&R.getAttribute("data-type")==="outside";f.start(0,()=>{let E=o.select("domReferenceElement"),y=ke(re(E));!R&&y===E||B(c.current.floatingContext?.refs.floating.current,y)||B(E,y)||h||bt(R??y,o.context.triggerElements)||o.setOpen(!1,fe(te.triggerFocus,p))})}}},[c,r,o,f]);return ut.useMemo(()=>n?{reference:g,trigger:g}:{},[n,g])}i(Sc,"useFocus");var jr=class e{static{i(this,"HoverInteraction")}constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new Ke,this.restTimeout=new Ke,this.handleCloseOptions=void 0}static create(){return new e}dispose=i(()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()},"dispose");disposeEffect=i(()=>this.dispose,"disposeEffect")},Jn=new WeakMap;function zt(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Jn.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty("pointer-events"),e.pointerEventsReferenceElement?.style.removeProperty("pointer-events"),e.pointerEventsFloatingElement?.style.removeProperty("pointer-events"),Jn.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}i(zt,"clearSafePolygonPointerEventsMutation");function Qn(e,t){let{scopeElement:n,referenceElement:r,floatingElement:o}=t,s=Jn.get(n);s&&s!==e&&zt(s),zt(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=o,Jn.set(n,e),n.style.pointerEvents="none",r.style.pointerEvents="auto",o.style.pointerEvents="auto"}i(Qn,"applySafePolygonPointerEventsMutation");function Zn(e){let t=e.context.dataRef.current,n=Qe(()=>t.hoverInteractionState??jr.create()).current;return t.hoverInteractionState||(t.hoverInteractionState=n),uo(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}i(Zn,"useHoverInteractionSharedState");var qr=ne(he(),1);function Tc(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:o}=t,s="rootStore"in e?e.rootStore:e,c=s.useState("open"),l=s.useState("floatingElement"),d=s.useState("domReferenceElement"),{dataRef:a}=s.context,f=Ge(),g=ot(),u=Zn(s),m=Ne(),R=X(()=>Dn(a.current.openEvent?.type,u.interactedInside)),p=X(()=>Oo(a.current.openEvent?.type)),h=X(()=>{zt(u)});V(()=>{c||(u.pointerType=void 0,u.restTimeoutPending=!1,u.interactedInside=!1,h())},[c,u,h]),qr.useEffect(()=>h,[h]),V(()=>{if(n&&c&&u.handleCloseOptions?.blockPointerEvents&&p()&&ee(d)&&l){let E=d,y=l,x=re(l),b=f?.nodesRef.current.find(O=>O.id===g)?.context?.elements.floating;b&&(b.style.pointerEvents="");let T=u.pointerEventsScopeElement!==y?u.pointerEventsScopeElement:null,P=b!==y?b:null,v=u.handleCloseOptions?.getScope?.()??T??P??E.closest("[data-rootownerid]")??x.body;return Qn(u,{scopeElement:v,referenceElement:E,floatingElement:y}),()=>{h()}}},[n,c,d,l,u,p,f,g,h]),qr.useEffect(()=>{if(!n)return;function E(){return!!(f&&g&&Ze(f.nodesRef.current,g).length>0)}i(E,"hasParentChildren");function y(O){let A=gt(r,"close",u.pointerType),N=i(()=>{s.setOpen(!1,fe(te.triggerHover,O)),f?.events.emit("floating.closed",O)},"close");A?u.openChangeTimeout.start(A,N):(u.openChangeTimeout.clear(),N())}i(y,"closeWithDelay");function x(O){let A=Te(O);if(!hr(A)){u.interactedInside=!1;return}u.interactedInside=A?.closest("[aria-haspopup]")!=null}i(x,"handleInteractInside");function b(){u.openChangeTimeout.clear(),m.clear(),f?.events.off("floating.closed",P),h()}i(b,"onFloatingMouseEnter");function T(O){if(E()&&f){f.events.on("floating.closed",P);return}if(bt(O.relatedTarget,s.context.triggerElements))return;let A=a.current.floatingContext?.nodeId??o,N=O.relatedTarget;if(!(f&&A&&ee(N)&&Ze(f.nodesRef.current,A,!1).some(Y=>B(Y.context?.elements.floating,N)))){if(u.handler){u.handler(O);return}h(),p()&&!R()&&y(O)}}i(T,"onFloatingMouseLeave");function P(O){!f||!g||E()||m.start(0,()=>{f.events.off("floating.closed",P),s.setOpen(!1,fe(te.triggerHover,O)),f.events.emit("floating.closed",O)})}i(P,"onNodeClosed");let v=l;return _e(v&&q(v,"mouseenter",b),v&&q(v,"mouseleave",T),v&&q(v,"pointerdown",x,!0),()=>{f?.events.off("floating.closed",P)})},[n,l,s,a,r,o,p,R,h,u,f,g,m])}i(Tc,"useHoverFloatingInteraction");var Tt=ne(he(),1),Li=ne(wn(),1);var Oc={current:null};function Cc(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:o=null,mouseOnly:s=!1,restMs:c=0,move:l=!0,triggerElementRef:d=Oc,externalTree:a,isActiveTrigger:f=!0,getHandleCloseContext:g,isClosing:u,shouldOpen:m,guardStaleOpen:R=!1}=t,p="rootStore"in e?e.rootStore:e,{dataRef:h,events:E}=p.context,y=Ge(a),x=Zn(p),b=Tt.useRef(!1),T=Oe(o),P=Oe(r),v=Oe(c),O=Oe(n),A=Oe(m),N=Oe(u),G=X(()=>Dn(h.current.openEvent?.type,x.interactedInside)),Y=X(()=>A.current?.()!==!1),L=X((_,F,C)=>{let W=p.context.triggerElements;if(W.hasElement(F))return!_||!B(_,F);if(!ee(C))return!1;let Q=C;return W.hasMatchingElement(Z=>B(Z,Q))&&(!_||!B(_,Q))}),M=X(()=>{if(!x.handler)return;re(p.select("domReferenceElement")).removeEventListener("mousemove",x.handler),x.handler=void 0}),I=X(()=>{zt(x)});return f&&(x.handleCloseOptions=T.current?.__options),Tt.useEffect(()=>M,[M]),Tt.useEffect(()=>{if(!n)return;function _(F){F.open?b.current=!1:(b.current=F.reason===te.triggerHover,M(),x.openChangeTimeout.clear(),x.restTimeout.clear(),x.blockMouseMove=!0,x.restTimeoutPending=!1)}return i(_,"onOpenChangeLocal"),E.on("openchange",_),()=>{E.off("openchange",_)}},[n,E,x,M]),Tt.useEffect(()=>{if(!n)return;function _(D,$=!0){let z=gt(P.current,"close",x.pointerType);z?x.openChangeTimeout.start(z,()=>{p.setOpen(!1,fe(te.triggerHover,D)),y?.events.emit("floating.closed",D)}):$&&(x.openChangeTimeout.clear(),p.setOpen(!1,fe(te.triggerHover,D)),y?.events.emit("floating.closed",D))}i(_,"closeWithDelay");let F=d.current??(f?p.select("domReferenceElement"):null);if(!ee(F))return;function C(D){if(x.openChangeTimeout.clear(),x.blockMouseMove=!1,s&&!tt(x.pointerType))return;let $=Er(v.current),z=gt(P.current,"open",x.pointerType),ce=Te(D),j=D.currentTarget??null,xe=p.select("domReferenceElement"),H=j;if(ee(ce)&&!p.context.triggerElements.hasElement(ce)){for(let U of p.context.triggerElements.elements())if(B(U,ce)){H=U;break}}ee(j)&&ee(xe)&&!p.context.triggerElements.hasElement(j)&&B(j,xe)&&(H=xe);let ie=H==null?!1:L(xe,H,ce),ae=p.select("open"),Se=N.current?.()??p.select("transitionStatus")==="ending",J=!ae&&Se&&b.current,me=!ie&&ee(H)&&ee(xe)&&B(xe,H)&&J,Ee=$>0&&!z,ge=ie&&(ae||J)||me,ve=!ae||ie;if(ge){Y()&&p.setOpen(!0,fe(te.triggerHover,D,H));return}Ee||(z?x.openChangeTimeout.start(z,()=>{ve&&Y()&&p.setOpen(!0,fe(te.triggerHover,D,H))}):ve&&Y()&&p.setOpen(!0,fe(te.triggerHover,D,H)))}i(C,"onMouseEnter");function W(D){if(G()){I();return}M();let $=p.select("domReferenceElement"),z=re($);x.restTimeout.clear(),x.restTimeoutPending=!1;let ce=h.current.floatingContext??g?.();if(bt(D.relatedTarget,p.context.triggerElements))return;if(T.current&&ce){p.select("open")||x.openChangeTimeout.clear();let xe=d.current;x.handler=T.current({...ce,tree:y,x:D.clientX,y:D.clientY,onClose(){I(),M(),O.current&&!G()&&xe===p.select("domReferenceElement")&&_(D,!0)}}),z.addEventListener("mousemove",x.handler),x.handler(D);return}(x.pointerType!=="touch"||!B(p.select("floatingElement"),D.relatedTarget))&&_(D)}i(W,"onMouseLeave");function Q(D){B(F,D.relatedTarget)||(x.openChangeTimeout.clear(),x.restTimeout.clear(),x.restTimeoutPending=!1)}i(Q,"onMouseOut");let Z=R?q(F,"mouseout",Q):void 0;return l?_e(q(F,"mousemove",C,{once:!0}),q(F,"mouseenter",C),q(F,"mouseleave",W),Z):_e(q(F,"mouseenter",C),q(F,"mouseleave",W),Z)},[M,I,h,P,p,n,T,x,f,L,G,s,l,v,d,y,O,g,N,Y,R]),Tt.useMemo(()=>{if(!n)return;function _(F){x.pointerType=F.pointerType}return i(_,"setPointerRef"),{onPointerDown:_,onPointerEnter:_,onMouseMove(F){let{nativeEvent:C}=F,W=F.currentTarget,Q=p.select("domReferenceElement"),Z=p.select("open"),D=L(Q,W,F.target);if(s&&!tt(x.pointerType))return;if(Z&&D&&x.handleCloseOptions?.blockPointerEvents){let ce=p.select("floatingElement");if(ce){let j=x.handleCloseOptions?.getScope?.()??W.ownerDocument.body;Qn(x,{scopeElement:j,referenceElement:W,floatingElement:ce})}}let $=Er(v.current);if(Z&&!D||$===0||!D&&x.restTimeoutPending&&F.movementX**2+F.movementY**2<2)return;x.restTimeout.clear();function z(){if(x.restTimeoutPending=!1,G())return;let ce=p.select("open");!x.blockMouseMove&&(!ce||D)&&Y()&&p.setOpen(!0,fe(te.triggerHover,C,W))}i(z,"handleMouseMove"),x.pointerType==="touch"?Li.flushSync(()=>{z()}):D&&Z?z():(x.restTimeoutPending=!0,x.restTimeout.start($,z))}}},[n,x,G,L,s,p,v,Y])}i(Cc,"useHoverReferenceInteraction");var De=ne(he(),1);var Pc="Escape";function Ni(e){return Ce.engine.webkit&&e.movementX===0&&e.movementY===0}i(Ni,"isStationaryWebKitPointer");function tr(e,t,n){switch(e){case"vertical":return t;case"horizontal":return n;default:return t||n}}i(tr,"doSwitch");function er(e,t){return tr(t,e===gr||e===Cn,e===Zt||e===en)}i(er,"isMainOrientationKey");function Jr(e,t,n){return tr(t,e===Cn,n?e===Zt:e===en)||e==="Enter"||e===" "||e===""}i(Jr,"isMainOrientationToEndKey");function Ic(e,t,n){return tr(t,n?e===Zt:e===en,e===Cn)}i(Ic,"isCrossOrientationOpenKey");function Mc(e,t,n,r){let o=n?e===en:e===Zt,s=e===gr;return t==="both"||t==="horizontal"&&r?e===Pc:tr(t,o,s)}i(Mc,"isCrossOrientationCloseKey");function Ac(e,t){let{listRef:n,activeIndex:r,onNavigate:o=i(()=>{},"onNavigateProp"),enabled:s=!0,selectedIndex:c=null,allowEscape:l=!1,loopFocus:d=!1,nested:a=!1,rtl:f=!1,virtual:g=!1,focusItemOnOpen:u="auto",focusItemOnHover:m=!0,openOnArrowKeyDown:R=!0,disabledIndices:p=void 0,orientation:h="vertical",parentOrientation:E,id:y,resetOnPointerLeave:x=!0,externalTree:b,grid:T}=t,P=T!=null,v="rootStore"in e?e.rootStore:e,O=v.useState("open"),A=v.useState("floatingElement"),N=v.useState("domReferenceElement"),G=v.context.dataRef,Y=nn(A),L=tn(N),M=Oe(Y),I=ot(),_=Ge(b),F=De.useRef(u),C=De.useRef(c??-1),W=De.useRef(null),Q=De.useRef(!0),Z=X(w=>{o(C.current===-1?null:C.current,w)}),D=De.useRef(!!A),$=De.useRef(O),z=De.useRef(!1),ce=De.useRef(!1),j=De.useRef(null),xe=Oe(p),H=Oe(O),ie=Oe(c),ae=Oe(x),Se=Ct(),J=Ct(),me=X(()=>{function w(oe){g?_?.events.emit("virtualfocus",oe):j.current=Xt(oe,{sync:z.current,preventScroll:!0})}i(w,"runFocus");let S=n.current[C.current],se=ce.current;S&&w(S),(z.current?oe=>oe():oe=>Se.request(oe))(()=>{let oe=n.current[C.current]||S;if(!oe)return;S||w(oe),K&&(se||!Q.current)&&oe.scrollIntoView?.({block:"nearest",inline:"nearest"})})});V(()=>{G.current.orientation=h},[G,h]),V(()=>{s&&(O&&A?(C.current=c??-1,F.current&&c!=null&&(ce.current=!0,Z())):D.current&&(C.current=-1,Z()))},[s,O,A,c,Z]),V(()=>{if(s){if(!O){z.current=!1;return}if(A)if(r==null){if(z.current=!1,ie.current!=null)return;if(D.current&&(C.current=-1,me()),(!$.current||!D.current)&&F.current&&(W.current!=null||F.current===!0&&W.current==null)){let w=0,S=i(()=>{n.current[0]==null?(w<2&&(w?k=>J.request(k):queueMicrotask)(S),w+=1):(C.current=W.current==null||Jr(W.current,h,f)||a?Nn(n):xr(n),W.current=null,Z())},"waitForListPopulated");S()}}else yr(n.current,r)||(C.current=r,me(),ce.current=!1)}},[s,O,A,r,ie,a,n,h,f,Z,me,J]),V(()=>{if(!s||A||!_||g||!D.current)return;let w=_.nodesRef.current,S=w.find(oe=>oe.id===I)?.context?.elements.floating,se=ke(re(N??S??null)),k=w.some(oe=>oe.context&&B(oe.context.elements.floating,se));S&&!k&&Q.current&&S.focus({preventScroll:!0})},[s,A,N,_,I,g]),V(()=>{$.current=O,D.current=!!A}),V(()=>{O||(W.current=null,F.current=u)},[O,u]);let Ee=r!=null,ge=X(w=>{if(!H.current)return;let S=n.current.indexOf(w.currentTarget);S!==-1&&(C.current!==S||r!==S)&&(C.current=S,Z(w))}),ve=X(()=>E??_?.nodesRef.current.find(w=>w.id===I)?.context?.dataRef?.current.orientation),U=X(()=>Nn(n,xe.current)),ue=X(w=>{if(Q.current=!1,z.current=!0,w.which===229||!H.current&&w.currentTarget===M.current)return;if(a&&Mc(w.key,h,f,P)){er(w.key,ve())||ze(w),v.setOpen(!1,fe(te.listNavigation,w.nativeEvent)),ye(N)&&(g?_?.events.emit("virtualfocus",N):N.focus());return}let S=C.current,se=Nn(n,p),k=xr(n,p);if(L||(w.key==="Home"&&(ze(w),C.current=se,Z(w)),w.key==="End"&&(ze(w),C.current=k,Z(w))),T!=null){let oe=T(w,C.current,n,h,d,f,p,se,k);if(oe!=null&&(C.current=oe,Z(w)),h==="both")return}if(er(w.key,h)){if(ze(w),O&&!g&&ke(w.currentTarget.ownerDocument)===w.currentTarget){C.current=Jr(w.key,h,f)?se:k,Z(w);return}Jr(w.key,h,f)?d?S>=k?l&&S!==n.current.length?C.current=-1:(z.current=!1,C.current=se):C.current=It(n.current,{startingIndex:S,disabledIndices:p}):C.current=Math.min(k,It(n.current,{startingIndex:S,disabledIndices:p})):d?S<=se?l&&S!==-1?C.current=n.current.length:(z.current=!1,C.current=k):C.current=It(n.current,{startingIndex:S,decrement:!0,disabledIndices:p}):C.current=Math.max(se,It(n.current,{startingIndex:S,decrement:!0,disabledIndices:p})),yr(n.current,C.current)&&(C.current=-1),Z(w)}}),K=De.useMemo(()=>({onFocus(S){z.current=!0,ge(S)},onClick:i(({currentTarget:S})=>S.focus({preventScroll:!0}),"onClick"),onMouseMove(S){Ni(S)||(z.current=!0,ce.current=!1,m&&ge(S))},onPointerLeave(S){if(!H.current||!Q.current||S.pointerType==="touch")return;z.current=!0;let se=S.relatedTarget;if(!(!m||n.current.includes(se))&&ae.current&&(j.current?.(),j.current=null,C.current=-1,Z(S),!g)){let k=M.current,oe=ke(re(k));k&&B(k,oe)&&k.focus({preventScroll:!0})}}}),[ge,H,M,m,n,Z,ae,g]),pe=De.useMemo(()=>g&&O&&Ee&&{"aria-activedescendant":`${y}-${r}`},[g,O,Ee,y,r]),be=De.useMemo(()=>({"aria-orientation":h==="both"?void 0:h,...L?{}:pe,onKeyDown(w){if(w.key==="Tab"&&w.shiftKey&&O&&!g){let S=Te(w.nativeEvent);if(S&&!B(M.current,S))return;ze(w),v.setOpen(!1,fe(te.focusOut,w.nativeEvent)),ye(N)&&N.focus();return}ue(w)},onPointerMove(w){Ni(w)||(Q.current=!0)}}),[pe,ue,M,h,L,v,O,g,N]),le=De.useMemo(()=>{function w(k){v.setOpen(!0,fe(te.listNavigation,k.nativeEvent,k.currentTarget))}i(w,"openOnNavigationKeyDown");function S(k){u==="auto"&&In(k.nativeEvent)&&(F.current=!g)}i(S,"checkVirtualMouse");function se(k){F.current=u,u==="auto"&&Yt(k.nativeEvent)&&(F.current=!0)}return i(se,"checkVirtualPointer"),{onKeyDown(k){let oe=v.select("open");Q.current=!1;let Fe=k.key.startsWith("Arrow"),et=Ic(k.key,ve(),f),Le=er(k.key,h),Rt=(a?et:Le)||k.key==="Enter"||k.key.trim()==="";if(g&&oe)return ue(k);if(!(!oe&&!R&&Fe)){if(Rt){let ft=er(k.key,ve());W.current=a&&ft?null:k.key}if(a){et&&(ze(k),oe?(C.current=U(),Z(k)):w(k));return}Le&&(ie.current!=null&&(C.current=ie.current),ze(k),!oe&&R?w(k):ue(k),oe&&Z(k))}},onFocus(k){v.select("open")&&!g&&(C.current=-1,Z(k))},onPointerDown:se,onPointerEnter:se,onMouseDown:S,onClick:S}},[ue,u,U,a,Z,v,R,h,ve,f,ie,g]),Me=De.useMemo(()=>({...pe,...le}),[pe,le]);return De.useMemo(()=>s?{reference:Me,floating:be,item:K,trigger:le}:{},[s,Me,be,le,K])}i(Ac,"useListNavigation");var Nt=ne(he(),1);function kc(e,t){let{listRef:n,elementsRef:r,activeIndex:o,onMatch:s,disabledIndices:c,onTyping:l,enabled:d=!0,resetMs:a=750,selectedIndex:f=null}=t,g="rootStore"in e?e.rootStore:e,u=g.useState("open"),m=Ne(),R=Nt.useRef(""),p=Nt.useRef(f??o??-1),h=Nt.useRef(null),E=X(b=>{function T(M){return r?.current[M]}i(T,"getElement");function P(M){let I=T(M);return I&&!Mt(I)||I?.matches(":disabled")?!1:c==null||!br(ro,M,c)}i(P,"isItemAvailable");function v(M,I,_=0){if(M.length===0)return-1;let F=(_%M.length+M.length)%M.length,C=I.toLowerCase();for(let W=0;W<M.length;W+=1){let Q=(F+W)%M.length;if(!(!M[Q]?.toLowerCase().startsWith(C)||!P(Q)))return Q}return-1}i(v,"getMatchingIndex");let O=n.current;if(R.current.length>0&&b.key===" "&&(ze(b),l?.(!0)),R.current.length>0&&R.current[0]!==" "&&v(O,R.current)===-1&&b.key!==" "&&l?.(!1),O==null||b.key.length!==1||b.ctrlKey||b.metaKey||b.altKey)return;u&&b.key!==" "&&(ze(b),l?.(!0));let A=R.current==="";A&&(p.current=f??o??-1),O.every((M,I)=>M&&P(I)?M[0]?.toLowerCase()!==M[1]?.toLowerCase():!0)&&R.current===b.key&&(R.current="",p.current=h.current),R.current+=b.key,m.start(a,()=>{R.current="",p.current=h.current,l?.(!1)});let Y=((A?f??o??-1:p.current)??0)+1,L=v(O,R.current,Y);L!==-1?(s?.(L),h.current=L):b.key!==" "&&(R.current="",l?.(!1))}),y=X(b=>{let T=b.relatedTarget,P=g.select("domReferenceElement"),v=g.select("floatingElement");B(P,T)||B(v,T)||(m.clear(),R.current="",p.current=h.current,l?.(!1))});V(()=>{!u&&f!==null||(m.clear(),h.current=null,R.current!==""&&(R.current=""))},[u,f,m]);let x=Nt.useMemo(()=>({onKeyDown:E,onBlur:y}),[E,y]);return Nt.useMemo(()=>d?{reference:x,floating:x}:{},[d,x])}i(kc,"useTypeahead");var _i=.1,Fc=_i*_i,Re=.5;function nr(e,t,n,r,o,s){return r>=t!=s>=t&&e<=(o-n)*(t-r)/(s-r)+n}i(nr,"hasIntersectingEdge");function rr(e,t,n,r,o,s,c,l,d,a){let f=!1;return nr(e,t,n,r,o,s)&&(f=!f),nr(e,t,o,s,c,l)&&(f=!f),nr(e,t,c,l,d,a)&&(f=!f),nr(e,t,d,a,n,r)&&(f=!f),f}i(rr,"isPointInQuadrilateral");function Dc(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}i(Dc,"isInsideRect");function or(e,t,n,r,o,s){let c=Math.min(n,o),l=Math.max(n,o),d=Math.min(r,s),a=Math.max(r,s);return e>=c&&e<=l&&t>=d&&t<=a}i(or,"isInsideAxisAlignedRect");function Lc(e={}){let{blockPointerEvents:t=!1}=e,n=new Ke,r=i(({x:o,y:s,placement:c,elements:l,onClose:d,nodeId:a,tree:f})=>{let g=c?.split("-")[0],u=!1,m=null,R=null,p=typeof performance<"u"?performance.now():0;function h(y,x){let b=performance.now(),T=b-p;if(m===null||R===null||T===0)return m=y,R=x,p=b,!1;let P=y-m,v=x-R,O=P*P+v*v,A=T*T*Fc;return m=y,R=x,p=b,O<A}i(h,"isCursorMovingSlowly");function E(){n.clear(),d()}return i(E,"close"),i(function(x){n.clear();let b=l.domReference,T=l.floating;if(!b||!T||g==null||o==null||s==null)return;let{clientX:P,clientY:v}=x,O=Te(x),A=x.type==="mouseleave",N=B(T,O),G=B(b,O);if(N&&(u=!0,!A))return;if(G&&(u=!1,!A)){u=!0;return}if(A&&ee(x.relatedTarget)&&B(T,x.relatedTarget))return;function Y(){return!!(f&&Ze(f.nodesRef.current,a).length>0)}i(Y,"hasOpenChildNode");function L(){Y()||E()}if(i(L,"closeIfNoOpenChild"),Y())return;let M=b.getBoundingClientRect(),I=T.getBoundingClientRect(),_=o>I.right-I.width/2,F=s>I.bottom-I.height/2,C=I.width>M.width,W=I.height>M.height,Q=(C?M:I).left,Z=(C?M:I).right,D=(W?M:I).top,$=(W?M:I).bottom;if(g==="top"&&s>=M.bottom-1||g==="bottom"&&s<=M.top+1||g==="left"&&o>=M.right-1||g==="right"&&o<=M.left+1){L();return}let z=!1;switch(g){case"top":z=or(P,v,Q,M.top+1,Z,I.bottom-1);break;case"bottom":z=or(P,v,Q,I.top+1,Z,M.bottom-1);break;case"left":z=or(P,v,I.right-1,$,M.left+1,D);break;case"right":z=or(P,v,M.right-1,$,I.left+1,D);break;default:}if(z)return;if(u&&!Dc(P,v,M)){L();return}if(!A&&h(P,v)){L();return}let ce=!1;switch(g){case"top":{let j=C?Re/2:Re*4,xe=C||_?o+j:o-j,H=C?o-j:_?o+j:o-j,ie=s+Re+1,ae=_||C?I.bottom-Re:I.top,Se=_?C?I.bottom-Re:I.top:I.bottom-Re;ce=rr(P,v,xe,ie,H,ie,I.left,ae,I.right,Se);break}case"bottom":{let j=C?Re/2:Re*4,xe=C||_?o+j:o-j,H=C?o-j:_?o+j:o-j,ie=s-Re,ae=_||C?I.top+Re:I.bottom,Se=_?C?I.top+Re:I.bottom:I.top+Re;ce=rr(P,v,xe,ie,H,ie,I.left,ae,I.right,Se);break}case"left":{let j=W?Re/2:Re*4,xe=W||F?s+j:s-j,H=W?s-j:F?s+j:s-j,ie=o+Re+1,ae=F||W?I.right-Re:I.left,Se=F?W?I.right-Re:I.left:I.right-Re;ce=rr(P,v,ae,I.top,Se,I.bottom,ie,xe,ie,H);break}case"right":{let j=W?Re/2:Re*4,xe=W||F?s+j:s-j,H=W?s-j:F?s+j:s-j,ie=o-Re,ae=F||W?I.left+Re:I.right,Se=F?W?I.left+Re:I.right:I.left+Re;ce=rr(P,v,ie,xe,ie,H,ae,I.top,Se,I.bottom);break}default:}ce?u||n.start(40,L):L()},"onMouseMove")},"fn");return r.__options={...e,blockPointerEvents:t},r}i(Lc,"safePolygon");var Ve=ne(he(),1);function Hi(e){return Nc(e,e.rootContext)}i(Hi,"useBaseUIFloating");function Nc(e,t){let{nodeId:n,externalTree:r}=e,o=t.useState("referenceElement"),s=t.useState("floatingElement"),c=t.useState("domReferenceElement"),l=t.useState("open"),d=t.useState("floatingId"),[a,f]=Ve.useState(null),[g,u]=Ve.useState(void 0),[m,R]=Ve.useState(void 0),p=Ve.useRef(null),h=Ge(r),E=Ve.useMemo(()=>({reference:o,floating:s,domReference:c}),[o,s,c]),y=Ci({...e,elements:{...E,...a&&{reference:a}}}),x=ee(g)?g:null,b=m===void 0?t.state.floatingElement:m;t.useSyncedValue("referenceElement",g??null),t.useSyncedValue("domReferenceElement",g===void 0?c:x),t.useSyncedValue("floatingElement",b);let T=Ve.useCallback(G=>{let Y=ee(G)?{getBoundingClientRect:i(()=>G.getBoundingClientRect(),"getBoundingClientRect"),getClientRects:i(()=>G.getClientRects(),"getClientRects"),contextElement:G}:G;f(Y),y.refs.setReference(Y)},[y.refs]),P=Ve.useCallback(G=>{(ee(G)||G===null)&&(p.current=G,u(G)),(ee(y.refs.reference.current)||y.refs.reference.current===null||G!==null&&!ee(G))&&y.refs.setReference(G)},[y.refs,u]),v=Ve.useCallback(G=>{R(G),y.refs.setFloating(G)},[y.refs]),O=Ve.useMemo(()=>({...y.refs,setReference:P,setFloating:v,setPositionReference:T,domReference:p}),[y.refs,P,v,T]),A=Ve.useMemo(()=>({...y.elements,domReference:c}),[y.elements,c]),N=Ve.useMemo(()=>({...y,dataRef:t.context.dataRef,open:l,onOpenChange:t.setOpen,events:t.context.events,floatingId:d,refs:O,elements:A,nodeId:n,rootStore:t}),[y,O,A,n,t,l,d]);return V(()=>{c&&(p.current=c)},[c]),V(()=>{t.context.dataRef.current.floatingContext=N;let G=h?.nodesRef.current.find(Y=>Y.id===n);G&&(G.context=N)}),Ve.useMemo(()=>({...y,context:N,refs:O,elements:A,rootStore:t}),[y,O,A,N,t])}i(Nc,"useFloatingWithStore");var Rp=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=Rr.startingStyle]="startingStyle",e[e.endingStyle=Rr.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align",e})({});var _c={"data-popup-open":""},Hc={"data-popup-open":"","data-pressed":""},Vc={"data-open":""},Wc={"data-closed":""},Bc={"data-anchor-hidden":""},Ep={open(e){return e?_c:null}},yp={open(e){return e?Hc:null}},Qr={open(e){return e?Vc:Wc},anchorHidden(e){return e?Bc:null}},xp={...Qr,...po};var pn=ne(he(),1);var mn=ne(he(),1);function Vi(e){let t=mn.useRef(""),n=mn.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:mn.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o?e(o,o.pointerType):e(o,t.current),t.current=""},[e]),onPointerDown:n}}i(Vi,"useEnhancedClickHandler");function Yc(e,t){let n=X((s,c)=>{(typeof e=="function"?e():e)||t(c||(Ce.os.ios?"touch":""))}),{onClick:r,onPointerDown:o}=Vi(n);return pn.useMemo(()=>({onClick:r,onPointerDown:o}),[r,o])}i(Yc,"useOpenMethodTriggerProps");function Pp(e){let[t,n]=pn.useState(null),r=Yc(e,n);return Ro(e,o=>{o&&!e&&n(null)}),pn.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}i(Pp,"useOpenInteractionType");function kp(e){return vn(19)?e:e?"true":void 0}i(kp,"inertValue");var qe=ne(he(),1);var $c=i(e=>({name:"arrow",options:e,async fn(t){let{x:n,y:r,placement:o,rects:s,platform:c,elements:l,middlewareData:d}=t,{element:a,padding:f=0,offsetParent:g="real"}=at(e,t)||{};if(a==null)return{};let u=Fn(f),m={x:n,y:r},R=ln(o),p=cn(R),h=await c.getDimensions(a),E=R==="y",y=E?"top":"left",x=E?"bottom":"right",b=E?"clientHeight":"clientWidth",T=s.reference[p]+s.reference[R]-m[R]-s.floating[p],P=m[R]-s.reference[R],v=g==="real"?await c.getOffsetParent?.(a):l.floating,O=l.floating[b]||s.floating[p];(!O||!await c.isElement?.(v))&&(O=l.floating[b]||s.floating[p]);let A=T/2-P/2,N=O/2-h[p]/2-1,G=Math.min(u[y],N),Y=Math.min(u[x],N),L=G,M=O-h[p]-Y,I=O/2-h[p]/2+A,_=An(L,I,M),F=!d.arrow&&rt(o)!=null&&I!==_&&s.reference[p]/2-(I<L?G:Y)-h[p]/2<0,C=F?I<L?I-L:I-M:0;return{[R]:m[R]+C,data:{[R]:_,centerOffset:I-_-C,...F&&{alignmentOffset:C}},reset:F}}}),"baseArrow"),Wi=i((e,t)=>({...$c(e),options:[e,t]}),"arrow");var Bi={name:"hide",async fn(e){let{width:t,height:n,x:r,y:o}=e.rects.reference,s=t===0&&n===0&&r===0&&o===0,c=await e.platform.detectOverflow(e,{elementContext:"reference"});return{data:{referenceHidden:c.top-n>=0||c.right-t>=0||c.bottom-n>=0||c.left-t>=0||s}}}};var Yi={sideX:"left",sideY:"top"};var $i="--available-width",Gi="--available-height";function Ki(e,t,n){let r=e==="inline-start"||e==="inline-end";return{top:"top",right:r?n?"inline-start":"inline-end":"right",bottom:"bottom",left:r?n?"inline-end":"inline-start":"left"}[t]}i(Ki,"getLogicalSide");function Xi(e,t,n){let{rects:r,placement:o}=e;return{side:Ki(t,Ye(o),n),align:rt(o)||"center",anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}i(Xi,"getOffsetData");function Jp(e){return Gc(e,Hi)}i(Jp,"useAnchorPositioning");function Gc(e,t){let{anchor:n,positionMethod:r="absolute",side:o="bottom",sideOffset:s=0,align:c="center",alignOffset:l=0,collisionBoundary:d,collisionPadding:a=5,sticky:f=!1,arrowPadding:g=5,disableAnchorTracking:u=!1,inline:m,keepMounted:R=!1,floatingRootContext:p,mounted:h,collisionAvoidance:E,shift:y,nodeId:x,adaptiveOrigin:b,lazyFlip:T=!1,externalTree:P}=e,[v,O]=qe.useState(null);!h&&v!==null&&O(null);let A=E.side||"flip",N=E.align||"flip",G=E.fallbackAxisSide||"end",Y=y?.crossAxis??!1,L=y?.rootBoundary,M=typeof n=="function"?n:void 0,I=X(M),_=M?I:n,F=Oe(n),C=Oe(h),Q=Eo()==="rtl",Z=v||{top:"top",right:"right",bottom:"bottom",left:"left","inline-end":Q?"left":"right","inline-start":Q?"right":"left"}[o],D=c==="center"?Z:`${Z}-${c}`,$=a;typeof $=="number"?$={top:$,right:$,bottom:$,left:$}:$&&($={top:$.top||0,right:$.right||0,bottom:$.bottom||0,left:$.left||0});let z=1,ce=o==="bottom"?z:0,j=o==="top"?z:0,xe=o==="right"?z:0,H=o==="left"?z:0,ie={boundary:d==="clipping-ancestors"?"clippingAncestors":d,padding:$},ae=qe.useRef(null),Se=Oe(s),J=Oe(l),me=typeof s!="function"?s:0,Ee=typeof l!="function"?l:0,ge=[];m&&ge.push(m),ge.push(Vr(de=>{let Je=Xi(de,o,Q),it=typeof Se.current=="function"?Se.current(Je):Se.current,Ue=typeof J.current=="function"?J.current(Je):J.current;return{mainAxis:it,crossAxis:Ue,alignmentAxis:Ue}},[me,Ee,Q,o]));let ve=N==="none"&&A!=="shift",U=!ve&&(f||Y||A==="shift"),ue=A==="none"?null:Yr({...ie,padding:{top:$.top+z+ce,right:$.right+z+H,bottom:$.bottom+z+j,left:$.left+z+xe},mainAxis:!Y&&A==="flip",crossAxis:N==="flip"?"alignment":!1,fallbackAxisSideDirection:G}),K=ve?null:Wr({...ie,rootBoundary:L,mainAxis:N!=="none",crossAxis:U,limiter:f||Y?void 0:Br(de=>{if(!ae.current)return{};let{width:Je,height:it}=ae.current.getBoundingClientRect(),Ue=$e(Ye(de.placement)),dt=Ue==="y"?Je:it,st=Ue==="y"?$.left+$.right:$.top+$.bottom;return{offset:dt/2+st/2}})},[ie,f,Y,L,$,N]);A==="shift"||N==="shift"||c==="center"?ge.push(K,ue):ge.push(ue,K),ge.push($r({...ie,apply({elements:{floating:de},availableWidth:Je,availableHeight:it,rects:Ue}){if(!C.current)return;let dt=de.style;dt.setProperty($i,`${Je}px`),dt.setProperty(Gi,`${it}px`);let st=Pe(de).devicePixelRatio||1,{x:jt,y:xn,width:bn,height:cr}=Ue.reference,lr=(Math.round((jt+bn)*st)-Math.round(jt*st))/st,ar=(Math.round((xn+cr)*st)-Math.round(xn*st))/st;dt.setProperty("--anchor-width",`${lr}px`),dt.setProperty("--anchor-height",`${ar}px`)}}),Wi(de=>({element:ae.current||re(de.elements.floating).createElement("div"),padding:g,offsetParent:"floating"}),[g]),{name:"transformOrigin",fn(de){let{elements:Je,middlewareData:it,placement:Ue,rects:dt,y:st}=de,jt=Ye(Ue),xn=$e(jt),bn=ae.current,cr=it.arrow?.x||0,lr=it.arrow?.y||0,ar=bn?.clientWidth||0,os=bn?.clientHeight||0,ur=cr+ar/2,to=lr+os/2,is=Math.abs(it.shift?.y||0),ss=dt.reference.height/2,qt=typeof s=="function"?s(Xi(de,o,Q)):s,cs=is>qt,ls={top:`${ur}px calc(100% + ${qt}px)`,bottom:`${ur}px ${-qt}px`,left:`calc(100% + ${qt}px) ${to}px`,right:`${-qt}px ${to}px`}[jt],as=`${ur}px ${dt.reference.y+ss-st}px`;return Je.floating.style.setProperty("--transform-origin",U&&xn==="y"&&cs?as:ls),{}}},Bi,b),V(()=>{!h&&p&&p.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[h,p]);let pe=qe.useMemo(()=>({elementResize:!u&&typeof ResizeObserver<"u",layoutShift:!u&&typeof IntersectionObserver<"u"}),[u]),{refs:be,elements:le,x:Me,y:w,middlewareData:S,update:se,placement:k,context:oe,isPositioned:Fe,floatingStyles:et}=t({rootContext:p,open:R?h:void 0,placement:D,middleware:ge,strategy:r,whileElementsMounted:R?void 0:(...de)=>dn(...de,pe),nodeId:x,externalTree:P}),{sideX:Le,sideY:Rt}=S.adaptiveOrigin||Yi,ft=Fe?r:"fixed",gn=qe.useMemo(()=>{let de;return Fe?b?de={position:ft,[Le]:Me,[Rt]:w}:de={...et,position:ft}:de={position:ft,top:0,left:0},de[$i]="100vw",de[Gi]="100vh",Fe||(de.opacity=0),de},[b,ft,Le,Me,Rt,w,et,Fe]),_t=qe.useRef(null);V(()=>{if(!h)return;let de=F.current,Je=typeof de=="function"?de():de,Ue=(Ui(Je)?Je.current:Je)||null||null;Ue!==_t.current&&(be.setPositionReference(Ue),_t.current=Ue)},[h,be,_,F]),qe.useEffect(()=>{if(!h)return;let de=F.current;typeof de!="function"&&Ui(de)&&de.current!==_t.current&&(be.setPositionReference(de.current),_t.current=de.current)},[h,be,_,F]),qe.useEffect(()=>{if(R&&h&&le.reference&&le.floating)return dn(le.reference,le.floating,se,pe)},[R,h,le,se,pe]);let Et=Ye(k),hn=Ki(o,Et,Q),Rn=rt(k)||"center",En=!!S.hide?.referenceHidden;V(()=>{T&&h&&Fe&&Et!==Z&&O(Et)},[T,h,Fe,Et,Z]);let yn=qe.useMemo(()=>({position:"absolute",top:S.arrow?.y,left:S.arrow?.x}),[S.arrow]),eo=S.arrow?.centerOffset!==0;return qe.useMemo(()=>({positionerStyles:gn,arrowStyles:yn,arrowRef:ae,arrowUncentered:eo,side:hn,align:Rn,physicalSide:Et,anchorHidden:En,refs:be,context:oe,isPositioned:Fe,update:se}),[gn,yn,ae,eo,hn,Rn,Et,En,be,oe,Fe,se])}i(Gc,"useAnchorPositioningWithHook");function Ui(e){return e!=null&&"current"in e}i(Ui,"isRef");var zi=ne(he(),1),ji=ne(Ht(),1);var eg=zi.forwardRef(i(function(t,n){let{cutout:r,...o}=t,s;if(r){let c=r.getBoundingClientRect();s=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${c.left}px ${c.top}px,${c.left}px ${c.bottom}px,${c.right}px ${c.bottom}px,${c.right}px ${c.top}px,${c.left}px ${c.top}px)`}return(0,ji.jsx)("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:s}})},"InternalBackdrop"));function qi(e){return e==="starting"?Mo:ct}i(qi,"getDisabledMountTransitionStyles");function ug(e,t,{styles:n,transitionStatus:r,props:o,refs:s,hidden:c,inert:l=!1}){let d={...n};return l&&(d.pointerEvents="none"),Tn("div",e,{state:t,ref:s,props:[{role:"presentation",hidden:c,style:d},qi(r),o],stateAttributesMapping:Qr})}i(ug,"usePositioner");var ns=ne(he(),1);var Ji={},Qi={},Zi="";function ir(e,t){return Jt(e)?e:t}i(ir,"getViewportScroller");function es(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ir(t,n)).overflowY)}i(es,"isPageScrollLocked");function Xc(e){if(typeof document>"u")return!1;let t=re(e);return Pe(t).innerWidth-t.documentElement.clientWidth>0}i(Xc,"hasInsetScrollbars");function Uc(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;let n=re(e),r=n.documentElement,o=n.body,s=ir(r,o),c=s.style.overflowY,l=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",s.style.overflowY="scroll";let d=s.offsetWidth;s.style.overflowY="hidden";let a=s.offsetWidth;return s.style.overflowY=c,r.style.scrollbarGutter=l,d===a}i(Uc,"supportsStableScrollbarGutter");function Kc(e){let t=re(e),n=t.documentElement,r=t.body,o=ir(n,r),s={overflowY:o.style.overflowY,overflowX:o.style.overflowX};return Object.assign(o.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(o.style,s)}}i(Kc,"preventScrollOverlayScrollbars");function zc(e){let t=re(e),n=t.documentElement,r=t.body,o=Pe(n),s=0,c=0,l=!1,d=fo.create();if(Ce.engine.webkit&&(o.visualViewport?.scale??1)!==1)return()=>{};function a(){let m=o.getComputedStyle(n),R=o.getComputedStyle(r),E=(m.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";s=n.scrollTop,c=n.scrollLeft,Ji={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},Zi=n.style.scrollBehavior,Qi={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let y=n.scrollHeight>n.clientHeight,x=n.scrollWidth>n.clientWidth,b=m.overflowY==="scroll"||R.overflowY==="scroll",T=m.overflowX==="scroll"||R.overflowX==="scroll",P=Math.max(0,o.innerWidth-r.clientWidth),v=Math.max(0,o.innerHeight-r.clientHeight),O=parseFloat(R.marginTop)+parseFloat(R.marginBottom),A=parseFloat(R.marginLeft)+parseFloat(R.marginRight),N=ir(n,r);if(l=Uc(e),l){n.style.scrollbarGutter=E,N.style.overflowY="hidden",N.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:E,overflowY:"hidden",overflowX:"hidden"}),(y||b)&&(n.style.overflowY="scroll"),(x||T)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:O||v?`calc(100dvh - ${O+v}px)`:"100dvh",width:A||P?`calc(100vw - ${A+P}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=s,r.scrollLeft=c,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}i(a,"lockScroll");function f(){Object.assign(n.style,Ji),Object.assign(r.style,Qi),l||(n.scrollTop=s,n.scrollLeft=c,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=Zi)}i(f,"cleanup");function g(){f(),d.request(a)}i(g,"handleResize"),a();let u=q(o,"resize",g);return()=>{d.cancel(),f(),typeof o.removeEventListener=="function"&&u()}}i(zc,"preventScrollInsetScrollbars");var Zr=class{static{i(this,"ScrollLocker")}lockCount=0;restore=null;timeoutLock=Ke.create();timeoutUnlock=Ke.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=i(()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)},"release");unlock=i(()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)},"unlock");lock(t){if(this.lockCount===0||this.restore!==null)return;let n=re(t),r=n.documentElement,o=n.body,s=Pe(r);if(es(s,r,o)){let l=new s.MutationObserver(()=>{es(s,r,o)||(l.disconnect(),this.restore=null,this.lock(t))}),d={attributes:!0};l.observe(r,d),l.observe(o,d),this.restore=()=>l.disconnect();return}let c=Ce.os.ios||!Xc(t);this.restore=c?Kc(t):zc(t)}},jc=new Zr;function ts(e=!0,t=null){V(()=>{if(e)return jc.acquire(t)},[e,t])}i(ts,"useScrollLock");var qc=20;function Tg(e,t,n,r){let[o,s]=ns.useState(!1);V(()=>{if(!e||!t||n==null){s(!1);return}let c=re(n).documentElement.clientWidth,l=n.offsetWidth;s(c>0&&l>0&&l>=c-qc)},[e,t,n]),ts(e&&(!t||o),r)}i(Tg,"useAnchoredPopupScrollLock");var Jc="ArrowUp",Qc="ArrowDown",Zc="ArrowLeft",el="ArrowRight",tl="Home",nl="End";var Pg=new Set([Jc,Qc,Zc,el,tl,nl]);var sr=ne(he(),1);var rl=sr.createContext(void 0);function kg(e){let t=sr.useContext(rl);if(t===void 0&&!e)throw new Error(no(69));return t}i(kg,"useToolbarRootContext");var rs=ne(he(),1);function Hg(e){let[t,n]=rs.useState({current:e,previous:null});return Object.is(e,t.current)||n({current:e,previous:t.current}),t.previous}i(Hg,"usePreviousValue");export{In as a,tt as b,on as c,Ye as d,Pt as e,Hn as f,$l as g,Gl as h,At as i,gt as j,ys as k,xs as l,Oe as m,$t as n,Ao as o,Al as p,kl as q,$o as r,As as s,Bn as t,ot as u,Ge as v,ks as w,Fs as x,Ds as y,Vs as z,Ws as A,Ys as B,Xs as C,_r as D,dc as E,lf as F,Kn as G,jn as H,Kt as I,Kr as J,Kf as K,zf as L,jf as M,qf as N,xc as O,bc as P,wc as Q,Jf as R,Qf as S,Zf as T,ed as U,td as V,nd as W,qn as X,vc as Y,Sc as Z,Zn as _,Tc as $,Cc as aa,Ac as ba,kc as ca,Lc as da,Ep as ea,yp as fa,Qr as ga,xp as ha,Yc as ia,Pp as ja,kp as ka,Yi as la,Jp as ma,eg as na,qi as oa,ug as pa,ts as qa,Tg as ra,Pg as sa,kg as ta,Hg as ua};