motionary 0.0.0-stage → 6.2.0

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 (374) hide show
  1. package/CHANGELOG.md +803 -0
  2. package/LICENSE +21 -0
  3. package/README.md +218 -2
  4. package/README_ja.md +219 -0
  5. package/README_zh.md +219 -0
  6. package/bin/usa-codemod-5.mjs +79 -0
  7. package/bin/usa-codemod-6.mjs +146 -0
  8. package/dist/chunks/base-BaQV-2ha.cjs +436 -0
  9. package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
  10. package/dist/chunks/base-C_3cAoRz.js +404 -0
  11. package/dist/chunks/base-C_3cAoRz.js.map +1 -0
  12. package/dist/chunks/bind-B_CTL6Qn.js +22 -0
  13. package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
  14. package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
  15. package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
  16. package/dist/chunks/core-B5T0dhFH.cjs +920 -0
  17. package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
  18. package/dist/chunks/core-BGAyaY6L.cjs +265 -0
  19. package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
  20. package/dist/chunks/core-D7cVumUu.js +909 -0
  21. package/dist/chunks/core-D7cVumUu.js.map +1 -0
  22. package/dist/chunks/core-VEBw36QK.js +260 -0
  23. package/dist/chunks/core-VEBw36QK.js.map +1 -0
  24. package/dist/chunks/core-ps8uvYuN.js +181 -0
  25. package/dist/chunks/core-ps8uvYuN.js.map +1 -0
  26. package/dist/chunks/core-zq17EeCI.cjs +185 -0
  27. package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
  28. package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
  29. package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
  30. package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
  31. package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
  32. package/dist/chunks/generative-D2YyhaeO.js +336 -0
  33. package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
  34. package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
  35. package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
  36. package/dist/chunks/gpu-Bu7qwugO.js +380 -0
  37. package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
  38. package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
  39. package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
  40. package/dist/chunks/index-tags-DucKMQr_.js +26 -0
  41. package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
  42. package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
  43. package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
  44. package/dist/chunks/presets-BYBVJVeP.js +226 -0
  45. package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
  46. package/dist/chunks/presets-CUHys3sK.cjs +233 -0
  47. package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
  48. package/dist/chunks/registry-CKNLQpwd.js +121 -0
  49. package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
  50. package/dist/chunks/registry-DehBVRDV.cjs +131 -0
  51. package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
  52. package/dist/chunks/spring-CbvHfVtP.js +219 -0
  53. package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
  54. package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
  55. package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
  56. package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
  57. package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
  58. package/dist/chunks/stagger-DtMKo2SK.js +84 -0
  59. package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
  60. package/dist/chunks/variants-BhjyddG8.cjs +39 -0
  61. package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
  62. package/dist/chunks/variants-DRlKVHvu.js +35 -0
  63. package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
  64. package/dist/components/a11y.cjs +276 -0
  65. package/dist/components/a11y.cjs.map +1 -0
  66. package/dist/components/a11y.d.cts +131 -0
  67. package/dist/components/a11y.d.ts +131 -0
  68. package/dist/components/a11y.js +259 -0
  69. package/dist/components/a11y.js.map +1 -0
  70. package/dist/components/angular.cjs +76 -0
  71. package/dist/components/angular.cjs.map +1 -0
  72. package/dist/components/angular.d.cts +1734 -0
  73. package/dist/components/angular.d.ts +1734 -0
  74. package/dist/components/angular.js +70 -0
  75. package/dist/components/angular.js.map +1 -0
  76. package/dist/components/background.cjs +659 -0
  77. package/dist/components/background.cjs.map +1 -0
  78. package/dist/components/background.css +9 -0
  79. package/dist/components/background.d.cts +166 -0
  80. package/dist/components/background.d.ts +166 -0
  81. package/dist/components/background.js +647 -0
  82. package/dist/components/background.js.map +1 -0
  83. package/dist/components/bridge.cjs +154 -0
  84. package/dist/components/bridge.cjs.map +1 -0
  85. package/dist/components/bridge.d.cts +63 -0
  86. package/dist/components/bridge.d.ts +63 -0
  87. package/dist/components/bridge.js +147 -0
  88. package/dist/components/bridge.js.map +1 -0
  89. package/dist/components/cards.cjs +561 -0
  90. package/dist/components/cards.cjs.map +1 -0
  91. package/dist/components/cards.css +6 -0
  92. package/dist/components/cards.d.cts +115 -0
  93. package/dist/components/cards.d.ts +115 -0
  94. package/dist/components/cards.js +554 -0
  95. package/dist/components/cards.js.map +1 -0
  96. package/dist/components/click.cjs +877 -0
  97. package/dist/components/click.cjs.map +1 -0
  98. package/dist/components/click.css +9 -0
  99. package/dist/components/click.d.cts +218 -0
  100. package/dist/components/click.d.ts +218 -0
  101. package/dist/components/click.js +863 -0
  102. package/dist/components/click.js.map +1 -0
  103. package/dist/components/depth.cjs +250 -0
  104. package/dist/components/depth.cjs.map +1 -0
  105. package/dist/components/depth.css +3 -0
  106. package/dist/components/depth.d.cts +86 -0
  107. package/dist/components/depth.d.ts +86 -0
  108. package/dist/components/depth.js +242 -0
  109. package/dist/components/depth.js.map +1 -0
  110. package/dist/components/effects.cjs +2258 -0
  111. package/dist/components/effects.cjs.map +1 -0
  112. package/dist/components/effects.d.cts +545 -0
  113. package/dist/components/effects.d.ts +545 -0
  114. package/dist/components/effects.js +2200 -0
  115. package/dist/components/effects.js.map +1 -0
  116. package/dist/components/feedback.cjs +442 -0
  117. package/dist/components/feedback.cjs.map +1 -0
  118. package/dist/components/feedback.css +7 -0
  119. package/dist/components/feedback.d.cts +144 -0
  120. package/dist/components/feedback.d.ts +144 -0
  121. package/dist/components/feedback.js +433 -0
  122. package/dist/components/feedback.js.map +1 -0
  123. package/dist/components/fx-gpu.cjs +12 -0
  124. package/dist/components/fx-gpu.cjs.map +1 -0
  125. package/dist/components/fx-gpu.d.cts +63 -0
  126. package/dist/components/fx-gpu.d.ts +63 -0
  127. package/dist/components/fx-gpu.js +5 -0
  128. package/dist/components/fx-gpu.js.map +1 -0
  129. package/dist/components/fx.cjs +169 -0
  130. package/dist/components/fx.cjs.map +1 -0
  131. package/dist/components/fx.css +3 -0
  132. package/dist/components/fx.d.cts +114 -0
  133. package/dist/components/fx.d.ts +114 -0
  134. package/dist/components/fx.js +156 -0
  135. package/dist/components/fx.js.map +1 -0
  136. package/dist/components/fx2.cjs +25 -0
  137. package/dist/components/fx2.cjs.map +1 -0
  138. package/dist/components/fx2.d.cts +136 -0
  139. package/dist/components/fx2.d.ts +136 -0
  140. package/dist/components/fx2.js +17 -0
  141. package/dist/components/fx2.js.map +1 -0
  142. package/dist/components/gesture.cjs +209 -0
  143. package/dist/components/gesture.cjs.map +1 -0
  144. package/dist/components/gesture.css +3 -0
  145. package/dist/components/gesture.d.cts +134 -0
  146. package/dist/components/gesture.d.ts +134 -0
  147. package/dist/components/gesture.js +203 -0
  148. package/dist/components/gesture.js.map +1 -0
  149. package/dist/components/interaction.cjs +424 -0
  150. package/dist/components/interaction.cjs.map +1 -0
  151. package/dist/components/interaction.css +8 -0
  152. package/dist/components/interaction.d.cts +115 -0
  153. package/dist/components/interaction.d.ts +115 -0
  154. package/dist/components/interaction.js +416 -0
  155. package/dist/components/interaction.js.map +1 -0
  156. package/dist/components/jsx.cjs +3 -0
  157. package/dist/components/jsx.cjs.map +1 -0
  158. package/dist/components/jsx.d.cts +53 -0
  159. package/dist/components/jsx.d.ts +53 -0
  160. package/dist/components/jsx.js +2 -0
  161. package/dist/components/jsx.js.map +1 -0
  162. package/dist/components/layout.cjs +257 -0
  163. package/dist/components/layout.cjs.map +1 -0
  164. package/dist/components/layout.css +3 -0
  165. package/dist/components/layout.d.cts +99 -0
  166. package/dist/components/layout.d.ts +99 -0
  167. package/dist/components/layout.js +249 -0
  168. package/dist/components/layout.js.map +1 -0
  169. package/dist/components/lazy.cjs +92 -0
  170. package/dist/components/lazy.cjs.map +1 -0
  171. package/dist/components/lazy.d.cts +48 -0
  172. package/dist/components/lazy.d.ts +48 -0
  173. package/dist/components/lazy.js +87 -0
  174. package/dist/components/lazy.js.map +1 -0
  175. package/dist/components/lite.cjs +11095 -0
  176. package/dist/components/lite.cjs.map +1 -0
  177. package/dist/components/lite.d.cts +4 -0
  178. package/dist/components/lite.d.ts +4 -0
  179. package/dist/components/lite.js +10827 -0
  180. package/dist/components/lite.js.map +1 -0
  181. package/dist/components/packs.cjs +192 -0
  182. package/dist/components/packs.cjs.map +1 -0
  183. package/dist/components/packs.css +3 -0
  184. package/dist/components/packs.d.cts +72 -0
  185. package/dist/components/packs.d.ts +72 -0
  186. package/dist/components/packs.js +184 -0
  187. package/dist/components/packs.js.map +1 -0
  188. package/dist/components/page.cjs +824 -0
  189. package/dist/components/page.cjs.map +1 -0
  190. package/dist/components/page.css +11 -0
  191. package/dist/components/page.d.cts +249 -0
  192. package/dist/components/page.d.ts +249 -0
  193. package/dist/components/page.js +799 -0
  194. package/dist/components/page.js.map +1 -0
  195. package/dist/components/perf.cjs +120 -0
  196. package/dist/components/perf.cjs.map +1 -0
  197. package/dist/components/perf.d.cts +98 -0
  198. package/dist/components/perf.d.ts +98 -0
  199. package/dist/components/perf.js +110 -0
  200. package/dist/components/perf.js.map +1 -0
  201. package/dist/components/physics.cjs +448 -0
  202. package/dist/components/physics.cjs.map +1 -0
  203. package/dist/components/physics.css +5 -0
  204. package/dist/components/physics.d.cts +189 -0
  205. package/dist/components/physics.d.ts +189 -0
  206. package/dist/components/physics.js +430 -0
  207. package/dist/components/physics.js.map +1 -0
  208. package/dist/components/react.cjs +96 -0
  209. package/dist/components/react.cjs.map +1 -0
  210. package/dist/components/react.d.cts +18 -0
  211. package/dist/components/react.d.ts +18 -0
  212. package/dist/components/react.js +91 -0
  213. package/dist/components/react.js.map +1 -0
  214. package/dist/components/reveal.cjs +362 -0
  215. package/dist/components/reveal.cjs.map +1 -0
  216. package/dist/components/reveal.css +5 -0
  217. package/dist/components/reveal.d.cts +105 -0
  218. package/dist/components/reveal.d.ts +105 -0
  219. package/dist/components/reveal.js +353 -0
  220. package/dist/components/reveal.js.map +1 -0
  221. package/dist/components/solid.cjs +86 -0
  222. package/dist/components/solid.cjs.map +1 -0
  223. package/dist/components/solid.d.cts +1751 -0
  224. package/dist/components/solid.d.ts +1751 -0
  225. package/dist/components/solid.js +82 -0
  226. package/dist/components/solid.js.map +1 -0
  227. package/dist/components/svelte.cjs +68 -0
  228. package/dist/components/svelte.cjs.map +1 -0
  229. package/dist/components/svelte.d.cts +1733 -0
  230. package/dist/components/svelte.d.ts +1733 -0
  231. package/dist/components/svelte.js +64 -0
  232. package/dist/components/svelte.js.map +1 -0
  233. package/dist/components/svg.cjs +359 -0
  234. package/dist/components/svg.cjs.map +1 -0
  235. package/dist/components/svg.css +3 -0
  236. package/dist/components/svg.d.cts +113 -0
  237. package/dist/components/svg.d.ts +113 -0
  238. package/dist/components/svg.js +347 -0
  239. package/dist/components/svg.js.map +1 -0
  240. package/dist/components/text.cjs +968 -0
  241. package/dist/components/text.cjs.map +1 -0
  242. package/dist/components/text.css +8 -0
  243. package/dist/components/text.d.cts +342 -0
  244. package/dist/components/text.d.ts +342 -0
  245. package/dist/components/text.js +947 -0
  246. package/dist/components/text.js.map +1 -0
  247. package/dist/components/timeline.cjs +109 -0
  248. package/dist/components/timeline.cjs.map +1 -0
  249. package/dist/components/timeline.css +3 -0
  250. package/dist/components/timeline.d.cts +155 -0
  251. package/dist/components/timeline.d.ts +155 -0
  252. package/dist/components/timeline.js +103 -0
  253. package/dist/components/timeline.js.map +1 -0
  254. package/dist/components/tokens.cjs +226 -0
  255. package/dist/components/tokens.cjs.map +1 -0
  256. package/dist/components/tokens.d.cts +74 -0
  257. package/dist/components/tokens.d.ts +74 -0
  258. package/dist/components/tokens.js +211 -0
  259. package/dist/components/tokens.js.map +1 -0
  260. package/dist/components/transitions.cjs +430 -0
  261. package/dist/components/transitions.cjs.map +1 -0
  262. package/dist/components/transitions.css +5 -0
  263. package/dist/components/transitions.d.cts +126 -0
  264. package/dist/components/transitions.d.ts +126 -0
  265. package/dist/components/transitions.js +423 -0
  266. package/dist/components/transitions.js.map +1 -0
  267. package/dist/components/ui.cjs +1050 -0
  268. package/dist/components/ui.cjs.map +1 -0
  269. package/dist/components/ui.css +14 -0
  270. package/dist/components/ui.d.cts +224 -0
  271. package/dist/components/ui.d.ts +224 -0
  272. package/dist/components/ui.js +1034 -0
  273. package/dist/components/ui.js.map +1 -0
  274. package/dist/components/vue.cjs +67 -0
  275. package/dist/components/vue.cjs.map +1 -0
  276. package/dist/components/vue.d.cts +1722 -0
  277. package/dist/components/vue.d.ts +1722 -0
  278. package/dist/components/vue.js +64 -0
  279. package/dist/components/vue.js.map +1 -0
  280. package/dist/components/webgl.cjs +459 -0
  281. package/dist/components/webgl.cjs.map +1 -0
  282. package/dist/components/webgl.css +3 -0
  283. package/dist/components/webgl.d.cts +133 -0
  284. package/dist/components/webgl.d.ts +133 -0
  285. package/dist/components/webgl.js +442 -0
  286. package/dist/components/webgl.js.map +1 -0
  287. package/dist/components/widgets.cjs +591 -0
  288. package/dist/components/widgets.cjs.map +1 -0
  289. package/dist/components/widgets.d.cts +110 -0
  290. package/dist/components/widgets.d.ts +110 -0
  291. package/dist/components/widgets.js +581 -0
  292. package/dist/components/widgets.js.map +1 -0
  293. package/dist/components.cjs +351 -0
  294. package/dist/components.cjs.map +1 -0
  295. package/dist/components.css +75 -0
  296. package/dist/components.d.cts +2997 -0
  297. package/dist/components.d.ts +2997 -0
  298. package/dist/components.js +106 -0
  299. package/dist/components.js.map +1 -0
  300. package/dist/components.umd.js +23 -0
  301. package/dist/components.umd.js.map +1 -0
  302. package/dist/element.cjs +97 -0
  303. package/dist/element.cjs.map +1 -0
  304. package/dist/element.d.cts +215 -0
  305. package/dist/element.d.ts +215 -0
  306. package/dist/element.js +95 -0
  307. package/dist/element.js.map +1 -0
  308. package/dist/element.umd.js +2 -0
  309. package/dist/element.umd.js.map +1 -0
  310. package/dist/index.cjs +149 -0
  311. package/dist/index.cjs.map +1 -0
  312. package/dist/index.d.cts +425 -0
  313. package/dist/index.d.ts +425 -0
  314. package/dist/index.js +131 -0
  315. package/dist/index.js.map +1 -0
  316. package/dist/index.umd.js +15 -0
  317. package/dist/index.umd.js.map +1 -0
  318. package/dist/presets/extended.cjs +243 -0
  319. package/dist/presets/extended.cjs.map +1 -0
  320. package/dist/presets/extended.d.cts +37 -0
  321. package/dist/presets/extended.d.ts +37 -0
  322. package/dist/presets/extended.js +239 -0
  323. package/dist/presets/extended.js.map +1 -0
  324. package/dist/presets-extended.umd.js +2 -0
  325. package/dist/presets-extended.umd.js.map +1 -0
  326. package/dist/react.cjs +68 -0
  327. package/dist/react.cjs.map +1 -0
  328. package/dist/react.d.cts +158 -0
  329. package/dist/react.d.ts +158 -0
  330. package/dist/react.js +65 -0
  331. package/dist/react.js.map +1 -0
  332. package/dist/solid.cjs +93 -0
  333. package/dist/solid.cjs.map +1 -0
  334. package/dist/solid.d.cts +249 -0
  335. package/dist/solid.d.ts +249 -0
  336. package/dist/solid.js +89 -0
  337. package/dist/solid.js.map +1 -0
  338. package/dist/svelte.cjs +66 -0
  339. package/dist/svelte.cjs.map +1 -0
  340. package/dist/svelte.d.cts +243 -0
  341. package/dist/svelte.d.ts +243 -0
  342. package/dist/svelte.js +63 -0
  343. package/dist/svelte.js.map +1 -0
  344. package/dist/vue.cjs +62 -0
  345. package/dist/vue.cjs.map +1 -0
  346. package/dist/vue.d.cts +158 -0
  347. package/dist/vue.d.ts +158 -0
  348. package/dist/vue.js +60 -0
  349. package/dist/vue.js.map +1 -0
  350. package/dist/widgets.umd.js +2 -0
  351. package/dist/widgets.umd.js.map +1 -0
  352. package/docs/API.md +147 -0
  353. package/docs/ROADMAP.md +14 -0
  354. package/docs/accessibility.md +60 -0
  355. package/docs/components.md +564 -0
  356. package/docs/deprecations.md +30 -0
  357. package/docs/frameworks-ssr.md +100 -0
  358. package/docs/hybrid-apps.md +145 -0
  359. package/docs/images/showcase-detail.png +0 -0
  360. package/docs/images/showcase-grid.png +0 -0
  361. package/docs/images/showcase-mobile.png +0 -0
  362. package/docs/migration-from-aos.md +67 -0
  363. package/docs/migration-from-gsap-scrolltrigger.md +80 -0
  364. package/docs/motion-tokens.css +31 -0
  365. package/docs/motion-tokens.md +46 -0
  366. package/docs/motion.tokens.json +132 -0
  367. package/docs/performance.md +24 -0
  368. package/docs/presets.md +310 -0
  369. package/docs/upgrading-3.md +21 -0
  370. package/docs/upgrading-4.md +65 -0
  371. package/docs/upgrading-5.md +31 -0
  372. package/docs/upgrading-6.md +32 -0
  373. package/docs/windows-apps.md +119 -0
  374. package/package.json +562 -4
@@ -0,0 +1,947 @@
1
+ import { x as defineElement, B as srText, l as caf, q as now, r as raf, y as EASE_OUT, E as EASE_SPRING, k as clamp } from '../chunks/base-C_3cAoRz.js';
2
+ import { t as timeline } from '../chunks/core-VEBw36QK.js';
3
+ import './tokens.js';
4
+
5
+ var css$5 = "usa-typewriter{white-space:pre-wrap}usa-typewriter .usa-tw-caret{display:inline-block;width:var(--usa-caret-width,0.08em);height:1.05em;margin-left:0.06em;vertical-align:-0.12em;background:var(--usa-caret-color,currentColor);animation:usa-caret 1.06s steps(1) infinite}usa-typewriter[data-typing] .usa-tw-caret{animation:none}usa-typewriter[data-no-cursor] .usa-tw-caret{display:none}@keyframes usa-caret{50%{opacity:0}}@media (prefers-reduced-motion:reduce){usa-typewriter .usa-tw-caret,usa-shimmer-text{animation:none}}";
6
+
7
+ function defineTypewriter(tag = 'usa-typewriter') {
8
+ return defineElement(tag, (Base) => class UsaTypewriter extends Base {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._source = null;
12
+ this._out = null;
13
+ this._timer = 0;
14
+ this._running = false;
15
+ }
16
+ static get observedAttributes() {
17
+ return ['text', 'words'];
18
+ }
19
+ get phrases() {
20
+ const words = this.getAttribute('words');
21
+ if (words)
22
+ return words.split('|').map((w) => w.trim()).filter(Boolean);
23
+ return [this.getAttribute('text') ?? this._source ?? ''];
24
+ }
25
+ mount() {
26
+ if (this._source === null)
27
+ this._source = (this.textContent || '').trim();
28
+ const phrases = this.phrases;
29
+ const sr = srText(phrases.join(', '));
30
+ this._out = document.createElement('span');
31
+ this._out.className = 'usa-tw-text';
32
+ this._out.setAttribute('aria-hidden', 'true');
33
+ const caret = document.createElement('span');
34
+ caret.className = 'usa-tw-caret';
35
+ caret.setAttribute('aria-hidden', 'true');
36
+ this.replaceChildren(sr, this._out, caret);
37
+ this.toggleAttribute('data-no-cursor', this.getAttribute('cursor') === 'false');
38
+ if (this.reduced) {
39
+ this._out.textContent = phrases[0] || '';
40
+ return;
41
+ }
42
+ const start = this.str('start', 'view');
43
+ if (start === 'load')
44
+ this.start();
45
+ else if (start === 'view') {
46
+ this.inView((visible) => {
47
+ if (visible && !this._running && !this._out?.textContent)
48
+ this.start();
49
+ });
50
+ }
51
+ }
52
+ unmount() {
53
+ this.stop();
54
+ }
55
+ stop() {
56
+ clearTimeout(this._timer);
57
+ this._timer = 0;
58
+ this._running = false;
59
+ this.removeAttribute('data-typing');
60
+ }
61
+ restart() {
62
+ this.stop();
63
+ if (this._out)
64
+ this._out.textContent = '';
65
+ this.start();
66
+ }
67
+ start() {
68
+ if (this._running || !this._out)
69
+ return;
70
+ const out = this._out;
71
+ const phrases = this.phrases;
72
+ if (this.reduced) {
73
+ out.textContent = phrases[0] || '';
74
+ return;
75
+ }
76
+ this._running = true;
77
+ const speed = this.num('speed', 55);
78
+ const del = this.num('delete-speed', 30);
79
+ const pause = this.num('pause', 1400);
80
+ const loop = this.flag('loop') || phrases.length > 1;
81
+ let p = 0;
82
+ let i = 0;
83
+ let deleting = false;
84
+ const tick = () => {
85
+ const word = phrases[p] || '';
86
+ if (!deleting) {
87
+ i++;
88
+ out.textContent = word.slice(0, i);
89
+ this.setAttribute('data-typing', '');
90
+ if (i >= word.length) {
91
+ this.removeAttribute('data-typing');
92
+ const last = p === phrases.length - 1;
93
+ if (last)
94
+ this.emit('complete');
95
+ if (!loop && last) {
96
+ this._running = false;
97
+ return;
98
+ }
99
+ deleting = true;
100
+ this._timer = setTimeout(tick, pause);
101
+ return;
102
+ }
103
+ this._timer = setTimeout(tick, speed * (0.6 + Math.random() * 0.8));
104
+ }
105
+ else {
106
+ i--;
107
+ out.textContent = word.slice(0, Math.max(0, i));
108
+ if (i <= 0) {
109
+ deleting = false;
110
+ p = (p + 1) % phrases.length;
111
+ this._timer = setTimeout(tick, speed * 4);
112
+ return;
113
+ }
114
+ this._timer = setTimeout(tick, del);
115
+ }
116
+ };
117
+ this._timer = setTimeout(tick, this.num('delay', 0));
118
+ }
119
+ }, { id: 'typewriter', text: css$5 });
120
+ }
121
+
122
+ var css$4 = "usa-split-text .usa-split-word{display:inline-block;white-space:nowrap}usa-split-text .usa-split-unit{display:inline-block;white-space:pre}usa-split-text[data-state=\"hidden\"] .usa-split-unit{opacity:0}usa-split-text[data-state=\"play\"] .usa-split-unit{animation:usa-split-rise var(--usa-split-duration,620ms) cubic-bezier(0.22,1,0.36,1) both;animation-delay:calc(var(--usa-split-delay,0ms) + var(--i,0) * var(--usa-split-stagger,28ms))}usa-split-text[effect=\"fade\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-fade}usa-split-text[effect=\"blur\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-blur}usa-split-text[effect=\"flip\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-flip;transform-origin:50% 100%}usa-split-text[effect=\"pop\"][data-state=\"play\"] .usa-split-unit{animation-name:usa-split-pop;animation-timing-function:cubic-bezier(0.34,1.56,0.64,1)}@keyframes usa-split-rise{from{opacity:0;transform:translate3d(0,0.6em,0)}to{opacity:1;transform:none}}@keyframes usa-split-fade{from{opacity:0}to{opacity:1}}@keyframes usa-split-blur{from{opacity:0;filter:blur(8px)}to{opacity:1;filter:none}}@keyframes usa-split-flip{from{opacity:0;transform:perspective(500px) rotateX(-80deg)}to{opacity:1;transform:none}}@keyframes usa-split-pop{from{opacity:0;transform:scale(0.3)}to{opacity:1;transform:none}}@media (prefers-reduced-motion:reduce){usa-split-text .usa-split-unit{animation:none !important;opacity:1 !important}}";
123
+
124
+ const CJK = /[\u2E80-\u2FFF\u3000-\u303F\u3040-\u30FF\u3100-\u312F\u3130-\u318F\u31A0-\u31FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF]/;
125
+ /** Scripts whose letters join (splitting them would break shaping). */
126
+ const JOINING_SCRIPT = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
127
+ const RTL = /[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/;
128
+ const SR = 'position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0';
129
+ function segmenter(locale, granularity) {
130
+ const S = globalThis.Intl?.Segmenter;
131
+ if (typeof S !== 'function')
132
+ return null;
133
+ try {
134
+ return new S(locale || undefined, { granularity });
135
+ }
136
+ catch {
137
+ return null;
138
+ }
139
+ }
140
+ /** Grapheme clusters of `s` (emoji / combining marks stay whole). */
141
+ function graphemes(s, locale) {
142
+ const seg = segmenter(locale, 'grapheme');
143
+ if (seg)
144
+ return Array.from(seg.segment(s), (x) => x.segment);
145
+ return Array.from(s);
146
+ }
147
+ /**
148
+ * Word-ish tokens of `s`, whitespace kept as separate tokens. CJK text is
149
+ * segmented into words with `Intl.Segmenter`, or per character without it.
150
+ */
151
+ function words(s, locale) {
152
+ const seg = segmenter(locale, 'word');
153
+ const out = [];
154
+ if (seg) {
155
+ for (const x of seg.segment(s)) {
156
+ const last = out[out.length - 1];
157
+ // glue punctuation onto the previous word so it never starts a line alone
158
+ if (!x.isWordLike && !/^\s+$/.test(x.segment) && last && !/^\s+$/.test(last))
159
+ out[out.length - 1] = last + x.segment;
160
+ else
161
+ out.push(x.segment);
162
+ }
163
+ return out;
164
+ }
165
+ for (const part of s.split(/(\s+)/)) {
166
+ if (!part)
167
+ continue;
168
+ if (/^\s+$/.test(part) || !CJK.test(part))
169
+ out.push(part);
170
+ else {
171
+ let buf = '';
172
+ for (const ch of Array.from(part)) {
173
+ if (CJK.test(ch)) {
174
+ if (buf)
175
+ out.push(buf), (buf = '');
176
+ out.push(ch);
177
+ }
178
+ else if (/[\p{P}]/u.test(ch) && out.length)
179
+ out[out.length - 1] += ch;
180
+ else
181
+ buf += ch;
182
+ }
183
+ if (buf)
184
+ out.push(buf);
185
+ }
186
+ }
187
+ return out;
188
+ }
189
+ function dirOf(el, text) {
190
+ const attr = el.closest?.('[dir]')?.getAttribute('dir');
191
+ if (attr === 'rtl' || attr === 'ltr')
192
+ return attr;
193
+ try {
194
+ const d = getComputedStyle(el).direction;
195
+ if (d === 'rtl')
196
+ return 'rtl';
197
+ }
198
+ catch {
199
+ /* no layout */
200
+ }
201
+ return RTL.test(text) && !/[A-Za-z]/.test(text.replace(RTL, '')) ? 'rtl' : 'ltr';
202
+ }
203
+ function splitText(el, options = {}) {
204
+ const by = new Set((Array.isArray(options.by) ? options.by : String(options.by ?? 'char').split(/[\s,]+/)).filter(Boolean));
205
+ const cls = options.className || 'usa-split';
206
+ const locale = options.locale || el.closest?.('[lang]')?.getAttribute('lang') || undefined;
207
+ const original = Array.from(el.childNodes).map((n) => n.cloneNode(true));
208
+ const text = el.textContent || '';
209
+ const direction = dirOf(el, text);
210
+ const chars = [];
211
+ const wordEls = [];
212
+ let lines = [];
213
+ const doc = el.ownerDocument;
214
+ const span = (c, t) => {
215
+ const s = doc.createElement('span');
216
+ s.className = c;
217
+ if (t !== undefined)
218
+ s.textContent = t;
219
+ return s;
220
+ };
221
+ const splitNode = (node) => {
222
+ if (node.nodeType === 3) {
223
+ const frag = doc.createDocumentFragment();
224
+ for (const w of words(node.nodeValue || '', locale)) {
225
+ if (/^\s+$/.test(w)) {
226
+ frag.append(doc.createTextNode(w));
227
+ continue;
228
+ }
229
+ const wordEl = span(`${cls}-word`);
230
+ wordEl.style.display = 'inline-block';
231
+ wordEl.style.whiteSpace = 'nowrap';
232
+ wordEl.dataset.index = String(wordEls.length);
233
+ wordEls.push(wordEl);
234
+ // Arabic script joins its letters: keep the word whole (shaping), even in char mode.
235
+ if (by.has('char') && !JOINING_SCRIPT.test(w)) {
236
+ for (const g of graphemes(w, locale)) {
237
+ const c = span(`${cls}-char`, g);
238
+ c.style.display = 'inline-block';
239
+ c.dataset.index = String(chars.length);
240
+ chars.push(c);
241
+ wordEl.append(c);
242
+ }
243
+ }
244
+ else {
245
+ wordEl.textContent = w;
246
+ if (by.has('char')) {
247
+ wordEl.dataset.whole = '';
248
+ chars.push(wordEl);
249
+ }
250
+ }
251
+ frag.append(wordEl);
252
+ }
253
+ node.parentNode.replaceChild(frag, node);
254
+ }
255
+ else if (node.nodeType === 1 && !/^(BR|SCRIPT|STYLE|SVG|IMG)$/i.test(node.tagName)) {
256
+ Array.from(node.childNodes).forEach(splitNode);
257
+ }
258
+ };
259
+ const wrap = doc.createElement('span');
260
+ wrap.setAttribute('aria-hidden', 'true');
261
+ wrap.className = `${cls}-body`;
262
+ original.forEach((n) => wrap.append(n.cloneNode(true)));
263
+ Array.from(wrap.childNodes).forEach(splitNode);
264
+ const sr = span(`${cls}-sr`, text.replace(/\s+/g, ' ').trim());
265
+ sr.setAttribute('style', SR);
266
+ el.replaceChildren(sr, wrap);
267
+ el.setAttribute('data-split', [...by].join(' '));
268
+ if (direction === 'rtl')
269
+ el.setAttribute('data-split-dir', 'rtl');
270
+ const relayout = () => {
271
+ // unwrap old lines
272
+ for (const l of lines)
273
+ l.replaceWith(...Array.from(l.childNodes));
274
+ lines = [];
275
+ if (!by.has('line') || !wordEls.length)
276
+ return lines;
277
+ const groups = [];
278
+ let lastTop = null;
279
+ for (const w of wordEls) {
280
+ const top = Math.round(w.offsetTop);
281
+ if (lastTop === null || Math.abs(top - lastTop) > 2)
282
+ groups.push([]);
283
+ groups[groups.length - 1].push(w);
284
+ lastTop = top;
285
+ }
286
+ groups.forEach((g, i) => {
287
+ // only group words that share a parent (inline markup keeps its words)
288
+ const parent = g[0].parentNode;
289
+ const same = g.filter((w) => w.parentNode === parent);
290
+ const line = span(`${cls}-line`);
291
+ line.style.display = 'inline-block';
292
+ line.dataset.index = String(i);
293
+ parent.insertBefore(line, same[0]);
294
+ let n = same[0];
295
+ const end = same[same.length - 1];
296
+ while (n) {
297
+ const next = n.nextSibling;
298
+ line.append(n);
299
+ if (n === end)
300
+ break;
301
+ n = next;
302
+ }
303
+ // keep the space between lines outside the line box
304
+ lines.push(line);
305
+ });
306
+ return lines;
307
+ };
308
+ relayout();
309
+ return {
310
+ chars,
311
+ words: wordEls,
312
+ get lines() {
313
+ return lines;
314
+ },
315
+ direction,
316
+ relayout,
317
+ revert() {
318
+ el.replaceChildren(...original.map((n) => n.cloneNode(true)));
319
+ el.removeAttribute('data-split');
320
+ el.removeAttribute('data-split-dir');
321
+ },
322
+ };
323
+ }
324
+ /** Order indices `0…n-1` by choreography: from the start, end, center outwards, edges inwards, or random (seeded). */
325
+ function splitOrder(n, from = 'start', seed = 1) {
326
+ const idx = Array.from({ length: n }, (_, i) => i);
327
+ const mid = (n - 1) / 2;
328
+ if (from === 'end')
329
+ return idx.map((i) => n - 1 - i);
330
+ if (from === 'center')
331
+ return idx.map((i) => Math.round(Math.abs(i - mid) * 2) / 2);
332
+ if (from === 'edges')
333
+ return idx.map((i) => Math.round((mid - Math.abs(i - mid)) * 2) / 2);
334
+ if (from === 'random') {
335
+ let s = seed;
336
+ const r = () => ((s = (s * 16807) % 2147483647) / 2147483647);
337
+ const shuffled = idx.slice().sort(() => r() - 0.5);
338
+ const rank = [];
339
+ shuffled.forEach((v, i) => (rank[v] = i));
340
+ return rank;
341
+ }
342
+ return idx;
343
+ }
344
+ /**
345
+ * Split `el` and build a `timeline()` with one step per unit — play it,
346
+ * `scrub()` it with scroll, `reverse()` or `seek()` it.
347
+ *
348
+ * ```ts
349
+ * const { timeline: tl } = splitTimeline(h1, { by: 'char', preset: 'blur', from: 'center' });
350
+ * tl.play();
351
+ * ```
352
+ */
353
+ function splitTimeline(el, options = {}) {
354
+ const split = splitText(el, options);
355
+ const by = Array.isArray(options.by) ? options.by : String(options.by ?? 'char').split(/[\s,]+/);
356
+ const unit = options.unit || (by.includes('char') ? 'char' : by.includes('word') ? 'word' : 'line');
357
+ const units = unit === 'char' ? split.chars : unit === 'word' ? split.words : split.lines;
358
+ const stagger = options.stagger ?? (unit === 'char' ? 30 : unit === 'word' ? 80 : 140);
359
+ const order = splitOrder(units.length, options.from);
360
+ const tl = timeline({ defaults: { duration: options.duration ?? 500, easing: options.easing } });
361
+ units.forEach((u, i) => tl.to(u, options.preset || 'fade-up', { at: order[i] * stagger }));
362
+ tl.seek(0);
363
+ return { split, timeline: tl };
364
+ }
365
+
366
+ function defineSplitText(tag = 'usa-split-text') {
367
+ return defineElement(tag, (Base) => class UsaSplitText extends Base {
368
+ constructor() {
369
+ super(...arguments);
370
+ this._source = null;
371
+ this._timer = 0;
372
+ this._steps = 0;
373
+ }
374
+ static get observedAttributes() {
375
+ return ['by', 'text'];
376
+ }
377
+ get units() {
378
+ return Array.from(this.querySelectorAll('.usa-split-unit'));
379
+ }
380
+ mount() {
381
+ if (this._source === null)
382
+ this._source = this.getAttribute('text') ?? (this.textContent || '').replace(/\s+/g, ' ').trim();
383
+ const text = this.getAttribute('text') ?? this._source;
384
+ const mode = this.str('by', 'chars');
385
+ const byWords = mode !== 'chars';
386
+ const lang = this.closest('[lang]')?.getAttribute('lang') || undefined;
387
+ const frag = document.createDocumentFragment();
388
+ frag.append(srText(text));
389
+ const units = [];
390
+ for (const word of words(text, lang)) {
391
+ if (/^\s+$/.test(word)) {
392
+ frag.append(' ');
393
+ continue;
394
+ }
395
+ const wordEl = document.createElement('span');
396
+ wordEl.className = 'usa-split-word';
397
+ wordEl.setAttribute('aria-hidden', 'true');
398
+ const parts = byWords || JOINING_SCRIPT.test(word) ? [word] : graphemes(word, lang);
399
+ for (const part of parts) {
400
+ const u = document.createElement('span');
401
+ u.className = 'usa-split-unit';
402
+ u.textContent = part;
403
+ units.push(u);
404
+ wordEl.append(u);
405
+ }
406
+ frag.append(wordEl);
407
+ }
408
+ this.replaceChildren(frag);
409
+ // cascade order: per unit, or per line for by="lines"
410
+ let rank = units.map((_, k) => k);
411
+ if (mode === 'lines') {
412
+ let line = -1;
413
+ let top = null;
414
+ rank = units.map((u) => {
415
+ const t = Math.round(u.parentElement.offsetTop);
416
+ if (top === null || Math.abs(t - top) > 2)
417
+ line++;
418
+ top = t;
419
+ return line;
420
+ });
421
+ }
422
+ const groups = Math.max(0, ...rank) + 1;
423
+ const order = splitOrder(groups, this.str('from', 'start'));
424
+ units.forEach((u, k) => u.style.setProperty('--i', String(order[rank[k]] ?? 0)));
425
+ const i = Math.max(0, ...units.map((_, k) => order[rank[k]] ?? 0)) + 1;
426
+ this._steps = i;
427
+ this.style.setProperty('--usa-split-stagger', `${this.num('stagger', mode === 'lines' ? 140 : byWords ? 70 : 28)}ms`);
428
+ this.style.setProperty('--usa-split-duration', `${this.num('duration', 620)}ms`);
429
+ this.style.setProperty('--usa-split-delay', `${this.num('delay', 0)}ms`);
430
+ this.style.setProperty('--usa-split-count', String(i));
431
+ if (this.reduced) {
432
+ this.setAttribute('data-state', 'shown');
433
+ return;
434
+ }
435
+ this.setAttribute('data-state', 'hidden');
436
+ const trigger = this.str('trigger', 'view');
437
+ if (trigger === 'load')
438
+ this.play();
439
+ else if (trigger === 'view') {
440
+ this.inView((visible) => {
441
+ if (visible && this.getAttribute('data-state') === 'hidden')
442
+ this.play();
443
+ else if (!visible && this.flag('repeat'))
444
+ this.reset();
445
+ }, { threshold: 0.2 });
446
+ }
447
+ }
448
+ unmount() {
449
+ clearTimeout(this._timer);
450
+ }
451
+ play() {
452
+ clearTimeout(this._timer);
453
+ if (this.reduced) {
454
+ this.setAttribute('data-state', 'shown');
455
+ return;
456
+ }
457
+ // Restart the CSS animations
458
+ this.setAttribute('data-state', 'hidden');
459
+ void this.offsetWidth;
460
+ this.setAttribute('data-state', 'play');
461
+ const by = this.str('by', 'chars');
462
+ const total = this.num('delay', 0) + this.num('duration', 620) + Math.max(0, this._steps - 1) * this.num('stagger', by === 'lines' ? 140 : by === 'words' ? 70 : 28);
463
+ this._timer = setTimeout(() => {
464
+ this.setAttribute('data-state', 'shown');
465
+ this.emit('complete');
466
+ }, total);
467
+ }
468
+ reset() {
469
+ clearTimeout(this._timer);
470
+ this.setAttribute('data-state', this.reduced ? 'shown' : 'hidden');
471
+ }
472
+ }, { id: 'split-text', text: css$4 });
473
+ }
474
+
475
+ const GLYPHS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#%&*+=<>/\\?!';
476
+ /** One frame of the scramble: the first `progress` share is resolved. */
477
+ function scrambleFrame(text, progress, glyphs = GLYPHS, rnd = Math.random) {
478
+ const done = Math.floor(text.length * progress);
479
+ let out = '';
480
+ for (let i = 0; i < text.length; i++) {
481
+ const ch = text[i];
482
+ out += i < done || /\s|[.,:;!?'"()\-–—]/.test(ch) ? ch : glyphs[Math.floor(rnd() * glyphs.length)];
483
+ }
484
+ return out;
485
+ }
486
+ function defineScramble(tag = 'usa-scramble') {
487
+ return defineElement(tag, (Base) => class UsaScramble extends Base {
488
+ constructor() {
489
+ super(...arguments);
490
+ this._source = null;
491
+ this._out = null;
492
+ this._frame = 0;
493
+ }
494
+ static get observedAttributes() {
495
+ return ['text'];
496
+ }
497
+ get text() {
498
+ return this.getAttribute('text') ?? this._source ?? '';
499
+ }
500
+ mount() {
501
+ if (this._source === null)
502
+ this._source = (this.textContent || '').trim();
503
+ this._out = document.createElement('span');
504
+ this._out.setAttribute('aria-hidden', 'true');
505
+ this._out.textContent = this.text;
506
+ this.replaceChildren(srText(this.text), this._out);
507
+ if (this.reduced)
508
+ return;
509
+ const trigger = this.str('trigger', 'view');
510
+ if (trigger === 'load')
511
+ this.play();
512
+ else if (trigger === 'hover') {
513
+ this.listen(this, 'pointerenter', () => this.play());
514
+ this.listen(this, 'focusin', () => this.play());
515
+ }
516
+ else if (trigger === 'view') {
517
+ let played = false;
518
+ this.inView((v) => {
519
+ if (v && !played) {
520
+ played = true;
521
+ this.play();
522
+ }
523
+ });
524
+ }
525
+ }
526
+ unmount() {
527
+ caf(this._frame);
528
+ this._frame = 0;
529
+ }
530
+ play() {
531
+ caf(this._frame);
532
+ const out = this._out;
533
+ const text = this.text;
534
+ if (!out || this.reduced) {
535
+ if (out)
536
+ out.textContent = text;
537
+ return Promise.resolve();
538
+ }
539
+ const duration = this.num('duration', 900);
540
+ const glyphs = this.str('chars', GLYPHS) || GLYPHS;
541
+ const t0 = now();
542
+ let last = -1;
543
+ return new Promise((resolve) => {
544
+ const step = () => {
545
+ const p = Math.min(1, Math.max(0, now() - t0) / duration);
546
+ // ~30 fps glyph churn is plenty and halves DOM writes
547
+ const bucket = Math.floor(p * duration / 33);
548
+ if (bucket !== last || p === 1) {
549
+ last = bucket;
550
+ out.textContent = p === 1 ? text : scrambleFrame(text, p, glyphs);
551
+ }
552
+ if (p < 1)
553
+ this._frame = raf(step);
554
+ else {
555
+ this._frame = 0;
556
+ this.emit('complete');
557
+ resolve();
558
+ }
559
+ };
560
+ this._frame = raf(step);
561
+ });
562
+ }
563
+ }, undefined);
564
+ }
565
+
566
+ var css$3 = "usa-counter{font-variant-numeric:tabular-nums}";
567
+
568
+ /** easeOutExpo */
569
+ const easeOutExpo = (t) => (t >= 1 ? 1 : 1 - Math.pow(2, -10 * t));
570
+ function defineCounter(tag = 'usa-counter') {
571
+ return defineElement(tag, (Base) => class UsaCounter extends Base {
572
+ constructor() {
573
+ super(...arguments);
574
+ this._current = NaN;
575
+ this._target = NaN;
576
+ this._frame = 0;
577
+ this._fmt = null;
578
+ }
579
+ static get observedAttributes() {
580
+ return ['to', 'decimals', 'locale', 'prefix', 'suffix', 'grouping'];
581
+ }
582
+ get value() {
583
+ return Number.isNaN(this._target) ? this.num('to', 0) : this._target;
584
+ }
585
+ set value(v) {
586
+ this.play(Number(v));
587
+ }
588
+ format(n) {
589
+ if (!this._fmt) {
590
+ const d = Math.max(0, Math.min(20, this.num('decimals', 0)));
591
+ const locale = this.getAttribute('locale') || (typeof document !== 'undefined' && document.documentElement.lang) || undefined;
592
+ try {
593
+ this._fmt = new Intl.NumberFormat(locale, { minimumFractionDigits: d, maximumFractionDigits: d, useGrouping: this.getAttribute('grouping') !== 'false' });
594
+ }
595
+ catch {
596
+ this._fmt = new Intl.NumberFormat(undefined, { minimumFractionDigits: d, maximumFractionDigits: d });
597
+ }
598
+ }
599
+ return `${this.str('prefix')}${this._fmt.format(n)}${this.str('suffix')}`;
600
+ }
601
+ render(n) {
602
+ this._current = n;
603
+ this.textContent = this.format(n);
604
+ }
605
+ changed(name) {
606
+ this._fmt = null;
607
+ if (name === 'to')
608
+ this.play();
609
+ else
610
+ this.render(Number.isNaN(this._current) ? this.num('from', 0) : this._current);
611
+ }
612
+ mount() {
613
+ this._fmt = null;
614
+ const to = this.num('to', 0);
615
+ if (this.reduced) {
616
+ this._target = to;
617
+ this.render(to);
618
+ return;
619
+ }
620
+ if (Number.isNaN(this._current))
621
+ this.render(this.num('from', 0));
622
+ const start = this.str('start', 'view');
623
+ if (start === 'load')
624
+ this.play();
625
+ else if (start === 'view') {
626
+ let done = false;
627
+ this.inView((v) => {
628
+ if (v && !done) {
629
+ done = true;
630
+ this.play();
631
+ }
632
+ }, { threshold: 0.4 });
633
+ }
634
+ }
635
+ unmount() {
636
+ caf(this._frame);
637
+ this._frame = 0;
638
+ }
639
+ play(to = this.num('to', 0)) {
640
+ caf(this._frame);
641
+ this._target = to;
642
+ const from = Number.isNaN(this._current) ? this.num('from', 0) : this._current;
643
+ if (this.reduced || from === to || !this.isConnected) {
644
+ this.render(to);
645
+ this.emit('complete', { value: to });
646
+ return Promise.resolve();
647
+ }
648
+ const duration = this.num('duration', 1600);
649
+ const t0 = now();
650
+ return new Promise((resolve) => {
651
+ const step = () => {
652
+ const t = Math.min(1, Math.max(0, now() - t0) / duration);
653
+ this.render(from + (to - from) * easeOutExpo(t));
654
+ if (t < 1)
655
+ this._frame = raf(step);
656
+ else {
657
+ this._frame = 0;
658
+ this.render(to);
659
+ this.emit('complete', { value: to });
660
+ resolve();
661
+ }
662
+ };
663
+ this._frame = raf(step);
664
+ });
665
+ }
666
+ }, { id: 'counter', text: css$3 });
667
+ }
668
+
669
+ var css$2 = "usa-shimmer-text{--usa-shimmer-color:currentColor;--usa-shimmer-shine:#fff;background:linear-gradient(var(--usa-shimmer-angle,110deg),var(--usa-shimmer-color) 35%,var(--usa-shimmer-shine) 50%,var(--usa-shimmer-color) 65%) 0 0 / 250% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent;animation:usa-shimmer var(--usa-shimmer-duration,2600ms) linear infinite}@keyframes usa-shimmer{from{background-position:100% 0}to{background-position:-150% 0}}";
670
+
671
+ function defineShimmerText(tag = 'usa-shimmer-text') {
672
+ return defineElement(tag, (Base) => class UsaShimmerText extends Base {
673
+ static get observedAttributes() {
674
+ return ['duration', 'color', 'shine', 'angle'];
675
+ }
676
+ mount() {
677
+ const set = (attr, prop, unit = '') => {
678
+ const v = this.getAttribute(attr);
679
+ if (v !== null)
680
+ this.style.setProperty(prop, v + unit);
681
+ else
682
+ this.style.removeProperty(prop);
683
+ };
684
+ set('duration', '--usa-shimmer-duration', 'ms');
685
+ set('color', '--usa-shimmer-color');
686
+ set('shine', '--usa-shimmer-shine');
687
+ set('angle', '--usa-shimmer-angle', 'deg');
688
+ }
689
+ }, { id: 'shimmer-text', text: css$2 });
690
+ }
691
+
692
+ var css$1 = "usa-text-rotate{display:inline-grid;vertical-align:bottom;overflow:hidden;padding-block:0.08em}usa-text-rotate .usa-rotate-word{grid-area:1 / 1;white-space:nowrap}usa-text-rotate .usa-rotate-word[data-hidden]{opacity:0}";
693
+
694
+ function defineTextRotate(tag = 'usa-text-rotate') {
695
+ return defineElement(tag, (Base) => class UsaTextRotate extends Base {
696
+ constructor() {
697
+ super(...arguments);
698
+ this._source = null;
699
+ this._index = 0;
700
+ this._timer = 0;
701
+ this._visible = true;
702
+ }
703
+ static get observedAttributes() {
704
+ return ['words', 'interval', 'paused'];
705
+ }
706
+ get index() {
707
+ return this._index;
708
+ }
709
+ get words() {
710
+ return (this.getAttribute('words') ?? this._source ?? '').split('|').map((w) => w.trim()).filter(Boolean);
711
+ }
712
+ mount() {
713
+ if (this._source === null)
714
+ this._source = (this.textContent || '').trim();
715
+ const words = this.words;
716
+ this.replaceChildren(srText(words.join(', ')), ...words.map((w, i) => {
717
+ const s = document.createElement('span');
718
+ s.className = 'usa-rotate-word';
719
+ s.textContent = w;
720
+ s.setAttribute('aria-hidden', 'true');
721
+ if (i !== this._index)
722
+ s.setAttribute('data-hidden', '');
723
+ return s;
724
+ }));
725
+ if (this._index >= words.length)
726
+ this._index = 0;
727
+ if (words.length < 2)
728
+ return;
729
+ this.inView((v) => (this._visible = v));
730
+ if (!this.flag('paused')) {
731
+ this._timer = setInterval(() => {
732
+ if (this._visible && !(typeof document !== 'undefined' && document.hidden))
733
+ this.next();
734
+ }, Math.max(400, this.num('interval', 2200)));
735
+ }
736
+ }
737
+ unmount() {
738
+ clearInterval(this._timer);
739
+ this._timer = 0;
740
+ }
741
+ next() {
742
+ const els = Array.from(this.querySelectorAll('.usa-rotate-word'));
743
+ if (els.length < 2)
744
+ return;
745
+ const prev = els[this._index];
746
+ this._index = (this._index + 1) % els.length;
747
+ const cur = els[this._index];
748
+ prev.setAttribute('data-hidden', '');
749
+ cur.removeAttribute('data-hidden');
750
+ const effect = this.reduced ? 'fade' : this.str('effect', 'slide');
751
+ const [inFrom, outTo] = effect === 'fade'
752
+ ? [{ opacity: 0 }, { opacity: 0 }]
753
+ : effect === 'flip'
754
+ ? [{ opacity: 0, transform: 'perspective(400px) rotateX(-90deg)' }, { opacity: 0, transform: 'perspective(400px) rotateX(90deg)' }]
755
+ : effect === 'blur'
756
+ ? [{ opacity: 0, filter: 'blur(8px)' }, { opacity: 0, filter: 'blur(8px)' }]
757
+ : [{ opacity: 0, transform: 'translateY(0.8em)' }, { opacity: 0, transform: 'translateY(-0.8em)' }];
758
+ const neutral = { opacity: 1, transform: 'none', filter: 'none' };
759
+ const pick = (f) => Object.fromEntries(Object.keys(f).map((k) => [k, neutral[k]]));
760
+ this.motion(prev, [{ ...pick(outTo) }, outTo], { duration: 380, easing: EASE_OUT });
761
+ this.motion(cur, [inFrom, pick(inFrom)], { duration: 520, easing: effect === 'slide' ? EASE_SPRING : EASE_OUT });
762
+ this.emit('change', { index: this._index, word: cur.textContent });
763
+ }
764
+ }, { id: 'text-rotate', text: css$1 });
765
+ }
766
+
767
+ var css = "usa-wave-text .usa-word,usa-scroll-highlight .usa-word{display:inline-block;white-space:nowrap}usa-wave-text .usa-char{display:inline-block;animation:usa-wave var(--usa-wave-s,1.6s) ease-in-out infinite;animation-delay:calc(var(--i) * var(--usa-wave-d,0.06s))}@keyframes usa-wave{0%,60%,100%{transform:translateY(0)}30%{transform:translateY(calc(var(--usa-wave-a,0.25em) * -1))}}usa-glitch{position:relative;display:inline-block}usa-glitch::before,usa-glitch::after{content:attr(data-text);position:absolute;inset:0;pointer-events:none}usa-glitch::before{color:#ff2bd6;transform:translate(calc(var(--usa-glitch-i,3px) * -1),0);clip-path:inset(0 0 55% 0);mix-blend-mode:screen;animation:usa-glitch-a 2.4s steps(2,end) infinite}usa-glitch::after{color:#00f0ff;transform:translate(var(--usa-glitch-i,3px),0);clip-path:inset(50% 0 0 0);mix-blend-mode:screen;animation:usa-glitch-b 1.9s steps(2,end) infinite}usa-glitch[trigger=\"hover\"]::before,usa-glitch[trigger=\"hover\"]::after{animation-play-state:paused;opacity:0}usa-glitch[trigger=\"hover\"]:hover::before,usa-glitch[trigger=\"hover\"]:hover::after{animation-play-state:running;opacity:1}@keyframes usa-glitch-a{0%{clip-path:inset(0 0 80% 0)}20%{clip-path:inset(30% 0 40% 0)}40%{clip-path:inset(70% 0 5% 0)}60%{clip-path:inset(10% 0 60% 0)}80%{clip-path:inset(50% 0 30% 0)}100%{clip-path:inset(0 0 80% 0)}}@keyframes usa-glitch-b{0%{clip-path:inset(60% 0 10% 0)}25%{clip-path:inset(15% 0 70% 0)}50%{clip-path:inset(80% 0 2% 0)}75%{clip-path:inset(40% 0 35% 0)}100%{clip-path:inset(60% 0 10% 0)}}usa-gradient-text{background:var(--usa-grad) 0 50% / 300% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;-webkit-text-fill-color:transparent;animation:usa-grad-flow var(--usa-grad-s,6s) linear infinite}@keyframes usa-grad-flow{to{background-position:150% 50%}}usa-handwriting{--usa-hw-stroke:currentColor;display:inline-block;line-height:0}usa-handwriting svg{width:auto;max-width:100%;height:auto;overflow:visible}usa-handwriting text{fill:transparent;stroke:var(--usa-hw-stroke);stroke-width:1.2;stroke-dasharray:1600;stroke-dashoffset:1600;font-family:\"Segoe Script\",\"Brush Script MT\",\"Snell Roundhand\",cursive}usa-handwriting[data-state=\"drawing\"] text{animation:usa-hw-draw var(--usa-hw-d,2400ms) cubic-bezier(0.55,0,0.45,1) forwards,usa-hw-fill 0.6s ease calc(var(--usa-hw-d,2400ms) * 0.8) forwards}usa-handwriting[data-state=\"done\"] text{stroke-dashoffset:0;fill:currentColor}@keyframes usa-hw-draw{to{stroke-dashoffset:0}}@keyframes usa-hw-fill{to{fill:currentColor}}usa-scroll-highlight .usa-hl-word{opacity:var(--usa-hl-dim,0.2);transition:opacity 0.35s ease}usa-scroll-highlight .usa-hl-word[data-on]{opacity:1}usa-scroll-highlight[mode=\"marker\"]{--usa-hl-color:color-mix(in srgb,#facc15 55%,transparent);background:linear-gradient(var(--usa-hl-color),var(--usa-hl-color)) 0 88% / 0% 40% no-repeat;transition:background-size 1s cubic-bezier(0.65,0,0.35,1);-webkit-box-decoration-break:clone;box-decoration-break:clone}usa-scroll-highlight[mode=\"marker\"][data-lit]{background-size:100% 40%}@media (prefers-reduced-motion:reduce){usa-wave-text .usa-char,usa-glitch::before,usa-glitch::after,usa-gradient-text{animation:none !important}usa-glitch::before,usa-glitch::after{display:none}usa-scroll-highlight .usa-hl-word,usa-scroll-highlight[mode=\"marker\"]{transition:none}}";
768
+
769
+ /** Split `text` into per-character spans (words never break). The animated copy is aria-hidden. */
770
+ function splitChars(host, text) {
771
+ const vis = document.createElement('span');
772
+ vis.setAttribute('aria-hidden', 'true');
773
+ const chars = [];
774
+ text.split(/(\s+)/).forEach((w) => {
775
+ if (/^\s+$/.test(w)) {
776
+ vis.append(document.createTextNode(w));
777
+ return;
778
+ }
779
+ const word = document.createElement('span');
780
+ word.className = 'usa-word';
781
+ for (const c of Array.from(w)) {
782
+ const s = document.createElement('span');
783
+ s.className = 'usa-char';
784
+ s.textContent = c;
785
+ s.style.setProperty('--i', String(chars.length));
786
+ word.append(s);
787
+ chars.push(s);
788
+ }
789
+ vis.append(word);
790
+ });
791
+ host.replaceChildren(srText(text), vis);
792
+ return chars;
793
+ }
794
+ const textOf = (el) => (el.getAttribute('text') ?? el.dataset.usaText ?? (el.dataset.usaText = (el.textContent || '').trim()));
795
+ function defineWaveText(tag = 'usa-wave-text') {
796
+ return defineElement(tag, (Base) => class extends Base {
797
+ static get observedAttributes() { return ['text']; }
798
+ mount() {
799
+ splitChars(this, textOf(this));
800
+ this.style.setProperty('--usa-wave-a', `${this.num('amplitude', 0.25)}em`);
801
+ this.style.setProperty('--usa-wave-s', `${this.num('speed', 1.6)}s`);
802
+ this.style.setProperty('--usa-wave-d', `${this.num('stagger', 0.06)}s`);
803
+ }
804
+ }, { id: 'text-fx', text: css });
805
+ }
806
+ function defineGlitch(tag = 'usa-glitch') {
807
+ return defineElement(tag, (Base) => class extends Base {
808
+ static get observedAttributes() { return ['text', 'intensity']; }
809
+ mount() {
810
+ const t = textOf(this);
811
+ this.setAttribute('data-text', t);
812
+ this.style.setProperty('--usa-glitch-i', `${this.num('intensity', 3)}px`);
813
+ if (!this.firstChild)
814
+ this.textContent = t;
815
+ }
816
+ }, { id: 'text-fx', text: css });
817
+ }
818
+ function defineGradientText(tag = 'usa-gradient-text') {
819
+ return defineElement(tag, (Base) => class extends Base {
820
+ static get observedAttributes() { return ['colors', 'speed', 'angle']; }
821
+ mount() {
822
+ const c = this.str('colors', '#7c5cff,#22d3ee,#f472b6,#facc15').split(',').map((s) => s.trim());
823
+ this.style.setProperty('--usa-grad', `linear-gradient(${this.num('angle', 90)}deg, ${[...c, c[0]].join(', ')})`);
824
+ this.style.setProperty('--usa-grad-s', `${this.num('speed', 6)}s`);
825
+ }
826
+ }, { id: 'text-fx', text: css });
827
+ }
828
+ function defineHandwriting(tag = 'usa-handwriting') {
829
+ return defineElement(tag, (Base) => class extends Base {
830
+ static get observedAttributes() { return ['text', 'size', 'font']; }
831
+ mount() {
832
+ const t = textOf(this);
833
+ const size = this.num('size', 64);
834
+ const w = Math.ceil(t.length * size * 0.62) + 8;
835
+ this.replaceChildren(srText(t));
836
+ this.insertAdjacentHTML('beforeend', `<svg aria-hidden="true" viewBox="0 0 ${w} ${Math.ceil(size * 1.3)}" width="${w}" height="${Math.ceil(size * 1.3)}"><text x="4" y="${Math.round(size)}" font-size="${size}"></text></svg>`);
837
+ const text = this.querySelector('text');
838
+ text.textContent = t;
839
+ if (this.str('font'))
840
+ text.setAttribute('font-family', this.str('font'));
841
+ if (this.str('stroke'))
842
+ this.style.setProperty('--usa-hw-stroke', this.str('stroke'));
843
+ this.style.setProperty('--usa-hw-d', `${this.num('duration', 2400)}ms`);
844
+ if (this.reduced) {
845
+ this.setAttribute('data-state', 'done');
846
+ return;
847
+ }
848
+ this.inView((v) => v && this.play(), { threshold: 0.3 });
849
+ }
850
+ play() {
851
+ this.removeAttribute('data-state');
852
+ void this.offsetWidth;
853
+ this.setAttribute('data-state', 'drawing');
854
+ setTimeout(() => {
855
+ this.setAttribute('data-state', 'done');
856
+ this.emit('complete');
857
+ }, this.reduced ? 0 : this.num('duration', 2400));
858
+ }
859
+ }, { id: 'text-fx', text: css });
860
+ }
861
+ function defineScrollHighlight(tag = 'usa-scroll-highlight') {
862
+ return defineElement(tag, (Base) => class extends Base {
863
+ constructor() {
864
+ super(...arguments);
865
+ this._f = 0;
866
+ this._p = 0;
867
+ }
868
+ static get observedAttributes() { return ['mode', 'text']; }
869
+ get progress() { return this._p; }
870
+ mount() {
871
+ const mode = this.str('mode', 'words');
872
+ if (this.str('color'))
873
+ this.style.setProperty('--usa-hl-color', this.str('color'));
874
+ this.style.setProperty('--usa-hl-dim', String(this.num('dim', 0.2)));
875
+ if (mode === 'marker') {
876
+ if (this.reduced)
877
+ this.setAttribute('data-lit', '');
878
+ else
879
+ this.inView((v) => v && this.setAttribute('data-lit', ''), { threshold: 0.6 });
880
+ return;
881
+ }
882
+ const t = textOf(this);
883
+ const vis = document.createElement('span');
884
+ vis.setAttribute('aria-hidden', 'true');
885
+ const words = t.split(/\s+/).filter(Boolean).map((w) => {
886
+ const s = document.createElement('span');
887
+ s.className = 'usa-hl-word';
888
+ s.textContent = w;
889
+ vis.append(s, ' ');
890
+ return s;
891
+ });
892
+ this.replaceChildren(srText(t), vis);
893
+ if (this.reduced) {
894
+ words.forEach((w) => w.setAttribute('data-on', ''));
895
+ return;
896
+ }
897
+ const update = () => {
898
+ this._f = 0;
899
+ const r = this.getBoundingClientRect();
900
+ const H = window.innerHeight || 800;
901
+ this._p = clamp((H * 0.85 - r.top) / (r.height + H * 0.35), 0, 1);
902
+ const lit = Math.round(this._p * words.length);
903
+ words.forEach((w, i) => w.toggleAttribute('data-on', i < lit));
904
+ };
905
+ const on = () => !this._f && (this._f = raf(update));
906
+ let active = false;
907
+ this.inView((v) => {
908
+ if (v === active)
909
+ return;
910
+ active = v;
911
+ if (v)
912
+ window.addEventListener('scroll', on, { passive: true });
913
+ else
914
+ window.removeEventListener('scroll', on);
915
+ on();
916
+ });
917
+ this.onCleanup(() => window.removeEventListener('scroll', on));
918
+ }
919
+ unmount() {
920
+ caf(this._f);
921
+ this._f = 0;
922
+ }
923
+ }, { id: 'text-fx', text: css });
924
+ }
925
+
926
+ /**
927
+ * motionary/components/text — text effects.
928
+ * `<usa-typewriter>`, `<usa-split-text>`, `<usa-scramble>`, `<usa-counter>`,
929
+ * `<usa-shimmer-text>`, `<usa-text-rotate>`.
930
+ */
931
+ /** Register every component of this category under its default tag. */
932
+ function defineTextComponents() {
933
+ defineTypewriter();
934
+ defineSplitText();
935
+ defineScramble();
936
+ defineCounter();
937
+ defineShimmerText();
938
+ defineTextRotate();
939
+ defineWaveText();
940
+ defineGlitch();
941
+ defineGradientText();
942
+ defineHandwriting();
943
+ defineScrollHighlight();
944
+ }
945
+
946
+ export { JOINING_SCRIPT, defineCounter, defineGlitch, defineGradientText, defineHandwriting, defineScramble, defineScrollHighlight, defineShimmerText, defineSplitText, defineTextComponents, defineTextRotate, defineTypewriter, defineWaveText, easeOutExpo, graphemes, scrambleFrame, splitOrder, splitText, splitTimeline, words as splitWords };
947
+ //# sourceMappingURL=text.js.map