use-scroll-animate 2.6.0 → 2.7.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 (74) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/README_ja.md +1 -0
  4. package/README_zh.md +1 -0
  5. package/dist/chunks/{base-5DFCAnvH.cjs → base-BR6fYLBA.cjs} +23 -2
  6. package/dist/chunks/base-BR6fYLBA.cjs.map +1 -0
  7. package/dist/chunks/{base-08OYzphB.js → base-D6zLiNGH.js} +21 -3
  8. package/dist/chunks/base-D6zLiNGH.js.map +1 -0
  9. package/dist/chunks/{spring-CpeFkxNd.js → spring-C2Megtcf.js} +3 -3
  10. package/dist/chunks/spring-C2Megtcf.js.map +1 -0
  11. package/dist/chunks/{spring-Bi4qY0pL.cjs → spring-DyHe1Hfa.cjs} +3 -3
  12. package/dist/chunks/spring-DyHe1Hfa.cjs.map +1 -0
  13. package/dist/components/background.cjs +1 -1
  14. package/dist/components/background.d.cts +8 -0
  15. package/dist/components/background.d.ts +8 -0
  16. package/dist/components/background.js +2 -2
  17. package/dist/components/cards.cjs +2 -2
  18. package/dist/components/cards.d.cts +8 -0
  19. package/dist/components/cards.d.ts +8 -0
  20. package/dist/components/cards.js +3 -3
  21. package/dist/components/click.cjs +2 -2
  22. package/dist/components/click.d.cts +8 -0
  23. package/dist/components/click.d.ts +8 -0
  24. package/dist/components/click.js +3 -3
  25. package/dist/components/feedback.cjs +1 -1
  26. package/dist/components/feedback.d.cts +8 -0
  27. package/dist/components/feedback.d.ts +8 -0
  28. package/dist/components/feedback.js +2 -2
  29. package/dist/components/interaction.cjs +1 -1
  30. package/dist/components/interaction.d.cts +8 -0
  31. package/dist/components/interaction.d.ts +8 -0
  32. package/dist/components/interaction.js +2 -2
  33. package/dist/components/page.cjs +801 -0
  34. package/dist/components/page.cjs.map +1 -0
  35. package/dist/components/page.css +11 -0
  36. package/dist/components/page.d.cts +275 -0
  37. package/dist/components/page.d.ts +275 -0
  38. package/dist/components/page.js +776 -0
  39. package/dist/components/page.js.map +1 -0
  40. package/dist/components/physics.cjs +2 -2
  41. package/dist/components/physics.d.cts +8 -0
  42. package/dist/components/physics.d.ts +8 -0
  43. package/dist/components/physics.js +4 -4
  44. package/dist/components/reveal.cjs +1 -1
  45. package/dist/components/reveal.d.cts +8 -0
  46. package/dist/components/reveal.d.ts +8 -0
  47. package/dist/components/reveal.js +2 -2
  48. package/dist/components/text.cjs +1 -1
  49. package/dist/components/text.d.cts +8 -0
  50. package/dist/components/text.d.ts +8 -0
  51. package/dist/components/text.js +2 -2
  52. package/dist/components/transitions.cjs +1 -1
  53. package/dist/components/transitions.d.cts +8 -0
  54. package/dist/components/transitions.d.ts +8 -0
  55. package/dist/components/transitions.js +2 -2
  56. package/dist/components/ui.cjs +2 -2
  57. package/dist/components/ui.d.cts +8 -0
  58. package/dist/components/ui.d.ts +8 -0
  59. package/dist/components/ui.js +3 -3
  60. package/dist/components.cjs +28 -2
  61. package/dist/components.cjs.map +1 -1
  62. package/dist/components.css +9 -0
  63. package/dist/components.d.cts +239 -2
  64. package/dist/components.d.ts +239 -2
  65. package/dist/components.js +8 -4
  66. package/dist/components.js.map +1 -1
  67. package/dist/components.umd.js +2 -2
  68. package/dist/components.umd.js.map +1 -1
  69. package/docs/components.md +17 -0
  70. package/package.json +13 -2
  71. package/dist/chunks/base-08OYzphB.js.map +0 -1
  72. package/dist/chunks/base-5DFCAnvH.cjs.map +0 -1
  73. package/dist/chunks/spring-Bi4qY0pL.cjs.map +0 -1
  74. package/dist/chunks/spring-CpeFkxNd.js.map +0 -1
@@ -0,0 +1,776 @@
1
+ import { d as defineElement, e as caf, r as raf, p as prefersReducedMotion, n as now, g as getMotionIntensity, a as configureComponents, i as adoptStyles } from '../chunks/base-D6zLiNGH.js';
2
+ export { M as MOTION_SCALE } from '../chunks/base-D6zLiNGH.js';
3
+ import { e as springSamples } from '../chunks/spring-C2Megtcf.js';
4
+
5
+ var css$8 = "usa-cursor{--usa-cursor-color:var(--usa-accent,#7c5cff);--usa-cursor-size:28px;position:fixed;inset:0;pointer-events:none;z-index:2147483600;opacity:0;transition:opacity 0.2s ease;contain:strict}usa-cursor[data-active]{opacity:1}usa-cursor .usa-cursor-ring{position:absolute;left:0;top:0;width:var(--usa-cursor-size);height:var(--usa-cursor-size);margin:calc(var(--usa-cursor-size) / -2) 0 0 calc(var(--usa-cursor-size) / -2);border:1.5px solid var(--usa-cursor-color);border-radius:999px;box-sizing:border-box;transition:width 0.25s cubic-bezier(0.34,1.56,0.64,1),height 0.25s cubic-bezier(0.34,1.56,0.64,1),margin 0.25s ease,border-radius 0.25s ease,background-color 0.2s ease;will-change:transform}usa-cursor[mode=\"trail\"] .usa-cursor-ring{border:0;background:var(--usa-cursor-color);width:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));height:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04));margin:calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2) 0 0 calc(var(--usa-cursor-size) * (0.45 - var(--i) * 0.04) / -2);opacity:calc(1 - var(--i) * 0.11)}usa-cursor[data-hover] .usa-cursor-ring:first-child{width:calc(var(--usa-cursor-size) * 1.6);height:calc(var(--usa-cursor-size) * 1.6);margin:calc(var(--usa-cursor-size) * -0.8) 0 0 calc(var(--usa-cursor-size) * -0.8);background:color-mix(in srgb,var(--usa-cursor-color) 15%,transparent)}usa-cursor[data-snapped] .usa-cursor-ring{border-radius:12px;background:color-mix(in srgb,var(--usa-cursor-color) 12%,transparent);translate:-50% -50%;margin:0}usa-cursor[data-down] .usa-cursor-ring:first-child{scale:0.8}usa-cursor .usa-cursor-dot{position:absolute;left:-3px;top:-3px;width:6px;height:6px;border-radius:50%;background:var(--usa-cursor-color)}usa-cursor[data-snapped] .usa-cursor-dot{opacity:0}usa-cursor .usa-cursor-glow{position:absolute;left:-200px;top:-200px;width:400px;height:400px;border-radius:50%;background:radial-gradient(circle,color-mix(in srgb,var(--usa-cursor-color) 35%,transparent),transparent 65%);mix-blend-mode:screen}.usa-cursor-none,.usa-cursor-none *{cursor:none !important}@media (pointer:coarse),(prefers-reduced-motion:reduce){usa-cursor{display:none}.usa-cursor-none,.usa-cursor-none *{cursor:auto !important}}";
6
+
7
+ const CURSOR_MODES = ['dot', 'trail', 'magnetic', 'glow'];
8
+ function defineCursor(tag = 'usa-cursor') {
9
+ return defineElement(tag, (Base) => class UsaCursor extends Base {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._frame = 0;
13
+ }
14
+ static get observedAttributes() {
15
+ return ['mode', 'size', 'color', 'hide-native'];
16
+ }
17
+ get active() {
18
+ return this.hasAttribute('data-active');
19
+ }
20
+ mount() {
21
+ this.setAttribute('aria-hidden', 'true');
22
+ const fine = typeof matchMedia !== 'function' || matchMedia('(pointer: fine)').matches || matchMedia('(hover: hover)').matches;
23
+ if (this.reduced || !fine)
24
+ return;
25
+ const mode = this.str('mode', 'dot');
26
+ const n = mode === 'trail' ? 8 : 1;
27
+ this.innerHTML = Array.from({ length: n }, (_, i) => `<span class="usa-cursor-${mode === 'glow' ? 'glow' : 'ring'}" style="--i:${i}"></span>`).join('') + (mode === 'glow' ? '' : '<span class="usa-cursor-dot"></span>');
28
+ if (this.str('color'))
29
+ this.style.setProperty('--usa-cursor-color', this.str('color'));
30
+ this.style.setProperty('--usa-cursor-size', `${this.num('size', 28)}px`);
31
+ if (this.flag('hide-native'))
32
+ document.documentElement.classList.add('usa-cursor-none');
33
+ this.onCleanup(() => document.documentElement.classList.remove('usa-cursor-none'));
34
+ const parts = Array.from(this.querySelectorAll('.usa-cursor-ring, .usa-cursor-glow'));
35
+ const dot = this.querySelector('.usa-cursor-dot');
36
+ const pts = parts.map(() => ({ x: -100, y: -100 }));
37
+ let mx = -100;
38
+ let my = -100;
39
+ let snap = null;
40
+ const sel = this.str('targets', 'a, button, [role="button"], [data-cursor], input, select, textarea, label');
41
+ const loop = () => {
42
+ this._frame = 0;
43
+ let tx = mx;
44
+ let ty = my;
45
+ pts.forEach((p, i) => {
46
+ const k = mode === 'trail' ? 0.35 - i * 0.03 : mode === 'glow' ? 0.12 : 0.22;
47
+ const goalX = snap && i === 0 ? snap.left + snap.width / 2 : tx;
48
+ const goalY = snap && i === 0 ? snap.top + snap.height / 2 : ty;
49
+ p.x += (goalX - p.x) * k;
50
+ p.y += (goalY - p.y) * k;
51
+ parts[i].style.transform = `translate3d(${p.x.toFixed(1)}px, ${p.y.toFixed(1)}px, 0)`;
52
+ tx = p.x;
53
+ ty = p.y;
54
+ });
55
+ if (snap && parts[0]) {
56
+ parts[0].style.width = `${snap.width + 12}px`;
57
+ parts[0].style.height = `${snap.height + 12}px`;
58
+ }
59
+ else if (parts[0]) {
60
+ parts[0].style.width = parts[0].style.height = '';
61
+ }
62
+ if (dot)
63
+ dot.style.transform = `translate3d(${mx}px, ${my}px, 0)`;
64
+ const moving = pts.some((p, i) => Math.abs(p.x - (i === 0 && snap ? snap.left + snap.width / 2 : mx)) > 0.3);
65
+ if (moving)
66
+ this._frame = raf(loop);
67
+ };
68
+ const kick = () => {
69
+ if (!this._frame)
70
+ this._frame = raf(loop);
71
+ };
72
+ this.listen(document, 'pointermove', (e) => {
73
+ if (e.pointerType === 'touch')
74
+ return;
75
+ mx = e.clientX;
76
+ my = e.clientY;
77
+ this.setAttribute('data-active', '');
78
+ if (mode === 'magnetic') {
79
+ const t = e.target?.closest?.(sel);
80
+ snap = t ? t.getBoundingClientRect() : null;
81
+ this.toggleAttribute('data-snapped', !!t);
82
+ }
83
+ else {
84
+ this.toggleAttribute('data-hover', !!e.target?.closest?.(sel));
85
+ }
86
+ kick();
87
+ }, { passive: true });
88
+ this.listen(document, 'pointerdown', () => this.setAttribute('data-down', ''));
89
+ this.listen(document, 'pointerup', () => this.removeAttribute('data-down'));
90
+ this.listen(document.documentElement, 'pointerleave', () => this.removeAttribute('data-active'));
91
+ }
92
+ unmount() {
93
+ caf(this._frame);
94
+ this._frame = 0;
95
+ this.removeAttribute('data-active');
96
+ }
97
+ }, { id: 'cursor', text: css$8 });
98
+ }
99
+
100
+ function smoothScroll(options = {}) {
101
+ if (typeof window === 'undefined' || prefersReducedMotion())
102
+ return () => undefined;
103
+ const el = options.target || null;
104
+ const lerp = Math.min(1, Math.max(0.02, options.lerp ?? 0.12));
105
+ const mult = options.wheelMultiplier ?? 1;
106
+ const get = () => (el ? el.scrollTop : window.scrollY);
107
+ const max = () => (el ? el.scrollHeight - el.clientHeight : document.documentElement.scrollHeight - window.innerHeight);
108
+ const set = (y) => (el ? (el.scrollTop = y) : window.scrollTo(0, y));
109
+ let target = get();
110
+ let current = target;
111
+ let id = 0;
112
+ const loop = () => {
113
+ current += (target - current) * lerp;
114
+ if (Math.abs(target - current) < 0.5)
115
+ current = target;
116
+ set(current);
117
+ id = current === target ? 0 : raf(loop);
118
+ };
119
+ const onWheel = (e) => {
120
+ if (e.ctrlKey || e.defaultPrevented)
121
+ return;
122
+ if (!id)
123
+ target = current = get();
124
+ e.preventDefault();
125
+ const dy = e.deltaMode === 1 ? e.deltaY * 16 : e.deltaMode === 2 ? e.deltaY * (window.innerHeight || 800) : e.deltaY;
126
+ target = Math.max(0, Math.min(max(), target + dy * mult));
127
+ if (!id)
128
+ id = raf(loop);
129
+ };
130
+ const onScroll = () => {
131
+ if (!id)
132
+ target = current = get();
133
+ };
134
+ const host = el || window;
135
+ host.addEventListener('wheel', onWheel, { passive: false });
136
+ host.addEventListener('scroll', onScroll, { passive: true });
137
+ return () => {
138
+ host.removeEventListener('wheel', onWheel);
139
+ host.removeEventListener('scroll', onScroll);
140
+ if (id)
141
+ caf(id);
142
+ id = 0;
143
+ };
144
+ }
145
+ /**
146
+ * Scroll to a y position, element or selector with spring timing (or
147
+ * instantly under reduced motion). Resolves when done.
148
+ */
149
+ function scrollToTarget(to, options = {}) {
150
+ if (typeof window === 'undefined')
151
+ return Promise.resolve();
152
+ const el = options.target || null;
153
+ const start = el ? el.scrollTop : window.scrollY;
154
+ let y = typeof to === 'number' ? to : 0;
155
+ if (typeof to !== 'number') {
156
+ const node = typeof to === 'string' ? document.querySelector(to) : to;
157
+ if (!node)
158
+ return Promise.resolve();
159
+ const top = node.getBoundingClientRect().top;
160
+ y = start + top - (el ? el.getBoundingClientRect().top : 0);
161
+ }
162
+ y = Math.max(0, y - (options.offset ?? 0));
163
+ const set = (v) => (el ? (el.scrollTop = v) : window.scrollTo(0, v));
164
+ if (prefersReducedMotion()) {
165
+ set(y);
166
+ return Promise.resolve();
167
+ }
168
+ const { values, duration } = springSamples(options.preset || 'slow');
169
+ const t0 = now();
170
+ return new Promise((resolve) => {
171
+ const step = () => {
172
+ const p = Math.min(1, (now() - t0) / Math.max(1, duration));
173
+ const v = values[Math.min(values.length - 1, Math.round(p * (values.length - 1)))];
174
+ set(start + (y - start) * v);
175
+ if (p < 1)
176
+ raf(step);
177
+ else
178
+ resolve();
179
+ };
180
+ raf(step);
181
+ });
182
+ }
183
+
184
+ var css$7 = "usa-fullpage{position:relative;display:block;height:100vh;height:100dvh;overflow-y:auto;scroll-snap-type:y mandatory;overscroll-behavior:contain;outline:none}usa-fullpage[axis=\"x\"]{display:flex;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x mandatory}usa-fullpage .usa-fullpage-section{box-sizing:border-box;min-height:100%;scroll-snap-align:start;scroll-snap-stop:always}usa-fullpage[axis=\"x\"] .usa-fullpage-section{flex:0 0 100%}usa-fullpage .usa-fullpage-dots{position:sticky;float:right;top:50%;margin-right:16px;transform:translateY(-50%);display:grid;gap:10px;z-index:5}usa-fullpage .usa-fullpage-dots button{width:10px;height:10px;padding:0;border-radius:50%;border:0;cursor:pointer;background:color-mix(in srgb,currentColor 35%,transparent);transition:transform 0.3s cubic-bezier(0.34,1.56,0.64,1),background-color 0.2s ease}usa-fullpage .usa-fullpage-dots button[aria-current]{background:var(--usa-accent,#7c5cff);transform:scale(1.5)}";
185
+
186
+ function defineFullpage(tag = 'usa-fullpage') {
187
+ return defineElement(tag, (Base) => class UsaFullpage extends Base {
188
+ constructor() {
189
+ super(...arguments);
190
+ this._i = 0;
191
+ }
192
+ get index() {
193
+ return this._i;
194
+ }
195
+ sections() {
196
+ return Array.from(this.children).filter((c) => !c.classList.contains('usa-fullpage-dots'));
197
+ }
198
+ mount() {
199
+ if (!this.hasAttribute('tabindex'))
200
+ this.tabIndex = 0;
201
+ const secs = this.sections();
202
+ secs.forEach((s, i) => {
203
+ s.classList.add('usa-fullpage-section');
204
+ s.setAttribute('data-index', String(i));
205
+ });
206
+ let nav = null;
207
+ if (this.flag('dots')) {
208
+ nav = document.createElement('nav');
209
+ nav.className = 'usa-fullpage-dots';
210
+ nav.setAttribute('aria-label', 'Sections');
211
+ secs.forEach((s, i) => {
212
+ const b = document.createElement('button');
213
+ b.type = 'button';
214
+ b.setAttribute('aria-label', s.getAttribute('aria-label') || s.querySelector('h1,h2,h3')?.textContent?.trim() || `Section ${i + 1}`);
215
+ b.addEventListener('click', () => this.go(i));
216
+ nav.append(b);
217
+ });
218
+ this.append(nav);
219
+ this.onCleanup(() => nav?.remove());
220
+ }
221
+ this.mark(0);
222
+ if (typeof IntersectionObserver !== 'undefined') {
223
+ const io = new IntersectionObserver((entries) => {
224
+ for (const e of entries)
225
+ if (e.isIntersecting && e.intersectionRatio >= 0.6)
226
+ this.mark(Number(e.target.dataset.index));
227
+ }, { root: this, threshold: [0.6] });
228
+ secs.forEach((s) => io.observe(s));
229
+ this.onCleanup(() => io.disconnect());
230
+ }
231
+ this.listen(this, 'keydown', (e) => {
232
+ const n = this.sections().length;
233
+ const map = { PageDown: this._i + 1, ArrowDown: this._i + 1, ' ': this._i + 1, PageUp: this._i - 1, ArrowUp: this._i - 1, Home: 0, End: n - 1 };
234
+ if (this.str('axis') === 'x')
235
+ Object.assign(map, { ArrowRight: this._i + 1, ArrowLeft: this._i - 1 });
236
+ if (!(e.key in map) || e.target.closest?.('input, textarea, select'))
237
+ return;
238
+ e.preventDefault();
239
+ this.go(map[e.key]);
240
+ });
241
+ }
242
+ mark(i) {
243
+ if (i === this._i && this.hasAttribute('data-ready'))
244
+ return;
245
+ this.setAttribute('data-ready', '');
246
+ this._i = i;
247
+ this.sections().forEach((s, j) => s.toggleAttribute('data-current', j === i));
248
+ this.querySelectorAll('.usa-fullpage-dots button').forEach((b, j) => (j === i ? b.setAttribute('aria-current', 'true') : b.removeAttribute('aria-current')));
249
+ this.emit('section', { index: i });
250
+ }
251
+ go(i) {
252
+ const secs = this.sections();
253
+ const t = secs[Math.max(0, Math.min(secs.length - 1, i))];
254
+ if (!t)
255
+ return;
256
+ if (this.str('axis') === 'x')
257
+ this.scrollTo({ left: t.offsetLeft, behavior: this.reduced ? 'auto' : 'smooth' });
258
+ else
259
+ scrollToTarget(t.offsetTop, { target: this, preset: 'stiff' });
260
+ this.mark(secs.indexOf(t));
261
+ }
262
+ next() {
263
+ this.go(this._i + 1);
264
+ }
265
+ prev() {
266
+ this.go(this._i - 1);
267
+ }
268
+ }, { id: 'fullpage', text: css$7 });
269
+ }
270
+
271
+ var css$6 = "usa-loading-bar{--usa-loading:0;--usa-loading-h:3px;--usa-loading-color:var(--usa-accent,#7c5cff);position:fixed;left:0;right:0;top:0;height:var(--usa-loading-h);z-index:2147483500;pointer-events:none;opacity:0;transition:opacity 0.3s ease}usa-loading-bar[position=\"bottom\"]{top:auto;bottom:0}usa-loading-bar[data-active]{opacity:1}usa-loading-bar .usa-loading-bar-fill{position:absolute;inset:0;transform-origin:0 50%;transform:scaleX(var(--usa-loading));background:var(--usa-loading-color);box-shadow:0 0 10px var(--usa-loading-color);transition:transform 0.2s ease-out}@media (prefers-reduced-motion:reduce){usa-loading-bar .usa-loading-bar-fill{transition:none}}";
272
+
273
+ function defineLoadingBar(tag = 'usa-loading-bar') {
274
+ return defineElement(tag, (Base) => class UsaLoadingBar extends Base {
275
+ constructor() {
276
+ super(...arguments);
277
+ this._p = 0;
278
+ }
279
+ get progress() {
280
+ return this._p;
281
+ }
282
+ mount() {
283
+ if (!this.querySelector('.usa-loading-bar-fill'))
284
+ this.innerHTML = '<span class="usa-loading-bar-fill"></span>';
285
+ this.setAttribute('role', 'progressbar');
286
+ this.setAttribute('aria-label', this.str('label', 'Loading'));
287
+ this.setAttribute('aria-valuemin', '0');
288
+ this.setAttribute('aria-valuemax', '100');
289
+ if (this.str('color'))
290
+ this.style.setProperty('--usa-loading-color', this.str('color'));
291
+ this.style.setProperty('--usa-loading-h', `${this.num('height', 3)}px`);
292
+ this.paint();
293
+ }
294
+ unmount() {
295
+ clearInterval(this._t);
296
+ clearTimeout(this._h);
297
+ }
298
+ paint() {
299
+ this.style.setProperty('--usa-loading', this._p.toFixed(4));
300
+ this.setAttribute('aria-valuenow', String(Math.round(this._p * 100)));
301
+ }
302
+ start() {
303
+ clearTimeout(this._h);
304
+ clearInterval(this._t);
305
+ this.setAttribute('data-active', '');
306
+ this.setAttribute('aria-busy', 'true');
307
+ this._p = Math.max(this._p, 0.08);
308
+ this.paint();
309
+ this._t = setInterval(() => {
310
+ this._p += (0.9 - this._p) * (this.reduced ? 0.5 : 0.08);
311
+ this.paint();
312
+ }, 200);
313
+ }
314
+ set(p) {
315
+ this.setAttribute('data-active', '');
316
+ this._p = Math.max(0, Math.min(1, p));
317
+ this.paint();
318
+ }
319
+ done() {
320
+ clearInterval(this._t);
321
+ this._p = 1;
322
+ this.paint();
323
+ this.removeAttribute('aria-busy');
324
+ this._h = setTimeout(() => {
325
+ this.removeAttribute('data-active');
326
+ this._h = setTimeout(() => {
327
+ this._p = 0;
328
+ this.paint();
329
+ }, 300);
330
+ }, 250);
331
+ }
332
+ }, { id: 'loading-bar', text: css$6 });
333
+ }
334
+ function bar() {
335
+ if (typeof document === 'undefined')
336
+ return null;
337
+ let el = document.querySelector('usa-loading-bar');
338
+ if (!el) {
339
+ defineLoadingBar();
340
+ el = document.createElement('usa-loading-bar');
341
+ document.body.appendChild(el);
342
+ }
343
+ return typeof el.start === 'function' ? el : null;
344
+ }
345
+ /** Drive the page's `<usa-loading-bar>` (created on first use). */
346
+ const loadingBar = {
347
+ start: () => bar()?.start(),
348
+ set: (p) => bar()?.set(p),
349
+ done: () => bar()?.done(),
350
+ /** Run `task` with the bar shown; resolves with its result. */
351
+ async track(task) {
352
+ bar()?.start();
353
+ try {
354
+ return await (typeof task === 'function' ? task() : task);
355
+ }
356
+ finally {
357
+ bar()?.done();
358
+ }
359
+ },
360
+ };
361
+
362
+ var css$5 = "usa-back-to-top{--usa-btt:0;position:fixed;right:max(20px,env(safe-area-inset-right));bottom:max(20px,env(safe-area-inset-bottom));z-index:850;opacity:0;transform:translateY(16px) scale(0.8);pointer-events:none;transition:opacity 0.25s ease,transform 0.4s cubic-bezier(0.34,1.56,0.64,1)}usa-back-to-top[position=\"bottom-left\"]{right:auto;left:max(20px,env(safe-area-inset-left))}usa-back-to-top[data-visible]{opacity:1;transform:none;pointer-events:auto}usa-back-to-top button{width:48px;height:48px;padding:0;border:0;border-radius:50%;cursor:pointer;display:grid;place-items:center;color:var(--usa-accent,#7c5cff);background:var(--usa-surface,#1b1e27);box-shadow:var(--usa-shadow,0 8px 24px -10px rgb(0 0 0 / 0.5))}usa-back-to-top svg{width:44px;height:44px;fill:none;stroke:currentColor;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}usa-back-to-top circle{stroke-dasharray:100;stroke-dashoffset:calc(100 - var(--usa-btt) * 100);transform:rotate(-90deg);transform-origin:50% 50%;opacity:0.85}usa-back-to-top button:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:3px}@media (prefers-reduced-motion:reduce){usa-back-to-top{transition:opacity 0.2s ease;transform:none}}";
363
+
364
+ function defineBackToTop(tag = 'usa-back-to-top') {
365
+ return defineElement(tag, (Base) => class UsaBackToTop extends Base {
366
+ constructor() {
367
+ super(...arguments);
368
+ this._frame = 0;
369
+ }
370
+ get visible() {
371
+ return this.hasAttribute('data-visible');
372
+ }
373
+ mount() {
374
+ if (!this.querySelector('button')) {
375
+ this.innerHTML = `<button type="button" aria-label="${this.str('label', 'Back to top')}"><svg viewBox="0 0 36 36" aria-hidden="true"><circle cx="18" cy="18" r="16" pathLength="100"/><path d="M12 20l6-6 6 6"/></svg></button>`;
376
+ }
377
+ const btn = this.querySelector('button');
378
+ const update = () => {
379
+ this._frame = 0;
380
+ const y = window.scrollY || document.documentElement.scrollTop || 0;
381
+ const max = Math.max(1, (document.documentElement.scrollHeight || 0) - (window.innerHeight || 0));
382
+ this.toggleAttribute('data-visible', y > this.num('offset', 300));
383
+ this.style.setProperty('--usa-btt', Math.min(1, y / max).toFixed(4));
384
+ };
385
+ this.listen(window, 'scroll', () => {
386
+ if (!this._frame)
387
+ this._frame = raf(update);
388
+ }, { passive: true });
389
+ this.listen(btn, 'click', async () => {
390
+ await scrollToTarget(0, { preset: 'slow' });
391
+ const f = document.querySelector(this.str('focus-target', '#main')) || document.body;
392
+ if (!f.hasAttribute('tabindex') && f !== document.body)
393
+ f.tabIndex = -1;
394
+ f.focus?.({ preventScroll: true });
395
+ });
396
+ update();
397
+ }
398
+ unmount() {
399
+ caf(this._frame);
400
+ this._frame = 0;
401
+ }
402
+ }, { id: 'back-to-top', text: css$5 });
403
+ }
404
+
405
+ var css$4 = "usa-ambient{--usa-ambient-opacity:0.6;--usa-ambient-p:0;position:fixed;inset:0;z-index:-1;pointer-events:none;opacity:var(--usa-ambient-opacity);contain:strict}usa-ambient[layer=\"front\"]{z-index:2147483000}usa-ambient canvas{display:block}usa-ambient[effect=\"noise\"]{opacity:calc(var(--usa-ambient-opacity) * 0.25);background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\");animation:usa-ambient-grain 0.6s steps(4) infinite;mix-blend-mode:overlay}@keyframes usa-ambient-grain{25%{background-position:-40px 20px}50%{background-position:30px -50px}75%{background-position:-20px -30px}}usa-ambient[effect=\"gradient\"]{background:linear-gradient(135deg,hsl(calc(250 + var(--usa-ambient-p) * 140) 85% 60%),hsl(calc(190 + var(--usa-ambient-p) * 160) 85% 55%) 50%,hsl(calc(320 + var(--usa-ambient-p) * 90) 85% 62%))}@media (prefers-reduced-motion:reduce){usa-ambient[effect=\"noise\"]{animation:none}}";
406
+
407
+ const AMBIENT_EFFECTS = ['particles', 'snow', 'stars', 'noise', 'gradient'];
408
+ function defineAmbient(tag = 'usa-ambient') {
409
+ return defineElement(tag, (Base) => class UsaAmbient extends Base {
410
+ constructor() {
411
+ super(...arguments);
412
+ this._frame = 0;
413
+ }
414
+ static get observedAttributes() {
415
+ return ['effect', 'density', 'color'];
416
+ }
417
+ mount() {
418
+ this.setAttribute('aria-hidden', 'true');
419
+ const effect = this.str('effect', 'particles');
420
+ this.style.setProperty('--usa-ambient-opacity', String(this.num('opacity', 0.6)));
421
+ this.replaceChildren();
422
+ if (effect === 'noise')
423
+ return;
424
+ if (effect === 'gradient') {
425
+ const upd = () => {
426
+ this._frame = 0;
427
+ const max = Math.max(1, document.documentElement.scrollHeight - window.innerHeight);
428
+ this.style.setProperty('--usa-ambient-p', ((window.scrollY || 0) / max).toFixed(4));
429
+ };
430
+ if (!this.reduced)
431
+ this.listen(window, 'scroll', () => !this._frame && (this._frame = raf(upd)), { passive: true });
432
+ upd();
433
+ return;
434
+ }
435
+ const canvas = document.createElement('canvas');
436
+ this.append(canvas);
437
+ const ctx = canvas.getContext?.('2d');
438
+ if (!ctx)
439
+ return;
440
+ const dpr = Math.min(2, window.devicePixelRatio || 1);
441
+ let W = 0;
442
+ let H = 0;
443
+ const color = this.str('color', effect === 'snow' ? '#ffffff' : effect === 'stars' ? '#ffffff' : '#a78bfa');
444
+ const speed = this.num('speed', 1);
445
+ const resize = () => {
446
+ W = window.innerWidth || 800;
447
+ H = window.innerHeight || 600;
448
+ canvas.width = W * dpr;
449
+ canvas.height = H * dpr;
450
+ canvas.style.width = `${W}px`;
451
+ canvas.style.height = `${H}px`;
452
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
453
+ };
454
+ resize();
455
+ const base = effect === 'stars' ? 140 : effect === 'snow' ? 90 : 60;
456
+ const n = Math.round(base * Math.max(0.2, Math.min(3, this.num('density', 1))) * Math.min(1.5, (W * H) / (1280 * 800)));
457
+ const dots = Array.from({ length: n }, () => ({
458
+ x: Math.random() * W,
459
+ y: Math.random() * H,
460
+ r: effect === 'stars' ? Math.random() * 1.3 + 0.2 : effect === 'snow' ? Math.random() * 2.6 + 0.8 : Math.random() * 2 + 0.6,
461
+ vx: (Math.random() - 0.5) * 0.25,
462
+ vy: effect === 'snow' ? Math.random() * 0.8 + 0.4 : (Math.random() - 0.5) * 0.25,
463
+ t: Math.random() * Math.PI * 2,
464
+ }));
465
+ ctx.fillStyle = color;
466
+ const draw = (move) => {
467
+ ctx.clearRect(0, 0, W, H);
468
+ for (const d of dots) {
469
+ if (move) {
470
+ d.t += 0.02 * speed;
471
+ d.x += (d.vx + (effect === 'snow' ? Math.sin(d.t) * 0.3 : 0)) * speed;
472
+ d.y += d.vy * speed;
473
+ if (d.y > H + 5)
474
+ d.y = -5;
475
+ if (d.y < -5)
476
+ d.y = H + 5;
477
+ if (d.x > W + 5)
478
+ d.x = -5;
479
+ if (d.x < -5)
480
+ d.x = W + 5;
481
+ }
482
+ ctx.globalAlpha = effect === 'stars' ? 0.35 + 0.65 * Math.abs(Math.sin(d.t)) : 0.85;
483
+ ctx.beginPath();
484
+ ctx.arc(d.x, d.y, d.r, 0, Math.PI * 2);
485
+ ctx.fill();
486
+ }
487
+ };
488
+ this.listen(window, 'resize', () => {
489
+ resize();
490
+ ctx.fillStyle = color;
491
+ draw(false);
492
+ });
493
+ if (this.reduced) {
494
+ draw(false);
495
+ return;
496
+ }
497
+ const loop = () => {
498
+ if (!document.hidden)
499
+ draw(true);
500
+ this._frame = raf(loop);
501
+ };
502
+ this._frame = raf(loop);
503
+ }
504
+ unmount() {
505
+ caf(this._frame);
506
+ this._frame = 0;
507
+ }
508
+ }, { id: 'ambient', text: css$4 });
509
+ }
510
+
511
+ var css$3 = "usa-splash{position:fixed;inset:0;z-index:2147483400;display:grid;place-items:center;background:var(--usa-splash-bg,var(--usa-surface,#0b0d12));color:var(--usa-text,#fff)}usa-splash[hidden]{display:none}";
512
+
513
+ function defineSplash(tag = 'usa-splash') {
514
+ return defineElement(tag, (Base) => class UsaSplash extends Base {
515
+ constructor() {
516
+ super(...arguments);
517
+ this._t0 = 0;
518
+ this._gone = false;
519
+ }
520
+ mount() {
521
+ this._t0 = Date.now();
522
+ this.setAttribute('role', 'status');
523
+ this.setAttribute('aria-label', this.str('label', 'Loading'));
524
+ document.body?.setAttribute('aria-busy', 'true');
525
+ if (this.flag('manual'))
526
+ return;
527
+ if (document.readyState === 'complete')
528
+ this.done();
529
+ else
530
+ this.listen(window, 'load', () => this.done(), { once: true });
531
+ }
532
+ async done() {
533
+ if (this._gone)
534
+ return;
535
+ this._gone = true;
536
+ const wait = Math.max(0, this.num('min', 600) - (Date.now() - this._t0));
537
+ if (wait)
538
+ await new Promise((r) => setTimeout(r, wait));
539
+ const exit = this.reduced ? 'fade' : this.str('exit', 'fade');
540
+ const frames = {
541
+ fade: [{ opacity: 1 }, { opacity: 0 }],
542
+ scale: [{ opacity: 1, transform: 'scale(1)' }, { opacity: 0, transform: 'scale(1.15)' }],
543
+ 'slide-up': [{ transform: 'translateY(0)' }, { transform: 'translateY(-100%)' }],
544
+ circle: [{ clipPath: 'circle(150% at 50% 50%)' }, { clipPath: 'circle(0% at 50% 50%)' }],
545
+ };
546
+ const a = this.motion(this, frames[exit] || frames.fade, { duration: this.reduced ? 200 : 550, easing: 'cubic-bezier(0.65, 0, 0.35, 1)', fill: 'forwards' });
547
+ await a?.finished.catch(() => undefined);
548
+ document.body?.removeAttribute('aria-busy');
549
+ this.hidden = true;
550
+ this.emit('done');
551
+ }
552
+ }, { id: 'splash', text: css$3 });
553
+ }
554
+
555
+ var css$2 = "usa-auto-skeleton{display:block;--usa-skel-base:color-mix(in srgb,currentColor 10%,transparent);--usa-skel-shine:color-mix(in srgb,currentColor 18%,transparent)}usa-auto-skeleton[loading] :is(h1,h2,h3,h4,h5,h6,p,li,span,a,button,label,img,svg,video,input,select,textarea,td,th,figcaption,blockquote,[data-skeleton]):not([data-no-skeleton]):not(:has(:is(h1,h2,h3,h4,h5,h6,p,li,img,button,input))){color:transparent !important;border-color:transparent !important;box-shadow:none !important;user-select:none;pointer-events:none;background:linear-gradient(90deg,var(--usa-skel-base) 25%,var(--usa-skel-shine) 50%,var(--usa-skel-base) 75%) 0 0 / 300% 100% !important;border-radius:6px;animation:usa-skel-shimmer 1.4s ease-in-out infinite}usa-auto-skeleton[loading] :is(img,svg,video){opacity:0}usa-auto-skeleton[loading] :is(img,svg,video):not([data-no-skeleton]){opacity:1;object-position:-9999px}@keyframes usa-skel-shimmer{from{background-position:100% 0}to{background-position:0 0}}@media (prefers-reduced-motion:reduce){usa-auto-skeleton[loading] *{animation:none !important}}";
556
+
557
+ function defineAutoSkeleton(tag = 'usa-auto-skeleton') {
558
+ return defineElement(tag, (Base) => class UsaAutoSkeleton extends Base {
559
+ static get observedAttributes() {
560
+ return ['loading'];
561
+ }
562
+ get loading() {
563
+ return this.flag('loading');
564
+ }
565
+ set loading(v) {
566
+ this.setFlag('loading', v);
567
+ }
568
+ mount() {
569
+ this.sync(false);
570
+ }
571
+ changed() {
572
+ this.sync(true);
573
+ }
574
+ sync(animate) {
575
+ if (this.loading)
576
+ this.setAttribute('aria-busy', 'true');
577
+ else {
578
+ this.removeAttribute('aria-busy');
579
+ if (animate && !this.reduced)
580
+ this.motion(this, [{ opacity: 0.4 }, { opacity: 1 }], { duration: 300, easing: 'ease-out' });
581
+ }
582
+ }
583
+ }, { id: 'auto-skeleton', text: css$2 });
584
+ }
585
+
586
+ var css$1 = "usa-motion-switch{--usa-motion-i:2;position:relative;display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;padding:3px;border-radius:999px;background:color-mix(in srgb,currentColor 9%,transparent);isolation:isolate}usa-motion-switch button{position:relative;z-index:1;padding:6px 12px;border:0;background:none;color:inherit;font:inherit;font-size:0.85em;border-radius:999px;cursor:pointer}usa-motion-switch button[aria-checked=\"true\"]{color:var(--usa-accent-text,#fff)}usa-motion-switch button:focus-visible{outline:2px solid var(--usa-accent,#7c5cff);outline-offset:1px}usa-motion-switch .usa-motion-thumb{position:absolute;z-index:0;top:3px;bottom:3px;left:3px;width:calc((100% - 6px) / 4);border-radius:999px;background:var(--usa-accent,#7c5cff);transform:translateX(calc(var(--usa-motion-i) * 100%));transition:transform 0.4s cubic-bezier(0.34,1.4,0.64,1)}@media (prefers-reduced-motion:reduce){usa-motion-switch .usa-motion-thumb{transition:none}}";
587
+
588
+ const LEVELS = ['off', 'low', 'normal', 'high'];
589
+ const KEY = 'usa:motion';
590
+ /**
591
+ * Set the global motion intensity for every `<usa-*>` component:
592
+ * `'off'` (like reduced motion), `'low'`, `'normal'` (default), `'high'`.
593
+ * Sets `--usa-motion` and `data-usa-motion` on `<html>`; with `persist`
594
+ * the choice is remembered (localStorage) and restored by `restoreMotionIntensity()`.
595
+ */
596
+ function setMotionIntensity(level, persist = false) {
597
+ if (!LEVELS.includes(level))
598
+ return;
599
+ configureComponents({ motionIntensity: level });
600
+ if (persist) {
601
+ try {
602
+ localStorage.setItem(KEY, level);
603
+ }
604
+ catch {
605
+ /* private mode */
606
+ }
607
+ }
608
+ if (typeof document !== 'undefined')
609
+ document.dispatchEvent(new CustomEvent('usa:motion', { detail: { level } }));
610
+ }
611
+ /** Re-apply a persisted intensity (call early on page load). Returns it. */
612
+ function restoreMotionIntensity() {
613
+ try {
614
+ const v = localStorage.getItem(KEY);
615
+ if (v && LEVELS.includes(v))
616
+ setMotionIntensity(v);
617
+ }
618
+ catch {
619
+ /* ignore */
620
+ }
621
+ return getMotionIntensity();
622
+ }
623
+ function defineMotionSwitch(tag = 'usa-motion-switch') {
624
+ return defineElement(tag, (Base) => class UsaMotionSwitch extends Base {
625
+ get value() {
626
+ return getMotionIntensity();
627
+ }
628
+ set value(v) {
629
+ setMotionIntensity(v, true);
630
+ this.sync();
631
+ }
632
+ mount() {
633
+ restoreMotionIntensity();
634
+ const labels = this.str('labels', 'Off,Low,Normal,High').split(',');
635
+ this.setAttribute('role', 'radiogroup');
636
+ this.setAttribute('aria-label', this.str('label', 'Motion'));
637
+ this.innerHTML = LEVELS.map((l, i) => `<button type="button" role="radio" data-level="${l}">${labels[i] || l}</button><span hidden></span>`.replace('<span hidden></span>', '')).join('') + '<span class="usa-motion-thumb" aria-hidden="true"></span>';
638
+ this.listen(this, 'click', (e) => {
639
+ const b = e.target.closest?.('[data-level]');
640
+ if (b)
641
+ this.pick(b.dataset.level);
642
+ });
643
+ this.listen(this, 'keydown', (e) => {
644
+ const i = LEVELS.indexOf(this.value);
645
+ const n = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? i + 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? i - 1 : null;
646
+ if (n === null)
647
+ return;
648
+ e.preventDefault();
649
+ this.pick(LEVELS[(n + LEVELS.length) % LEVELS.length]);
650
+ this.querySelector('[aria-checked="true"]')?.focus();
651
+ });
652
+ this.listen(document, 'usa:motion', () => this.sync());
653
+ this.sync();
654
+ }
655
+ pick(l) {
656
+ this.value = l;
657
+ this.emit('change', { level: l });
658
+ }
659
+ sync() {
660
+ const v = this.value;
661
+ const i = LEVELS.indexOf(v);
662
+ this.style.setProperty('--usa-motion-i', String(i));
663
+ this.querySelectorAll('[data-level]').forEach((b) => {
664
+ const on = b.dataset.level === v;
665
+ b.setAttribute('aria-checked', String(on));
666
+ b.tabIndex = on ? 0 : -1;
667
+ });
668
+ }
669
+ }, { id: 'motion-switch', text: css$1 });
670
+ }
671
+
672
+ var css = "::view-transition-group(root){animation-duration:var(--usa-pt-duration,600ms)}html[data-usa-pt] ::view-transition-old(root),html[data-usa-pt] ::view-transition-new(root){animation-duration:var(--usa-pt-duration,600ms);animation-timing-function:cubic-bezier(0.22,1,0.36,1);mix-blend-mode:normal}html[data-usa-pt=\"slide\"] ::view-transition-old(root),html[data-usa-pt=\"slide-left\"] ::view-transition-old(root){animation-name:usa-pt-out-left}html[data-usa-pt=\"slide\"] ::view-transition-new(root),html[data-usa-pt=\"slide-left\"] ::view-transition-new(root){animation-name:usa-pt-in-right}html[data-usa-pt=\"slide-right\"] ::view-transition-old(root){animation-name:usa-pt-out-right}html[data-usa-pt=\"slide-right\"] ::view-transition-new(root){animation-name:usa-pt-in-left}html[data-usa-pt=\"slide-up\"] ::view-transition-old(root){animation-name:usa-pt-out-up}html[data-usa-pt=\"slide-up\"] ::view-transition-new(root){animation-name:usa-pt-in-up}html[data-usa-pt=\"zoom\"] ::view-transition-old(root){animation-name:usa-pt-zoom-out}html[data-usa-pt=\"zoom\"] ::view-transition-new(root){animation-name:usa-pt-zoom-in}html[data-usa-pt=\"circle\"] ::view-transition-old(root){animation:none}html[data-usa-pt=\"circle\"] ::view-transition-new(root){animation-name:usa-pt-circle}html[data-usa-pt=\"blinds\"] ::view-transition-old(root){animation:none}html[data-usa-pt=\"blinds\"] ::view-transition-new(root){animation-name:usa-pt-blinds;-webkit-mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh);mask-image:repeating-linear-gradient(to bottom,#000 0 var(--usa-blind),transparent var(--usa-blind) 10vh)}html[data-usa-pt=\"pixel\"] ::view-transition-old(root){animation-name:usa-pt-pixel-out;animation-timing-function:steps(10,end)}html[data-usa-pt=\"pixel\"] ::view-transition-new(root){animation-name:usa-pt-pixel-in;animation-timing-function:steps(10,end)}@property --usa-blind{syntax:\"<length-percentage>\";inherits:false;initial-value:0vh}@keyframes usa-pt-out-left{to{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-in-right{from{transform:translateX(30%);opacity:0}}@keyframes usa-pt-out-right{to{transform:translateX(30%);opacity:0}}@keyframes usa-pt-in-left{from{transform:translateX(-30%);opacity:0}}@keyframes usa-pt-out-up{to{transform:translateY(-12%);opacity:0}}@keyframes usa-pt-in-up{from{transform:translateY(12%);opacity:0}}@keyframes usa-pt-zoom-out{to{transform:scale(0.92);opacity:0}}@keyframes usa-pt-zoom-in{from{transform:scale(1.08);opacity:0}}@keyframes usa-pt-circle{from{clip-path:circle(0 at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}to{clip-path:circle(var(--usa-pt-r,150vmax) at var(--usa-pt-x,50%) var(--usa-pt-y,50%))}}@keyframes usa-pt-blinds{from{--usa-blind:0vh}to{--usa-blind:10vh}}@keyframes usa-pt-pixel-out{to{opacity:0;filter:blur(6px) contrast(1.4)}}@keyframes usa-pt-pixel-in{from{opacity:0;filter:blur(6px) contrast(1.4)}}@media (prefers-reduced-motion:reduce){::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none !important}}";
673
+
674
+ /**
675
+ * Page & app-wide transitions (v2.7), built on the View Transitions API
676
+ * (Chromium: Chrome, Edge, Electron, WebView2) with graceful fallbacks.
677
+ *
678
+ * - `pageTransition(update, { effect })` — SPA route changes: `fade`,
679
+ * `slide` (`slide-left` / `slide-right` / `slide-up`), `circle` (reveal
680
+ * from `x`, `y`), `blinds`, `pixel` (stepped dissolve), `zoom`.
681
+ * - `enableMpaTransitions(effect)` — the same effects for multi-page sites
682
+ * (`@view-transition { navigation: auto }`); call it on every page.
683
+ * - `themeTransition(apply, { x, y })` — a circle-reveal theme switch.
684
+ *
685
+ * Without View Transitions (Firefox, older Safari) or under reduced motion
686
+ * the update runs immediately (`fade` falls back to a short cross-fade of
687
+ * `fallback` when given).
688
+ */
689
+ const PAGE_EFFECTS = ['fade', 'slide', 'slide-left', 'slide-right', 'slide-up', 'circle', 'blinds', 'pixel', 'zoom'];
690
+ let lastPointer = null;
691
+ function trackPointer() {
692
+ if (typeof document === 'undefined' || trackPointer.done)
693
+ return;
694
+ trackPointer.done = true;
695
+ document.addEventListener('pointerdown', (e) => (lastPointer = [e.clientX, e.clientY]), { capture: true, passive: true });
696
+ }
697
+ /** `true` when `document.startViewTransition` exists. */
698
+ const supportsViewTransitions = () => typeof document !== 'undefined' && typeof document.startViewTransition === 'function';
699
+ function setVars(o) {
700
+ const d = document.documentElement;
701
+ const W = window.innerWidth || 1024;
702
+ const H = window.innerHeight || 768;
703
+ const [x, y] = o.x !== undefined && o.y !== undefined ? [o.x, o.y] : lastPointer || [W / 2, H / 2];
704
+ const r = Math.hypot(Math.max(x, W - x), Math.max(y, H - y));
705
+ d.style.setProperty('--usa-pt-x', `${x}px`);
706
+ d.style.setProperty('--usa-pt-y', `${y}px`);
707
+ d.style.setProperty('--usa-pt-r', `${Math.ceil(r)}px`);
708
+ d.style.setProperty('--usa-pt-duration', `${o.duration ?? 600}ms`);
709
+ }
710
+ /** Run `update` (sync or async) as an animated page transition. Resolves when it is done. */
711
+ async function pageTransition(update, options = {}) {
712
+ if (typeof document === 'undefined') {
713
+ await update();
714
+ return;
715
+ }
716
+ adoptStyles('page-transitions', css);
717
+ trackPointer();
718
+ const effect = options.effect || 'fade';
719
+ if (prefersReducedMotion() || !supportsViewTransitions()) {
720
+ await update();
721
+ const f = options.fallback;
722
+ if (f && typeof f.animate === 'function' && !prefersReducedMotion())
723
+ await f.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 200 }).finished.catch(() => undefined);
724
+ return;
725
+ }
726
+ const d = document.documentElement;
727
+ setVars(options);
728
+ d.setAttribute('data-usa-pt', effect);
729
+ try {
730
+ const vt = document.startViewTransition(() => update());
731
+ await vt.finished;
732
+ }
733
+ finally {
734
+ d.removeAttribute('data-usa-pt');
735
+ }
736
+ }
737
+ /** Opt a multi-page site into cross-document view transitions with `effect`. */
738
+ function enableMpaTransitions(effect = 'fade', duration = 450) {
739
+ if (typeof document === 'undefined')
740
+ return;
741
+ adoptStyles('page-transitions', css);
742
+ adoptStyles('mpa-transitions', prefersReducedMotion() ? '' : '@view-transition{navigation:auto}');
743
+ const d = document.documentElement;
744
+ d.setAttribute('data-usa-pt', effect);
745
+ setVars({ duration });
746
+ }
747
+ /**
748
+ * Switch theme with a circle reveal from (`x`, `y`) (default: last pointer).
749
+ * `apply` flips your theme (e.g. toggles a class / `data-theme`).
750
+ */
751
+ function themeTransition(apply, options = {}) {
752
+ return pageTransition(apply, { ...options, effect: 'circle', duration: options.duration ?? 650 });
753
+ }
754
+
755
+ /**
756
+ * use-scroll-animate/components/page — page & app-wide effects (v2.7).
757
+ * Page transitions (`pageTransition()`, `enableMpaTransitions()`,
758
+ * `themeTransition()`), `<usa-cursor>`, `smoothScroll()` / `scrollToTarget()`,
759
+ * `<usa-fullpage>`, `<usa-loading-bar>` + `loadingBar`, `<usa-back-to-top>`,
760
+ * `<usa-ambient>`, `<usa-splash>`, `<usa-auto-skeleton>` and the global motion
761
+ * intensity (`setMotionIntensity()`, `<usa-motion-switch>`).
762
+ */
763
+ /** Register every component of this category under its default tag. */
764
+ function definePageComponents() {
765
+ defineCursor();
766
+ defineFullpage();
767
+ defineLoadingBar();
768
+ defineBackToTop();
769
+ defineAmbient();
770
+ defineSplash();
771
+ defineAutoSkeleton();
772
+ defineMotionSwitch();
773
+ }
774
+
775
+ export { AMBIENT_EFFECTS, CURSOR_MODES, PAGE_EFFECTS, configureComponents, defineAmbient, defineAutoSkeleton, defineBackToTop, defineCursor, defineFullpage, defineLoadingBar, defineMotionSwitch, definePageComponents, defineSplash, enableMpaTransitions, getMotionIntensity, loadingBar, pageTransition, prefersReducedMotion, restoreMotionIntensity, scrollToTarget, setMotionIntensity, smoothScroll, supportsViewTransitions, themeTransition };
776
+ //# sourceMappingURL=page.js.map