@qredence/fleet 0.6.1 → 0.6.3

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 (280) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/web/client/assets/DialogTitle-DiAm7YNe.js +1 -0
  3. package/dist/web/client/assets/agent-disclosure-CMrxF7L-.js +1 -0
  4. package/dist/web/client/assets/alert-dialog-CYE37KMM.js +1 -0
  5. package/dist/web/client/assets/analytics-stub-C2vgmGm_.js +1 -0
  6. package/dist/web/client/assets/artifacts-panel-ClDpGWOU.js +1 -0
  7. package/dist/web/client/assets/{bot-Bs7QWJ2q.js → bot-DbB9BKL0.js} +1 -1
  8. package/dist/web/client/assets/bundle-mjs-cJTHqqzI.js +1 -0
  9. package/dist/web/client/assets/button-Dl0ce3Y5.js +1 -0
  10. package/dist/web/client/assets/{card-DA3Vnqay.js → card-DCEnYd2G.js} +1 -1
  11. package/dist/web/client/assets/chat-BVMnC5Qh.js +52 -0
  12. package/dist/web/client/assets/chat-command-palette-YuyaJNbi.js +1 -0
  13. package/dist/web/client/assets/check-B3LlvM65.js +1 -0
  14. package/dist/web/client/assets/{chevron-down-BEVGmnSb.js → chevron-down-DUUprRP5.js} +1 -1
  15. package/dist/web/client/assets/chevron-right-NVqQIoiO.js +1 -0
  16. package/dist/web/client/assets/{chunk-YOKDWASO-BAf618wr.js → chunk-YOKDWASO-Bte3iwlH.js} +6 -6
  17. package/dist/web/client/assets/citations-DXqV2NLy.js +1 -0
  18. package/dist/web/client/assets/collapsible-CUxOjhDJ.js +1 -0
  19. package/dist/web/client/assets/command-Cw4X8Bpk.js +1 -0
  20. package/dist/web/client/assets/createBaseUIEventDetails-B58Jldei.js +1 -0
  21. package/dist/web/client/assets/createLucideIcon-_dfI7Arx.js +1 -0
  22. package/dist/web/client/assets/dialog-BzcIOvFC.js +1 -0
  23. package/dist/web/client/assets/dist-52wg4XPY.js +1 -0
  24. package/dist/web/client/assets/dist-DbHxXSgQ.js +41 -0
  25. package/dist/web/client/assets/ease-CMumuPlX.js +1 -0
  26. package/dist/web/client/assets/{eye-B0DFz5hL.js → eye-CDHqtVoE.js} +1 -1
  27. package/dist/web/client/assets/file-text-TmalmYrb.js +1 -0
  28. package/dist/web/client/assets/{folder-BC5p7qK7.js → folder-vuNT4shY.js} +1 -1
  29. package/dist/web/client/assets/{fork-picker-dialog-B7NNpVmW.js → fork-picker-dialog-BYRr-xTy.js} +1 -1
  30. package/dist/web/client/assets/gauge-BsDqNM1A.js +1 -0
  31. package/dist/web/client/assets/git-branch-CTq9aACS.js +1 -0
  32. package/dist/web/client/assets/globals-BtCXZXL_.css +2 -0
  33. package/dist/web/client/assets/{hard-drive-CHqgr7VQ.js → hard-drive-BT7UxHQu.js} +1 -1
  34. package/dist/web/client/assets/highlighted-body-KPVGNVTW-CgT7gqvs.js +1 -0
  35. package/dist/web/client/assets/horizontal-resize-VLjLByUV.js +1 -0
  36. package/dist/web/client/assets/index-B9aXxpOv.js +12 -0
  37. package/dist/web/client/assets/input-CxZp56Im.js +1 -0
  38. package/dist/web/client/assets/input-group-D7lAfKHR.js +1 -0
  39. package/dist/web/client/assets/ipython-tool-CkHaO3PW.js +3 -0
  40. package/dist/web/client/assets/is-ref-object-BcRWZ4l7.js +1 -0
  41. package/dist/web/client/assets/{loader-circle-DjfHXUPB.js → loader-circle-B5GIZGxd.js} +1 -1
  42. package/dist/web/client/assets/markdown-BHkByC9K.js +2 -0
  43. package/dist/web/client/assets/{markdown-code-xNyjdZ4g.js → markdown-code-CDTRq-HZ.js} +1 -1
  44. package/dist/web/client/assets/mermaid-HWGCJPDP-CY3N5ECk.js +1 -0
  45. package/dist/web/client/assets/message-queue-Dl8wbCOu.js +1 -0
  46. package/dist/web/client/assets/model-selector-list-CHD8lMAl.js +1 -0
  47. package/dist/web/client/assets/{notify-DxL0VD7Z.js → notify-DjVixft7.js} +1 -1
  48. package/dist/web/client/assets/{openui-renderer-TLNe5e_Q.js → openui-renderer-C4e9FOVR.js} +38 -38
  49. package/dist/web/client/assets/{package-CdcJFPf2.js → package-BKBPgwMP.js} +1 -1
  50. package/dist/web/client/assets/{pencil-DcUwsKLn.js → pencil-CdO6qfv3.js} +1 -1
  51. package/dist/web/client/assets/{plug-Dt6VN0zF.js → plug-BRROUIw-.js} +1 -1
  52. package/dist/web/client/assets/prompt-input-WaGSKZCU.js +1 -0
  53. package/dist/web/client/assets/prompt-suggestions-BNyTcyWg.js +1 -0
  54. package/dist/web/client/assets/provider-catalog-ClVvphe0.js +1 -0
  55. package/dist/web/client/assets/provider-label-CwZ-KDxk.js +1 -0
  56. package/dist/web/client/assets/react-CwJFpaho.js +1 -0
  57. package/dist/web/client/assets/react-dom-DX3XddaT.js +1 -0
  58. package/dist/web/client/assets/{refresh-cw-IThTJ3j-.js → refresh-cw-l9WPHRkq.js} +1 -1
  59. package/dist/web/client/assets/repl-panel-L9dmPqio.js +1 -0
  60. package/dist/web/client/assets/{resource-helpers-Q2T0YCMO.js → resource-helpers-BuWybA8l.js} +1 -1
  61. package/dist/web/client/assets/resources-panel-mT-aMCvV.js +1 -0
  62. package/dist/web/client/assets/right-panel-context-CS8tJMzE.js +1 -0
  63. package/dist/web/client/assets/right-panel-registry-BnYCffmM.js +2 -0
  64. package/dist/web/client/assets/{rotate-ccw-WNFNkKQD.js → rotate-ccw-CfGhzOv7.js} +1 -1
  65. package/dist/web/client/assets/routes-DUontXSG.js +16 -0
  66. package/dist/web/client/assets/safe-external-url-BbAom7Bm.js +1 -0
  67. package/dist/web/client/assets/search-BjcXAUrI.js +1 -0
  68. package/dist/web/client/assets/session-insights-panel-B0rl37lo.js +1 -0
  69. package/dist/web/client/assets/session-reasoning-panel-8D2P7iaJ.js +1 -0
  70. package/dist/web/client/assets/session-tool-renderer-Bd3dsE2D.js +1395 -0
  71. package/dist/web/client/assets/session-tree-panel-CM4_wwrM.js +1 -0
  72. package/dist/web/client/assets/settings-dialog-DMTD9m6z.js +2 -0
  73. package/dist/web/client/assets/{skeleton-CkR2VmWc.js → skeleton-C3mo31Qu.js} +1 -1
  74. package/dist/web/client/assets/skeleton-loaders-BMa_G4yX.js +1 -0
  75. package/dist/web/client/assets/sparkles-BY5MFyk6.js +1 -0
  76. package/dist/web/client/assets/square-DQaQu9bp.js +1 -0
  77. package/dist/web/client/assets/{square-terminal-BYTN_I86.js → square-terminal-BsopiuN7.js} +1 -1
  78. package/dist/web/client/assets/{subagent-chat-panel-oeLDPDAK.js → subagent-chat-panel-BESrXxAR.js} +1 -1
  79. package/dist/web/client/assets/subagent-transcript-CAqFJfMj.js +1 -0
  80. package/dist/web/client/assets/subagents-panel-8aKOwWLs.js +1 -0
  81. package/dist/web/client/assets/{sun-BWiZFty0.js → sun-D0llhiMU.js} +1 -1
  82. package/dist/web/client/assets/surfaces-CpfsGAIA.js +1 -0
  83. package/dist/web/client/assets/switch-D3FhZU-S.js +1 -0
  84. package/dist/web/client/assets/terminal-BQAKkBY6.js +1 -0
  85. package/dist/web/client/assets/toast-lnCWGgSE.js +1 -0
  86. package/dist/web/client/assets/tokens-Ch5WqXC_.js +1 -0
  87. package/dist/web/client/assets/tool-result-B_yb2JoE.js +4 -0
  88. package/dist/web/client/assets/tool-timeline-VnMRQoLS.js +1 -0
  89. package/dist/web/client/assets/{triangle-alert-CU-gd7ui.js → triangle-alert-GAYh_5d3.js} +1 -1
  90. package/dist/web/client/assets/ui-preferences-aG2U2jjW.js +1 -0
  91. package/dist/web/client/assets/use-presence-7I2qv4qI.js +1 -0
  92. package/dist/web/client/assets/use-reduced-motion-BOcG709U.js +9 -0
  93. package/dist/web/client/assets/useBaseUiId-D9ZGPZ6f.js +1 -0
  94. package/dist/web/client/assets/useControlled-CgAAWIy9.js +1 -0
  95. package/dist/web/client/assets/utils-Brtgag-m.js +1 -0
  96. package/dist/web/client/assets/virtualized-turn-list-mL3ONUUA.js +6 -0
  97. package/dist/web/client/assets/workspace-panel-CKF5JQl2.js +1 -0
  98. package/dist/web/client/assets/workspace-path-nav-DqPbETfJ.js +2 -0
  99. package/dist/web/client/assets/{wrench-BJNNe07k.js → wrench-Myc12BTA.js} +1 -1
  100. package/dist/web/client/assets/x-BGsDD848.js +1 -0
  101. package/dist/web/client/bundle-budget.json +6 -6
  102. package/dist/web/server/_tanstack-start-manifest_v-Cm8xE-Rb-TMLYN3GY.js +93 -0
  103. package/dist/web/server/{artifacts-panel-D3ySO--V-XSL53CXL.js → artifacts-panel-CwLVBqyi-CDORJY75.js} +37 -41
  104. package/dist/web/server/{chat-command-palette-kAbXhWVg-TJWXH2WW.js → chat-command-palette-DUha04ia-5OV7WVJZ.js} +20 -18
  105. package/dist/web/server/{chunk-SALXCFVO.js → chunk-33QA7BQJ.js} +19 -1
  106. package/dist/web/server/chunk-3Q3QKLHC.js +386 -0
  107. package/dist/web/server/chunk-4EBSM4JR.js +74 -0
  108. package/dist/web/server/{chunk-5UCAJBAH.js → chunk-5RTGRTPD.js} +82 -49
  109. package/dist/web/server/chunk-7E76R7MB.js +2138 -0
  110. package/dist/web/server/{chunk-EBG3XFGQ.js → chunk-7FK6YEMA.js} +49 -44
  111. package/dist/web/server/chunk-7HXCGBUP.js +56 -0
  112. package/dist/web/server/{chunk-P66QQWUM.js → chunk-7NZ3FJDA.js} +14 -1
  113. package/dist/web/server/{chunk-HF7DG7PC.js → chunk-7UTDOTOU.js} +80 -78
  114. package/dist/web/server/{chunk-NNKJTKOQ.js → chunk-ADYZWC5L.js} +311 -281
  115. package/dist/web/server/{chunk-NJ4QEZHK.js → chunk-B2LF64HM.js} +7 -5
  116. package/dist/web/server/{chunk-OZO5ARFA.js → chunk-BQROC4PL.js} +11 -2
  117. package/dist/web/server/{chunk-NIZBFVJF.js → chunk-CAPTFJOC.js} +9 -7
  118. package/dist/web/server/{chunk-DJMHPJBP.js → chunk-CHEC7TWB.js} +3 -1
  119. package/dist/web/server/chunk-DLA5TLKX.js +164 -0
  120. package/dist/web/server/{chunk-PLYZ7P2Y.js → chunk-DP26GVWH.js} +43 -5
  121. package/dist/web/server/{chunk-MNBGB2SP.js → chunk-E5HALE4M.js} +4 -4
  122. package/dist/web/server/chunk-ETCO5KZK.js +113 -0
  123. package/dist/web/server/{chunk-NGCQJ33Y.js → chunk-FMAYMBRS.js} +1492 -1640
  124. package/dist/web/server/{chunk-KP2PNDGL.js → chunk-FTLJ66KU.js} +30 -33
  125. package/dist/web/server/{chunk-BLSX7WHW.js → chunk-H5D5DX3K.js} +23 -21
  126. package/dist/web/server/chunk-HGVJEUV4.js +102 -0
  127. package/dist/web/server/{chunk-WNCAL4HN.js → chunk-HQ5TEXHT.js} +132 -152
  128. package/dist/web/server/{chunk-YOM42BKD.js → chunk-IPV4GLJL.js} +16 -16
  129. package/dist/web/server/chunk-K6PTNSCW.js +31 -0
  130. package/dist/web/server/{chunk-AR7O7JXD.js → chunk-KBWUBWVJ.js} +24 -1
  131. package/dist/web/server/{chunk-O3HDELZ2.js → chunk-KZ35W5M7.js} +667 -661
  132. package/dist/web/server/{chunk-QIULBRTU.js → chunk-MJXXVQNA.js} +79 -84
  133. package/dist/web/server/{chunk-EAJTWMK5.js → chunk-NZ6KQT2X.js} +2 -2
  134. package/dist/web/server/{chunk-YGYOBX7G.js → chunk-O2IC376F.js} +1811 -53
  135. package/dist/web/server/chunk-OMPXUTMX.js +33 -0
  136. package/dist/web/server/{chunk-S3PQ6HKH.js → chunk-OVJYUWSQ.js} +2 -2
  137. package/dist/web/server/{chunk-JTCCQZLN.js → chunk-RJNGEU6C.js} +2 -2
  138. package/dist/web/server/{chunk-UCUFC553.js → chunk-RXUMFFUV.js} +3 -3
  139. package/dist/web/server/{chunk-DLUZFOG3.js → chunk-S2IBIJIG.js} +18 -22
  140. package/dist/web/server/{chunk-DO2O27B2.js → chunk-SDV3P3IW.js} +2 -2
  141. package/dist/web/server/{chunk-2DDWXTVG.js → chunk-T2UTBHJ4.js} +55 -11
  142. package/dist/web/server/chunk-TLNZNR7C.js +46 -0
  143. package/dist/web/server/{chunk-UL2725KQ.js → chunk-TR2GA5OF.js} +57 -49
  144. package/dist/web/server/{chunk-QFRCJWQQ.js → chunk-TU2WNRAL.js} +93 -32
  145. package/dist/web/server/{chunk-FYDQK6UX.js → chunk-UDD5W4CR.js} +32 -10
  146. package/dist/web/server/{chunk-MNPHMZU7.js → chunk-UE32PAV2.js} +47 -57
  147. package/dist/web/server/{chunk-3TIMGWWI.js → chunk-UM3RHJNZ.js} +2 -2
  148. package/dist/web/server/{chunk-ZIFSJ3HQ.js → chunk-V5IFFLZQ.js} +185 -109
  149. package/dist/web/server/{chunk-ETTDO4UO.js → chunk-WTYNN6EV.js} +1 -26
  150. package/dist/web/server/{chunk-EJEPDVK6.js → chunk-WU6X3GPJ.js} +48 -5
  151. package/dist/web/server/{chunk-D27LRYVT.js → chunk-XEG4JTND.js} +10 -9
  152. package/dist/web/server/{chunk-XIB6XNUX.js → chunk-XJ6TGSUB.js} +425 -404
  153. package/dist/web/server/{chunk-NWDI3OWB.js → chunk-XSOUURPF.js} +30 -26
  154. package/dist/web/server/{chunk-RIP3PBWT.js → chunk-YCCF676T.js} +4 -4
  155. package/dist/web/server/{chunk-4WBFCB4O.js → chunk-YDDDSVNB.js} +178 -269
  156. package/dist/web/server/{chunk-GETSIVNU.js → chunk-YVGCPUAW.js} +7 -7
  157. package/dist/web/server/{chunk-4UBOIY2S.js → chunk-ZNFXBGLK.js} +1 -1
  158. package/dist/web/server/{fork-picker-dialog-Ds6Tgtu3-DIBWN7MV.js → fork-picker-dialog-DeMiLZtS-WTRTTP64.js} +10 -8
  159. package/dist/web/server/{markdown-DTnMbD87-FXGGAPJD.js → markdown-BzNejPoZ-6ITTDAV6.js} +2 -3
  160. package/dist/web/server/{markdown-code-BStjFfsy-SSLWUT4S.js → markdown-code-DAwXuW6m-HHVELO6I.js} +3 -4
  161. package/dist/web/server/{fleet-message-queue-D_w8lSeY-T3HB7HVQ.js → message-queue-Demph1x4-GGXJUUKO.js} +14 -10
  162. package/dist/web/server/{model-selector-list-DxeGZoD2-P6S6FSJH.js → model-selector-list-BeGQHwKV-UJYFO4KX.js} +21 -19
  163. package/dist/web/server/{openui-renderer-MKFv6LlH-MDRSVFEY.js → openui-renderer-B4z18Brm-HSMKJ47D.js} +17 -17
  164. package/dist/web/server/{prompt-suggestions-BOItmGnD-YQA7RHLG.js → prompt-suggestions-yPZqX__K-3VGJC4IF.js} +7 -6
  165. package/dist/web/server/{repl-panel-CuyF8wt5-CHDT2Q3N.js → repl-panel-CgUF1qUw-3DFD2V53.js} +10 -11
  166. package/dist/web/server/{resources-panel-CE5pD4vy-V5FXBTYC.js → resources-panel-ChUliWV--JITAGS6Q.js} +6 -7
  167. package/dist/web/server/{router-Dg72SESP-PCWKLFRG.js → router-DfG45nTQ-3VXEUYG5.js} +3336 -238
  168. package/dist/web/server/{routes-BGrVtPYF-SURPAJN6.js → routes-B9F9UfF1-UN2IVBMJ.js} +5156 -4242
  169. package/dist/web/server/server.js +2 -2
  170. package/dist/web/server/{session-insights-panel-CUhdgvRt-VB2HUCQP.js → session-insights-panel-xgrkX1Rp-FDNURBXZ.js} +9 -9
  171. package/dist/web/server/{fleet-reasoning-panel-DG_vuvv0-NCZWEEIT.js → session-reasoning-panel-m1RgcIph-NUXGXVKE.js} +21 -22
  172. package/dist/web/server/session-tool-renderer-CT65wuet-RQBMXHEZ.js +46 -0
  173. package/dist/web/server/session-tree-panel-rS0t1wbf-HNA6AJBY.js +229 -0
  174. package/dist/web/server/{settings-dialog-CK0FJlTg-HZRBAXDZ.js → settings-dialog-CqkrDSnm-LFEKSS7Y.js} +186 -1380
  175. package/dist/web/server/{subagent-chat-panel-gzamnTgK-PQ2TLLJF.js → subagent-chat-panel-Cf7QdDqH-DPPSVLSY.js} +31 -39
  176. package/dist/web/server/{subagents-panel-Berjd7HJ-EI5ZKC6V.js → subagents-panel-_JsUw-6t-MZWM5P45.js} +38 -45
  177. package/dist/web/server/{fleet-tool-timeline-D6yM4ZMz-ZSFVRRRI.js → tool-timeline-QL9k5dzA-RLU26HXT.js} +6 -6
  178. package/dist/web/server/{workspace-panel-CBBa_3UO-B4PPFPMA.js → workspace-panel-BHEB9nRM-Y6KGIVGP.js} +23 -30
  179. package/package.json +1 -1
  180. package/dist/web/client/assets/action-swap-roll-COzQ86wm.js +0 -1
  181. package/dist/web/client/assets/agent-activity-svETLf_5.js +0 -1
  182. package/dist/web/client/assets/agent-disclosure-DAMuuGcM.js +0 -1
  183. package/dist/web/client/assets/analytics-stub-B6zGMuSV.js +0 -1
  184. package/dist/web/client/assets/artifacts-panel-HVjqBMyx.js +0 -1
  185. package/dist/web/client/assets/artifacts-utils-N_kUFbz2.js +0 -1
  186. package/dist/web/client/assets/bundle-mjs-DKHVkVWu.js +0 -1
  187. package/dist/web/client/assets/button-C5wFDY5_.js +0 -1
  188. package/dist/web/client/assets/chat-BhYseKd6.js +0 -52
  189. package/dist/web/client/assets/chat-command-palette-LILDO_vG.js +0 -1
  190. package/dist/web/client/assets/check-JjHKAZas.js +0 -1
  191. package/dist/web/client/assets/chevron-right-DrJxToLs.js +0 -1
  192. package/dist/web/client/assets/chevron-up-CnSvySGH.js +0 -1
  193. package/dist/web/client/assets/circle-alert-CONlFReH.js +0 -1
  194. package/dist/web/client/assets/circle-x-CkKCB__4.js +0 -1
  195. package/dist/web/client/assets/citations-BPv8HIpf.js +0 -2
  196. package/dist/web/client/assets/cn-C8c0S2mI.js +0 -1
  197. package/dist/web/client/assets/collapsible-BoXtZZWN.js +0 -1
  198. package/dist/web/client/assets/command-PhicLCoO.js +0 -1
  199. package/dist/web/client/assets/createBaseUIEventDetails-DV0dQrBX.js +0 -1
  200. package/dist/web/client/assets/createLucideIcon-DwxZHm0M.js +0 -1
  201. package/dist/web/client/assets/dialog-pBGUjAQ7.js +0 -1
  202. package/dist/web/client/assets/dist-BPaFisIZ.js +0 -41
  203. package/dist/web/client/assets/earth-DGZXAN5r.js +0 -1
  204. package/dist/web/client/assets/ease-u56MhKYS.js +0 -1
  205. package/dist/web/client/assets/file-text-T-NcAlZs.js +0 -1
  206. package/dist/web/client/assets/fleet-message-queue-fbYYwMj0.js +0 -1
  207. package/dist/web/client/assets/fleet-pi-tool-renderer-BRgNnmaJ.js +0 -1395
  208. package/dist/web/client/assets/fleet-reasoning-panel-CjA2dwUJ.js +0 -1
  209. package/dist/web/client/assets/fleet-subagent-list-iKUtLJKZ.js +0 -1
  210. package/dist/web/client/assets/fleet-tool-timeline-C8heL7ae.js +0 -1
  211. package/dist/web/client/assets/gauge-DNpstbBn.js +0 -1
  212. package/dist/web/client/assets/globals-CuIiqOTg.css +0 -2
  213. package/dist/web/client/assets/highlighted-body-KPVGNVTW-sUCZ1fHv.js +0 -1
  214. package/dist/web/client/assets/horizontal-resize-Cp3iHMH7.js +0 -1
  215. package/dist/web/client/assets/image-BbPmlw-n.js +0 -1
  216. package/dist/web/client/assets/index-CSGplyr_.js +0 -12
  217. package/dist/web/client/assets/input-PcdubeKn.js +0 -1
  218. package/dist/web/client/assets/input-group-C2HJEZvl.js +0 -1
  219. package/dist/web/client/assets/ipython-tool-CyuMOxz1.js +0 -3
  220. package/dist/web/client/assets/layout-gyLzPvVv.js +0 -1
  221. package/dist/web/client/assets/markdown-lvexwooo.js +0 -2
  222. package/dist/web/client/assets/mermaid-HWGCJPDP-Bm7CuruA.js +0 -1
  223. package/dist/web/client/assets/message-square-hbDao-A1.js +0 -1
  224. package/dist/web/client/assets/model-selector-list-CoXX358G.js +0 -1
  225. package/dist/web/client/assets/plus-DXN1Bg_z.js +0 -1
  226. package/dist/web/client/assets/prompt-input-fwP8TsgQ.js +0 -1
  227. package/dist/web/client/assets/prompt-suggestions-BlGXmWS7.js +0 -1
  228. package/dist/web/client/assets/provider-catalog-DYMFdbKc.js +0 -1
  229. package/dist/web/client/assets/provider-label-B4q5mI65.js +0 -1
  230. package/dist/web/client/assets/react-dom-Bwxum3ti.js +0 -1
  231. package/dist/web/client/assets/repl-panel-C5om8MGU.js +0 -1
  232. package/dist/web/client/assets/resources-panel-D867-goy.js +0 -1
  233. package/dist/web/client/assets/right-panel-context-DHlNWJsF.js +0 -1
  234. package/dist/web/client/assets/right-panel-registry-BBlxLxnx.js +0 -2
  235. package/dist/web/client/assets/routes-XGsAIqBJ.js +0 -16
  236. package/dist/web/client/assets/safe-external-url-D3PJJIcM.js +0 -1
  237. package/dist/web/client/assets/search-eWVnAJsb.js +0 -1
  238. package/dist/web/client/assets/session-insights-panel-YnaXvTpi.js +0 -1
  239. package/dist/web/client/assets/settings-dialog-BSBasR3o.js +0 -2
  240. package/dist/web/client/assets/shield-check-CkA2viVW.js +0 -1
  241. package/dist/web/client/assets/skeleton-loaders-C9vHwAYV.js +0 -1
  242. package/dist/web/client/assets/sparkles-DuclzqlE.js +0 -1
  243. package/dist/web/client/assets/square-Bhn8gjr0.js +0 -1
  244. package/dist/web/client/assets/subagent-transcript-DaVHjNUH.js +0 -1
  245. package/dist/web/client/assets/subagent-utils-DDH5qm9Z.js +0 -1
  246. package/dist/web/client/assets/subagents-panel-D_aVgSCi.js +0 -1
  247. package/dist/web/client/assets/surfaces-BhAXz9So.js +0 -1
  248. package/dist/web/client/assets/switch-WhXeJNNY.js +0 -1
  249. package/dist/web/client/assets/terminal-DOS1s1gm.js +0 -1
  250. package/dist/web/client/assets/toast-D3c9XeGe.js +0 -1
  251. package/dist/web/client/assets/tool-result-Cki8WUNc.js +0 -4
  252. package/dist/web/client/assets/ui-preferences-CImQGZm_.js +0 -1
  253. package/dist/web/client/assets/use-reduced-motion-eORd7fqW.js +0 -9
  254. package/dist/web/client/assets/useBaseUiId-CHqXB2UQ.js +0 -1
  255. package/dist/web/client/assets/useControlled-CJJ9BOQB.js +0 -1
  256. package/dist/web/client/assets/utils-Eg7xtNmV.js +0 -1
  257. package/dist/web/client/assets/virtualized-turn-list-CdMa-ydT.js +0 -6
  258. package/dist/web/client/assets/workspace-panel-77bDbprs.js +0 -1
  259. package/dist/web/client/assets/workspace-path-nav-C0AQNZyy.js +0 -1
  260. package/dist/web/client/assets/x-CsRC_tCI.js +0 -1
  261. package/dist/web/server/_tanstack-start-manifest_v-0L7fqnH4-KMVGUFE4.js +0 -95
  262. package/dist/web/server/agent-activity-BuEE6iVw-CDZLK4D2.js +0 -514
  263. package/dist/web/server/chunk-2JHTYWD5.js +0 -1196
  264. package/dist/web/server/chunk-3JMESBAT.js +0 -35
  265. package/dist/web/server/chunk-42XU6WV7.js +0 -56
  266. package/dist/web/server/chunk-AQ66E5OW.js +0 -33
  267. package/dist/web/server/chunk-BYXBJQAS.js +0 -0
  268. package/dist/web/server/chunk-FAGDMGLK.js +0 -6589
  269. package/dist/web/server/chunk-FJV6EQDW.js +0 -36
  270. package/dist/web/server/chunk-GL6HWDJB.js +0 -19
  271. package/dist/web/server/chunk-L46H6IDX.js +0 -13
  272. package/dist/web/server/chunk-NIDBN7BQ.js +0 -86
  273. package/dist/web/server/chunk-ON33WDZX.js +0 -31
  274. package/dist/web/server/chunk-PVJCTQFK.js +0 -22
  275. package/dist/web/server/chunk-QPNUGF3V.js +0 -35
  276. package/dist/web/server/chunk-S5LFXXDY.js +0 -1265
  277. package/dist/web/server/chunk-VPKX7QRU.js +0 -42
  278. package/dist/web/server/chunk-ZCVWADNW.js +0 -37
  279. package/dist/web/server/fleet-pi-tool-renderer-qwc-qZFq-4U556N5Q.js +0 -51
  280. package/dist/web/server/fleet-subagent-list-BGb0PjhF-2X67FMUV.js +0 -18
@@ -1,3 +1,6 @@
1
+ import {
2
+ isModelPatternEnabled
3
+ } from "./chunk-WTYNN6EV.js";
1
4
  import {
2
5
  ChatMcpDeleteRequestSchema,
3
6
  ChatMcpOAuthLoginRequestSchema,
@@ -8,22 +11,51 @@ import {
8
11
  ChatProviderUpdateRequestSchema,
9
12
  ChatSettingsUpdateRequestSchema,
10
13
  FLEET_ADAPTER_CAPABILITIES,
11
- LazyMotion,
14
+ HTMLVisualElement,
15
+ MotionConfig,
12
16
  NETWORK_DISCONNECTED_MESSAGE,
13
17
  QueryClient,
14
18
  QueryClientProvider,
15
- domAnimation,
19
+ SVGVisualElement,
20
+ SessionTreeNavigateRequestSchema,
21
+ SessionTreeNavigateResponseSchema,
22
+ SessionTreeSnapshotResponseSchema,
23
+ addValueToWillChange,
24
+ animateMotionValue,
25
+ animateSingleValue,
26
+ animateTarget,
27
+ applyBoxDelta,
28
+ applyTreeDeltas,
29
+ circOut,
30
+ convertBoundingBoxToBox,
31
+ convertBoxToBoundingBox,
32
+ getOptimisedAppearId,
33
+ getValueTransition,
34
+ has2DTranslate,
35
+ hasScale,
36
+ hasTransform,
16
37
  initAnalytics,
17
- isServer
18
- } from "./chunk-YGYOBX7G.js";
38
+ isKeyframesTarget,
39
+ isSVGElement,
40
+ isSVGSVGElement,
41
+ isServer,
42
+ measurePageBox,
43
+ pipe,
44
+ progress,
45
+ resolveElements,
46
+ resolveVariant,
47
+ scalePoint,
48
+ transformBox,
49
+ translateAxis
50
+ } from "./chunk-O2IC376F.js";
19
51
  import {
20
52
  DEFAULT_UI_PREFERENCES,
21
- isModelPatternEnabled,
53
+ applyUiPreferencesToDocument,
22
54
  readUiPreferences
23
- } from "./chunk-ETTDO4UO.js";
55
+ } from "./chunk-4EBSM4JR.js";
24
56
  import {
25
57
  Toaster
26
- } from "./chunk-UL2725KQ.js";
58
+ } from "./chunk-TR2GA5OF.js";
27
59
  import {
28
60
  fallbackSessionLabel,
29
61
  meaningfulSessionLabel,
@@ -32,9 +64,44 @@ import {
32
64
  import "./chunk-SZJUXVWG.js";
33
65
  import "./chunk-TNL4YV63.js";
34
66
  import {
35
- drag,
36
- layout
37
- } from "./chunk-FAGDMGLK.js";
67
+ isHTMLElement,
68
+ usePresence
69
+ } from "./chunk-K6PTNSCW.js";
70
+ import {
71
+ LayoutGroupContext,
72
+ LazyContext,
73
+ SubscriptionManager,
74
+ SwitchLayoutGroupContext,
75
+ addUniqueItem,
76
+ cancelFrame,
77
+ clamp,
78
+ cornerRadiusProps,
79
+ createBox,
80
+ createDelta,
81
+ frame,
82
+ frameData,
83
+ frameSteps,
84
+ invariant,
85
+ isAnimationControls,
86
+ isRefObject,
87
+ isSVGComponent,
88
+ isVariantLabel,
89
+ loadFeatures,
90
+ microtask,
91
+ millisecondsToSeconds,
92
+ mixNumber,
93
+ motionValue,
94
+ noop,
95
+ percent,
96
+ px,
97
+ removeItem,
98
+ resolveMotionValue,
99
+ scaleCorrectors,
100
+ secondsToMilliseconds,
101
+ time,
102
+ variantPriorityOrder,
103
+ variantProps
104
+ } from "./chunk-7E76R7MB.js";
38
105
  import {
39
106
  Card,
40
107
  CardContent,
@@ -42,7 +109,7 @@ import {
42
109
  CardHeader,
43
110
  CardTitle,
44
111
  validateAndNormalizeOpenUIHtmlArtifact
45
- } from "./chunk-3TIMGWWI.js";
112
+ } from "./chunk-UM3RHJNZ.js";
46
113
  import {
47
114
  ChatNewRequestSchema,
48
115
  ChatOpenUIArtifactUpsertRequestSchema,
@@ -62,7 +129,7 @@ import {
62
129
  UploadedAttachmentSchema,
63
130
  ZodError,
64
131
  external_exports
65
- } from "./chunk-PLYZ7P2Y.js";
132
+ } from "./chunk-DP26GVWH.js";
66
133
  import {
67
134
  KNOWN_PROVIDERS,
68
135
  OPENAI_CHAT_COMPLETIONS_PROVIDER_ID,
@@ -77,12 +144,13 @@ import {
77
144
  toInstanceSlug,
78
145
  toOccInstanceId
79
146
  } from "./chunk-RJOANOT4.js";
80
- import "./chunk-WNCAL4HN.js";
81
147
  import "./chunk-JBLHIEVG.js";
82
- import "./chunk-XIB6XNUX.js";
148
+ import "./chunk-HQ5TEXHT.js";
149
+ import "./chunk-TLNZNR7C.js";
150
+ import "./chunk-XJ6TGSUB.js";
83
151
  import "./chunk-HFQZLPU2.js";
84
152
  import "./chunk-4ZIEVI5O.js";
85
- import "./chunk-DJMHPJBP.js";
153
+ import "./chunk-CHEC7TWB.js";
86
154
  import {
87
155
  HeadContent,
88
156
  Outlet,
@@ -96,8 +164,8 @@ import "./chunk-JDCCC7A7.js";
96
164
  import "./chunk-L547YHC4.js";
97
165
  import "./chunk-MLKGABMK.js";
98
166
 
99
- // web/app/dist/server/assets/router-Dg72SESP.js
100
- import { useEffect, useLayoutEffect } from "react";
167
+ // web/app/dist/server/assets/router-DfG45nTQ.js
168
+ import { Component, Fragment, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
101
169
  import { jsx, jsxs } from "react/jsx-runtime";
102
170
  import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
103
171
  import { fileURLToPath } from "node:url";
@@ -107,8 +175,2868 @@ import { AuthStorage, DAEMON_PROTOCOL_NAME, DAEMON_PROTOCOL_VERSION, DaemonAgent
107
175
  import { spawn } from "node:child_process";
108
176
  import { homedir } from "node:os";
109
177
  import { getProviders, getSupportedThinkingLevels } from "@earendil-works/pi-ai";
178
+ function calcChildStagger(children, child, delayChildren, staggerChildren = 0, staggerDirection = 1) {
179
+ const index = Array.from(children).sort((a, b) => a.sortNodePosition(b)).indexOf(child);
180
+ const numChildren = children.size;
181
+ const maxStaggerDuration = (numChildren - 1) * staggerChildren;
182
+ return typeof delayChildren === "function" ? delayChildren(index, numChildren) : staggerDirection === 1 ? index * staggerChildren : maxStaggerDuration - index * staggerChildren;
183
+ }
184
+ function animateVariant(visualElement, variant, options = {}) {
185
+ const resolved = resolveVariant(visualElement, variant, options.type === "exit" ? visualElement.presenceContext?.custom : void 0);
186
+ let { transition = visualElement.getDefaultTransition() || {} } = resolved || {};
187
+ if (options.transitionOverride) transition = options.transitionOverride;
188
+ const getAnimation = resolved ? () => Promise.all(animateTarget(visualElement, resolved, options)) : () => Promise.resolve();
189
+ const getChildAnimations = visualElement.variantChildren && visualElement.variantChildren.size ? (forwardDelay = 0) => {
190
+ const { delayChildren = 0, staggerChildren, staggerDirection } = transition;
191
+ return animateChildren(visualElement, variant, forwardDelay, delayChildren, staggerChildren, staggerDirection, options);
192
+ } : () => Promise.resolve();
193
+ const { when } = transition;
194
+ if (when) {
195
+ const [first, last] = when === "beforeChildren" ? [getAnimation, getChildAnimations] : [getChildAnimations, getAnimation];
196
+ return first().then(() => last());
197
+ } else return Promise.all([getAnimation(), getChildAnimations(options.delay)]);
198
+ }
199
+ function animateChildren(visualElement, variant, delay2 = 0, delayChildren = 0, staggerChildren = 0, staggerDirection = 1, options) {
200
+ const animations2 = [];
201
+ for (const child of visualElement.variantChildren) {
202
+ child.notify("AnimationStart", variant);
203
+ animations2.push(animateVariant(child, variant, {
204
+ ...options,
205
+ delay: delay2 + (typeof delayChildren === "function" ? 0 : delayChildren) + calcChildStagger(visualElement.variantChildren, child, delayChildren, staggerChildren, staggerDirection)
206
+ }).then(() => child.notify("AnimationComplete", variant)));
207
+ }
208
+ return Promise.all(animations2);
209
+ }
210
+ function animateVisualElement(visualElement, definition, options = {}) {
211
+ visualElement.notify("AnimationStart", definition);
212
+ let animation;
213
+ if (Array.isArray(definition)) {
214
+ const animations2 = definition.map((variant) => animateVariant(visualElement, variant, options));
215
+ animation = Promise.all(animations2);
216
+ } else if (typeof definition === "string") animation = animateVariant(visualElement, definition, options);
217
+ else {
218
+ const resolvedDefinition = typeof definition === "function" ? resolveVariant(visualElement, definition, options.custom) : definition;
219
+ animation = Promise.all(animateTarget(visualElement, resolvedDefinition, options));
220
+ }
221
+ return animation.then(() => {
222
+ visualElement.notify("AnimationComplete", definition);
223
+ });
224
+ }
225
+ var isDragging = {
226
+ x: false,
227
+ y: false
228
+ };
229
+ function isDragActive() {
230
+ return isDragging.x || isDragging.y;
231
+ }
232
+ function setDragLock(axis) {
233
+ if (axis === "x" || axis === "y") {
234
+ if (isDragging[axis]) return null;
235
+ else {
236
+ isDragging[axis] = true;
237
+ return () => {
238
+ isDragging[axis] = false;
239
+ };
240
+ }
241
+ } else if (isDragging.x || isDragging.y) return null;
242
+ else {
243
+ isDragging.x = isDragging.y = true;
244
+ return () => {
245
+ isDragging.x = isDragging.y = false;
246
+ };
247
+ }
248
+ }
249
+ function setupGesture(elementOrSelector, options) {
250
+ const elements = resolveElements(elementOrSelector);
251
+ const gestureAbortController = new AbortController();
252
+ const eventOptions = {
253
+ passive: true,
254
+ ...options,
255
+ signal: gestureAbortController.signal
256
+ };
257
+ const cancel = () => gestureAbortController.abort();
258
+ return [
259
+ elements,
260
+ eventOptions,
261
+ cancel
262
+ ];
263
+ }
264
+ function isValidHover(event) {
265
+ return !(event.pointerType === "touch" || isDragActive());
266
+ }
267
+ function hover(elementOrSelector, onHoverStart, options = {}) {
268
+ const [elements, eventOptions, cancel] = setupGesture(elementOrSelector, options);
269
+ elements.forEach((element) => {
270
+ let isPressed = false;
271
+ let deferredHoverEnd = false;
272
+ let hoverEndCallback;
273
+ const removePointerLeave = () => {
274
+ element.removeEventListener("pointerleave", onPointerLeave);
275
+ };
276
+ const endHover = (event) => {
277
+ if (hoverEndCallback) {
278
+ hoverEndCallback(event);
279
+ hoverEndCallback = void 0;
280
+ }
281
+ removePointerLeave();
282
+ };
283
+ const onPointerUp = (event) => {
284
+ isPressed = false;
285
+ window.removeEventListener("pointerup", onPointerUp);
286
+ window.removeEventListener("pointercancel", onPointerUp);
287
+ if (deferredHoverEnd) {
288
+ deferredHoverEnd = false;
289
+ endHover(event);
290
+ }
291
+ };
292
+ const onPointerDown = () => {
293
+ isPressed = true;
294
+ window.addEventListener("pointerup", onPointerUp, eventOptions);
295
+ window.addEventListener("pointercancel", onPointerUp, eventOptions);
296
+ };
297
+ const onPointerLeave = (leaveEvent) => {
298
+ if (leaveEvent.pointerType === "touch") return;
299
+ if (isPressed) {
300
+ deferredHoverEnd = true;
301
+ return;
302
+ }
303
+ endHover(leaveEvent);
304
+ };
305
+ const onPointerEnter = (enterEvent) => {
306
+ if (!isValidHover(enterEvent)) return;
307
+ deferredHoverEnd = false;
308
+ const onHoverEnd = onHoverStart(element, enterEvent);
309
+ if (typeof onHoverEnd !== "function") return;
310
+ hoverEndCallback = onHoverEnd;
311
+ element.addEventListener("pointerleave", onPointerLeave, eventOptions);
312
+ };
313
+ element.addEventListener("pointerenter", onPointerEnter, eventOptions);
314
+ element.addEventListener("pointerdown", onPointerDown, eventOptions);
315
+ });
316
+ return cancel;
317
+ }
318
+ var isNodeOrChild = (parent, child) => {
319
+ if (!child) return false;
320
+ else if (parent === child) return true;
321
+ else return isNodeOrChild(parent, child.parentElement);
322
+ };
323
+ var isPrimaryPointer = (event) => {
324
+ if (event.pointerType === "mouse") return typeof event.button !== "number" || event.button <= 0;
325
+ else
326
+ return event.isPrimary !== false;
327
+ };
328
+ var keyboardAccessibleElements = /* @__PURE__ */ new Set([
329
+ "BUTTON",
330
+ "INPUT",
331
+ "SELECT",
332
+ "TEXTAREA",
333
+ "A"
334
+ ]);
335
+ function isElementKeyboardAccessible(element) {
336
+ return keyboardAccessibleElements.has(element.tagName) || element.isContentEditable === true;
337
+ }
338
+ var textInputElements = /* @__PURE__ */ new Set([
339
+ "INPUT",
340
+ "SELECT",
341
+ "TEXTAREA"
342
+ ]);
343
+ function isElementTextInput(element) {
344
+ return textInputElements.has(element.tagName) || element.isContentEditable === true;
345
+ }
346
+ var isPressing = /* @__PURE__ */ new WeakSet();
347
+ function filterEvents(callback) {
348
+ return (event) => {
349
+ if (event.key !== "Enter") return;
350
+ callback(event);
351
+ };
352
+ }
353
+ function firePointerEvent(target, type) {
354
+ target.dispatchEvent(new PointerEvent("pointer" + type, {
355
+ isPrimary: true,
356
+ bubbles: true
357
+ }));
358
+ }
359
+ var enableKeyboardPress = (focusEvent, eventOptions) => {
360
+ const element = focusEvent.currentTarget;
361
+ if (!element) return;
362
+ const handleKeydown = filterEvents(() => {
363
+ if (isPressing.has(element)) return;
364
+ firePointerEvent(element, "down");
365
+ const handleKeyup = filterEvents(() => {
366
+ firePointerEvent(element, "up");
367
+ });
368
+ const handleBlur = () => firePointerEvent(element, "cancel");
369
+ element.addEventListener("keyup", handleKeyup, eventOptions);
370
+ element.addEventListener("blur", handleBlur, eventOptions);
371
+ });
372
+ element.addEventListener("keydown", handleKeydown, eventOptions);
373
+ element.addEventListener("blur", () => element.removeEventListener("keydown", handleKeydown), eventOptions);
374
+ };
375
+ function isValidPressEvent(event) {
376
+ return isPrimaryPointer(event) && !isDragActive();
377
+ }
378
+ var claimedPointerDownEvents = /* @__PURE__ */ new WeakSet();
379
+ function press(targetOrSelector, onPressStart, options = {}) {
380
+ const [targets, eventOptions, cancelEvents] = setupGesture(targetOrSelector, options);
381
+ const startPress = (startEvent) => {
382
+ const target = startEvent.currentTarget;
383
+ if (!isValidPressEvent(startEvent)) return;
384
+ if (claimedPointerDownEvents.has(startEvent)) return;
385
+ isPressing.add(target);
386
+ if (options.stopPropagation) claimedPointerDownEvents.add(startEvent);
387
+ const onPressEnd = onPressStart(target, startEvent);
388
+ const endEventOptions = {
389
+ ...eventOptions,
390
+ capture: true
391
+ };
392
+ const onPointerEnd = (endEvent, success) => {
393
+ window.removeEventListener("pointerup", onPointerUp, endEventOptions);
394
+ window.removeEventListener("pointercancel", onPointerCancel, endEventOptions);
395
+ if (isPressing.has(target)) isPressing.delete(target);
396
+ if (!isValidPressEvent(endEvent)) return;
397
+ if (typeof onPressEnd === "function") onPressEnd(endEvent, { success });
398
+ };
399
+ const onPointerUp = (upEvent) => {
400
+ onPointerEnd(upEvent, target === window || target === document || options.useGlobalTarget || isNodeOrChild(target, upEvent.target));
401
+ };
402
+ const onPointerCancel = (cancelEvent) => {
403
+ onPointerEnd(cancelEvent, false);
404
+ };
405
+ window.addEventListener("pointerup", onPointerUp, endEventOptions);
406
+ window.addEventListener("pointercancel", onPointerCancel, endEventOptions);
407
+ };
408
+ targets.forEach((target) => {
409
+ (options.useGlobalTarget ? window : target).addEventListener("pointerdown", startPress, eventOptions);
410
+ if (isHTMLElement(target)) {
411
+ target.addEventListener("focus", (event) => enableKeyboardPress(event, eventOptions));
412
+ if (!isElementKeyboardAccessible(target) && !target.hasAttribute("tabindex")) target.tabIndex = 0;
413
+ }
414
+ });
415
+ return cancelEvents;
416
+ }
417
+ var resizeHandlers = /* @__PURE__ */ new WeakMap();
418
+ var observer;
419
+ var getSize = (borderBoxAxis, svgAxis, htmlAxis) => (target, borderBoxSize) => {
420
+ if (borderBoxSize && borderBoxSize[0]) return borderBoxSize[0][borderBoxAxis + "Size"];
421
+ else if (isSVGElement(target) && "getBBox" in target) return target.getBBox()[svgAxis];
422
+ else return target[htmlAxis];
423
+ };
424
+ var getWidth = /* @__PURE__ */ getSize("inline", "width", "offsetWidth");
425
+ var getHeight = /* @__PURE__ */ getSize("block", "height", "offsetHeight");
426
+ function notifyTarget({ target, borderBoxSize }) {
427
+ resizeHandlers.get(target)?.forEach((handler) => {
428
+ handler(target, {
429
+ get width() {
430
+ return getWidth(target, borderBoxSize);
431
+ },
432
+ get height() {
433
+ return getHeight(target, borderBoxSize);
434
+ }
435
+ });
436
+ });
437
+ }
438
+ function notifyAll(entries) {
439
+ entries.forEach(notifyTarget);
440
+ }
441
+ function createResizeObserver() {
442
+ if (typeof ResizeObserver === "undefined") return;
443
+ observer = new ResizeObserver(notifyAll);
444
+ }
445
+ function resizeElement(target, handler) {
446
+ if (!observer) createResizeObserver();
447
+ const elements = resolveElements(target);
448
+ elements.forEach((element) => {
449
+ let elementHandlers = resizeHandlers.get(element);
450
+ if (!elementHandlers) {
451
+ elementHandlers = /* @__PURE__ */ new Set();
452
+ resizeHandlers.set(element, elementHandlers);
453
+ }
454
+ elementHandlers.add(handler);
455
+ observer?.observe(element);
456
+ });
457
+ return () => {
458
+ elements.forEach((element) => {
459
+ const elementHandlers = resizeHandlers.get(element);
460
+ elementHandlers?.delete(handler);
461
+ if (!elementHandlers?.size) observer?.unobserve(element);
462
+ });
463
+ };
464
+ }
465
+ var windowCallbacks = /* @__PURE__ */ new Set();
466
+ var windowResizeHandler;
467
+ function createWindowResizeHandler() {
468
+ windowResizeHandler = () => {
469
+ const info = {
470
+ get width() {
471
+ return window.innerWidth;
472
+ },
473
+ get height() {
474
+ return window.innerHeight;
475
+ }
476
+ };
477
+ windowCallbacks.forEach((callback) => callback(info));
478
+ };
479
+ window.addEventListener("resize", windowResizeHandler);
480
+ }
481
+ function resizeWindow(callback) {
482
+ windowCallbacks.add(callback);
483
+ if (!windowResizeHandler) createWindowResizeHandler();
484
+ return () => {
485
+ windowCallbacks.delete(callback);
486
+ if (!windowCallbacks.size && typeof windowResizeHandler === "function") {
487
+ window.removeEventListener("resize", windowResizeHandler);
488
+ windowResizeHandler = void 0;
489
+ }
490
+ };
491
+ }
492
+ function resize(a, b) {
493
+ return typeof a === "function" ? resizeWindow(a) : resizeElement(a, b);
494
+ }
495
+ var statsBuffer = {
496
+ value: null,
497
+ addProjectionMetrics: null
498
+ };
499
+ var Feature = class {
500
+ constructor(node) {
501
+ this.isMounted = false;
502
+ this.node = node;
503
+ }
504
+ update() {
505
+ }
506
+ };
507
+ var numVariantProps = variantProps.length;
508
+ function getVariantContext(visualElement) {
509
+ if (!visualElement) return void 0;
510
+ if (!visualElement.isControllingVariants) {
511
+ const context2 = visualElement.parent ? getVariantContext(visualElement.parent) || {} : {};
512
+ if (visualElement.props.initial !== void 0) context2.initial = visualElement.props.initial;
513
+ return context2;
514
+ }
515
+ const context = {};
516
+ for (let i = 0; i < numVariantProps; i++) {
517
+ const name = variantProps[i];
518
+ const prop = visualElement.props[name];
519
+ if (isVariantLabel(prop) || prop === false) context[name] = prop;
520
+ }
521
+ return context;
522
+ }
523
+ function shallowCompare(next, prev) {
524
+ if (!Array.isArray(prev)) return false;
525
+ const prevLength = prev.length;
526
+ if (prevLength !== next.length) return false;
527
+ for (let i = 0; i < prevLength; i++) if (prev[i] !== next[i]) return false;
528
+ return true;
529
+ }
530
+ var reversePriorityOrder = [...variantPriorityOrder].reverse();
531
+ var numAnimationTypes = variantPriorityOrder.length;
532
+ function createAnimateFunction(visualElement) {
533
+ return (animations2) => {
534
+ return Promise.all(animations2.map(({ animation, options }) => animateVisualElement(visualElement, animation, options)));
535
+ };
536
+ }
537
+ function createAnimationState(visualElement) {
538
+ let animate = createAnimateFunction(visualElement);
539
+ let state = createState$1();
540
+ let isInitialRender = true;
541
+ let wasReset = false;
542
+ const buildResolvedTypeValues = (type) => (acc, definition) => {
543
+ const resolved = resolveVariant(visualElement, definition, type === "exit" ? visualElement.presenceContext?.custom : void 0);
544
+ if (resolved) {
545
+ const { transition, transitionEnd, ...target } = resolved;
546
+ acc = {
547
+ ...acc,
548
+ ...target,
549
+ ...transitionEnd
550
+ };
551
+ }
552
+ return acc;
553
+ };
554
+ function setAnimateFunction(makeAnimator) {
555
+ animate = makeAnimator(visualElement);
556
+ }
557
+ function animateChanges(changedActiveType) {
558
+ const { props } = visualElement;
559
+ const context = getVariantContext(visualElement.parent) || {};
560
+ const animations2 = [];
561
+ const removedKeys = /* @__PURE__ */ new Set();
562
+ let encounteredKeys = {};
563
+ let removedVariantIndex = Infinity;
564
+ for (let i = 0; i < numAnimationTypes; i++) {
565
+ const type = reversePriorityOrder[i];
566
+ const typeState = state[type];
567
+ const prop = props[type] !== void 0 ? props[type] : context[type];
568
+ const propIsVariant = isVariantLabel(prop);
569
+ const activeDelta = type === changedActiveType ? typeState.isActive : null;
570
+ if (activeDelta === false) removedVariantIndex = i;
571
+ let isInherited = prop === context[type] && prop !== props[type] && propIsVariant;
572
+ if (isInherited && (isInitialRender || wasReset) && visualElement.manuallyAnimateOnMount) isInherited = false;
573
+ typeState.protectedKeys = { ...encounteredKeys };
574
+ if (!typeState.isActive && activeDelta === null || !prop && !typeState.prevProp || isAnimationControls(prop) || typeof prop === "boolean") continue;
575
+ if (type === "exit" && typeState.isActive && activeDelta !== true) {
576
+ if (typeState.prevResolvedValues) encounteredKeys = {
577
+ ...encounteredKeys,
578
+ ...typeState.prevResolvedValues
579
+ };
580
+ continue;
581
+ }
582
+ const variantDidChange = checkVariantsDidChange(typeState.prevProp, prop);
583
+ let shouldAnimateType = variantDidChange || type === changedActiveType && typeState.isActive && !isInherited && propIsVariant || i > removedVariantIndex && propIsVariant;
584
+ let handledRemovedValues = false;
585
+ const definitionList = Array.isArray(prop) ? prop : [prop];
586
+ let resolvedValues = definitionList.reduce(buildResolvedTypeValues(type), {});
587
+ if (activeDelta === false) resolvedValues = {};
588
+ const { prevResolvedValues = {} } = typeState;
589
+ const allKeys = {
590
+ ...prevResolvedValues,
591
+ ...resolvedValues
592
+ };
593
+ const markToAnimate = (key) => {
594
+ shouldAnimateType = true;
595
+ if (removedKeys.has(key)) {
596
+ handledRemovedValues = true;
597
+ removedKeys.delete(key);
598
+ }
599
+ typeState.needsAnimating[key] = true;
600
+ const motionValue2 = visualElement.getValue(key);
601
+ if (motionValue2) motionValue2.liveStyle = false;
602
+ };
603
+ for (const key in allKeys) {
604
+ const next = resolvedValues[key];
605
+ const prev = prevResolvedValues[key];
606
+ if (encounteredKeys.hasOwnProperty(key)) continue;
607
+ let valueHasChanged = false;
608
+ if (isKeyframesTarget(next) && isKeyframesTarget(prev)) valueHasChanged = !shallowCompare(next, prev) || variantDidChange;
609
+ else valueHasChanged = next !== prev;
610
+ if (valueHasChanged) {
611
+ if (next !== void 0 && next !== null) markToAnimate(key);
612
+ else removedKeys.add(key);
613
+ } else if (next !== void 0 && removedKeys.has(key))
614
+ markToAnimate(key);
615
+ else
616
+ typeState.protectedKeys[key] = true;
617
+ }
618
+ typeState.prevProp = prop;
619
+ typeState.prevResolvedValues = resolvedValues;
620
+ if (typeState.isActive) encounteredKeys = {
621
+ ...encounteredKeys,
622
+ ...resolvedValues
623
+ };
624
+ if ((isInitialRender || wasReset) && visualElement.blockInitialAnimation) shouldAnimateType = false;
625
+ const willAnimateViaParent = isInherited && variantDidChange;
626
+ if (shouldAnimateType && (!willAnimateViaParent || handledRemovedValues)) animations2.push(...definitionList.map((animation) => {
627
+ const options = { type };
628
+ if (typeof animation === "string" && (isInitialRender || wasReset) && !willAnimateViaParent && visualElement.manuallyAnimateOnMount && visualElement.parent) {
629
+ const { parent } = visualElement;
630
+ const parentVariant = resolveVariant(parent, animation);
631
+ if (parent.enteringChildren && parentVariant) {
632
+ const { delayChildren } = parentVariant.transition || {};
633
+ options.delay = calcChildStagger(parent.enteringChildren, visualElement, delayChildren);
634
+ }
635
+ }
636
+ return {
637
+ animation,
638
+ options
639
+ };
640
+ }));
641
+ }
642
+ if (removedKeys.size) {
643
+ const fallbackAnimation = {};
644
+ if (typeof props.initial !== "boolean") {
645
+ const initialTransition = resolveVariant(visualElement, Array.isArray(props.initial) ? props.initial[0] : props.initial);
646
+ if (initialTransition && initialTransition.transition) fallbackAnimation.transition = initialTransition.transition;
647
+ }
648
+ removedKeys.forEach((key) => {
649
+ const fallbackTarget = visualElement.getBaseTarget(key);
650
+ const motionValue2 = visualElement.getValue(key);
651
+ if (motionValue2) motionValue2.liveStyle = true;
652
+ fallbackAnimation[key] = fallbackTarget ?? null;
653
+ });
654
+ animations2.push({ animation: fallbackAnimation });
655
+ }
656
+ let shouldAnimate = Boolean(animations2.length);
657
+ if (isInitialRender && (props.initial === false || props.initial === props.animate) && !visualElement.manuallyAnimateOnMount) shouldAnimate = false;
658
+ isInitialRender = false;
659
+ wasReset = false;
660
+ return shouldAnimate ? animate(animations2) : Promise.resolve();
661
+ }
662
+ function setActive(type, isActive) {
663
+ if (state[type].isActive === isActive) return Promise.resolve();
664
+ visualElement.variantChildren?.forEach((child) => child.animationState?.setActive(type, isActive));
665
+ state[type].isActive = isActive;
666
+ const animations2 = animateChanges(type);
667
+ for (const key in state) state[key].protectedKeys = {};
668
+ return animations2;
669
+ }
670
+ return {
671
+ animateChanges,
672
+ setActive,
673
+ setAnimateFunction,
674
+ getState: () => state,
675
+ reset: () => {
676
+ state = createState$1();
677
+ wasReset = true;
678
+ }
679
+ };
680
+ }
681
+ function checkVariantsDidChange(prev, next) {
682
+ if (typeof next === "string") return next !== prev;
683
+ else if (Array.isArray(next)) return !shallowCompare(next, prev);
684
+ return false;
685
+ }
686
+ function createTypeState(isActive = false) {
687
+ return {
688
+ isActive,
689
+ protectedKeys: {},
690
+ needsAnimating: {},
691
+ prevResolvedValues: {}
692
+ };
693
+ }
694
+ function createState$1() {
695
+ return {
696
+ animate: createTypeState(true),
697
+ whileInView: createTypeState(),
698
+ whileHover: createTypeState(),
699
+ whileTap: createTypeState(),
700
+ whileDrag: createTypeState(),
701
+ whileFocus: createTypeState(),
702
+ exit: createTypeState()
703
+ };
704
+ }
705
+ function copyAxisInto(axis, originAxis) {
706
+ axis.min = originAxis.min;
707
+ axis.max = originAxis.max;
708
+ }
709
+ function copyBoxInto(box, originBox) {
710
+ copyAxisInto(box.x, originBox.x);
711
+ copyAxisInto(box.y, originBox.y);
712
+ }
713
+ function copyAxisDeltaInto(delta, originDelta) {
714
+ delta.translate = originDelta.translate;
715
+ delta.scale = originDelta.scale;
716
+ delta.originPoint = originDelta.originPoint;
717
+ delta.origin = originDelta.origin;
718
+ }
719
+ var SCALE_MIN = 0.9999;
720
+ var SCALE_MAX = 1.0001;
721
+ var TRANSLATE_MIN = -0.01;
722
+ var TRANSLATE_MAX = 0.01;
723
+ function calcLength(axis) {
724
+ return axis.max - axis.min;
725
+ }
726
+ function isNear(value, target, maxDistance) {
727
+ return Math.abs(value - target) <= maxDistance;
728
+ }
729
+ function calcAxisDelta(delta, source, target, origin = 0.5) {
730
+ delta.origin = origin;
731
+ delta.originPoint = mixNumber(source.min, source.max, delta.origin);
732
+ delta.scale = calcLength(target) / calcLength(source);
733
+ delta.translate = mixNumber(target.min, target.max, delta.origin) - delta.originPoint;
734
+ if (delta.scale >= SCALE_MIN && delta.scale <= SCALE_MAX || isNaN(delta.scale)) delta.scale = 1;
735
+ if (delta.translate >= TRANSLATE_MIN && delta.translate <= TRANSLATE_MAX || isNaN(delta.translate)) delta.translate = 0;
736
+ }
737
+ function calcBoxDelta(delta, source, target, origin) {
738
+ calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : void 0);
739
+ calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : void 0);
740
+ }
741
+ function calcRelativeAxis(target, relative2, parent, anchor = 0) {
742
+ target.min = (anchor ? mixNumber(parent.min, parent.max, anchor) : parent.min) + relative2.min;
743
+ target.max = target.min + calcLength(relative2);
744
+ }
745
+ function calcRelativeBox(target, relative2, parent, anchor) {
746
+ calcRelativeAxis(target.x, relative2.x, parent.x, anchor?.x);
747
+ calcRelativeAxis(target.y, relative2.y, parent.y, anchor?.y);
748
+ }
749
+ function calcRelativeAxisPosition(target, layout2, parent, anchor = 0) {
750
+ const anchorPoint = anchor ? mixNumber(parent.min, parent.max, anchor) : parent.min;
751
+ target.min = layout2.min - anchorPoint;
752
+ target.max = target.min + calcLength(layout2);
753
+ }
754
+ function calcRelativePosition(target, layout2, parent, anchor) {
755
+ calcRelativeAxisPosition(target.x, layout2.x, parent.x, anchor?.x);
756
+ calcRelativeAxisPosition(target.y, layout2.y, parent.y, anchor?.y);
757
+ }
758
+ function removePointDelta(point, translate, scale, originPoint, boxScale) {
759
+ point -= translate;
760
+ point = scalePoint(point, 1 / scale, originPoint);
761
+ if (boxScale !== void 0) point = scalePoint(point, 1 / boxScale, originPoint);
762
+ return point;
763
+ }
764
+ function removeAxisDelta(axis, translate = 0, scale = 1, origin = 0.5, boxScale, originAxis = axis, sourceAxis = axis) {
765
+ if (percent.test(translate)) {
766
+ translate = parseFloat(translate);
767
+ translate = mixNumber(sourceAxis.min, sourceAxis.max, translate / 100) - sourceAxis.min;
768
+ }
769
+ if (typeof translate !== "number") return;
770
+ let originPoint = mixNumber(originAxis.min, originAxis.max, origin);
771
+ if (axis === originAxis) originPoint -= translate;
772
+ axis.min = removePointDelta(axis.min, translate, scale, originPoint, boxScale);
773
+ axis.max = removePointDelta(axis.max, translate, scale, originPoint, boxScale);
774
+ }
775
+ function removeAxisTransforms(axis, transforms, [key, scaleKey, originKey], origin, sourceAxis) {
776
+ removeAxisDelta(axis, transforms[key], transforms[scaleKey], transforms[originKey], transforms.scale, origin, sourceAxis);
777
+ }
778
+ var xKeys = [
779
+ "x",
780
+ "scaleX",
781
+ "originX"
782
+ ];
783
+ var yKeys = [
784
+ "y",
785
+ "scaleY",
786
+ "originY"
787
+ ];
788
+ function removeBoxTransforms(box, transforms, originBox, sourceBox) {
789
+ removeAxisTransforms(box.x, transforms, xKeys, originBox ? originBox.x : void 0, sourceBox ? sourceBox.x : void 0);
790
+ removeAxisTransforms(box.y, transforms, yKeys, originBox ? originBox.y : void 0, sourceBox ? sourceBox.y : void 0);
791
+ }
792
+ function isAxisDeltaZero(delta) {
793
+ return delta.translate === 0 && delta.scale === 1;
794
+ }
795
+ function isDeltaZero(delta) {
796
+ return isAxisDeltaZero(delta.x) && isAxisDeltaZero(delta.y);
797
+ }
798
+ function axisEquals(a, b) {
799
+ return a.min === b.min && a.max === b.max;
800
+ }
801
+ function boxEquals(a, b) {
802
+ return axisEquals(a.x, b.x) && axisEquals(a.y, b.y);
803
+ }
804
+ function axisEqualsRounded(a, b) {
805
+ return Math.round(a.min) === Math.round(b.min) && Math.round(a.max) === Math.round(b.max);
806
+ }
807
+ function boxEqualsRounded(a, b) {
808
+ return axisEqualsRounded(a.x, b.x) && axisEqualsRounded(a.y, b.y);
809
+ }
810
+ function aspectRatio(box) {
811
+ return calcLength(box.x) / calcLength(box.y);
812
+ }
813
+ function axisDeltaEquals(a, b) {
814
+ return a.translate === b.translate && a.scale === b.scale && a.originPoint === b.originPoint;
815
+ }
816
+ function eachAxis(callback) {
817
+ return [callback("x"), callback("y")];
818
+ }
819
+ function buildProjectionTransform(delta, treeScale, latestTransform) {
820
+ let transform = "";
821
+ const xTranslate = delta.x.translate / treeScale.x;
822
+ const yTranslate = delta.y.translate / treeScale.y;
823
+ const zTranslate = latestTransform?.z || 0;
824
+ if (xTranslate || yTranslate || zTranslate) transform = `translate3d(${xTranslate}px, ${yTranslate}px, ${zTranslate}px) `;
825
+ if (treeScale.x !== 1 || treeScale.y !== 1) transform += `scale(${1 / treeScale.x}, ${1 / treeScale.y}) `;
826
+ if (latestTransform) {
827
+ const { transformPerspective, rotate, pathRotation, rotateX, rotateY, skewX, skewY } = latestTransform;
828
+ if (transformPerspective) transform = `perspective(${transformPerspective}px) ${transform}`;
829
+ if (rotate) transform += `rotate(${rotate}deg) `;
830
+ if (pathRotation) transform += `rotate(${pathRotation}deg) `;
831
+ if (rotateX) transform += `rotateX(${rotateX}deg) `;
832
+ if (rotateY) transform += `rotateY(${rotateY}deg) `;
833
+ if (skewX) transform += `skewX(${skewX}deg) `;
834
+ if (skewY) transform += `skewY(${skewY}deg) `;
835
+ }
836
+ const elementScaleX = delta.x.scale * treeScale.x;
837
+ const elementScaleY = delta.y.scale * treeScale.y;
838
+ if (elementScaleX !== 1 || elementScaleY !== 1) transform += `scale(${elementScaleX}, ${elementScaleY})`;
839
+ return transform || "none";
840
+ }
841
+ var numBorders = cornerRadiusProps.length;
842
+ var asNumber = (value) => typeof value === "string" ? parseFloat(value) : value;
843
+ var isPx = (value) => typeof value === "number" || px.test(value);
844
+ function mixValues(target, follow, lead, progress2, shouldCrossfadeOpacity, isOnlyMember) {
845
+ if (shouldCrossfadeOpacity) {
846
+ target.opacity = mixNumber(0, lead.opacity ?? 1, easeCrossfadeIn(progress2));
847
+ target.opacityExit = mixNumber(follow.opacity ?? 1, 0, easeCrossfadeOut(progress2));
848
+ } else if (isOnlyMember) target.opacity = mixNumber(follow.opacity ?? 1, lead.opacity ?? 1, progress2);
849
+ for (let i = 0; i < numBorders; i++) {
850
+ const borderLabel = cornerRadiusProps[i];
851
+ let followRadius = getRadius(follow, borderLabel);
852
+ let leadRadius = getRadius(lead, borderLabel);
853
+ if (followRadius === void 0 && leadRadius === void 0) continue;
854
+ followRadius || (followRadius = 0);
855
+ leadRadius || (leadRadius = 0);
856
+ if (followRadius === 0 || leadRadius === 0 || isPx(followRadius) === isPx(leadRadius)) {
857
+ target[borderLabel] = Math.max(mixNumber(asNumber(followRadius), asNumber(leadRadius), progress2), 0);
858
+ if (percent.test(leadRadius) || percent.test(followRadius)) target[borderLabel] += "%";
859
+ } else target[borderLabel] = leadRadius;
860
+ }
861
+ if (follow.rotate || lead.rotate) target.rotate = mixNumber(follow.rotate || 0, lead.rotate || 0, progress2);
862
+ }
863
+ function getRadius(values, radiusName) {
864
+ return values[radiusName] !== void 0 ? values[radiusName] : values.borderRadius;
865
+ }
866
+ var easeCrossfadeIn = /* @__PURE__ */ compress(0, 0.5, circOut);
867
+ var easeCrossfadeOut = /* @__PURE__ */ compress(0.5, 0.95, noop);
868
+ function compress(min, max, easing) {
869
+ return (p) => {
870
+ if (p < min) return 0;
871
+ if (p > max) return 1;
872
+ return easing(progress(min, max, p));
873
+ };
874
+ }
875
+ function addDomEvent(target, eventName, handler, options = { passive: true }) {
876
+ target.addEventListener(eventName, handler, options);
877
+ return () => target.removeEventListener(eventName, handler, options);
878
+ }
879
+ var compareByDepth = (a, b) => a.depth - b.depth;
880
+ var FlatTree = class {
881
+ constructor() {
882
+ this.children = [];
883
+ this.isDirty = false;
884
+ }
885
+ add(child) {
886
+ addUniqueItem(this.children, child);
887
+ this.isDirty = true;
888
+ }
889
+ remove(child) {
890
+ removeItem(this.children, child);
891
+ this.isDirty = true;
892
+ }
893
+ forEach(callback) {
894
+ this.isDirty && this.children.sort(compareByDepth);
895
+ this.isDirty = false;
896
+ this.children.forEach(callback);
897
+ }
898
+ };
899
+ function delay$1(callback, timeout) {
900
+ const start = time.now();
901
+ const checkElapsed = ({ timestamp }) => {
902
+ const elapsed = timestamp - start;
903
+ if (elapsed >= timeout) {
904
+ cancelFrame(checkElapsed);
905
+ callback(elapsed - timeout);
906
+ }
907
+ };
908
+ frame.setup(checkElapsed, true);
909
+ return () => cancelFrame(checkElapsed);
910
+ }
911
+ var NodeStack = class {
912
+ constructor() {
913
+ this.members = [];
914
+ }
915
+ add(node) {
916
+ addUniqueItem(this.members, node);
917
+ for (let i = this.members.length - 1; i >= 0; i--) {
918
+ const member = this.members[i];
919
+ if (member === node || member === this.lead || member === this.prevLead) continue;
920
+ const inst = member.instance;
921
+ if ((!inst || inst.isConnected === false) && !member.snapshot) {
922
+ removeItem(this.members, member);
923
+ member.unmount();
924
+ }
925
+ }
926
+ node.scheduleRender();
927
+ }
928
+ remove(node) {
929
+ removeItem(this.members, node);
930
+ if (node === this.prevLead) this.prevLead = void 0;
931
+ if (node === this.lead) {
932
+ const prevLead = this.members[this.members.length - 1];
933
+ if (prevLead) this.promote(prevLead);
934
+ }
935
+ }
936
+ relegate(node) {
937
+ for (let i = this.members.indexOf(node) - 1; i >= 0; i--) {
938
+ const member = this.members[i];
939
+ if (member.isPresent !== false && member.instance?.isConnected !== false) {
940
+ this.promote(member);
941
+ return true;
942
+ }
943
+ }
944
+ return false;
945
+ }
946
+ promote(node, preserveFollowOpacity) {
947
+ const prevLead = this.lead;
948
+ if (node === prevLead) return;
949
+ this.prevLead = prevLead;
950
+ this.lead = node;
951
+ node.show();
952
+ if (prevLead) {
953
+ prevLead.updateSnapshot();
954
+ node.scheduleRender();
955
+ const { layoutDependency: prevDep } = prevLead.options;
956
+ const { layoutDependency: nextDep } = node.options;
957
+ if (prevDep === void 0 || prevDep !== nextDep) {
958
+ node.resumeFrom = prevLead;
959
+ if (preserveFollowOpacity) prevLead.preserveOpacity = true;
960
+ if (prevLead.snapshot) {
961
+ node.snapshot = prevLead.snapshot;
962
+ node.snapshot.latestValues = prevLead.animationValues || prevLead.latestValues;
963
+ }
964
+ if (node.root?.isUpdating) node.isLayoutDirty = true;
965
+ }
966
+ if (node.options.crossfade === false) prevLead.hide();
967
+ }
968
+ }
969
+ exitAnimationComplete() {
970
+ this.members.forEach((member) => {
971
+ member.options.onExitComplete?.();
972
+ member.resumingFrom?.options.onExitComplete?.();
973
+ });
974
+ }
975
+ scheduleRender() {
976
+ this.members.forEach((member) => member.instance && member.scheduleRender(false));
977
+ }
978
+ removeLeadSnapshot() {
979
+ if (this.lead?.snapshot) this.lead.snapshot = void 0;
980
+ }
981
+ };
982
+ var globalProjectionState = {
983
+ /**
984
+ * Global flag as to whether the tree has animated since the last time
985
+ * we resized the window
986
+ */
987
+ hasAnimatedSinceResize: true,
988
+ /**
989
+ * We set this to true once, on the first update. Any nodes added to the tree beyond that
990
+ * update will be given a `data-projection-id` attribute.
991
+ */
992
+ hasEverUpdated: false
993
+ };
994
+ var metrics = {
995
+ nodes: 0,
996
+ calculatedTargetDeltas: 0,
997
+ calculatedProjections: 0
998
+ };
999
+ var transformAxes = [
1000
+ "",
1001
+ "X",
1002
+ "Y",
1003
+ "Z"
1004
+ ];
1005
+ var animationTarget = 1e3;
1006
+ var id$1 = 0;
1007
+ function resetDistortingTransform(key, visualElement, values, sharedAnimationValues) {
1008
+ const { latestValues } = visualElement;
1009
+ if (latestValues[key]) {
1010
+ values[key] = latestValues[key];
1011
+ visualElement.setStaticValue(key, 0);
1012
+ if (sharedAnimationValues) sharedAnimationValues[key] = 0;
1013
+ }
1014
+ }
1015
+ function cancelTreeOptimisedTransformAnimations(projectionNode) {
1016
+ projectionNode.hasCheckedOptimisedAppear = true;
1017
+ if (projectionNode.root === projectionNode) return;
1018
+ const { visualElement } = projectionNode.options;
1019
+ if (!visualElement) return;
1020
+ const appearId = getOptimisedAppearId(visualElement);
1021
+ if (window.MotionHasOptimisedAnimation(appearId, "transform")) {
1022
+ const { layout: layout2, layoutId } = projectionNode.options;
1023
+ window.MotionCancelOptimisedAnimation(appearId, "transform", frame, !(layout2 || layoutId));
1024
+ }
1025
+ const { parent } = projectionNode;
1026
+ if (parent && !parent.hasCheckedOptimisedAppear) cancelTreeOptimisedTransformAnimations(parent);
1027
+ }
1028
+ function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform }) {
1029
+ return class ProjectionNode {
1030
+ constructor(latestValues = {}, parent = defaultParent?.()) {
1031
+ this.id = id$1++;
1032
+ this.animationId = 0;
1033
+ this.animationCommitId = 0;
1034
+ this.children = /* @__PURE__ */ new Set();
1035
+ this.options = {};
1036
+ this.isTreeAnimating = false;
1037
+ this.isAnimationBlocked = false;
1038
+ this.isLayoutDirty = false;
1039
+ this.isProjectionDirty = false;
1040
+ this.isSharedProjectionDirty = false;
1041
+ this.isTransformDirty = false;
1042
+ this.updateManuallyBlocked = false;
1043
+ this.updateBlockedByResize = false;
1044
+ this.isUpdating = false;
1045
+ this.isSVG = false;
1046
+ this.needsReset = false;
1047
+ this.shouldResetTransform = false;
1048
+ this.hasCheckedOptimisedAppear = false;
1049
+ this.treeScale = {
1050
+ x: 1,
1051
+ y: 1
1052
+ };
1053
+ this.eventHandlers = /* @__PURE__ */ new Map();
1054
+ this.hasTreeAnimated = false;
1055
+ this.layoutVersion = 0;
1056
+ this.updateScheduled = false;
1057
+ this.scheduleUpdate = () => this.update();
1058
+ this.projectionUpdateScheduled = false;
1059
+ this.checkUpdateFailed = () => {
1060
+ if (this.isUpdating) {
1061
+ this.isUpdating = false;
1062
+ this.clearAllSnapshots();
1063
+ }
1064
+ };
1065
+ this.updateProjection = () => {
1066
+ this.projectionUpdateScheduled = false;
1067
+ if (statsBuffer.value) metrics.nodes = metrics.calculatedTargetDeltas = metrics.calculatedProjections = 0;
1068
+ this.nodes.forEach(propagateDirtyNodes);
1069
+ this.nodes.forEach(resolveTargetDelta);
1070
+ this.nodes.forEach(calcProjection);
1071
+ this.nodes.forEach(cleanDirtyNodes);
1072
+ if (statsBuffer.addProjectionMetrics) statsBuffer.addProjectionMetrics(metrics);
1073
+ };
1074
+ this.resolvedRelativeTargetAt = 0;
1075
+ this.linkedParentVersion = 0;
1076
+ this.hasProjected = false;
1077
+ this.isVisible = true;
1078
+ this.animationProgress = 0;
1079
+ this.sharedNodes = /* @__PURE__ */ new Map();
1080
+ this.latestValues = latestValues;
1081
+ this.root = parent ? parent.root || parent : this;
1082
+ this.path = parent ? [...parent.path, parent] : [];
1083
+ this.parent = parent;
1084
+ this.depth = parent ? parent.depth + 1 : 0;
1085
+ for (let i = 0; i < this.path.length; i++) this.path[i].shouldResetTransform = true;
1086
+ if (this.root === this) this.nodes = new FlatTree();
1087
+ }
1088
+ addEventListener(name, handler) {
1089
+ if (!this.eventHandlers.has(name)) this.eventHandlers.set(name, new SubscriptionManager());
1090
+ return this.eventHandlers.get(name).add(handler);
1091
+ }
1092
+ notifyListeners(name, ...args) {
1093
+ const subscriptionManager = this.eventHandlers.get(name);
1094
+ subscriptionManager && subscriptionManager.notify(...args);
1095
+ }
1096
+ hasListeners(name) {
1097
+ return this.eventHandlers.has(name);
1098
+ }
1099
+ /**
1100
+ * Lifecycles
1101
+ */
1102
+ mount(instance) {
1103
+ if (this.instance) return;
1104
+ this.isSVG = isSVGElement(instance) && !isSVGSVGElement(instance);
1105
+ this.instance = instance;
1106
+ const { layoutId, layout: layout2, visualElement } = this.options;
1107
+ if (visualElement && !visualElement.current) visualElement.mount(instance);
1108
+ this.root.nodes.add(this);
1109
+ this.parent && this.parent.children.add(this);
1110
+ if (this.root.hasTreeAnimated && (layout2 || layoutId)) this.isLayoutDirty = true;
1111
+ if (attachResizeListener) {
1112
+ let cancelDelay;
1113
+ let innerWidth = 0;
1114
+ const resizeUnblockUpdate = () => this.root.updateBlockedByResize = false;
1115
+ frame.read(() => {
1116
+ innerWidth = window.innerWidth;
1117
+ });
1118
+ attachResizeListener(instance, () => {
1119
+ const newInnerWidth = window.innerWidth;
1120
+ if (newInnerWidth === innerWidth) return;
1121
+ innerWidth = newInnerWidth;
1122
+ this.root.updateBlockedByResize = true;
1123
+ cancelDelay && cancelDelay();
1124
+ cancelDelay = delay$1(resizeUnblockUpdate, 250);
1125
+ if (globalProjectionState.hasAnimatedSinceResize) {
1126
+ globalProjectionState.hasAnimatedSinceResize = false;
1127
+ this.nodes.forEach(finishAnimation);
1128
+ }
1129
+ });
1130
+ }
1131
+ if (layoutId) this.root.registerSharedNode(layoutId, this);
1132
+ if (this.options.animate !== false && visualElement && (layoutId || layout2)) this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeLayoutChanged, layout: newLayout }) => {
1133
+ if (this.isTreeAnimationBlocked()) {
1134
+ this.target = void 0;
1135
+ this.relativeTarget = void 0;
1136
+ return;
1137
+ }
1138
+ const layoutTransition = this.options.transition || visualElement.getDefaultTransition() || defaultLayoutTransition;
1139
+ const { onLayoutAnimationStart, onLayoutAnimationComplete } = visualElement.getProps();
1140
+ const hasTargetChanged = !this.targetLayout || !boxEqualsRounded(this.targetLayout, newLayout);
1141
+ const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeLayoutChanged;
1142
+ if (this.options.layoutRoot || this.resumeFrom || hasOnlyRelativeTargetChanged || hasLayoutChanged && (hasTargetChanged || !this.currentAnimation)) {
1143
+ if (this.resumeFrom) {
1144
+ this.resumingFrom = this.resumeFrom;
1145
+ this.resumingFrom.resumingFrom = void 0;
1146
+ }
1147
+ const animationOptions = {
1148
+ ...getValueTransition(layoutTransition, "layout"),
1149
+ onPlay: onLayoutAnimationStart,
1150
+ onComplete: onLayoutAnimationComplete
1151
+ };
1152
+ if (visualElement.shouldReduceMotion || this.options.layoutRoot) {
1153
+ animationOptions.delay = 0;
1154
+ animationOptions.type = false;
1155
+ }
1156
+ this.startAnimation(animationOptions);
1157
+ this.setAnimationOrigin(delta, hasOnlyRelativeTargetChanged, animationOptions.path);
1158
+ } else {
1159
+ if (!hasLayoutChanged) finishAnimation(this);
1160
+ if (this.isLead() && this.options.onExitComplete) this.options.onExitComplete();
1161
+ }
1162
+ this.targetLayout = newLayout;
1163
+ });
1164
+ }
1165
+ unmount() {
1166
+ this.options.layoutId && this.willUpdate();
1167
+ this.root.nodes.remove(this);
1168
+ const stack = this.getStack();
1169
+ stack && stack.remove(this);
1170
+ this.parent && this.parent.children.delete(this);
1171
+ this.instance = void 0;
1172
+ this.eventHandlers.clear();
1173
+ cancelFrame(this.updateProjection);
1174
+ }
1175
+ blockUpdate() {
1176
+ this.updateManuallyBlocked = true;
1177
+ }
1178
+ unblockUpdate() {
1179
+ this.updateManuallyBlocked = false;
1180
+ }
1181
+ isUpdateBlocked() {
1182
+ return this.updateManuallyBlocked || this.updateBlockedByResize;
1183
+ }
1184
+ isTreeAnimationBlocked() {
1185
+ return this.isAnimationBlocked || this.parent && this.parent.isTreeAnimationBlocked() || false;
1186
+ }
1187
+ startUpdate() {
1188
+ if (this.isUpdateBlocked()) return;
1189
+ this.isUpdating = true;
1190
+ this.nodes && this.nodes.forEach(resetSkewAndRotation);
1191
+ this.animationId++;
1192
+ }
1193
+ getTransformTemplate() {
1194
+ const { visualElement } = this.options;
1195
+ return visualElement && visualElement.getProps().transformTemplate;
1196
+ }
1197
+ willUpdate(shouldNotifyListeners = true) {
1198
+ this.root.hasTreeAnimated = true;
1199
+ if (this.root.isUpdateBlocked()) {
1200
+ this.options.onExitComplete && this.options.onExitComplete();
1201
+ return;
1202
+ }
1203
+ if (window.MotionCancelOptimisedAnimation && !this.hasCheckedOptimisedAppear) cancelTreeOptimisedTransformAnimations(this);
1204
+ !this.root.isUpdating && this.root.startUpdate();
1205
+ if (this.isLayoutDirty) return;
1206
+ this.isLayoutDirty = true;
1207
+ for (let i = 0; i < this.path.length; i++) {
1208
+ const node = this.path[i];
1209
+ node.shouldResetTransform = true;
1210
+ if (typeof node.latestValues.x === "string" || typeof node.latestValues.y === "string") node.isLayoutDirty = true;
1211
+ node.updateScroll("snapshot");
1212
+ if (node.options.layoutRoot) node.willUpdate(false);
1213
+ }
1214
+ const { layoutId, layout: layout2 } = this.options;
1215
+ if (layoutId === void 0 && !layout2) return;
1216
+ const transformTemplate = this.getTransformTemplate();
1217
+ this.prevTransformTemplateValue = transformTemplate ? transformTemplate(this.latestValues, "") : void 0;
1218
+ this.updateSnapshot();
1219
+ shouldNotifyListeners && this.notifyListeners("willUpdate");
1220
+ }
1221
+ update() {
1222
+ this.updateScheduled = false;
1223
+ if (this.isUpdateBlocked()) {
1224
+ const wasBlockedByResize = this.updateBlockedByResize;
1225
+ this.unblockUpdate();
1226
+ this.updateBlockedByResize = false;
1227
+ this.clearAllSnapshots();
1228
+ if (wasBlockedByResize) this.nodes.forEach(forceLayoutMeasure);
1229
+ this.nodes.forEach(clearMeasurements);
1230
+ return;
1231
+ }
1232
+ if (this.animationId <= this.animationCommitId) {
1233
+ this.nodes.forEach(clearIsLayoutDirty);
1234
+ return;
1235
+ }
1236
+ this.animationCommitId = this.animationId;
1237
+ if (!this.isUpdating) this.nodes.forEach(clearIsLayoutDirty);
1238
+ else {
1239
+ this.isUpdating = false;
1240
+ this.nodes.forEach(ensureDraggedNodesSnapshotted);
1241
+ this.nodes.forEach(resetTransformStyle);
1242
+ this.nodes.forEach(updateLayout);
1243
+ this.nodes.forEach(notifyLayoutUpdate);
1244
+ }
1245
+ this.clearAllSnapshots();
1246
+ const now2 = time.now();
1247
+ frameData.delta = clamp(0, 1e3 / 60, now2 - frameData.timestamp);
1248
+ frameData.timestamp = now2;
1249
+ frameData.isProcessing = true;
1250
+ frameSteps.update.process(frameData);
1251
+ frameSteps.preRender.process(frameData);
1252
+ frameSteps.render.process(frameData);
1253
+ frameData.isProcessing = false;
1254
+ }
1255
+ didUpdate() {
1256
+ if (!this.updateScheduled) {
1257
+ this.updateScheduled = true;
1258
+ microtask.read(this.scheduleUpdate);
1259
+ }
1260
+ }
1261
+ clearAllSnapshots() {
1262
+ this.nodes.forEach(clearSnapshot);
1263
+ this.sharedNodes.forEach(removeLeadSnapshots);
1264
+ }
1265
+ scheduleUpdateProjection() {
1266
+ if (!this.projectionUpdateScheduled) {
1267
+ this.projectionUpdateScheduled = true;
1268
+ frame.preRender(this.updateProjection, false, true);
1269
+ }
1270
+ }
1271
+ scheduleCheckAfterUnmount() {
1272
+ frame.postRender(() => {
1273
+ if (this.isLayoutDirty) this.root.didUpdate();
1274
+ else this.root.checkUpdateFailed();
1275
+ });
1276
+ }
1277
+ /**
1278
+ * Update measurements
1279
+ */
1280
+ updateSnapshot() {
1281
+ if (this.snapshot || !this.instance) return;
1282
+ this.snapshot = this.measure();
1283
+ if (this.snapshot && !calcLength(this.snapshot.measuredBox.x) && !calcLength(this.snapshot.measuredBox.y)) this.snapshot = void 0;
1284
+ }
1285
+ updateLayout() {
1286
+ if (!this.instance) return;
1287
+ this.updateScroll();
1288
+ if (!(this.options.alwaysMeasureLayout && this.isLead()) && !this.isLayoutDirty) return;
1289
+ if (this.resumeFrom && !this.resumeFrom.instance) for (let i = 0; i < this.path.length; i++) this.path[i].updateScroll();
1290
+ const prevLayout = this.layout;
1291
+ this.layout = this.measure(false);
1292
+ this.layoutVersion++;
1293
+ if (!this.layoutCorrected) this.layoutCorrected = createBox();
1294
+ this.isLayoutDirty = false;
1295
+ this.projectionDelta = void 0;
1296
+ this.notifyListeners("measure", this.layout.layoutBox);
1297
+ const { visualElement } = this.options;
1298
+ visualElement && visualElement.notify("LayoutMeasure", this.layout.layoutBox, prevLayout ? prevLayout.layoutBox : void 0);
1299
+ }
1300
+ updateScroll(phase = "measure") {
1301
+ let needsMeasurement = Boolean(this.options.layoutScroll && this.instance);
1302
+ if (this.scroll && this.scroll.animationId === this.root.animationId && this.scroll.phase === phase) needsMeasurement = false;
1303
+ if (needsMeasurement && this.instance) {
1304
+ const isRoot = checkIsScrollRoot(this.instance);
1305
+ this.scroll = {
1306
+ animationId: this.root.animationId,
1307
+ phase,
1308
+ isRoot,
1309
+ offset: measureScroll(this.instance),
1310
+ wasRoot: this.scroll ? this.scroll.isRoot : isRoot
1311
+ };
1312
+ }
1313
+ }
1314
+ resetTransform() {
1315
+ if (!resetTransform) return;
1316
+ const isResetRequested = this.isLayoutDirty || this.shouldResetTransform || this.options.alwaysMeasureLayout;
1317
+ const hasProjection = this.projectionDelta && !isDeltaZero(this.projectionDelta);
1318
+ const transformTemplate = this.getTransformTemplate();
1319
+ const transformTemplateValue = transformTemplate ? transformTemplate(this.latestValues, "") : void 0;
1320
+ const transformTemplateHasChanged = transformTemplateValue !== this.prevTransformTemplateValue;
1321
+ if (isResetRequested && this.instance && (hasProjection || hasTransform(this.latestValues) || transformTemplateHasChanged)) {
1322
+ resetTransform(this.instance, transformTemplateValue);
1323
+ this.shouldResetTransform = false;
1324
+ this.scheduleRender();
1325
+ }
1326
+ }
1327
+ measure(removeTransform = true) {
1328
+ const pageBox = this.measurePageBox();
1329
+ let layoutBox = this.removeElementScroll(pageBox);
1330
+ if (removeTransform) layoutBox = this.removeTransform(layoutBox);
1331
+ roundBox(layoutBox);
1332
+ return {
1333
+ animationId: this.root.animationId,
1334
+ measuredBox: pageBox,
1335
+ layoutBox,
1336
+ latestValues: {},
1337
+ source: this.id
1338
+ };
1339
+ }
1340
+ measurePageBox() {
1341
+ const { visualElement } = this.options;
1342
+ if (!visualElement) return createBox();
1343
+ const box = visualElement.measureViewportBox();
1344
+ if (!(this.scroll?.wasRoot || this.path.some(checkNodeWasScrollRoot))) {
1345
+ const { scroll } = this.root;
1346
+ if (scroll) {
1347
+ translateAxis(box.x, scroll.offset.x);
1348
+ translateAxis(box.y, scroll.offset.y);
1349
+ }
1350
+ }
1351
+ return box;
1352
+ }
1353
+ removeElementScroll(box) {
1354
+ const boxWithoutScroll = createBox();
1355
+ copyBoxInto(boxWithoutScroll, box);
1356
+ if (this.scroll?.wasRoot) return boxWithoutScroll;
1357
+ for (let i = 0; i < this.path.length; i++) {
1358
+ const node = this.path[i];
1359
+ const { scroll, options } = node;
1360
+ if (node !== this.root && scroll && options.layoutScroll) {
1361
+ if (scroll.wasRoot) copyBoxInto(boxWithoutScroll, box);
1362
+ translateAxis(boxWithoutScroll.x, scroll.offset.x);
1363
+ translateAxis(boxWithoutScroll.y, scroll.offset.y);
1364
+ }
1365
+ }
1366
+ return boxWithoutScroll;
1367
+ }
1368
+ applyTransform(box, transformOnly = false, output) {
1369
+ const withTransforms = output || createBox();
1370
+ copyBoxInto(withTransforms, box);
1371
+ for (let i = 0; i < this.path.length; i++) {
1372
+ const node = this.path[i];
1373
+ if (!transformOnly && node.options.layoutScroll && node.scroll && node !== node.root) {
1374
+ translateAxis(withTransforms.x, -node.scroll.offset.x);
1375
+ translateAxis(withTransforms.y, -node.scroll.offset.y);
1376
+ }
1377
+ if (!hasTransform(node.latestValues)) continue;
1378
+ transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
1379
+ }
1380
+ if (hasTransform(this.latestValues)) transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
1381
+ return withTransforms;
1382
+ }
1383
+ removeTransform(box) {
1384
+ const boxWithoutTransform = createBox();
1385
+ copyBoxInto(boxWithoutTransform, box);
1386
+ for (let i = 0; i < this.path.length; i++) {
1387
+ const node = this.path[i];
1388
+ if (!hasTransform(node.latestValues)) continue;
1389
+ let sourceBox;
1390
+ if (node.instance) {
1391
+ hasScale(node.latestValues) && node.updateSnapshot();
1392
+ sourceBox = createBox();
1393
+ copyBoxInto(sourceBox, node.measurePageBox());
1394
+ }
1395
+ removeBoxTransforms(boxWithoutTransform, node.latestValues, node.snapshot?.layoutBox, sourceBox);
1396
+ }
1397
+ if (hasTransform(this.latestValues)) removeBoxTransforms(boxWithoutTransform, this.latestValues);
1398
+ return boxWithoutTransform;
1399
+ }
1400
+ setTargetDelta(delta) {
1401
+ this.targetDelta = delta;
1402
+ this.root.scheduleUpdateProjection();
1403
+ this.isProjectionDirty = true;
1404
+ }
1405
+ setOptions(options) {
1406
+ this.options = {
1407
+ ...this.options,
1408
+ ...options,
1409
+ crossfade: options.crossfade !== void 0 ? options.crossfade : true
1410
+ };
1411
+ }
1412
+ clearMeasurements() {
1413
+ this.scroll = void 0;
1414
+ this.layout = void 0;
1415
+ this.snapshot = void 0;
1416
+ this.prevTransformTemplateValue = void 0;
1417
+ this.targetDelta = void 0;
1418
+ this.target = void 0;
1419
+ this.isLayoutDirty = false;
1420
+ }
1421
+ forceRelativeParentToResolveTarget() {
1422
+ if (!this.relativeParent) return;
1423
+ if (this.relativeParent.resolvedRelativeTargetAt !== frameData.timestamp) this.relativeParent.resolveTargetDelta(true);
1424
+ }
1425
+ resolveTargetDelta(forceRecalculation = false) {
1426
+ const lead = this.getLead();
1427
+ this.isProjectionDirty || (this.isProjectionDirty = lead.isProjectionDirty);
1428
+ this.isTransformDirty || (this.isTransformDirty = lead.isTransformDirty);
1429
+ this.isSharedProjectionDirty || (this.isSharedProjectionDirty = lead.isSharedProjectionDirty);
1430
+ const isShared = Boolean(this.resumingFrom) || this !== lead;
1431
+ if (!(forceRecalculation || isShared && this.isSharedProjectionDirty || this.isProjectionDirty || this.parent?.isProjectionDirty || this.attemptToResolveRelativeTarget || this.root.updateBlockedByResize)) return;
1432
+ const { layout: layout2, layoutId } = this.options;
1433
+ if (!this.layout || !(layout2 || layoutId)) return;
1434
+ this.resolvedRelativeTargetAt = frameData.timestamp;
1435
+ const relativeParent = this.getClosestProjectingParent();
1436
+ if (relativeParent && this.linkedParentVersion !== relativeParent.layoutVersion && !relativeParent.options.layoutRoot) this.removeRelativeTarget();
1437
+ if (!this.targetDelta && !this.relativeTarget) {
1438
+ if (this.options.layoutAnchor !== false && relativeParent && relativeParent.layout) this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
1439
+ else this.removeRelativeTarget();
1440
+ }
1441
+ if (!this.relativeTarget && !this.targetDelta) return;
1442
+ if (!this.target) {
1443
+ this.target = createBox();
1444
+ this.targetWithTransforms = createBox();
1445
+ }
1446
+ if (this.relativeTarget && this.relativeTargetOrigin && this.relativeParent && this.relativeParent.target) {
1447
+ this.forceRelativeParentToResolveTarget();
1448
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || void 0);
1449
+ } else if (this.targetDelta) {
1450
+ if (Boolean(this.resumingFrom)) this.applyTransform(this.layout.layoutBox, false, this.target);
1451
+ else copyBoxInto(this.target, this.layout.layoutBox);
1452
+ applyBoxDelta(this.target, this.targetDelta);
1453
+ } else
1454
+ copyBoxInto(this.target, this.layout.layoutBox);
1455
+ if (this.attemptToResolveRelativeTarget) {
1456
+ this.attemptToResolveRelativeTarget = false;
1457
+ if (this.options.layoutAnchor !== false && relativeParent && Boolean(relativeParent.resumingFrom) === Boolean(this.resumingFrom) && !relativeParent.options.layoutScroll && relativeParent.target && this.animationProgress !== 1) this.createRelativeTarget(relativeParent, this.target, relativeParent.target);
1458
+ else this.relativeParent = this.relativeTarget = void 0;
1459
+ }
1460
+ if (statsBuffer.value) metrics.calculatedTargetDeltas++;
1461
+ }
1462
+ getClosestProjectingParent() {
1463
+ if (!this.parent || hasScale(this.parent.latestValues) || has2DTranslate(this.parent.latestValues)) return;
1464
+ if (this.parent.isProjecting()) return this.parent;
1465
+ else return this.parent.getClosestProjectingParent();
1466
+ }
1467
+ isProjecting() {
1468
+ return Boolean((this.relativeTarget || this.targetDelta || this.options.layoutRoot) && this.layout);
1469
+ }
1470
+ createRelativeTarget(relativeParent, layout2, parentLayout) {
1471
+ this.relativeParent = relativeParent;
1472
+ this.linkedParentVersion = relativeParent.layoutVersion;
1473
+ this.forceRelativeParentToResolveTarget();
1474
+ this.relativeTarget = createBox();
1475
+ this.relativeTargetOrigin = createBox();
1476
+ calcRelativePosition(this.relativeTargetOrigin, layout2, parentLayout, this.options.layoutAnchor || void 0);
1477
+ copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
1478
+ }
1479
+ removeRelativeTarget() {
1480
+ this.relativeParent = this.relativeTarget = void 0;
1481
+ }
1482
+ calcProjection() {
1483
+ const lead = this.getLead();
1484
+ const isShared = Boolean(this.resumingFrom) || this !== lead;
1485
+ let canSkip = true;
1486
+ if (this.isProjectionDirty || this.parent?.isProjectionDirty) canSkip = false;
1487
+ if (isShared && (this.isSharedProjectionDirty || this.isTransformDirty)) canSkip = false;
1488
+ if (this.resolvedRelativeTargetAt === frameData.timestamp) canSkip = false;
1489
+ if (canSkip) return;
1490
+ const { layout: layout2, layoutId } = this.options;
1491
+ this.isTreeAnimating = Boolean(this.parent && this.parent.isTreeAnimating || this.currentAnimation || this.pendingAnimation);
1492
+ if (!this.isTreeAnimating) this.targetDelta = this.relativeTarget = void 0;
1493
+ if (!this.layout || !(layout2 || layoutId)) return;
1494
+ copyBoxInto(this.layoutCorrected, this.layout.layoutBox);
1495
+ const prevTreeScaleX = this.treeScale.x;
1496
+ const prevTreeScaleY = this.treeScale.y;
1497
+ applyTreeDeltas(this.layoutCorrected, this.treeScale, this.path, isShared);
1498
+ if (lead.layout && !lead.target && (this.treeScale.x !== 1 || this.treeScale.y !== 1)) {
1499
+ lead.target = lead.layout.layoutBox;
1500
+ lead.targetWithTransforms = createBox();
1501
+ }
1502
+ const { target } = lead;
1503
+ if (!target) {
1504
+ if (this.prevProjectionDelta) {
1505
+ this.createProjectionDeltas();
1506
+ this.scheduleRender();
1507
+ }
1508
+ return;
1509
+ }
1510
+ if (!this.projectionDelta || !this.prevProjectionDelta) this.createProjectionDeltas();
1511
+ else {
1512
+ copyAxisDeltaInto(this.prevProjectionDelta.x, this.projectionDelta.x);
1513
+ copyAxisDeltaInto(this.prevProjectionDelta.y, this.projectionDelta.y);
1514
+ }
1515
+ calcBoxDelta(this.projectionDelta, this.layoutCorrected, target, this.latestValues);
1516
+ if (this.treeScale.x !== prevTreeScaleX || this.treeScale.y !== prevTreeScaleY || !axisDeltaEquals(this.projectionDelta.x, this.prevProjectionDelta.x) || !axisDeltaEquals(this.projectionDelta.y, this.prevProjectionDelta.y)) {
1517
+ this.hasProjected = true;
1518
+ this.scheduleRender();
1519
+ this.notifyListeners("projectionUpdate", target);
1520
+ }
1521
+ if (statsBuffer.value) metrics.calculatedProjections++;
1522
+ }
1523
+ hide() {
1524
+ this.isVisible = false;
1525
+ }
1526
+ show() {
1527
+ this.isVisible = true;
1528
+ }
1529
+ scheduleRender(notifyAll2 = true) {
1530
+ this.options.visualElement?.scheduleRender();
1531
+ if (notifyAll2) {
1532
+ const stack = this.getStack();
1533
+ stack && stack.scheduleRender();
1534
+ }
1535
+ if (this.resumingFrom && !this.resumingFrom.instance) this.resumingFrom = void 0;
1536
+ }
1537
+ createProjectionDeltas() {
1538
+ this.prevProjectionDelta = createDelta();
1539
+ this.projectionDelta = createDelta();
1540
+ this.projectionDeltaWithTransform = createDelta();
1541
+ }
1542
+ setAnimationOrigin(delta, hasOnlyRelativeTargetChanged = false, pathFn) {
1543
+ const snapshot2 = this.snapshot;
1544
+ const snapshotLatestValues = snapshot2 ? snapshot2.latestValues : {};
1545
+ const mixedValues = { ...this.latestValues };
1546
+ const targetDelta = createDelta();
1547
+ if (!this.relativeParent || !this.relativeParent.options.layoutRoot) this.relativeTarget = this.relativeTargetOrigin = void 0;
1548
+ this.attemptToResolveRelativeTarget = !hasOnlyRelativeTargetChanged;
1549
+ const relativeLayout = createBox();
1550
+ const isSharedLayoutAnimation = (snapshot2 ? snapshot2.source : void 0) !== (this.layout ? this.layout.source : void 0);
1551
+ const stack = this.getStack();
1552
+ const isOnlyMember = !stack || stack.members.length <= 1;
1553
+ const shouldCrossfadeOpacity = Boolean(isSharedLayoutAnimation && !isOnlyMember && this.options.crossfade === true && !this.path.some(hasOpacityCrossfade));
1554
+ this.animationProgress = 0;
1555
+ let prevRelativeTarget;
1556
+ const interpolate = pathFn?.interpolateProjection(delta);
1557
+ this.mixTargetDelta = (latest) => {
1558
+ const progress2 = latest / 1e3;
1559
+ const point = interpolate?.(progress2);
1560
+ if (point) {
1561
+ targetDelta.x.translate = point.x;
1562
+ targetDelta.x.scale = mixNumber(delta.x.scale, 1, progress2);
1563
+ targetDelta.x.origin = delta.x.origin;
1564
+ targetDelta.x.originPoint = delta.x.originPoint;
1565
+ targetDelta.y.translate = point.y;
1566
+ targetDelta.y.scale = mixNumber(delta.y.scale, 1, progress2);
1567
+ targetDelta.y.origin = delta.y.origin;
1568
+ targetDelta.y.originPoint = delta.y.originPoint;
1569
+ } else {
1570
+ mixAxisDeltaLinear(targetDelta.x, delta.x, progress2);
1571
+ mixAxisDeltaLinear(targetDelta.y, delta.y, progress2);
1572
+ }
1573
+ this.setTargetDelta(targetDelta);
1574
+ if (this.relativeTarget && this.relativeTargetOrigin && this.layout && this.relativeParent && this.relativeParent.layout) {
1575
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || void 0);
1576
+ mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress2);
1577
+ if (prevRelativeTarget && boxEquals(this.relativeTarget, prevRelativeTarget)) this.isProjectionDirty = false;
1578
+ if (!prevRelativeTarget) prevRelativeTarget = createBox();
1579
+ copyBoxInto(prevRelativeTarget, this.relativeTarget);
1580
+ }
1581
+ if (isSharedLayoutAnimation) {
1582
+ this.animationValues = mixedValues;
1583
+ mixValues(mixedValues, snapshotLatestValues, this.latestValues, progress2, shouldCrossfadeOpacity, isOnlyMember);
1584
+ }
1585
+ if (point && point.rotate !== void 0) {
1586
+ if (!this.animationValues) this.animationValues = mixedValues;
1587
+ this.animationValues.pathRotation = point.rotate;
1588
+ }
1589
+ this.root.scheduleUpdateProjection();
1590
+ this.scheduleRender();
1591
+ this.animationProgress = progress2;
1592
+ };
1593
+ this.mixTargetDelta(this.options.layoutRoot ? 1e3 : 0);
1594
+ }
1595
+ startAnimation(options) {
1596
+ this.notifyListeners("animationStart");
1597
+ this.currentAnimation?.stop();
1598
+ this.resumingFrom?.currentAnimation?.stop();
1599
+ if (this.pendingAnimation) {
1600
+ cancelFrame(this.pendingAnimation);
1601
+ this.pendingAnimation = void 0;
1602
+ }
1603
+ this.pendingAnimation = frame.update(() => {
1604
+ globalProjectionState.hasAnimatedSinceResize = true;
1605
+ this.motionValue || (this.motionValue = motionValue(0));
1606
+ this.motionValue.jump(0, false);
1607
+ this.currentAnimation = animateSingleValue(this.motionValue, [0, 1e3], {
1608
+ ...options,
1609
+ velocity: 0,
1610
+ isSync: true,
1611
+ onUpdate: (latest) => {
1612
+ this.mixTargetDelta(latest);
1613
+ options.onUpdate && options.onUpdate(latest);
1614
+ },
1615
+ onComplete: () => {
1616
+ options.onComplete && options.onComplete();
1617
+ this.completeAnimation();
1618
+ }
1619
+ });
1620
+ if (this.resumingFrom) this.resumingFrom.currentAnimation = this.currentAnimation;
1621
+ this.pendingAnimation = void 0;
1622
+ });
1623
+ }
1624
+ completeAnimation() {
1625
+ if (this.resumingFrom) {
1626
+ this.resumingFrom.currentAnimation = void 0;
1627
+ this.resumingFrom.preserveOpacity = void 0;
1628
+ }
1629
+ const stack = this.getStack();
1630
+ stack && stack.exitAnimationComplete();
1631
+ this.resumingFrom = this.currentAnimation = this.animationValues = void 0;
1632
+ this.notifyListeners("animationComplete");
1633
+ }
1634
+ finishAnimation() {
1635
+ if (this.currentAnimation) {
1636
+ this.mixTargetDelta && this.mixTargetDelta(animationTarget);
1637
+ this.currentAnimation.stop();
1638
+ }
1639
+ this.completeAnimation();
1640
+ }
1641
+ applyTransformsToTarget() {
1642
+ const lead = this.getLead();
1643
+ let { targetWithTransforms, target, layout: layout2, latestValues } = lead;
1644
+ if (!targetWithTransforms || !target || !layout2) return;
1645
+ if (this !== lead && this.layout && layout2 && shouldAnimatePositionOnly(this.options.animationType, this.layout.layoutBox, layout2.layoutBox)) {
1646
+ target = this.target || createBox();
1647
+ const xLength = calcLength(this.layout.layoutBox.x);
1648
+ target.x.min = lead.target.x.min;
1649
+ target.x.max = target.x.min + xLength;
1650
+ const yLength = calcLength(this.layout.layoutBox.y);
1651
+ target.y.min = lead.target.y.min;
1652
+ target.y.max = target.y.min + yLength;
1653
+ }
1654
+ copyBoxInto(targetWithTransforms, target);
1655
+ transformBox(targetWithTransforms, latestValues);
1656
+ calcBoxDelta(this.projectionDeltaWithTransform, this.layoutCorrected, targetWithTransforms, latestValues);
1657
+ }
1658
+ registerSharedNode(layoutId, node) {
1659
+ if (!this.sharedNodes.has(layoutId)) this.sharedNodes.set(layoutId, new NodeStack());
1660
+ this.sharedNodes.get(layoutId).add(node);
1661
+ const config = node.options.initialPromotionConfig;
1662
+ node.promote({
1663
+ transition: config ? config.transition : void 0,
1664
+ preserveFollowOpacity: config && config.shouldPreserveFollowOpacity ? config.shouldPreserveFollowOpacity(node) : void 0
1665
+ });
1666
+ }
1667
+ isLead() {
1668
+ const stack = this.getStack();
1669
+ return stack ? stack.lead === this : true;
1670
+ }
1671
+ getLead() {
1672
+ const { layoutId } = this.options;
1673
+ return layoutId ? this.getStack()?.lead || this : this;
1674
+ }
1675
+ getPrevLead() {
1676
+ const { layoutId } = this.options;
1677
+ return layoutId ? this.getStack()?.prevLead : void 0;
1678
+ }
1679
+ getStack() {
1680
+ const { layoutId } = this.options;
1681
+ if (layoutId) return this.root.sharedNodes.get(layoutId);
1682
+ }
1683
+ promote({ needsReset, transition, preserveFollowOpacity } = {}) {
1684
+ const stack = this.getStack();
1685
+ if (stack) stack.promote(this, preserveFollowOpacity);
1686
+ if (needsReset) {
1687
+ this.projectionDelta = void 0;
1688
+ this.needsReset = true;
1689
+ }
1690
+ if (transition) this.setOptions({ transition });
1691
+ }
1692
+ relegate() {
1693
+ const stack = this.getStack();
1694
+ if (stack) return stack.relegate(this);
1695
+ else return false;
1696
+ }
1697
+ resetSkewAndRotation() {
1698
+ const { visualElement } = this.options;
1699
+ if (!visualElement) return;
1700
+ let hasDistortingTransform = false;
1701
+ const { latestValues } = visualElement;
1702
+ if (latestValues.z || latestValues.rotate || latestValues.rotateX || latestValues.rotateY || latestValues.rotateZ || latestValues.skewX || latestValues.skewY) hasDistortingTransform = true;
1703
+ if (!hasDistortingTransform) return;
1704
+ const resetValues = {};
1705
+ if (latestValues.z) resetDistortingTransform("z", visualElement, resetValues, this.animationValues);
1706
+ for (let i = 0; i < transformAxes.length; i++) {
1707
+ resetDistortingTransform(`rotate${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
1708
+ resetDistortingTransform(`skew${transformAxes[i]}`, visualElement, resetValues, this.animationValues);
1709
+ }
1710
+ visualElement.render();
1711
+ for (const key in resetValues) {
1712
+ visualElement.setStaticValue(key, resetValues[key]);
1713
+ if (this.animationValues) this.animationValues[key] = resetValues[key];
1714
+ }
1715
+ visualElement.scheduleRender();
1716
+ }
1717
+ applyProjectionStyles(targetStyle, styleProp) {
1718
+ if (!this.instance || this.isSVG) return;
1719
+ if (!this.isVisible) {
1720
+ targetStyle.visibility = "hidden";
1721
+ return;
1722
+ }
1723
+ const transformTemplate = this.getTransformTemplate();
1724
+ if (this.needsReset) {
1725
+ this.needsReset = false;
1726
+ targetStyle.visibility = "";
1727
+ targetStyle.opacity = "";
1728
+ targetStyle.pointerEvents = resolveMotionValue(styleProp?.pointerEvents) || "";
1729
+ targetStyle.transform = transformTemplate ? transformTemplate(this.latestValues, "") : "none";
1730
+ return;
1731
+ }
1732
+ const lead = this.getLead();
1733
+ if (!this.projectionDelta || !this.layout || !lead.target) {
1734
+ if (this.options.layoutId) {
1735
+ targetStyle.opacity = this.latestValues.opacity !== void 0 ? this.latestValues.opacity : 1;
1736
+ targetStyle.pointerEvents = resolveMotionValue(styleProp?.pointerEvents) || "";
1737
+ }
1738
+ if (this.hasProjected && !hasTransform(this.latestValues)) {
1739
+ targetStyle.transform = transformTemplate ? transformTemplate({}, "") : "none";
1740
+ this.hasProjected = false;
1741
+ }
1742
+ return;
1743
+ }
1744
+ targetStyle.visibility = "";
1745
+ const valuesToRender = lead.animationValues || lead.latestValues;
1746
+ this.applyTransformsToTarget();
1747
+ let transform = buildProjectionTransform(this.projectionDeltaWithTransform, this.treeScale, valuesToRender);
1748
+ if (transformTemplate) transform = transformTemplate(valuesToRender, transform);
1749
+ targetStyle.transform = transform;
1750
+ const { x, y } = this.projectionDelta;
1751
+ targetStyle.transformOrigin = `${x.origin * 100}% ${y.origin * 100}% 0`;
1752
+ if (lead.animationValues)
1753
+ targetStyle.opacity = lead === this ? valuesToRender.opacity ?? this.latestValues.opacity ?? 1 : this.preserveOpacity ? this.latestValues.opacity : valuesToRender.opacityExit;
1754
+ else
1755
+ targetStyle.opacity = lead === this ? valuesToRender.opacity !== void 0 ? valuesToRender.opacity : "" : valuesToRender.opacityExit !== void 0 ? valuesToRender.opacityExit : 0;
1756
+ for (const key in scaleCorrectors) {
1757
+ if (valuesToRender[key] === void 0) continue;
1758
+ const { correct, applyTo, isCSSVariable } = scaleCorrectors[key];
1759
+ const corrected = transform === "none" ? valuesToRender[key] : correct(valuesToRender[key], lead);
1760
+ if (applyTo) {
1761
+ const num = applyTo.length;
1762
+ for (let i = 0; i < num; i++) targetStyle[applyTo[i]] = corrected;
1763
+ } else if (isCSSVariable) this.options.visualElement.renderState.vars[key] = corrected;
1764
+ else targetStyle[key] = corrected;
1765
+ }
1766
+ if (this.options.layoutId) targetStyle.pointerEvents = lead === this ? resolveMotionValue(styleProp?.pointerEvents) || "" : "none";
1767
+ }
1768
+ clearSnapshot() {
1769
+ this.resumeFrom = this.snapshot = void 0;
1770
+ }
1771
+ resetTree() {
1772
+ this.root.nodes.forEach((node) => node.currentAnimation?.stop());
1773
+ this.root.nodes.forEach(clearMeasurements);
1774
+ this.root.sharedNodes.clear();
1775
+ }
1776
+ };
1777
+ }
1778
+ function updateLayout(node) {
1779
+ node.updateLayout();
1780
+ }
1781
+ function notifyLayoutUpdate(node) {
1782
+ const snapshot2 = node.resumeFrom?.snapshot || node.snapshot;
1783
+ if (node.isLead() && node.layout && snapshot2 && node.hasListeners("didUpdate")) {
1784
+ const { layoutBox: layout2, measuredBox: measuredLayout } = node.layout;
1785
+ const { animationType } = node.options;
1786
+ const isShared = snapshot2.source !== node.layout.source;
1787
+ if (animationType === "size") eachAxis((axis) => {
1788
+ const axisSnapshot = isShared ? snapshot2.measuredBox[axis] : snapshot2.layoutBox[axis];
1789
+ const length = calcLength(axisSnapshot);
1790
+ axisSnapshot.min = layout2[axis].min;
1791
+ axisSnapshot.max = axisSnapshot.min + length;
1792
+ });
1793
+ else if (animationType === "x" || animationType === "y") {
1794
+ const snapAxis = animationType === "x" ? "y" : "x";
1795
+ copyAxisInto(isShared ? snapshot2.measuredBox[snapAxis] : snapshot2.layoutBox[snapAxis], layout2[snapAxis]);
1796
+ } else if (shouldAnimatePositionOnly(animationType, snapshot2.layoutBox, layout2)) eachAxis((axis) => {
1797
+ const axisSnapshot = isShared ? snapshot2.measuredBox[axis] : snapshot2.layoutBox[axis];
1798
+ const length = calcLength(layout2[axis]);
1799
+ axisSnapshot.max = axisSnapshot.min + length;
1800
+ if (node.relativeTarget && !node.currentAnimation) {
1801
+ node.isProjectionDirty = true;
1802
+ node.relativeTarget[axis].max = node.relativeTarget[axis].min + length;
1803
+ }
1804
+ });
1805
+ const layoutDelta = createDelta();
1806
+ calcBoxDelta(layoutDelta, layout2, snapshot2.layoutBox);
1807
+ const visualDelta = createDelta();
1808
+ if (isShared) calcBoxDelta(visualDelta, node.applyTransform(measuredLayout, true), snapshot2.measuredBox);
1809
+ else calcBoxDelta(visualDelta, layout2, snapshot2.layoutBox);
1810
+ const hasLayoutChanged = !isDeltaZero(layoutDelta);
1811
+ let hasRelativeLayoutChanged = false;
1812
+ if (!node.resumeFrom) {
1813
+ const relativeParent = node.getClosestProjectingParent();
1814
+ if (relativeParent && !relativeParent.resumeFrom) {
1815
+ const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
1816
+ if (parentSnapshot && parentLayout) {
1817
+ const anchor = node.options.layoutAnchor || void 0;
1818
+ const relativeSnapshot = createBox();
1819
+ calcRelativePosition(relativeSnapshot, snapshot2.layoutBox, parentSnapshot.layoutBox, anchor);
1820
+ const relativeLayout = createBox();
1821
+ calcRelativePosition(relativeLayout, layout2, parentLayout.layoutBox, anchor);
1822
+ if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) hasRelativeLayoutChanged = true;
1823
+ if (relativeParent.options.layoutRoot) {
1824
+ node.relativeTarget = relativeLayout;
1825
+ node.relativeTargetOrigin = relativeSnapshot;
1826
+ node.relativeParent = relativeParent;
1827
+ }
1828
+ }
1829
+ }
1830
+ }
1831
+ node.notifyListeners("didUpdate", {
1832
+ layout: layout2,
1833
+ snapshot: snapshot2,
1834
+ delta: visualDelta,
1835
+ layoutDelta,
1836
+ hasLayoutChanged,
1837
+ hasRelativeLayoutChanged
1838
+ });
1839
+ } else if (node.isLead()) {
1840
+ const { onExitComplete } = node.options;
1841
+ onExitComplete && onExitComplete();
1842
+ }
1843
+ node.options.transition = void 0;
1844
+ }
1845
+ function propagateDirtyNodes(node) {
1846
+ if (statsBuffer.value) metrics.nodes++;
1847
+ if (!node.parent) return;
1848
+ if (!node.isProjecting()) node.isProjectionDirty = node.parent.isProjectionDirty;
1849
+ node.isSharedProjectionDirty || (node.isSharedProjectionDirty = Boolean(node.isProjectionDirty || node.parent.isProjectionDirty || node.parent.isSharedProjectionDirty));
1850
+ node.isTransformDirty || (node.isTransformDirty = node.parent.isTransformDirty);
1851
+ }
1852
+ function cleanDirtyNodes(node) {
1853
+ node.isProjectionDirty = node.isSharedProjectionDirty = node.isTransformDirty = false;
1854
+ }
1855
+ function clearSnapshot(node) {
1856
+ node.clearSnapshot();
1857
+ }
1858
+ function clearMeasurements(node) {
1859
+ node.clearMeasurements();
1860
+ }
1861
+ function forceLayoutMeasure(node) {
1862
+ node.isLayoutDirty = true;
1863
+ node.updateLayout();
1864
+ }
1865
+ function clearIsLayoutDirty(node) {
1866
+ node.isLayoutDirty = false;
1867
+ }
1868
+ function ensureDraggedNodesSnapshotted(node) {
1869
+ if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
1870
+ node.snapshot = node.layout;
1871
+ node.isLayoutDirty = true;
1872
+ }
1873
+ }
1874
+ function resetTransformStyle(node) {
1875
+ const { visualElement } = node.options;
1876
+ if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) visualElement.notify("BeforeLayoutMeasure");
1877
+ node.resetTransform();
1878
+ }
1879
+ function finishAnimation(node) {
1880
+ node.finishAnimation();
1881
+ node.targetDelta = node.relativeTarget = node.target = void 0;
1882
+ node.isProjectionDirty = true;
1883
+ }
1884
+ function resolveTargetDelta(node) {
1885
+ node.resolveTargetDelta();
1886
+ }
1887
+ function calcProjection(node) {
1888
+ node.calcProjection();
1889
+ }
1890
+ function resetSkewAndRotation(node) {
1891
+ node.resetSkewAndRotation();
1892
+ }
1893
+ function removeLeadSnapshots(stack) {
1894
+ stack.removeLeadSnapshot();
1895
+ }
1896
+ function mixAxisDeltaLinear(output, delta, p) {
1897
+ output.translate = mixNumber(delta.translate, 0, p);
1898
+ output.scale = mixNumber(delta.scale, 1, p);
1899
+ output.origin = delta.origin;
1900
+ output.originPoint = delta.originPoint;
1901
+ }
1902
+ function mixAxis(output, from, to, p) {
1903
+ output.min = mixNumber(from.min, to.min, p);
1904
+ output.max = mixNumber(from.max, to.max, p);
1905
+ }
1906
+ function mixBox(output, from, to, p) {
1907
+ mixAxis(output.x, from.x, to.x, p);
1908
+ mixAxis(output.y, from.y, to.y, p);
1909
+ }
1910
+ function hasOpacityCrossfade(node) {
1911
+ return node.animationValues && node.animationValues.opacityExit !== void 0;
1912
+ }
1913
+ var defaultLayoutTransition = {
1914
+ duration: 0.45,
1915
+ ease: [
1916
+ 0.4,
1917
+ 0,
1918
+ 0.1,
1919
+ 1
1920
+ ]
1921
+ };
1922
+ var userAgentContains = (string) => typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().includes(string);
1923
+ var roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/") ? Math.round : noop;
1924
+ function roundAxis(axis) {
1925
+ axis.min = roundPoint(axis.min);
1926
+ axis.max = roundPoint(axis.max);
1927
+ }
1928
+ function roundBox(box) {
1929
+ roundAxis(box.x);
1930
+ roundAxis(box.y);
1931
+ }
1932
+ function shouldAnimatePositionOnly(animationType, snapshot2, layout2) {
1933
+ return animationType === "position" || animationType === "preserve-aspect" && !isNear(aspectRatio(snapshot2), aspectRatio(layout2), 0.2);
1934
+ }
1935
+ function checkNodeWasScrollRoot(node) {
1936
+ return node !== node.root && node.scroll?.wasRoot;
1937
+ }
1938
+ var DocumentProjectionNode = createProjectionNode({
1939
+ attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
1940
+ measureScroll: () => ({
1941
+ x: document.documentElement.scrollLeft || document.body?.scrollLeft || 0,
1942
+ y: document.documentElement.scrollTop || document.body?.scrollTop || 0
1943
+ }),
1944
+ checkIsScrollRoot: () => true
1945
+ });
1946
+ var rootProjectionNode = { current: void 0 };
1947
+ var HTMLProjectionNode = createProjectionNode({
1948
+ measureScroll: (instance) => ({
1949
+ x: instance.scrollLeft,
1950
+ y: instance.scrollTop
1951
+ }),
1952
+ defaultParent: () => {
1953
+ if (!rootProjectionNode.current) {
1954
+ const documentNode = new DocumentProjectionNode({});
1955
+ documentNode.mount(window);
1956
+ documentNode.setOptions({ layoutScroll: true });
1957
+ rootProjectionNode.current = documentNode;
1958
+ }
1959
+ return rootProjectionNode.current;
1960
+ },
1961
+ resetTransform: (instance, value) => {
1962
+ instance.style.transform = value !== void 0 ? value : "none";
1963
+ },
1964
+ checkIsScrollRoot: (instance) => Boolean(window.getComputedStyle(instance).position === "fixed")
1965
+ });
1966
+ function LazyMotion({ children, features, strict = false }) {
1967
+ const [, setIsLoaded] = useState(!isLazyBundle(features));
1968
+ const loadedRenderer = useRef(void 0);
1969
+ if (!isLazyBundle(features)) {
1970
+ const { renderer, ...loadedFeatures } = features;
1971
+ loadedRenderer.current = renderer;
1972
+ loadFeatures(loadedFeatures);
1973
+ }
1974
+ useEffect(() => {
1975
+ if (isLazyBundle(features)) features().then(({ renderer, ...loadedFeatures }) => {
1976
+ loadFeatures(loadedFeatures);
1977
+ loadedRenderer.current = renderer;
1978
+ setIsLoaded(true);
1979
+ });
1980
+ }, []);
1981
+ return jsx(LazyContext.Provider, {
1982
+ value: {
1983
+ renderer: loadedRenderer.current,
1984
+ strict
1985
+ },
1986
+ children
1987
+ });
1988
+ }
1989
+ function isLazyBundle(features) {
1990
+ return typeof features === "function";
1991
+ }
1992
+ var createDomVisualElement = (Component2, options) => {
1993
+ return options.isSVG ?? isSVGComponent(Component2) ? new SVGVisualElement(options) : new HTMLVisualElement(options, { allowProjection: Component2 !== Fragment });
1994
+ };
1995
+ var AnimationFeature = class extends Feature {
1996
+ /**
1997
+ * We dynamically generate the AnimationState manager as it contains a reference
1998
+ * to the underlying animation library. We only want to load that if we load this,
1999
+ * so people can optionally code split it out using the `m` component.
2000
+ */
2001
+ constructor(node) {
2002
+ super(node);
2003
+ node.animationState || (node.animationState = createAnimationState(node));
2004
+ }
2005
+ updateAnimationControlsSubscription() {
2006
+ const { animate } = this.node.getProps();
2007
+ if (isAnimationControls(animate)) this.unmountControls = animate.subscribe(this.node);
2008
+ }
2009
+ /**
2010
+ * Subscribe any provided AnimationControls to the component's VisualElement
2011
+ */
2012
+ mount() {
2013
+ this.updateAnimationControlsSubscription();
2014
+ }
2015
+ update() {
2016
+ const { animate } = this.node.getProps();
2017
+ const { animate: prevAnimate } = this.node.prevProps || {};
2018
+ if (animate !== prevAnimate) this.updateAnimationControlsSubscription();
2019
+ }
2020
+ unmount() {
2021
+ this.node.animationState.reset();
2022
+ this.unmountControls?.();
2023
+ }
2024
+ };
2025
+ var id = 0;
2026
+ var ExitAnimationFeature = class extends Feature {
2027
+ constructor() {
2028
+ super(...arguments);
2029
+ this.id = id++;
2030
+ this.isExitComplete = false;
2031
+ }
2032
+ update() {
2033
+ if (!this.node.presenceContext) return;
2034
+ const { isPresent, onExitComplete } = this.node.presenceContext;
2035
+ const { isPresent: prevIsPresent } = this.node.prevPresenceContext || {};
2036
+ if (!this.node.animationState || isPresent === prevIsPresent) return;
2037
+ if (isPresent && prevIsPresent === false) {
2038
+ if (this.isExitComplete) {
2039
+ const { initial, custom } = this.node.getProps();
2040
+ if (typeof initial === "string" || typeof initial === "object" && initial !== null && !Array.isArray(initial)) {
2041
+ const resolved = resolveVariant(this.node, initial, custom);
2042
+ if (resolved) {
2043
+ const { transition, transitionEnd, ...target } = resolved;
2044
+ for (const key in target) this.node.getValue(key)?.jump(target[key]);
2045
+ }
2046
+ }
2047
+ this.node.animationState.reset();
2048
+ this.node.animationState.animateChanges();
2049
+ } else this.node.animationState.setActive("exit", false);
2050
+ this.isExitComplete = false;
2051
+ return;
2052
+ }
2053
+ const exitAnimation = this.node.animationState.setActive("exit", !isPresent);
2054
+ if (onExitComplete && !isPresent) exitAnimation.then(() => {
2055
+ this.isExitComplete = true;
2056
+ onExitComplete(this.id);
2057
+ });
2058
+ }
2059
+ mount() {
2060
+ const { register, onExitComplete } = this.node.presenceContext || {};
2061
+ if (onExitComplete) onExitComplete(this.id);
2062
+ if (register) this.unmount = register(this.id);
2063
+ }
2064
+ unmount() {
2065
+ }
2066
+ };
2067
+ var animations = {
2068
+ animation: { Feature: AnimationFeature },
2069
+ exit: { Feature: ExitAnimationFeature }
2070
+ };
2071
+ function extractEventInfo(event) {
2072
+ return { point: {
2073
+ x: event.pageX,
2074
+ y: event.pageY
2075
+ } };
2076
+ }
2077
+ var addPointerInfo = (handler) => (event) => isPrimaryPointer(event) && handler(event, extractEventInfo(event));
2078
+ function addPointerEvent(target, eventName, handler, options) {
2079
+ return addDomEvent(target, eventName, addPointerInfo(handler), options);
2080
+ }
2081
+ var getContextWindow = ({ current }) => {
2082
+ return current ? current.ownerDocument.defaultView : null;
2083
+ };
2084
+ var distance = (a, b) => Math.abs(a - b);
2085
+ function distance2D(a, b) {
2086
+ const xDelta = distance(a.x, b.x);
2087
+ const yDelta = distance(a.y, b.y);
2088
+ return Math.sqrt(xDelta ** 2 + yDelta ** 2);
2089
+ }
2090
+ var overflowStyles = /* @__PURE__ */ new Set(["auto", "scroll"]);
2091
+ var PanSession = class {
2092
+ constructor(event, handlers, { transformPagePoint, contextWindow = window, dragSnapToOrigin = false, distanceThreshold = 3, element } = {}) {
2093
+ this.startEvent = null;
2094
+ this.lastMoveEvent = null;
2095
+ this.lastMoveEventInfo = null;
2096
+ this.lastRawMoveEventInfo = null;
2097
+ this.handlers = {};
2098
+ this.contextWindow = window;
2099
+ this.scrollPositions = /* @__PURE__ */ new Map();
2100
+ this.removeScrollListeners = null;
2101
+ this.onElementScroll = (event2) => {
2102
+ this.handleScroll(event2.target);
2103
+ };
2104
+ this.onWindowScroll = () => {
2105
+ this.handleScroll(window);
2106
+ };
2107
+ this.updatePoint = () => {
2108
+ if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return;
2109
+ if (this.lastRawMoveEventInfo) this.lastMoveEventInfo = transformPoint(this.lastRawMoveEventInfo, this.transformPagePoint);
2110
+ const info = getPanInfo(this.lastMoveEventInfo, this.history);
2111
+ const isPanStarted = this.startEvent !== null;
2112
+ const isDistancePastThreshold = distance2D(info.offset, {
2113
+ x: 0,
2114
+ y: 0
2115
+ }) >= this.distanceThreshold;
2116
+ if (!isPanStarted && !isDistancePastThreshold) return;
2117
+ const { point: point2 } = info;
2118
+ const { timestamp: timestamp2 } = frameData;
2119
+ this.history.push({
2120
+ ...point2,
2121
+ timestamp: timestamp2
2122
+ });
2123
+ const { onStart, onMove } = this.handlers;
2124
+ if (!isPanStarted) {
2125
+ onStart && onStart(this.lastMoveEvent, info);
2126
+ this.startEvent = this.lastMoveEvent;
2127
+ }
2128
+ onMove && onMove(this.lastMoveEvent, info);
2129
+ };
2130
+ this.handlePointerMove = (event2, info) => {
2131
+ this.lastMoveEvent = event2;
2132
+ this.lastRawMoveEventInfo = info;
2133
+ this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint);
2134
+ frame.update(this.updatePoint, true);
2135
+ };
2136
+ this.handlePointerUp = (event2, info) => {
2137
+ this.end();
2138
+ const { onEnd, onSessionEnd, resumeAnimation } = this.handlers;
2139
+ if (this.dragSnapToOrigin || !this.startEvent) resumeAnimation && resumeAnimation();
2140
+ if (!(this.lastMoveEvent && this.lastMoveEventInfo)) return;
2141
+ const panInfo = getPanInfo(event2.type === "pointercancel" ? this.lastMoveEventInfo : transformPoint(info, this.transformPagePoint), this.history);
2142
+ if (this.startEvent && onEnd) onEnd(event2, panInfo);
2143
+ onSessionEnd && onSessionEnd(event2, panInfo);
2144
+ };
2145
+ if (!isPrimaryPointer(event)) return;
2146
+ this.dragSnapToOrigin = dragSnapToOrigin;
2147
+ this.handlers = handlers;
2148
+ this.transformPagePoint = transformPagePoint;
2149
+ this.distanceThreshold = distanceThreshold;
2150
+ this.contextWindow = contextWindow || window;
2151
+ const initialInfo = transformPoint(extractEventInfo(event), this.transformPagePoint);
2152
+ const { point } = initialInfo;
2153
+ const { timestamp } = frameData;
2154
+ this.history = [{
2155
+ ...point,
2156
+ timestamp
2157
+ }];
2158
+ const { onSessionStart } = handlers;
2159
+ onSessionStart && onSessionStart(event, getPanInfo(initialInfo, this.history));
2160
+ const eventOptions = {
2161
+ passive: true,
2162
+ capture: true
2163
+ };
2164
+ this.removeListeners = pipe(addPointerEvent(this.contextWindow, "pointermove", this.handlePointerMove, eventOptions), addPointerEvent(this.contextWindow, "pointerup", this.handlePointerUp, eventOptions), addPointerEvent(this.contextWindow, "pointercancel", this.handlePointerUp, eventOptions));
2165
+ if (element) this.startScrollTracking(element);
2166
+ }
2167
+ /**
2168
+ * Start tracking scroll on ancestors and window.
2169
+ */
2170
+ startScrollTracking(element) {
2171
+ let current = element.parentElement;
2172
+ while (current) {
2173
+ const style = getComputedStyle(current);
2174
+ if (overflowStyles.has(style.overflowX) || overflowStyles.has(style.overflowY)) this.scrollPositions.set(current, {
2175
+ x: current.scrollLeft,
2176
+ y: current.scrollTop
2177
+ });
2178
+ current = current.parentElement;
2179
+ }
2180
+ this.scrollPositions.set(window, {
2181
+ x: window.scrollX,
2182
+ y: window.scrollY
2183
+ });
2184
+ window.addEventListener("scroll", this.onElementScroll, { capture: true });
2185
+ window.addEventListener("scroll", this.onWindowScroll);
2186
+ this.removeScrollListeners = () => {
2187
+ window.removeEventListener("scroll", this.onElementScroll, { capture: true });
2188
+ window.removeEventListener("scroll", this.onWindowScroll);
2189
+ };
2190
+ }
2191
+ /**
2192
+ * Handle scroll compensation during drag.
2193
+ *
2194
+ * For element scroll: adjusts history origin since pageX/pageY doesn't change.
2195
+ * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.
2196
+ */
2197
+ handleScroll(target) {
2198
+ const initial = this.scrollPositions.get(target);
2199
+ if (!initial) return;
2200
+ const isWindow = target === window;
2201
+ const current = isWindow ? {
2202
+ x: window.scrollX,
2203
+ y: window.scrollY
2204
+ } : {
2205
+ x: target.scrollLeft,
2206
+ y: target.scrollTop
2207
+ };
2208
+ const delta = {
2209
+ x: current.x - initial.x,
2210
+ y: current.y - initial.y
2211
+ };
2212
+ if (delta.x === 0 && delta.y === 0) return;
2213
+ if (isWindow) {
2214
+ if (this.lastMoveEventInfo) {
2215
+ this.lastMoveEventInfo.point.x += delta.x;
2216
+ this.lastMoveEventInfo.point.y += delta.y;
2217
+ }
2218
+ } else if (this.history.length > 0) {
2219
+ this.history[0].x -= delta.x;
2220
+ this.history[0].y -= delta.y;
2221
+ }
2222
+ this.scrollPositions.set(target, current);
2223
+ frame.update(this.updatePoint, true);
2224
+ }
2225
+ updateHandlers(handlers) {
2226
+ this.handlers = handlers;
2227
+ }
2228
+ end() {
2229
+ this.removeListeners && this.removeListeners();
2230
+ this.removeScrollListeners && this.removeScrollListeners();
2231
+ this.scrollPositions.clear();
2232
+ cancelFrame(this.updatePoint);
2233
+ }
2234
+ };
2235
+ function transformPoint(info, transformPagePoint) {
2236
+ return transformPagePoint ? { point: transformPagePoint(info.point) } : info;
2237
+ }
2238
+ function subtractPoint(a, b) {
2239
+ return {
2240
+ x: a.x - b.x,
2241
+ y: a.y - b.y
2242
+ };
2243
+ }
2244
+ function getPanInfo({ point }, history) {
2245
+ return {
2246
+ point,
2247
+ delta: subtractPoint(point, lastDevicePoint(history)),
2248
+ offset: subtractPoint(point, startDevicePoint(history)),
2249
+ velocity: getVelocity(history, 0.1)
2250
+ };
2251
+ }
2252
+ function startDevicePoint(history) {
2253
+ return history[0];
2254
+ }
2255
+ function lastDevicePoint(history) {
2256
+ return history[history.length - 1];
2257
+ }
2258
+ function getVelocity(history, timeDelta) {
2259
+ if (history.length < 2) return {
2260
+ x: 0,
2261
+ y: 0
2262
+ };
2263
+ let i = history.length - 1;
2264
+ let timestampedPoint = null;
2265
+ const lastPoint = lastDevicePoint(history);
2266
+ while (i >= 0) {
2267
+ timestampedPoint = history[i];
2268
+ if (lastPoint.timestamp - timestampedPoint.timestamp > secondsToMilliseconds(timeDelta)) break;
2269
+ i--;
2270
+ }
2271
+ if (!timestampedPoint) return {
2272
+ x: 0,
2273
+ y: 0
2274
+ };
2275
+ if (timestampedPoint === history[0] && history.length > 2 && lastPoint.timestamp - timestampedPoint.timestamp > secondsToMilliseconds(timeDelta) * 2) timestampedPoint = history[1];
2276
+ const time2 = millisecondsToSeconds(lastPoint.timestamp - timestampedPoint.timestamp);
2277
+ if (time2 === 0) return {
2278
+ x: 0,
2279
+ y: 0
2280
+ };
2281
+ const currentVelocity = {
2282
+ x: (lastPoint.x - timestampedPoint.x) / time2,
2283
+ y: (lastPoint.y - timestampedPoint.y) / time2
2284
+ };
2285
+ if (currentVelocity.x === Infinity) currentVelocity.x = 0;
2286
+ if (currentVelocity.y === Infinity) currentVelocity.y = 0;
2287
+ return currentVelocity;
2288
+ }
2289
+ function applyConstraints(point, { min, max }, elastic) {
2290
+ if (min !== void 0 && point < min) point = elastic ? mixNumber(min, point, elastic.min) : Math.max(point, min);
2291
+ else if (max !== void 0 && point > max) point = elastic ? mixNumber(max, point, elastic.max) : Math.min(point, max);
2292
+ return point;
2293
+ }
2294
+ function calcRelativeAxisConstraints(axis, min, max) {
2295
+ return {
2296
+ min: min !== void 0 ? axis.min + min : void 0,
2297
+ max: max !== void 0 ? axis.max + max - (axis.max - axis.min) : void 0
2298
+ };
2299
+ }
2300
+ function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {
2301
+ return {
2302
+ x: calcRelativeAxisConstraints(layoutBox.x, left, right),
2303
+ y: calcRelativeAxisConstraints(layoutBox.y, top, bottom)
2304
+ };
2305
+ }
2306
+ function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {
2307
+ let min = constraintsAxis.min - layoutAxis.min;
2308
+ let max = constraintsAxis.max - layoutAxis.max;
2309
+ if (constraintsAxis.max - constraintsAxis.min < layoutAxis.max - layoutAxis.min) [min, max] = [max, min];
2310
+ return {
2311
+ min,
2312
+ max
2313
+ };
2314
+ }
2315
+ function calcViewportConstraints(layoutBox, constraintsBox) {
2316
+ return {
2317
+ x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),
2318
+ y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y)
2319
+ };
2320
+ }
2321
+ function calcOrigin(source, target) {
2322
+ let origin = 0.5;
2323
+ const sourceLength = calcLength(source);
2324
+ const targetLength = calcLength(target);
2325
+ if (targetLength > sourceLength) origin = progress(target.min, target.max - sourceLength, source.min);
2326
+ else if (sourceLength > targetLength) origin = progress(source.min, source.max - targetLength, target.min);
2327
+ return clamp(0, 1, origin);
2328
+ }
2329
+ function rebaseAxisConstraints(layout2, constraints) {
2330
+ const relativeConstraints = {};
2331
+ if (constraints.min !== void 0) relativeConstraints.min = constraints.min - layout2.min;
2332
+ if (constraints.max !== void 0) relativeConstraints.max = constraints.max - layout2.min;
2333
+ return relativeConstraints;
2334
+ }
2335
+ var defaultElastic = 0.35;
2336
+ function resolveDragElastic(dragElastic = defaultElastic) {
2337
+ if (dragElastic === false) dragElastic = 0;
2338
+ else if (dragElastic === true) dragElastic = defaultElastic;
2339
+ return {
2340
+ x: resolveAxisElastic(dragElastic, "left", "right"),
2341
+ y: resolveAxisElastic(dragElastic, "top", "bottom")
2342
+ };
2343
+ }
2344
+ function resolveAxisElastic(dragElastic, minLabel, maxLabel) {
2345
+ return {
2346
+ min: resolvePointElastic(dragElastic, minLabel),
2347
+ max: resolvePointElastic(dragElastic, maxLabel)
2348
+ };
2349
+ }
2350
+ function resolvePointElastic(dragElastic, label) {
2351
+ return typeof dragElastic === "number" ? dragElastic : dragElastic[label] || 0;
2352
+ }
2353
+ var elementDragControls = /* @__PURE__ */ new WeakMap();
2354
+ var VisualElementDragControls = class {
2355
+ constructor(visualElement) {
2356
+ this.openDragLock = null;
2357
+ this.isDragging = false;
2358
+ this.currentDirection = null;
2359
+ this.originPoint = {
2360
+ x: 0,
2361
+ y: 0
2362
+ };
2363
+ this.constraints = false;
2364
+ this.hasMutatedConstraints = false;
2365
+ this.elastic = createBox();
2366
+ this.latestPointerEvent = null;
2367
+ this.latestPanInfo = null;
2368
+ this.visualElement = visualElement;
2369
+ }
2370
+ start(originEvent, { snapToCursor = false, distanceThreshold } = {}) {
2371
+ const { presenceContext } = this.visualElement;
2372
+ if (presenceContext && presenceContext.isPresent === false) return;
2373
+ const onSessionStart = (event) => {
2374
+ if (snapToCursor) this.snapToCursor(extractEventInfo(event).point);
2375
+ this.stopAnimation();
2376
+ };
2377
+ const onStart = (event, info) => {
2378
+ const { drag: drag2, dragPropagation, onDragStart } = this.getProps();
2379
+ if (drag2 && !dragPropagation) {
2380
+ if (this.openDragLock) this.openDragLock();
2381
+ this.openDragLock = setDragLock(drag2);
2382
+ if (!this.openDragLock) return;
2383
+ }
2384
+ this.latestPointerEvent = event;
2385
+ this.latestPanInfo = info;
2386
+ this.isDragging = true;
2387
+ this.currentDirection = null;
2388
+ this.resolveConstraints();
2389
+ if (this.visualElement.projection) {
2390
+ this.visualElement.projection.isAnimationBlocked = true;
2391
+ this.visualElement.projection.target = void 0;
2392
+ }
2393
+ eachAxis((axis) => {
2394
+ let current = this.getAxisMotionValue(axis).get() || 0;
2395
+ if (percent.test(current)) {
2396
+ const { projection } = this.visualElement;
2397
+ if (projection && projection.layout) {
2398
+ const measuredAxis = projection.layout.layoutBox[axis];
2399
+ if (measuredAxis) current = calcLength(measuredAxis) * (parseFloat(current) / 100);
2400
+ }
2401
+ }
2402
+ this.originPoint[axis] = current;
2403
+ });
2404
+ if (onDragStart) frame.update(() => onDragStart(event, info), false, true);
2405
+ addValueToWillChange(this.visualElement, "transform");
2406
+ const { animationState } = this.visualElement;
2407
+ animationState && animationState.setActive("whileDrag", true);
2408
+ };
2409
+ const onMove = (event, info) => {
2410
+ this.latestPointerEvent = event;
2411
+ this.latestPanInfo = info;
2412
+ const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag } = this.getProps();
2413
+ if (!dragPropagation && !this.openDragLock) return;
2414
+ const { offset } = info;
2415
+ if (dragDirectionLock && this.currentDirection === null) {
2416
+ this.currentDirection = getCurrentDirection(offset);
2417
+ if (this.currentDirection !== null) onDirectionLock && onDirectionLock(this.currentDirection);
2418
+ return;
2419
+ }
2420
+ this.updateAxis("x", info.point, offset);
2421
+ this.updateAxis("y", info.point, offset);
2422
+ this.visualElement.render();
2423
+ if (onDrag) frame.update(() => onDrag(event, info), false, true);
2424
+ };
2425
+ const onSessionEnd = (event, info) => {
2426
+ this.latestPointerEvent = event;
2427
+ this.latestPanInfo = info;
2428
+ this.stop(event, info);
2429
+ this.latestPointerEvent = null;
2430
+ this.latestPanInfo = null;
2431
+ };
2432
+ const resumeAnimation = () => {
2433
+ const { dragSnapToOrigin: snap } = this.getProps();
2434
+ if (snap || this.constraints) this.startAnimation({
2435
+ x: 0,
2436
+ y: 0
2437
+ });
2438
+ };
2439
+ const { dragSnapToOrigin } = this.getProps();
2440
+ this.panSession = new PanSession(originEvent, {
2441
+ onSessionStart,
2442
+ onStart,
2443
+ onMove,
2444
+ onSessionEnd,
2445
+ resumeAnimation
2446
+ }, {
2447
+ transformPagePoint: this.visualElement.getTransformPagePoint(),
2448
+ dragSnapToOrigin,
2449
+ distanceThreshold,
2450
+ contextWindow: getContextWindow(this.visualElement),
2451
+ element: this.visualElement.current
2452
+ });
2453
+ }
2454
+ /**
2455
+ * @internal
2456
+ */
2457
+ stop(event, panInfo) {
2458
+ const finalEvent = event || this.latestPointerEvent;
2459
+ const finalPanInfo = panInfo || this.latestPanInfo;
2460
+ const isDragging2 = this.isDragging;
2461
+ this.cancel();
2462
+ if (!isDragging2 || !finalPanInfo || !finalEvent) return;
2463
+ const { velocity } = finalPanInfo;
2464
+ this.startAnimation(velocity);
2465
+ const { onDragEnd } = this.getProps();
2466
+ if (onDragEnd) frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));
2467
+ }
2468
+ /**
2469
+ * @internal
2470
+ */
2471
+ cancel() {
2472
+ this.isDragging = false;
2473
+ const { projection, animationState } = this.visualElement;
2474
+ if (projection) projection.isAnimationBlocked = false;
2475
+ this.endPanSession();
2476
+ const { dragPropagation } = this.getProps();
2477
+ if (!dragPropagation && this.openDragLock) {
2478
+ this.openDragLock();
2479
+ this.openDragLock = null;
2480
+ }
2481
+ animationState && animationState.setActive("whileDrag", false);
2482
+ }
2483
+ /**
2484
+ * Clean up the pan session without modifying other drag state.
2485
+ * This is used during unmount to ensure event listeners are removed
2486
+ * without affecting projection animations or drag locks.
2487
+ * @internal
2488
+ */
2489
+ endPanSession() {
2490
+ this.panSession && this.panSession.end();
2491
+ this.panSession = void 0;
2492
+ }
2493
+ updateAxis(axis, _point, offset) {
2494
+ const { drag: drag2 } = this.getProps();
2495
+ if (!offset || !shouldDrag(axis, drag2, this.currentDirection)) return;
2496
+ const axisValue = this.getAxisMotionValue(axis);
2497
+ let next = this.originPoint[axis] + offset[axis];
2498
+ if (this.constraints && this.constraints[axis]) next = applyConstraints(next, this.constraints[axis], this.elastic[axis]);
2499
+ axisValue.set(next);
2500
+ }
2501
+ resolveConstraints() {
2502
+ const { dragConstraints, dragElastic } = this.getProps();
2503
+ const layout2 = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(false) : this.visualElement.projection?.layout;
2504
+ const prevConstraints = this.constraints;
2505
+ if (dragConstraints && isRefObject(dragConstraints)) {
2506
+ if (!this.constraints) this.constraints = this.resolveRefConstraints();
2507
+ } else if (dragConstraints && layout2) this.constraints = calcRelativeConstraints(layout2.layoutBox, dragConstraints);
2508
+ else this.constraints = false;
2509
+ this.elastic = resolveDragElastic(dragElastic);
2510
+ if (prevConstraints !== this.constraints && !isRefObject(dragConstraints) && layout2 && this.constraints && !this.hasMutatedConstraints) eachAxis((axis) => {
2511
+ if (this.constraints !== false && this.getAxisMotionValue(axis)) this.constraints[axis] = rebaseAxisConstraints(layout2.layoutBox[axis], this.constraints[axis]);
2512
+ });
2513
+ }
2514
+ resolveRefConstraints() {
2515
+ const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();
2516
+ if (!constraints || !isRefObject(constraints)) return false;
2517
+ const constraintsElement = constraints.current;
2518
+ invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.", "drag-constraints-ref");
2519
+ const { projection } = this.visualElement;
2520
+ if (!projection || !projection.layout) return false;
2521
+ if (projection.root) {
2522
+ projection.root.scroll = void 0;
2523
+ projection.root.updateScroll();
2524
+ }
2525
+ const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());
2526
+ let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, constraintsBox);
2527
+ if (onMeasureDragConstraints) {
2528
+ const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));
2529
+ this.hasMutatedConstraints = !!userConstraints;
2530
+ if (userConstraints) measuredConstraints = convertBoundingBoxToBox(userConstraints);
2531
+ }
2532
+ return measuredConstraints;
2533
+ }
2534
+ startAnimation(velocity) {
2535
+ const { drag: drag2, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd } = this.getProps();
2536
+ const constraints = this.constraints || {};
2537
+ const momentumAnimations = eachAxis((axis) => {
2538
+ if (!shouldDrag(axis, drag2, this.currentDirection)) return;
2539
+ let transition = constraints && constraints[axis] || {};
2540
+ if (dragSnapToOrigin === true || dragSnapToOrigin === axis) transition = {
2541
+ min: 0,
2542
+ max: 0
2543
+ };
2544
+ const bounceStiffness = dragElastic ? 200 : 1e6;
2545
+ const bounceDamping = dragElastic ? 40 : 1e7;
2546
+ const inertia = {
2547
+ type: "inertia",
2548
+ velocity: dragMomentum ? velocity[axis] : 0,
2549
+ bounceStiffness,
2550
+ bounceDamping,
2551
+ timeConstant: 750,
2552
+ restDelta: 1,
2553
+ restSpeed: 10,
2554
+ ...dragTransition,
2555
+ ...transition
2556
+ };
2557
+ return this.startAxisValueAnimation(axis, inertia);
2558
+ });
2559
+ return Promise.all(momentumAnimations).then(onDragTransitionEnd);
2560
+ }
2561
+ startAxisValueAnimation(axis, transition) {
2562
+ const axisValue = this.getAxisMotionValue(axis);
2563
+ addValueToWillChange(this.visualElement, axis);
2564
+ return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));
2565
+ }
2566
+ stopAnimation() {
2567
+ eachAxis((axis) => this.getAxisMotionValue(axis).stop());
2568
+ }
2569
+ /**
2570
+ * Drag works differently depending on which props are provided.
2571
+ *
2572
+ * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
2573
+ * - Otherwise, we apply the delta to the x/y motion values.
2574
+ */
2575
+ getAxisMotionValue(axis) {
2576
+ const dragKey = `_drag${axis.toUpperCase()}`;
2577
+ const externalMotionValue = this.visualElement.getProps()[dragKey];
2578
+ return externalMotionValue ? externalMotionValue : this.visualElement.getValue(axis, this.visualElement.latestValues[axis] ?? 0);
2579
+ }
2580
+ snapToCursor(point) {
2581
+ eachAxis((axis) => {
2582
+ const { drag: drag2 } = this.getProps();
2583
+ if (!shouldDrag(axis, drag2, this.currentDirection)) return;
2584
+ const { projection } = this.visualElement;
2585
+ const axisValue = this.getAxisMotionValue(axis);
2586
+ if (projection && projection.layout) {
2587
+ const { min, max } = projection.layout.layoutBox[axis];
2588
+ const current = axisValue.get() || 0;
2589
+ axisValue.set(point[axis] - mixNumber(min, max, 0.5) + current);
2590
+ }
2591
+ });
2592
+ }
2593
+ /**
2594
+ * When the viewport resizes we want to check if the measured constraints
2595
+ * have changed and, if so, reposition the element within those new constraints
2596
+ * relative to where it was before the resize.
2597
+ */
2598
+ scalePositionWithinConstraints() {
2599
+ if (!this.visualElement.current) return;
2600
+ const { drag: drag2, dragConstraints } = this.getProps();
2601
+ const { projection } = this.visualElement;
2602
+ if (!isRefObject(dragConstraints) || !projection || !this.constraints) return;
2603
+ this.stopAnimation();
2604
+ const boxProgress = {
2605
+ x: 0,
2606
+ y: 0
2607
+ };
2608
+ eachAxis((axis) => {
2609
+ const axisValue = this.getAxisMotionValue(axis);
2610
+ if (axisValue && this.constraints !== false) {
2611
+ const latest = axisValue.get();
2612
+ boxProgress[axis] = calcOrigin({
2613
+ min: latest,
2614
+ max: latest
2615
+ }, this.constraints[axis]);
2616
+ }
2617
+ });
2618
+ const { transformTemplate } = this.visualElement.getProps();
2619
+ this.visualElement.current.style.transform = transformTemplate ? transformTemplate({}, "") : "none";
2620
+ projection.root && projection.root.updateScroll();
2621
+ projection.updateLayout();
2622
+ this.constraints = false;
2623
+ this.resolveConstraints();
2624
+ eachAxis((axis) => {
2625
+ if (!shouldDrag(axis, drag2, null)) return;
2626
+ const axisValue = this.getAxisMotionValue(axis);
2627
+ const { min, max } = this.constraints[axis];
2628
+ axisValue.set(mixNumber(min, max, boxProgress[axis]));
2629
+ });
2630
+ this.visualElement.render();
2631
+ }
2632
+ addListeners() {
2633
+ if (!this.visualElement.current) return;
2634
+ elementDragControls.set(this.visualElement, this);
2635
+ const element = this.visualElement.current;
2636
+ const stopPointerListener = addPointerEvent(element, "pointerdown", (event) => {
2637
+ const { drag: drag2, dragListener = true } = this.getProps();
2638
+ const target = event.target;
2639
+ const isClickingTextInputChild = target !== element && isElementTextInput(target);
2640
+ if (drag2 && dragListener && !isClickingTextInputChild) this.start(event);
2641
+ });
2642
+ let stopResizeObservers;
2643
+ const measureDragConstraints = () => {
2644
+ const { dragConstraints } = this.getProps();
2645
+ if (isRefObject(dragConstraints) && dragConstraints.current) {
2646
+ this.constraints = this.resolveRefConstraints();
2647
+ if (!stopResizeObservers) stopResizeObservers = startResizeObservers(element, dragConstraints.current, () => this.scalePositionWithinConstraints());
2648
+ }
2649
+ };
2650
+ const { projection } = this.visualElement;
2651
+ const stopMeasureLayoutListener = projection.addEventListener("measure", measureDragConstraints);
2652
+ if (projection && !projection.layout) {
2653
+ projection.root && projection.root.updateScroll();
2654
+ projection.updateLayout();
2655
+ }
2656
+ frame.read(measureDragConstraints);
2657
+ const stopResizeListener = addDomEvent(window, "resize", () => this.scalePositionWithinConstraints());
2658
+ const stopLayoutUpdateListener = projection.addEventListener("didUpdate", (({ delta, hasLayoutChanged }) => {
2659
+ if (this.isDragging && hasLayoutChanged) {
2660
+ eachAxis((axis) => {
2661
+ const motionValue2 = this.getAxisMotionValue(axis);
2662
+ if (!motionValue2) return;
2663
+ this.originPoint[axis] += delta[axis].translate;
2664
+ motionValue2.set(motionValue2.get() + delta[axis].translate);
2665
+ });
2666
+ this.visualElement.render();
2667
+ }
2668
+ }));
2669
+ return () => {
2670
+ stopResizeListener();
2671
+ stopPointerListener();
2672
+ stopMeasureLayoutListener();
2673
+ stopLayoutUpdateListener && stopLayoutUpdateListener();
2674
+ stopResizeObservers && stopResizeObservers();
2675
+ };
2676
+ }
2677
+ getProps() {
2678
+ const props = this.visualElement.getProps();
2679
+ const { drag: drag2 = false, dragDirectionLock = false, dragPropagation = false, dragConstraints = false, dragElastic = defaultElastic, dragMomentum = true } = props;
2680
+ return {
2681
+ ...props,
2682
+ drag: drag2,
2683
+ dragDirectionLock,
2684
+ dragPropagation,
2685
+ dragConstraints,
2686
+ dragElastic,
2687
+ dragMomentum
2688
+ };
2689
+ }
2690
+ };
2691
+ function skipFirstCall(callback) {
2692
+ let isFirst = true;
2693
+ return () => {
2694
+ if (isFirst) {
2695
+ isFirst = false;
2696
+ return;
2697
+ }
2698
+ callback();
2699
+ };
2700
+ }
2701
+ function startResizeObservers(element, constraintsElement, onResize) {
2702
+ const stopElement = resize(element, skipFirstCall(onResize));
2703
+ const stopContainer = resize(constraintsElement, skipFirstCall(onResize));
2704
+ return () => {
2705
+ stopElement();
2706
+ stopContainer();
2707
+ };
2708
+ }
2709
+ function shouldDrag(direction, drag2, currentDirection) {
2710
+ return (drag2 === true || drag2 === direction) && (currentDirection === null || currentDirection === direction);
2711
+ }
2712
+ function getCurrentDirection(offset, lockThreshold = 10) {
2713
+ let direction = null;
2714
+ if (Math.abs(offset.y) > lockThreshold) direction = "y";
2715
+ else if (Math.abs(offset.x) > lockThreshold) direction = "x";
2716
+ return direction;
2717
+ }
2718
+ var DragGesture = class extends Feature {
2719
+ constructor(node) {
2720
+ super(node);
2721
+ this.removeGroupControls = noop;
2722
+ this.removeListeners = noop;
2723
+ this.controls = new VisualElementDragControls(node);
2724
+ }
2725
+ mount() {
2726
+ const { dragControls } = this.node.getProps();
2727
+ if (dragControls) this.removeGroupControls = dragControls.subscribe(this.controls);
2728
+ this.removeListeners = this.controls.addListeners() || noop;
2729
+ }
2730
+ update() {
2731
+ const { dragControls } = this.node.getProps();
2732
+ const { dragControls: prevDragControls } = this.node.prevProps || {};
2733
+ if (dragControls !== prevDragControls) {
2734
+ this.removeGroupControls();
2735
+ if (dragControls) this.removeGroupControls = dragControls.subscribe(this.controls);
2736
+ }
2737
+ }
2738
+ unmount() {
2739
+ this.removeGroupControls();
2740
+ this.removeListeners();
2741
+ if (!this.controls.isDragging) this.controls.endPanSession();
2742
+ }
2743
+ };
2744
+ var asyncHandler = (handler) => (event, info) => {
2745
+ if (handler) frame.update(() => handler(event, info), false, true);
2746
+ };
2747
+ var PanGesture = class extends Feature {
2748
+ constructor() {
2749
+ super(...arguments);
2750
+ this.removePointerDownListener = noop;
2751
+ }
2752
+ onPointerDown(pointerDownEvent) {
2753
+ this.session = new PanSession(pointerDownEvent, this.createPanHandlers(), {
2754
+ transformPagePoint: this.node.getTransformPagePoint(),
2755
+ contextWindow: getContextWindow(this.node)
2756
+ });
2757
+ }
2758
+ createPanHandlers() {
2759
+ const { onPanSessionStart, onPanStart, onPan, onPanEnd } = this.node.getProps();
2760
+ return {
2761
+ onSessionStart: asyncHandler(onPanSessionStart),
2762
+ onStart: asyncHandler(onPanStart),
2763
+ onMove: asyncHandler(onPan),
2764
+ onEnd: (event, info) => {
2765
+ delete this.session;
2766
+ if (onPanEnd) frame.postRender(() => onPanEnd(event, info));
2767
+ }
2768
+ };
2769
+ }
2770
+ mount() {
2771
+ this.removePointerDownListener = addPointerEvent(this.node.current, "pointerdown", (event) => this.onPointerDown(event));
2772
+ }
2773
+ update() {
2774
+ this.session && this.session.updateHandlers(this.createPanHandlers());
2775
+ }
2776
+ unmount() {
2777
+ this.removePointerDownListener();
2778
+ this.session && this.session.end();
2779
+ }
2780
+ };
2781
+ var hasTakenAnySnapshot = false;
2782
+ var MeasureLayoutWithContext = class extends Component {
2783
+ /**
2784
+ * This only mounts projection nodes for components that
2785
+ * need measuring, we might want to do it for all components
2786
+ * in order to incorporate transforms
2787
+ */
2788
+ componentDidMount() {
2789
+ const { visualElement, layoutGroup, switchLayoutGroup, layoutId } = this.props;
2790
+ const { projection } = visualElement;
2791
+ if (projection) {
2792
+ if (layoutGroup.group) layoutGroup.group.add(projection);
2793
+ if (switchLayoutGroup && switchLayoutGroup.register && layoutId) switchLayoutGroup.register(projection);
2794
+ if (hasTakenAnySnapshot) projection.root.didUpdate();
2795
+ projection.addEventListener("animationComplete", () => {
2796
+ this.safeToRemove();
2797
+ });
2798
+ projection.setOptions({
2799
+ ...projection.options,
2800
+ layoutDependency: this.props.layoutDependency,
2801
+ onExitComplete: () => this.safeToRemove()
2802
+ });
2803
+ }
2804
+ globalProjectionState.hasEverUpdated = true;
2805
+ }
2806
+ getSnapshotBeforeUpdate(prevProps) {
2807
+ const { layoutDependency, visualElement, drag: drag2, isPresent } = this.props;
2808
+ const { projection } = visualElement;
2809
+ if (!projection) return null;
2810
+ projection.isPresent = isPresent;
2811
+ if (prevProps.layoutDependency !== layoutDependency) projection.setOptions({
2812
+ ...projection.options,
2813
+ layoutDependency
2814
+ });
2815
+ hasTakenAnySnapshot = true;
2816
+ if (drag2 || prevProps.layoutDependency !== layoutDependency || layoutDependency === void 0 || prevProps.isPresent !== isPresent) projection.willUpdate();
2817
+ else this.safeToRemove();
2818
+ if (prevProps.isPresent !== isPresent) {
2819
+ if (isPresent) projection.promote();
2820
+ else if (!projection.relegate())
2821
+ frame.postRender(() => {
2822
+ const stack = projection.getStack();
2823
+ if (!stack || !stack.members.length) this.safeToRemove();
2824
+ });
2825
+ }
2826
+ return null;
2827
+ }
2828
+ componentDidUpdate() {
2829
+ const { visualElement, layoutAnchor } = this.props;
2830
+ const { projection } = visualElement;
2831
+ if (projection) {
2832
+ projection.options.layoutAnchor = layoutAnchor;
2833
+ projection.root.didUpdate();
2834
+ microtask.postRender(() => {
2835
+ if (!projection.currentAnimation && projection.isLead()) this.safeToRemove();
2836
+ });
2837
+ }
2838
+ }
2839
+ componentWillUnmount() {
2840
+ const { visualElement, layoutGroup, switchLayoutGroup: promoteContext } = this.props;
2841
+ const { projection } = visualElement;
2842
+ hasTakenAnySnapshot = true;
2843
+ if (projection) {
2844
+ projection.scheduleCheckAfterUnmount();
2845
+ if (layoutGroup && layoutGroup.group) layoutGroup.group.remove(projection);
2846
+ if (promoteContext && promoteContext.deregister) promoteContext.deregister(projection);
2847
+ }
2848
+ }
2849
+ safeToRemove() {
2850
+ const { safeToRemove } = this.props;
2851
+ safeToRemove && safeToRemove();
2852
+ }
2853
+ render() {
2854
+ return null;
2855
+ }
2856
+ };
2857
+ function MeasureLayout(props) {
2858
+ const [isPresent, safeToRemove] = usePresence();
2859
+ const layoutGroup = useContext(LayoutGroupContext);
2860
+ return jsx(MeasureLayoutWithContext, {
2861
+ ...props,
2862
+ layoutGroup,
2863
+ switchLayoutGroup: useContext(SwitchLayoutGroupContext),
2864
+ isPresent,
2865
+ safeToRemove
2866
+ });
2867
+ }
2868
+ var drag = {
2869
+ pan: { Feature: PanGesture },
2870
+ drag: {
2871
+ Feature: DragGesture,
2872
+ ProjectionNode: HTMLProjectionNode,
2873
+ MeasureLayout
2874
+ }
2875
+ };
2876
+ function handleHoverEvent(node, event, lifecycle) {
2877
+ const { props } = node;
2878
+ if (node.animationState && props.whileHover) node.animationState.setActive("whileHover", lifecycle === "Start");
2879
+ const callback = props["onHover" + lifecycle];
2880
+ if (callback) frame.postRender(() => callback(event, extractEventInfo(event)));
2881
+ }
2882
+ var HoverGesture = class extends Feature {
2883
+ mount() {
2884
+ const { current } = this.node;
2885
+ if (!current) return;
2886
+ this.unmount = hover(current, (_element, startEvent) => {
2887
+ handleHoverEvent(this.node, startEvent, "Start");
2888
+ return (endEvent) => handleHoverEvent(this.node, endEvent, "End");
2889
+ });
2890
+ }
2891
+ unmount() {
2892
+ }
2893
+ };
2894
+ var FocusGesture = class extends Feature {
2895
+ constructor() {
2896
+ super(...arguments);
2897
+ this.isActive = false;
2898
+ }
2899
+ onFocus() {
2900
+ let isFocusVisible = false;
2901
+ try {
2902
+ isFocusVisible = this.node.current.matches(":focus-visible");
2903
+ } catch (e) {
2904
+ isFocusVisible = true;
2905
+ }
2906
+ if (!isFocusVisible || !this.node.animationState) return;
2907
+ this.node.animationState.setActive("whileFocus", true);
2908
+ this.isActive = true;
2909
+ }
2910
+ onBlur() {
2911
+ if (!this.isActive || !this.node.animationState) return;
2912
+ this.node.animationState.setActive("whileFocus", false);
2913
+ this.isActive = false;
2914
+ }
2915
+ mount() {
2916
+ this.unmount = pipe(addDomEvent(this.node.current, "focus", () => this.onFocus()), addDomEvent(this.node.current, "blur", () => this.onBlur()));
2917
+ }
2918
+ unmount() {
2919
+ }
2920
+ };
2921
+ function handlePressEvent(node, event, lifecycle) {
2922
+ const { props } = node;
2923
+ if (node.current instanceof HTMLButtonElement && node.current.disabled) return;
2924
+ if (node.animationState && props.whileTap) node.animationState.setActive("whileTap", lifecycle === "Start");
2925
+ const callback = props["onTap" + (lifecycle === "End" ? "" : lifecycle)];
2926
+ if (callback) frame.postRender(() => callback(event, extractEventInfo(event)));
2927
+ }
2928
+ var PressGesture = class extends Feature {
2929
+ mount() {
2930
+ const { current } = this.node;
2931
+ if (!current) return;
2932
+ const { globalTapTarget, propagate } = this.node.props;
2933
+ this.unmount = press(current, (_element, startEvent) => {
2934
+ handlePressEvent(this.node, startEvent, "Start");
2935
+ return (endEvent, { success }) => handlePressEvent(this.node, endEvent, success ? "End" : "Cancel");
2936
+ }, {
2937
+ useGlobalTarget: globalTapTarget,
2938
+ stopPropagation: propagate?.tap === false
2939
+ });
2940
+ }
2941
+ unmount() {
2942
+ }
2943
+ };
2944
+ var observerCallbacks = /* @__PURE__ */ new WeakMap();
2945
+ var observers = /* @__PURE__ */ new WeakMap();
2946
+ var fireObserverCallback = (entry) => {
2947
+ const callback = observerCallbacks.get(entry.target);
2948
+ callback && callback(entry);
2949
+ };
2950
+ var fireAllObserverCallbacks = (entries) => {
2951
+ entries.forEach(fireObserverCallback);
2952
+ };
2953
+ function initIntersectionObserver({ root: root2, ...options }) {
2954
+ const lookupRoot = root2 || document;
2955
+ if (!observers.has(lookupRoot)) observers.set(lookupRoot, {});
2956
+ const rootObservers = observers.get(lookupRoot);
2957
+ const key = JSON.stringify(options);
2958
+ if (!rootObservers[key]) rootObservers[key] = new IntersectionObserver(fireAllObserverCallbacks, {
2959
+ root: root2,
2960
+ ...options
2961
+ });
2962
+ return rootObservers[key];
2963
+ }
2964
+ function observeIntersection(element, options, callback) {
2965
+ const rootInteresectionObserver = initIntersectionObserver(options);
2966
+ observerCallbacks.set(element, callback);
2967
+ rootInteresectionObserver.observe(element);
2968
+ return () => {
2969
+ observerCallbacks.delete(element);
2970
+ rootInteresectionObserver.unobserve(element);
2971
+ };
2972
+ }
2973
+ var thresholdNames = {
2974
+ some: 0,
2975
+ all: 1
2976
+ };
2977
+ var InViewFeature = class extends Feature {
2978
+ constructor() {
2979
+ super(...arguments);
2980
+ this.hasEnteredView = false;
2981
+ this.isInView = false;
2982
+ }
2983
+ startObserver() {
2984
+ this.stopObserver?.();
2985
+ const { viewport = {} } = this.node.getProps();
2986
+ const { root: root2, margin: rootMargin, amount = "some", once } = viewport;
2987
+ const options = {
2988
+ root: root2 ? root2.current : void 0,
2989
+ rootMargin,
2990
+ threshold: typeof amount === "number" ? amount : thresholdNames[amount]
2991
+ };
2992
+ const onIntersectionUpdate = (entry) => {
2993
+ const { isIntersecting } = entry;
2994
+ if (this.isInView === isIntersecting) return;
2995
+ this.isInView = isIntersecting;
2996
+ if (once && !isIntersecting && this.hasEnteredView) return;
2997
+ else if (isIntersecting) this.hasEnteredView = true;
2998
+ if (this.node.animationState) this.node.animationState.setActive("whileInView", isIntersecting);
2999
+ const { onViewportEnter, onViewportLeave } = this.node.getProps();
3000
+ const callback = isIntersecting ? onViewportEnter : onViewportLeave;
3001
+ callback && callback(entry);
3002
+ };
3003
+ this.stopObserver = observeIntersection(this.node.current, options, onIntersectionUpdate);
3004
+ }
3005
+ mount() {
3006
+ this.startObserver();
3007
+ }
3008
+ update() {
3009
+ if (typeof IntersectionObserver === "undefined") return;
3010
+ const { props, prevProps } = this.node;
3011
+ if ([
3012
+ "amount",
3013
+ "margin",
3014
+ "root"
3015
+ ].some(hasViewportOptionChanged(props, prevProps))) this.startObserver();
3016
+ }
3017
+ unmount() {
3018
+ this.stopObserver?.();
3019
+ this.hasEnteredView = false;
3020
+ this.isInView = false;
3021
+ }
3022
+ };
3023
+ function hasViewportOptionChanged({ viewport = {} }, { viewport: prevViewport = {} } = {}) {
3024
+ return (name) => viewport[name] !== prevViewport[name];
3025
+ }
3026
+ var gestureAnimations = {
3027
+ inView: { Feature: InViewFeature },
3028
+ tap: { Feature: PressGesture },
3029
+ focus: { Feature: FocusGesture },
3030
+ hover: { Feature: HoverGesture }
3031
+ };
3032
+ var layout = { layout: {
3033
+ ProjectionNode: HTMLProjectionNode,
3034
+ MeasureLayout
3035
+ } };
110
3036
  var domMax = {
111
- ...domAnimation,
3037
+ renderer: createDomVisualElement,
3038
+ ...animations,
3039
+ ...gestureAnimations,
112
3040
  ...drag,
113
3041
  ...layout
114
3042
  };
@@ -125,13 +3053,33 @@ function NotFoundPage({ title = "404", description = "The requested page could n
125
3053
  })
126
3054
  });
127
3055
  }
3056
+ function useHtmlReducedMotionClass() {
3057
+ const [reduced, setReduced] = useState(false);
3058
+ useLayoutEffect(() => {
3059
+ const root2 = document.documentElement;
3060
+ const sync = () => setReduced(root2.classList.contains("reduce-motion"));
3061
+ sync();
3062
+ const observer2 = new MutationObserver(sync);
3063
+ observer2.observe(root2, {
3064
+ attributes: true,
3065
+ attributeFilter: ["class"]
3066
+ });
3067
+ return () => observer2.disconnect();
3068
+ }, []);
3069
+ return reduced;
3070
+ }
128
3071
  function MotionRuntime({ children }) {
3072
+ const htmlReduced = useHtmlReducedMotionClass();
129
3073
  return /* @__PURE__ */ jsx(LazyMotion, {
130
3074
  features: domMax,
131
- children
3075
+ strict: true,
3076
+ children: /* @__PURE__ */ jsx(MotionConfig, {
3077
+ reducedMotion: htmlReduced ? "always" : "user",
3078
+ children
3079
+ })
132
3080
  });
133
3081
  }
134
- var globals_default = "/assets/globals-CuIiqOTg.css";
3082
+ var globals_default = "/assets/globals-BtCXZXL_.css";
135
3083
  function makeQueryClient() {
136
3084
  return new QueryClient({ defaultOptions: { queries: {
137
3085
  staleTime: 6e4,
@@ -145,7 +3093,7 @@ function getQueryClient() {
145
3093
  if (!browserQueryClient) browserQueryClient = makeQueryClient();
146
3094
  return browserQueryClient;
147
3095
  }
148
- var Route$29 = createRootRoute({
3096
+ var Route$27 = createRootRoute({
149
3097
  head: () => ({
150
3098
  meta: [
151
3099
  { charSet: "utf-8" },
@@ -192,9 +3140,7 @@ var Route$29 = createRootRoute({
192
3140
  });
193
3141
  function RootComponent() {
194
3142
  useLayoutEffect(() => {
195
- const preferences = readUiPreferences();
196
- document.documentElement.dataset.density = preferences.density;
197
- document.documentElement.classList.toggle("reduce-motion", preferences.motion === "reduced");
3143
+ applyUiPreferencesToDocument(readUiPreferences());
198
3144
  }, []);
199
3145
  useEffect(() => {
200
3146
  initAnalytics();
@@ -215,8 +3161,8 @@ function RootDocument({ children }) {
215
3161
  ] })]
216
3162
  });
217
3163
  }
218
- var $$splitComponentImporter = () => import("./routes-BGrVtPYF-SURPAJN6.js");
219
- var Route$28 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter, "component") });
3164
+ var $$splitComponentImporter = () => import("./routes-B9F9UfF1-UN2IVBMJ.js");
3165
+ var Route$26 = createFileRoute("/")({ component: lazyRouteComponent($$splitComponentImporter, "component") });
220
3166
  var ManagedAttachmentValidationError = class extends Error {
221
3167
  status;
222
3168
  constructor(message, status) {
@@ -1028,8 +3974,8 @@ var openUIPromptSpec = {
1028
3974
  description: "A button that triggers interactive actions or conversational updates."
1029
3975
  },
1030
3976
  PanelAction: {
1031
- signature: 'PanelAction(label: string, panel: "resources" | "workspace" | "artifacts" | "repl" | "subagents" | "session-insights", relativePath?: any, focus?: boolean)',
1032
- description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, or Session insights. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
3977
+ signature: 'PanelAction(label: string, panel: "resources" | "workspace" | "artifacts" | "repl" | "subagents" | "session-insights" | "session-tree", relativePath?: any, focus?: boolean)',
3978
+ description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, Session insights, or Session tree. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
1033
3979
  },
1034
3980
  Input: {
1035
3981
  signature: 'Input(name: string, value: $binding<string>, placeholder?: string, type?: "text" | "email" | "number" | "password" | "search", disabled?: boolean)',
@@ -1353,7 +4299,8 @@ var openUIPromptSpec = {
1353
4299
  "artifacts",
1354
4300
  "repl",
1355
4301
  "subagents",
1356
- "session-insights"
4302
+ "session-insights",
4303
+ "session-tree"
1357
4304
  ]
1358
4305
  },
1359
4306
  relativePath: { type: "string" },
@@ -1368,7 +4315,7 @@ var openUIPromptSpec = {
1368
4315
  "focus"
1369
4316
  ],
1370
4317
  additionalProperties: false,
1371
- description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, or Session insights. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
4318
+ description: "A trusted local action that opens Resources, Workspace, Artifacts, REPL, Subagents, Session insights, or Session tree. relativePath selects a contained workspace-relative path and is valid only for Workspace and Artifacts panels."
1372
4319
  },
1373
4320
  Input: {
1374
4321
  type: "object",
@@ -2292,8 +5239,8 @@ function createPrimeConfig(initialCwd) {
2292
5239
  const authStorage = AuthStorage.create();
2293
5240
  const modelRegistry2 = ModelRegistry.create(authStorage);
2294
5241
  const projectRegistry = new ProjectRegistry(agentDir, initialCwd);
2295
- let currentDefaultCwd = resolve(initialCwd);
2296
- let defaultSettings = SettingsManager.create(currentDefaultCwd);
5242
+ const currentDefaultCwd = resolve(initialCwd);
5243
+ const defaultSettings = SettingsManager.create(currentDefaultCwd);
2297
5244
  const settingsByCwd = /* @__PURE__ */ new Map();
2298
5245
  settingsByCwd.set(currentDefaultCwd, defaultSettings);
2299
5246
  return {
@@ -2325,17 +5272,6 @@ function createPrimeConfig(initialCwd) {
2325
5272
  await loader.reload();
2326
5273
  return loader;
2327
5274
  },
2328
- setDefaultCwd(cwd) {
2329
- const next = resolve(cwd);
2330
- currentDefaultCwd = next;
2331
- const existing = settingsByCwd.get(next);
2332
- if (existing) {
2333
- defaultSettings = existing;
2334
- return;
2335
- }
2336
- defaultSettings = SettingsManager.create(next);
2337
- settingsByCwd.set(next, defaultSettings);
2338
- },
2339
5275
  reloadAuth() {
2340
5276
  this.authStorage.reload();
2341
5277
  this.modelRegistry.refresh();
@@ -2345,7 +5281,7 @@ function createPrimeConfig(initialCwd) {
2345
5281
  function getPrimeConfig() {
2346
5282
  const globalStore2 = globalThis;
2347
5283
  const existing = globalStore2.__primeConfig;
2348
- if (!existing || typeof existing.setDefaultCwd !== "function" || !existing.projectRegistry) globalStore2.__primeConfig = createPrimeConfig(resolveDefaultWorkspaceRoot(process.cwd()));
5284
+ if (!existing || !existing.projectRegistry) globalStore2.__primeConfig = createPrimeConfig(resolveDefaultWorkspaceRoot(process.cwd()));
2349
5285
  return globalStore2.__primeConfig;
2350
5286
  }
2351
5287
  var DAEMON_STARTUP_TIMEOUT_MS = 3e4;
@@ -2942,11 +5878,11 @@ function stringifyPayload(value) {
2942
5878
  return String(value);
2943
5879
  }
2944
5880
  }
2945
- function createPayloadPart(kind, title, payload, text, id) {
5881
+ function createPayloadPart(kind, title, payload, text, id2) {
2946
5882
  const safePayload = browserSafePayload(payload);
2947
5883
  return {
2948
5884
  type: "payload",
2949
- ...id ? { id } : {},
5885
+ ...id2 ? { id: id2 } : {},
2950
5886
  kind,
2951
5887
  title,
2952
5888
  ...text ? { text } : {},
@@ -2956,7 +5892,7 @@ function createPayloadPart(kind, title, payload, text, id) {
2956
5892
  function textFromChatParts(parts) {
2957
5893
  return parts.filter((part) => part.type === "text").map((part) => part.text).join("\n");
2958
5894
  }
2959
- function toChatMessageFromRuntimeMessage(message, id) {
5895
+ function toChatMessageFromRuntimeMessage(message, id2) {
2960
5896
  const value = message;
2961
5897
  const role = typeof value.role === "string" ? value.role : "runtime";
2962
5898
  const timestamp = getTimestamp(message);
@@ -2974,7 +5910,7 @@ function toChatMessageFromRuntimeMessage(message, id) {
2974
5910
  cancelled ? "(cancelled)" : status
2975
5911
  ].filter((part) => Boolean(part)).join("\n");
2976
5912
  return {
2977
- id,
5913
+ id: id2,
2978
5914
  role: "assistant",
2979
5915
  parts: [createPayloadPart("bashExecution", "Bash", {
2980
5916
  command,
@@ -2983,7 +5919,7 @@ function toChatMessageFromRuntimeMessage(message, id) {
2983
5919
  cancelled,
2984
5920
  truncated,
2985
5921
  excludeFromContext: value.excludeFromContext === true
2986
- }, text, id)],
5922
+ }, text, id2)],
2987
5923
  createdAt: timestamp
2988
5924
  };
2989
5925
  }
@@ -2997,23 +5933,23 @@ function toChatMessageFromRuntimeMessage(message, id) {
2997
5933
  ...details !== void 0 ? { details } : {}
2998
5934
  };
2999
5935
  return {
3000
- id,
5936
+ id: id2,
3001
5937
  role: "assistant",
3002
- parts: [...contentParts2, createPayloadPart(customType, `[${customType}]`, payload2, textFromChatParts(contentParts2) ? void 0 : stringifyPayload(details), id)],
5938
+ parts: [...contentParts2, createPayloadPart(customType, `[${customType}]`, payload2, textFromChatParts(contentParts2) ? void 0 : stringifyPayload(details), id2)],
3003
5939
  createdAt: timestamp
3004
5940
  };
3005
5941
  }
3006
5942
  if (role === "branchSummary") {
3007
5943
  const summary = typeof value.summary === "string" ? value.summary : "";
3008
5944
  return {
3009
- id,
5945
+ id: id2,
3010
5946
  role: "assistant",
3011
5947
  parts: [createPayloadPart("branchSummary", "Branch summary", {
3012
5948
  fromId: value.fromId,
3013
5949
  summary
3014
5950
  }, `Branch Summary
3015
5951
 
3016
- ${summary}`, id)],
5952
+ ${summary}`, id2)],
3017
5953
  createdAt: timestamp
3018
5954
  };
3019
5955
  }
@@ -3023,7 +5959,7 @@ ${summary}`, id)],
3023
5959
  const customInstructions = typeof value.customInstructions === "string" ? value.customInstructions : void 0;
3024
5960
  const tokenLabel = tokensBefore === void 0 ? "" : `Compacted from ${tokensBefore.toLocaleString()} tokens`;
3025
5961
  return {
3026
- id,
5962
+ id: id2,
3027
5963
  role: "assistant",
3028
5964
  parts: [createPayloadPart("compactionSummary", "Compaction summary", {
3029
5965
  summary,
@@ -3034,7 +5970,7 @@ ${summary}`, id)],
3034
5970
  tokenLabel,
3035
5971
  customInstructions ? `Focus: ${customInstructions}` : void 0,
3036
5972
  summary
3037
- ].filter((part) => Boolean(part)).join("\n\n"), id)],
5973
+ ].filter((part) => Boolean(part)).join("\n\n"), id2)],
3038
5974
  createdAt: timestamp
3039
5975
  };
3040
5976
  }
@@ -3042,13 +5978,13 @@ ${summary}`, id)],
3042
5978
  const contentParts = contentToChatParts(value.content);
3043
5979
  const payload = browserSafePayload(Object.fromEntries(Object.entries(value).filter(([key]) => key !== "content")));
3044
5980
  return {
3045
- id,
5981
+ id: id2,
3046
5982
  role: "assistant",
3047
- parts: [...contentParts, createPayloadPart(role, `[${role}]`, payload, textFromChatParts(contentParts) ? void 0 : stringifyPayload(payload), id)],
5983
+ parts: [...contentParts, createPayloadPart(role, `[${role}]`, payload, textFromChatParts(contentParts) ? void 0 : stringifyPayload(payload), id2)],
3048
5984
  createdAt: timestamp
3049
5985
  };
3050
5986
  }
3051
- function toChatMessageFromAssistant(msg, id) {
5987
+ function toChatMessageFromAssistant(msg, id2) {
3052
5988
  const parts = [];
3053
5989
  for (const block of msg.content) {
3054
5990
  const value = block;
@@ -3082,15 +6018,15 @@ function toChatMessageFromAssistant(msg, id) {
3082
6018
  message: errorMessage
3083
6019
  });
3084
6020
  return {
3085
- id,
6021
+ id: id2,
3086
6022
  role: "assistant",
3087
6023
  parts,
3088
6024
  createdAt: getTimestamp(msg)
3089
6025
  };
3090
6026
  }
3091
- function toChatMessageFromUser(msg, id) {
6027
+ function toChatMessageFromUser(msg, id2) {
3092
6028
  return {
3093
- id,
6029
+ id: id2,
3094
6030
  role: "user",
3095
6031
  parts: contentToChatParts(msg.content),
3096
6032
  createdAt: getTimestamp(msg)
@@ -3224,16 +6160,16 @@ function toChatMessagesFromAgentMessages(messages, sessionId) {
3224
6160
  const output = [];
3225
6161
  for (const [index, message] of messages.entries()) {
3226
6162
  const role = message.role;
3227
- const id = `${sessionId}-m${index}`;
6163
+ const id2 = `${sessionId}-m${index}`;
3228
6164
  if (role === "assistant") {
3229
- output.push(toChatMessageFromAssistant(message, id));
6165
+ output.push(toChatMessageFromAssistant(message, id2));
3230
6166
  continue;
3231
6167
  }
3232
6168
  if (role === "user") {
3233
- output.push(toChatMessageFromUser(message, id));
6169
+ output.push(toChatMessageFromUser(message, id2));
3234
6170
  continue;
3235
6171
  }
3236
- const runtimeMessage = toChatMessageFromRuntimeMessage(message, id);
6172
+ const runtimeMessage = toChatMessageFromRuntimeMessage(message, id2);
3237
6173
  if (runtimeMessage) {
3238
6174
  output.push(runtimeMessage);
3239
6175
  continue;
@@ -3250,10 +6186,10 @@ function toChatMessagesFromAgentMessages(messages, sessionId) {
3250
6186
  let attached = false;
3251
6187
  if (toolCallId) for (let messageIndex = output.length - 1; messageIndex >= 0 && !attached; messageIndex -= 1) {
3252
6188
  const candidate = output[messageIndex];
3253
- const partIndex = candidate.parts.findIndex((part2) => part2.type.startsWith("tool-") && part2.toolCallId === toolCallId);
6189
+ const partIndex = candidate.parts.findIndex((part2) => isChatToolPart(part2) && part2.toolCallId === toolCallId);
3254
6190
  if (partIndex < 0) continue;
3255
6191
  const part = candidate.parts[partIndex];
3256
- if (!part.type.startsWith("tool-")) continue;
6192
+ if (!isChatToolPart(part)) continue;
3257
6193
  const nextPart = {
3258
6194
  ...part,
3259
6195
  state: isError ? "output-error" : "output-available",
@@ -3270,7 +6206,7 @@ function toChatMessagesFromAgentMessages(messages, sessionId) {
3270
6206
  attached = true;
3271
6207
  }
3272
6208
  if (!attached) output.push({
3273
- id,
6209
+ id: id2,
3274
6210
  role: "assistant",
3275
6211
  createdAt: typeof result.timestamp === "number" ? result.timestamp : void 0,
3276
6212
  parts: [{
@@ -3395,8 +6331,8 @@ function computeRlmExecutionTree(rootSessionId, children, activeNodeId) {
3395
6331
  };
3396
6332
  for (const child of children) if (child.parentId && child.parentId !== rootSessionId && nodes[child.parentId]) nodes[child.parentId].childrenIds.push(child.id);
3397
6333
  else rootChildrenIds.push(child.id);
3398
- const queue = rootChildrenIds.map((id) => ({
3399
- id,
6334
+ const queue = rootChildrenIds.map((id2) => ({
6335
+ id: id2,
3400
6336
  depth: 1
3401
6337
  }));
3402
6338
  const visited = /* @__PURE__ */ new Set();
@@ -3621,8 +6557,8 @@ function rememberSentAgentMessage(state, toolCallId, message) {
3621
6557
  const safeMessage = browserSafePayload(message);
3622
6558
  if (safeMessage === void 0) return;
3623
6559
  const messages = state.currentToolSentAgentMessages[toolCallId] ?? [];
3624
- const id = sentAgentMessageId(safeMessage);
3625
- if (id && messages.some((entry) => sentAgentMessageId(entry) === id)) return;
6560
+ const id2 = sentAgentMessageId(safeMessage);
6561
+ if (id2 && messages.some((entry) => sentAgentMessageId(entry) === id2)) return;
3626
6562
  state.currentToolSentAgentMessages[toolCallId] = [...messages, safeMessage];
3627
6563
  }
3628
6564
  function withSentAgentMessages(state, toolCallId, value) {
@@ -3740,8 +6676,8 @@ function mapCoreAgentEvent(state, event) {
3740
6676
  }];
3741
6677
  case "message_start":
3742
6678
  if (isUserMessage(event.message)) {
3743
- const id = `${state.runId}-u${state.userMessages.length}`;
3744
- const message = toChatMessageFromUser(event.message, id);
6679
+ const id2 = `${state.runId}-u${state.userMessages.length}`;
6680
+ const message = toChatMessageFromUser(event.message, id2);
3745
6681
  state.userMessages.push(message);
3746
6682
  return [{
3747
6683
  type: "message",
@@ -4056,10 +6992,10 @@ function mapSessionSpecificEvent(state, event) {
4056
6992
  })];
4057
6993
  case "bash_start": {
4058
6994
  const runId = event.runId ?? stablePresentationId(`bash:${state.sessionId}:${state.userBashSequence++}:${event.command}`);
4059
- const id = stablePresentationId(`user-bash:${runId}`);
4060
- state.activeUserBashId = id;
6995
+ const id2 = stablePresentationId(`user-bash:${runId}`);
6996
+ state.activeUserBashId = id2;
4061
6997
  const entry = {
4062
- id,
6998
+ id: id2,
4063
6999
  runId,
4064
7000
  command: event.command,
4065
7001
  output: "",
@@ -4113,10 +7049,10 @@ function mapSessionSpecificEvent(state, event) {
4113
7049
  }))];
4114
7050
  }
4115
7051
  case "refine_failed": {
4116
- const id = stablePresentationId(`${presentationRunId(state)}:refinement:${state.presentation.refinements.length}`);
7052
+ const id2 = stablePresentationId(`${presentationRunId(state)}:refinement:${state.presentation.refinements.length}`);
4117
7053
  const timestamp = Date.now();
4118
7054
  const refinement = {
4119
- id,
7055
+ id: id2,
4120
7056
  summary: "Refinement failed",
4121
7057
  rationale: "",
4122
7058
  expectedOutcome: "",
@@ -4129,9 +7065,9 @@ function mapSessionSpecificEvent(state, event) {
4129
7065
  ...state.presentation,
4130
7066
  refinements: [...state.presentation.refinements, refinement]
4131
7067
  }, {
4132
- id: stablePresentationId(`${presentationRunId(state)}:${id}:refinement`),
7068
+ id: stablePresentationId(`${presentationRunId(state)}:${id2}:refinement`),
4133
7069
  runId: presentationRunId(state),
4134
- sourceToolCallId: id,
7070
+ sourceToolCallId: id2,
4135
7071
  kind: "refinement",
4136
7072
  title: refinement.summary,
4137
7073
  status: "error",
@@ -4449,7 +7385,7 @@ var PendingDialogRegistry = class {
4449
7385
  if (!dialog) return false;
4450
7386
  clearTimeout(dialog.timer);
4451
7387
  this.bySession.get(sessionId)?.delete(toolCallId);
4452
- const frame = {
7388
+ const frame2 = {
4453
7389
  type: "tool",
4454
7390
  part: {
4455
7391
  type: "tool-Question",
@@ -4462,7 +7398,7 @@ var PendingDialogRegistry = class {
4462
7398
  }
4463
7399
  }
4464
7400
  };
4465
- this.emitFrame(sessionId, frame);
7401
+ this.emitFrame(sessionId, frame2);
4466
7402
  dialog.reject(/* @__PURE__ */ new Error(`Question cancelled: ${reason}`));
4467
7403
  return true;
4468
7404
  }
@@ -4531,6 +7467,123 @@ var RingBuffer = class {
4531
7467
  this.nextSeq = 1;
4532
7468
  }
4533
7469
  };
7470
+ var SessionTreeBusyError = class extends Error {
7471
+ status = 409;
7472
+ constructor() {
7473
+ super("Session is still streaming. Stop the current turn before rewinding.");
7474
+ this.name = "SessionTreeBusyError";
7475
+ }
7476
+ };
7477
+ var SessionTreeConcurrencyError = class extends Error {
7478
+ status = 409;
7479
+ constructor() {
7480
+ super("The session tree changed while you were selecting a rewind target. Refresh and try again.");
7481
+ this.name = "SessionTreeConcurrencyError";
7482
+ }
7483
+ };
7484
+ var SessionTreeCancelledError = class extends Error {
7485
+ status = 409;
7486
+ constructor() {
7487
+ super("Session tree navigation was cancelled. Refresh and try again.");
7488
+ this.name = "SessionTreeCancelledError";
7489
+ }
7490
+ };
7491
+ function messageContentToText(content) {
7492
+ if (typeof content === "string") return content;
7493
+ if (!Array.isArray(content)) return "";
7494
+ return content.filter((part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string").map((part) => part.text).join(" ");
7495
+ }
7496
+ function entryPreview(node) {
7497
+ const { entry } = node;
7498
+ if (entry.type === "message" && entry.message) {
7499
+ const role = entry.message.role ?? "message";
7500
+ const oneLine = messageContentToText(entry.message.content).replace(/\s+/g, " ").trim();
7501
+ return `${role}: ${oneLine.length > 72 ? `${oneLine.slice(0, 72)}\u2026` : oneLine}`;
7502
+ }
7503
+ return entry.label ?? node.label ?? entry.type;
7504
+ }
7505
+ function entryKind(entry) {
7506
+ if (entry.type === "message") return "message";
7507
+ if (entry.type === "system" || entry.type === "compaction" || entry.type === "model_change") return "system";
7508
+ return "other";
7509
+ }
7510
+ function entryRole(entry) {
7511
+ if (entry.type !== "message" || !entry.message?.role) return void 0;
7512
+ switch (entry.message.role) {
7513
+ case "user":
7514
+ return "user";
7515
+ case "assistant":
7516
+ return "assistant";
7517
+ case "system":
7518
+ return "system";
7519
+ default:
7520
+ return "unknown";
7521
+ }
7522
+ }
7523
+ function findActiveBranchPath(nodes, leafId) {
7524
+ const active = /* @__PURE__ */ new Set();
7525
+ if (!leafId) return active;
7526
+ const walk = (items) => {
7527
+ for (const node of items) {
7528
+ if (node.entry.id === leafId) {
7529
+ active.add(node.entry.id);
7530
+ return true;
7531
+ }
7532
+ if (walk(node.children)) {
7533
+ active.add(node.entry.id);
7534
+ return true;
7535
+ }
7536
+ }
7537
+ return false;
7538
+ };
7539
+ walk(nodes);
7540
+ return active;
7541
+ }
7542
+ function buildMessageIndexByEntryId(nodes, leafId) {
7543
+ const activePath = findActiveBranchPath(nodes, leafId);
7544
+ const messageIndexByEntryId = /* @__PURE__ */ new Map();
7545
+ let messageIndex = 0;
7546
+ const walk = (items) => {
7547
+ for (const node of items) {
7548
+ if (!activePath.has(node.entry.id)) continue;
7549
+ if (node.entry.type === "message") {
7550
+ messageIndexByEntryId.set(node.entry.id, messageIndex);
7551
+ messageIndex += 1;
7552
+ }
7553
+ walk(node.children);
7554
+ return;
7555
+ }
7556
+ };
7557
+ walk(nodes);
7558
+ return messageIndexByEntryId;
7559
+ }
7560
+ function mapNode(node, leafId, activePath, messageIndexByEntryId) {
7561
+ const preview = entryPreview(node);
7562
+ const role = entryRole(node.entry);
7563
+ const messageIndex = messageIndexByEntryId.get(node.entry.id);
7564
+ return {
7565
+ id: node.entry.id,
7566
+ ...node.entry.parentId ? { parentId: node.entry.parentId } : {},
7567
+ kind: entryKind(node.entry),
7568
+ ...role ? { role } : {},
7569
+ label: node.entry.label ?? node.label ?? node.entry.type,
7570
+ preview,
7571
+ isLeaf: node.entry.id === leafId,
7572
+ isOnActiveBranch: activePath.has(node.entry.id),
7573
+ ...messageIndex !== void 0 ? { messageIndex } : {},
7574
+ children: node.children.map((child) => mapNode(child, leafId, activePath, messageIndexByEntryId))
7575
+ };
7576
+ }
7577
+ function mapSessionTreeSnapshot(sessionId, nodes, leafId) {
7578
+ const upstreamNodes = nodes;
7579
+ const activePath = findActiveBranchPath(upstreamNodes, leafId);
7580
+ const messageIndexByEntryId = buildMessageIndexByEntryId(upstreamNodes, leafId);
7581
+ return {
7582
+ sessionId,
7583
+ leafId,
7584
+ nodes: upstreamNodes.map((node) => mapNode(node, leafId, activePath, messageIndexByEntryId))
7585
+ };
7586
+ }
4534
7587
  var WEB_UI_UNSUPPORTED = "Not available in the web UI";
4535
7588
  function unsupportedInWebUi(method) {
4536
7589
  throw new Error(`${method}: ${WEB_UI_UNSUPPORTED}`);
@@ -4842,6 +7895,7 @@ var PrimeBridge = class {
4842
7895
  #childPromptStarter;
4843
7896
  #childPrompts = /* @__PURE__ */ new Map();
4844
7897
  #caches = /* @__PURE__ */ new Map();
7898
+ #sessionTreeNavigationQueues = /* @__PURE__ */ new Map();
4845
7899
  #openUIPromptTransitions = /* @__PURE__ */ new Map();
4846
7900
  #daemonDialogs = /* @__PURE__ */ new Map();
4847
7901
  #auxiliaryWarnings = /* @__PURE__ */ new Set();
@@ -4857,7 +7911,7 @@ var PrimeBridge = class {
4857
7911
  this.#childPromptStarter = options.childPromptStarter ?? startDaemonChildPrompt;
4858
7912
  this.#dialogs = new PendingDialogRegistry({
4859
7913
  defaultTimeoutMs: options.dialogTimeoutMs ?? 6e4,
4860
- emitFrame: (sessionId, frame) => this.#dispatch(sessionId, frame)
7914
+ emitFrame: (sessionId, frame2) => this.#dispatch(sessionId, frame2)
4861
7915
  });
4862
7916
  }
4863
7917
  /** Late-boot kernel readiness gate. Boot-time callers await this; failures cause `/api/chat` to 503. */
@@ -4896,11 +7950,11 @@ var PrimeBridge = class {
4896
7950
  return () => this.#listeners.delete(listener);
4897
7951
  }
4898
7952
  /** Emit a frame to ring buffer (SSE replay) and all live listeners. */
4899
- #dispatch(sessionId, frame) {
4900
- const next = frame.type === "done" && !(frame.sessionId ?? "").trim() ? {
4901
- ...frame,
7953
+ #dispatch(sessionId, frame2) {
7954
+ const next = frame2.type === "done" && !(frame2.sessionId ?? "").trim() ? {
7955
+ ...frame2,
4902
7956
  sessionId
4903
- } : frame;
7957
+ } : frame2;
4904
7958
  const buffer = this.#ringBuffers.get(sessionId);
4905
7959
  if (buffer) buffer.push(next);
4906
7960
  for (const listener of this.#listeners) listener(sessionId, next);
@@ -4937,6 +7991,7 @@ var PrimeBridge = class {
4937
7991
  this.#presentationWrites.clear();
4938
7992
  this.#presentationGenerations.clear();
4939
7993
  this.#caches.clear();
7994
+ this.#sessionTreeNavigationQueues.clear();
4940
7995
  this.#openUIPromptTransitions.clear();
4941
7996
  this.#daemonDialogs.clear();
4942
7997
  this.#auxiliaryWarnings.clear();
@@ -5040,7 +8095,7 @@ var PrimeBridge = class {
5040
8095
  await getPrimeConfig().projectRegistry.assignSession(sessionId, resolvedProjectId);
5041
8096
  const uiContext = createWebUIContext({
5042
8097
  sessionId,
5043
- emitFrame: (frame) => this.#dispatch(sessionId, frame),
8098
+ emitFrame: (frame2) => this.#dispatch(sessionId, frame2),
5044
8099
  dialogs: this.#dialogs
5045
8100
  });
5046
8101
  await webAgent.bindUiContext?.(uiContext);
@@ -5073,9 +8128,9 @@ var PrimeBridge = class {
5073
8128
  } catch {
5074
8129
  }
5075
8130
  const frames = mapAgentConnectionEvent(mapperState, event);
5076
- for (const frame of frames) {
5077
- if (frame.type === "presentation") this.#persistPresentation(sessionId, sessionPath, frame.presentation);
5078
- this.#dispatch(sessionId, frame);
8131
+ for (const frame2 of frames) {
8132
+ if (frame2.type === "presentation") this.#persistPresentation(sessionId, sessionPath, frame2.presentation);
8133
+ this.#dispatch(sessionId, frame2);
5079
8134
  }
5080
8135
  if (event.type === "session_resynced" || event.type === "session_event" && event.event.type === "rlm_child_update") this.#queueRlmChildMetadataRefresh(sessionId);
5081
8136
  });
@@ -5215,7 +8270,7 @@ var PrimeBridge = class {
5215
8270
  sessions2 = await this.#sessionLister();
5216
8271
  } catch {
5217
8272
  for (const child of parent.mapperState.presentation.rlmChildren) parent.mapperState.rlmChildOverrides.delete(child.id);
5218
- for (const frame of applyRlmChildStatusOverrides(parent.mapperState, /* @__PURE__ */ new Map())) this.#dispatch(rootSessionId, frame);
8273
+ for (const frame2 of applyRlmChildStatusOverrides(parent.mapperState, /* @__PURE__ */ new Map())) this.#dispatch(rootSessionId, frame2);
5219
8274
  return;
5220
8275
  }
5221
8276
  const { sessionsByIdentifier, sessionsByPath, rootIdentifiers, rootPaths } = await this.#resolveRlmLineage(sessions2, rootSessionId, parent.sessionPath);
@@ -5226,9 +8281,9 @@ var PrimeBridge = class {
5226
8281
  else parent.mapperState.rlmChildOverrides.delete(child.id);
5227
8282
  }
5228
8283
  const frames = applyRlmChildStatusOverrides(parent.mapperState, overrides);
5229
- for (const frame of frames) {
5230
- if (frame.type === "presentation") this.#persistPresentation(rootSessionId, parent.sessionPath, frame.presentation);
5231
- this.#dispatch(rootSessionId, frame);
8284
+ for (const frame2 of frames) {
8285
+ if (frame2.type === "presentation") this.#persistPresentation(rootSessionId, parent.sessionPath, frame2.presentation);
8286
+ this.#dispatch(rootSessionId, frame2);
5232
8287
  }
5233
8288
  }
5234
8289
  #childStreamStatus(child, summary) {
@@ -5323,12 +8378,12 @@ var PrimeBridge = class {
5323
8378
  terminal: true
5324
8379
  };
5325
8380
  const frames = mapAgentConnectionEvent(stream.mapperState, event);
5326
- for (const frame of frames) {
5327
- if (frame.type === "error") stream.snapshot = {
8381
+ for (const frame2 of frames) {
8382
+ if (frame2.type === "error") stream.snapshot = {
5328
8383
  ...stream.snapshot,
5329
8384
  status: "error"
5330
8385
  };
5331
- this.#dispatch(stream.channelId, frame);
8386
+ this.#dispatch(stream.channelId, frame2);
5332
8387
  }
5333
8388
  if (event.type === "session_event" && event.event.type === "rlm_child_update") this.#queueRlmChildMetadataRefresh(stream.parentSessionId);
5334
8389
  if (event.type === "session_replaced" || event.type === "session_resynced" || event.type === "closed" || event.type === "session_event" && (event.event.type === "agent_end" || event.event.type === "turn_end")) this.#queueRlmChildSnapshot(stream);
@@ -5625,12 +8680,6 @@ var PrimeBridge = class {
5625
8680
  session.openUIPrompt.artifact = artifact;
5626
8681
  session.openUIPrompt.prompt = nextPrompt;
5627
8682
  }
5628
- async steer(sessionId, text) {
5629
- await this.#requireSession(sessionId).connection.steer(text);
5630
- }
5631
- async followUp(sessionId, text) {
5632
- await this.#requireSession(sessionId).connection.followUp(text);
5633
- }
5634
8683
  async mutateQueuedMessage(sessionId, lane, index, expectedText, mutation) {
5635
8684
  const session = this.#requireSession(sessionId);
5636
8685
  const upstreamMutation = mutation.type === "delete" ? { type: "delete" } : {
@@ -5648,9 +8697,6 @@ var PrimeBridge = class {
5648
8697
  }
5649
8698
  };
5650
8699
  }
5651
- async deleteQueuedMessage(sessionId, lane, index, expectedText) {
5652
- return this.mutateQueuedMessage(sessionId, lane, index, expectedText, { type: "delete" });
5653
- }
5654
8700
  async abort(sessionId) {
5655
8701
  const session = this.#requireSession(sessionId);
5656
8702
  this.#dialogs.cancelAll(sessionId, "user-abort");
@@ -5811,8 +8857,12 @@ var PrimeBridge = class {
5811
8857
  /** /tree — session-tree navigation via navigateTree (requires entry id). */
5812
8858
  async navigateTree(sessionId, targetId) {
5813
8859
  const session = this.#requireSession(sessionId);
5814
- await session.connection.navigateTree(targetId, {});
5815
- await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
8860
+ await this.#withSessionTreeNavigationLock(sessionId, async () => {
8861
+ await session.connection.waitForIdle();
8862
+ await session.connection.navigateTree(targetId, {});
8863
+ await this.#refreshSessionTreeCache(sessionId, session.connection);
8864
+ await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
8865
+ });
5816
8866
  }
5817
8867
  /** /tree — the session's entry tree plus the current leaf, for pickers. */
5818
8868
  getSessionTree(sessionId) {
@@ -5824,6 +8874,43 @@ var PrimeBridge = class {
5824
8874
  leafId: null
5825
8875
  };
5826
8876
  }
8877
+ async #refreshSessionTreeCache(sessionId, connection) {
8878
+ const tree = await connection.getSessionTree();
8879
+ const cache = this.#caches.get(sessionId) ?? emptyCache();
8880
+ cache.tree = {
8881
+ tree: tree.tree,
8882
+ leafId: tree.leafId
8883
+ };
8884
+ this.#caches.set(sessionId, cache);
8885
+ }
8886
+ async #withSessionTreeNavigationLock(sessionId, operation) {
8887
+ const current = (this.#sessionTreeNavigationQueues.get(sessionId) ?? Promise.resolve()).catch(() => void 0).then(operation);
8888
+ const tail = current.then(() => void 0, () => void 0);
8889
+ this.#sessionTreeNavigationQueues.set(sessionId, tail);
8890
+ tail.then(() => {
8891
+ if (this.#sessionTreeNavigationQueues.get(sessionId) === tail) this.#sessionTreeNavigationQueues.delete(sessionId);
8892
+ });
8893
+ return current;
8894
+ }
8895
+ /** Reads a browser-safe session tree snapshot from the live connection. */
8896
+ async readSessionTreeSnapshot(sessionId) {
8897
+ const session = this.#requireSession(sessionId);
8898
+ await this.#refreshSessionTreeCache(sessionId, session.connection);
8899
+ const cached = this.getSessionTree(sessionId);
8900
+ return mapSessionTreeSnapshot(sessionId, cached.tree, cached.leafId);
8901
+ }
8902
+ /** Navigates the live session tree and returns the authoritative browser-safe snapshot. */
8903
+ async navigateSessionTree(sessionId, targetEntryId, expectedLeafId) {
8904
+ const session = this.#requireSession(sessionId);
8905
+ return this.#withSessionTreeNavigationLock(sessionId, async () => {
8906
+ await session.connection.waitForIdle();
8907
+ const before = await session.connection.getSessionTree();
8908
+ if (expectedLeafId && before.leafId !== expectedLeafId) throw new SessionTreeConcurrencyError();
8909
+ if ((await session.connection.navigateTree(targetEntryId, {})).cancelled) throw new SessionTreeCancelledError();
8910
+ await deleteManagedPlanPresentationsForSession(sessionId, session.sessionPath);
8911
+ return this.readSessionTreeSnapshot(sessionId);
8912
+ });
8913
+ }
5827
8914
  /**
5828
8915
  * /fork and /clone — branch the session at `entryId` into a NEW live session.
5829
8916
  *
@@ -6097,10 +9184,10 @@ async function handleChatChildPost(bridge, parentSessionId, childId, message, st
6097
9184
  } catch {
6098
9185
  }
6099
9186
  };
6100
- const write = (frame) => {
9187
+ const write = (frame2) => {
6101
9188
  if (closed) return;
6102
9189
  try {
6103
- controller.enqueue(encoder.encode(`${JSON.stringify(frame)}
9190
+ controller.enqueue(encoder.encode(`${JSON.stringify(frame2)}
6104
9191
  `));
6105
9192
  } catch {
6106
9193
  }
@@ -6232,21 +9319,21 @@ ${attachmentContext.join("\n\n")}` : message;
6232
9319
  } catch {
6233
9320
  }
6234
9321
  };
6235
- const write = (frame) => {
9322
+ const write = (frame2) => {
6236
9323
  if (closed) return;
6237
9324
  try {
6238
- controller.enqueue(encoder.encode(`${JSON.stringify(frame)}
9325
+ controller.enqueue(encoder.encode(`${JSON.stringify(frame2)}
6239
9326
  `));
6240
9327
  } catch {
6241
9328
  }
6242
9329
  };
6243
- removeListener = bridge.addEventListener((sid, frame) => {
9330
+ removeListener = bridge.addEventListener((sid, frame2) => {
6244
9331
  if (sid !== session.sessionId) return;
6245
9332
  if (backendSessionCommand) return;
6246
- const nextFrame = frame.type === "done" && !frame.sessionReset ? {
6247
- ...frame,
9333
+ const nextFrame = frame2.type === "done" && !frame2.sessionReset ? {
9334
+ ...frame2,
6248
9335
  presentation: bridge.getPresentation(session.sessionId)
6249
- } : frame;
9336
+ } : frame2;
6250
9337
  write(nextFrame);
6251
9338
  if (nextFrame.type === "done" && !nextFrame.sessionReset) terminalDoneSent = true;
6252
9339
  if (nextFrame.type === "error" || nextFrame.type === "done" && !nextFrame.sessionReset) close();
@@ -6329,14 +9416,14 @@ ${attachmentContext.join("\n\n")}` : message;
6329
9416
  } });
6330
9417
  }, request);
6331
9418
  }
6332
- var BodySchema$3 = external_exports.object({
9419
+ var BodySchema$2 = external_exports.object({
6333
9420
  sessionId: SessionIdSchema.optional(),
6334
9421
  childId: external_exports.string().min(1).max(160).optional()
6335
9422
  });
6336
9423
  function handleChatAbortPost(request) {
6337
9424
  return wrapApiHandler(async () => {
6338
9425
  const raw = await request.json().catch(() => ({}));
6339
- const body = BodySchema$3.parse(raw);
9426
+ const body = BodySchema$2.parse(raw);
6340
9427
  const sessionId = body.sessionId;
6341
9428
  if (!sessionId) return Response.json({ message: "abort requires sessionId" }, { status: 400 });
6342
9429
  const bridge = getBridge();
@@ -6423,14 +9510,14 @@ function handleChatAttachmentGet(request) {
6423
9510
  } });
6424
9511
  }, request);
6425
9512
  }
6426
- var BodySchema$2 = external_exports.object({
9513
+ var BodySchema$1 = external_exports.object({
6427
9514
  sessionId: SessionIdSchema,
6428
9515
  command: external_exports.string(),
6429
9516
  args: external_exports.string().max(1024).optional()
6430
9517
  });
6431
9518
  function handleChatCommandPost(request) {
6432
9519
  return wrapApiHandler(async () => {
6433
- const body = BodySchema$2.parse(await request.json().catch(() => ({})));
9520
+ const body = BodySchema$1.parse(await request.json().catch(() => ({})));
6434
9521
  const bridge = getBridge();
6435
9522
  const args = body.args?.trim() ?? "";
6436
9523
  switch (body.command) {
@@ -6724,9 +9811,9 @@ function handleChatCommandsGet(request) {
6724
9811
  function shouldReplaySseEvent(event, pendingQuestionIds) {
6725
9812
  if (!pendingQuestionIds) return true;
6726
9813
  if (!event || typeof event !== "object") return true;
6727
- const frame = event;
6728
- if (frame.type !== "tool" || frame.part?.type !== "tool-Question") return true;
6729
- const toolCallId = frame.part.toolCallId;
9814
+ const frame2 = event;
9815
+ if (frame2.type !== "tool" || frame2.part?.type !== "tool-Question") return true;
9816
+ const toolCallId = frame2.part.toolCallId;
6730
9817
  return typeof toolCallId === "string" && pendingQuestionIds.has(toolCallId);
6731
9818
  }
6732
9819
  function normalizeSseReplayEvent(event) {
@@ -34219,7 +37306,7 @@ var MODELS = {
34219
37306
  var modelRegistry = /* @__PURE__ */ new Map();
34220
37307
  for (const [provider, models] of Object.entries(MODELS)) {
34221
37308
  const providerModels = /* @__PURE__ */ new Map();
34222
- for (const [id, model] of Object.entries(models)) providerModels.set(id, model);
37309
+ for (const [id2, model] of Object.entries(models)) providerModels.set(id2, model);
34223
37310
  modelRegistry.set(provider, providerModels);
34224
37311
  }
34225
37312
  function getModels(provider) {
@@ -34755,8 +37842,8 @@ var oauthProviderRegistry = new Map([
34755
37842
  }
34756
37843
  }
34757
37844
  ].map((provider) => [provider.id, provider]));
34758
- function getOAuthProvider(id) {
34759
- return oauthProviderRegistry.get(id);
37845
+ function getOAuthProvider(id2) {
37846
+ return oauthProviderRegistry.get(id2);
34760
37847
  }
34761
37848
  function registerOAuthProvider(provider) {
34762
37849
  oauthProviderRegistry.set(provider.id, provider);
@@ -35373,7 +38460,7 @@ function addCustomProviderModelIds(filePath, providerId, modelIds) {
35373
38460
  if (!existing) return;
35374
38461
  providers[providerId] = {
35375
38462
  ...existing,
35376
- models: mergeModelDefinitions(existing.models, [...existing.models ?? [], ...modelIds.map((id) => ({ id }))])
38463
+ models: mergeModelDefinitions(existing.models, [...existing.models ?? [], ...modelIds.map((id2) => ({ id: id2 }))])
35377
38464
  };
35378
38465
  writeModelsJson(filePath, {
35379
38466
  ...data,
@@ -35495,23 +38582,23 @@ function buildProviders() {
35495
38582
  const builtinIds = new Set(getProviders());
35496
38583
  const allIds = /* @__PURE__ */ new Set([...builtinIds, ...Object.keys(custom)]);
35497
38584
  allIds.add(OPENAI_CHAT_COMPLETIONS_PROVIDER_ID);
35498
- return [...allIds].map((id) => {
35499
- const isCustom = !builtinIds.has(id);
35500
- const customEntry = isCustom ? custom[id] : void 0;
35501
- const status = config.modelRegistry.getProviderAuthStatus(id);
35502
- const catalogEntry = KNOWN_PROVIDER_BY_ID.get(id);
35503
- const name = isCustom ? customEntry?.name ?? catalogEntry?.name ?? id : BUILT_IN_PROVIDER_DISPLAY_NAMES[id] ?? catalogEntry?.name ?? id;
35504
- const envVarName = isCustom ? customEntry?.apiKey ?? catalogEntry?.envVarName ?? "" : envHintForBuiltin(id);
38585
+ return [...allIds].map((id2) => {
38586
+ const isCustom = !builtinIds.has(id2);
38587
+ const customEntry = isCustom ? custom[id2] : void 0;
38588
+ const status = config.modelRegistry.getProviderAuthStatus(id2);
38589
+ const catalogEntry = KNOWN_PROVIDER_BY_ID.get(id2);
38590
+ const name = isCustom ? customEntry?.name ?? catalogEntry?.name ?? id2 : BUILT_IN_PROVIDER_DISPLAY_NAMES[id2] ?? catalogEntry?.name ?? id2;
38591
+ const envVarName = isCustom ? customEntry?.apiKey ?? catalogEntry?.envVarName ?? "" : envHintForBuiltin(id2);
35505
38592
  const row = {
35506
- id,
38593
+ id: id2,
35507
38594
  name,
35508
38595
  envVarName,
35509
- ...resolveProviderAuthFields(id, envVarName, oauthIds),
38596
+ ...resolveProviderAuthFields(id2, envVarName, oauthIds),
35510
38597
  isConfigured: status.configured
35511
38598
  };
35512
- if (isOccProviderId(id) || isCustomProviderId(id)) {
35513
- row.providerFamily = isOccProviderId(id) ? OPENAI_CHAT_COMPLETIONS_PROVIDER_ID : "custom";
35514
- if (customEntry?.name && (isNamedOccInstanceId(id) || isCustomProviderId(id))) row.displayName = customEntry.name;
38599
+ if (isOccProviderId(id2) || isCustomProviderId(id2)) {
38600
+ row.providerFamily = isOccProviderId(id2) ? OPENAI_CHAT_COMPLETIONS_PROVIDER_ID : "custom";
38601
+ if (customEntry?.name && (isNamedOccInstanceId(id2) || isCustomProviderId(id2))) row.displayName = customEntry.name;
35515
38602
  const customApi = uiApiForCustomProvider(customEntry?.api);
35516
38603
  if (customApi) row.api = customApi;
35517
38604
  if (customEntry?.baseUrl) row.baseUrl = customEntry.baseUrl;
@@ -35585,7 +38672,7 @@ function handleChatProvidersPost(request) {
35585
38672
  baseUrl,
35586
38673
  api,
35587
38674
  apiKey: envVarNameForManagedProvider(providerId),
35588
- models: modelIds.map((id) => ({ id }))
38675
+ models: modelIds.map((id2) => ({ id: id2 }))
35589
38676
  });
35590
38677
  config.authStorage.set(providerId, {
35591
38678
  type: "api_key",
@@ -35938,27 +39025,6 @@ function handleChatMcpOAuthPost(request, deps = defaultMcpDeps()) {
35938
39025
  return Response.json(toMcpOAuthResponse(startOAuthLogin(providerId, oauthDeps(deps))));
35939
39026
  }, request);
35940
39027
  }
35941
- var BodySchema$1 = external_exports.object({
35942
- sessionId: SessionIdSchema,
35943
- model: external_exports.object({
35944
- provider: external_exports.string(),
35945
- id: external_exports.string()
35946
- })
35947
- });
35948
- function handleChatModelPost(request) {
35949
- return wrapApiHandler(async () => {
35950
- const raw = await request.json().catch(() => ({}));
35951
- const body = BodySchema$1.parse(raw);
35952
- const bridge = getBridge();
35953
- const session = bridge.getSession(body.sessionId) ?? await bridge.resumeSessionById(body.sessionId);
35954
- if (!session || !await requireProjectSession(session)) return Response.json({ message: `Unknown session: ${body.sessionId}` }, { status: 404 });
35955
- await bridge.setModel(body.sessionId, {
35956
- provider: body.model.provider,
35957
- id: body.model.id
35958
- });
35959
- return Response.json({ ok: true });
35960
- }, request);
35961
- }
35962
39028
  function toPatternCandidate(model) {
35963
39029
  return {
35964
39030
  id: model.id,
@@ -36406,9 +39472,9 @@ function sessionSourcePath(source) {
36406
39472
  const raw = source;
36407
39473
  return stringValue(raw.sessionFile) ?? stringValue(raw.path);
36408
39474
  }
36409
- function latestBy(entries, time) {
39475
+ function latestBy(entries, time2) {
36410
39476
  if (entries.length === 0) return void 0;
36411
- return entries.reduce((latest, entry) => time(entry) >= time(latest) ? entry : latest);
39477
+ return entries.reduce((latest, entry) => time2(entry) >= time2(latest) ? entry : latest);
36412
39478
  }
36413
39479
  function presentationListActivity(presentation) {
36414
39480
  if (!presentation) return { activityCount: 0 };
@@ -36658,9 +39724,52 @@ function handleHealthGet(request) {
36658
39724
  });
36659
39725
  }, request);
36660
39726
  }
36661
- function handleWorkspaceBrowseGet(request) {
39727
+ async function requireReadableSession(sessionId) {
39728
+ const bridge = getBridge();
39729
+ const session = bridge.getSession(sessionId) ?? await bridge.resumeSessionById(sessionId);
39730
+ if (!await requireProjectSession(session)) return {
39731
+ ok: false,
39732
+ response: Response.json({ message: `Unknown session: ${sessionId}` }, { status: 404 })
39733
+ };
39734
+ return {
39735
+ ok: true,
39736
+ session
39737
+ };
39738
+ }
39739
+ async function requireWritableSession(sessionId) {
39740
+ const access = await requireReadableSession(sessionId);
39741
+ if (!access.ok) return access;
39742
+ const { session } = access;
39743
+ if (session?.isStreaming) return {
39744
+ ok: false,
39745
+ response: Response.json({ message: new SessionTreeBusyError().message }, { status: 409 })
39746
+ };
39747
+ return access;
39748
+ }
39749
+ function handleChatSessionTreeGet(request) {
36662
39750
  return wrapApiHandler(async () => {
36663
- return Response.json({ message: "Workspace root switching is disabled; use /api/projects/browse for opaque directory tokens." }, { status: 410 });
39751
+ const sessionId = new URL(request.url).searchParams.get("sessionId");
39752
+ if (!sessionId) return Response.json({ message: "GET /api/chat/session-tree requires ?sessionId=" }, { status: 400 });
39753
+ const parsedSessionId = SessionIdSchema.safeParse(sessionId);
39754
+ if (!parsedSessionId.success) return Response.json({ message: "Invalid session id" }, { status: 400 });
39755
+ const access = await requireReadableSession(parsedSessionId.data);
39756
+ if (!access.ok) return access.response;
39757
+ const snapshot2 = await getBridge().readSessionTreeSnapshot(parsedSessionId.data);
39758
+ return Response.json(SessionTreeSnapshotResponseSchema.parse({ snapshot: snapshot2 }));
39759
+ }, request);
39760
+ }
39761
+ function handleChatSessionTreeNavigatePost(request) {
39762
+ return wrapApiHandler(async () => {
39763
+ const body = SessionTreeNavigateRequestSchema.parse(await request.json().catch(() => ({})));
39764
+ const access = await requireWritableSession(body.sessionId);
39765
+ if (!access.ok) return access.response;
39766
+ try {
39767
+ const snapshot2 = await getBridge().navigateSessionTree(body.sessionId, body.targetEntryId, body.expectedLeafId);
39768
+ return Response.json(SessionTreeNavigateResponseSchema.parse({ snapshot: snapshot2 }));
39769
+ } catch (error) {
39770
+ if (error instanceof SessionTreeConcurrencyError || error instanceof SessionTreeCancelledError) return Response.json({ message: error.message }, { status: error.status });
39771
+ throw error;
39772
+ }
36664
39773
  }, request);
36665
39774
  }
36666
39775
  function canonicalizePath(path) {
@@ -36864,188 +39973,179 @@ function handleWorkspaceTreeGet(_request) {
36864
39973
  });
36865
39974
  }, _request);
36866
39975
  }
36867
- var Route$27 = createFileRoute("/api/chat")({ server: { handlers: { POST: ({ request }) => handleChatPost(request) } } });
36868
- var Route$26 = createFileRoute("/api/health")({ server: { handlers: { GET: ({ request }) => handleHealthGet(request) } } });
36869
- var Route$25 = createFileRoute("/api/projects")({ server: { handlers: {
39976
+ var Route$25 = createFileRoute("/api/chat")({ server: { handlers: { POST: ({ request }) => handleChatPost(request) } } });
39977
+ var Route$24 = createFileRoute("/api/health")({ server: { handlers: { GET: ({ request }) => handleHealthGet(request) } } });
39978
+ var Route$23 = createFileRoute("/api/projects")({ server: { handlers: {
36870
39979
  DELETE: ({ request }) => handleProjectDelete(request),
36871
39980
  GET: ({ request }) => handleProjectsGet(request),
36872
39981
  PATCH: ({ request }) => handleProjectPatch(request),
36873
39982
  POST: ({ request }) => handleProjectsPost(request)
36874
39983
  } } });
36875
- var Route$24 = createFileRoute("/api/chat/abort")({ server: { handlers: { POST: ({ request }) => handleChatAbortPost(request) } } });
36876
- var Route$23 = createFileRoute("/api/chat/artifacts")({ server: { handlers: { PUT: ({ request }) => handleChatOpenUIArtifactPut(request) } } });
36877
- var Route$22 = createFileRoute("/api/chat/command")({ server: { handlers: { POST: ({ request }) => handleChatCommandPost(request) } } });
36878
- var Route$21 = createFileRoute("/api/chat/commands")({ server: { handlers: { GET: ({ request }) => handleChatCommandsGet(request) } } });
36879
- var Route$20 = createFileRoute("/api/chat/events")({ server: { handlers: { GET: ({ request }) => handleChatEventsGet(request) } } });
36880
- var Route$19 = createFileRoute("/api/chat/mcp")({ server: { handlers: {
39984
+ var Route$22 = createFileRoute("/api/chat/abort")({ server: { handlers: { POST: ({ request }) => handleChatAbortPost(request) } } });
39985
+ var Route$21 = createFileRoute("/api/chat/artifacts")({ server: { handlers: { PUT: ({ request }) => handleChatOpenUIArtifactPut(request) } } });
39986
+ var Route$20 = createFileRoute("/api/chat/command")({ server: { handlers: { POST: ({ request }) => handleChatCommandPost(request) } } });
39987
+ var Route$19 = createFileRoute("/api/chat/commands")({ server: { handlers: { GET: ({ request }) => handleChatCommandsGet(request) } } });
39988
+ var Route$18 = createFileRoute("/api/chat/events")({ server: { handlers: { GET: ({ request }) => handleChatEventsGet(request) } } });
39989
+ var Route$17 = createFileRoute("/api/chat/mcp")({ server: { handlers: {
36881
39990
  GET: ({ request }) => handleChatMcpGet(request),
36882
39991
  POST: ({ request }) => handleChatMcpPost(request),
36883
39992
  DELETE: ({ request }) => handleChatMcpDelete(request)
36884
39993
  } } });
36885
- var Route$18 = createFileRoute("/api/chat/model")({ server: { handlers: { POST: ({ request }) => handleChatModelPost(request) } } });
36886
- var Route$17 = createFileRoute("/api/chat/models")({ server: { handlers: { GET: ({ request }) => handleChatModelsGet(request) } } });
36887
- var Route$16 = createFileRoute("/api/chat/new")({ server: { handlers: { POST: ({ request }) => handleChatNewPost(request) } } });
36888
- var Route$15 = createFileRoute("/api/chat/providers")({ server: { handlers: {
39994
+ var Route$16 = createFileRoute("/api/chat/models")({ server: { handlers: { GET: ({ request }) => handleChatModelsGet(request) } } });
39995
+ var Route$15 = createFileRoute("/api/chat/new")({ server: { handlers: { POST: ({ request }) => handleChatNewPost(request) } } });
39996
+ var Route$14 = createFileRoute("/api/chat/providers")({ server: { handlers: {
36889
39997
  GET: ({ request }) => handleChatProvidersGet(request),
36890
39998
  POST: ({ request }) => handleChatProvidersPost(request),
36891
39999
  DELETE: ({ request }) => handleChatProvidersDelete(request)
36892
40000
  } } });
36893
- var Route$14 = createFileRoute("/api/chat/question")({ server: { handlers: { POST: ({ request }) => handleChatQuestionPost(request) } } });
36894
- var Route$13 = createFileRoute("/api/chat/resources")({ server: { handlers: { GET: ({ request }) => handleChatResourcesGet(request) } } });
36895
- var Route$12 = createFileRoute("/api/chat/resume")({ server: { handlers: { POST: ({ request }) => handleChatResumePost(request) } } });
36896
- var Route$11 = createFileRoute("/api/chat/session")({ server: { handlers: {
40001
+ var Route$13 = createFileRoute("/api/chat/question")({ server: { handlers: { POST: ({ request }) => handleChatQuestionPost(request) } } });
40002
+ var Route$12 = createFileRoute("/api/chat/resources")({ server: { handlers: { GET: ({ request }) => handleChatResourcesGet(request) } } });
40003
+ var Route$11 = createFileRoute("/api/chat/resume")({ server: { handlers: { POST: ({ request }) => handleChatResumePost(request) } } });
40004
+ var Route$10 = createFileRoute("/api/chat/session")({ server: { handlers: {
36897
40005
  GET: ({ request }) => new URL(request.url).searchParams.has("attachmentId") ? handleChatAttachmentGet(request) : handleChatSessionGet(request),
36898
40006
  POST: ({ request }) => handleChatAttachmentsPost(request),
36899
40007
  PUT: ({ request }) => handleChatPlanPresentationPut(request),
36900
40008
  PATCH: ({ request }) => handleChatQueueMutationPost(request)
36901
40009
  } } });
36902
- var Route$10 = createFileRoute("/api/chat/sessions")({ server: { handlers: {
40010
+ var Route$9 = createFileRoute("/api/chat/session-tree")({ server: { handlers: {
40011
+ GET: ({ request }) => handleChatSessionTreeGet(request),
40012
+ POST: ({ request }) => handleChatSessionTreeNavigatePost(request)
40013
+ } } });
40014
+ var Route$8 = createFileRoute("/api/chat/sessions")({ server: { handlers: {
36903
40015
  DELETE: ({ request }) => handleChatSessionDelete(request),
36904
40016
  GET: ({ request }) => handleChatSessionsGet(request),
36905
40017
  PATCH: ({ request }) => handleChatSessionRenamePatch(request)
36906
40018
  } } });
36907
- var Route$9 = createFileRoute("/api/chat/settings")({ server: { handlers: {
40019
+ var Route$7 = createFileRoute("/api/chat/settings")({ server: { handlers: {
36908
40020
  GET: ({ request }) => handleChatSettingsGet(request),
36909
40021
  PATCH: ({ request }) => handleChatSettingsPatch(request)
36910
40022
  } } });
36911
- var Route$8 = createFileRoute("/api/projects/browse")({ server: { handlers: { GET: ({ request }) => handleProjectBrowseGet(request) } } });
36912
- var Route$7 = createFileRoute("/api/projects/fork")({ server: { handlers: { POST: ({ request }) => handleProjectSessionFork(request) } } });
36913
- var Route$6 = createFileRoute("/api/workspace/browse")({ server: { handlers: { GET: ({ request }) => handleWorkspaceBrowseGet(request) } } });
36914
- var Route$5 = createFileRoute("/api/workspace/file")({ server: { handlers: { GET: ({ request }) => handleWorkspaceFileGet(request) } } });
36915
- var Route$4 = createFileRoute("/api/workspace/root")({ server: { handlers: { POST: () => Response.json({ message: "The workspace root is fixed when Fleet starts" }, { status: 405 }) } } });
40023
+ var Route$6 = createFileRoute("/api/projects/browse")({ server: { handlers: { GET: ({ request }) => handleProjectBrowseGet(request) } } });
40024
+ var Route$5 = createFileRoute("/api/projects/fork")({ server: { handlers: { POST: ({ request }) => handleProjectSessionFork(request) } } });
40025
+ var Route$4 = createFileRoute("/api/workspace/file")({ server: { handlers: { GET: ({ request }) => handleWorkspaceFileGet(request) } } });
36916
40026
  var Route$3 = createFileRoute("/api/workspace/tree")({ server: { handlers: { GET: ({ request }) => handleWorkspaceTreeGet(request) } } });
36917
40027
  var Route$2 = createFileRoute("/api/chat/mcp/oauth")({ server: { handlers: { POST: ({ request }) => handleChatMcpOAuthPost(request) } } });
36918
40028
  var Route$1 = createFileRoute("/api/chat/models/discover")({ server: { handlers: { POST: ({ request }) => handleChatModelsDiscoverPost(request) } } });
36919
40029
  var Route = createFileRoute("/api/chat/providers/oauth")({ server: { handlers: { POST: ({ request }) => handleChatProvidersOAuthPost(request) } } });
36920
- var IndexRoute = Route$28.update({
40030
+ var IndexRoute = Route$26.update({
36921
40031
  id: "/",
36922
40032
  path: "/",
36923
- getParentRoute: () => Route$29
40033
+ getParentRoute: () => Route$27
36924
40034
  });
36925
- var ApiChatRoute = Route$27.update({
40035
+ var ApiChatRoute = Route$25.update({
36926
40036
  id: "/api/chat",
36927
40037
  path: "/api/chat",
36928
- getParentRoute: () => Route$29
40038
+ getParentRoute: () => Route$27
36929
40039
  });
36930
- var ApiHealthRoute = Route$26.update({
40040
+ var ApiHealthRoute = Route$24.update({
36931
40041
  id: "/api/health",
36932
40042
  path: "/api/health",
36933
- getParentRoute: () => Route$29
40043
+ getParentRoute: () => Route$27
36934
40044
  });
36935
- var ApiProjectsRoute = Route$25.update({
40045
+ var ApiProjectsRoute = Route$23.update({
36936
40046
  id: "/api/projects",
36937
40047
  path: "/api/projects",
36938
- getParentRoute: () => Route$29
40048
+ getParentRoute: () => Route$27
36939
40049
  });
36940
- var ApiChatAbortRoute = Route$24.update({
40050
+ var ApiChatAbortRoute = Route$22.update({
36941
40051
  id: "/abort",
36942
40052
  path: "/abort",
36943
40053
  getParentRoute: () => ApiChatRoute
36944
40054
  });
36945
- var ApiChatArtifactsRoute = Route$23.update({
40055
+ var ApiChatArtifactsRoute = Route$21.update({
36946
40056
  id: "/artifacts",
36947
40057
  path: "/artifacts",
36948
40058
  getParentRoute: () => ApiChatRoute
36949
40059
  });
36950
- var ApiChatCommandRoute = Route$22.update({
40060
+ var ApiChatCommandRoute = Route$20.update({
36951
40061
  id: "/command",
36952
40062
  path: "/command",
36953
40063
  getParentRoute: () => ApiChatRoute
36954
40064
  });
36955
- var ApiChatCommandsRoute = Route$21.update({
40065
+ var ApiChatCommandsRoute = Route$19.update({
36956
40066
  id: "/commands",
36957
40067
  path: "/commands",
36958
40068
  getParentRoute: () => ApiChatRoute
36959
40069
  });
36960
- var ApiChatEventsRoute = Route$20.update({
40070
+ var ApiChatEventsRoute = Route$18.update({
36961
40071
  id: "/events",
36962
40072
  path: "/events",
36963
40073
  getParentRoute: () => ApiChatRoute
36964
40074
  });
36965
- var ApiChatMcpRoute = Route$19.update({
40075
+ var ApiChatMcpRoute = Route$17.update({
36966
40076
  id: "/mcp",
36967
40077
  path: "/mcp",
36968
40078
  getParentRoute: () => ApiChatRoute
36969
40079
  });
36970
- var ApiChatModelRoute = Route$18.update({
36971
- id: "/model",
36972
- path: "/model",
36973
- getParentRoute: () => ApiChatRoute
36974
- });
36975
- var ApiChatModelsRoute = Route$17.update({
40080
+ var ApiChatModelsRoute = Route$16.update({
36976
40081
  id: "/models",
36977
40082
  path: "/models",
36978
40083
  getParentRoute: () => ApiChatRoute
36979
40084
  });
36980
- var ApiChatNewRoute = Route$16.update({
40085
+ var ApiChatNewRoute = Route$15.update({
36981
40086
  id: "/new",
36982
40087
  path: "/new",
36983
40088
  getParentRoute: () => ApiChatRoute
36984
40089
  });
36985
- var ApiChatProvidersRoute = Route$15.update({
40090
+ var ApiChatProvidersRoute = Route$14.update({
36986
40091
  id: "/providers",
36987
40092
  path: "/providers",
36988
40093
  getParentRoute: () => ApiChatRoute
36989
40094
  });
36990
- var ApiChatQuestionRoute = Route$14.update({
40095
+ var ApiChatQuestionRoute = Route$13.update({
36991
40096
  id: "/question",
36992
40097
  path: "/question",
36993
40098
  getParentRoute: () => ApiChatRoute
36994
40099
  });
36995
- var ApiChatResourcesRoute = Route$13.update({
40100
+ var ApiChatResourcesRoute = Route$12.update({
36996
40101
  id: "/resources",
36997
40102
  path: "/resources",
36998
40103
  getParentRoute: () => ApiChatRoute
36999
40104
  });
37000
- var ApiChatResumeRoute = Route$12.update({
40105
+ var ApiChatResumeRoute = Route$11.update({
37001
40106
  id: "/resume",
37002
40107
  path: "/resume",
37003
40108
  getParentRoute: () => ApiChatRoute
37004
40109
  });
37005
- var ApiChatSessionRoute = Route$11.update({
40110
+ var ApiChatSessionRoute = Route$10.update({
37006
40111
  id: "/session",
37007
40112
  path: "/session",
37008
40113
  getParentRoute: () => ApiChatRoute
37009
40114
  });
37010
- var ApiChatSessionsRoute = Route$10.update({
40115
+ var ApiChatSessionTreeRoute = Route$9.update({
40116
+ id: "/session-tree",
40117
+ path: "/session-tree",
40118
+ getParentRoute: () => ApiChatRoute
40119
+ });
40120
+ var ApiChatSessionsRoute = Route$8.update({
37011
40121
  id: "/sessions",
37012
40122
  path: "/sessions",
37013
40123
  getParentRoute: () => ApiChatRoute
37014
40124
  });
37015
- var ApiChatSettingsRoute = Route$9.update({
40125
+ var ApiChatSettingsRoute = Route$7.update({
37016
40126
  id: "/settings",
37017
40127
  path: "/settings",
37018
40128
  getParentRoute: () => ApiChatRoute
37019
40129
  });
37020
- var ApiProjectsBrowseRoute = Route$8.update({
40130
+ var ApiProjectsBrowseRoute = Route$6.update({
37021
40131
  id: "/browse",
37022
40132
  path: "/browse",
37023
40133
  getParentRoute: () => ApiProjectsRoute
37024
40134
  });
37025
- var ApiProjectsForkRoute = Route$7.update({
40135
+ var ApiProjectsForkRoute = Route$5.update({
37026
40136
  id: "/fork",
37027
40137
  path: "/fork",
37028
40138
  getParentRoute: () => ApiProjectsRoute
37029
40139
  });
37030
- var ApiWorkspaceBrowseRoute = Route$6.update({
37031
- id: "/api/workspace/browse",
37032
- path: "/api/workspace/browse",
37033
- getParentRoute: () => Route$29
37034
- });
37035
- var ApiWorkspaceFileRoute = Route$5.update({
40140
+ var ApiWorkspaceFileRoute = Route$4.update({
37036
40141
  id: "/api/workspace/file",
37037
40142
  path: "/api/workspace/file",
37038
- getParentRoute: () => Route$29
37039
- });
37040
- var ApiWorkspaceRootRoute = Route$4.update({
37041
- id: "/api/workspace/root",
37042
- path: "/api/workspace/root",
37043
- getParentRoute: () => Route$29
40143
+ getParentRoute: () => Route$27
37044
40144
  });
37045
40145
  var ApiWorkspaceTreeRoute = Route$3.update({
37046
40146
  id: "/api/workspace/tree",
37047
40147
  path: "/api/workspace/tree",
37048
- getParentRoute: () => Route$29
40148
+ getParentRoute: () => Route$27
37049
40149
  });
37050
40150
  var ApiChatMcpOauthRoute = Route$2.update({
37051
40151
  id: "/oauth",
@@ -37074,7 +40174,6 @@ var ApiChatRouteChildren = {
37074
40174
  ApiChatCommandsRoute,
37075
40175
  ApiChatEventsRoute,
37076
40176
  ApiChatMcpRoute: ApiChatMcpRouteWithChildren,
37077
- ApiChatModelRoute,
37078
40177
  ApiChatModelsRoute: ApiChatModelsRouteWithChildren,
37079
40178
  ApiChatNewRoute,
37080
40179
  ApiChatProvidersRoute: ApiChatProvidersRoute._addFileChildren(ApiChatProvidersRouteChildren),
@@ -37082,6 +40181,7 @@ var ApiChatRouteChildren = {
37082
40181
  ApiChatResourcesRoute,
37083
40182
  ApiChatResumeRoute,
37084
40183
  ApiChatSessionRoute,
40184
+ ApiChatSessionTreeRoute,
37085
40185
  ApiChatSessionsRoute,
37086
40186
  ApiChatSettingsRoute
37087
40187
  };
@@ -37095,12 +40195,10 @@ var rootRouteChildren = {
37095
40195
  ApiChatRoute: ApiChatRouteWithChildren,
37096
40196
  ApiHealthRoute,
37097
40197
  ApiProjectsRoute: ApiProjectsRoute._addFileChildren(ApiProjectsRouteChildren),
37098
- ApiWorkspaceBrowseRoute,
37099
40198
  ApiWorkspaceFileRoute,
37100
- ApiWorkspaceRootRoute,
37101
40199
  ApiWorkspaceTreeRoute
37102
40200
  };
37103
- var routeTree = Route$29._addFileChildren(rootRouteChildren)._addFileTypes();
40201
+ var routeTree = Route$27._addFileChildren(rootRouteChildren)._addFileTypes();
37104
40202
  function getRouter() {
37105
40203
  return createRouter({
37106
40204
  routeTree,