@vite-hub/ui 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (360) hide show
  1. package/README.md +102 -76
  2. package/dist/andromeeda-DaUPZ4_A.js +147 -0
  3. package/dist/announce-B0DLwflT.js +31 -0
  4. package/dist/{attachments-BzTwqRTU.js → attachments-DgwoQZKY.js} +3 -5
  5. package/dist/aurora-x-B5RPZ9i5.js +162 -0
  6. package/dist/{avatar-stack-DPRFuezh.d.ts → avatar-stack-C0IKwj6g.d.ts} +1 -3
  7. package/dist/ayu-dark-DXTaGA7I.js +137 -0
  8. package/dist/ayu-light-BCYi80Fe.js +137 -0
  9. package/dist/ayu-mirage-CgbXz-N5.js +137 -0
  10. package/dist/catppuccin-frappe-MV2xzv44.js +266 -0
  11. package/dist/catppuccin-latte-CL6jjlVD.js +266 -0
  12. package/dist/catppuccin-macchiato-Bp6oZJVK.js +266 -0
  13. package/dist/catppuccin-mocha-DOHrQ4dw.js +266 -0
  14. package/dist/{choices-input-ByXJvDn1.d.ts → choices-input-BUf-QqGj.d.ts} +0 -2
  15. package/dist/{code-view-DsU-xzic.js → code-view-Cg4nyTNA.js} +6 -8
  16. package/dist/{colors-BghReA9C-CjF9gnmy.js → colors-BghReA9C-DEq4bhEP.js} +1 -2
  17. package/dist/{comment-attachments-C4yNbcx5.js → comment-attachments-CMpYOJod.js} +1 -2
  18. package/dist/{comment-composer-fINL5bxo.d.ts → comment-composer-BI6CNJyO.d.ts} +3 -5
  19. package/dist/{comment-composer-jYv2ULNP.js → comment-composer-CzU7DdfD.js} +260 -16
  20. package/dist/{comment-layer-C_sbPIR5.d.ts → comment-layer-DyVstrs-.d.ts} +5 -7
  21. package/dist/{comment-list-BcSaLngS.d.ts → comment-list-CSK5o-Ua.d.ts} +3 -5
  22. package/dist/comment-marks.css +18 -22
  23. package/dist/{comment-panel-CfvdRUMX.d.ts → comment-panel-CEvOI3gk.d.ts} +3 -5
  24. package/dist/{comment-person-CLPlW_SS.js → comment-person-D_IyIjXo.js} +1 -2
  25. package/dist/{comment-pin-DHOdRvUw.d.ts → comment-pin-C5UeLPTa.d.ts} +1 -3
  26. package/dist/{comment-row-Bn3nr8l5.js → comment-row-DPMWI5Z0.js} +3 -4
  27. package/dist/{comment-selection-bar-CyVBNYl9.d.ts → comment-selection-bar-CVuS-FNL.d.ts} +0 -2
  28. package/dist/comment-send-DPzV9B8S.js +275 -0
  29. package/dist/comment-send-MmxFsOQf.d.ts +23 -0
  30. package/dist/comment-send.css +267 -0
  31. package/dist/comment-thread-CbPtoi8-.js +796 -0
  32. package/dist/{comment-thread-DKJjmWN0.d.ts → comment-thread-DGm1cGJt.d.ts} +4 -8
  33. package/dist/{comment-visibility-DsVuVndP.d.ts → comment-visibility-CYctacNx.d.ts} +0 -2
  34. package/dist/{comments-D0d26ghV.js → comments-C0OdHh_F.js} +5 -8
  35. package/dist/{comments-D8hulVPy.d.ts → comments-DrE9DU-E.d.ts} +1 -3
  36. package/dist/{comments-context-C2lOZyQ5.js → comments-context-CrjhleVA.js} +4 -5
  37. package/dist/{config-Dk67emQt.js → config-DztmAYYn.js} +9 -3
  38. package/dist/{config-DgxBW013.d.ts → config-xL4EBeXw.d.ts} +11 -4
  39. package/dist/dark-plus-CXEBSjk4.js +148 -0
  40. package/dist/dracula-Bvyz6eCo.js +165 -0
  41. package/dist/dracula-soft-a9indxAQ.js +115 -0
  42. package/dist/{draw-DzSmD7uo-Dwz8zoH2.js → draw-DzSmD7uo-Cb7s9kxJ.js} +359 -708
  43. package/dist/drop-field-CNZgwFVO.js +162 -0
  44. package/dist/{editor-C_wt4RRV.js → editor-CGiEVOnB.js} +44 -6
  45. package/dist/effects-g4QucvgO.js +2955 -0
  46. package/dist/{error-diagnostics-SXtnk6bz.js → error-diagnostics-BlgA9rI2.js} +1 -2
  47. package/dist/everforest-dark-9sVAxG7I.js +99 -0
  48. package/dist/everforest-light-BocTn_Hd.js +99 -0
  49. package/dist/{file-tree-C4OYgbV-.js → file-tree-CRFIdtzw.js} +58 -116
  50. package/dist/{file-tree-DlT9RGhu.d.ts → file-tree-DOtkeBaq.d.ts} +0 -14
  51. package/dist/{format-orwcdZL_.js → format-Bc9m7-r0.js} +1 -2
  52. package/dist/{getSingularPatch-Dsb8EgxR.js → getSingularPatch-C7LmmBrW.js} +375 -79
  53. package/dist/github-dark-BO9SXswM.js +142 -0
  54. package/dist/github-dark-default-XB_RHfBI.js +90 -0
  55. package/dist/github-dark-dimmed-BoGxaWUQ.js +137 -0
  56. package/dist/github-dark-high-contrast-B3X6t2fG.js +137 -0
  57. package/dist/github-light-D7VHHlUH.js +142 -0
  58. package/dist/github-light-default-BuDsGtcR.js +137 -0
  59. package/dist/github-light-high-contrast-GodZiAwh.js +137 -0
  60. package/dist/gruvbox-dark-hard-CU4LuKJc.js +140 -0
  61. package/dist/gruvbox-dark-medium-DjAsuXuH.js +140 -0
  62. package/dist/gruvbox-dark-soft-D3Zttj6R.js +140 -0
  63. package/dist/gruvbox-light-hard-4M_9onwE.js +140 -0
  64. package/dist/gruvbox-light-medium-D9QwS4kQ.js +140 -0
  65. package/dist/gruvbox-light-soft-DhYcfQql.js +140 -0
  66. package/dist/{handlers-DMl-Na3x.js → handlers-CnbkvXjX.js} +1 -2
  67. package/dist/headless.d.ts +4 -4
  68. package/dist/headless.js +1 -1
  69. package/dist/highlights-C2AbEdDI.js +2630 -0
  70. package/dist/hold-to-delete-BSMrpE-i.d.ts +49 -0
  71. package/dist/hold-to-delete-Cludb56v.js +433 -0
  72. package/dist/horizon-bright-B9u59onx.js +97 -0
  73. package/dist/horizon-tItY9ATR.js +97 -0
  74. package/dist/houston-BqKrKNQv.js +207 -0
  75. package/dist/icon-XZaCUZTG.d.ts +29 -0
  76. package/dist/{image-preview-C9tdkmEj.js → image-preview-DrLXrHpp.js} +3 -4
  77. package/dist/{index-CNY1uNTh.d.ts → index-B2cbt3py.d.ts} +3945 -2445
  78. package/dist/{index-BYRFQfCd.d.ts → index-B_PSX-5h.d.ts} +5 -11
  79. package/dist/index.d.ts +35 -32
  80. package/dist/index.js +71 -73
  81. package/dist/install-Ba9mkkqI.js +16 -0
  82. package/dist/kanagawa-dragon-BH1K3aMw.js +159 -0
  83. package/dist/kanagawa-lotus-C-4JB2io.js +159 -0
  84. package/dist/kanagawa-wave-DTQqNe5k.js +159 -0
  85. package/dist/laserwave-BkV0uIaG.js +84 -0
  86. package/dist/light-plus-CxYgEz7U.js +149 -0
  87. package/dist/list-DUTAo0uC.js +270 -0
  88. package/dist/loader-CYMEjzwc.js +79 -0
  89. package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-3gY9MLvy.js} +237 -38
  90. package/dist/{markdown-editor-wQF0yD5o.d.ts → markdown-editor-B7gD60tp.d.ts} +0 -6
  91. package/dist/markdown-editor.d.ts +1 -5
  92. package/dist/markdown-editor.js +2 -2
  93. package/dist/markdown-renderer-DFS1vf1h.js +26578 -0
  94. package/dist/material-theme-Xdm37UUJ.js +105 -0
  95. package/dist/material-theme-darker-Blaz0cgN.js +105 -0
  96. package/dist/material-theme-lighter-BddVxBVA.js +105 -0
  97. package/dist/material-theme-ocean-C4qhfFHi.js +105 -0
  98. package/dist/material-theme-palenight-ChHDqoiA.js +105 -0
  99. package/dist/{message-scroller-jrYN9dG9.d.ts → message-scroller-a6qaYHno.d.ts} +2 -4
  100. package/dist/min-dark-DpGSNjaW.js +125 -0
  101. package/dist/min-light-BMfJUsU2.js +122 -0
  102. package/dist/monokai-DW19E-zg.js +162 -0
  103. package/dist/motion/core.d.ts +4 -0
  104. package/dist/motion/core.js +11 -0
  105. package/dist/motion-core-DNl7TR1T.d.ts +402 -0
  106. package/dist/motion.d.ts +14 -0
  107. package/dist/motion.js +13 -0
  108. package/dist/night-owl-B7Of8ee9.js +188 -0
  109. package/dist/night-owl-light-Vu9tTNpS.js +189 -0
  110. package/dist/nord-CDzJumeN.js +128 -0
  111. package/dist/nuxt-ui-7ByUrymx.js +43 -0
  112. package/dist/nuxt.d.ts +1 -7
  113. package/dist/nuxt.js +16 -11
  114. package/dist/one-dark-pro-hS_sNo5p.js +124 -0
  115. package/dist/one-light-CD4ItzSC.js +153 -0
  116. package/dist/opt-out-D66l60sg.js +205 -0
  117. package/dist/parts/components/agent-session.d.ts +1 -3
  118. package/dist/parts/components/agent-session.js +3 -4
  119. package/dist/parts/components/attachment.d.ts +2 -4
  120. package/dist/parts/components/attachment.js +3 -4
  121. package/dist/parts/components/avatar-stack.d.ts +1 -1
  122. package/dist/parts/components/avatar-stack.js +4 -4
  123. package/dist/parts/components/bubble.d.ts +2 -4
  124. package/dist/parts/components/bubble.js +2 -3
  125. package/dist/parts/components/chat-message.d.ts +1 -3
  126. package/dist/parts/components/chat-message.js +1 -2
  127. package/dist/parts/components/chat-session.d.ts +2 -4
  128. package/dist/parts/components/chat-session.js +1 -2
  129. package/dist/parts/components/chat.d.ts +1 -3
  130. package/dist/parts/components/chat.js +4 -5
  131. package/dist/parts/components/code-block.d.ts +2 -4
  132. package/dist/parts/components/code-block.js +3 -4
  133. package/dist/parts/components/code-view.d.ts +1 -3
  134. package/dist/parts/components/code-view.js +1 -2
  135. package/dist/parts/components/comment-composer.d.ts +1 -1
  136. package/dist/parts/components/comment-composer.js +1 -2
  137. package/dist/parts/components/comment-layer.d.ts +1 -1
  138. package/dist/parts/components/comment-layer.js +28 -11
  139. package/dist/parts/components/comment-list.d.ts +1 -1
  140. package/dist/parts/components/comment-list.js +13 -9
  141. package/dist/parts/components/comment-panel.d.ts +1 -1
  142. package/dist/parts/components/comment-panel.js +27 -14
  143. package/dist/parts/components/comment-pin.d.ts +1 -1
  144. package/dist/parts/components/comment-pin.js +2 -3
  145. package/dist/parts/components/comment-selection-bar.d.ts +1 -1
  146. package/dist/parts/components/comment-selection-bar.js +4 -4
  147. package/dist/parts/components/comment-send.d.ts +2 -0
  148. package/dist/parts/components/comment-send.js +1 -0
  149. package/dist/parts/components/comment-thread.d.ts +1 -1
  150. package/dist/parts/components/comment-thread.js +2 -597
  151. package/dist/parts/components/comments.d.ts +9 -8
  152. package/dist/parts/components/comments.js +7 -6
  153. package/dist/parts/components/connection-status.d.ts +1 -3
  154. package/dist/parts/components/connection-status.js +1 -2
  155. package/dist/parts/components/copy-button.d.ts +14 -6
  156. package/dist/parts/components/copy-button.js +225 -1
  157. package/dist/parts/components/device-frame.d.ts +3 -5
  158. package/dist/parts/components/device-frame.js +1 -2
  159. package/dist/parts/components/drop-field.d.ts +67 -0
  160. package/dist/parts/components/drop-field.js +76 -0
  161. package/dist/parts/components/file-tree.d.ts +1 -1
  162. package/dist/parts/components/file-tree.js +1 -2
  163. package/dist/parts/components/filter-search.d.ts +2 -4
  164. package/dist/parts/components/filter-search.js +2 -3
  165. package/dist/parts/components/hold-to-delete.d.ts +80 -0
  166. package/dist/parts/components/hold-to-delete.js +75 -0
  167. package/dist/parts/components/markdown-editor.d.ts +1 -1
  168. package/dist/parts/components/markdown-editor.js +1 -2
  169. package/dist/parts/components/markdown-renderer.d.ts +1 -3
  170. package/dist/parts/components/markdown-renderer.js +1 -23077
  171. package/dist/parts/components/markdown.d.ts +1 -3
  172. package/dist/parts/components/markdown.js +2 -3
  173. package/dist/parts/components/marker.d.ts +2 -4
  174. package/dist/parts/components/marker.js +2 -3
  175. package/dist/parts/components/message-parts.d.ts +1 -3
  176. package/dist/parts/components/message-parts.js +14 -7
  177. package/dist/parts/components/message.d.ts +1 -3
  178. package/dist/parts/components/message.js +2 -3
  179. package/dist/parts/components/motion-list.d.ts +40 -0
  180. package/dist/parts/components/motion-list.js +41 -0
  181. package/dist/parts/components/motion.d.ts +122 -0
  182. package/dist/parts/components/motion.js +171 -0
  183. package/dist/parts/components/patch-parsers.d.ts +1 -1
  184. package/dist/parts/components/patch-parsers.js +1 -2
  185. package/dist/parts/components/progress.d.ts +39 -0
  186. package/dist/parts/components/progress.js +53 -0
  187. package/dist/parts/components/prompt-input.d.ts +5 -7
  188. package/dist/parts/components/prompt-input.js +5 -6
  189. package/dist/parts/components/relative-time.d.ts +1 -3
  190. package/dist/parts/components/relative-time.js +1 -2
  191. package/dist/parts/components/status.d.ts +1 -3
  192. package/dist/parts/components/status.js +1 -2
  193. package/dist/parts/components/sync-status.d.ts +1 -3
  194. package/dist/parts/components/sync-status.js +3 -3
  195. package/dist/parts/components/tool-list.d.ts +2 -4
  196. package/dist/parts/components/tool-list.js +2 -3
  197. package/dist/parts/components/trace-run.d.ts +2 -4
  198. package/dist/parts/components/trace-run.js +4 -5
  199. package/dist/parts/components/trace.d.ts +2 -4
  200. package/dist/parts/components/trace.js +2 -3
  201. package/dist/parts/composables/attachments.d.ts +1 -3
  202. package/dist/parts/composables/attachments.js +1 -2
  203. package/dist/parts/composables/highlighted-code.d.ts +1 -3
  204. package/dist/parts/composables/highlighted-code.js +1 -2
  205. package/dist/parts/headless/choices-input.d.ts +1 -1
  206. package/dist/parts/headless/choices-input.js +3 -4
  207. package/dist/parts/headless/comment-visibility.d.ts +1 -1
  208. package/dist/parts/headless/comment-visibility.js +1 -2
  209. package/dist/parts/headless/comments.d.ts +1 -1
  210. package/dist/parts/headless/comments.js +1 -2
  211. package/dist/parts/headless/message-scroller.d.ts +1 -1
  212. package/dist/parts/headless/message-scroller.js +2 -3
  213. package/dist/parts/playground/paths.d.ts +1 -3
  214. package/dist/parts/playground/paths.js +1 -2
  215. package/dist/parts/playground/share.d.ts +34 -2
  216. package/dist/parts/playground/share.js +1 -2
  217. package/dist/parts/playground/zip.d.ts +1 -3
  218. package/dist/parts/playground/zip.js +2 -3
  219. package/dist/parts/workspace/browser-support-notice.d.ts +2 -4
  220. package/dist/parts/workspace/browser-support-notice.js +13 -6
  221. package/dist/parts/workspace/codemirror.d.ts +10 -3
  222. package/dist/parts/workspace/codemirror.js +40 -8
  223. package/dist/parts/workspace/connect-panel.d.ts +2 -4
  224. package/dist/parts/workspace/connect-panel.js +2 -3
  225. package/dist/parts/workspace/connect-store.d.ts +1 -3
  226. package/dist/parts/workspace/connect-store.js +1 -2
  227. package/dist/parts/workspace/file-icons.d.ts +14 -0
  228. package/dist/parts/workspace/file-icons.js +81 -0
  229. package/dist/parts/workspace/icons.d.ts +2 -2
  230. package/dist/parts/workspace/icons.js +2 -2
  231. package/dist/parts/workspace/runners/render.d.ts +24 -0
  232. package/dist/parts/workspace/runners/render.js +123 -0
  233. package/dist/parts/workspace/runners/web-container.d.ts +27 -0
  234. package/dist/parts/workspace/runners/web-container.js +185 -0
  235. package/dist/parts/workspace/workspace-bar.d.ts +49 -0
  236. package/dist/parts/workspace/workspace-bar.js +50 -0
  237. package/dist/parts/workspace/workspace-boot-status.d.ts +1 -2
  238. package/dist/parts/workspace/workspace-boot-status.js +2 -3
  239. package/dist/parts/workspace/workspace-editor-head.d.ts +45 -0
  240. package/dist/parts/workspace/workspace-editor-head.js +65 -0
  241. package/dist/parts/workspace/workspace-editor.d.ts +18 -3
  242. package/dist/parts/workspace/workspace-editor.js +30 -5
  243. package/dist/parts/workspace/workspace-examples.d.ts +72 -0
  244. package/dist/parts/workspace/workspace-examples.js +71 -0
  245. package/dist/parts/workspace/workspace-file-link.d.ts +33 -0
  246. package/dist/parts/workspace/workspace-file-link.js +38 -0
  247. package/dist/parts/workspace/workspace-file-tree.d.ts +9 -11
  248. package/dist/parts/workspace/workspace-file-tree.js +28 -22
  249. package/dist/parts/workspace/workspace-guide.d.ts +50 -0
  250. package/dist/parts/workspace/workspace-guide.js +90 -0
  251. package/dist/parts/workspace/workspace-issues.d.ts +44 -0
  252. package/dist/parts/workspace/workspace-issues.js +48 -0
  253. package/dist/parts/workspace/workspace-preview.d.ts +1 -3
  254. package/dist/parts/workspace/workspace-preview.js +2 -3
  255. package/dist/parts/workspace/workspace-shell.d.ts +2 -88
  256. package/dist/parts/workspace/workspace-shell.js +132 -80
  257. package/dist/parts/workspace/workspace-sidebar.d.ts +73 -0
  258. package/dist/parts/workspace/workspace-sidebar.js +131 -0
  259. package/dist/parts/workspace/workspace-start.d.ts +45 -0
  260. package/dist/parts/workspace/workspace-start.js +59 -0
  261. package/dist/parts/workspace/workspace-status.d.ts +67 -0
  262. package/dist/parts/workspace/workspace-status.js +73 -0
  263. package/dist/parts/workspace/workspace-steps.d.ts +2 -0
  264. package/dist/parts/workspace/workspace-steps.js +127 -0
  265. package/dist/parts/workspace/workspace-task.d.ts +18 -0
  266. package/dist/parts/workspace/workspace-task.js +19 -0
  267. package/dist/parts/workspace/workspace-terminal.d.ts +1 -3
  268. package/dist/parts/workspace/workspace-terminal.js +1 -2
  269. package/dist/parts/workspace/workspace.d.ts +249 -0
  270. package/dist/parts/workspace/workspace.js +664 -0
  271. package/dist/{payload-text-sjkYAwvw.js → payload-text-DQNRbJY5.js} +1 -2
  272. package/dist/{pierre-code-view-NE35tkmR.js → pierre-code-view-C49BVDrc.js} +11333 -6718
  273. package/dist/pierre-dark-BtKHt2e4.js +166 -0
  274. package/dist/pierre-dark-CXW3KeKO.js +5 -0
  275. package/dist/pierre-dark-protanopia-deuteranopia-CS0Gs25Q.js +166 -0
  276. package/dist/pierre-dark-protanopia-deuteranopia-DajNv_A3.js +3 -0
  277. package/dist/pierre-dark-soft-BUFoeBEf.js +3 -0
  278. package/dist/pierre-dark-soft-D__0FtYP.js +166 -0
  279. package/dist/pierre-dark-tritanopia-C6fHROmA.js +166 -0
  280. package/dist/pierre-dark-tritanopia-oa3gpgIR.js +3 -0
  281. package/dist/pierre-dark-vibrant-COXpyAHb.js +166 -0
  282. package/dist/pierre-dark-vibrant-CYRHyDoW.js +3 -0
  283. package/dist/pierre-light-BD28C_vh.js +166 -0
  284. package/dist/pierre-light-BN0rL1e5.js +5 -0
  285. package/dist/pierre-light-protanopia-deuteranopia-CYsDHJt0.js +3 -0
  286. package/dist/pierre-light-protanopia-deuteranopia-CwWH1xGL.js +166 -0
  287. package/dist/pierre-light-soft-BkKY4pMj.js +166 -0
  288. package/dist/pierre-light-soft-F2QIpNbb.js +3 -0
  289. package/dist/pierre-light-tritanopia-BbKKIkua.js +3 -0
  290. package/dist/pierre-light-tritanopia-Mpubahl7.js +166 -0
  291. package/dist/pierre-light-vibrant-CdV9Besm.js +3 -0
  292. package/dist/pierre-light-vibrant-x11J3_aO.js +166 -0
  293. package/dist/plastic-BQnXkmvK.js +137 -0
  294. package/dist/playground.d.ts +1 -1
  295. package/dist/poimandres-DEfG-8RI.js +124 -0
  296. package/dist/progress-DL9k-ERG.js +265 -0
  297. package/dist/red-BfKrAjYG.js +169 -0
  298. package/dist/registry-DAIjCjWd.js +77 -0
  299. package/dist/{relative-time-BVmjOsYG.js → relative-time-DJnw45tr.js} +5 -8
  300. package/dist/ring-BN4d8vtw.js +173 -0
  301. package/dist/{rolldown-runtime-C9mWXvCC.js → rolldown-runtime-CahUhzF3.js} +2 -3
  302. package/dist/rose-pine-D0rhGGFg.js +136 -0
  303. package/dist/rose-pine-dawn-7jVaYUiD.js +136 -0
  304. package/dist/rose-pine-moon-CFyS0Mvu.js +136 -0
  305. package/dist/runtime/nuxt-plugin.d.ts +0 -2
  306. package/dist/runtime/nuxt-plugin.js +3 -4
  307. package/dist/{sankey-CAYwt82B-D4uDQoMR.js → sankey-CAYwt82B-BAAk7WkJ.js} +147 -151
  308. package/dist/shiki-CbfEu_Az.js +607 -0
  309. package/dist/slack-dark-Bv-KFSBD.js +87 -0
  310. package/dist/slack-ochin-Dg2BAv1D.js +107 -0
  311. package/dist/{slot-part-Doic71uh.js → slot-part-BWHvQ3mK.js} +1 -2
  312. package/dist/snazzy-light-sYDdR9rx.js +93 -0
  313. package/dist/solarized-dark-COt2tTmN.js +160 -0
  314. package/dist/solarized-light-BJrwFarZ.js +160 -0
  315. package/dist/stream-tokenizer-ByC3l0HQ.js +263 -0
  316. package/dist/styles.css +590 -573
  317. package/dist/synthwave-84-NUDBykTM.js +410 -0
  318. package/dist/{temml-BilSAAws.js → temml-m3ad3bfq.js} +2 -3
  319. package/dist/text-BWzZFnGY.js +822 -0
  320. package/dist/theme.d.ts +44 -3
  321. package/dist/theme.js +23 -9
  322. package/dist/themes-DKugPHlg.js +323 -0
  323. package/dist/tokyo-night-DD3B2QcO.js +153 -0
  324. package/dist/travel-CwVhU_GS.js +180 -0
  325. package/dist/tween-Dv3IIIQG.js +61 -0
  326. package/dist/{types-Dj7vp0lZ.d.ts → types-Ceh7h7NT.d.ts} +1 -3
  327. package/dist/vesper-oVQYrv8Y.js +99 -0
  328. package/dist/visual-copy-CHHBfJ6O.js +14 -0
  329. package/dist/vite.d.ts +1 -3
  330. package/dist/vite.js +13 -3
  331. package/dist/vitesse-black-D84DQZAP.js +196 -0
  332. package/dist/vitesse-dark-CMZ6olk_.js +196 -0
  333. package/dist/vitesse-light-D9d8hLOY.js +196 -0
  334. package/dist/{vue-DGstVdGn.js → vue-BlknIGIm.js} +43 -34
  335. package/dist/{vue-BDmSCtay.js → vue-kCdzBu0N.js} +4 -7
  336. package/dist/workspace-shell-ChCwWPyv.d.ts +110 -0
  337. package/dist/workspace-steps-BKByX9DW.d.ts +70 -0
  338. package/dist/workspace.d.ts +16 -5
  339. package/dist/workspace.js +16 -3
  340. package/package.json +66 -55
  341. package/dist/copy-button-CRN3kmSD.js +0 -253
  342. package/dist/icon-swap.css +0 -69
  343. package/dist/nuxt-ui-DSQFzq3s.js +0 -38
  344. package/dist/parts/playground/highlight.d.ts +0 -5
  345. package/dist/parts/playground/highlight.js +0 -23
  346. package/dist/parts/playground/playground-render.d.ts +0 -126
  347. package/dist/parts/playground/playground-render.js +0 -356
  348. package/dist/parts/workspace/playground-container.d.ts +0 -192
  349. package/dist/parts/workspace/playground-container.js +0 -603
  350. package/dist/pierre-dark-CzUmjETS.js +0 -6
  351. package/dist/pierre-dark-protanopia-deuteranopia-C35UMuvO.js +0 -4
  352. package/dist/pierre-dark-soft-Bb-4-biO.js +0 -4
  353. package/dist/pierre-dark-tritanopia-CIJISGWF.js +0 -4
  354. package/dist/pierre-dark-vibrant-8oZzB3gw.js +0 -4
  355. package/dist/pierre-light-Dn6E0sWv.js +0 -6
  356. package/dist/pierre-light-protanopia-deuteranopia-u0U7N4Hn.js +0 -4
  357. package/dist/pierre-light-soft-BCU6fuhO.js +0 -4
  358. package/dist/pierre-light-tritanopia-3c8Yx3co.js +0 -4
  359. package/dist/pierre-light-vibrant-Cwh332o_.js +0 -4
  360. package/dist/share-DM4eNy4q.d.ts +0 -37
@@ -0,0 +1,2955 @@
1
+ import { c as offsetIn, d as iconShape, n as morph, o as enterIcon, r as morphTarget, s as leaveIcon, t as discardMorph, u as findIcons } from "./text-BWzZFnGY.js";
2
+ import { i as getMotionSlowFactor, l as onReducedMotionChange, r as createSpring, s as springs, t as isMotionOff, u as prefersReducedMotion } from "./opt-out-D66l60sg.js";
3
+ import { a as listMotionEffects, c as onMotionEffectsChange, i as handOffMotionEffects, l as otherMotionLayer, o as motionEffectRegistrations, r as defineOwnEffect, s as motionStateAttributes, t as claimMotionLayer, u as writeMotionStyle } from "./registry-DAIjCjWd.js";
4
+ import { a as isOwnNode, c as own } from "./ring-BN4d8vtw.js";
5
+ // src/motion/effects/divider.ts
6
+ const springBack = {
7
+ stiffness: 500,
8
+ damping: 14
9
+ };
10
+ const reach = 60;
11
+ const inset = 40;
12
+ const svgNamespace$1 = "http://www.w3.org/2000/svg";
13
+ const rekaDragAttribute = "data-resize-handle-active";
14
+ const bends = /* @__PURE__ */ new WeakMap();
15
+ function axisOf$1(handle, rect) {
16
+ const orientation = handle.getAttribute("aria-orientation");
17
+ if (orientation === "vertical") return "x";
18
+ if (orientation === "horizontal") return "y";
19
+ return rect.height >= rect.width ? "x" : "y";
20
+ }
21
+ function shows(color) {
22
+ return !/^transparent$|rgba\([^)]*,\s*0\)$|\/\s*0\)$/.test(color.trim());
23
+ }
24
+ function lineOf(handle, axis) {
25
+ const across = (style) => Number.parseFloat(axis === "x" ? style.width : style.height);
26
+ const styles = [
27
+ [getComputedStyle(handle), handle],
28
+ [getComputedStyle(handle, "::before"), handle],
29
+ [getComputedStyle(handle, "::after"), handle]
30
+ ];
31
+ for (const child of handle.children) if (child instanceof HTMLElement) styles.push([getComputedStyle(child), child]);
32
+ for (const [style, element] of styles) {
33
+ const width = across(style);
34
+ if (style.display !== "none" && shows(style.backgroundColor) && width > 0 && width <= 4) return {
35
+ color: style.backgroundColor,
36
+ width,
37
+ element
38
+ };
39
+ }
40
+ return {
41
+ color: "var(--ui-border, var(--vh-border, currentColor))",
42
+ width: 1
43
+ };
44
+ }
45
+ function draw$4(bend, amount) {
46
+ const { handle, axis, line } = bend;
47
+ if (Math.abs(amount) < .5 && !bend.spring.active) {
48
+ bend.lane?.svg.remove();
49
+ if (line.element && bend.opacity) line.element.style.setProperty("opacity", bend.opacity.value, bend.opacity.priority);
50
+ if (bends.get(handle) === bend) bends.delete(handle);
51
+ return;
52
+ }
53
+ if (!bend.lane) {
54
+ const svg = document.createElementNS(svgNamespace$1, "svg");
55
+ svg.setAttribute("aria-hidden", "true");
56
+ svg.dataset.motion = "bend";
57
+ svg.style.cssText = "position:absolute;left:0;top:0;width:1px;height:1px;overflow:visible;pointer-events:none;z-index:1";
58
+ const path = document.createElementNS(svgNamespace$1, "path");
59
+ path.setAttribute("fill", "none");
60
+ path.style.stroke = line.color;
61
+ path.style.strokeWidth = `${line.width}px`;
62
+ svg.append(path);
63
+ bend.lane = {
64
+ svg,
65
+ path
66
+ };
67
+ if (line.element) {
68
+ const { style } = line.element;
69
+ bend.opacity = {
70
+ value: style.opacity,
71
+ priority: style.getPropertyPriority("opacity")
72
+ };
73
+ style.setProperty("opacity", "0");
74
+ }
75
+ }
76
+ const { svg, path } = bend.lane;
77
+ if (!svg.isConnected) handle.after(svg);
78
+ const zoom = handle.offsetHeight ? handle.getBoundingClientRect().height / handle.offsetHeight || 1 : 1;
79
+ const scaled = (box) => ({
80
+ left: box.left / zoom,
81
+ top: box.top / zoom,
82
+ width: box.width / zoom,
83
+ height: box.height / zoom
84
+ });
85
+ const origin = scaled(svg.getBoundingClientRect());
86
+ const rect = scaled(handle.getBoundingClientRect());
87
+ const u = axis === "x" ? rect.left + rect.width / 2 - origin.left : rect.top + rect.height / 2 - origin.top;
88
+ const from = axis === "x" ? rect.top - origin.top : rect.left - origin.left;
89
+ const to = from + (axis === "x" ? rect.height : rect.width);
90
+ const middle = (from + to) / 2;
91
+ const at = to - from > 80 ? Math.max(from + inset, Math.min(to - inset, bend.at / zoom - (axis === "x" ? origin.top : origin.left))) : middle;
92
+ const point = (along, across) => axis === "x" ? `${across.toFixed(2)},${along.toFixed(2)}` : `${along.toFixed(2)},${across.toFixed(2)}`;
93
+ const tip = u + amount;
94
+ path.setAttribute("d", `M${point(from, u)} C${point(at - 70, u)} ${point(at - 40, tip)} ${point(at, tip)} C${point(at + 40, tip)} ${point(at + 70, u)} ${point(to, u)}`);
95
+ }
96
+ function draggable(handle) {
97
+ if (handle.matches("[aria-disabled=true], [data-disabled]:not([data-disabled=false]), [data-panel-resize-handle-enabled=false]")) return false;
98
+ return /resize/.test(getComputedStyle(handle).cursor) || handle.tabIndex >= 0 || handle.hasAttribute("aria-valuenow");
99
+ }
100
+ /**
101
+ * Drag a value (docs/design/motion.md): a divider, `[role=separator]` that a person can drag, from Nuxt UI `USplitter`,
102
+ * `UDashboardPanel`, Reka, ui-sdk and kit `Resizable`, or a plain handle. Past the limit of its panel, the divider
103
+ * stays where its component keeps it and its line bends toward the pointer. On release it springs back straight.
104
+ */
105
+ const divider = {
106
+ name: "divider",
107
+ selector: "[role=separator]",
108
+ press(handle, event) {
109
+ if (!(event instanceof PointerEvent) || !draggable(handle)) return;
110
+ if (handle.matches("[role=separator][data-panel-resize-handle-id]") && handle.getAttribute("data-resize-handle-active") !== "pointer") return;
111
+ const rect = handle.getBoundingClientRect();
112
+ const axis = axisOf$1(handle, rect);
113
+ const along = (pointer) => axis === "x" ? pointer.clientX : pointer.clientY;
114
+ const across = (pointer) => axis === "x" ? pointer.clientY : pointer.clientX;
115
+ const center = (box) => axis === "x" ? box.left + box.width / 2 : box.top + box.height / 2;
116
+ const grab = along(event) - center(rect);
117
+ let bend = bends.get(handle);
118
+ if (!bend) {
119
+ const current = {
120
+ handle,
121
+ axis,
122
+ line: lineOf(handle, axis),
123
+ at: across(event),
124
+ spring: createSpring(0, (value) => draw$4(current, value), springBack)
125
+ };
126
+ bend = current;
127
+ bends.set(handle, bend);
128
+ }
129
+ const active = bend;
130
+ active.at = across(event);
131
+ let pointer = event;
132
+ let frame = 0;
133
+ const measure = () => {
134
+ frame = 0;
135
+ const box = handle.getBoundingClientRect();
136
+ const zoom = handle.offsetHeight ? box.height / handle.offsetHeight || 1 : 1;
137
+ const over = (along(pointer) - grab - center(box)) / zoom;
138
+ active.at = across(pointer);
139
+ active.spring.set(Math.abs(over) < 1 ? 0 : over / (1 + Math.abs(over) / reach));
140
+ };
141
+ return {
142
+ move(next) {
143
+ pointer = next;
144
+ if (!frame) frame = requestAnimationFrame(measure);
145
+ },
146
+ release() {
147
+ cancelAnimationFrame(frame);
148
+ active.spring.to(0, { preset: springBack });
149
+ }
150
+ };
151
+ }
152
+ };
153
+ // src/motion/layer.ts
154
+ const roots = /* @__PURE__ */ new Map();
155
+ let observer;
156
+ const presses = /* @__PURE__ */ new Map();
157
+ let splitterPointer;
158
+ let stopWatching = [];
159
+ const pressedBy = Symbol.for("vite-hub.motion.effect-presses");
160
+ const eventPresses = (event) => {
161
+ const claimed = Reflect.get(event, pressedBy);
162
+ if (claimed) return claimed;
163
+ const effects = /* @__PURE__ */ new Map();
164
+ Reflect.set(event, pressedBy, effects);
165
+ return effects;
166
+ };
167
+ const unreadable = /* @__PURE__ */ new Set();
168
+ /** `element.matches(selector)`, false for a selector that this browser cannot read. */
169
+ function matches(element, selector) {
170
+ if (unreadable.has(selector)) return false;
171
+ try {
172
+ return element.matches(selector);
173
+ } catch {
174
+ unreadable.add(selector);
175
+ return false;
176
+ }
177
+ }
178
+ /**
179
+ * True when an install covers the element: an installed element contains it, or its root is installed, also through the
180
+ * shadow hosts around it. An app that installs the document covers the shadow roots in it, and the page pill, which
181
+ * installs only its own host and shadow roots, does not move the buttons of the page that it is on.
182
+ */
183
+ function covered(element) {
184
+ let node = element;
185
+ for (;;) {
186
+ for (const root of roots.keys()) if (root instanceof Element && root.contains(node)) return true;
187
+ const root = node.getRootNode();
188
+ if ((root instanceof Document || root instanceof ShadowRoot) && roots.has(root)) return true;
189
+ if (!(root instanceof ShadowRoot)) return false;
190
+ node = root.host;
191
+ }
192
+ }
193
+ /** The innermost element on the event path that matches `selector`, that an install covers, and that is not inside `[data-motion="none"]`. */
194
+ function find(path, selector) {
195
+ let lastOff = -1;
196
+ path.forEach((node, index) => {
197
+ if (node instanceof Element && node.matches("[data-motion=\"none\"]")) lastOff = index;
198
+ });
199
+ const index = path.findIndex((node) => node instanceof HTMLElement && matches(node, selector));
200
+ return index === -1 || index <= lastOff || !covered(path[index]) ? void 0 : path[index];
201
+ }
202
+ function begin(id, event, path) {
203
+ end(id, true);
204
+ const claimed = eventPresses(event);
205
+ const started = [];
206
+ for (const { effect, isReduced } of motionEffectRegistrations()) {
207
+ if (!effect.press || isReduced()) continue;
208
+ const element = find(path, effect.selector);
209
+ if (!element || id === "key" && element !== path[0]) continue;
210
+ const previous = claimed.get(element);
211
+ if (previous?.has(effect.name)) continue;
212
+ const press = effect.press(element, event);
213
+ if (!press) continue;
214
+ if (previous) previous.add(effect.name);
215
+ else claimed.set(element, /* @__PURE__ */ new Set([effect.name]));
216
+ const item = {
217
+ element,
218
+ press
219
+ };
220
+ if (id !== "key" && !press.move) {
221
+ item.leave = () => endItem(id, item, true);
222
+ element.addEventListener("pointerleave", item.leave, { once: true });
223
+ }
224
+ started.push(item);
225
+ }
226
+ if (!started.length) return;
227
+ presses.set(id, started);
228
+ if (started.some((item) => item.press.move)) document.addEventListener("pointermove", onPointerMove, {
229
+ capture: true,
230
+ passive: true
231
+ });
232
+ }
233
+ function end(id, cancelled = false) {
234
+ const items = presses.get(id);
235
+ if (!items) return;
236
+ presses.delete(id);
237
+ for (const { element, press, leave } of items) {
238
+ if (leave) element.removeEventListener("pointerleave", leave);
239
+ if (cancelled && press.cancel) press.cancel();
240
+ else press.release();
241
+ }
242
+ stopPointerMoveIfIdle();
243
+ }
244
+ function endItem(id, item, cancelled = false) {
245
+ const items = presses.get(id);
246
+ const index = items?.indexOf(item) ?? -1;
247
+ if (!items || index === -1) return;
248
+ if (item.leave) item.element.removeEventListener("pointerleave", item.leave);
249
+ items.splice(index, 1);
250
+ if (!items.length) presses.delete(id);
251
+ if (cancelled && item.press.cancel) item.press.cancel();
252
+ else item.press.release();
253
+ stopPointerMoveIfIdle();
254
+ }
255
+ function stopPointerMoveIfIdle() {
256
+ if (![...presses.values()].some((list) => list.some((item) => item.press.move))) document.removeEventListener("pointermove", onPointerMove, { capture: true });
257
+ }
258
+ function onPointerDown(event) {
259
+ if (event.button !== 0) return;
260
+ const path = event.composedPath();
261
+ if (event.isPrimary) splitterPointer = {
262
+ event,
263
+ path
264
+ };
265
+ begin(event.pointerId, event, path);
266
+ }
267
+ function onPointerUp(event) {
268
+ if (splitterPointer?.event.pointerId === event.pointerId) splitterPointer = void 0;
269
+ end(event.pointerId, event.type === "pointercancel");
270
+ }
271
+ function onPointerMove(event) {
272
+ for (const { press } of presses.get(event.pointerId) ?? []) press.move?.(event);
273
+ }
274
+ function onKeyDown(event) {
275
+ if (event.repeat || event.key !== " " && event.key !== "Enter") return;
276
+ const path = event.composedPath();
277
+ if (event.key === " " && path[0] instanceof Element && path[0].matches("a[href], [role=link]")) return;
278
+ begin("key", event, path);
279
+ }
280
+ function onKeyUp(event) {
281
+ if (event.key === " " || event.key === "Enter") end("key");
282
+ }
283
+ function collectContent(records, effects) {
284
+ const watching = effects.filter((effect) => effect.content);
285
+ if (!watching.length) return;
286
+ const changes = /* @__PURE__ */ new Map();
287
+ for (const record of records) {
288
+ if (record.type === "attributes") continue;
289
+ const element = record.type === "characterData" ? record.target.parentElement : record.target;
290
+ if (!(element instanceof HTMLElement || element instanceof SVGElement)) continue;
291
+ let change = changes.get(element);
292
+ if (!change) {
293
+ change = {
294
+ added: [],
295
+ removed: [],
296
+ oldText: void 0,
297
+ texts: /* @__PURE__ */ new Map()
298
+ };
299
+ changes.set(element, change);
300
+ }
301
+ if (record.type === "characterData") {
302
+ if (!change.texts.has(record.target)) change.texts.set(record.target, record.oldValue);
303
+ continue;
304
+ }
305
+ change.added.push(...record.addedNodes);
306
+ change.removed.push(...record.removedNodes);
307
+ }
308
+ for (const [element, change] of changes) {
309
+ if (!element.isConnected) continue;
310
+ const added = change.added.filter((node) => !change.removed.includes(node));
311
+ const removed = change.removed.filter((node) => !change.added.includes(node));
312
+ const texts = change.texts;
313
+ let oldText;
314
+ const children = [...element.childNodes];
315
+ if (removed.length && children.every((node) => added.includes(node))) oldText = removed.map((node) => node.textContent ?? "").join("");
316
+ else if (texts.size === 1 && children.length === 1 && texts.has(children[0])) oldText = texts.get(children[0]) ?? "";
317
+ for (const effect of watching) if (matches(element, effect.selector) && !isMotionOff(element)) effect.content(element, {
318
+ added,
319
+ removed,
320
+ oldText
321
+ });
322
+ }
323
+ }
324
+ function onSplitterDrag(handle) {
325
+ if (!splitterPointer || !handle.matches("[role=separator][data-panel-resize-handle-id]")) return;
326
+ const registration = motionEffectRegistrations().find(({ effect }) => effect.name === "divider");
327
+ if (!registration || registration.isReduced()) return;
328
+ const { event, path } = splitterPointer;
329
+ const items = presses.get(event.pointerId) ?? [];
330
+ const current = items.find((item) => item.splitter && item.element === handle);
331
+ if (handle.getAttribute("data-resize-handle-active") !== "pointer") {
332
+ if (current) endItem(event.pointerId, current);
333
+ return;
334
+ }
335
+ if (current || !path.includes(handle.getRootNode()) || !covered(handle) || isMotionOff(handle)) return;
336
+ const press = registration.effect.press?.(handle, event);
337
+ if (!press) return;
338
+ items.push({
339
+ element: handle,
340
+ press,
341
+ splitter: true
342
+ });
343
+ presses.set(event.pointerId, items);
344
+ document.addEventListener("pointermove", onPointerMove, {
345
+ capture: true,
346
+ passive: true
347
+ });
348
+ }
349
+ function onMutations(batch) {
350
+ const records = [...new Set(batch)];
351
+ const effects = listMotionEffects();
352
+ const dispatched = /* @__PURE__ */ new Map();
353
+ collectContent(records, effects);
354
+ for (const record of records) {
355
+ if (record.type === "characterData") continue;
356
+ if (record.type === "attributes") {
357
+ const element = record.target;
358
+ if (!(element instanceof HTMLElement)) continue;
359
+ if (record.attributeName === "data-resize-handle-active") {
360
+ onSplitterDrag(element);
361
+ continue;
362
+ }
363
+ const attribute = record.attributeName;
364
+ const value = element.getAttribute(attribute);
365
+ if (value === record.oldValue) continue;
366
+ let attributes = dispatched.get(element);
367
+ if (!attributes) dispatched.set(element, attributes = /* @__PURE__ */ new Map());
368
+ let oldValues = attributes.get(attribute);
369
+ if (!oldValues) attributes.set(attribute, oldValues = /* @__PURE__ */ new Set());
370
+ if (oldValues.has(record.oldValue)) continue;
371
+ oldValues.add(record.oldValue);
372
+ for (const effect of effects) if (effect.state && matches(element, effect.selector) && !isMotionOff(element)) effect.state(element, {
373
+ attribute,
374
+ oldValue: record.oldValue,
375
+ value
376
+ });
377
+ continue;
378
+ }
379
+ for (const node of record.addedNodes) {
380
+ if (!(node instanceof HTMLElement) || !node.isConnected) continue;
381
+ for (const effect of effects) {
382
+ if (!effect.enter) continue;
383
+ const self = matches(node, effect.selector);
384
+ if (unreadable.has(effect.selector)) continue;
385
+ const found = [...self ? [node] : [], ...node.querySelectorAll(effect.selector)];
386
+ for (const element of found) if (!isMotionOff(element)) effect.enter(element);
387
+ }
388
+ }
389
+ }
390
+ }
391
+ function observe(root, observer) {
392
+ const content = listMotionEffects().some((effect) => effect.content);
393
+ observer.observe(root, {
394
+ attributes: true,
395
+ attributeFilter: [...motionStateAttributes, ...listMotionEffects().some((effect) => effect.name === "divider") ? [rekaDragAttribute] : []],
396
+ attributeOldValue: true,
397
+ childList: content || listMotionEffects().some((effect) => effect.enter),
398
+ characterData: content,
399
+ characterDataOldValue: content,
400
+ subtree: true
401
+ });
402
+ }
403
+ function syncWatchers(root, watchers) {
404
+ const effects = listMotionEffects();
405
+ for (const [effect, stop] of watchers) {
406
+ if (effects.includes(effect)) continue;
407
+ stop();
408
+ watchers.delete(effect);
409
+ }
410
+ for (const effect of effects) if (effect.watch && !watchers.has(effect)) watchers.set(effect, effect.watch(root));
411
+ }
412
+ function startDocument() {
413
+ const options = {
414
+ capture: true,
415
+ passive: true
416
+ };
417
+ document.addEventListener("pointerdown", onPointerDown, options);
418
+ document.addEventListener("pointerup", onPointerUp, options);
419
+ document.addEventListener("pointercancel", onPointerUp, options);
420
+ document.addEventListener("keydown", onKeyDown, options);
421
+ document.addEventListener("keyup", onKeyUp, options);
422
+ stopWatching = [() => {
423
+ document.removeEventListener("pointerdown", onPointerDown, options);
424
+ document.removeEventListener("pointerup", onPointerUp, options);
425
+ document.removeEventListener("pointercancel", onPointerUp, options);
426
+ document.removeEventListener("keydown", onKeyDown, options);
427
+ document.removeEventListener("keyup", onKeyUp, options);
428
+ splitterPointer = void 0;
429
+ for (const id of presses.keys()) end(id, true);
430
+ }, onReducedMotionChange((reduced) => {
431
+ if (!reduced) return;
432
+ splitterPointer = void 0;
433
+ for (const id of presses.keys()) end(id, true);
434
+ })];
435
+ }
436
+ /**
437
+ * Starts the motion layer in `root`, the document, a shadow root, or an element and everything in it, with the effects
438
+ * in `options.effects`. The other built-in effects stay out of the bundle. It listens once on the document and reads the composed path, so a press also reaches
439
+ * the shadow roots inside an installed root. Pass a shadow root to also watch the state attributes inside it: an
440
+ * observer does not see into a shadow root. A surface that installs only its own host and shadow roots, such as the
441
+ * page pill, does not move the elements of the page around it.
442
+ *
443
+ * It is safe to call more than once. Returns a function that stops this install. The layer stops when every install
444
+ * has stopped. On the server it does nothing. `installMotion(root?)` of `@vite-hub/ui/motion` is this function with
445
+ * every built-in effect.
446
+ *
447
+ * When another copy of the module installed first, this install and these effects go to that copy, the shared layer,
448
+ * so an element that both copies cover moves once.
449
+ */
450
+ function installMotion(root, options) {
451
+ if (typeof document === "undefined") return () => {};
452
+ const shared = otherMotionLayer();
453
+ if (shared) {
454
+ handOffMotionEffects(shared);
455
+ return shared.install(root, options.effects, prefersReducedMotion);
456
+ }
457
+ claimMotionLayer(sharedLayer);
458
+ return installOwn(root, options.effects);
459
+ }
460
+ const sharedLayer = {
461
+ define: defineOwnEffect,
462
+ install: installOwn
463
+ };
464
+ function installOwn(root, effects, isReduced = prefersReducedMotion) {
465
+ const defined = new Set(listMotionEffects().map((effect) => effect.name));
466
+ for (const effect of effects) if (!defined.has(effect.name)) defineOwnEffect(effect, isReduced);
467
+ if (!observer) {
468
+ startDocument();
469
+ const active = new MutationObserver((records, source) => onMutations(records.concat(source.takeRecords())));
470
+ observer = active;
471
+ stopWatching.push(onMotionEffectsChange(() => {
472
+ for (const [root, { watchers }] of roots) {
473
+ observe(root, active);
474
+ syncWatchers(root, watchers);
475
+ }
476
+ }));
477
+ }
478
+ const entry = roots.get(root);
479
+ if (entry) entry.installs++;
480
+ else {
481
+ const watchers = /* @__PURE__ */ new Map();
482
+ observe(root, observer);
483
+ roots.set(root, {
484
+ installs: 1,
485
+ watchers
486
+ });
487
+ syncWatchers(root, watchers);
488
+ }
489
+ let stopped = false;
490
+ return () => {
491
+ if (stopped) return;
492
+ stopped = true;
493
+ const current = roots.get(root);
494
+ if (!current || --current.installs > 0) return;
495
+ roots.delete(root);
496
+ const active = observer;
497
+ const pending = active.takeRecords();
498
+ active.disconnect();
499
+ for (const stop of current.watchers.values()) stop();
500
+ if (roots.size) {
501
+ for (const root of roots.keys()) observe(root, active);
502
+ if (pending.length) queueMicrotask(() => {
503
+ if (observer !== active) return;
504
+ const remaining = [...roots.keys()];
505
+ onMutations(pending.filter((record) => remaining.some((root) => root.contains(record.target))));
506
+ });
507
+ return;
508
+ }
509
+ observer = void 0;
510
+ for (const stop of stopWatching) stop();
511
+ stopWatching = [];
512
+ };
513
+ }
514
+ // src/motion/effects/ghost.ts
515
+ /**
516
+ * A copy of an element that leaves the page, so its exit can play after the component removed or hid it. Reka and
517
+ * ui-sdk remove a closed tooltip or toast at once when it has no CSS animation, and Nuxt UI removes the mark of a
518
+ * checkbox with the check. The motion layer does not use CSS animations, so the effect plays the exit on this copy.
519
+ *
520
+ * The copy is inert, hidden from assistive technology, and inside `data-motion="none"`, so the layer does not take it
521
+ * for a new tooltip, toast, or checkbox. It has no `id` and no `role`.
522
+ */
523
+ function createGhost(source, parent, before) {
524
+ const ghost = source.cloneNode(true);
525
+ for (const element of [ghost, ...ghost.querySelectorAll("*")]) for (const name of [
526
+ "id",
527
+ "role",
528
+ "tabindex",
529
+ "hidden",
530
+ "inert",
531
+ "popover",
532
+ "data-ending-style",
533
+ "data-starting-style",
534
+ "aria-live"
535
+ ]) element.removeAttribute(name);
536
+ ghost.setAttribute("aria-hidden", "true");
537
+ ghost.setAttribute("data-motion", "none");
538
+ if (ghost instanceof HTMLElement) ghost.inert = true;
539
+ ghost.style.pointerEvents = "none";
540
+ parent.insertBefore(ghost, before?.parentNode === parent ? before : null);
541
+ return ghost;
542
+ }
543
+ /**
544
+ * Puts a ghost at a place on the screen with `position: fixed`, outside the layout of the list it came from. A parent
545
+ * with a transform moves fixed elements, so the ghost measures where it landed and corrects for it.
546
+ */
547
+ function pinGhost(ghost, rect) {
548
+ Object.assign(ghost.style, {
549
+ position: "fixed",
550
+ inset: "auto",
551
+ left: `${rect.left}px`,
552
+ top: `${rect.top}px`,
553
+ width: `${rect.width}px`,
554
+ height: `${rect.height}px`,
555
+ margin: "0",
556
+ boxSizing: "border-box",
557
+ transform: "none",
558
+ translate: "none",
559
+ zIndex: "2147483647"
560
+ });
561
+ const landed = ghost.getBoundingClientRect();
562
+ if (Math.abs(landed.left - rect.left) > .5) ghost.style.left = `${2 * rect.left - landed.left}px`;
563
+ if (Math.abs(landed.top - rect.top) > .5) ghost.style.top = `${2 * rect.top - landed.top}px`;
564
+ }
565
+ /** Calls `callback` after `ms` of motion time, so ¼× also slows the waits between the steps of an effect. */
566
+ function after(ms, callback) {
567
+ return window.setTimeout(callback, ms * getMotionSlowFactor());
568
+ }
569
+ // src/motion/effects/check.ts
570
+ const checks = /* @__PURE__ */ new WeakMap();
571
+ function isOn$1(value) {
572
+ return value === "true" || value === "mixed";
573
+ }
574
+ function styleable(node) {
575
+ return node instanceof HTMLElement || node instanceof SVGElement ? node : void 0;
576
+ }
577
+ /** The child of `element` that holds `node`. */
578
+ function childOf(element, node) {
579
+ let child = node;
580
+ while (child.parentElement && child.parentElement !== element) child = child.parentElement;
581
+ return child;
582
+ }
583
+ function keepGhost(check) {
584
+ const { indicator } = check;
585
+ if (check.drawn.target || check.ghost || !indicator || indicator.isConnected) return;
586
+ const source = styleable(indicator);
587
+ if (!source) return;
588
+ const ghost = createGhost(source, check.element, null);
589
+ check.ghost = ghost;
590
+ bind(check, findIcons(ghost)[0], ghost);
591
+ }
592
+ function draw$3(check, value) {
593
+ keepGhost(check);
594
+ const drawn = Math.min(1, Math.max(0, value));
595
+ if (check.icon && !check.reduced) {
596
+ const { icon, lengths } = check;
597
+ icon.shapes.forEach((shape, index) => {
598
+ const length = lengths[index];
599
+ icon.set(shape, "stroke-dasharray", `${length} ${length}`);
600
+ icon.set(shape, "stroke-dashoffset", String(length * (1 - drawn)));
601
+ });
602
+ icon.commit();
603
+ }
604
+ if (check.fade) writeMotionStyle(check.fade, { opacity: String(drawn) });
605
+ }
606
+ function finish$1(check) {
607
+ check.icon?.restore();
608
+ check.icon = void 0;
609
+ if (check.fade) writeMotionStyle(check.fade, { opacity: null });
610
+ check.fade = void 0;
611
+ check.ghost?.remove();
612
+ check.ghost = void 0;
613
+ }
614
+ function checkOf(element, wasOn) {
615
+ const existing = checks.get(element);
616
+ if (existing) return existing;
617
+ const check = {
618
+ element,
619
+ drawn: createSpring(wasOn ? 1 : 0, (value) => {
620
+ if (check.drawn.active) draw$3(check, value);
621
+ else finish$1(check);
622
+ }),
623
+ icon: void 0,
624
+ lengths: [],
625
+ fade: void 0,
626
+ indicator: void 0,
627
+ ghost: void 0,
628
+ reduced: false
629
+ };
630
+ checks.set(element, check);
631
+ return check;
632
+ }
633
+ /** Points the spring at the mark of `icon`, and puts back the mark that it drew before. */
634
+ function bind(check, icon, fade) {
635
+ check.icon?.restore();
636
+ if (check.fade && check.fade !== fade) writeMotionStyle(check.fade, { opacity: null });
637
+ check.icon = icon && !check.reduced ? iconShape(icon) : void 0;
638
+ check.lengths = check.icon?.measure((shapes) => shapes.map((shape) => shape.getTotalLength())) ?? [];
639
+ check.fade = fade;
640
+ return !!check.icon || !!fade;
641
+ }
642
+ const check = {
643
+ name: "check",
644
+ selector: "[role=checkbox]",
645
+ state(element, { attribute, oldValue, value }) {
646
+ if (attribute !== "aria-checked") return;
647
+ const check = checkOf(element, isOn$1(oldValue));
648
+ check.ghost?.remove();
649
+ check.ghost = void 0;
650
+ check.reduced = prefersReducedMotion();
651
+ const options = check.reduced ? { tween: .15 } : void 0;
652
+ if (isOn$1(value)) {
653
+ const icon = findIcons(element)[0];
654
+ check.indicator = icon && childOf(element, icon);
655
+ if (isOn$1(oldValue)) check.drawn.set(0);
656
+ if (!bind(check, icon, check.reduced ? styleable(check.indicator) : void 0)) return;
657
+ draw$3(check, check.drawn.value);
658
+ check.drawn.to(1, options);
659
+ return;
660
+ }
661
+ if (oldValue !== "true") {
662
+ check.drawn.set(0);
663
+ check.indicator = void 0;
664
+ return;
665
+ }
666
+ const icon = findIcons(element)[0];
667
+ if (icon) check.indicator = childOf(element, icon);
668
+ if (!bind(check, icon, check.reduced ? styleable(check.indicator) : void 0) && !check.indicator) return;
669
+ check.drawn.to(0, options);
670
+ draw$3(check, check.drawn.value);
671
+ }
672
+ };
673
+ // src/motion/effects/disclosure.ts
674
+ const iconSelector$1 = "[data-motion-chevron], svg, img, .iconify, [data-slot=icon], [data-slot$=Icon]";
675
+ const quarter = 90;
676
+ const turns = /* @__PURE__ */ new WeakMap();
677
+ const pending$1 = /* @__PURE__ */ new WeakMap();
678
+ /** The element that holds the chevron: the `<summary>` of a `<details>`, or the trigger itself. */
679
+ function triggerOf(element) {
680
+ return element instanceof HTMLDetailsElement ? element.querySelector(":scope > summary") : element;
681
+ }
682
+ function degrees(value) {
683
+ if (!value || value === "none") return 0;
684
+ const axis = value.trim().split(/\s+/);
685
+ const angle = axis.pop();
686
+ if (axis.length === 1 && axis[0] !== "z") return 0;
687
+ if (axis.length === 3 && (Number(axis[0]) !== 0 || Number(axis[1]) !== 0)) return 0;
688
+ const number = Number.parseFloat(angle);
689
+ if (angle.endsWith("turn")) return number * 360;
690
+ if (angle.endsWith("grad")) return number * .9;
691
+ if (angle.endsWith("rad")) return number * 180 / Math.PI;
692
+ return Number.isFinite(number) ? number : 0;
693
+ }
694
+ /** The Z angle of a computed transform matrix. */
695
+ function matrixDegrees(value) {
696
+ const match = /^matrix(?:3d)?\(([^)]+)\)$/.exec(value);
697
+ if (!match) return 0;
698
+ const [a = 1, b = 0] = match[1].split(",").map(Number);
699
+ return Math.atan2(b, a) * 180 / Math.PI;
700
+ }
701
+ /** The angle that the stylesheet draws the icon at now, without what the effect wrote, split into its two sources. */
702
+ function measure$2(icon) {
703
+ const written = icon.style.getPropertyValue("rotate");
704
+ if (written) icon.style.removeProperty("rotate");
705
+ const style = getComputedStyle(icon);
706
+ const base = matrixDegrees(style.transform);
707
+ const total = base + degrees(style.rotate);
708
+ if (written) icon.style.setProperty("rotate", written);
709
+ return {
710
+ total,
711
+ base
712
+ };
713
+ }
714
+ /**
715
+ * True when the icon still turns with a CSS transition of its own, as Nuxt UI's accordion chevron does. The transition
716
+ * would smear each frame of the spring, so that icon keeps its own motion.
717
+ */
718
+ function transitionsTurn(icon) {
719
+ const style = getComputedStyle(icon);
720
+ const durations = style.transitionDuration.split(",");
721
+ return style.transitionProperty.split(",").some((property, index) => /^\s*(?:transform|rotate|all)\s*$/.test(property) && Number.parseFloat(durations[index % durations.length]) > 0);
722
+ }
723
+ function icons(trigger) {
724
+ return [...trigger.querySelectorAll(iconSelector$1)].filter((icon) => !icon.parentElement?.closest(iconSelector$1) || icon.matches("[data-motion-chevron]"));
725
+ }
726
+ function turnOf(icon) {
727
+ const turn = turns.get(icon);
728
+ if (turn) return turn;
729
+ const current = {
730
+ base: 0,
731
+ spring: createSpring(0, (value, velocity) => {
732
+ if (isMotionOff(icon)) {
733
+ current.spring.stop();
734
+ writeMotionStyle(icon, { rotate: null });
735
+ return;
736
+ }
737
+ const settled = velocity === 0 && value === current.spring.target;
738
+ writeMotionStyle(icon, { rotate: settled ? null : `${(value * quarter - current.base).toFixed(2)}deg` });
739
+ }, springs.snappy)
740
+ };
741
+ turns.set(icon, current);
742
+ return current;
743
+ }
744
+ const disclosure = {
745
+ name: "disclosure",
746
+ selector: "details, summary, [aria-expanded]",
747
+ press(element) {
748
+ const owner = element.tagName === "SUMMARY" ? element.parentElement : element.matches("[aria-expanded]") ? element : null;
749
+ if (!owner || !(owner instanceof HTMLDetailsElement || owner.matches("[aria-expanded]"))) return;
750
+ const trigger = triggerOf(owner);
751
+ if (!trigger) return;
752
+ const angles = /* @__PURE__ */ new Map();
753
+ for (const icon of icons(trigger)) {
754
+ if (isMotionOff(icon) || transitionsTurn(icon)) continue;
755
+ const spring = turns.get(icon)?.spring;
756
+ angles.set(icon, spring?.active ? spring.target * quarter : measure$2(icon).total);
757
+ }
758
+ if (!angles.size) return;
759
+ pending$1.set(owner, angles);
760
+ return { release() {
761
+ setTimeout(() => {
762
+ if (pending$1.get(owner) === angles) pending$1.delete(owner);
763
+ });
764
+ } };
765
+ },
766
+ state(element, { attribute }) {
767
+ if (attribute !== (element instanceof HTMLDetailsElement ? "open" : "aria-expanded")) return;
768
+ const angles = pending$1.get(element);
769
+ pending$1.delete(element);
770
+ const trigger = triggerOf(element);
771
+ if (!trigger) return;
772
+ for (const icon of icons(trigger)) {
773
+ const previous = turns.get(icon);
774
+ const sampled = angles?.get(icon);
775
+ if (isMotionOff(icon) || sampled === void 0 || prefersReducedMotion() || transitionsTurn(icon)) {
776
+ if (previous?.spring.active) {
777
+ previous.spring.stop();
778
+ writeMotionStyle(icon, { rotate: null });
779
+ }
780
+ continue;
781
+ }
782
+ const turn = turnOf(icon);
783
+ const from = turn.spring.active ? turn.spring.value * quarter : sampled;
784
+ const { total, base } = measure$2(icon);
785
+ turn.base = base;
786
+ if (Math.abs(total - from) < .5) {
787
+ if (turn.spring.active) turn.spring.set(total / quarter);
788
+ continue;
789
+ }
790
+ if (!turn.spring.active) turn.spring.set(from / quarter);
791
+ turn.spring.to(total / quarter);
792
+ if (turn.spring.active) writeMotionStyle(icon, { rotate: `${(turn.spring.value * quarter - base).toFixed(2)}deg` });
793
+ }
794
+ }
795
+ };
796
+ // src/motion/effects/jelly.ts
797
+ const waveEnd = 1.5;
798
+ const waveSeconds = .56 * waveEnd;
799
+ const points = 120;
800
+ const waves = /* @__PURE__ */ new WeakMap();
801
+ /** The outline of the path at `wave`, as a closed polyline. The formula is the prototype's, for any path size. */
802
+ function deform({ outline, box }, wave) {
803
+ const amount = wave <= 1 ? .5 * Math.sin(Math.PI * wave) : -.12 * Math.sin(Math.PI * (wave - 1) / .5);
804
+ const crest = -.15 + 1.35 * Math.min(1, Math.max(0, wave));
805
+ const lift = 4 * box.height / 18;
806
+ return `M${outline.map(([x, y]) => {
807
+ const along = (y - box.top) / box.height;
808
+ const bulge = Math.exp(-(((along - crest) / .3) ** 2));
809
+ const swell = amount * bulge * (.12 + 1.1 * Math.max(0, along) ** 1.6);
810
+ const nextX = box.center + (x - box.center) * (1 + swell);
811
+ const nextY = along > .8 ? y - amount * bulge * lift * (along - .8) : y;
812
+ return `${nextX.toFixed(2)} ${nextY.toFixed(2)}`;
813
+ }).join("L")}Z`;
814
+ }
815
+ function singleOutline(shape) {
816
+ const [path, ...rest] = shape.shapes;
817
+ if (rest.length || !(path instanceof SVGPathElement)) return;
818
+ const data = path.getAttribute("d") ?? "";
819
+ return /^[Mm][^MmZz]+[Zz]\s*$/.test(data.trim()) ? path : void 0;
820
+ }
821
+ function start$2(icon) {
822
+ const running = waves.get(icon);
823
+ if (running) {
824
+ running.clock.set(0);
825
+ running.clock.to(1, { tween: waveSeconds });
826
+ return;
827
+ }
828
+ const shape = iconShape(icon);
829
+ const path = shape && singleOutline(shape);
830
+ if (!shape || !path) return;
831
+ const sampled = shape.measure(([geometry]) => {
832
+ const length = geometry.getTotalLength();
833
+ const bounds = geometry.getBBox();
834
+ return {
835
+ outline: Array.from({ length: points }, (_, index) => {
836
+ const point = geometry.getPointAtLength(length * index / points);
837
+ return [point.x, point.y];
838
+ }),
839
+ box: {
840
+ top: bounds.y,
841
+ height: bounds.height,
842
+ center: bounds.x + bounds.width / 2
843
+ }
844
+ };
845
+ });
846
+ if (!sampled.box.height) return;
847
+ const wave = {
848
+ shape,
849
+ path,
850
+ ...sampled,
851
+ clock: createSpring(0, (eased) => {
852
+ const time = 1 - Math.cbrt(1 - Math.min(1, eased));
853
+ if (time >= 1 || !icon.isConnected) {
854
+ waves.delete(icon);
855
+ wave.clock.stop();
856
+ shape.restore();
857
+ return;
858
+ }
859
+ shape.set(path, "d", deform(wave, time * waveEnd));
860
+ shape.commit();
861
+ })
862
+ };
863
+ waves.set(icon, wave);
864
+ wave.clock.to(1, { tween: waveSeconds });
865
+ }
866
+ let batch;
867
+ function flush$1() {
868
+ const changes = batch;
869
+ batch = void 0;
870
+ for (const elements of changes.values()) {
871
+ if (new Set(elements.map((element) => element.getAttribute("aria-pressed") === "true")).size > 1) continue;
872
+ for (const element of elements) {
873
+ const icons = findIcons(element);
874
+ if (icons.length === 1) start$2(icons[0]);
875
+ }
876
+ }
877
+ }
878
+ const jelly = {
879
+ name: "jelly",
880
+ selector: "[aria-pressed]",
881
+ state(element, { attribute }) {
882
+ if (attribute !== "aria-pressed" || prefersReducedMotion()) return;
883
+ if (!batch) {
884
+ batch = /* @__PURE__ */ new Map();
885
+ queueMicrotask(flush$1);
886
+ }
887
+ const siblings = batch.get(element.parentElement) ?? [];
888
+ siblings.push(element);
889
+ batch.set(element.parentElement, siblings);
890
+ }
891
+ };
892
+ // src/motion/effects/label.ts
893
+ const controls = ":is(button, a, [role=button])";
894
+ /**
895
+ * Rule 4 for every button: when the text-only label of a Nuxt UI button, or of a control with a `[data-slot=label]` child,
896
+ * changes, its letters morph and the button's width follows. The app only changes the label, such as
897
+ * `:label="loading ? 'Publishing' : 'Publish'"`.
898
+ */
899
+ const label = {
900
+ name: "label",
901
+ selector: `${controls} > [data-slot=label]`,
902
+ content(element, { added, removed, oldText }) {
903
+ if (!(element instanceof HTMLElement)) return;
904
+ if ([...element.childNodes].some((node) => node.nodeType !== Node.TEXT_NODE && !isOwnNode(node))) {
905
+ discardMorph(element);
906
+ return;
907
+ }
908
+ if (added.length ? added.every(isOwnNode) : removed.length > 0) return;
909
+ const before = morphTarget(element) ?? oldText;
910
+ if (before === void 0) return;
911
+ morph(element, element.textContent ?? "", before);
912
+ }
913
+ };
914
+ /**
915
+ * Rule 5 for every button: when Vue draws another icon into the leading or trailing SVG of a button, such as the
916
+ * spinner of `loading`, a copy of the old icon blurs out where it was and the new one comes in. A spinner draws its
917
+ * stroke. An icon of `@nuxt/icon` in CSS mode changes a class, which the layer does not watch, so it changes at once.
918
+ */
919
+ const buttonIcon = {
920
+ name: "button-icon",
921
+ selector: `${controls}, ${controls} > svg:is([data-slot=leadingIcon], [data-slot=trailingIcon])`,
922
+ content(svg, { added, removed }) {
923
+ if (svg instanceof HTMLElement) {
924
+ for (const slot of ["leadingIcon", "trailingIcon"]) {
925
+ const isIcon = (node) => node instanceof SVGSVGElement && node.getAttribute("data-slot") === slot && !isOwnNode(node);
926
+ const next = added.find((node) => isIcon(node) && node.parentNode === svg);
927
+ const previous = removed.find(isIcon);
928
+ if (previous) {
929
+ const ghost = own(previous.cloneNode(true));
930
+ ghost.classList.remove("animate-spin");
931
+ ghost.removeAttribute("data-slot");
932
+ if (next) next.after(ghost);
933
+ else if (slot === "leadingIcon") svg.prepend(ghost);
934
+ else svg.append(ghost);
935
+ leaveIcon(svg, ghost, offsetIn(svg, next ?? ghost), "blur", (old) => old.remove());
936
+ }
937
+ if (next) enterIcon(next, void 0, 0);
938
+ }
939
+ return;
940
+ }
941
+ const container = svg.parentElement;
942
+ if (!(svg instanceof SVGSVGElement) || !container || !removed.length || added.every(isOwnNode)) return;
943
+ if (!removed.some((node) => node instanceof SVGElement)) return;
944
+ const at = offsetIn(container, svg);
945
+ const ghost = own(svg.cloneNode(false));
946
+ ghost.classList.remove("animate-spin");
947
+ ghost.removeAttribute("data-slot");
948
+ ghost.append(...removed);
949
+ svg.after(ghost);
950
+ leaveIcon(container, ghost, at, "blur", (old) => old.remove());
951
+ enterIcon(svg, void 0, 0);
952
+ }
953
+ };
954
+ // src/motion/effects/leave.ts
955
+ const fold = {
956
+ stiffness: 260,
957
+ damping: 28
958
+ };
959
+ const slotScale = .9;
960
+ const crossfade$2 = .15;
961
+ const leaving = /* @__PURE__ */ new WeakMap();
962
+ function stop(element) {
963
+ const entry = leaving.get(element);
964
+ if (!entry) return;
965
+ leaving.delete(element);
966
+ entry.spring.stop();
967
+ entry.ghost.remove();
968
+ element.removeAttribute("data-motion-leave-managed");
969
+ writeMotionStyle(element, { opacity: null });
970
+ }
971
+ /**
972
+ * A mark that leaves while its page keeps it a moment longer, such as a comment pin when one comment shows on its own:
973
+ * the page sets `data-leaving="true"` on it and removes it later. A copy of it folds away in its place, as a removed item
974
+ * of a list does, and the mark itself hides at once, so the time the page keeps it does not matter. When the page shows
975
+ * it again, the copy goes. Under reduced motion the copy fades out in 150ms.
976
+ */
977
+ const leave$2 = {
978
+ name: "leave",
979
+ selector: "*",
980
+ state(element, { attribute, value }) {
981
+ if (attribute !== "data-leaving") return;
982
+ stop(element);
983
+ if (value !== "true" || !element.parentNode) return;
984
+ element.setAttribute("data-motion-leave-managed", "");
985
+ const rect = element.getBoundingClientRect();
986
+ const ghost = createGhost(element, element.parentNode, element.nextSibling);
987
+ const position = getComputedStyle(element).position;
988
+ if (position !== "absolute" && position !== "fixed") pinGhost(ghost, rect);
989
+ writeMotionStyle(element, { opacity: "0" });
990
+ const reduced = prefersReducedMotion();
991
+ const spring = createSpring(1, (progress) => {
992
+ writeMotionStyle(ghost, {
993
+ scale: reduced ? null : (slotScale + .09999999999999998 * progress).toFixed(4),
994
+ opacity: Math.max(0, progress).toFixed(3)
995
+ });
996
+ if (progress < .02) {
997
+ spring.stop();
998
+ ghost.remove();
999
+ }
1000
+ }, fold);
1001
+ leaving.set(element, {
1002
+ ghost,
1003
+ spring
1004
+ });
1005
+ spring.to(0, reduced ? { tween: crossfade$2 } : { preset: fold });
1006
+ }
1007
+ };
1008
+ // src/motion/effects/panel.ts
1009
+ const resizeSpring = {
1010
+ stiffness: 420,
1011
+ damping: 30
1012
+ };
1013
+ const panelSelector = "[data-motion-panel]";
1014
+ const resizes = /* @__PURE__ */ new WeakMap();
1015
+ const widths = /* @__PURE__ */ new WeakMap();
1016
+ const tracking = /* @__PURE__ */ new WeakMap();
1017
+ const unit = 100;
1018
+ function stopResize(element) {
1019
+ const spring = resizes.get(element)?.spring;
1020
+ if (!spring?.active) return;
1021
+ spring.stop();
1022
+ writeMotionStyle(element, { width: null });
1023
+ }
1024
+ function watchPanels(root) {
1025
+ const panels = /* @__PURE__ */ new Set();
1026
+ const resize = new ResizeObserver((entries) => {
1027
+ for (const { target } of entries) if (target instanceof HTMLElement && panels.has(target) && !resizes.get(target)?.spring.active) widths.set(target, target.getBoundingClientRect().width);
1028
+ });
1029
+ function track(element) {
1030
+ if (panels.has(element) || !root.contains(element) || !element.matches(panelSelector)) return;
1031
+ panels.add(element);
1032
+ const count = tracking.get(element) ?? 0;
1033
+ if (count === 0) widths.set(element, element.getBoundingClientRect().width);
1034
+ tracking.set(element, count + 1);
1035
+ resize.observe(element, { box: "border-box" });
1036
+ }
1037
+ function untrack(element) {
1038
+ panels.delete(element);
1039
+ resize.unobserve(element);
1040
+ const count = tracking.get(element) ?? 1;
1041
+ if (count > 1) {
1042
+ tracking.set(element, count - 1);
1043
+ return;
1044
+ }
1045
+ tracking.delete(element);
1046
+ stopResize(element);
1047
+ widths.delete(element);
1048
+ }
1049
+ const observer = new MutationObserver((records) => {
1050
+ for (const element of panels) if (!root.contains(element) || !element.matches(panelSelector)) untrack(element);
1051
+ for (const record of records) {
1052
+ if (record.type === "attributes" && record.target instanceof HTMLElement) track(record.target);
1053
+ for (const node of record.addedNodes) {
1054
+ if (!(node instanceof HTMLElement)) continue;
1055
+ track(node);
1056
+ for (const element of node.querySelectorAll(panelSelector)) track(element);
1057
+ }
1058
+ }
1059
+ });
1060
+ if (root instanceof HTMLElement) track(root);
1061
+ for (const element of root.querySelectorAll(panelSelector)) track(element);
1062
+ observer.observe(root, {
1063
+ subtree: true,
1064
+ childList: true,
1065
+ attributeFilter: ["data-motion-panel"]
1066
+ });
1067
+ return () => {
1068
+ observer.disconnect();
1069
+ for (const element of panels) untrack(element);
1070
+ resize.disconnect();
1071
+ };
1072
+ }
1073
+ function frameOf$1(element) {
1074
+ const style = getComputedStyle(element);
1075
+ if (style.boxSizing === "border-box") return 0;
1076
+ return [
1077
+ style.paddingLeft,
1078
+ style.paddingRight,
1079
+ style.borderLeftWidth,
1080
+ style.borderRightWidth
1081
+ ].reduce((sum, value) => sum + Number.parseFloat(value), 0);
1082
+ }
1083
+ function write$1(element, resize) {
1084
+ writeMotionStyle(element, { width: `${resize.spring.value * unit - resize.frame}px` });
1085
+ }
1086
+ const panel = {
1087
+ name: "panel",
1088
+ selector: panelSelector,
1089
+ watch: watchPanels,
1090
+ state(element) {
1091
+ let resize = resizes.get(element);
1092
+ const from = resize?.spring.active ? resize.spring.value * unit : widths.get(element);
1093
+ if (resize?.spring.active) writeMotionStyle(element, { width: null });
1094
+ const to = element.getBoundingClientRect().width;
1095
+ widths.set(element, to);
1096
+ if (from === void 0 || prefersReducedMotion() || Math.abs(to - from) < .5) {
1097
+ stopResize(element);
1098
+ return;
1099
+ }
1100
+ if (!resize) {
1101
+ const current = {
1102
+ frame: 0,
1103
+ spring: createSpring(from / unit, (width, velocity) => {
1104
+ if (velocity === 0 && width === current.spring.target) writeMotionStyle(element, { width: null });
1105
+ else write$1(element, current);
1106
+ }, resizeSpring)
1107
+ };
1108
+ resize = current;
1109
+ resizes.set(element, resize);
1110
+ }
1111
+ resize.frame = frameOf$1(element);
1112
+ if (!resize.spring.active) resize.spring.set(from / unit);
1113
+ resize.spring.to(to / unit);
1114
+ if (resize.spring.active) write$1(element, resize);
1115
+ }
1116
+ };
1117
+ // src/motion/effects/press.ts
1118
+ const down = {
1119
+ stiffness: 900,
1120
+ damping: 40
1121
+ };
1122
+ const up = {
1123
+ stiffness: 380,
1124
+ damping: 14
1125
+ };
1126
+ /**
1127
+ * Everything a person presses: native controls and the roles of docs/design/motion.md, when they are enabled. A switch
1128
+ * is not squashed: the switch effect grows its knob instead.
1129
+ */
1130
+ const pressSelector = `:is(button, a[href], summary, input:is([type=button], [type=submit], [type=reset], [type=checkbox], [type=radio]), ${[
1131
+ "button",
1132
+ "link",
1133
+ "tab",
1134
+ "radio",
1135
+ "menuitem",
1136
+ "menuitemradio",
1137
+ "menuitemcheckbox",
1138
+ "option",
1139
+ "checkbox"
1140
+ ].map((role) => `[role=${role}]`).join(", ")}):not(:disabled, [aria-disabled="true"], [role=switch])`;
1141
+ const iconSelector = "svg, img, .iconify, [data-slot=icon], [data-slot$=Icon], [data-slot=swap-icon]";
1142
+ const pressed = /* @__PURE__ */ new WeakMap();
1143
+ /** How much a control of this height squashes: 3% from 40px high, 4% from 32px, and 5% below. */
1144
+ const amountFor = (height) => height >= 40 ? .03 : height >= 32 ? .04 : .05;
1145
+ /**
1146
+ * How much a press squashes, from the prototype: an icon-only control squashes its icon by 15%, and a control squashes
1147
+ * by its height. A control that another element draws, such as the mark of the folded page pill, names that element
1148
+ * with `data-motion-press-target`, a selector that `closest()` finds from the control. Then that element squashes.
1149
+ */
1150
+ function squash(element) {
1151
+ const drawnBy = element.dataset.motionPressTarget ? element.closest(element.dataset.motionPressTarget) : null;
1152
+ if (drawnBy instanceof HTMLElement) return {
1153
+ target: drawnBy,
1154
+ amount: amountFor(drawnBy.offsetHeight)
1155
+ };
1156
+ const icon = element.firstElementChild;
1157
+ if (element.childElementCount === 1 && !element.textContent?.trim() && (icon instanceof HTMLElement || icon instanceof SVGElement) && icon.matches(iconSelector)) return {
1158
+ target: icon,
1159
+ amount: .15
1160
+ };
1161
+ return {
1162
+ target: element,
1163
+ amount: amountFor(element.offsetHeight)
1164
+ };
1165
+ }
1166
+ /**
1167
+ * True when the element still animates `scale` with a CSS transition of its own, as a hand-written press on the
1168
+ * allowlist of `test/design-rules.test.ts` does. The transition would smear each frame of the spring, so that element
1169
+ * keeps its own press until its wave moves it onto the layer. Tailwind's plain `transition` class also animates `scale`.
1170
+ */
1171
+ function transitionsScale(style) {
1172
+ const durations = style.transitionDuration.split(",");
1173
+ return style.transitionProperty.split(",").some((property, index) => /^\s*(?:scale|all)\s*$/.test(property) && Number.parseFloat(durations[index % durations.length]) > 0);
1174
+ }
1175
+ function nearEdge(bounds, event, amount) {
1176
+ const { left, right, top, bottom, width, height } = bounds;
1177
+ return Math.min(event.clientX - left, right - event.clientX) <= width * amount || Math.min(event.clientY - top, bottom - event.clientY) <= height * amount;
1178
+ }
1179
+ const press = {
1180
+ name: "press",
1181
+ selector: pressSelector,
1182
+ press(element, event) {
1183
+ const { target, amount } = squash(element);
1184
+ const style = getComputedStyle(target);
1185
+ if (transitionsScale(style) || style.display === "contents") return;
1186
+ if (style.display === "inline" && target === element && !(element instanceof HTMLInputElement)) return;
1187
+ let bounds;
1188
+ if (target === element && "pointerId" in event) {
1189
+ bounds = element.getBoundingClientRect();
1190
+ if (nearEdge(bounds, event, amount)) return;
1191
+ }
1192
+ let state = pressed.get(target);
1193
+ if (!state) {
1194
+ const current = {
1195
+ amount,
1196
+ spring: createSpring(0, (value) => {
1197
+ writeMotionStyle(target, { scale: value ? String(1 - current.amount * value) : null });
1198
+ }, down)
1199
+ };
1200
+ state = current;
1201
+ pressed.set(target, state);
1202
+ }
1203
+ state.amount = amount;
1204
+ const { spring } = state;
1205
+ spring.to(1, { preset: down });
1206
+ let cancelled = false;
1207
+ const cancel = () => {
1208
+ if (cancelled) return;
1209
+ cancelled = true;
1210
+ spring.set(0);
1211
+ };
1212
+ return {
1213
+ move: bounds ? (pointer) => {
1214
+ if (nearEdge(bounds, pointer, amount)) cancel();
1215
+ } : void 0,
1216
+ release: () => {
1217
+ if (!cancelled) spring.to(0, { preset: up });
1218
+ },
1219
+ cancel
1220
+ };
1221
+ }
1222
+ };
1223
+ // src/motion/effects/select.ts
1224
+ const groups = {
1225
+ tab: "[role=tablist]",
1226
+ radio: "[role=radiogroup]",
1227
+ option: "[role=listbox]",
1228
+ menuitemradio: "[role=group], [role=menu]"
1229
+ };
1230
+ const optIn = "[data-motion-select]";
1231
+ const anyGroup = `[role=tablist], [role=radiogroup], [role=listbox], [role=group], [role=menu], ${optIn}`;
1232
+ const byRole = Object.keys(groups).map((role) => `[role=${role}]`).join(", ");
1233
+ const itemSelector = `${byRole}, ${optIn} *`;
1234
+ const selectionState = [
1235
+ "aria-selected",
1236
+ "aria-checked",
1237
+ "data-state",
1238
+ "data-checked"
1239
+ ];
1240
+ const indicatorItem = `${byRole}, [aria-selected], [aria-checked], [data-checked], ${[
1241
+ "active",
1242
+ "inactive",
1243
+ "checked",
1244
+ "unchecked",
1245
+ "on",
1246
+ "off"
1247
+ ].map((value) => `[data-state=${value}]`).join(", ")}`;
1248
+ const ownIndicator = "[data-motion-indicator], [data-slot=indicator]";
1249
+ const groupIndicator = `${ownIndicator}, [data-slot$="-indicator"]`;
1250
+ const stretchPerSpeed$1 = .09;
1251
+ const stretchMax$1 = .55;
1252
+ const thinning = .25;
1253
+ const flights = /* @__PURE__ */ new WeakMap();
1254
+ const pending = /* @__PURE__ */ new Map();
1255
+ const observedItems = /* @__PURE__ */ new WeakSet();
1256
+ let frameId = 0;
1257
+ function isSelected(attribute, value) {
1258
+ if (attribute === "aria-selected" || attribute === "aria-checked") return value === "true";
1259
+ if (attribute === "data-state") return value === "active" || value === "checked" || value === "on";
1260
+ if (attribute === "data-checked") return value !== null && value !== "false";
1261
+ return false;
1262
+ }
1263
+ function groupOf(item) {
1264
+ const group = item.parentElement?.closest(anyGroup);
1265
+ if (!group || group.matches("[role=listbox][aria-multiselectable=true]")) return null;
1266
+ const role = item.getAttribute("role");
1267
+ const selector = role ? groups[role] : void 0;
1268
+ return group.matches(optIn) || selector && group.matches(selector) ? group : null;
1269
+ }
1270
+ function selected(item) {
1271
+ return selectionState.some((attribute) => isSelected(attribute, item.getAttribute(attribute)));
1272
+ }
1273
+ function indicatorOwner(group, indicator) {
1274
+ for (let node = indicator; node && node !== group; node = node.parentElement) if (observedItems.has(node) || node.matches(indicatorItem)) return node;
1275
+ }
1276
+ function frameOf(group) {
1277
+ const rect = group.getBoundingClientRect();
1278
+ return {
1279
+ left: rect.left,
1280
+ top: rect.top,
1281
+ k: group.offsetWidth ? rect.width / group.offsetWidth : 1
1282
+ };
1283
+ }
1284
+ /**
1285
+ * The layout box of an element relative to the group, in CSS pixels. The size comes from layout and the center from the
1286
+ * screen, so a press that scales an item around its center does not change it.
1287
+ */
1288
+ function boxOf(element, frame) {
1289
+ const rect = element.getBoundingClientRect();
1290
+ const width = element.offsetWidth || rect.width / frame.k;
1291
+ const height = element.offsetHeight || rect.height / frame.k;
1292
+ return {
1293
+ x: (rect.left + rect.width / 2 - frame.left) / frame.k - width / 2,
1294
+ y: (rect.top + rect.height / 2 - frame.top) / frame.k - height / 2,
1295
+ width,
1296
+ height
1297
+ };
1298
+ }
1299
+ /** The indicator of `item`: its own one, or the one of the group that is in no item. */
1300
+ function indicatorOf(group, item) {
1301
+ for (const candidate of item.querySelectorAll(ownIndicator)) if (candidate.closest(anyGroup) === group && indicatorOwner(group, candidate) === item) return candidate;
1302
+ for (const candidate of group.querySelectorAll(groupIndicator)) if (candidate.closest(anyGroup) === group && !indicatorOwner(group, candidate)) return candidate;
1303
+ }
1304
+ function innerBounds(group) {
1305
+ const style = getComputedStyle(group);
1306
+ const left = group.clientLeft + Number.parseFloat(style.paddingLeft);
1307
+ const top = group.clientTop + Number.parseFloat(style.paddingTop);
1308
+ const right = group.clientLeft + group.clientWidth - Number.parseFloat(style.paddingRight);
1309
+ const bottom = group.clientTop + group.clientHeight - Number.parseFloat(style.paddingBottom);
1310
+ return [[left, right], [top, bottom]];
1311
+ }
1312
+ function pixels(value, size) {
1313
+ return value.endsWith("%") ? Number.parseFloat(value) / 100 * size : Number.parseFloat(value) || 0;
1314
+ }
1315
+ function measureRest$1(flight) {
1316
+ writeMotionStyle(flight.element, {
1317
+ translate: null,
1318
+ scale: null
1319
+ });
1320
+ const style = getComputedStyle(flight.element);
1321
+ flight.rest = boxOf(flight.element, frameOf(flight.group));
1322
+ const [tx = "0", ty = "0"] = style.translate === "none" ? [] : style.translate.split(" ");
1323
+ const [ox = "50%", oy = "50%"] = style.transformOrigin.split(" ");
1324
+ flight.translate = [pixels(tx, flight.rest.width), pixels(ty, flight.rest.height)];
1325
+ flight.origin = [pixels(ox, flight.rest.width), pixels(oy, flight.rest.height)];
1326
+ }
1327
+ /** The box of the indicator at rest in `to`, moved and resized to sit the same way in `from`. */
1328
+ function mapBox(rest, to, from) {
1329
+ const sx = to.width ? from.width / to.width : 1;
1330
+ const sy = to.height ? from.height / to.height : 1;
1331
+ return {
1332
+ x: from.x + (rest.x - to.x) * sx,
1333
+ y: from.y + (rest.y - to.y) * sy,
1334
+ width: rest.width * sx,
1335
+ height: rest.height * sy
1336
+ };
1337
+ }
1338
+ function moving(flight) {
1339
+ return !!flight && (flight.x.active || flight.y.active || flight.width.active || flight.height.active);
1340
+ }
1341
+ function queue(flight) {
1342
+ if (flight.queued) return;
1343
+ flight.queued = true;
1344
+ queueMicrotask(() => {
1345
+ flight.queued = false;
1346
+ render(flight);
1347
+ });
1348
+ }
1349
+ /**
1350
+ * One axis of the box in flight: its start and size, longer by `along` of its size toward where it moves, thinner by a
1351
+ * quarter of `across`, and kept inside `bounds` or the place at rest.
1352
+ */
1353
+ function stretch(start, size, velocity, along, across, bounds, restStart, restSize) {
1354
+ const extra = along * size;
1355
+ const low = Math.min(bounds[0], restStart, start);
1356
+ const high = Math.max(bounds[1], restStart + restSize, start + size);
1357
+ let from = velocity < 0 ? Math.max(low, start - extra) : start;
1358
+ let to = velocity < 0 ? start + size : Math.min(high, start + size + extra);
1359
+ const thin = (to - from) * across * thinning / 2;
1360
+ from += thin;
1361
+ to -= thin;
1362
+ return [from, to - from];
1363
+ }
1364
+ function render(flight) {
1365
+ if (!flight.ready) return;
1366
+ const { element, rest, translate, origin, x, y, width, height, span } = flight;
1367
+ if (!moving(flight)) {
1368
+ writeMotionStyle(element, {
1369
+ translate: null,
1370
+ scale: null
1371
+ });
1372
+ land(flight);
1373
+ return;
1374
+ }
1375
+ const fx = Math.min(stretchMax$1, Math.abs(x.velocity) / span[0] * stretchPerSpeed$1);
1376
+ const fy = Math.min(stretchMax$1, Math.abs(y.velocity) / span[1] * stretchPerSpeed$1);
1377
+ const [left, boxWidth] = stretch(x.value, width.value, x.velocity, fx, fy, flight.bounds[0], rest.x, rest.width);
1378
+ const [top, boxHeight] = stretch(y.value, height.value, y.velocity, fy, fx, flight.bounds[1], rest.y, rest.height);
1379
+ const scaleX = rest.width ? boxWidth / rest.width : 1;
1380
+ const scaleY = rest.height ? boxHeight / rest.height : 1;
1381
+ const tx = left - (rest.x - translate[0]) - origin[0] * (1 - scaleX);
1382
+ const ty = top - (rest.y - translate[1]) - origin[1] * (1 - scaleY);
1383
+ writeMotionStyle(element, {
1384
+ translate: `${tx}px ${ty}px`,
1385
+ scale: `${scaleX} ${scaleY}`
1386
+ });
1387
+ }
1388
+ function fly(group, element, from, to, copyOf) {
1389
+ const previous = flights.get(group);
1390
+ const wasMoving = moving(previous);
1391
+ if (previous && previous.element !== element) {
1392
+ writeMotionStyle(previous.element, {
1393
+ translate: null,
1394
+ scale: null
1395
+ });
1396
+ land(previous);
1397
+ }
1398
+ const flight = previous ?? {
1399
+ element,
1400
+ group,
1401
+ ready: false,
1402
+ rest: {
1403
+ x: 0,
1404
+ y: 0,
1405
+ width: 0,
1406
+ height: 0
1407
+ },
1408
+ translate: [0, 0],
1409
+ origin: [0, 0],
1410
+ span: [1, 1],
1411
+ bounds: [[0, 0], [0, 0]],
1412
+ queued: false,
1413
+ x: createSpring(0, () => queue(flight), springs.snappy),
1414
+ y: createSpring(0, () => queue(flight), springs.snappy),
1415
+ width: createSpring(0, () => queue(flight), springs.snappy),
1416
+ height: createSpring(0, () => queue(flight), springs.snappy)
1417
+ };
1418
+ flights.set(group, flight);
1419
+ flight.ready = false;
1420
+ flight.element = element;
1421
+ flight.copyOf = copyOf;
1422
+ measureRest$1(flight);
1423
+ flight.bounds = innerBounds(group);
1424
+ const { rest } = flight;
1425
+ if (!rest.width || !rest.height || !wasMoving && !from) {
1426
+ flight.ready = true;
1427
+ return land(flight);
1428
+ }
1429
+ if (!wasMoving && from) {
1430
+ const frame = frameOf(group);
1431
+ const start = mapBox(rest, boxOf(to, frame), boxOf(from, frame));
1432
+ flight.x.set(start.x);
1433
+ flight.y.set(start.y);
1434
+ flight.width.set(start.width);
1435
+ flight.height.set(start.height);
1436
+ }
1437
+ flight.span = [Math.max(Math.abs(rest.x - flight.x.value), rest.width, 1), Math.max(Math.abs(rest.y - flight.y.value), rest.height, 1)];
1438
+ flight.x.to(rest.x);
1439
+ flight.y.to(rest.y);
1440
+ flight.width.to(rest.width);
1441
+ flight.height.to(rest.height);
1442
+ flight.ready = true;
1443
+ render(flight);
1444
+ }
1445
+ const sides = [
1446
+ "top",
1447
+ "right",
1448
+ "bottom",
1449
+ "left"
1450
+ ];
1451
+ const borderParts = [
1452
+ "width",
1453
+ "style",
1454
+ "color"
1455
+ ];
1456
+ const lookProperties = [
1457
+ "background-color",
1458
+ "box-shadow",
1459
+ ...sides.flatMap((side) => borderParts.map((part) => `border-${side}-${part}`))
1460
+ ];
1461
+ function finishLook(element) {
1462
+ getComputedStyle(element).backgroundColor;
1463
+ for (const animation of element.getAnimations()) if (animation instanceof CSSTransition && lookProperties.includes(animation.transitionProperty)) animation.finish();
1464
+ }
1465
+ const hiddenLook = [
1466
+ "[data-motion-select-moving] { isolation: isolate; }",
1467
+ "[data-motion-select-hidden~=\"background\"] { background-color: transparent !important; }",
1468
+ "[data-motion-select-hidden~=\"shadow\"] { box-shadow: none !important; }",
1469
+ ...sides.map((side) => `[data-motion-select-hidden~="border-${side}"] { border-${side}-color: transparent !important; }`)
1470
+ ].join("\n");
1471
+ let sheet;
1472
+ function adoptSheet(node) {
1473
+ const root = node.getRootNode();
1474
+ if (!(root instanceof Document || root instanceof ShadowRoot)) return;
1475
+ if (!sheet) {
1476
+ sheet = new CSSStyleSheet();
1477
+ sheet.replaceSync(hiddenLook);
1478
+ }
1479
+ if (!root.adoptedStyleSheets.includes(sheet)) root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
1480
+ }
1481
+ const clear = /^transparent$|^rgba\((?:[^,]+,){3}\s*0(?:\.0+)?\)$|\/\s*0(?:\.0+)?%?\s*\)$/;
1482
+ /** A copy of the look that `to` has and `from` does not, behind the items, or nothing when they look the same. */
1483
+ function copyLook(group, from, to) {
1484
+ finishLook(from);
1485
+ finishLook(to);
1486
+ const was = getComputedStyle(from);
1487
+ const now = getComputedStyle(to);
1488
+ const hidden = [];
1489
+ const style = {
1490
+ "position": "absolute",
1491
+ "z-index": "-1",
1492
+ "box-sizing": "border-box",
1493
+ "margin": "0",
1494
+ "pointer-events": "none",
1495
+ "border-radius": now.borderRadius,
1496
+ "background-color": "transparent",
1497
+ "box-shadow": "none"
1498
+ };
1499
+ if (now.backgroundColor !== was.backgroundColor && !clear.test(now.backgroundColor)) {
1500
+ style["background-color"] = now.backgroundColor;
1501
+ hidden.push("background");
1502
+ }
1503
+ if (now.boxShadow !== was.boxShadow && now.boxShadow !== "none") {
1504
+ style["box-shadow"] = now.boxShadow;
1505
+ hidden.push("shadow");
1506
+ }
1507
+ for (const side of sides) {
1508
+ const border = `border-${side}`;
1509
+ const width = now.getPropertyValue(`${border}-width`);
1510
+ const color = now.getPropertyValue(`${border}-color`);
1511
+ style[`${border}-width`] = width;
1512
+ style[`${border}-style`] = now.getPropertyValue(`${border}-style`);
1513
+ style[`${border}-color`] = "transparent";
1514
+ if (Number.parseFloat(width) > 0 && !clear.test(color) && borderParts.some((part) => {
1515
+ const property = `${border}-${part}`;
1516
+ return now.getPropertyValue(property) !== was.getPropertyValue(property);
1517
+ })) {
1518
+ style[`${border}-color`] = color;
1519
+ hidden.push(border);
1520
+ }
1521
+ }
1522
+ if (!hidden.length) return void 0;
1523
+ const element = document.createElement("span");
1524
+ element.setAttribute("aria-hidden", "true");
1525
+ element.setAttribute("data-motion-copy", "");
1526
+ for (const [property, value] of Object.entries(style)) element.style.setProperty(property, value);
1527
+ adoptSheet(group);
1528
+ group.append(element);
1529
+ const parent = element.offsetParent instanceof HTMLElement ? element.offsetParent : null;
1530
+ const block = parent && !(parent === document.body && getComputedStyle(parent).position === "static") ? parent : null;
1531
+ const box = boxOf(to, frameOf(block ?? document.documentElement));
1532
+ element.style.left = `${box.x - (block ? block.clientLeft - block.scrollLeft : 0)}px`;
1533
+ element.style.top = `${box.y - (block ? block.clientTop - block.scrollTop : 0)}px`;
1534
+ element.style.width = `${box.width}px`;
1535
+ element.style.height = `${box.height}px`;
1536
+ return {
1537
+ element,
1538
+ hidden
1539
+ };
1540
+ }
1541
+ function land(flight) {
1542
+ const item = flight.copyOf;
1543
+ if (!item) return;
1544
+ flight.copyOf = void 0;
1545
+ item.removeAttribute("data-motion-select-hidden");
1546
+ finishLook(item);
1547
+ flight.element.remove();
1548
+ flight.group.removeAttribute("data-motion-select-moving");
1549
+ }
1550
+ function cancelFlight(group) {
1551
+ const flight = flights.get(group);
1552
+ if (!flight) return;
1553
+ flights.delete(group);
1554
+ flight.ready = false;
1555
+ for (const spring of [
1556
+ flight.x,
1557
+ flight.y,
1558
+ flight.width,
1559
+ flight.height
1560
+ ]) spring.stop();
1561
+ writeMotionStyle(flight.element, {
1562
+ translate: null,
1563
+ scale: null
1564
+ });
1565
+ land(flight);
1566
+ }
1567
+ function move(group, from, to) {
1568
+ if (prefersReducedMotion() || isMotionOff(to)) return cancelFlight(group);
1569
+ const indicator = indicatorOf(group, to);
1570
+ if (indicator) return isMotionOff(indicator) ? cancelFlight(group) : fly(group, indicator, from, to);
1571
+ const previous = flights.get(group);
1572
+ const source = from ?? (moving(previous) ? previous?.copyOf : void 0);
1573
+ if (!source) return;
1574
+ const look = copyLook(group, source, to);
1575
+ if (!look) return;
1576
+ to.setAttribute("data-motion-select-hidden", look.hidden.join(" "));
1577
+ finishLook(to);
1578
+ fly(group, look.element, from, to, to);
1579
+ if (look.element.isConnected) group.setAttribute("data-motion-select-moving", "");
1580
+ }
1581
+ function flush() {
1582
+ frameId = 0;
1583
+ const batch = [...pending];
1584
+ pending.clear();
1585
+ for (const [group, { from, to }] of batch) if (to?.isConnected && groupOf(to) === group && selected(to)) move(group, from?.isConnected && groupOf(from) === group ? from : void 0, to);
1586
+ else if (!group.isConnected || flights.has(group) && ![...group.querySelectorAll(itemSelector)].some((item) => selected(item) && groupOf(item) === group)) cancelFlight(group);
1587
+ }
1588
+ const select = {
1589
+ name: "select",
1590
+ selector: itemSelector,
1591
+ state(element, { attribute, oldValue, value }) {
1592
+ const was = isSelected(attribute, oldValue);
1593
+ const now = isSelected(attribute, value);
1594
+ if (was === now) return;
1595
+ const group = groupOf(element);
1596
+ if (!group) return;
1597
+ observedItems.add(element);
1598
+ const entry = pending.get(group) ?? {};
1599
+ if (now) entry.to = element;
1600
+ else entry.from = element;
1601
+ pending.set(group, entry);
1602
+ frameId ||= requestAnimationFrame(flush);
1603
+ }
1604
+ };
1605
+ // src/motion/effects/slider.ts
1606
+ const followSpring = {
1607
+ stiffness: 520,
1608
+ damping: 38
1609
+ };
1610
+ const trail = {
1611
+ stiffness: 260,
1612
+ damping: 30
1613
+ };
1614
+ const heldScale = 1.12;
1615
+ const tailMax = 150;
1616
+ const tailPerSpeed = .13;
1617
+ const turnSpeed = .05;
1618
+ const tailPoints = 28;
1619
+ const stretchPerSpeed = .09;
1620
+ const stretchMax = .55;
1621
+ const svgNamespace = "http://www.w3.org/2000/svg";
1622
+ const valueSelector = "[role=slider], input[type=range]";
1623
+ const nativeThumb = "[data-slot=slider-thumb]";
1624
+ const rangeSelector = "[data-slot=range], [data-slot=slider-indicator]";
1625
+ const trackSelector = "[data-slot=track], [data-slot=slider-track], :has(> [data-slot=range])";
1626
+ const motions = /* @__PURE__ */ new WeakMap();
1627
+ const fills = /* @__PURE__ */ new WeakMap();
1628
+ function thumbOf(element) {
1629
+ if (!(element instanceof HTMLInputElement)) return element;
1630
+ const parent = element.parentElement;
1631
+ return parent?.matches(nativeThumb) ? parent : void 0;
1632
+ }
1633
+ function trackValues(track) {
1634
+ return track.querySelectorAll(`:scope > [role=slider], :scope > ${nativeThumb} > input[type=range]`);
1635
+ }
1636
+ function axisOf(value) {
1637
+ return value.getAttribute("aria-orientation") === "vertical" || value.closest("[data-orientation=vertical]") ? "y" : "x";
1638
+ }
1639
+ function rectOf(element, motion) {
1640
+ const { left, top, width, height } = element.getBoundingClientRect();
1641
+ return {
1642
+ left: left / motion.zoom,
1643
+ top: top / motion.zoom,
1644
+ width: width / motion.zoom,
1645
+ height: height / motion.zoom
1646
+ };
1647
+ }
1648
+ function zoomOf(track) {
1649
+ return track.offsetWidth ? track.getBoundingClientRect().width / track.offsetWidth || 1 : 1;
1650
+ }
1651
+ function along$1(rect, axis) {
1652
+ return axis === "x" ? {
1653
+ start: rect.left,
1654
+ size: rect.width
1655
+ } : {
1656
+ start: rect.top,
1657
+ size: rect.height
1658
+ };
1659
+ }
1660
+ function measure$1(motion) {
1661
+ const { thumb, track, axis } = motion;
1662
+ motion.zoom = zoomOf(track);
1663
+ const shown = along$1(rectOf(thumb, motion), axis);
1664
+ const trackBox = along$1(rectOf(track, motion), axis);
1665
+ motion.length = trackBox.size;
1666
+ return shown.start + shown.size / 2 - trackBox.start - (motions.get(thumb) === motion ? motion.position.value - motion.layout : 0);
1667
+ }
1668
+ function number(value) {
1669
+ return Number.parseFloat(value ?? "");
1670
+ }
1671
+ function directionOf({ thumb, axis }) {
1672
+ const { style } = thumb;
1673
+ const forward = axis === "x" ? style.left : style.top;
1674
+ const backward = axis === "x" ? style.right : style.bottom;
1675
+ if (forward && !backward) return 1;
1676
+ if (backward && !forward) return -1;
1677
+ return axis === "y" || getComputedStyle(thumb).direction === "rtl" ? -1 : 1;
1678
+ }
1679
+ function previousCenter(motion, value, from, to) {
1680
+ const min = number(value.getAttribute("aria-valuemin") ?? value.getAttribute("min"));
1681
+ const max = number(value.getAttribute("aria-valuemax") ?? value.getAttribute("max"));
1682
+ const minimum = Number.isFinite(min) ? min : 0;
1683
+ const maximum = Number.isFinite(max) ? max : 100;
1684
+ if (!(maximum > minimum) || !Number.isFinite(from) || !Number.isFinite(to)) return void 0;
1685
+ const size = along$1(rectOf(motion.thumb, motion), motion.axis).size;
1686
+ const fraction = (to - minimum) / (maximum - minimum);
1687
+ const signAtMidpoint = directionOf(motion);
1688
+ let best;
1689
+ for (const travel of [motion.length - size, motion.length]) for (const sign of [signAtMidpoint, -signAtMidpoint]) {
1690
+ const predicted = motion.length / 2 + sign * (fraction - .5) * travel;
1691
+ const error = Math.abs(predicted - motion.layout);
1692
+ if (!best || error < best.error) best = {
1693
+ error,
1694
+ travel,
1695
+ sign
1696
+ };
1697
+ }
1698
+ if (!best || best.error > 3) return void 0;
1699
+ return motion.layout - best.sign * ((to - from) / (maximum - minimum)) * best.travel;
1700
+ }
1701
+ function split(translate) {
1702
+ const [x = "0px", y = "0px"] = translate.split(" ").filter(Boolean);
1703
+ return {
1704
+ raw: translate,
1705
+ x,
1706
+ y
1707
+ };
1708
+ }
1709
+ function start$1(thumb, value) {
1710
+ const track = thumb.parentElement;
1711
+ if (!track) return void 0;
1712
+ const axis = axisOf(value);
1713
+ const motion = {
1714
+ thumb,
1715
+ track,
1716
+ range: track.querySelector(":scope > [data-slot=range], :scope > [data-slot=slider-indicator]"),
1717
+ axis,
1718
+ layout: 0,
1719
+ length: 0,
1720
+ zoom: 1,
1721
+ direction: 1,
1722
+ held: false,
1723
+ position: createSpring(0, (_value, velocity) => {
1724
+ if (Math.abs(velocity) > turnSpeed * motion.length) motion.direction = velocity > 0 ? 1 : -1;
1725
+ motion.tail.to(Math.min(tailMax, Math.abs(velocity) * tailPerSpeed));
1726
+ draw$2(motion);
1727
+ }, followSpring),
1728
+ tail: createSpring(0, () => draw$2(motion), trail),
1729
+ ownTranslate: split(thumb.style.translate)
1730
+ };
1731
+ motion.layout = measure$1(motion);
1732
+ motion.position.set(motion.layout);
1733
+ motions.set(thumb, motion);
1734
+ return motion;
1735
+ }
1736
+ function finish(motion) {
1737
+ motions.delete(motion.thumb);
1738
+ motion.position.stop();
1739
+ motion.tail.stop();
1740
+ writeMotionStyle(motion.thumb, {
1741
+ translate: motion.ownTranslate.raw || null,
1742
+ scale: null
1743
+ });
1744
+ drawRange(motion);
1745
+ motion.lane?.ownerSVGElement?.remove();
1746
+ }
1747
+ function drawRange(motion) {
1748
+ const { range, axis, track } = motion;
1749
+ if (!range) return;
1750
+ const endpoints = [...trackValues(track)].flatMap((value) => {
1751
+ const thumb = thumbOf(value);
1752
+ if (!thumb) return [];
1753
+ const current = motions.get(thumb);
1754
+ const box = along$1(rectOf(thumb, motion), axis);
1755
+ return [{
1756
+ center: box.start + box.size / 2,
1757
+ moving: !!current && Math.abs(current.position.value - current.layout) >= .01
1758
+ }];
1759
+ });
1760
+ const minSize = axis === "x" ? "minWidth" : "minHeight";
1761
+ let fill = fills.get(range);
1762
+ if (!endpoints.some((endpoint) => endpoint.moving)) {
1763
+ if (fill) {
1764
+ range.style[minSize] = fill.minSize;
1765
+ writeMotionStyle(range, {
1766
+ translate: fill.translate,
1767
+ scale: fill.scale
1768
+ });
1769
+ fills.delete(range);
1770
+ }
1771
+ return;
1772
+ }
1773
+ if (!fill) {
1774
+ fill = {
1775
+ minSize: range.style[minSize],
1776
+ scale: range.style.scale,
1777
+ translate: range.style.translate,
1778
+ shift: 0
1779
+ };
1780
+ fills.set(range, fill);
1781
+ range.style[minSize] = "1px";
1782
+ }
1783
+ const size = Number.parseFloat(getComputedStyle(range)[axis === "x" ? "width" : "height"]);
1784
+ if (!(size > 0)) return;
1785
+ const box = along$1(rectOf(range, motion), axis);
1786
+ const start = box.start + box.size / 2 - fill.shift - size / 2;
1787
+ const end = start + size;
1788
+ const centers = endpoints.map((endpoint) => endpoint.center);
1789
+ let from = Math.min(...centers);
1790
+ let to = Math.max(...centers);
1791
+ if (endpoints.length === 1) {
1792
+ if (directionOf(motion) > 0) from = start;
1793
+ else to = end;
1794
+ }
1795
+ const scale = Math.max(0, to - from) / size;
1796
+ const move = fill.shift = (from + to) / 2 - (start + end) / 2;
1797
+ writeMotionStyle(range, {
1798
+ translate: axis === "x" ? `${move}px 0px` : `0px ${move}px`,
1799
+ scale: axis === "x" ? `${scale} 1` : `1 ${scale}`
1800
+ });
1801
+ }
1802
+ function drawTail(motion) {
1803
+ const { thumb, track, axis, direction, length, range } = motion;
1804
+ const tail = Math.min(tailMax, motion.tail.value);
1805
+ if (tail <= 2) {
1806
+ motion.lane?.setAttribute("d", "");
1807
+ return;
1808
+ }
1809
+ if (!motion.lane) {
1810
+ const svg = document.createElementNS(svgNamespace, "svg");
1811
+ svg.setAttribute("aria-hidden", "true");
1812
+ svg.dataset.motion = "tail";
1813
+ svg.style.cssText = "position:absolute;left:0;top:0;width:1px;height:1px;overflow:visible;pointer-events:none;margin:0";
1814
+ const path = document.createElementNS(svgNamespace, "path");
1815
+ path.style.fill = getComputedStyle(range ?? thumb).backgroundColor;
1816
+ svg.append(path);
1817
+ motion.lane = path;
1818
+ }
1819
+ const svg = motion.lane.ownerSVGElement;
1820
+ if (!svg.isConnected) thumb.before(svg);
1821
+ const origin = rectOf(svg, motion);
1822
+ const trackRect = rectOf(track, motion);
1823
+ const thumbRect = rectOf(thumb, motion);
1824
+ const radius = (axis === "x" ? thumbRect.height : thumbRect.width) / 2 / (motion.held ? heldScale : 1);
1825
+ const cross = axis === "x" ? thumbRect.top + thumbRect.height / 2 - origin.top : thumbRect.left + thumbRect.width / 2 - origin.left;
1826
+ const trackStart = axis === "x" ? trackRect.left - origin.left : trackRect.top - origin.top;
1827
+ const at = Math.max(0, Math.min(length, motion.position.value));
1828
+ const reach = Math.min(tail, direction > 0 ? at : length - at);
1829
+ const thinnest = direction > 0 && range ? (axis === "x" ? range.offsetHeight : range.offsetWidth) / 2 : 0;
1830
+ const one = [];
1831
+ const other = [];
1832
+ for (let index = 0; index <= tailPoints; index++) {
1833
+ const progress = index / tailPoints;
1834
+ const point = (trackStart + at - direction * reach * progress).toFixed(1);
1835
+ const half = Math.max(thinnest, radius * .95 * (1 - progress) ** 1.3);
1836
+ const near = (cross - half).toFixed(2);
1837
+ const far = (cross + half).toFixed(2);
1838
+ one.push(axis === "x" ? `${point} ${near}` : `${near} ${point}`);
1839
+ other.push(axis === "x" ? `${point} ${far}` : `${far} ${point}`);
1840
+ }
1841
+ motion.lane.setAttribute("d", `M${one.join("L")}L${other.reverse().join("L")}Z`);
1842
+ }
1843
+ function draw$2(motion) {
1844
+ if (motions.get(motion.thumb) !== motion) return;
1845
+ if (!motion.held && !motion.position.active && !motion.tail.active) {
1846
+ finish(motion);
1847
+ return;
1848
+ }
1849
+ const { thumb, axis } = motion;
1850
+ const shift = motion.position.value - motion.layout;
1851
+ const { x, y } = motion.ownTranslate;
1852
+ const translate = axis === "x" ? `calc(${x} + ${shift.toFixed(2)}px) ${y}` : `${x} calc(${y} + ${shift.toFixed(2)}px)`;
1853
+ const speed = Math.abs(motion.position.velocity) / Math.max(1, motion.length);
1854
+ const stretch = Math.min(stretchMax, speed * stretchPerSpeed);
1855
+ const base = motion.held ? heldScale : 1;
1856
+ const travel = (base * (1 + stretch)).toFixed(4);
1857
+ const cross = (base * (1 - stretch * .25)).toFixed(4);
1858
+ writeMotionStyle(thumb, {
1859
+ translate,
1860
+ scale: axis === "x" ? `${travel} ${cross}` : `${cross} ${travel}`
1861
+ });
1862
+ drawRange(motion);
1863
+ drawTail(motion);
1864
+ }
1865
+ function follow(thumb, value, from, to) {
1866
+ if (prefersReducedMotion()) {
1867
+ const existing = motions.get(thumb);
1868
+ if (existing) finish(existing);
1869
+ return;
1870
+ }
1871
+ const existing = motions.get(thumb);
1872
+ const motion = existing ?? start$1(thumb, value);
1873
+ if (!motion) return;
1874
+ const next = measure$1(motion);
1875
+ if (!existing) {
1876
+ const was = from === void 0 || to === void 0 ? void 0 : previousCenter(motion, value, from, to);
1877
+ motion.position.set(was ?? next);
1878
+ }
1879
+ if (Math.abs(next - motion.layout) < .01 && existing) return;
1880
+ motion.layout = next;
1881
+ motion.position.to(next);
1882
+ draw$2(motion);
1883
+ }
1884
+ function disabled$1(value) {
1885
+ return value.matches(":disabled, [aria-disabled=true], [data-disabled]:not([data-disabled=false])");
1886
+ }
1887
+ /**
1888
+ * Drag a value (docs/design/motion.md): a slider thumb from Nuxt UI `USlider`, Reka, ui-sdk and kit, or a plain
1889
+ * `[role=slider]`. Its component puts the thumb at the value. The effect keeps the thumb that people see where it was
1890
+ * and springs it there, so a tail trails it with its speed and it stretches along the track. A press on the thumb or
1891
+ * on its track holds the thumb, and it grows while it is held.
1892
+ */
1893
+ const slider = {
1894
+ name: "slider",
1895
+ selector: `${valueSelector}, ${trackSelector}, [data-slot=slider-control]`,
1896
+ press(element, event) {
1897
+ if (!(event instanceof PointerEvent)) return;
1898
+ const target = event.composedPath()[0];
1899
+ if (!(target instanceof Element)) return;
1900
+ const track = element.matches("[data-slot=slider-control]") ? element.querySelector("[data-slot=slider-track]") : element;
1901
+ const values = element.matches(valueSelector) ? [element] : track && (target === element || target === track || target.closest(rangeSelector)?.parentElement === track) ? trackValues(track) : [];
1902
+ let held;
1903
+ let nearest = Number.POSITIVE_INFINITY;
1904
+ for (const value of values) {
1905
+ const thumb = thumbOf(value);
1906
+ if (!thumb || disabled$1(value) || isMotionOff(value)) continue;
1907
+ const rect = thumb.getBoundingClientRect();
1908
+ const distance = Math.hypot(rect.left + rect.width / 2 - event.clientX, rect.top + rect.height / 2 - event.clientY);
1909
+ if (distance < nearest) {
1910
+ nearest = distance;
1911
+ held = {
1912
+ thumb,
1913
+ value
1914
+ };
1915
+ }
1916
+ }
1917
+ if (!held) return;
1918
+ const { thumb, value } = held;
1919
+ const motion = motions.get(thumb) ?? start$1(thumb, value);
1920
+ if (!motion) return;
1921
+ motion.held = true;
1922
+ draw$2(motion);
1923
+ let frame = 0;
1924
+ return {
1925
+ move() {
1926
+ if (!frame) frame = requestAnimationFrame(() => {
1927
+ frame = 0;
1928
+ follow(thumb, value);
1929
+ });
1930
+ },
1931
+ release() {
1932
+ cancelAnimationFrame(frame);
1933
+ const current = motions.get(thumb);
1934
+ if (!current) return;
1935
+ current.held = false;
1936
+ follow(thumb, value);
1937
+ draw$2(current);
1938
+ }
1939
+ };
1940
+ },
1941
+ state(element, { attribute, oldValue, value }) {
1942
+ if (attribute !== "aria-valuenow" && attribute !== "aria-valuetext") return;
1943
+ if (!element.matches(valueSelector)) return;
1944
+ const thumb = thumbOf(element);
1945
+ if (!thumb) return;
1946
+ follow(thumb, element, number(oldValue), number(value));
1947
+ }
1948
+ };
1949
+ // src/motion/effects/switch.ts
1950
+ const travel = {
1951
+ stiffness: 300,
1952
+ damping: 24
1953
+ };
1954
+ const size = {
1955
+ stiffness: 320,
1956
+ damping: 16
1957
+ };
1958
+ const pressSpring = {
1959
+ stiffness: 700,
1960
+ damping: 32
1961
+ };
1962
+ const wobble = {
1963
+ stiffness: 520,
1964
+ damping: 9
1965
+ };
1966
+ const wobbleDelay = 170;
1967
+ const wobbleKick = -5;
1968
+ const knobSelector = "[data-slot=thumb], [data-slot=switch-thumb]";
1969
+ const knobs = /* @__PURE__ */ new WeakMap();
1970
+ function findKnob(element) {
1971
+ const knob = element.querySelector(knobSelector) ?? element.firstElementChild;
1972
+ return knob instanceof HTMLElement ? knob : void 0;
1973
+ }
1974
+ function isOn(value) {
1975
+ return value === "true";
1976
+ }
1977
+ /** Reads where the stylesheet puts the knob in the current state, without what the effect wrote. */
1978
+ function measure(element, knob) {
1979
+ writeMotionStyle(knob, {
1980
+ translate: null,
1981
+ scale: null
1982
+ });
1983
+ const track = element.getBoundingClientRect();
1984
+ const box = knob.getBoundingClientRect();
1985
+ const [x = "0px", y = "0px"] = getComputedStyle(knob).translate.split(" ");
1986
+ const zoom = element.offsetWidth ? track.width / element.offsetWidth : 1;
1987
+ return {
1988
+ rest: {
1989
+ center: (box.left + box.width / 2 - track.left) / zoom,
1990
+ width: box.width / zoom,
1991
+ height: box.height / zoom
1992
+ },
1993
+ translate: x === "none" ? ["0px", "0px"] : [x, y],
1994
+ width: knob.offsetWidth,
1995
+ height: knob.offsetHeight
1996
+ };
1997
+ }
1998
+ function restOf(state, on, trackWidth) {
1999
+ const own = state.rest[on ? 1 : 0];
2000
+ if (own) return own;
2001
+ const other = state.rest[on ? 0 : 1];
2002
+ return {
2003
+ ...other,
2004
+ center: trackWidth - other.center
2005
+ };
2006
+ }
2007
+ function draw$1(element, state) {
2008
+ const { knob, now } = state;
2009
+ if (!state.position.active && !state.size.active && !state.press.active && !state.press.target && !state.wobble.active && state.wobbleTimer === void 0) {
2010
+ writeMotionStyle(knob, {
2011
+ translate: null,
2012
+ scale: null
2013
+ });
2014
+ return;
2015
+ }
2016
+ const trackWidth = element.offsetWidth;
2017
+ const off = restOf(state, false, trackWidth);
2018
+ const on = restOf(state, true, trackWidth);
2019
+ const p = state.position.value;
2020
+ const grown = state.size.value;
2021
+ const stretch = Math.min(.55, Math.abs(state.velocity) * .09) + state.press.value * .4;
2022
+ const sx = 1 + stretch + state.wobble.value * .14;
2023
+ const sy = 1 - stretch * .25 - state.wobble.value * .14;
2024
+ const width = (off.width + (on.width - off.width) * grown) * sx;
2025
+ const height = (off.height + (on.height - off.height) * grown) * sy;
2026
+ const start = Math.min(off.center - off.width / 2, on.center - on.width / 2);
2027
+ const end = Math.max(off.center + off.width / 2, on.center + on.width / 2);
2028
+ const center = off.center + (on.center - off.center) * p;
2029
+ const half = width / 2;
2030
+ const shift = (start + half > end - half ? (start + end) / 2 : Math.max(start + half, Math.min(end - half, center))) - (now.on ? on : off).center;
2031
+ writeMotionStyle(knob, {
2032
+ translate: `calc(${now.translate[0]} + ${shift.toFixed(2)}px) ${now.translate[1]}`,
2033
+ scale: `${(width / now.width).toFixed(4)} ${(height / now.height).toFixed(4)}`
2034
+ });
2035
+ }
2036
+ /**
2037
+ * True when the knob still moves with a CSS transition of its own, as Nuxt UI's thumb does without the ViteHub theme.
2038
+ * The transition would smear each frame of the springs, so that knob keeps its own motion.
2039
+ */
2040
+ function transitionsKnob(knob) {
2041
+ const style = getComputedStyle(knob);
2042
+ const durations = style.transitionDuration.split(",");
2043
+ return style.transitionProperty.split(",").some((property, index) => /^\s*(?:transform|translate|scale|all)\s*$/.test(property) && Number.parseFloat(durations[index % durations.length]) > 0);
2044
+ }
2045
+ function knobOf(element, wasOn) {
2046
+ const existing = knobs.get(element);
2047
+ if (existing && existing.knob.isConnected && element.contains(existing.knob)) return existing;
2048
+ const knob = findKnob(element);
2049
+ if (!knob || transitionsKnob(knob)) return;
2050
+ const value = wasOn ? 1 : 0;
2051
+ const redraw = () => draw$1(element, state);
2052
+ const state = {
2053
+ knob,
2054
+ rest: [void 0, void 0],
2055
+ now: {
2056
+ on: wasOn,
2057
+ translate: ["0px", "0px"],
2058
+ width: 1,
2059
+ height: 1
2060
+ },
2061
+ position: createSpring(value, (position, velocity) => {
2062
+ state.velocity = velocity;
2063
+ redraw();
2064
+ }, travel),
2065
+ velocity: 0,
2066
+ size: createSpring(value, redraw, size),
2067
+ press: createSpring(0, redraw, pressSpring),
2068
+ wobble: createSpring(0, redraw, wobble),
2069
+ wobbleTimer: void 0
2070
+ };
2071
+ knobs.set(element, state);
2072
+ return state;
2073
+ }
2074
+ /** Measures the state that the stylesheet draws now and keeps it as the rest of that state. */
2075
+ function remeasure(element, state, on) {
2076
+ const { rest, translate, width, height } = measure(element, state.knob);
2077
+ state.rest[on ? 1 : 0] = rest;
2078
+ state.now = {
2079
+ on,
2080
+ translate,
2081
+ width,
2082
+ height
2083
+ };
2084
+ }
2085
+ function disabled(element) {
2086
+ return element.matches(":disabled, [aria-disabled=\"true\"]");
2087
+ }
2088
+ const switchKnob = {
2089
+ name: "switch",
2090
+ selector: "[role=switch]",
2091
+ press(element) {
2092
+ if (disabled(element)) return;
2093
+ const on = isOn(element.getAttribute("aria-checked"));
2094
+ const state = knobOf(element, on);
2095
+ if (!state) return;
2096
+ if (!state.position.active) remeasure(element, state, on);
2097
+ state.press.to(1);
2098
+ return { release: () => state.press.to(0) };
2099
+ },
2100
+ state(element, { attribute, oldValue, value }) {
2101
+ if (attribute !== "aria-checked") return;
2102
+ const on = isOn(value);
2103
+ const state = knobOf(element, isOn(oldValue));
2104
+ if (!state) return;
2105
+ remeasure(element, state, on);
2106
+ state.position.to(on ? 1 : 0);
2107
+ state.size.to(on ? 1 : 0);
2108
+ clearTimeout(state.wobbleTimer);
2109
+ state.wobbleTimer = void 0;
2110
+ if (!prefersReducedMotion()) state.wobbleTimer = setTimeout(() => {
2111
+ state.wobbleTimer = void 0;
2112
+ state.wobble.to(0, { velocity: wobbleKick });
2113
+ }, wobbleDelay * getMotionSlowFactor());
2114
+ draw$1(element, state);
2115
+ }
2116
+ };
2117
+ // src/motion/effects/toast.ts
2118
+ const crossfade$1 = .15;
2119
+ const lists = /* @__PURE__ */ new WeakMap();
2120
+ const fixed = (element) => !!element && getComputedStyle(element).position === "fixed";
2121
+ function isToast(element) {
2122
+ const list = element.parentElement;
2123
+ if (!list || list.tagName !== "OL" && list.tagName !== "UL") return false;
2124
+ const region = list.closest("[role=region], [data-slot=toast-region]");
2125
+ return !!region && (fixed(list) || fixed(list.parentElement) || fixed(region));
2126
+ }
2127
+ function edgeOf$1(rect) {
2128
+ return rect.top + rect.height / 2 > innerHeight / 2 ? "bottom" : "top";
2129
+ }
2130
+ function pastEdge(rect) {
2131
+ return edgeOf$1(rect) === "bottom" ? innerHeight - rect.top : -(rect.top + rect.height);
2132
+ }
2133
+ function exitOf(rect, direction) {
2134
+ if (direction === "left") return {
2135
+ axis: "x",
2136
+ distance: -rect.right
2137
+ };
2138
+ if (direction === "right") return {
2139
+ axis: "x",
2140
+ distance: innerWidth - rect.left
2141
+ };
2142
+ if (direction === "up") return {
2143
+ axis: "y",
2144
+ distance: -rect.bottom
2145
+ };
2146
+ if (direction === "down") return {
2147
+ axis: "y",
2148
+ distance: innerHeight - rect.top
2149
+ };
2150
+ const center = rect.left + rect.width / 2;
2151
+ if (Math.abs(center - innerWidth / 2) < innerWidth / 8) return {
2152
+ axis: "y",
2153
+ distance: pastEdge(rect)
2154
+ };
2155
+ return {
2156
+ axis: "x",
2157
+ distance: center > innerWidth / 2 ? innerWidth - rect.left : -rect.right
2158
+ };
2159
+ }
2160
+ function exitDirection(list, element) {
2161
+ const align = list.region.getAttribute("data-align");
2162
+ if (align === "center") return list.region.getAttribute("data-side") === "top" ? "up" : "down";
2163
+ if (align === "start" || align === "end") return align === "start" !== (getComputedStyle(list.region).direction === "rtl") ? "left" : "right";
2164
+ return element.getAttribute("data-swipe-direction");
2165
+ }
2166
+ function swipeOffset(element, axis, released = false) {
2167
+ const reka = `--reka-toast-swipe-${released ? "end" : "move"}-${axis}`;
2168
+ return Number.parseFloat(element.style.getPropertyValue(reka) || element.style.getPropertyValue(`--toast-swipe-${axis}`)) || 0;
2169
+ }
2170
+ function write(element, x, y, fade) {
2171
+ const still = Math.abs(x.value) < .01 && Math.abs(y.value) < .01;
2172
+ const offset = (value, axis) => {
2173
+ return `calc(${`${Math.round(value * 100) / 100}px`} + var(--reka-toast-swipe-move-${axis}, var(--toast-swipe-${axis}, 0px)))`;
2174
+ };
2175
+ writeMotionStyle(element, {
2176
+ translate: still && !x.active && !y.active ? null : `${offset(x.value, "x")} ${offset(y.value, "y")}`,
2177
+ opacity: fade && (fade.active || fade.value < 1) ? String(fade.value) : null
2178
+ });
2179
+ }
2180
+ function createItem(element, rest) {
2181
+ const item = {
2182
+ element,
2183
+ rest
2184
+ };
2185
+ const frame = () => write(element, item.x, item.y, item.fade);
2186
+ item.x = createSpring(0, frame, springs.snappy);
2187
+ item.y = createSpring(0, frame, springs.snappy);
2188
+ return item;
2189
+ }
2190
+ function shift(spring, distance) {
2191
+ const velocity = spring.velocity;
2192
+ spring.set(spring.value + distance);
2193
+ spring.to(0, { velocity });
2194
+ }
2195
+ function relayout(list) {
2196
+ for (const item of list.items.values()) {
2197
+ if (!item.element.isConnected) continue;
2198
+ const rect = item.element.getBoundingClientRect();
2199
+ const rest = {
2200
+ left: rect.left - item.x.value - swipeOffset(item.element, "x"),
2201
+ top: rect.top - item.y.value - swipeOffset(item.element, "y"),
2202
+ width: rect.width,
2203
+ height: rect.height
2204
+ };
2205
+ const dx = item.rest.left - rest.left;
2206
+ const dy = item.rest.top - rest.top;
2207
+ item.rest = rest;
2208
+ if (Math.abs(dx) > .5) shift(item.x, dx);
2209
+ if (Math.abs(dy) > .5) shift(item.y, dy);
2210
+ }
2211
+ }
2212
+ function watchLayout(list) {
2213
+ list.watchFrames = 12;
2214
+ if (list.frame) return;
2215
+ const step = () => {
2216
+ relayout(list);
2217
+ list.watchFrames = [...list.items.values()].some((item) => item.x.active || item.y.active) ? Math.max(list.watchFrames, 2) : list.watchFrames - 1;
2218
+ list.frame = list.watchFrames > 0 ? requestAnimationFrame(step) : 0;
2219
+ };
2220
+ list.frame = requestAnimationFrame(step);
2221
+ }
2222
+ function leave$1(list, element) {
2223
+ const item = list.items.get(element);
2224
+ if (!item) return;
2225
+ list.items.delete(element);
2226
+ item.x.stop();
2227
+ item.y.stop();
2228
+ const direction = exitDirection(list, element);
2229
+ const swipe = element.getAttribute("data-swipe") === "end" || element.matches("[data-slot=toast]") && element.hasAttribute("data-swipe-direction");
2230
+ const swipeDirection = swipe ? element.getAttribute("data-swipe-direction") : null;
2231
+ const parent = list.region.parentNode;
2232
+ if (parent) {
2233
+ const rect = new DOMRect(item.rest.left + item.x.value + (swipe ? swipeOffset(element, "x", true) : 0), item.rest.top + item.y.value + (swipe ? swipeOffset(element, "y", true) : 0), item.rest.width, item.rest.height);
2234
+ const ghost = createGhost(element, parent, list.region.nextSibling);
2235
+ writeMotionStyle(ghost, {
2236
+ translate: null,
2237
+ opacity: null
2238
+ });
2239
+ pinGhost(ghost, rect);
2240
+ if (prefersReducedMotion()) {
2241
+ const fade = createSpring(1, (value) => {
2242
+ writeMotionStyle(ghost, { opacity: String(value) });
2243
+ if (!fade.active && value === 0) ghost.remove();
2244
+ });
2245
+ fade.to(0, { tween: crossfade$1 });
2246
+ } else {
2247
+ const { axis, distance: target } = exitOf(rect, swipeDirection ?? direction);
2248
+ const spring = createSpring(0, (value) => {
2249
+ const offset = `${Math.round(value * 100) / 100}px`;
2250
+ writeMotionStyle(ghost, { translate: axis === "x" ? `${offset} 0px` : `0px ${offset}` });
2251
+ if ((target > 0 ? value >= target : value <= target) || !spring.active) {
2252
+ spring.stop();
2253
+ ghost.remove();
2254
+ }
2255
+ }, springs.snappy);
2256
+ spring.to(target);
2257
+ }
2258
+ }
2259
+ relayout(list);
2260
+ watchLayout(list);
2261
+ if (!list.items.size) {
2262
+ list.observer.disconnect();
2263
+ lists.delete(list.element);
2264
+ }
2265
+ }
2266
+ function listOf(element) {
2267
+ const parent = element.parentElement;
2268
+ let list = lists.get(parent);
2269
+ if (list) return list;
2270
+ const current = {
2271
+ element: parent,
2272
+ items: /* @__PURE__ */ new Map(),
2273
+ observer: new MutationObserver((records) => {
2274
+ for (const record of records) for (const node of record.removedNodes) if (node instanceof HTMLElement && !node.isConnected) leave$1(current, node);
2275
+ }),
2276
+ region: parent.closest("[role=region], [data-slot=toast-region]") ?? parent,
2277
+ watchFrames: 0,
2278
+ frame: 0
2279
+ };
2280
+ current.observer.observe(parent, { childList: true });
2281
+ lists.set(parent, current);
2282
+ list = current;
2283
+ return list;
2284
+ }
2285
+ /**
2286
+ * Something arrives on its own: a toast comes in from its edge of the screen, and the toasts that the list moves make
2287
+ * room with a spring. A toast that closes leaves past the side of the screen that the toaster sits at, and the others
2288
+ * close the gap. A toast that a person
2289
+ * swiped away leaves from where they let go. Under reduced motion a toast crossfades in and out in 150ms, and the others
2290
+ * take their new places at once.
2291
+ *
2292
+ * It is a role effect on the items of a notifications region, so Nuxt UI's `UToast` and ui-sdk's `Toast` both get it.
2293
+ */
2294
+ const toast = {
2295
+ name: "toast",
2296
+ selector: "[role=region] li, [data-slot=toast]",
2297
+ enter(element) {
2298
+ if (!isToast(element)) return;
2299
+ const list = listOf(element);
2300
+ if (list.items.has(element)) return;
2301
+ relayout(list);
2302
+ const rect = element.getBoundingClientRect();
2303
+ const item = createItem(element, {
2304
+ left: rect.left,
2305
+ top: rect.top,
2306
+ width: rect.width,
2307
+ height: rect.height
2308
+ });
2309
+ list.items.set(element, item);
2310
+ if (prefersReducedMotion()) {
2311
+ const fade = createSpring(0, () => write(element, item.x, item.y, fade));
2312
+ item.fade = fade;
2313
+ fade.set(0);
2314
+ fade.to(1, { tween: crossfade$1 });
2315
+ } else {
2316
+ item.y.set(pastEdge(rect));
2317
+ item.y.to(0);
2318
+ }
2319
+ watchLayout(list);
2320
+ }
2321
+ };
2322
+ // src/motion/effects/tooltip.ts
2323
+ const slide = {
2324
+ stiffness: 480,
2325
+ damping: 36
2326
+ };
2327
+ const rise = {
2328
+ stiffness: 380,
2329
+ damping: 26
2330
+ };
2331
+ const widen = {
2332
+ stiffness: 440,
2333
+ damping: 32
2334
+ };
2335
+ const narrow = 30;
2336
+ const widenAfter = 120;
2337
+ const labelAfterRise = 70;
2338
+ const labelAfterSlide = 40;
2339
+ const sinkAfter = 90;
2340
+ const goneAfter = 520;
2341
+ const labelIn = .24;
2342
+ const labelOutOnSlide = .15;
2343
+ const labelOutOnLeave = .14;
2344
+ const crossfade = .15;
2345
+ const tips = /* @__PURE__ */ new WeakMap();
2346
+ const openTips = /* @__PURE__ */ new Set();
2347
+ const exitBoxes = /* @__PURE__ */ new Set();
2348
+ let handoff;
2349
+ function visuallyHidden(element) {
2350
+ const style = getComputedStyle(element);
2351
+ return style.clipPath === "inset(50%)" || style.clip === "rect(0px, 0px, 0px, 0px)";
2352
+ }
2353
+ function roleElement(box) {
2354
+ return box.matches("[role=tooltip]") ? box : box.querySelector(":scope > [role=tooltip]");
2355
+ }
2356
+ /** An element that is not a tooltip but appears next to its trigger in the same way, such as a comment's draft bubble. */
2357
+ const appearSelector = "[data-motion-appear]";
2358
+ function visualBox(element) {
2359
+ if (element.matches(appearSelector)) return element;
2360
+ if (element.matches("[role=tooltip]")) return visuallyHidden(element) ? element.parentElement : element;
2361
+ const inner = element.querySelector(":scope > [role=tooltip]");
2362
+ return inner && visuallyHidden(inner) ? element : null;
2363
+ }
2364
+ function isOpen(box) {
2365
+ const state = box.getAttribute("data-state");
2366
+ if (state !== null) return state !== "closed";
2367
+ return !box.hidden && !box.hasAttribute("data-closed");
2368
+ }
2369
+ /**
2370
+ * The trigger of a tooltip: the element that `aria-describedby` points at it. The trigger of a `data-motion-appear`
2371
+ * element is the nearest element around it that its value selects, else a sibling that it selects, or none for an
2372
+ * empty value.
2373
+ */
2374
+ function findTrigger(box) {
2375
+ const anchor = box.getAttribute("data-motion-appear");
2376
+ if (anchor !== null) {
2377
+ const parent = box.parentElement;
2378
+ if (!anchor || !parent) return null;
2379
+ return parent.closest(anchor) ?? [...parent.children].find((sibling) => sibling !== box && sibling.matches(anchor)) ?? null;
2380
+ }
2381
+ const id = roleElement(box)?.id;
2382
+ if (!id) return null;
2383
+ return box.getRootNode().querySelector(`[aria-describedby~="${CSS.escape(id)}"]`) ?? document.querySelector(`[aria-describedby~="${CSS.escape(id)}"]`);
2384
+ }
2385
+ function measureRest(element) {
2386
+ const saved = [
2387
+ "translate",
2388
+ "scale",
2389
+ "clip-path",
2390
+ "opacity"
2391
+ ].map((name) => [name, element.style.getPropertyValue(name)]);
2392
+ writeMotionStyle(element, {
2393
+ translate: null,
2394
+ scale: null,
2395
+ "clip-path": null
2396
+ });
2397
+ const rect = element.getBoundingClientRect();
2398
+ for (const [name, value] of saved) if (value) element.style.setProperty(name, value);
2399
+ return rect;
2400
+ }
2401
+ function sideOf(box, rest, trigger) {
2402
+ const side = box.getAttribute("data-side");
2403
+ if (side === "top" || side === "bottom" || side === "left" || side === "right") return side;
2404
+ if (!trigger) return "top";
2405
+ const dx = trigger.left + trigger.width / 2 - (rest.left + rest.width / 2);
2406
+ const dy = trigger.top + trigger.height / 2 - (rest.top + rest.height / 2);
2407
+ if (Math.abs(dy) >= Math.abs(dx)) return dy > 0 ? "top" : "bottom";
2408
+ return dx > 0 ? "left" : "right";
2409
+ }
2410
+ function edgeOf(side, rest, trigger) {
2411
+ if (side === "top") return trigger?.top ?? rest.bottom + 8;
2412
+ if (side === "bottom") return trigger?.bottom ?? rest.top - 8;
2413
+ if (side === "left") return trigger?.left ?? rest.right + 8;
2414
+ return trigger?.right ?? rest.left - 8;
2415
+ }
2416
+ const vertical = (side) => side === "top" || side === "bottom";
2417
+ function hiddenCenter(box) {
2418
+ const { rest, side, edge } = box;
2419
+ if (side === "top") return edge + rest.height / 2;
2420
+ if (side === "bottom") return edge - rest.height / 2;
2421
+ if (side === "left") return edge + rest.width / 2;
2422
+ return edge - rest.width / 2;
2423
+ }
2424
+ function labelElements(box) {
2425
+ return [...box.element.children].filter((child) => child instanceof HTMLElement && child !== box.old?.element && !child.matches("[role=tooltip]") && !visuallyHidden(child));
2426
+ }
2427
+ function labelText(box) {
2428
+ return [...box.element.childNodes].filter((node) => node.nodeType === Node.TEXT_NODE || node instanceof Element && node !== box.old?.element && !node.matches("[role=tooltip]") && !visuallyHidden(node)).map((node) => node.textContent ?? "").join("");
2429
+ }
2430
+ function hasTextOfItsOwn(element) {
2431
+ return [...element.childNodes].some((node) => node.nodeType === Node.TEXT_NODE && node.textContent?.trim());
2432
+ }
2433
+ const px = (value) => `${Math.round(value * 100) / 100}px`;
2434
+ function draw(box) {
2435
+ const { element, rest, side, edge, origin } = box;
2436
+ const width = Math.max(1, box.width.value);
2437
+ const reveal = box.mode === "clip" && width < rest.width;
2438
+ const scale = reveal ? 1 : width / rest.width;
2439
+ const left = box.x.value - width / 2;
2440
+ const tx = reveal ? box.x.value - (rest.left + rest.width / 2) : left - rest.left - origin * (1 - scale);
2441
+ const ty = box.y.value - (rest.top + rest.height / 2);
2442
+ const insets = [
2443
+ -40,
2444
+ -40,
2445
+ -40,
2446
+ -40
2447
+ ];
2448
+ if (side === "top") insets[2] = box.y.value + rest.height / 2 - edge;
2449
+ if (side === "bottom") insets[0] = edge - (box.y.value - rest.height / 2);
2450
+ if (side === "left") insets[1] = (box.x.value + width / 2 - edge) / scale;
2451
+ if (side === "right") insets[3] = (edge - (box.x.value - width / 2)) / scale;
2452
+ const behind = insets.some((inset) => inset > 0);
2453
+ let clip = null;
2454
+ if (reveal) {
2455
+ const hidden = (rest.width - width) / 2;
2456
+ clip = `inset(${[
2457
+ Math.max(0, insets[0]),
2458
+ hidden + Math.max(0, insets[1]),
2459
+ Math.max(0, insets[2]),
2460
+ hidden + Math.max(0, insets[3])
2461
+ ].map(px).join(" ")} round ${box.radius})`;
2462
+ } else if (behind) clip = `inset(${insets.map(px).join(" ")})`;
2463
+ writeMotionStyle(element, {
2464
+ "translate": Math.abs(tx) > .01 || Math.abs(ty) > .01 || box.old ? `${px(tx)} ${px(ty)}` : null,
2465
+ "scale": Math.abs(scale - 1) > .001 ? `${scale} 1` : null,
2466
+ "clip-path": clip,
2467
+ "opacity": box.fade.active || box.fade.value < 1 ? String(box.fade.value) : null
2468
+ });
2469
+ const inverse = Math.abs(scale - 1) > .001 ? `${1 / scale} 1` : null;
2470
+ const label = box.label.value;
2471
+ for (const child of labelElements(box)) writeMotionStyle(child, {
2472
+ scale: inverse,
2473
+ opacity: label < 1 ? String(label) : null,
2474
+ filter: label < 1 ? `blur(${px((1 - label) * 6)})` : null
2475
+ });
2476
+ if (box.old) {
2477
+ const value = box.old.spring.value;
2478
+ writeMotionStyle(box.old.element, {
2479
+ scale: inverse,
2480
+ opacity: String(value),
2481
+ filter: `blur(${px((1 - value) * 5)})`
2482
+ });
2483
+ }
2484
+ }
2485
+ function settle(box) {
2486
+ if (box.holding || box.timers.size || [
2487
+ box.x,
2488
+ box.y,
2489
+ box.width,
2490
+ box.label,
2491
+ box.fade,
2492
+ box.old?.spring
2493
+ ].some((spring) => spring?.active)) return;
2494
+ box.old?.element.remove();
2495
+ box.old = void 0;
2496
+ writeMotionStyle(box.element, {
2497
+ "translate": null,
2498
+ "scale": null,
2499
+ "clip-path": null,
2500
+ "opacity": null
2501
+ });
2502
+ for (const child of labelElements(box)) writeMotionStyle(child, {
2503
+ scale: null,
2504
+ opacity: null,
2505
+ filter: null
2506
+ });
2507
+ box.done?.();
2508
+ }
2509
+ function createBox(element, rest, trigger) {
2510
+ const style = getComputedStyle(element);
2511
+ const side = sideOf(element, rest, trigger);
2512
+ const box = {
2513
+ element,
2514
+ rest,
2515
+ origin: Number.parseFloat(style.transformOrigin) || rest.width / 2,
2516
+ side,
2517
+ edge: edgeOf(side, rest, trigger),
2518
+ trigger,
2519
+ mode: hasTextOfItsOwn(element) || element.matches(appearSelector) ? "clip" : "scale",
2520
+ handoff: !element.matches(appearSelector),
2521
+ radius: style.borderRadius || "0px",
2522
+ timers: /* @__PURE__ */ new Set(),
2523
+ holding: true
2524
+ };
2525
+ const frame = () => {
2526
+ draw(box);
2527
+ settle(box);
2528
+ };
2529
+ box.x = createSpring(rest.left + rest.width / 2, frame, slide);
2530
+ box.y = createSpring(rest.top + rest.height / 2, frame, slide);
2531
+ box.width = createSpring(rest.width, frame, widen);
2532
+ box.label = createSpring(1, frame);
2533
+ box.fade = createSpring(1, frame);
2534
+ return box;
2535
+ }
2536
+ function later(box, ms, step) {
2537
+ const timer = after(ms, () => {
2538
+ box.timers.delete(timer);
2539
+ step();
2540
+ settle(box);
2541
+ });
2542
+ box.timers.add(timer);
2543
+ }
2544
+ function stopBox(box) {
2545
+ for (const timer of box.timers) clearTimeout(timer);
2546
+ box.timers.clear();
2547
+ for (const spring of [
2548
+ box.x,
2549
+ box.y,
2550
+ box.width,
2551
+ box.label,
2552
+ box.fade,
2553
+ box.old?.spring
2554
+ ]) spring?.stop();
2555
+ }
2556
+ function removeGhost(box) {
2557
+ stopBox(box);
2558
+ exitBoxes.delete(box);
2559
+ if (handoff === box) handoff = void 0;
2560
+ box.element.closest("[data-motion=none]")?.remove();
2561
+ }
2562
+ function reduceTooltips(reduced) {
2563
+ if (!reduced) return;
2564
+ for (const ghost of exitBoxes) removeGhost(ghost);
2565
+ for (const element of openTips) {
2566
+ const box = tips.get(element)?.box;
2567
+ if (!box) continue;
2568
+ stopBox(box);
2569
+ box.holding = true;
2570
+ box.x.set(box.rest.left + box.rest.width / 2);
2571
+ box.y.set(box.rest.top + box.rest.height / 2);
2572
+ box.width.set(box.rest.width);
2573
+ box.label.set(1);
2574
+ box.fade.set(1);
2575
+ box.holding = false;
2576
+ settle(box);
2577
+ }
2578
+ }
2579
+ function nextTo(from, to) {
2580
+ const a = from.trigger;
2581
+ const b = to.trigger;
2582
+ if (!a || !b || from.side !== to.side) return false;
2583
+ return vertical(to.side) ? a.top < b.bottom && b.top < a.bottom : a.left < b.right && b.left < a.right;
2584
+ }
2585
+ function along(box) {
2586
+ return vertical(box.side) ? box.y : box.x;
2587
+ }
2588
+ function blurOutOld(box, nodes, from) {
2589
+ if (!nodes.length) return;
2590
+ const element = document.createElement("span");
2591
+ element.setAttribute("aria-hidden", "true");
2592
+ Object.assign(element.style, {
2593
+ position: "absolute",
2594
+ inset: "0",
2595
+ display: "flex",
2596
+ alignItems: "center",
2597
+ justifyContent: "center",
2598
+ gap: "inherit",
2599
+ pointerEvents: "none",
2600
+ whiteSpace: "nowrap"
2601
+ });
2602
+ element.append(...nodes);
2603
+ box.element.append(element);
2604
+ const spring = createSpring(from, () => {
2605
+ draw(box);
2606
+ settle(box);
2607
+ });
2608
+ box.old = {
2609
+ element,
2610
+ spring
2611
+ };
2612
+ spring.to(0, { tween: labelOutOnSlide });
2613
+ }
2614
+ function copyLabel(box) {
2615
+ if (box.mode === "clip") return [...box.element.childNodes].filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.cloneNode());
2616
+ return labelElements(box).map((child) => {
2617
+ const copy = child.cloneNode(true);
2618
+ copy.style.removeProperty("scale");
2619
+ copy.style.removeProperty("opacity");
2620
+ copy.style.removeProperty("filter");
2621
+ return copy;
2622
+ });
2623
+ }
2624
+ function start(element, tip) {
2625
+ const triggerRect = tip.trigger?.getBoundingClientRect();
2626
+ const rest = measureRest(element);
2627
+ const box = createBox(element, rest, triggerRect);
2628
+ tip.box = box;
2629
+ tip.text = labelText(box);
2630
+ tip.label = copyLabel(box);
2631
+ writeMotionStyle(element, { opacity: null });
2632
+ const from = box.handoff && handoff && nextTo(handoff, box) ? handoff : void 0;
2633
+ if (from) handoff = void 0;
2634
+ if (prefersReducedMotion()) {
2635
+ if (from) leaveGhost(from, true);
2636
+ box.fade.set(0);
2637
+ box.holding = false;
2638
+ box.fade.to(1, { tween: crossfade });
2639
+ return;
2640
+ }
2641
+ if (from) {
2642
+ const old = copyLabel(from);
2643
+ const values = {
2644
+ x: [from.x.value, from.x.velocity],
2645
+ y: [from.y.value, from.y.velocity],
2646
+ width: [from.width.value, from.width.velocity]
2647
+ };
2648
+ const label = from.old ? 0 : from.label.value;
2649
+ removeGhost(from);
2650
+ box.x.set(values.x[0]);
2651
+ box.y.set(values.y[0]);
2652
+ box.width.set(values.width[0]);
2653
+ box.label.set(0);
2654
+ blurOutOld(box, old, label);
2655
+ box.x.to(rest.left + rest.width / 2, {
2656
+ preset: slide,
2657
+ velocity: values.x[1]
2658
+ });
2659
+ box.y.to(rest.top + rest.height / 2, {
2660
+ preset: slide,
2661
+ velocity: values.y[1]
2662
+ });
2663
+ box.width.to(rest.width, {
2664
+ preset: widen,
2665
+ velocity: values.width[1]
2666
+ });
2667
+ later(box, labelAfterSlide, () => box.label.to(1, { tween: labelIn }));
2668
+ box.holding = false;
2669
+ draw(box);
2670
+ return;
2671
+ }
2672
+ along(box).set(hiddenCenter(box));
2673
+ box.width.set(Math.min(narrow, rest.width));
2674
+ box.label.set(0);
2675
+ draw(box);
2676
+ along(box).to(vertical(box.side) ? rest.top + rest.height / 2 : rest.left + rest.width / 2, { preset: rise });
2677
+ later(box, widenAfter, () => {
2678
+ box.width.to(rest.width, { preset: widen });
2679
+ later(box, labelAfterRise, () => box.label.to(1, { tween: labelIn }));
2680
+ });
2681
+ box.holding = false;
2682
+ }
2683
+ function leaveGhost(box, reduced) {
2684
+ exitBoxes.add(box);
2685
+ box.holding = false;
2686
+ if (reduced) {
2687
+ box.done = () => removeGhost(box);
2688
+ box.fade.to(0, { tween: crossfade });
2689
+ return;
2690
+ }
2691
+ if (box.handoff) handoff = box;
2692
+ if (box.old) box.old.spring.to(0, { tween: labelOutOnLeave });
2693
+ box.label.to(0, { tween: labelOutOnLeave });
2694
+ box.width.to(Math.min(narrow, box.rest.width), { preset: widen });
2695
+ later(box, sinkAfter, () => {
2696
+ if (handoff === box) handoff = void 0;
2697
+ along(box).to(hiddenCenter(box), { preset: rise });
2698
+ });
2699
+ later(box, goneAfter, () => removeGhost(box));
2700
+ }
2701
+ function leave(element, tip) {
2702
+ if (!tip.open) return;
2703
+ tip.open = false;
2704
+ openTips.delete(element);
2705
+ tip.stopWatch?.();
2706
+ tip.stopWatch = void 0;
2707
+ if (!openTips.size) stopWatchingMoves();
2708
+ const box = tip.box;
2709
+ tip.box = void 0;
2710
+ writeMotionStyle(element, { opacity: null });
2711
+ if (!box) return;
2712
+ const parent = tip.root.parentNode ?? tip.parent;
2713
+ const ghostRoot = parent?.isConnected ? createGhost(tip.root, parent, tip.root.isConnected ? tip.root.nextSibling : tip.next) : void 0;
2714
+ const now = {
2715
+ x: box.x,
2716
+ y: box.y,
2717
+ width: box.width,
2718
+ label: box.label,
2719
+ fade: box.fade
2720
+ };
2721
+ const values = Object.fromEntries(Object.entries(now).map(([name, spring]) => [name, [spring.value, spring.velocity]]));
2722
+ const oldLabel = box.old?.spring.value;
2723
+ stopBox(box);
2724
+ box.old?.element.remove();
2725
+ writeMotionStyle(element, {
2726
+ "translate": null,
2727
+ "scale": null,
2728
+ "clip-path": null,
2729
+ "opacity": null
2730
+ });
2731
+ for (const child of labelElements(box)) writeMotionStyle(child, {
2732
+ scale: null,
2733
+ opacity: null,
2734
+ filter: null
2735
+ });
2736
+ if (!ghostRoot) return;
2737
+ const ghostElement = pathTo(tip.root, element).reduce((node, index) => node?.children[index], ghostRoot);
2738
+ if (!(ghostElement instanceof HTMLElement)) {
2739
+ ghostRoot.remove();
2740
+ return;
2741
+ }
2742
+ if (element.hasAttribute("popover")) {
2743
+ writeMotionStyle(ghostElement, { scale: null });
2744
+ pinGhost(ghostElement, box.rest);
2745
+ }
2746
+ const ghost = createBox(ghostElement, box.rest, void 0);
2747
+ Object.assign(ghost, {
2748
+ side: box.side,
2749
+ edge: box.edge,
2750
+ trigger: box.trigger,
2751
+ mode: box.mode,
2752
+ origin: box.origin,
2753
+ radius: box.radius,
2754
+ handoff: box.handoff
2755
+ });
2756
+ const old = ghostElement.querySelector(":scope > [aria-hidden=true][style*=absolute]");
2757
+ if (oldLabel !== void 0 && old) ghost.old = {
2758
+ element: old,
2759
+ spring: createSpring(oldLabel, () => draw(ghost))
2760
+ };
2761
+ for (const name of [
2762
+ "x",
2763
+ "y",
2764
+ "width",
2765
+ "label",
2766
+ "fade"
2767
+ ]) ghost[name].set(values[name][0]);
2768
+ draw(ghost);
2769
+ for (const name of [
2770
+ "x",
2771
+ "y",
2772
+ "width"
2773
+ ]) if (values[name][1]) ghost[name].to(values[name][0], { velocity: values[name][1] });
2774
+ leaveGhost(ghost, prefersReducedMotion());
2775
+ }
2776
+ function pathTo(root, element) {
2777
+ const path = [];
2778
+ for (let node = element; node !== root && node.parentElement; node = node.parentElement) path.unshift([...node.parentElement.children].indexOf(node));
2779
+ return path;
2780
+ }
2781
+ function whenPlaced(element, tip, callback, frames = 20) {
2782
+ requestAnimationFrame(() => {
2783
+ if (!tip.open || !element.isConnected) return;
2784
+ const wrapper = element.closest("[data-reka-popper-content-wrapper]");
2785
+ if (frames > 0 && wrapper?.style.transform.includes("-200%")) return whenPlaced(element, tip, callback, frames - 1);
2786
+ callback();
2787
+ });
2788
+ }
2789
+ function watchRemoval(element, tip) {
2790
+ const observe = () => {
2791
+ observer.disconnect();
2792
+ let node = element;
2793
+ while (node) {
2794
+ const parent = node.parentNode;
2795
+ if (parent) observer.observe(parent, { childList: true });
2796
+ node = parent ?? (node instanceof ShadowRoot ? node.host : null);
2797
+ }
2798
+ };
2799
+ const observer = new MutationObserver(() => {
2800
+ if (!element.isConnected) leave(element, tip);
2801
+ else {
2802
+ tip.parent = tip.root.parentNode;
2803
+ tip.next = tip.root.nextSibling;
2804
+ observe();
2805
+ }
2806
+ });
2807
+ observe();
2808
+ return () => observer.disconnect();
2809
+ }
2810
+ function open(element) {
2811
+ let tip = tips.get(element);
2812
+ if (tip?.open) return;
2813
+ const trigger = findTrigger(element);
2814
+ if (trigger && isMotionOff(trigger)) return;
2815
+ const root = element.closest("[data-reka-popper-content-wrapper]") ?? element;
2816
+ tip = {
2817
+ open: true,
2818
+ root,
2819
+ parent: root.parentNode,
2820
+ next: root.nextSibling,
2821
+ text: "",
2822
+ label: [],
2823
+ trigger
2824
+ };
2825
+ tips.set(element, tip);
2826
+ openTips.add(element);
2827
+ watchMoves();
2828
+ writeMotionStyle(element, { opacity: "0" });
2829
+ tip.stopWatch = watchRemoval(element, tip);
2830
+ const current = tip;
2831
+ whenPlaced(element, tip, () => start(element, current));
2832
+ }
2833
+ let checking = 0;
2834
+ function checkMoves() {
2835
+ checking = 0;
2836
+ for (const element of openTips) {
2837
+ const tip = tips.get(element);
2838
+ const box = tip?.box;
2839
+ if (!tip || !box) continue;
2840
+ const rest = measureRest(element);
2841
+ const text = labelText(box);
2842
+ if (!(Math.abs(rest.left - box.rest.left) > 1 || Math.abs(rest.top - box.rest.top) > 1 || Math.abs(rest.width - box.rest.width) > 1) && text === tip.text) continue;
2843
+ const old = text === tip.text ? [] : tip.label;
2844
+ tip.trigger = findTrigger(element) ?? tip.trigger;
2845
+ const triggerRect = tip.trigger?.getBoundingClientRect();
2846
+ tip.text = text;
2847
+ tip.label = copyLabel(box);
2848
+ box.rest = rest;
2849
+ box.side = sideOf(element, rest, triggerRect);
2850
+ box.edge = edgeOf(box.side, rest, triggerRect);
2851
+ if (prefersReducedMotion()) {
2852
+ box.x.set(rest.left + rest.width / 2);
2853
+ box.y.set(rest.top + rest.height / 2);
2854
+ box.width.set(rest.width);
2855
+ continue;
2856
+ }
2857
+ box.x.to(rest.left + rest.width / 2, { preset: slide });
2858
+ box.y.to(rest.top + rest.height / 2, { preset: slide });
2859
+ box.width.to(rest.width, { preset: widen });
2860
+ if (old.length) {
2861
+ box.old?.spring.stop();
2862
+ box.old?.element.remove();
2863
+ blurOutOld(box, old, box.label.value);
2864
+ box.label.set(0);
2865
+ later(box, labelAfterSlide, () => box.label.to(1, { tween: labelIn }));
2866
+ }
2867
+ }
2868
+ }
2869
+ function onMove() {
2870
+ if (!checking) checking = requestAnimationFrame(checkMoves);
2871
+ }
2872
+ let watching = false;
2873
+ let stopWatchingReduction;
2874
+ function watchMoves() {
2875
+ stopWatchingReduction ??= onReducedMotionChange(reduceTooltips);
2876
+ if (watching) return;
2877
+ watching = true;
2878
+ document.addEventListener("pointerover", onMove, {
2879
+ capture: true,
2880
+ passive: true
2881
+ });
2882
+ document.addEventListener("focusin", onMove, {
2883
+ capture: true,
2884
+ passive: true
2885
+ });
2886
+ }
2887
+ function stopWatchingMoves() {
2888
+ watching = false;
2889
+ cancelAnimationFrame(checking);
2890
+ checking = 0;
2891
+ document.removeEventListener("pointerover", onMove, { capture: true });
2892
+ document.removeEventListener("focusin", onMove, { capture: true });
2893
+ }
2894
+ /** The hooks of a tooltip and of an element with `data-motion-appear`: both appear the same way. */
2895
+ const appearHooks = {
2896
+ enter(element) {
2897
+ if (visualBox(element) !== element || !isOpen(element)) return;
2898
+ open(element);
2899
+ },
2900
+ state(element) {
2901
+ if (visualBox(element) !== element) return;
2902
+ const tip = tips.get(element);
2903
+ if (isOpen(element)) open(element);
2904
+ else if (tip) leave(element, tip);
2905
+ }
2906
+ };
2907
+ /**
2908
+ * A tooltip appears next to its trigger: it rises from behind its trigger, narrow and without its label, widens to
2909
+ * fit, and blurs its label in. When the next trigger opens its tooltip while this one leaves, the new one takes the
2910
+ * place, size, and speed of the old one and slides over. A tooltip that closes narrows and sinks back behind its
2911
+ * trigger. Under reduced motion it crossfades in 150ms.
2912
+ *
2913
+ * Floating UI or Reka still places the tooltip. The effect only adds `translate`, `scale`, `clip-path`, `opacity`, and
2914
+ * `filter` to that.
2915
+ */
2916
+ const tooltip = {
2917
+ name: "tooltip",
2918
+ selector: "[role=tooltip], :has(> [role=tooltip])",
2919
+ ...appearHooks
2920
+ };
2921
+ /**
2922
+ * An element with `data-motion-appear` that is not a tooltip, such as a comment's draft bubble or a tab that comes out
2923
+ * of a bar, appears as a tooltip does when it is added to the page, but never takes the place of another one. Its
2924
+ * trigger is the nearest element around it, or a sibling, that the attribute's value selects; with an empty value it
2925
+ * rises from 8px past its own edge, on the side that `data-side` names. Its parts are revealed, not squeezed, while it
2926
+ * widens.
2927
+ */
2928
+ const appear = {
2929
+ name: "appear",
2930
+ selector: appearSelector,
2931
+ ...appearHooks
2932
+ };
2933
+ // src/motion/effects/index.ts
2934
+ /**
2935
+ * Every built-in effect: what `installMotion()` of `@vite-hub/ui/motion` runs. Add a role effect here, in a file of its
2936
+ * own, and export it from `src/motion-core.ts`.
2937
+ */
2938
+ const motionEffects = [
2939
+ press,
2940
+ select,
2941
+ switchKnob,
2942
+ check,
2943
+ jelly,
2944
+ tooltip,
2945
+ appear,
2946
+ toast,
2947
+ slider,
2948
+ divider,
2949
+ label,
2950
+ buttonIcon,
2951
+ disclosure,
2952
+ leave$2,
2953
+ panel
2954
+ ];
2955
+ export { divider as _, switchKnob as a, press as c, buttonIcon as d, label as f, installMotion as g, check as h, toast as i, panel as l, disclosure as m, appear as n, slider as o, jelly as p, tooltip as r, select as s, motionEffects as t, leave$2 as u };