@uniqbit/mate-core 0.20.0 → 0.21.1

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 (287) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
  3. package/claude-plugin/hooks/hooks.json +10 -1
  4. package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
  5. package/opencode-plugin/src/server.ts +9 -2
  6. package/package.json +2 -1
  7. package/src/cli/commands/artifact/delivery/environment.ts +28 -8
  8. package/src/cli/commands/artifact/delivery/link.ts +28 -9
  9. package/src/cli/commands/artifact/delivery/output.ts +7 -0
  10. package/src/cli/commands/companion/update.ts +2 -19
  11. package/src/cli/commands/factory/factory.ts +11 -1
  12. package/src/cli/commands/install.ts +47 -36
  13. package/src/cli/commands/launch/claude.ts +2 -0
  14. package/src/cli/commands/launch/shared.ts +33 -6
  15. package/src/cli/commands/plugin/install.ts +27 -11
  16. package/src/cli/commands/report/index.ts +180 -184
  17. package/src/cli/commands/report/markdown.ts +67 -72
  18. package/src/cli/commands/shared/companion-selection.ts +3 -1
  19. package/src/cli/commands/studio/access.ts +6 -14
  20. package/src/cli/commands/studio/areas.ts +112 -33
  21. package/src/cli/commands/studio/companion-add.ts +87 -0
  22. package/src/cli/commands/studio/companion-removal.ts +15 -8
  23. package/src/cli/commands/studio/factory-credential.ts +1 -15
  24. package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
  25. package/src/cli/commands/studio/factory-relay.ts +18 -0
  26. package/src/cli/commands/studio/graph-model.ts +61 -0
  27. package/src/cli/commands/studio/graph.ts +336 -0
  28. package/src/cli/commands/studio/index.ts +4 -4
  29. package/src/cli/commands/studio/payload.ts +42 -15
  30. package/src/cli/commands/studio/repository-add.ts +116 -0
  31. package/src/cli/commands/studio/routes.ts +6 -0
  32. package/src/cli/commands/studio/selection.ts +12 -3
  33. package/src/cli/commands/studio/server.ts +127 -5
  34. package/src/cli/commands/studio/services.ts +40 -0
  35. package/src/cli/commands/studio/terminal.ts +45 -3
  36. package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
  37. package/src/cli/commands/studio/workset-session.ts +47 -14
  38. package/src/cli/commands/unwrap.ts +3 -0
  39. package/src/cli/commands/update.ts +2 -0
  40. package/src/cli/commands/vscode/release-vsix.json +4 -0
  41. package/src/cli/commands/vscode/setup.ts +71 -13
  42. package/src/cli/commands/vscode/vsix.ts +48 -7
  43. package/src/cli/commands/working/cleanup.ts +40 -8
  44. package/src/cli/commands/working/worktree.ts +176 -35
  45. package/src/cli/main.ts +17 -2
  46. package/src/cli/usage.ts +1 -1
  47. package/src/hooks/rtk-worktree-git.ts +48 -0
  48. package/src/hooks/validate-artifact-path.ts +38 -7
  49. package/src/lib/delivery/branch-template.ts +122 -0
  50. package/src/lib/delivery/branches.ts +21 -16
  51. package/src/lib/delivery/checkout.ts +102 -0
  52. package/src/lib/delivery/environment.ts +2 -0
  53. package/src/lib/delivery/merge-git.ts +13 -1
  54. package/src/lib/delivery/record-delivery.ts +83 -29
  55. package/src/lib/delivery/record.ts +15 -3
  56. package/src/lib/delivery/resolve-branch.ts +157 -110
  57. package/src/lib/factory/attach-client.ts +11 -1
  58. package/src/lib/factory/broker.ts +37 -40
  59. package/src/lib/factory/client.ts +22 -1
  60. package/src/lib/factory/clone-url.ts +39 -0
  61. package/src/lib/factory/command.ts +21 -5
  62. package/src/lib/factory/git-auth.ts +61 -0
  63. package/src/lib/factory/git-credential-store.ts +181 -0
  64. package/src/lib/factory/ids.ts +12 -2
  65. package/src/lib/factory/outcomes/actions.ts +20 -4
  66. package/src/lib/factory/outcomes/index.ts +77 -11
  67. package/src/lib/factory/outcomes/lifecycle.ts +9 -2
  68. package/src/lib/factory/outcomes/sessions.ts +23 -1
  69. package/src/lib/factory/prepare.ts +9 -3
  70. package/src/lib/factory/runner/scheduler.ts +96 -14
  71. package/src/lib/factory/runner/workflow.ts +5 -1
  72. package/src/lib/factory/runtime.ts +143 -43
  73. package/src/lib/orchestrator/companion-hub.ts +6 -1
  74. package/src/lib/orchestrator/engine-floor.ts +48 -0
  75. package/src/lib/orchestrator/launcher.ts +34 -1
  76. package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
  77. package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
  78. package/src/lib/orchestrator/projection-claude-links.ts +32 -8
  79. package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
  80. package/src/lib/orchestrator/projection-entries.ts +22 -18
  81. package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
  82. package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
  83. package/src/lib/orchestrator/projection-types.ts +28 -1
  84. package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
  85. package/src/lib/orchestrator/session-prepare.ts +6 -1
  86. package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
  87. package/src/lib/orchestrator/types.ts +4 -0
  88. package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
  89. package/src/lib/orchestrator/working-repo-projection.ts +24 -4
  90. package/src/lib/orchestrator/wrap-pass.ts +1 -0
  91. package/src/lib/public-npm.ts +95 -50
  92. package/src/lib/session-state.ts +72 -2
  93. package/src/lib/update-checker.ts +7 -1
  94. package/src/lib/usage/aggregate.ts +202 -0
  95. package/src/lib/usage/cache.ts +87 -0
  96. package/src/lib/usage/claude-pricing.ts +71 -0
  97. package/src/lib/usage/claude.ts +189 -0
  98. package/src/lib/usage/collect.ts +56 -0
  99. package/src/lib/usage/opencode.ts +188 -0
  100. package/src/lib/usage/records.ts +80 -0
  101. package/src/lib/usage/rtk-database.ts +72 -0
  102. package/src/lib/usage/savings.ts +209 -0
  103. package/src/lib/usage/scope.ts +182 -0
  104. package/src/lib/usage/source.ts +102 -0
  105. package/src/lib/usage/types.ts +143 -0
  106. package/src/lib/usage/window.ts +37 -0
  107. package/src/lib/workset/factory-local.ts +157 -0
  108. package/src/lib/workset/record.ts +25 -11
  109. package/src/lib/workset/repositories.ts +118 -25
  110. package/src/lib/workset/worktree-include.ts +161 -0
  111. package/src/lib/workset/worktree-index.ts +6 -2
  112. package/src/lib/workset/worktree.ts +591 -101
  113. package/src/opencode/companion-hooks.ts +46 -8
  114. package/src/opencode/companion-policy.ts +18 -5
  115. package/src/opencode/enter-worktree.ts +254 -6
  116. package/src/opencode/session-register.ts +2 -2
  117. package/src/runtime/claude-bg-isolation.ts +138 -0
  118. package/src/runtime/companion-git.ts +10 -2
  119. package/src/runtime/companion-guidance.ts +17 -4
  120. package/src/runtime/current-branch.ts +16 -2
  121. package/src/runtime/entered-worktree.ts +24 -0
  122. package/src/runtime/git-tracked.ts +60 -0
  123. package/src/runtime/repo-destination.ts +72 -0
  124. package/src/runtime/repo-local.ts +25 -3
  125. package/src/runtime/rtk-git-guard.ts +66 -0
  126. package/src/runtime/runtime-document-manifest.ts +229 -19
  127. package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
  128. package/src/runtime/secret-guard.ts +9 -2
  129. package/src/runtime/secret-policy-weakening.ts +122 -0
  130. package/src/runtime/serving-claude-wrap.ts +15 -2
  131. package/src/runtime/umbrella-folder.ts +56 -0
  132. package/src/runtime/wrap-state.ts +5 -13
  133. package/src/studio.ts +37 -0
  134. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
  135. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
  136. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
  137. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
  138. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
  139. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
  140. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
  141. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
  142. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
  143. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
  144. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
  145. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
  146. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +307 -42
  147. package/src/tools/setup/capabilities/rtk.ts +93 -1
  148. package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
  149. package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
  150. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
  151. package/src/tools/setup/dynamic-plugins/install.ts +24 -22
  152. package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
  153. package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
  154. package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
  155. package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
  156. package/src/tools/setup/mate.ts +3 -3
  157. package/src/tools/setup/plugins/gitignore.ts +15 -9
  158. package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
  159. package/src/tools/setup/providers/claude.ts +25 -3
  160. package/src/tools/setup/utils.ts +4 -2
  161. package/src/tools/setup/working-repo-cleanup.ts +2 -2
  162. package/src/tools/setup/working-repo-local-state.ts +2 -0
  163. package/src/tools/setup.ts +25 -14
  164. package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
  165. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
  166. package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
  167. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
  168. package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
  169. package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
  170. package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
  171. package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
  172. package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
  173. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
  174. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
  175. package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
  176. package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
  177. package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
  178. package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
  179. package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
  180. package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
  181. package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
  182. package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
  183. package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
  184. package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
  185. package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
  186. package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
  187. package/studio-dist/client/assets/select-CnaMd617.js +1 -0
  188. package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
  189. package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
  190. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
  191. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
  192. package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
  193. package/studio-dist/client/assets/store-Dw34catY.js +1 -0
  194. package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
  195. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
  196. package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
  197. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
  198. package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
  199. package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
  200. package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
  201. package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
  202. package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
  203. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
  204. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
  205. package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
  206. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
  207. package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
  208. package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
  209. package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
  210. package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
  211. package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
  212. package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
  213. package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
  214. package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
  215. package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
  216. package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
  217. package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
  218. package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
  219. package/studio-dist/server/assets/graph-CSje3029.js +801 -0
  220. package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
  221. package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
  222. package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
  223. package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
  224. package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
  225. package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
  226. package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
  227. package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
  228. package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
  229. package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
  230. package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
  231. package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
  232. package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
  233. package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
  234. package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
  235. package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
  236. package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
  237. package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
  238. package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
  239. package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
  240. package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
  241. package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
  242. package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
  243. package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
  244. package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
  245. package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
  246. package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
  247. package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
  248. package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
  249. package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
  250. package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
  251. package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
  252. package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
  253. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
  254. package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
  255. package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
  256. package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
  257. package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
  258. package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
  259. package/studio-dist/server/server.js +582 -8
  260. package/src/cli/commands/report/collector.ts +0 -288
  261. package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
  262. package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
  263. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
  264. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
  265. package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
  266. package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
  267. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
  268. package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
  269. package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
  270. package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
  271. package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
  272. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
  273. package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
  274. package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
  275. package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
  276. package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
  277. package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
  278. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
  279. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
  280. package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
  281. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
  282. package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
  283. package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
  284. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
  285. package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
  286. package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
  287. package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
@@ -0,0 +1,756 @@
1
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
2
+ import { A as useFloatingParentNodeId, Bn as triggerPress, Bt as stopEvent, Cr as useId, Dn as focusOut, G as useValueAsRef, Hn as createChangeEventDetails, Jn as useIsoLayoutEffect, Kn as ownerDocument, Kt as isTypeableCombobox, Lt as isMouseLikePointerType, Pn as listNavigation, Rt as isVirtualClick, Ut as getFloatingFocusElement, W as useAnimationFrame, Y as useTimeout, Yn as useStableCallback, _n as webkit, _r as EMPTY_OBJECT, c as PopupTriggerMap, cn as ARROW_LEFT, dn as activeElement, ft as getMaxListIndex, gt as isIndexOutOfListBounds, i as FloatingRootStore, j as useFloatingTree, ln as ARROW_RIGHT, mn as getTarget, mt as getNextListIndex, or as isElement, pn as contains, pt as getMinListIndex, qt as isTypeableElement, sn as ARROW_DOWN, sr as isHTMLElement, un as ARROW_UP, xr as useRefWithInit, yn as ios, zt as isVirtualPointerEvent } from "./button-CgOIVdmD.js";
3
+ import { i as useScrollLock, s as useValueChanged, y as enqueueFocus } from "./fields-BbieQTD0.js";
4
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useClick.mjs
5
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
6
+ /**
7
+ * Opens or closes the floating element when clicking the reference element.
8
+ * @see https://floating-ui.com/docs/useClick
9
+ */
10
+ function useClick(store, props = {}) {
11
+ const { enabled = true, event: eventOption = "click", toggle = true, ignoreMouse = false, stickIfOpen = true, touchOpenDelay = 0, reason = triggerPress } = props;
12
+ const dataRef = store.context.dataRef;
13
+ const pointerTypeRef = import_react.useRef(void 0);
14
+ const frame = useAnimationFrame();
15
+ const touchOpenTimeout = useTimeout();
16
+ const reference = import_react.useMemo(() => {
17
+ function setOpenWithTouchDelay(nextOpen, nativeEvent, target, pointerType) {
18
+ const details = createChangeEventDetails(reason, nativeEvent, target);
19
+ if (nextOpen && pointerType === "touch" && touchOpenDelay > 0) touchOpenTimeout.start(touchOpenDelay, () => {
20
+ store.setOpen(true, details);
21
+ });
22
+ else store.setOpen(nextOpen, details);
23
+ }
24
+ function getNextOpen(open, currentTarget, isClickLikeOpenEvent) {
25
+ const openEvent = dataRef.current.openEvent;
26
+ const hasClickedOnInactiveTrigger = store.select("domReferenceElement") !== currentTarget;
27
+ if (open && hasClickedOnInactiveTrigger) return true;
28
+ if (!open) return true;
29
+ if (!toggle) return true;
30
+ if (openEvent && (typeof stickIfOpen === "function" ? stickIfOpen() : stickIfOpen)) return !isClickLikeOpenEvent(openEvent.type);
31
+ return false;
32
+ }
33
+ return {
34
+ onPointerDown(event) {
35
+ pointerTypeRef.current = isMouseLikePointerType(event.pointerType, true) && isVirtualPointerEvent(event.nativeEvent) ? "virtual" : event.pointerType;
36
+ },
37
+ onMouseDown(event) {
38
+ const pointerType = pointerTypeRef.current;
39
+ const nativeEvent = event.nativeEvent;
40
+ const open = store.select("open");
41
+ if (event.button !== 0 || eventOption === "click" || isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
42
+ const nextOpen = getNextOpen(open, event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown");
43
+ const target = getTarget(nativeEvent);
44
+ const isTypeable = isTypeableElement(target);
45
+ if (isTypeable || pointerType === "virtual") {
46
+ setOpenWithTouchDelay(nextOpen, nativeEvent, isTypeable ? target : event.currentTarget, pointerType);
47
+ return;
48
+ }
49
+ const eventCurrentTarget = event.currentTarget;
50
+ frame.request(() => {
51
+ setOpenWithTouchDelay(nextOpen, nativeEvent, eventCurrentTarget, pointerType);
52
+ });
53
+ },
54
+ onClick(event) {
55
+ if (eventOption === "mousedown-only") return;
56
+ const pointerType = pointerTypeRef.current;
57
+ if (eventOption === "mousedown" && pointerType) {
58
+ pointerTypeRef.current = void 0;
59
+ return;
60
+ }
61
+ if (isMouseLikePointerType(pointerType, true) && ignoreMouse) return;
62
+ setOpenWithTouchDelay(getNextOpen(store.select("open"), event.currentTarget, (openEventType) => openEventType === "click" || openEventType === "mousedown" || openEventType === "keydown" || openEventType === "keyup"), event.nativeEvent, event.currentTarget, pointerType);
63
+ },
64
+ onKeyDown() {
65
+ pointerTypeRef.current = void 0;
66
+ }
67
+ };
68
+ }, [
69
+ dataRef,
70
+ eventOption,
71
+ ignoreMouse,
72
+ reason,
73
+ store,
74
+ stickIfOpen,
75
+ toggle,
76
+ frame,
77
+ touchOpenTimeout,
78
+ touchOpenDelay
79
+ ]);
80
+ return import_react.useMemo(() => enabled ? { reference } : EMPTY_OBJECT, [enabled, reference]);
81
+ }
82
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
83
+ function useFloatingRootContext(options) {
84
+ const { open = false, onOpenChange, elements = {} } = options;
85
+ const floatingId = useId();
86
+ const nested = useFloatingParentNodeId() != null;
87
+ const store = useRefWithInit(() => new FloatingRootStore({
88
+ open,
89
+ transitionStatus: void 0,
90
+ onOpenChange,
91
+ referenceElement: elements.reference ?? null,
92
+ floatingElement: elements.floating ?? null,
93
+ triggerElements: new PopupTriggerMap(),
94
+ floatingId,
95
+ syncOnly: false,
96
+ nested
97
+ })).current;
98
+ useIsoLayoutEffect(() => {
99
+ const valuesToSync = {
100
+ open,
101
+ floatingId
102
+ };
103
+ if (elements.reference !== void 0) {
104
+ valuesToSync.referenceElement = elements.reference;
105
+ valuesToSync.domReferenceElement = isElement(elements.reference) ? elements.reference : null;
106
+ }
107
+ if (elements.floating !== void 0) valuesToSync.floatingElement = elements.floating;
108
+ store.update(valuesToSync);
109
+ }, [
110
+ open,
111
+ floatingId,
112
+ elements.reference,
113
+ elements.floating,
114
+ store
115
+ ]);
116
+ store.context.onOpenChange = onOpenChange;
117
+ store.context.nested = nested;
118
+ return store;
119
+ }
120
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useListNavigation.mjs
121
+ function isStationaryWebKitPointer(event) {
122
+ return webkit && event.movementX === 0 && event.movementY === 0;
123
+ }
124
+ function doSwitch(orientation, vertical, horizontal) {
125
+ switch (orientation) {
126
+ case "vertical": return vertical;
127
+ case "horizontal": return horizontal;
128
+ default: return vertical || horizontal;
129
+ }
130
+ }
131
+ function isMainOrientationKey(key, orientation) {
132
+ return doSwitch(orientation, key === "ArrowUp" || key === "ArrowDown", key === "ArrowLeft" || key === "ArrowRight");
133
+ }
134
+ function isMainOrientationToEndKey(key, orientation, rtl) {
135
+ return doSwitch(orientation, key === "ArrowDown", rtl ? key === "ArrowLeft" : key === "ArrowRight") || key === "Enter" || key === " " || key === "";
136
+ }
137
+ function isCrossOrientationOpenKey(key, orientation, rtl) {
138
+ return doSwitch(orientation, rtl ? key === ARROW_LEFT : key === ARROW_RIGHT, key === ARROW_DOWN);
139
+ }
140
+ function isCrossOrientationCloseKey(key, orientation, rtl, grid) {
141
+ const vertical = rtl ? key === ARROW_RIGHT : key === ARROW_LEFT;
142
+ const horizontal = key === ARROW_UP;
143
+ if (orientation === "both" || orientation === "horizontal" && grid) return key === "Escape";
144
+ return doSwitch(orientation, vertical, horizontal);
145
+ }
146
+ /**
147
+ * Adds arrow key-based navigation of a list of items, either using real DOM
148
+ * focus or virtual focus.
149
+ * @see https://floating-ui.com/docs/useListNavigation
150
+ */
151
+ function useListNavigation(store, props) {
152
+ const { listRef, activeIndex, onNavigate: onNavigateProp = () => {}, enabled = true, selectedIndex = null, allowEscape = false, loopFocus = false, nested = false, rtl = false, virtual = false, focusItemOnOpen = "auto", focusItemOnHover = true, openOnArrowKeyDown = true, disabledIndices = void 0, orientation = "vertical", triggerOrientation = orientation, parentOrientation, id, resetOnPointerLeave = true, externalTree, nestedReturnFocusRef, grid: navigateGrid } = props;
153
+ const isGrid = navigateGrid != null;
154
+ const open = store.useState("open");
155
+ const floatingElement = store.useState("floatingElement");
156
+ const domReferenceElement = store.useState("domReferenceElement");
157
+ const dataRef = store.context.dataRef;
158
+ const floatingFocusElement = getFloatingFocusElement(floatingElement);
159
+ const typeableComboboxReference = isTypeableCombobox(domReferenceElement);
160
+ const floatingFocusElementRef = useValueAsRef(floatingFocusElement);
161
+ const parentId = useFloatingParentNodeId();
162
+ const tree = useFloatingTree(externalTree);
163
+ const focusItemOnOpenRef = import_react.useRef(focusItemOnOpen);
164
+ const indexRef = import_react.useRef(selectedIndex ?? -1);
165
+ const keyRef = import_react.useRef(null);
166
+ const isPointerModalityRef = import_react.useRef(true);
167
+ const onNavigate = useStableCallback((event) => {
168
+ onNavigateProp(indexRef.current === -1 ? null : indexRef.current, event);
169
+ });
170
+ const previousMountedRef = import_react.useRef(!!floatingElement);
171
+ const previousOpenRef = import_react.useRef(open);
172
+ const forceSyncFocusRef = import_react.useRef(false);
173
+ const forceScrollIntoViewRef = import_react.useRef(false);
174
+ const cancelQueuedFocusRef = import_react.useRef(null);
175
+ const disabledIndicesRef = useValueAsRef(disabledIndices);
176
+ const latestOpenRef = useValueAsRef(open);
177
+ const selectedIndexRef = useValueAsRef(selectedIndex);
178
+ const resetOnPointerLeaveRef = useValueAsRef(resetOnPointerLeave);
179
+ const focusFrame = useAnimationFrame();
180
+ const waitForListPopulatedFrame = useAnimationFrame();
181
+ const focusItem = useStableCallback(() => {
182
+ focusFrame.cancel();
183
+ function runFocus(item) {
184
+ if (!virtual) cancelQueuedFocusRef.current = enqueueFocus(item, {
185
+ sync: forceSyncFocusRef.current,
186
+ preventScroll: true
187
+ });
188
+ }
189
+ const initialItem = listRef.current[indexRef.current];
190
+ const forceScrollIntoView = forceScrollIntoViewRef.current;
191
+ if (initialItem) runFocus(initialItem);
192
+ (forceSyncFocusRef.current ? (callback) => callback() : (callback) => focusFrame.request(callback))(() => {
193
+ const waitedItem = listRef.current[indexRef.current] || initialItem;
194
+ if (!waitedItem) return;
195
+ if (!initialItem) runFocus(waitedItem);
196
+ if (item && (forceScrollIntoView || !isPointerModalityRef.current)) waitedItem.scrollIntoView?.({
197
+ block: "nearest",
198
+ inline: "nearest"
199
+ });
200
+ });
201
+ });
202
+ useIsoLayoutEffect(() => {
203
+ dataRef.current.orientation = orientation;
204
+ }, [dataRef, orientation]);
205
+ useIsoLayoutEffect(() => {
206
+ if (!open) keyRef.current = null;
207
+ if (!open || focusItemOnOpen !== "auto") focusItemOnOpenRef.current = focusItemOnOpen;
208
+ }, [open, focusItemOnOpen]);
209
+ useIsoLayoutEffect(() => {
210
+ if (!enabled) return;
211
+ if (open && floatingElement) {
212
+ indexRef.current = selectedIndex ?? -1;
213
+ if (focusItemOnOpenRef.current && selectedIndex != null) {
214
+ forceScrollIntoViewRef.current = true;
215
+ onNavigate();
216
+ }
217
+ } else if (previousMountedRef.current) {
218
+ indexRef.current = -1;
219
+ onNavigate();
220
+ }
221
+ }, [
222
+ enabled,
223
+ open,
224
+ floatingElement,
225
+ selectedIndex,
226
+ onNavigate
227
+ ]);
228
+ useIsoLayoutEffect(() => {
229
+ if (!enabled) return;
230
+ if (!open) {
231
+ forceSyncFocusRef.current = false;
232
+ return;
233
+ }
234
+ if (!floatingElement) return;
235
+ if (activeIndex == null) {
236
+ forceSyncFocusRef.current = false;
237
+ if (selectedIndexRef.current != null) return;
238
+ if (previousMountedRef.current) {
239
+ indexRef.current = -1;
240
+ focusItem();
241
+ }
242
+ if ((!previousOpenRef.current || !previousMountedRef.current) && focusItemOnOpenRef.current && (keyRef.current != null || focusItemOnOpenRef.current === true && keyRef.current == null)) {
243
+ let runs = 0;
244
+ const waitForListPopulated = () => {
245
+ if (listRef.current[0] == null) {
246
+ if (runs < 2) (runs ? (callback) => waitForListPopulatedFrame.request(callback) : queueMicrotask)(waitForListPopulated);
247
+ runs += 1;
248
+ } else {
249
+ indexRef.current = keyRef.current == null || isMainOrientationToEndKey(keyRef.current, triggerOrientation, rtl) || nested ? getMinListIndex(listRef) : getMaxListIndex(listRef);
250
+ keyRef.current = null;
251
+ onNavigate();
252
+ }
253
+ };
254
+ waitForListPopulated();
255
+ }
256
+ } else if (!isIndexOutOfListBounds(listRef.current, activeIndex)) {
257
+ indexRef.current = activeIndex;
258
+ focusItem();
259
+ forceScrollIntoViewRef.current = false;
260
+ }
261
+ }, [
262
+ enabled,
263
+ open,
264
+ floatingElement,
265
+ activeIndex,
266
+ selectedIndexRef,
267
+ nested,
268
+ listRef,
269
+ triggerOrientation,
270
+ rtl,
271
+ onNavigate,
272
+ focusItem,
273
+ waitForListPopulatedFrame
274
+ ]);
275
+ useIsoLayoutEffect(() => {
276
+ if (!enabled || floatingElement || !tree || virtual || !previousMountedRef.current) return;
277
+ const nodes = tree.nodesRef.current;
278
+ const parent = nodes.find((node) => node.id === parentId)?.context?.elements.floating;
279
+ const activeEl = activeElement(ownerDocument(domReferenceElement ?? parent ?? null));
280
+ const treeContainsActiveEl = nodes.some((node) => node.context && contains(node.context.elements.floating, activeEl));
281
+ if (parent && !treeContainsActiveEl && isPointerModalityRef.current) parent.focus({ preventScroll: true });
282
+ }, [
283
+ enabled,
284
+ floatingElement,
285
+ domReferenceElement,
286
+ tree,
287
+ parentId,
288
+ virtual
289
+ ]);
290
+ useIsoLayoutEffect(() => {
291
+ previousOpenRef.current = open;
292
+ previousMountedRef.current = !!floatingElement;
293
+ });
294
+ const hasActiveIndex = activeIndex != null;
295
+ const syncCurrentTarget = useStableCallback((event) => {
296
+ if (!latestOpenRef.current) return;
297
+ const index = listRef.current.indexOf(event.currentTarget);
298
+ if (index !== -1 && (indexRef.current !== index || activeIndex !== index)) {
299
+ indexRef.current = index;
300
+ onNavigate(event);
301
+ }
302
+ });
303
+ const getParentOrientation = useStableCallback(() => {
304
+ return parentOrientation ?? tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.dataRef?.current.orientation;
305
+ });
306
+ const getMinEnabledIndex = useStableCallback(() => {
307
+ return getMinListIndex(listRef, disabledIndicesRef.current);
308
+ });
309
+ const commonOnKeyDown = useStableCallback((event) => {
310
+ isPointerModalityRef.current = false;
311
+ forceSyncFocusRef.current = true;
312
+ if (event.which === 229) return;
313
+ if (!latestOpenRef.current && event.currentTarget === floatingFocusElementRef.current) return;
314
+ if (nested && isCrossOrientationCloseKey(event.key, orientation, rtl, isGrid)) {
315
+ if (!isMainOrientationKey(event.key, getParentOrientation())) stopEvent(event);
316
+ store.setOpen(false, createChangeEventDetails(listNavigation, event.nativeEvent));
317
+ const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
318
+ if (isHTMLElement(returnElement)) returnElement.focus();
319
+ return;
320
+ }
321
+ if (activeIndex != null && activeIndex !== indexRef.current && !isIndexOutOfListBounds(listRef.current, activeIndex)) indexRef.current = activeIndex;
322
+ const currentIndex = indexRef.current;
323
+ const minIndex = getMinListIndex(listRef, disabledIndices);
324
+ const maxIndex = getMaxListIndex(listRef, disabledIndices);
325
+ if (!typeableComboboxReference) {
326
+ if (event.key === "Home") {
327
+ stopEvent(event);
328
+ indexRef.current = minIndex;
329
+ onNavigate(event);
330
+ }
331
+ if (event.key === "End") {
332
+ stopEvent(event);
333
+ indexRef.current = maxIndex;
334
+ onNavigate(event);
335
+ }
336
+ }
337
+ if (navigateGrid != null) {
338
+ const index = navigateGrid(event, indexRef.current, listRef, orientation, loopFocus, rtl, disabledIndices, minIndex, maxIndex);
339
+ if (index != null && index !== indexRef.current) {
340
+ indexRef.current = index;
341
+ onNavigate(event);
342
+ }
343
+ if (orientation === "both") return;
344
+ }
345
+ if (isMainOrientationKey(event.key, orientation)) {
346
+ stopEvent(event);
347
+ const focusedElement = activeElement(event.currentTarget.ownerDocument);
348
+ if (open && !virtual && contains(event.currentTarget, focusedElement) && !listRef.current.some((item) => item != null && contains(item, focusedElement))) {
349
+ indexRef.current = isMainOrientationToEndKey(event.key, orientation, rtl) ? minIndex : maxIndex;
350
+ onNavigate(event);
351
+ if (activeIndex === indexRef.current) focusItem();
352
+ return;
353
+ }
354
+ const { index, wrapped } = getNextListIndex(listRef.current, currentIndex, {
355
+ decrement: !isMainOrientationToEndKey(event.key, orientation, rtl),
356
+ loopFocus,
357
+ allowEscape,
358
+ disabledIndices,
359
+ minIndex,
360
+ maxIndex
361
+ });
362
+ if (wrapped) forceSyncFocusRef.current = false;
363
+ indexRef.current = index;
364
+ onNavigate(event);
365
+ }
366
+ });
367
+ const item = import_react.useMemo(() => {
368
+ return {
369
+ onFocus(event) {
370
+ forceSyncFocusRef.current = true;
371
+ syncCurrentTarget(event);
372
+ },
373
+ onClick({ currentTarget }) {
374
+ if (!virtual) currentTarget.focus({ preventScroll: true });
375
+ },
376
+ onMouseMove(event) {
377
+ if (isStationaryWebKitPointer(event)) return;
378
+ forceSyncFocusRef.current = true;
379
+ forceScrollIntoViewRef.current = false;
380
+ if (focusItemOnHover) syncCurrentTarget(event);
381
+ },
382
+ onPointerLeave(event) {
383
+ if (!latestOpenRef.current || !isPointerModalityRef.current || event.pointerType === "touch") return;
384
+ forceSyncFocusRef.current = true;
385
+ const relatedTarget = event.relatedTarget;
386
+ if (!focusItemOnHover || listRef.current.includes(relatedTarget)) return;
387
+ if (!resetOnPointerLeaveRef.current) return;
388
+ cancelQueuedFocusRef.current?.();
389
+ cancelQueuedFocusRef.current = null;
390
+ indexRef.current = -1;
391
+ onNavigate(event);
392
+ if (!virtual) {
393
+ const floatingFocusEl = floatingFocusElementRef.current;
394
+ const activeEl = activeElement(ownerDocument(floatingFocusEl));
395
+ if (floatingFocusEl && contains(floatingFocusEl, activeEl)) floatingFocusEl.focus({ preventScroll: true });
396
+ }
397
+ }
398
+ };
399
+ }, [
400
+ syncCurrentTarget,
401
+ latestOpenRef,
402
+ floatingFocusElementRef,
403
+ focusItemOnHover,
404
+ listRef,
405
+ onNavigate,
406
+ resetOnPointerLeaveRef,
407
+ virtual
408
+ ]);
409
+ const ariaActiveDescendantProp = import_react.useMemo(() => {
410
+ return virtual && open && hasActiveIndex && { "aria-activedescendant": `${id}-${activeIndex}` };
411
+ }, [
412
+ virtual,
413
+ open,
414
+ hasActiveIndex,
415
+ id,
416
+ activeIndex
417
+ ]);
418
+ const floating = import_react.useMemo(() => {
419
+ return {
420
+ ...!typeableComboboxReference ? ariaActiveDescendantProp : {},
421
+ onKeyDown(event) {
422
+ if (event.key === "Tab" && event.shiftKey && open && !virtual) {
423
+ const target = getTarget(event.nativeEvent);
424
+ if (target && !contains(floatingFocusElementRef.current, target)) return;
425
+ stopEvent(event);
426
+ const details = createChangeEventDetails(focusOut, event.nativeEvent);
427
+ store.setOpen(false, details);
428
+ const returnElement = nestedReturnFocusRef?.current ?? domReferenceElement;
429
+ if (!details.isCanceled && isHTMLElement(returnElement)) returnElement.focus();
430
+ return;
431
+ }
432
+ commonOnKeyDown(event);
433
+ },
434
+ onPointerMove(event) {
435
+ if (isStationaryWebKitPointer(event)) return;
436
+ isPointerModalityRef.current = true;
437
+ }
438
+ };
439
+ }, [
440
+ ariaActiveDescendantProp,
441
+ commonOnKeyDown,
442
+ floatingFocusElementRef,
443
+ typeableComboboxReference,
444
+ store,
445
+ open,
446
+ virtual,
447
+ domReferenceElement,
448
+ nestedReturnFocusRef
449
+ ]);
450
+ const trigger = import_react.useMemo(() => {
451
+ function openOnNavigationKeyDown(event) {
452
+ store.setOpen(true, createChangeEventDetails(listNavigation, event.nativeEvent, event.currentTarget));
453
+ }
454
+ function checkVirtualMouse(event) {
455
+ if (focusItemOnOpen === "auto" && isVirtualClick(event.nativeEvent)) focusItemOnOpenRef.current = !virtual;
456
+ }
457
+ function checkVirtualPointer(event) {
458
+ focusItemOnOpenRef.current = focusItemOnOpen;
459
+ if (focusItemOnOpen === "auto" && isVirtualPointerEvent(event.nativeEvent)) focusItemOnOpenRef.current = true;
460
+ }
461
+ return {
462
+ onKeyDown(event) {
463
+ const currentOpen = store.select("open");
464
+ isPointerModalityRef.current = false;
465
+ const isArrowKey = event.key.startsWith("Arrow");
466
+ const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
467
+ const isMainKey = isMainOrientationKey(event.key, currentOpen ? orientation : triggerOrientation);
468
+ const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
469
+ if (virtual && currentOpen && (!nested || isTypeableElement(event.currentTarget))) return commonOnKeyDown(event);
470
+ if (!currentOpen && !openOnArrowKeyDown && isArrowKey) return;
471
+ if (isNavigationKey) {
472
+ const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
473
+ keyRef.current = nested && isParentMainKey ? null : event.key;
474
+ }
475
+ if (nested) {
476
+ if (isParentCrossOpenKey) {
477
+ stopEvent(event);
478
+ if (currentOpen) {
479
+ indexRef.current = getMinEnabledIndex();
480
+ onNavigate(event);
481
+ if (virtual) floatingFocusElementRef.current?.focus();
482
+ } else openOnNavigationKeyDown(event);
483
+ }
484
+ return;
485
+ }
486
+ if (isMainKey) {
487
+ if (selectedIndexRef.current != null) indexRef.current = selectedIndexRef.current;
488
+ stopEvent(event);
489
+ if (!currentOpen && openOnArrowKeyDown) openOnNavigationKeyDown(event);
490
+ else commonOnKeyDown(event);
491
+ if (currentOpen) onNavigate(event);
492
+ }
493
+ },
494
+ onFocus(event) {
495
+ if (event.target !== event.currentTarget) return;
496
+ if (store.select("open") && !virtual) {
497
+ indexRef.current = -1;
498
+ onNavigate(event);
499
+ }
500
+ },
501
+ onPointerDown: checkVirtualPointer,
502
+ onPointerEnter: checkVirtualPointer,
503
+ onMouseDown: checkVirtualMouse,
504
+ onClick: checkVirtualMouse
505
+ };
506
+ }, [
507
+ commonOnKeyDown,
508
+ focusItemOnOpen,
509
+ getMinEnabledIndex,
510
+ nested,
511
+ onNavigate,
512
+ store,
513
+ openOnArrowKeyDown,
514
+ orientation,
515
+ triggerOrientation,
516
+ getParentOrientation,
517
+ rtl,
518
+ selectedIndexRef,
519
+ virtual,
520
+ floatingFocusElementRef
521
+ ]);
522
+ const reference = import_react.useMemo(() => {
523
+ return {
524
+ ...ariaActiveDescendantProp,
525
+ ...trigger
526
+ };
527
+ }, [ariaActiveDescendantProp, trigger]);
528
+ return import_react.useMemo(() => enabled ? {
529
+ reference,
530
+ floating,
531
+ item,
532
+ trigger
533
+ } : {}, [
534
+ enabled,
535
+ reference,
536
+ floating,
537
+ trigger,
538
+ item
539
+ ]);
540
+ }
541
+ // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/useOnFirstRender.mjs
542
+ function useOnFirstRender(fn) {
543
+ const ref = import_react.useRef(true);
544
+ if (ref.current) {
545
+ ref.current = false;
546
+ fn();
547
+ }
548
+ }
549
+ // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/areArraysEqual.mjs
550
+ /**
551
+ * Compares two arrays element-wise.
552
+ *
553
+ * The default comparison is `Object.is`, so `NaN` equals `NaN` and `0` does not equal `-0`.
554
+ */
555
+ function areArraysEqual(array1, array2, itemComparer = Object.is) {
556
+ const { length } = array1;
557
+ if (length !== array2.length) return false;
558
+ for (let i = 0; i < length; i += 1) if (!itemComparer(array1[i], array2[i])) return false;
559
+ return true;
560
+ }
561
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/itemEquality.mjs
562
+ var defaultItemEquality = (itemValue, selectedValue) => Object.is(itemValue, selectedValue);
563
+ function compareItemEquality(itemValue, selectedValue, comparer) {
564
+ if (itemValue == null || selectedValue == null) return Object.is(itemValue, selectedValue);
565
+ return comparer(itemValue, selectedValue);
566
+ }
567
+ function isSelectedValueDirty(currentValue, initialValue, comparer) {
568
+ if (Array.isArray(currentValue) && Array.isArray(initialValue)) return !areArraysEqual(currentValue, initialValue, (itemValue, initialItemValue) => compareItemEquality(itemValue, initialItemValue, comparer));
569
+ return currentValue !== initialValue;
570
+ }
571
+ function selectedValueIncludes(selectedValues, itemValue, comparer) {
572
+ if (!selectedValues) return false;
573
+ return selectedValues.some((selectedValue) => {
574
+ if (selectedValue === void 0) return false;
575
+ return compareItemEquality(itemValue, selectedValue, comparer);
576
+ });
577
+ }
578
+ function findItemIndex(itemValues, selectedValue, comparer) {
579
+ if (!itemValues) return -1;
580
+ return itemValues.findIndex((itemValue) => {
581
+ if (itemValue === void 0) return false;
582
+ return compareItemEquality(itemValue, selectedValue, comparer);
583
+ });
584
+ }
585
+ function createSelectionMatcher(selectedValues, comparer) {
586
+ if (comparer !== defaultItemEquality) return (itemValue) => selectedValueIncludes(selectedValues, itemValue, comparer);
587
+ const index = new Set(selectedValues);
588
+ index.delete(void 0);
589
+ return (itemValue) => index.has(itemValue) && (itemValue !== 0 || selectedValues.some((v) => Object.is(itemValue, v)));
590
+ }
591
+ function findSelectionIndex(itemValues, selectedValue, comparer, multiple) {
592
+ const index = multiple && Array.isArray(selectedValue) ? itemValues.findIndex(createSelectionMatcher(selectedValue, comparer)) : findItemIndex(itemValues, selectedValue, comparer);
593
+ return index === -1 ? null : index;
594
+ }
595
+ /** Resolves the first selected index as items register or change. */
596
+ function resolveSelectedIndex(index, itemValue, registry, selectedValues, comparer, currentIndex) {
597
+ if (selectedValueIncludes(selectedValues, itemValue, comparer)) return currentIndex != null && index > currentIndex && selectedValueIncludes(selectedValues, registry[currentIndex], comparer) ? currentIndex : index;
598
+ return index === currentIndex ? findSelectionIndex(registry, selectedValues, comparer, true) : currentIndex;
599
+ }
600
+ function removeItem(selectedValues, itemValue, comparer) {
601
+ return selectedValues.filter((selectedValue) => !compareItemEquality(itemValue, selectedValue, comparer));
602
+ }
603
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/serializeValue.mjs
604
+ function serializeValue(value) {
605
+ if (value == null) return "";
606
+ if (typeof value === "string") return value;
607
+ try {
608
+ return JSON.stringify(value);
609
+ } catch {
610
+ return String(value);
611
+ }
612
+ }
613
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/resolveValueLabel.mjs
614
+ var import_jsx_runtime = require_jsx_runtime();
615
+ function isGroup(item) {
616
+ return typeof item === "object" && item != null && Array.isArray(item.items);
617
+ }
618
+ function isGroupedItems(items) {
619
+ return isGroup(items?.[0]);
620
+ }
621
+ function flattenLeafItems(items) {
622
+ return isGroupedItems(items) ? items.flatMap((group) => group.items) : items;
623
+ }
624
+ /**
625
+ * Checks if the items array contains an item with a null value that has a non-null label.
626
+ */
627
+ function hasNullItemLabel(items) {
628
+ if (!Array.isArray(items)) return items != null && "null" in items;
629
+ const arrayItems = items;
630
+ if (isGroupedItems(arrayItems)) {
631
+ for (const group of arrayItems) for (const item of group.items) if (item && item.value == null && item.label != null) return true;
632
+ return false;
633
+ }
634
+ for (const item of arrayItems) if (item && item.value == null && item.label != null) return true;
635
+ return false;
636
+ }
637
+ function stringifyAsLabel(item, itemToStringLabel) {
638
+ if (itemToStringLabel && item != null) return itemToStringLabel(item) ?? "";
639
+ if (item && typeof item === "object") {
640
+ if ("label" in item && item.label != null) return String(item.label);
641
+ if ("value" in item) return String(item.value);
642
+ }
643
+ return serializeValue(item);
644
+ }
645
+ function stringifyAsValue(item, itemToStringValue) {
646
+ if (itemToStringValue && item != null) return itemToStringValue(item) ?? "";
647
+ if (item && typeof item === "object" && "value" in item && "label" in item) return serializeValue(item.value);
648
+ return serializeValue(item);
649
+ }
650
+ function resolveSelectedLabel(value, items, itemToStringLabel) {
651
+ function fallback() {
652
+ return stringifyAsLabel(value, itemToStringLabel);
653
+ }
654
+ if (itemToStringLabel && value != null) return itemToStringLabel(value);
655
+ if (value && typeof value === "object" && "label" in value && value.label != null) return value.label;
656
+ if (items && !Array.isArray(items)) return (Object.hasOwn(items, value) ? items[value] : void 0) ?? fallback();
657
+ if (Array.isArray(items)) {
658
+ const flatItems = flattenLeafItems(items);
659
+ if (value == null || typeof value !== "object") {
660
+ const match = flatItems.find((item) => item.value === value);
661
+ if (match && match.label != null) return match.label;
662
+ return fallback();
663
+ }
664
+ if ("value" in value) {
665
+ const match = flatItems.find((item) => item && item.value === value.value);
666
+ if (match && match.label != null) return match.label;
667
+ }
668
+ }
669
+ return fallback();
670
+ }
671
+ function resolveMultipleLabels(values, items, itemToStringLabel) {
672
+ return values.reduce((acc, value, index) => {
673
+ if (index > 0) acc.push(", ");
674
+ acc.push(/*#__PURE__*/ (0, import_jsx_runtime.jsx)(import_react.Fragment, { children: resolveSelectedLabel(value, items, itemToStringLabel) }, index));
675
+ return acc;
676
+ }, []);
677
+ }
678
+ // ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/useEnhancedClickHandler.mjs
679
+ /**
680
+ * Provides a cross-browser way to determine the type of the pointer used to click.
681
+ * Safari and Firefox do not provide the PointerEvent to the click handler (they use MouseEvent) yet.
682
+ * Additionally, this implementation detects if the click was triggered by the keyboard.
683
+ *
684
+ * @param handler The function to be called when the button is clicked. The first parameter is the original event and the second parameter is the pointer type.
685
+ */
686
+ function useEnhancedClickHandler(handler) {
687
+ const lastClickInteractionTypeRef = import_react.useRef("");
688
+ const handlePointerDown = import_react.useCallback((event) => {
689
+ if (event.defaultPrevented) return;
690
+ lastClickInteractionTypeRef.current = event.pointerType;
691
+ handler(event, event.pointerType);
692
+ }, [handler]);
693
+ return {
694
+ onClick: import_react.useCallback((event) => {
695
+ if (event.detail === 0) {
696
+ handler(event, "keyboard");
697
+ return;
698
+ }
699
+ if ("pointerType" in event) handler(event, event.pointerType);
700
+ else handler(event, lastClickInteractionTypeRef.current);
701
+ lastClickInteractionTypeRef.current = "";
702
+ }, [handler]),
703
+ onPointerDown: handlePointerDown
704
+ };
705
+ }
706
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/useOpenInteractionType.mjs
707
+ function useOpenMethodTriggerProps(open, setOpenMethod) {
708
+ const { onClick, onPointerDown } = useEnhancedClickHandler(useStableCallback((_, interactionType) => {
709
+ if (!(typeof open === "function" ? open() : open)) setOpenMethod(interactionType || (ios ? "touch" : ""));
710
+ }));
711
+ return import_react.useMemo(() => ({
712
+ onClick,
713
+ onPointerDown
714
+ }), [onClick, onPointerDown]);
715
+ }
716
+ /**
717
+ * Determines the interaction type (keyboard, mouse, touch, etc.) that opened the component.
718
+ *
719
+ * @param open The open state of the component.
720
+ */
721
+ function useOpenInteractionType(open) {
722
+ const [openMethod, setOpenMethod] = import_react.useState(null);
723
+ const triggerProps = useOpenMethodTriggerProps(open, setOpenMethod);
724
+ useValueChanged(open, (previousOpen) => {
725
+ if (previousOpen && !open) setOpenMethod(null);
726
+ });
727
+ return import_react.useMemo(() => ({
728
+ openMethod,
729
+ triggerProps
730
+ }), [openMethod, triggerProps]);
731
+ }
732
+ // ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/useAnchoredPopupScrollLock.mjs
733
+ var VIEWPORT_WIDTH_TOLERANCE_PX = 20;
734
+ /**
735
+ * Manages scroll lock for anchored popups. For non-touch opens, scroll lock is applied when
736
+ * enabled. For touch opens, scroll lock is applied only when the positioner width is effectively
737
+ * viewport-sized.
738
+ */
739
+ function useAnchoredPopupScrollLock(enabled, touchOpen, positionerElement, referenceElement) {
740
+ const [touchOpenShouldLockScroll, setTouchOpenShouldLockScroll] = import_react.useState(false);
741
+ useIsoLayoutEffect(() => {
742
+ if (!enabled || !touchOpen || positionerElement == null) {
743
+ setTouchOpenShouldLockScroll(false);
744
+ return;
745
+ }
746
+ const viewportWidth = ownerDocument(positionerElement).documentElement.clientWidth;
747
+ const popupWidth = positionerElement.offsetWidth;
748
+ setTouchOpenShouldLockScroll(viewportWidth > 0 && popupWidth > 0 && popupWidth >= viewportWidth - VIEWPORT_WIDTH_TOLERANCE_PX);
749
+ }, [
750
+ enabled,
751
+ touchOpen,
752
+ positionerElement
753
+ ]);
754
+ useScrollLock(enabled && (!touchOpen || touchOpenShouldLockScroll), referenceElement);
755
+ }
756
+ export { useClick as S, resolveSelectedIndex as _, hasNullItemLabel as a, useListNavigation as b, resolveSelectedLabel as c, compareItemEquality as d, defaultItemEquality as f, removeItem as g, isSelectedValueDirty as h, flattenLeafItems as i, stringifyAsLabel as l, findSelectionIndex as m, useOpenInteractionType as n, isGroupedItems as o, findItemIndex as p, useOpenMethodTriggerProps as r, resolveMultipleLabels as s, useAnchoredPopupScrollLock as t, stringifyAsValue as u, selectedValueIncludes as v, useFloatingRootContext as x, useOnFirstRender as y };