@wix/interact 2.0.3 → 2.0.4

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 (38) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/react.js +1 -1
  3. package/dist/cjs/web.js +1 -1
  4. package/dist/es/index.js +1 -1
  5. package/dist/es/react.js +2 -2
  6. package/dist/es/web.js +2 -2
  7. package/dist/index-BZL18ynN.mjs +2750 -0
  8. package/dist/index-BZL18ynN.mjs.map +1 -0
  9. package/dist/index-IaOsZpFD.js +18 -0
  10. package/dist/index-IaOsZpFD.js.map +1 -0
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/dist/types/core/Interact.d.ts +9 -1
  13. package/dist/types/core/Interact.d.ts.map +1 -1
  14. package/dist/types/core/add.d.ts.map +1 -1
  15. package/dist/types/handlers/animationEnd.d.ts +1 -1
  16. package/dist/types/handlers/animationEnd.d.ts.map +1 -1
  17. package/dist/types/handlers/effectHandlers.d.ts +2 -1
  18. package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
  19. package/dist/types/handlers/eventTrigger.d.ts +1 -1
  20. package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
  21. package/dist/types/handlers/viewEnter.d.ts +1 -1
  22. package/dist/types/handlers/viewEnter.d.ts.map +1 -1
  23. package/dist/types/types.d.ts +29 -2
  24. package/dist/types/types.d.ts.map +1 -1
  25. package/package.json +2 -2
  26. package/rules/MASTER-CLEANUP-PLAN.md +286 -0
  27. package/rules/click.md +12 -31
  28. package/rules/full-lean.md +26 -4
  29. package/rules/hover.md +68 -153
  30. package/rules/integration.md +17 -85
  31. package/rules/pointermove.md +32 -57
  32. package/rules/scroll-list.md +82 -280
  33. package/rules/viewenter.md +65 -90
  34. package/rules/viewprogress.md +139 -845
  35. package/dist/index-BfcN_rkn.mjs +0 -2338
  36. package/dist/index-BfcN_rkn.mjs.map +0 -1
  37. package/dist/index-HXLBEIjG.js +0 -18
  38. package/dist/index-HXLBEIjG.js.map +0 -1
@@ -1,2338 +0,0 @@
1
- function Be(e) {
2
- return [...e.matchAll(/\[([-\w]+)]/g)].map(([t, n]) => n);
3
- }
4
- function R(e, t) {
5
- const n = Be(t);
6
- let s = 0;
7
- return n.length ? e.replace(/\[]/g, () => {
8
- const r = n[s++];
9
- return r !== void 0 ? `[${r}]` : "[]";
10
- }) : e;
11
- }
12
- class ue {
13
- animations;
14
- options;
15
- ready;
16
- isCSS;
17
- constructor(t, n) {
18
- this.animations = t, this.options = n, this.ready = n?.measured || Promise.resolve(), this.isCSS = t[0] instanceof CSSAnimation;
19
- }
20
- getProgress() {
21
- return this.animations[0]?.effect?.getComputedTiming().progress || 0;
22
- }
23
- async play(t) {
24
- await this.ready;
25
- for (const n of this.animations)
26
- n.play();
27
- await Promise.all(this.animations.map((n) => n.ready)), t && t();
28
- }
29
- pause() {
30
- for (const t of this.animations)
31
- t.pause();
32
- }
33
- async reverse(t) {
34
- await this.ready;
35
- for (const n of this.animations)
36
- n.reverse();
37
- await Promise.all(this.animations.map((n) => n.ready)), t && t();
38
- }
39
- progress(t) {
40
- for (const n of this.animations) {
41
- const { delay: s, duration: r, iterations: i } = n.effect.getTiming(), o = (Number.isFinite(r) ? r : 0) * (Number.isFinite(i) ? i : 1);
42
- n.currentTime = ((s || 0) + o) * t;
43
- }
44
- }
45
- cancel() {
46
- for (const t of this.animations)
47
- t.cancel();
48
- }
49
- setPlaybackRate(t) {
50
- for (const n of this.animations)
51
- n.playbackRate = t;
52
- }
53
- async onFinish(t) {
54
- try {
55
- await Promise.all(this.animations.map((s) => s.finished));
56
- const n = this.animations[0];
57
- if (n && !this.isCSS) {
58
- const s = n.effect?.target;
59
- if (s) {
60
- const r = new Event("animationend");
61
- s.dispatchEvent(r);
62
- }
63
- }
64
- t();
65
- } catch (n) {
66
- console.warn("animation was interrupted - aborting onFinish callback - ", n);
67
- }
68
- }
69
- get finished() {
70
- return Promise.all(this.animations.map((t) => t.finished));
71
- }
72
- get playState() {
73
- return this.animations[0]?.playState;
74
- }
75
- }
76
- const Qe = (e) => e, Xe = (e) => 1 - Math.cos(e * Math.PI / 2), Ue = (e) => Math.sin(e * Math.PI / 2), Je = (e) => -(Math.cos(Math.PI * e) - 1) / 2, Ze = (e) => e ** 2, et = (e) => 1 - (1 - e) ** 2, tt = (e) => e < 0.5 ? 2 * e ** 2 : 1 - (-2 * e + 2) ** 2 / 2, nt = (e) => e ** 3, st = (e) => 1 - (1 - e) ** 3, it = (e) => e < 0.5 ? 4 * e ** 3 : 1 - (-2 * e + 2) ** 3 / 2, rt = (e) => e ** 4, ot = (e) => 1 - (1 - e) ** 4, ct = (e) => e < 0.5 ? 8 * e ** 4 : 1 - (-2 * e + 2) ** 4 / 2, at = (e) => e ** 5, ft = (e) => 1 - (1 - e) ** 5, lt = (e) => e < 0.5 ? 16 * e ** 5 : 1 - (-2 * e + 2) ** 5 / 2, ut = (e) => e === 0 ? 0 : 2 ** (10 * e - 10), dt = (e) => e === 1 ? 1 : 1 - 2 ** (-10 * e), ht = (e) => e === 0 ? 0 : e === 1 ? 1 : e < 0.5 ? 2 ** (20 * e - 10) / 2 : (2 - 2 ** (-20 * e + 10)) / 2, mt = (e) => 1 - Math.sqrt(1 - e ** 2), gt = (e) => Math.sqrt(1 - (e - 1) ** 2), vt = (e) => e < 0.5 ? (1 - Math.sqrt(1 - 4 * e ** 2)) / 2 : (Math.sqrt(-(2 * e - 3) * (2 * e - 1)) + 1) / 2, pt = (e) => 2.70158 * e ** 3 - 1.70158 * e ** 2, yt = (e) => 1 + 2.70158 * (e - 1) ** 3 + 1.70158 * (e - 1) ** 2, Et = (e, t = 1.70158 * 1.525) => e < 0.5 ? (2 * e) ** 2 * ((t + 1) * 2 * e - t) / 2 : ((2 * e - 2) ** 2 * ((t + 1) * (e * 2 - 2) + t) + 2) / 2, wt = {
77
- linear: Qe,
78
- sineIn: Xe,
79
- sineOut: Ue,
80
- sineInOut: Je,
81
- quadIn: Ze,
82
- quadOut: et,
83
- quadInOut: tt,
84
- cubicIn: nt,
85
- cubicOut: st,
86
- cubicInOut: it,
87
- quartIn: rt,
88
- quartOut: ot,
89
- quartInOut: ct,
90
- quintIn: at,
91
- quintOut: ft,
92
- quintInOut: lt,
93
- expoIn: ut,
94
- expoOut: dt,
95
- expoInOut: ht,
96
- circIn: mt,
97
- circOut: gt,
98
- circInOut: vt,
99
- backIn: pt,
100
- backOut: yt,
101
- backInOut: Et
102
- }, ve = {
103
- linear: "linear",
104
- ease: "ease",
105
- easeIn: "ease-in",
106
- easeOut: "ease-out",
107
- easeInOut: "ease-in-out",
108
- sineIn: "cubic-bezier(0.47, 0, 0.745, 0.715)",
109
- sineOut: "cubic-bezier(0.39, 0.575, 0.565, 1)",
110
- sineInOut: "cubic-bezier(0.445, 0.05, 0.55, 0.95)",
111
- quadIn: "cubic-bezier(0.55, 0.085, 0.68, 0.53)",
112
- quadOut: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
113
- quadInOut: "cubic-bezier(0.455, 0.03, 0.515, 0.955)",
114
- cubicIn: "cubic-bezier(0.55, 0.055, 0.675, 0.19)",
115
- cubicOut: "cubic-bezier(0.215, 0.61, 0.355, 1)",
116
- cubicInOut: "cubic-bezier(0.645, 0.045, 0.355, 1)",
117
- quartIn: "cubic-bezier(0.895, 0.03, 0.685, 0.22)",
118
- quartOut: "cubic-bezier(0.165, 0.84, 0.44, 1)",
119
- quartInOut: "cubic-bezier(0.77, 0, 0.175, 1)",
120
- quintIn: "cubic-bezier(0.755, 0.05, 0.855, 0.06)",
121
- quintOut: "cubic-bezier(0.23, 1, 0.32, 1)",
122
- quintInOut: "cubic-bezier(0.86, 0, 0.07, 1)",
123
- expoIn: "cubic-bezier(0.95, 0.05, 0.795, 0.035)",
124
- expoOut: "cubic-bezier(0.19, 1, 0.22, 1)",
125
- expoInOut: "cubic-bezier(1, 0, 0, 1)",
126
- circIn: "cubic-bezier(0.6, 0.04, 0.98, 0.335)",
127
- circOut: "cubic-bezier(0.075, 0.82, 0.165, 1)",
128
- circInOut: "cubic-bezier(0.785, 0.135, 0.15, 0.86)",
129
- backIn: "cubic-bezier(0.6, -0.28, 0.735, 0.045)",
130
- backOut: "cubic-bezier(0.175, 0.885, 0.32, 1.275)",
131
- backInOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
132
- };
133
- function bt(e) {
134
- return e === "percentage" ? "%" : e || "px";
135
- }
136
- function D(e) {
137
- return e ? ve[e] || e : ve.linear;
138
- }
139
- function St(e) {
140
- return e ? wt[e] : void 0;
141
- }
142
- class Tt {
143
- _animation;
144
- customEffect;
145
- progress;
146
- _tickCbId;
147
- _finishHandler;
148
- constructor(t, n, s, r) {
149
- const i = new KeyframeEffect(n, [], {
150
- ...s,
151
- composite: "add"
152
- }), { timeline: o } = r;
153
- this._animation = new Animation(i, o), this._tickCbId = null, this.progress = null, this.customEffect = (c) => t(i.target, c), this._finishHandler = (c) => {
154
- this.effect.target?.getAnimations().find((u) => u === this._animation) || this.cancel();
155
- }, this.addEventListener("finish", this._finishHandler), this.addEventListener("remove", this._finishHandler);
156
- }
157
- // private tick method for customEffect loop implementation
158
- _tick() {
159
- try {
160
- const t = this.effect?.getComputedTiming().progress ?? null;
161
- t !== this.progress && (this.customEffect?.(t), this.progress = t), this._tickCbId = requestAnimationFrame(() => {
162
- this._tick();
163
- });
164
- } catch (t) {
165
- this._tickCbId = null, console.error(
166
- `failed to run customEffect! effectId: ${this.id}, error: ${t instanceof Error ? t.message : t}`
167
- );
168
- }
169
- }
170
- // Animation timing properties
171
- get currentTime() {
172
- return this._animation.currentTime;
173
- }
174
- set currentTime(t) {
175
- this._animation.currentTime = t;
176
- }
177
- get startTime() {
178
- return this._animation.startTime;
179
- }
180
- set startTime(t) {
181
- this._animation.startTime = t;
182
- }
183
- get playbackRate() {
184
- return this._animation.playbackRate;
185
- }
186
- set playbackRate(t) {
187
- this._animation.playbackRate = t;
188
- }
189
- // Animation basic properties
190
- get id() {
191
- return this._animation.id;
192
- }
193
- set id(t) {
194
- this._animation.id = t;
195
- }
196
- get effect() {
197
- return this._animation.effect;
198
- }
199
- set effect(t) {
200
- this._animation.effect = t;
201
- }
202
- get timeline() {
203
- return this._animation.timeline;
204
- }
205
- set timeline(t) {
206
- this._animation.timeline = t;
207
- }
208
- // Animation readonly state properties
209
- get finished() {
210
- return this._animation.finished;
211
- }
212
- get pending() {
213
- return this._animation.pending;
214
- }
215
- get playState() {
216
- return this._animation.playState;
217
- }
218
- get ready() {
219
- return this._animation.ready;
220
- }
221
- get replaceState() {
222
- return this._animation.replaceState;
223
- }
224
- // Animation event handlers
225
- get oncancel() {
226
- return this._animation.oncancel;
227
- }
228
- set oncancel(t) {
229
- this._animation.oncancel = t;
230
- }
231
- get onfinish() {
232
- return this._animation.onfinish;
233
- }
234
- set onfinish(t) {
235
- this._animation.onfinish = t;
236
- }
237
- get onremove() {
238
- return this._animation.onremove;
239
- }
240
- set onremove(t) {
241
- this._animation.onremove = t;
242
- }
243
- // CustomAnimation overridden methods
244
- play() {
245
- this._animation.play(), cancelAnimationFrame(this._tickCbId), this._tickCbId = requestAnimationFrame(() => this._tick());
246
- }
247
- pause() {
248
- this._animation.pause(), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
249
- }
250
- cancel() {
251
- this.removeEventListener("finish", this._finishHandler), this.removeEventListener("remove", this._finishHandler), this._animation.cancel(), this.customEffect(null), cancelAnimationFrame(this._tickCbId), this._tickCbId = null;
252
- }
253
- commitStyles() {
254
- console.warn(
255
- "CustomEffect animations do not support commitStyles method as they have no style to commit"
256
- );
257
- }
258
- // Animation methods without override
259
- finish() {
260
- this._animation.finish();
261
- }
262
- persist() {
263
- this._animation.persist();
264
- }
265
- reverse() {
266
- this._animation.reverse();
267
- }
268
- updatePlaybackRate(t) {
269
- this._animation.updatePlaybackRate(t);
270
- }
271
- // Animation events API
272
- addEventListener(t, n, s) {
273
- this._animation.addEventListener(t, n, s);
274
- }
275
- removeEventListener(t, n, s) {
276
- this._animation.removeEventListener(t, n, s);
277
- }
278
- dispatchEvent(t) {
279
- return this._animation.dispatchEvent(t);
280
- }
281
- }
282
- function It(e) {
283
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
284
- }
285
- var W = { exports: {} }, pe = W.exports, ye;
286
- function Ot() {
287
- return ye || (ye = 1, (function(e) {
288
- (function(t) {
289
- var n = function() {
290
- }, s = t.requestAnimationFrame || t.webkitRequestAnimationFrame || t.mozRequestAnimationFrame || t.msRequestAnimationFrame || function(a) {
291
- return setTimeout(a, 16);
292
- };
293
- function r() {
294
- var a = this;
295
- a.reads = [], a.writes = [], a.raf = s.bind(t);
296
- }
297
- r.prototype = {
298
- constructor: r,
299
- /**
300
- * We run this inside a try catch
301
- * so that if any jobs error, we
302
- * are able to recover and continue
303
- * to flush the batch until it's empty.
304
- *
305
- * @param {Array} tasks
306
- */
307
- runTasks: function(a) {
308
- for (var f; f = a.shift(); ) f();
309
- },
310
- /**
311
- * Adds a job to the read batch and
312
- * schedules a new frame if need be.
313
- *
314
- * @param {Function} fn
315
- * @param {Object} ctx the context to be bound to `fn` (optional).
316
- * @public
317
- */
318
- measure: function(a, f) {
319
- var d = f ? a.bind(f) : a;
320
- return this.reads.push(d), i(this), d;
321
- },
322
- /**
323
- * Adds a job to the
324
- * write batch and schedules
325
- * a new frame if need be.
326
- *
327
- * @param {Function} fn
328
- * @param {Object} ctx the context to be bound to `fn` (optional).
329
- * @public
330
- */
331
- mutate: function(a, f) {
332
- var d = f ? a.bind(f) : a;
333
- return this.writes.push(d), i(this), d;
334
- },
335
- /**
336
- * Clears a scheduled 'read' or 'write' task.
337
- *
338
- * @param {Object} task
339
- * @return {Boolean} success
340
- * @public
341
- */
342
- clear: function(a) {
343
- return c(this.reads, a) || c(this.writes, a);
344
- },
345
- /**
346
- * Extend this FastDom with some
347
- * custom functionality.
348
- *
349
- * Because fastdom must *always* be a
350
- * singleton, we're actually extending
351
- * the fastdom instance. This means tasks
352
- * scheduled by an extension still enter
353
- * fastdom's global task queue.
354
- *
355
- * The 'super' instance can be accessed
356
- * from `this.fastdom`.
357
- *
358
- * @example
359
- *
360
- * var myFastdom = fastdom.extend({
361
- * initialize: function() {
362
- * // runs on creation
363
- * },
364
- *
365
- * // override a method
366
- * measure: function(fn) {
367
- * // do extra stuff ...
368
- *
369
- * // then call the original
370
- * return this.fastdom.measure(fn);
371
- * },
372
- *
373
- * ...
374
- * });
375
- *
376
- * @param {Object} props properties to mixin
377
- * @return {FastDom}
378
- */
379
- extend: function(a) {
380
- if (typeof a != "object") throw new Error("expected object");
381
- var f = Object.create(this);
382
- return u(f, a), f.fastdom = this, f.initialize && f.initialize(), f;
383
- },
384
- // override this with a function
385
- // to prevent Errors in console
386
- // when tasks throw
387
- catch: null
388
- };
389
- function i(a) {
390
- a.scheduled || (a.scheduled = !0, a.raf(o.bind(null, a)));
391
- }
392
- function o(a) {
393
- var f = a.writes, d = a.reads, v;
394
- try {
395
- n("flushing reads", d.length), a.runTasks(d), n("flushing writes", f.length), a.runTasks(f);
396
- } catch (m) {
397
- v = m;
398
- }
399
- if (a.scheduled = !1, (d.length || f.length) && i(a), v)
400
- if (n("task errored", v.message), a.catch) a.catch(v);
401
- else throw v;
402
- }
403
- function c(a, f) {
404
- var d = a.indexOf(f);
405
- return !!~d && !!a.splice(d, 1);
406
- }
407
- function u(a, f) {
408
- for (var d in f)
409
- f.hasOwnProperty(d) && (a[d] = f[d]);
410
- }
411
- var l = t.fastdom = t.fastdom || new r();
412
- e.exports = l;
413
- })(typeof window < "u" ? window : typeof pe < "u" ? pe : globalThis);
414
- })(W)), W.exports;
415
- }
416
- var _t = Ot();
417
- const S = /* @__PURE__ */ It(_t), re = {};
418
- function kt(e) {
419
- Object.assign(re, e);
420
- }
421
- function Ct(e) {
422
- return e in re ? re[e] : (console.warn(
423
- `${e} not found in registry. Please make sure to import and register the preset.`
424
- ), null);
425
- }
426
- function k(e, t) {
427
- return e ? document.getElementById(e) : null;
428
- }
429
- function xt(e, t) {
430
- return e?.matches(`[data-motion-part~="${t}"]`) ? e : e?.querySelector(`[data-motion-part~="${t}"]`);
431
- }
432
- function At(e) {
433
- const t = e.alternate ? "alternate" : "";
434
- return e.reversed ? `${t ? `${t}-` : ""}reverse` : t || "normal";
435
- }
436
- function ne(e) {
437
- return `${e.value}${bt(e.unit)}`;
438
- }
439
- function Ee(e, t, n) {
440
- return `${e.name || "cover"} ${n && e.offset.unit !== "percentage" ? `calc(100% + ${ne(e.offset)}${t ? ` + ${t}` : ""})` : t ? `calc(${ne(e.offset)} + ${t})` : ne(e.offset)}`;
441
- }
442
- function Lt(e) {
443
- return {
444
- start: Ee(e.startOffset, e.startOffsetAdd),
445
- end: Ee(e.endOffset, e.endOffsetAdd, !0)
446
- };
447
- }
448
- function Re(e) {
449
- return (t) => S.measure(() => t(e));
450
- }
451
- function $e(e) {
452
- return (t) => S.mutate(() => t(e));
453
- }
454
- function B(e) {
455
- if (e.namedEffect) {
456
- const t = e.namedEffect.type;
457
- return typeof t == "string" ? Ct(t) : null;
458
- } else if (e.keyframeEffect) {
459
- const t = (s) => {
460
- const { name: r, keyframes: i } = s.keyframeEffect;
461
- return [{ ...s, name: r, keyframes: i }];
462
- };
463
- return { web: t, style: t, getNames: (s) => {
464
- const { effectId: r } = s, { name: i } = s.keyframeEffect, o = i || r;
465
- return o ? [o] : [];
466
- } };
467
- } else if (e.customEffect)
468
- return (t) => [{ ...t, keyframes: [] }];
469
- return null;
470
- }
471
- function Pt(e, t, n) {
472
- return e.map((s, r) => {
473
- const i = {
474
- fill: s.fill,
475
- easing: D(s.easing),
476
- iterations: s.iterations === 0 ? 1 / 0 : s.iterations || 1,
477
- composite: s.composite,
478
- direction: At(s)
479
- };
480
- return Fe(t) ? (i.duration = s.duration, i.delay = s.delay || 0) : window.ViewTimeline && t?.trigger === "view-progress" ? i.duration = "auto" : (i.duration = 99.99, i.delay = 0.01), {
481
- effect: s,
482
- options: i,
483
- id: n && `${n}-${r + 1}`,
484
- part: s.part
485
- };
486
- });
487
- }
488
- function Fe(e) {
489
- return !e || e.trigger !== "pointer-move" && e.trigger !== "view-progress";
490
- }
491
- function we(e, t, n, s, r) {
492
- if (e) {
493
- if (Fe(s) && (t.duration = t.duration || 1, r?.reducedMotion))
494
- if (t.iterations === 1 || t.iterations == null)
495
- t = { ...t, duration: 1 };
496
- else
497
- return [];
498
- let i;
499
- return n instanceof HTMLElement && (i = { measure: Re(n), mutate: $e(n) }), e.web ? e.web(t, i, r) : e(t, i, r);
500
- }
501
- return [];
502
- }
503
- function de(e, t, n, s, r) {
504
- const i = e instanceof HTMLElement ? e : k(e);
505
- if (n?.trigger === "pointer-move" && !t.keyframeEffect) {
506
- let d = t;
507
- t.customEffect && (d = {
508
- ...t,
509
- namedEffect: { id: "", type: "CustomMouse" }
510
- });
511
- const v = B(
512
- d
513
- ), m = we(
514
- v,
515
- t,
516
- i,
517
- n,
518
- s
519
- );
520
- return typeof m != "function" ? null : m(i);
521
- }
522
- const o = B(t), c = we(
523
- o,
524
- t,
525
- i,
526
- n,
527
- s
528
- );
529
- if (!c || c.length === 0)
530
- return null;
531
- const u = Pt(c, n, t.effectId);
532
- let l;
533
- const a = n?.trigger === "view-progress";
534
- a && window.ViewTimeline && (l = new ViewTimeline({
535
- subject: n.element || k(n.componentId)
536
- }));
537
- const f = u.map(({ effect: d, options: v, id: m, part: h }) => {
538
- const g = h ? xt(i, h) : i, y = new KeyframeEffect(g || null, [], v);
539
- S.mutate(() => {
540
- "timing" in d && y.updateTiming(d.timing), y.setKeyframes(d.keyframes);
541
- });
542
- const p = a && l ? { timeline: l } : {}, w = typeof d.customEffect == "function" ? new Tt(
543
- d.customEffect,
544
- g || null,
545
- v,
546
- p
547
- ) : new Animation(y, p.timeline);
548
- if (a)
549
- if (l)
550
- S.mutate(() => {
551
- const { start: b, end: T } = Lt(d);
552
- w.rangeStart = b, w.rangeEnd = T, w.play();
553
- });
554
- else {
555
- const { startOffset: b, endOffset: T } = t;
556
- S.mutate(() => {
557
- const C = d.startOffset || b, Z = d.endOffset || T;
558
- Object.assign(w, {
559
- start: {
560
- name: C.name,
561
- offset: C.offset?.value,
562
- add: d.startOffsetAdd
563
- },
564
- end: {
565
- name: Z.name,
566
- offset: Z.offset?.value,
567
- add: d.endOffsetAdd
568
- }
569
- });
570
- });
571
- }
572
- return m && (w.id = m), w;
573
- });
574
- return new ue(f, {
575
- ...t,
576
- trigger: { ...n || {} },
577
- // make sure the group is ready after all animation targets are measured and mutated
578
- measured: new Promise((d) => S.mutate(d))
579
- });
580
- }
581
- function Rt(e, t, n) {
582
- const s = B(t), r = e instanceof HTMLElement ? e : k(e);
583
- if (s && s.prepare && r) {
584
- const i = { measure: Re(r), mutate: $e(r) };
585
- s.prepare(t, i);
586
- }
587
- n && S.mutate(n);
588
- }
589
- function $t(e, t) {
590
- const n = B(t);
591
- if (!n)
592
- return null;
593
- if (!n.style)
594
- return t.effectId && e ? Ft(e, t.effectId) : null;
595
- const s = n.getNames(t), i = (typeof e == "string" ? k(e) : e)?.getAnimations(), o = i?.map((u) => u.animationName) || [], c = [];
596
- return s.forEach((u) => {
597
- o.includes(u) && c.push(
598
- i?.find((l) => l.animationName === u)
599
- );
600
- }), c?.length ? new ue(c) : null;
601
- }
602
- function Ft(e, t) {
603
- const s = (typeof e == "string" ? k(e) : e)?.getAnimations().filter((r) => {
604
- const i = r.id || r.animationName;
605
- return i ? i.startsWith(t) : !0;
606
- });
607
- return s?.length ? new ue(s) : null;
608
- }
609
- function Me(e, t, n, s = {}) {
610
- const { disabled: r, allowActiveEvent: i, ...o } = s, c = de(e, t, n, o);
611
- if (!c)
612
- return null;
613
- let u = {};
614
- if (n.trigger === "view-progress" && !window.ViewTimeline) {
615
- const l = n.element || k(n.componentId), { ready: a } = c;
616
- return c.animations.map((f) => ({
617
- /* we use getters for start and end in order to access the animation's start and end
618
- only when initializing the scrub scene rather than immediately */
619
- get start() {
620
- return f.start;
621
- },
622
- get end() {
623
- return f.end;
624
- },
625
- viewSource: l,
626
- ready: a,
627
- getProgress() {
628
- return c.getProgress();
629
- },
630
- effect(d, v) {
631
- const { activeDuration: m } = f.effect.getComputedTiming(), { delay: h } = f.effect.getTiming();
632
- f.currentTime = ((h || 0) + (m || 0)) * v;
633
- },
634
- disabled: r,
635
- destroy() {
636
- f.cancel();
637
- }
638
- }));
639
- } else if (n.trigger === "pointer-move") {
640
- const l = t, { centeredToTarget: a, transitionDuration: f, transitionEasing: d } = l, v = n.axis;
641
- if (l.keyframeEffect) {
642
- const m = c;
643
- return m.animations?.length === 0 ? null : {
644
- target: void 0,
645
- centeredToTarget: a,
646
- ready: m.ready,
647
- _currentProgress: 0,
648
- getProgress() {
649
- return this._currentProgress;
650
- },
651
- effect(g, y) {
652
- const p = v === "x" ? y.x : y.y;
653
- this._currentProgress = p, m.progress(p);
654
- },
655
- disabled: r ?? !1,
656
- destroy() {
657
- m.cancel();
658
- }
659
- };
660
- }
661
- u = {
662
- centeredToTarget: a,
663
- allowActiveEvent: i
664
- }, t.customEffect && f && (u.transitionDuration = f, u.transitionEasing = St(d)), u.target = c.target;
665
- }
666
- return {
667
- ...u,
668
- getProgress() {
669
- return c.getProgress();
670
- },
671
- effect(l, a, f, d) {
672
- c.progress(
673
- f ? {
674
- // @ts-expect-error spread error on p
675
- ...a,
676
- v: f,
677
- active: d
678
- } : a
679
- );
680
- },
681
- disabled: r,
682
- destroy() {
683
- c.cancel();
684
- }
685
- };
686
- }
687
- function he(e, t, n, s = !1) {
688
- const r = $t(e, t);
689
- return r ? (r.ready = new Promise((i) => {
690
- Rt(e, t, i);
691
- }), r) : de(e, t, n, { reducedMotion: s });
692
- }
693
- function j(e, t) {
694
- return t.includes("&") ? t.replace(/&/g, e) : `${e}${t}`;
695
- }
696
- function Mt() {
697
- return "wi-12343210".replace(
698
- /\d/g,
699
- (e) => String.fromCharCode(
700
- (+e ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +e / 4) + 97
701
- )
702
- // 97 for "a"
703
- );
704
- }
705
- function qt({
706
- key: e,
707
- effectId: t,
708
- transition: n,
709
- properties: s,
710
- childSelector: r = "> :first-child",
711
- selectorCondition: i
712
- }) {
713
- let o = [];
714
- if (n?.styleProperties) {
715
- const { duration: m, easing: h, delay: g } = n;
716
- m && (n.styleProperties.some(
717
- (p) => p.name.startsWith("--")
718
- ) ? o = [
719
- `all ${m}ms ${D(h || "ease")}${g ? ` ${g}ms` : ""}`,
720
- "visibility 0s"
721
- ] : o = n.styleProperties.map(
722
- (p) => `${p.name} ${m}ms ${D(
723
- h || "ease"
724
- )}${g ? ` ${g}ms` : ""}`
725
- )), s = n.styleProperties;
726
- } else
727
- o = s?.filter((m) => m.duration).map(
728
- (m) => `${m.name} ${m.duration}ms ${D(m.easing) || "ease"}${m.delay ? ` ${m.delay}ms` : ""}`
729
- ) || [];
730
- const c = s?.map((m) => `${m.name}: ${m.value};`) || [], u = e.replace(/"/g, "'"), l = `:is(:state(${t}), :--${t}) ${r}`, a = `[data-interact-effect~="${t}"] ${r}`, f = i ? j(l, i) : l, d = i ? j(a, i) : a, v = [
731
- `${f},
732
- ${d} {
733
- ${c.join(`
734
- `)}
735
- }`
736
- ];
737
- if (o.length) {
738
- const m = `[data-interact-key="${u}"] ${r}`, h = i ? j(m, i) : m;
739
- v.push(`@media (prefers-reduced-motion: no-preference) { ${h} {
740
- transition: ${o.join(", ")};
741
- } }`);
742
- }
743
- return v;
744
- }
745
- function $(e, t) {
746
- const n = (e || []).filter((i) => t[i]?.type === "media" && t[i].predicate).map((i) => t[i].predicate).join(") and ("), s = n && `(${n})`;
747
- return s && window.matchMedia(s);
748
- }
749
- function Q(e, t) {
750
- for (const n of e || []) {
751
- const s = t[n];
752
- if (s?.type === "selector" && s.predicate)
753
- return s.predicate;
754
- }
755
- }
756
- const q = {
757
- rangeStart: { name: "cover", offset: { value: 0, unit: "percentage" } },
758
- rangeEnd: { name: "cover", offset: { value: 100, unit: "percentage" } }
759
- };
760
- function Ht(e, t) {
761
- const n = e?.name ?? q.rangeStart.name, s = t?.name ?? e?.name ?? q.rangeEnd.name, r = {
762
- name: n,
763
- offset: e?.offset || q.rangeStart.offset
764
- }, i = {
765
- name: s,
766
- offset: t?.offset || q.rangeEnd.offset
767
- };
768
- return { startOffset: r, endOffset: i };
769
- }
770
- function F(e) {
771
- if ("keyframeEffect" in e && !e.keyframeEffect.name && "effectId" in e && (e.keyframeEffect.name = e.effectId), "duration" in e)
772
- return {
773
- id: "",
774
- ...e
775
- };
776
- const { rangeStart: t, rangeEnd: n, ...s } = e, { startOffset: r, endOffset: i } = Ht(t, n);
777
- return {
778
- id: "",
779
- startOffset: r,
780
- endOffset: i,
781
- ...s
782
- };
783
- }
784
- function I(e, t, n) {
785
- let s = e.get(t);
786
- s || (s = /* @__PURE__ */ new Set(), e.set(t, s)), s.add(n);
787
- }
788
- function M(e, t) {
789
- e.get(t)?.forEach((s) => {
790
- const { source: r, target: i, cleanup: o } = s;
791
- o();
792
- const c = r === t ? i : r;
793
- e.get(c)?.delete(s);
794
- }), e.delete(t);
795
- }
796
- const zt = {
797
- root: null,
798
- rootMargin: "0px 0px -10% 0px",
799
- threshold: [0]
800
- }, Nt = {
801
- root: null,
802
- rootMargin: "0px",
803
- threshold: [0]
804
- }, L = {}, X = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakSet(), G = /* @__PURE__ */ new WeakMap();
805
- let qe = {}, x = null;
806
- function Vt(e) {
807
- qe = e;
808
- }
809
- function He(e, t) {
810
- X.get(e)?.forEach(({ source: s, handler: r }) => {
811
- s === e && r(t);
812
- });
813
- }
814
- function be() {
815
- return x || (x = new IntersectionObserver((e) => {
816
- e.forEach((t) => {
817
- const n = t.target;
818
- t.isIntersecting || He(n, !1);
819
- });
820
- }, Nt), x);
821
- }
822
- function ze(e, t = !1) {
823
- const n = JSON.stringify({ ...e, isSafeMode: t });
824
- if (L[n])
825
- return L[n];
826
- const s = t ? zt : {
827
- root: null,
828
- rootMargin: e.inset ? `${e.inset} 0px ${e.inset}` : "0px",
829
- threshold: e.threshold
830
- }, r = new IntersectionObserver((i) => {
831
- i.forEach((o) => {
832
- const c = o.target, u = !Y.has(c);
833
- if (u && (Y.add(c), e.useSafeViewEnter && !o.isIntersecting)) {
834
- S.measure(() => {
835
- const a = o.boundingClientRect.height, f = o.rootBounds?.height;
836
- if (!f)
837
- return;
838
- const d = Array.isArray(e.threshold) ? Math.min(...e.threshold) : e.threshold;
839
- d && a * d > f && S.mutate(() => {
840
- r.unobserve(c);
841
- const m = ze(e, !0);
842
- G.set(c, m), m.observe(c);
843
- });
844
- });
845
- return;
846
- }
847
- const l = e.type || "once";
848
- (o.isIntersecting || l === "alternate" && !u) && (He(c, o.isIntersecting), l === "once" && (r.unobserve(o.target), Y.delete(c)));
849
- });
850
- }, s);
851
- return L[n] = r, r;
852
- }
853
- function Dt(e, t, n, s = {}, { reducedMotion: r, selectorCondition: i } = {}) {
854
- const o = { ...qe, ...s }, c = o.type || "once", u = he(
855
- t,
856
- F(n),
857
- void 0,
858
- r
859
- );
860
- if (!u)
861
- return;
862
- const l = ze(o);
863
- c !== "once" && u.persist?.();
864
- let a = !0;
865
- const v = { source: e, target: t, handler: (m) => {
866
- i && !t.matches(i) || (c === "once" ? m && u.play(() => {
867
- const h = () => {
868
- t.dataset.interactEnter = "start";
869
- };
870
- u.isCSS ? (S.mutate(() => {
871
- requestAnimationFrame(h);
872
- }), u.onFinish(() => {
873
- S.mutate(() => {
874
- t.dataset.interactEnter = "done";
875
- });
876
- })) : S.mutate(h);
877
- }) : c === "alternate" ? a && m ? (a = !1, u.play()) : a || u.reverse() : c === "repeat" ? m ? (u.progress(0), u.play()) : (u.pause(), u.progress(0)) : c === "state" && (m ? u.play() : u.pause()));
878
- }, cleanup: () => {
879
- (G.get(e) || l).unobserve(e), (c === "repeat" || c === "state") && be().unobserve(e), u.cancel(), Y.delete(e), G.delete(e);
880
- } };
881
- I(X, e, v), I(X, t, v), G.set(e, l), l.observe(e), (c === "repeat" || c === "state") && be().observe(e);
882
- }
883
- function Wt(e) {
884
- M(X, e);
885
- }
886
- function jt() {
887
- x = null, Object.keys(L).forEach((e) => delete L[e]);
888
- }
889
- const Se = {
890
- add: Dt,
891
- remove: Wt,
892
- setOptions: Vt,
893
- reset: jt
894
- };
895
- function Ne(e, t) {
896
- return Object.assign(Object.create(t), e);
897
- }
898
- function Yt(e, t, n, s) {
899
- let r = e * (1 - n) + t * n;
900
- if (s) {
901
- const i = r - e;
902
- Math.abs(i) < s && (r = e + s * Math.sign(i));
903
- const o = t - r;
904
- if (Math.abs(o) < s)
905
- return t;
906
- }
907
- return r;
908
- }
909
- function Gt(e) {
910
- let t = !1;
911
- return function() {
912
- t || (t = !0, window.requestAnimationFrame(() => {
913
- t = !1, e();
914
- }));
915
- };
916
- }
917
- function Te(e, t) {
918
- let n = 0;
919
- return function() {
920
- n && window.clearTimeout(n), n = window.setTimeout(() => {
921
- n = 0, e();
922
- }, t);
923
- };
924
- }
925
- function Kt(e, t) {
926
- const n = e.match(/^calc\s*\(\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\+\s*(-?\d+((px)|([lsd]?vh)|([lsd]?vw)))\s*\)\s*$/);
927
- return U(n[1], t) + U(n[6], t);
928
- }
929
- function U(e, t) {
930
- return e ? /^-?\d+px$/.test(e) ? parseInt(e) : /^-?\d+[lsd]?vh$/.test(e) ? parseInt(e) * t.viewportHeight / 100 : /^-?\d+[lsd]?vw$/.test(e) ? parseInt(e) * t.viewportWidth / 100 : /^calc\s*\(\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\+\s*-?\d+((px)|([lsd]?vh)|([lsd]?vw))\s*\)\s*$/.test(e) ? Kt(e, t) : parseInt(e) || 0 : 0;
931
- }
932
- function O(e, t, n) {
933
- const { name: s, offset: r = 0 } = e, { start: i, end: o } = n, c = o - i, u = r / 100;
934
- let l, a;
935
- return s === "entry" ? (l = i - t, a = Math.min(t, c)) : s === "entry-crossing" ? (l = i - t, a = c) : s === "contain" ? (l = Math.min(o - t, i), a = Math.abs(t - c)) : s === "exit" ? (l = Math.max(i, o - t), a = Math.min(t, c)) : s === "exit-crossing" ? (l = i, a = c) : s === "cover" && (l = i - t, a = c + t), l + u * a | 0;
936
- }
937
- function se(e, t, n, s, r) {
938
- let i = 0;
939
- const o = { start: t, end: n };
940
- return e.forEach((c, u) => {
941
- i += c.offset;
942
- const l = c.sticky;
943
- if (l) {
944
- if ("end" in l && e[u - 1]?.element) {
945
- const d = ((r ? c.element.offsetWidth : c.element.offsetHeight) || 0) + l.end - s, v = i + d - c.offset, m = v < o.start, h = !m && v <= n;
946
- let g = 0;
947
- (m || h) && (g = c.offset, o.end += g), m && (o.start += g);
948
- }
949
- if ("start" in l) {
950
- const a = i - l.start, f = a < o.start, d = !f && a <= o.end;
951
- let v = 0;
952
- const m = e[u - 1]?.element;
953
- if (m) {
954
- if (f || d) {
955
- const h = (r ? m.offsetWidth : m.offsetHeight) || 0, g = c.offset, y = (r ? c.element.offsetWidth : c.element.offsetHeight) || 0;
956
- v = h - (g + y), i += v, o.end += v;
957
- }
958
- f && (o.start += v);
959
- }
960
- }
961
- }
962
- }), o;
963
- }
964
- function Bt(e, t, n, s, r, i) {
965
- const { start: o, end: c, duration: u } = e;
966
- let l = o, a = c, f = e.startRange, d = e.endRange, v;
967
- if (typeof u == "string") {
968
- f = { name: u, offset: 0 }, d = { name: u, offset: 100 }, l = O(f, n, t), a = O(d, n, t), v = a - l;
969
- const m = se(i, l, a, n, s);
970
- l = m.start, a = m.end;
971
- } else {
972
- if (f || o?.name) {
973
- f = f || o;
974
- const m = U(f.add, r), h = O({ ...f, offset: 0 }, n, t), g = O({ ...f, offset: 100 }, n, t), y = se(i, h, g, n, s);
975
- l = y.start + f.offset / 100 * (y.end - y.start) + m;
976
- }
977
- if (d || c?.name) {
978
- d = d || c;
979
- const m = U(d.add, r), h = O({ ...d, offset: 0 }, n, t), g = O({ ...d, offset: 100 }, n, t), y = se(i, h, g, n, s);
980
- a = y.start + d.offset / 100 * (y.end - y.start) + m;
981
- } else typeof u == "number" && (a = l + u);
982
- }
983
- return !v && !u && (v = a - l), { ...e, start: l, end: a, startRange: f, endRange: d, duration: v || u };
984
- }
985
- function Qt(e) {
986
- return e.position === "sticky";
987
- }
988
- function Xt(e, t, n) {
989
- return e.position === "fixed" && (!t || t === window.document.body || t === n);
990
- }
991
- function Ut(e, t) {
992
- return parseInt(t ? e.left : e.top);
993
- }
994
- function Jt(e, t) {
995
- return parseInt(t ? e.right : e.bottom);
996
- }
997
- function Zt(e, t, n) {
998
- n && (e.style.position = "static");
999
- const s = (t ? e.offsetLeft : e.offsetTop) || 0;
1000
- return n && (e.style.position = null), s;
1001
- }
1002
- function en(e, t) {
1003
- let n;
1004
- const s = Ut(e, t), r = Jt(e, t), i = !isNaN(s), o = !isNaN(r);
1005
- return (i || o) && (n = {}, i && (n.start = s), o && (n.end = r)), n;
1006
- }
1007
- function H(e, t, n, s, r) {
1008
- const i = e[0].viewSource, o = [];
1009
- let c = (s ? i.offsetWidth : i.offsetHeight) || 0, u = 0, l = i;
1010
- for (; l; ) {
1011
- const f = window.getComputedStyle(l), d = Qt(f), v = d ? en(f, s) : void 0, m = Zt(l, s, d);
1012
- if ((!v || !("end" in v)) && (u += m), o.push({ element: l, offset: m, sticky: v }), l = l.offsetParent, Xt(f, l, t))
1013
- break;
1014
- if (l === t) {
1015
- o.push({ element: l, offset: 0 });
1016
- break;
1017
- }
1018
- }
1019
- return o.reverse(), e.map((f) => ({
1020
- ...Bt(
1021
- f,
1022
- { start: u, end: u + c },
1023
- n,
1024
- s,
1025
- r,
1026
- o
1027
- )
1028
- }));
1029
- }
1030
- const Ie = 100, tn = {
1031
- horizontal: !1,
1032
- observeViewportEntry: !0,
1033
- viewportRootMargin: "7% 7%",
1034
- observeViewportResize: !1,
1035
- observeSourcesResize: !1,
1036
- observeContentResize: !1
1037
- };
1038
- function nn(e, t, n, s) {
1039
- let r = 0;
1040
- return e >= t && e <= n ? r = s ? (e - t) / s : 1 : e > n && (r = 1), r;
1041
- }
1042
- function Oe(e, t) {
1043
- return e === window ? t ? window.document.documentElement.clientWidth : window.document.documentElement.clientHeight : t ? e.clientWidth : e.clientHeight;
1044
- }
1045
- function sn() {
1046
- return {
1047
- viewportWidth: window.document.documentElement.clientWidth,
1048
- viewportHeight: window.document.documentElement.clientHeight
1049
- };
1050
- }
1051
- function rn(e) {
1052
- const t = Ne(e, tn), n = t.root, s = t.horizontal, r = /* @__PURE__ */ new WeakMap();
1053
- let i = Oe(n, s), o, c, u, l, a;
1054
- const f = [], d = sn();
1055
- if (t.scenes = Object.values(
1056
- // TODO(ameerf): find a polyfill and use groupBy instead of following reduce
1057
- e.scenes.reduce(
1058
- (h, g, y) => {
1059
- const p = g.groupId ? `group-${g.groupId}` : String(y);
1060
- return h[p] ? h[p].push(g) : h[p] = [g], h;
1061
- },
1062
- {}
1063
- )
1064
- ).flatMap((h) => (h.every((g) => g.viewSource && (typeof g.duration == "string" || g.start?.name)) ? (h = H(h, n, i, s, d), (t.observeSourcesResize || t.observeContentResize) && f.push(h)) : h.forEach((g) => {
1065
- g.end == null && (g.end = g.start + g.duration), g.duration == null && (g.duration = g.end - g.start);
1066
- }), h)), t.scenes.forEach((h, g) => {
1067
- h.index = g;
1068
- }), f.length) {
1069
- const h = /* @__PURE__ */ new Map();
1070
- window.ResizeObserver && (u = new window.ResizeObserver(function(g) {
1071
- g.forEach((y) => {
1072
- const p = h.get(y.target), w = H(p, n, i, s, d);
1073
- w.forEach((b, T) => {
1074
- t.scenes[b.index] = w[T];
1075
- }), f.splice(f.indexOf(p), 1, w);
1076
- });
1077
- }), f.forEach((g) => {
1078
- u.observe(g[0].viewSource, { box: "border-box" }), h.set(g[0].viewSource, g);
1079
- }), t.observeContentResize && t.contentRoot && new window.ResizeObserver(Te(() => {
1080
- const y = f.map((p) => {
1081
- const w = H(p, n, i, s, d);
1082
- return w.forEach((b, T) => {
1083
- t.scenes[b.index] = w[T];
1084
- }), w;
1085
- });
1086
- f.length = 0, f.push(...y), f.forEach((p) => {
1087
- h.set(p[0].viewSource, p);
1088
- });
1089
- }, Ie)).observe(t.contentRoot, { box: "border-box" })), t.observeViewportResize && (l = Te(function() {
1090
- i = Oe(n, s);
1091
- const g = f.map((y) => {
1092
- const p = H(y, n, i, s, d);
1093
- return p.forEach((w, b) => {
1094
- t.scenes[w.index] = p[b];
1095
- }), p;
1096
- });
1097
- f.length = 0, f.push(...g), f.forEach((y) => {
1098
- h.set(y[0].viewSource, y);
1099
- });
1100
- }, Ie), n === window ? window.addEventListener("resize", l) : window.ResizeObserver && (a = new window.ResizeObserver(l), a.observe(n, { box: "border-box" })));
1101
- }
1102
- t.observeViewportEntry && window.IntersectionObserver && (c = new window.IntersectionObserver(function(h) {
1103
- h.forEach((g) => {
1104
- (r.get(g.target) || []).forEach((y) => {
1105
- y.disabled = !g.isIntersecting;
1106
- });
1107
- });
1108
- }, {
1109
- root: n === window ? window.document : n,
1110
- rootMargin: t.viewportRootMargin,
1111
- threshold: 0
1112
- }), t.scenes.forEach((h) => {
1113
- if (h.viewSource) {
1114
- let g = r.get(h.viewSource);
1115
- g || (g = [], r.set(h.viewSource, g), c.observe(h.viewSource)), g.push(h);
1116
- }
1117
- }));
1118
- function v({ p: h, vp: g }) {
1119
- h = +h.toFixed(1);
1120
- const y = +g.toFixed(4);
1121
- if (h !== o) {
1122
- for (let p of t.scenes)
1123
- if (!p.disabled) {
1124
- const { start: w, end: b, duration: T } = p, C = nn(h, w, b, T);
1125
- p.effect(p, C, y);
1126
- }
1127
- o = h;
1128
- }
1129
- }
1130
- function m() {
1131
- t.scenes.forEach((h) => h.destroy?.()), c && (c.disconnect(), c = null), u && (u.disconnect(), u = null), l && (a ? (a.disconnect(), a = null) : window.removeEventListener("resize", l));
1132
- }
1133
- return {
1134
- tick: v,
1135
- destroy: m
1136
- };
1137
- }
1138
- const on = {
1139
- transitionActive: !1,
1140
- transitionFriction: 0.9,
1141
- transitionEpsilon: 1,
1142
- velocityActive: !1,
1143
- velocityMax: 1
1144
- };
1145
- class cn {
1146
- constructor(t = {}) {
1147
- this.config = Ne(t, on), this.progress = {
1148
- p: 0,
1149
- prevP: 0,
1150
- vp: 0
1151
- }, this.currentProgress = {
1152
- p: 0,
1153
- prevP: 0,
1154
- vp: 0
1155
- }, this._lerpFrameId = 0, this.effect = null;
1156
- const n = !this.config.root || this.config.root === window.document.body;
1157
- this.config.root = n ? window : this.config.root, this.config.contentRoot = this.config.contentRoot || (n ? window.document.body : this.config.root.firstElementChild), this.config.resetProgress = this.config.resetProgress || this.resetProgress.bind(this), this._measure = this.config.measure || (() => {
1158
- const s = this.config.root;
1159
- this.progress.p = this.config.horizontal ? s.scrollX || s.scrollLeft || 0 : s.scrollY || s.scrollTop || 0;
1160
- }), this._trigger = Gt(() => {
1161
- this._measure?.(), this.tick(!0);
1162
- });
1163
- }
1164
- /**
1165
- * Setup event and effect, and reset progress and frame.
1166
- */
1167
- start() {
1168
- this.setupEffect(), this.setupEvent(), this.resetProgress(), this.tick();
1169
- }
1170
- /**
1171
- * Removes event listener.
1172
- */
1173
- pause() {
1174
- this.removeEvent();
1175
- }
1176
- /**
1177
- * Reset progress in the DOM and inner state to given x and y.
1178
- *
1179
- * @param {Object} [scrollPosition]
1180
- * @param {number} [scrollPosition.x]
1181
- * @param {number} [scrollPosition.y]
1182
- */
1183
- resetProgress(t = {}) {
1184
- const n = this.config.root, s = t.x || t.x === 0 ? t.x : n.scrollX || n.scrollLeft || 0, r = t.y || t.y === 0 ? t.y : n.scrollY || n.scrollTop || 0, i = this.config.horizontal ? s : r;
1185
- this.progress.p = i, this.progress.prevP = i, this.progress.vp = 0, this.config.transitionActive && (this.currentProgress.p = i, this.currentProgress.prevP = i, this.currentProgress.vp = 0), t && this.config.root.scrollTo(s, r);
1186
- }
1187
- /**
1188
- * Handle animation frame work.
1189
- *
1190
- * @param {boolean} [clearLerpFrame] whether to cancel an existing lerp frame
1191
- */
1192
- tick(t) {
1193
- const n = this.config.transitionActive;
1194
- n && this.lerp();
1195
- const s = n ? this.currentProgress : this.progress;
1196
- if (this.config.velocityActive) {
1197
- const r = s.p - s.prevP, i = r < 0 ? -1 : 1;
1198
- s.vp = Math.min(this.config.velocityMax, Math.abs(r)) / this.config.velocityMax * i;
1199
- }
1200
- this.effect.tick(s), n && s.p !== this.progress.p && (t && this._lerpFrameId && window.cancelAnimationFrame(this._lerpFrameId), this._lerpFrameId = window.requestAnimationFrame(() => this.tick())), s.prevP = s.p;
1201
- }
1202
- /**
1203
- * Calculate current progress.
1204
- */
1205
- lerp() {
1206
- this.currentProgress.p = Yt(this.currentProgress.p, this.progress.p, +(1 - this.config.transitionFriction).toFixed(3), this.config.transitionEpsilon);
1207
- }
1208
- /**
1209
- * Stop the event and effect, and remove all DOM side-effects.
1210
- */
1211
- destroy() {
1212
- this.pause(), this.removeEffect();
1213
- }
1214
- /**
1215
- * Register to scroll for triggering update.
1216
- */
1217
- setupEvent() {
1218
- this.removeEvent(), this.config.root.addEventListener("scroll", this._trigger);
1219
- }
1220
- /**
1221
- * Remove scroll handler.
1222
- */
1223
- removeEvent() {
1224
- this.config.root.removeEventListener("scroll", this._trigger);
1225
- }
1226
- /**
1227
- * Reset registered effect.
1228
- */
1229
- setupEffect() {
1230
- this.removeEffect(), this.effect = rn(this.config);
1231
- }
1232
- /**
1233
- * Remove registered effect.
1234
- */
1235
- removeEffect() {
1236
- this.effect && this.effect.destroy(), this.effect = null;
1237
- }
1238
- }
1239
- const oe = /* @__PURE__ */ new WeakMap();
1240
- let Ve = () => ({});
1241
- function an(e) {
1242
- Ve = e;
1243
- }
1244
- function fn(e, t, n, s, { reducedMotion: r }) {
1245
- if (r)
1246
- return;
1247
- const i = {
1248
- trigger: "view-progress",
1249
- element: e
1250
- }, o = F(n);
1251
- let c;
1252
- if ("ViewTimeline" in window) {
1253
- const l = de(t, o, i);
1254
- l && (l.play(), c = () => {
1255
- l.ready.then(() => {
1256
- l.cancel();
1257
- });
1258
- });
1259
- } else {
1260
- const l = Me(t, o, i);
1261
- if (l) {
1262
- const a = Array.isArray(l) ? l : [l], f = new cn({
1263
- viewSource: e,
1264
- scenes: a,
1265
- observeViewportEntry: !1,
1266
- observeViewportResize: !1,
1267
- observeSourcesResize: !0,
1268
- root: document.body,
1269
- ...Ve()
1270
- });
1271
- c = () => {
1272
- f.destroy();
1273
- }, Promise.all(a.map((d) => d.ready || Promise.resolve())).then(
1274
- () => {
1275
- f.start();
1276
- }
1277
- );
1278
- }
1279
- }
1280
- if (!c) return;
1281
- const u = { source: e, target: t, cleanup: c };
1282
- I(oe, e, u), I(oe, t, u);
1283
- }
1284
- function ln(e) {
1285
- M(oe, e);
1286
- }
1287
- const un = {
1288
- add: fn,
1289
- remove: ln,
1290
- registerOptionsGetter: an
1291
- };
1292
- function _e(e, t, n) {
1293
- return Math.min(Math.max(e, n), t);
1294
- }
1295
- function ke(e) {
1296
- let t = !1;
1297
- return function() {
1298
- if (!t)
1299
- return t = !0, window.requestAnimationFrame(() => {
1300
- t = !1, e();
1301
- });
1302
- };
1303
- }
1304
- function dn(e) {
1305
- let t = e, n = 0, s = 0;
1306
- if (t.offsetParent)
1307
- do
1308
- n += t.offsetLeft, s += t.offsetTop, t = t.offsetParent;
1309
- while (t);
1310
- return {
1311
- left: n,
1312
- top: s,
1313
- width: e.offsetWidth,
1314
- height: e.offsetHeight
1315
- };
1316
- }
1317
- function hn() {
1318
- const e = window.devicePixelRatio;
1319
- let t = !1;
1320
- if (e === 1)
1321
- return !1;
1322
- document.body.addEventListener("pointerdown", (s) => {
1323
- t = s.offsetX !== 10;
1324
- }, { once: !0 });
1325
- const n = new PointerEvent("pointerdown", {
1326
- clientX: 10
1327
- });
1328
- return document.body.dispatchEvent(n), t;
1329
- }
1330
- function mn() {
1331
- return new Promise((e) => {
1332
- const t = window.scrollY;
1333
- let n = !1, s;
1334
- function r() {
1335
- document.body.addEventListener("pointerdown", (c) => {
1336
- s === void 0 ? s = c.offsetY : n = c.offsetY === s;
1337
- }, { once: !0 });
1338
- const o = new PointerEvent("pointerdown", {
1339
- clientY: 500
1340
- });
1341
- document.body.dispatchEvent(o);
1342
- }
1343
- function i() {
1344
- window.scrollY !== t && (window.removeEventListener("scroll", i), r(), e(n));
1345
- }
1346
- r(), window.addEventListener("scroll", i), window.scrollY > 0 && window.scrollBy(0, -1);
1347
- });
1348
- }
1349
- function gn(e) {
1350
- mn().then((t) => {
1351
- e.fixRequired = t, t && (window.addEventListener("scroll", e.scrollHandler), e.scrollHandler());
1352
- });
1353
- }
1354
- let z = 0;
1355
- const K = /* @__PURE__ */ new Set();
1356
- function vn() {
1357
- const e = (n) => {
1358
- for (let s of n.changedTouches)
1359
- K.add(s.identifier);
1360
- }, t = (n) => {
1361
- for (let s of n.changedTouches)
1362
- K.delete(s.identifier);
1363
- };
1364
- return document.addEventListener("touchstart", e, { passive: !0 }), document.addEventListener("touchend", t, { passive: !0 }), function() {
1365
- K.clear(), document.removeEventListener("touchstart", e), document.removeEventListener("touchend", t);
1366
- };
1367
- }
1368
- function pn(e, t) {
1369
- if ("onscrollend" in window)
1370
- return e.addEventListener("scrollend", t), function() {
1371
- e.removeEventListener("scrollend", t);
1372
- };
1373
- let n = 0, s;
1374
- z || (s = vn()), z += 1;
1375
- function r(i) {
1376
- clearTimeout(n), n = setTimeout(() => {
1377
- K.size ? setTimeout(r, 100) : (t(i), n = 0);
1378
- }, 100);
1379
- }
1380
- return e.addEventListener("scroll", r), function() {
1381
- e.removeEventListener("scroll", r), z -= 1, z || s();
1382
- };
1383
- }
1384
- function yn(e, t, n) {
1385
- return {
1386
- x(s) {
1387
- const r = e.left - n.x + e.width / 2, i = r >= t.width / 2, o = (i ? r : t.width - r) * 2, c = i ? 0 : r - o / 2;
1388
- return (s - c) / o;
1389
- },
1390
- y(s) {
1391
- const r = e.top - n.y + e.height / 2, i = r >= t.height / 2, o = (i ? r : t.height - r) * 2, c = i ? 0 : r - o / 2;
1392
- return (s - c) / o;
1393
- }
1394
- };
1395
- }
1396
- function En(e, t) {
1397
- this.x = window.scrollX, this.y = window.scrollY, requestAnimationFrame(() => e && e(t));
1398
- }
1399
- function wn(e) {
1400
- e.rect.width = window.document.documentElement.clientWidth, e.rect.height = window.document.documentElement.clientHeight;
1401
- }
1402
- function bn(e) {
1403
- const t = new ResizeObserver((n) => {
1404
- n.forEach((s) => {
1405
- e.rect.width = s.borderBoxSize[0].inlineSize, e.rect.height = s.borderBoxSize[0].blockSize;
1406
- });
1407
- });
1408
- return t.observe(e.root, { box: "border-box" }), t;
1409
- }
1410
- function Sn(e) {
1411
- let t = !1, n = { x: e.rect.width / 2, y: e.rect.height / 2, vx: 0, vy: 0 }, s, r, i, o, c;
1412
- const u = { x: 0, y: 0 };
1413
- e.scenes.forEach((a) => {
1414
- a.target && a.centeredToTarget && (a.transform = yn(dn(a.target), e.rect, u), t = !0), e.root ? r = bn(e) : (i = wn.bind(null, e), window.addEventListener("resize", i));
1415
- }), s = function(a) {
1416
- for (let f of e.scenes)
1417
- if (!f.disabled) {
1418
- const d = f.transform?.x(a.x) || a.x / e.rect.width, v = f.transform?.y(a.y) || a.y / e.rect.height, m = +_e(0, 1, d).toPrecision(4), h = +_e(0, 1, v).toPrecision(4), g = { x: a.vx, y: a.vy };
1419
- e.allowActiveEvent && (a.active = d <= 1 && v <= 1 && d >= 0 && v >= 0), f.effect(f, { x: m, y: h }, g, a.active);
1420
- }
1421
- Object.assign(n, a);
1422
- }, t && (o = En.bind(u, s, n), c = pn(document, o));
1423
- function l() {
1424
- e.scenes.forEach((a) => a.destroy?.()), c?.(), r ? (r.disconnect(), r = null) : (window.removeEventListener("resize", i), i = null), s = null, n = null;
1425
- }
1426
- return {
1427
- tick: s,
1428
- destroy: l
1429
- };
1430
- }
1431
- const Tn = 1e3 / 60 * 3;
1432
- let N;
1433
- function In() {
1434
- _.x = window.scrollX, _.y = window.scrollY;
1435
- }
1436
- const _ = { x: 0, y: 0, scrollHandler: In, fixRequired: void 0 };
1437
- class On {
1438
- constructor(t = {}) {
1439
- this.config = { ...t }, this.effect = null, this._nextTick = null, this._nextTransitionTick = null, this._startTime = 0;
1440
- let n;
1441
- this.config.transitionDuration ? n = this.config.noThrottle ? () => this.transition() : ke(() => this.transition()) : n = this.config.noThrottle ? () => (this.tick(), null) : ke(() => {
1442
- this.tick();
1443
- }), this.config.rect = this.config.root ? {
1444
- width: this.config.root.offsetWidth,
1445
- height: this.config.root.offsetHeight
1446
- } : {
1447
- width: window.document.documentElement.clientWidth,
1448
- height: window.document.documentElement.clientHeight
1449
- }, this.progress = {
1450
- x: this.config.rect.width / 2,
1451
- y: this.config.rect.height / 2,
1452
- vx: 0,
1453
- vy: 0
1454
- }, this.previousProgress = { ...this.progress }, this.currentProgress = null;
1455
- const s = (r) => {
1456
- const i = this.config.root ? r.offsetX : r.x, o = this.config.root ? r.offsetY : r.y;
1457
- this.progress.vx = i - this.progress.x, this.progress.vy = o - this.progress.y, this.progress.x = i, this.progress.y = o, this._nextTick = n();
1458
- };
1459
- if (this._pointerLeave = () => {
1460
- this.progress.active = !1, this.progress.vx = 0, this.progress.vy = 0, this._nextTick = n();
1461
- }, this._pointerEnter = () => {
1462
- this.progress.active = !0, this._nextTick = n();
1463
- }, this.config.root) {
1464
- N = typeof N == "boolean" ? N : hn();
1465
- const r = N ? window.devicePixelRatio : 1;
1466
- typeof _.fixRequired > "u" && gn(_), this._measure = (i) => {
1467
- if (i.target !== this.config.root) {
1468
- const o = new PointerEvent("pointermove", {
1469
- bubbles: !0,
1470
- cancelable: !0,
1471
- clientX: i.x * r + _.x,
1472
- clientY: i.y * r + _.y
1473
- });
1474
- i.stopPropagation(), this.config.root.dispatchEvent(o);
1475
- } else
1476
- s(i);
1477
- };
1478
- } else
1479
- this._measure = s;
1480
- }
1481
- /**
1482
- * Setup event and effect, and reset progress and frame.
1483
- */
1484
- start() {
1485
- this.setupEffect(), this.setupEvent();
1486
- }
1487
- /**
1488
- * Removes event listener.
1489
- */
1490
- pause() {
1491
- this.removeEvent();
1492
- }
1493
- /**
1494
- * Handle animation frame work.
1495
- */
1496
- tick() {
1497
- this.effect.tick(this.progress);
1498
- }
1499
- /**
1500
- * Starts a transition from the previous progress to the current progress.
1501
- *
1502
- * @returns {number} the requestAnimationFrame id for the transition tick.
1503
- */
1504
- transition() {
1505
- const t = this.config.transitionDuration, n = this.config.transitionEasing || ((o) => o), s = performance.now();
1506
- let r = !1;
1507
- const i = (o) => {
1508
- const c = (o - this._startTime) / t, u = n(Math.min(1, c));
1509
- r && (this.progress.vx = 0, this.progress.vy = 0, r = !1), this.currentProgress = Object.entries(this.progress).reduce((l, [a, f]) => (a === "active" ? l[a] = f : l[a] = this.previousProgress[a] + (f - this.previousProgress[a]) * u, l), this.currentProgress || {}), c < 1 && (this._nextTransitionTick = requestAnimationFrame(i), r = o - this._startTime > Tn), this.effect.tick(this.currentProgress);
1510
- };
1511
- return this._startTime ? (this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick), Object.assign(this.previousProgress, this.currentProgress), this._startTime = s, i(s)) : this._startTime = s, this._nextTransitionTick;
1512
- }
1513
- /**
1514
- * Stop the event and effect, and remove all DOM side effects.
1515
- */
1516
- destroy() {
1517
- this.pause(), this.removeEffect(), this._nextTick && cancelAnimationFrame(this._nextTick), this._nextTransitionTick && cancelAnimationFrame(this._nextTransitionTick);
1518
- }
1519
- /**
1520
- * Register to pointermove for triggering update.
1521
- */
1522
- setupEvent() {
1523
- this.removeEvent();
1524
- const t = this.config.root || window;
1525
- t.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.eventSource && this.config.eventSource.addEventListener("pointermove", this._measure, { passive: !0 }), this.config.allowActiveEvent && (t.addEventListener("pointerleave", this._pointerLeave, { passive: !0 }), t.addEventListener("pointerenter", this._pointerEnter, { passive: !0 }), this.config.eventSource && (this.config.eventSource.addEventListener("pointerleave", this._pointerLeave, { passive: !0 }), this.config.eventSource.addEventListener("pointerenter", this._pointerEnter, { passive: !0 })));
1526
- }
1527
- /**
1528
- * Remove pointermove handler.
1529
- */
1530
- removeEvent() {
1531
- const t = this.config.root || window;
1532
- t.removeEventListener("pointermove", this._measure), this.config.eventSource && this.config.eventSource.removeEventListener("pointermove", this._measure), this.config.allowActiveEvent && (t.removeEventListener("pointerleave", this._pointerLeave), t.removeEventListener("pointerenter", this._pointerEnter), this.config.eventSource && (this.config.eventSource.removeEventListener("pointerleave", this._pointerLeave), this.config.eventSource.removeEventListener("pointerenter", this._pointerEnter)));
1533
- }
1534
- /**
1535
- * Reset registered effect.
1536
- */
1537
- setupEffect() {
1538
- this.removeEffect(), this.effect = Sn(this.config);
1539
- }
1540
- /**
1541
- * Remove registered effect.
1542
- */
1543
- removeEffect() {
1544
- this.effect && this.effect.destroy(), this.effect = null;
1545
- }
1546
- }
1547
- const ce = /* @__PURE__ */ new WeakMap();
1548
- let De = () => ({});
1549
- function _n(e) {
1550
- De = e;
1551
- }
1552
- function kn(e, t, n, s = {}, { reducedMotion: r }) {
1553
- if (r)
1554
- return;
1555
- const i = {
1556
- trigger: "pointer-move",
1557
- element: e,
1558
- axis: s.axis ?? "y"
1559
- }, o = Me(t, F(n), i);
1560
- if (o) {
1561
- const c = Array.isArray(o) ? o : [o], u = new On({
1562
- root: s.hitArea === "self" ? e : void 0,
1563
- scenes: c,
1564
- ...De()
1565
- }), a = { source: e, target: t, cleanup: () => {
1566
- u.destroy();
1567
- } };
1568
- I(ce, e, a), I(ce, t, a), Promise.all(
1569
- c.map((f) => f.ready || Promise.resolve())
1570
- ).then(() => {
1571
- u.start();
1572
- });
1573
- }
1574
- }
1575
- function Cn(e) {
1576
- M(ce, e);
1577
- }
1578
- const xn = {
1579
- add: kn,
1580
- remove: Cn,
1581
- registerOptionsGetter: _n
1582
- }, ae = /* @__PURE__ */ new WeakMap();
1583
- function An(e, t, n, s, { reducedMotion: r, selectorCondition: i }) {
1584
- const o = he(
1585
- t,
1586
- F(n),
1587
- void 0,
1588
- r
1589
- );
1590
- if (!o)
1591
- return;
1592
- const c = () => {
1593
- i && !t.matches(i) || o.play();
1594
- }, l = { source: e, target: t, cleanup: () => {
1595
- o.cancel(), e.removeEventListener("animationend", c);
1596
- } };
1597
- I(ae, e, l), I(ae, t, l), e.addEventListener("animationend", c);
1598
- }
1599
- function Ln(e) {
1600
- M(ae, e);
1601
- }
1602
- const Pn = {
1603
- add: An,
1604
- remove: Ln
1605
- };
1606
- function Rn(e, t, n, s = !1, r, i) {
1607
- const o = he(
1608
- e,
1609
- F(t),
1610
- void 0,
1611
- s
1612
- );
1613
- if (!o)
1614
- return null;
1615
- let c = !0;
1616
- const u = n.type || "alternate";
1617
- return (l) => {
1618
- if (r && !e.matches(r)) return;
1619
- const a = !i, f = i?.enter?.includes(l.type), d = i?.leave?.includes(l.type);
1620
- if (f || a) {
1621
- u === "alternate" || u === "state" ? c ? (c = !1, o.play()) : u === "alternate" ? o.reverse() : u === "state" && (o.playState === "running" ? o.pause() : o.playState !== "finished" && o.play()) : (o.progress(0), delete e.dataset.interactEnter, o.isCSS && o.onFinish(() => {
1622
- S.mutate(() => {
1623
- e.dataset.interactEnter = "done";
1624
- });
1625
- }), o.play());
1626
- return;
1627
- }
1628
- d && (u === "alternate" ? o.reverse() : u === "repeat" ? (o.cancel(), S.mutate(() => {
1629
- delete e.dataset.interactEnter;
1630
- })) : u === "state" && o.playState === "running" && o.pause());
1631
- };
1632
- }
1633
- function $n(e, t, {
1634
- effectId: n,
1635
- listContainer: s,
1636
- listItemSelector: r
1637
- }, i, o, c) {
1638
- const u = !!s, l = i.method || "toggle", a = l === "toggle";
1639
- return (f) => {
1640
- if (o && !e.matches(o)) return;
1641
- const d = u ? e.closest(
1642
- `${s} > ${r || ""}:has(:scope)`
1643
- ) : void 0, v = !c, m = c?.enter?.includes(f.type), h = c?.leave?.includes(f.type);
1644
- v ? t.toggleEffect(n, l, d) : (m && t.toggleEffect(n, a ? "add" : l, d), h && a && t.toggleEffect(n, "remove", d));
1645
- };
1646
- }
1647
- const fe = /* @__PURE__ */ new WeakMap();
1648
- function Ce(e, t) {
1649
- return (n) => {
1650
- const s = n;
1651
- e.contains(s.relatedTarget) || t(s);
1652
- };
1653
- }
1654
- function Fn(e) {
1655
- return (t) => {
1656
- const n = t;
1657
- n.pointerType && e(n);
1658
- };
1659
- }
1660
- function Mn(e) {
1661
- return (t) => {
1662
- const n = t;
1663
- n.code === "Space" ? (n.preventDefault(), e(n)) : n.code === "Enter" && e(n);
1664
- };
1665
- }
1666
- const qn = {
1667
- focusin: (e, t) => Ce(e, t),
1668
- focusout: (e, t) => Ce(e, t),
1669
- click: (e, t) => Fn(t),
1670
- keydown: (e, t) => Mn(t)
1671
- };
1672
- function Hn(e, t, n) {
1673
- const s = qn[e];
1674
- return s ? s(t, n) : (r) => n(r);
1675
- }
1676
- function zn(e) {
1677
- return typeof e == "object" && !Array.isArray(e) && ("enter" in e || "leave" in e);
1678
- }
1679
- function Nn(e) {
1680
- if (typeof e == "string")
1681
- return { toggle: [e] };
1682
- if (Array.isArray(e))
1683
- return { toggle: [...e] };
1684
- if (zn(e)) {
1685
- const t = e.enter ? [...e.enter] : [], n = e.leave ? [...e.leave] : [];
1686
- return { enter: t, leave: n };
1687
- }
1688
- return {};
1689
- }
1690
- function Vn(e) {
1691
- return !!(e.enter?.length || e.leave?.length);
1692
- }
1693
- function Dn(e) {
1694
- return Vn(e) ? { enter: e.enter ?? [], leave: e.leave ?? [] } : void 0;
1695
- }
1696
- function Wn(e, t, n, s, { reducedMotion: r, targetController: i, selectorCondition: o }) {
1697
- const c = Nn(s.eventConfig), u = n.transition || n.transitionProperties, l = Dn(c);
1698
- let a, f = !1;
1699
- if (u ? a = $n(
1700
- t,
1701
- i,
1702
- n,
1703
- s,
1704
- o,
1705
- l
1706
- ) : (a = Rn(
1707
- t,
1708
- n,
1709
- s,
1710
- r,
1711
- o,
1712
- l
1713
- ), f = s.type === "once"), !a)
1714
- return;
1715
- const d = a, v = new AbortController();
1716
- function m(y, p, w) {
1717
- const b = Hn(p, e, d);
1718
- y.addEventListener(p, b, { ...w, signal: v.signal });
1719
- }
1720
- const g = { source: e, target: t, cleanup: () => {
1721
- v.abort();
1722
- } };
1723
- if (I(fe, e, g), I(fe, t, g), l) {
1724
- const y = c.enter, p = c.leave;
1725
- y.forEach((b) => {
1726
- b === "focusin" && (e.tabIndex = 0), m(e, b, { passive: !0, once: f });
1727
- }), (u ? s.method === "toggle" : s.type !== "once") && p.forEach((b) => {
1728
- if (b === "focusout") {
1729
- m(e, b, { once: f });
1730
- return;
1731
- }
1732
- m(e, b, { passive: !0 });
1733
- });
1734
- } else
1735
- (c.toggle ?? []).forEach((p) => {
1736
- m(e, p, { once: f, passive: p !== "keydown" });
1737
- });
1738
- }
1739
- function jn(e) {
1740
- M(fe, e);
1741
- }
1742
- const A = {
1743
- add: Wn,
1744
- remove: jn
1745
- }, le = {
1746
- click: ["click"],
1747
- activate: ["click", "keydown"],
1748
- hover: { enter: ["mouseenter"], leave: ["mouseleave"] },
1749
- interest: {
1750
- enter: ["mouseenter", "focusin"],
1751
- leave: ["mouseleave", "focusout"]
1752
- }
1753
- }, xe = {
1754
- click: le.activate,
1755
- hover: le.interest
1756
- };
1757
- function V(e) {
1758
- const t = le[e];
1759
- return (n, s, r, i, o) => {
1760
- const c = o?.allowA11yTriggers && e in xe ? xe[e] : t;
1761
- A.add(n, s, r, { ...i, eventConfig: c }, o ?? {});
1762
- };
1763
- }
1764
- const P = {
1765
- viewEnter: Se,
1766
- hover: {
1767
- add: V("hover"),
1768
- remove: A.remove
1769
- },
1770
- click: {
1771
- add: V("click"),
1772
- remove: A.remove
1773
- },
1774
- pageVisible: Se,
1775
- animationEnd: Pn,
1776
- viewProgress: un,
1777
- pointerMove: xn,
1778
- activate: {
1779
- add: V("activate"),
1780
- remove: A.remove
1781
- },
1782
- interest: {
1783
- add: V("interest"),
1784
- remove: A.remove
1785
- }
1786
- };
1787
- function Yn(e) {
1788
- return e.replace(/\[([-\w]+)]/g, "[]");
1789
- }
1790
- class E {
1791
- static defineInteractElement;
1792
- dataCache;
1793
- addedInteractions;
1794
- mediaQueryListeners;
1795
- listInteractionsCache;
1796
- controllers;
1797
- static forceReducedMotion = !1;
1798
- static allowA11yTriggers = !0;
1799
- static instances = [];
1800
- static controllerCache = /* @__PURE__ */ new Map();
1801
- constructor() {
1802
- this.dataCache = { effects: {}, conditions: {}, interactions: {} }, this.addedInteractions = {}, this.mediaQueryListeners = /* @__PURE__ */ new Map(), this.listInteractionsCache = {}, this.controllers = /* @__PURE__ */ new Set();
1803
- }
1804
- init(t, n) {
1805
- if (typeof window > "u" || !window.customElements)
1806
- return;
1807
- const s = n?.useCutsomElement ?? !!E.defineInteractElement;
1808
- this.dataCache = Kn(t, s);
1809
- const r = E.defineInteractElement?.();
1810
- s && r === !1 ? document.querySelectorAll("interact-element").forEach((i) => {
1811
- i.connect();
1812
- }) : E.controllerCache.forEach(
1813
- (i, o) => i.connect(o)
1814
- );
1815
- }
1816
- destroy() {
1817
- for (const t of this.controllers)
1818
- t.disconnect();
1819
- for (const [, t] of this.mediaQueryListeners.entries())
1820
- t.mql.removeEventListener("change", t.handler);
1821
- this.mediaQueryListeners.clear(), this.addedInteractions = {}, this.listInteractionsCache = {}, this.controllers.clear(), this.dataCache = { effects: {}, conditions: {}, interactions: {} }, E.instances.splice(E.instances.indexOf(this), 1);
1822
- }
1823
- setController(t, n) {
1824
- this.controllers.add(n), E.setController(t, n);
1825
- }
1826
- deleteController(t, n = !1) {
1827
- const s = E.controllerCache.get(t);
1828
- this.clearInteractionStateForKey(t), this.clearMediaQueryListenersForKey(t), s && n && (this.controllers.delete(s), E.deleteController(t));
1829
- }
1830
- has(t) {
1831
- return !!this.get(t);
1832
- }
1833
- get(t) {
1834
- const n = Yn(t);
1835
- return this.dataCache.interactions[n];
1836
- }
1837
- clearMediaQueryListenersForKey(t) {
1838
- for (const [n, s] of this.mediaQueryListeners.entries())
1839
- s.key === t && (s.mql.removeEventListener("change", s.handler), this.mediaQueryListeners.delete(n));
1840
- }
1841
- clearInteractionStateForKey(t) {
1842
- (this.get(t)?.interactionIds || []).forEach((s) => {
1843
- const r = R(s, t);
1844
- delete this.addedInteractions[r];
1845
- });
1846
- }
1847
- setupMediaQueryListener(t, n, s, r) {
1848
- this.mediaQueryListeners.has(t) || (n.addEventListener("change", r), this.mediaQueryListeners.set(t, {
1849
- mql: n,
1850
- handler: r,
1851
- key: s
1852
- }));
1853
- }
1854
- static create(t, n) {
1855
- const s = new E();
1856
- return E.instances.push(s), s.init(t, n), s;
1857
- }
1858
- static destroy() {
1859
- E.controllerCache.forEach((t) => {
1860
- t.disconnect();
1861
- }), E.instances.length = 0, E.controllerCache.clear();
1862
- }
1863
- static setup(t) {
1864
- t.scrollOptionsGetter && P.viewProgress.registerOptionsGetter?.(
1865
- t.scrollOptionsGetter
1866
- ), t.pointerOptionsGetter && P.pointerMove.registerOptionsGetter?.(
1867
- t.pointerOptionsGetter
1868
- ), t.viewEnter && P.viewEnter.setOptions(
1869
- t.viewEnter
1870
- ), t.allowA11yTriggers !== void 0 && (E.allowA11yTriggers = t.allowA11yTriggers);
1871
- }
1872
- static getInstance(t) {
1873
- return E.instances.find((n) => n.has(t));
1874
- }
1875
- static getController(t) {
1876
- return t ? E.controllerCache.get(t) : void 0;
1877
- }
1878
- static setController(t, n) {
1879
- E.controllerCache.set(t, n);
1880
- }
1881
- static deleteController(t) {
1882
- E.controllerCache.delete(t);
1883
- }
1884
- static registerEffects = kt;
1885
- }
1886
- let Gn = 0;
1887
- function J(e, {
1888
- asCombinator: t = !1,
1889
- addItemFilter: n = !1,
1890
- useFirstChild: s = !1
1891
- } = {}) {
1892
- if (e.listContainer) {
1893
- const r = `${n && e.listItemSelector ? ` > ${e.listItemSelector}` : ""}`;
1894
- return e.selector ? `${e.listContainer}${r} ${e.selector}` : `${e.listContainer}${r || " > *"}`;
1895
- } else if (e.selector)
1896
- return e.selector;
1897
- return s ? t ? "> :first-child" : ":scope > :first-child" : "";
1898
- }
1899
- function Kn(e, t = !1) {
1900
- const n = e.conditions || {}, s = {};
1901
- return e.interactions?.forEach((r) => {
1902
- const i = r.key, o = ++Gn, { effects: c, ...u } = r;
1903
- if (!i) {
1904
- console.error(`Interaction ${o} is missing a key for source element.`);
1905
- return;
1906
- }
1907
- s[i] || (s[i] = {
1908
- triggers: [],
1909
- effects: {},
1910
- interactionIds: /* @__PURE__ */ new Set(),
1911
- selectors: /* @__PURE__ */ new Set()
1912
- });
1913
- const l = Array.from(c);
1914
- l.reverse();
1915
- const a = { ...u, effects: l };
1916
- s[i].triggers.push(a), s[i].selectors.add(
1917
- J(a, { useFirstChild: t })
1918
- );
1919
- const f = a.listContainer;
1920
- l.forEach((d) => {
1921
- let v = d.key;
1922
- if (!v && d.effectId) {
1923
- const g = e.effects[d.effectId];
1924
- g && (v = g.key);
1925
- }
1926
- d.effectId || (d.effectId = Mt()), v = v || i, d.key = v;
1927
- const m = d.effectId;
1928
- if (f && d.listContainer && (v !== i || d.listContainer !== f))
1929
- return;
1930
- const h = `${i}::${v}::${m}::${o}`;
1931
- d.interactionId = h, s[i].interactionIds.add(h), v !== i && (s[v] ? s[v].effects[h] || (s[v].effects[h] = [], s[v].interactionIds.add(h)) : s[v] = {
1932
- triggers: [],
1933
- effects: {
1934
- [h]: []
1935
- },
1936
- interactionIds: /* @__PURE__ */ new Set(),
1937
- selectors: /* @__PURE__ */ new Set()
1938
- }, s[v].effects[h].push({ ...u, effect: d }), s[v].selectors.add(J(d, { useFirstChild: t })));
1939
- });
1940
- }), {
1941
- effects: e.effects || {},
1942
- conditions: n,
1943
- interactions: s
1944
- };
1945
- }
1946
- function Ae(e, t, n) {
1947
- if (e.listContainer) {
1948
- const s = t.querySelector(e.listContainer);
1949
- return s ? e.selector ? Array.from(s.querySelectorAll(e.selector)) : Array.from(s.children) : (console.warn(`Interact: No container found for list container "${e.listContainer}"`), []);
1950
- }
1951
- if (e.selector) {
1952
- const s = t.querySelectorAll(e.selector);
1953
- if (s.length > 0)
1954
- return Array.from(s);
1955
- console.warn(`Interact: No elements found for selector "${e.selector}"`);
1956
- }
1957
- return n ? t.firstElementChild : t;
1958
- }
1959
- function Le(e, t) {
1960
- return t.map((n) => e.selector ? n.querySelector(e.selector) : n).filter(Boolean);
1961
- }
1962
- function We(e, t, n, s, r, i, o, c) {
1963
- return [
1964
- o ? Le(e, o) : Ae(e, n, s),
1965
- c ? Le(t, c) : Ae(t, r, i)
1966
- ];
1967
- }
1968
- function je(e, t, n, s, r, i, o) {
1969
- const c = Array.isArray(s), u = Array.isArray(r);
1970
- c ? s.forEach((l, a) => {
1971
- const f = u ? r[a] : r;
1972
- f && Pe(
1973
- e,
1974
- l,
1975
- t.trigger,
1976
- f,
1977
- n,
1978
- t.params,
1979
- i,
1980
- o
1981
- );
1982
- }) : (u ? r : [r]).forEach((a) => {
1983
- Pe(
1984
- e,
1985
- s,
1986
- t.trigger,
1987
- a,
1988
- n,
1989
- t.params,
1990
- i,
1991
- o
1992
- );
1993
- });
1994
- }
1995
- function Ye(e, t, n, s, r) {
1996
- const i = {}, o = [];
1997
- s.effects.forEach((c) => {
1998
- const u = c.effectId, l = {
1999
- ...n.dataCache.effects[u] || {},
2000
- ...c,
2001
- effectId: u
2002
- }, a = l.key, f = R(c.interactionId, e);
2003
- if (i[f] || n.addedInteractions[f] && !r)
2004
- return;
2005
- const d = $(l.conditions || [], n.dataCache.conditions);
2006
- if (d && n.setupMediaQueryListener(f, d, e, () => {
2007
- t.update();
2008
- }), !d || d.matches) {
2009
- i[f] = !0;
2010
- const v = a && R(a, e);
2011
- let m;
2012
- if (v) {
2013
- if (m = E.getController(v), !m)
2014
- return;
2015
- l.listContainer && m.watchChildList(l.listContainer);
2016
- } else
2017
- m = t;
2018
- const [h, g] = We(
2019
- s,
2020
- l,
2021
- t.element,
2022
- t.useFirstChild,
2023
- m.element,
2024
- m.useFirstChild,
2025
- r
2026
- );
2027
- if (!h || !g)
2028
- return;
2029
- n.addedInteractions[f] = !0;
2030
- const y = v || s.key, p = Q(
2031
- l.conditions || [],
2032
- n.dataCache.conditions
2033
- );
2034
- o.push([
2035
- y,
2036
- s,
2037
- l,
2038
- h,
2039
- g,
2040
- p,
2041
- m.useFirstChild
2042
- ]);
2043
- }
2044
- }), o.reverse().forEach((c) => {
2045
- je(...c);
2046
- });
2047
- }
2048
- function Ge(e, t, n, s, r) {
2049
- const i = n.get(e)?.effects || {}, o = Object.keys(i), c = [];
2050
- return o.forEach((u) => {
2051
- const l = R(u, e);
2052
- if (n.addedInteractions[l] && !r)
2053
- return;
2054
- i[u].some(({ effect: f, ...d }) => {
2055
- const v = $(
2056
- d.conditions || [],
2057
- n.dataCache.conditions
2058
- );
2059
- if (v && !v.matches)
2060
- return !1;
2061
- const m = f.effectId, h = {
2062
- ...n.dataCache.effects[m] || {},
2063
- ...f,
2064
- effectId: m
2065
- };
2066
- if (s && h.listContainer !== s)
2067
- return !1;
2068
- const g = $(h.conditions || [], n.dataCache.conditions);
2069
- if (g && n.setupMediaQueryListener(l, g, e, () => {
2070
- t.update();
2071
- }), !g || g.matches) {
2072
- const y = d.key && R(d.key, e), p = E.getController(y);
2073
- if (!p)
2074
- return !0;
2075
- h.listContainer && t.watchChildList(h.listContainer);
2076
- const [w, b] = We(
2077
- d,
2078
- h,
2079
- p.element,
2080
- p.useFirstChild,
2081
- t.element,
2082
- t.useFirstChild,
2083
- void 0,
2084
- r
2085
- );
2086
- if (!w || !b)
2087
- return !0;
2088
- n.addedInteractions[l] = !0;
2089
- const T = Q(
2090
- h.conditions || [],
2091
- n.dataCache.conditions
2092
- );
2093
- return c.push([
2094
- e,
2095
- d,
2096
- h,
2097
- w,
2098
- b,
2099
- T,
2100
- t.useFirstChild
2101
- ]), !0;
2102
- }
2103
- return !1;
2104
- });
2105
- }), c.reverse().forEach((u) => {
2106
- je(...u);
2107
- }), o.length > 0;
2108
- }
2109
- function Pe(e, t, n, s, r, i, o, c) {
2110
- let u;
2111
- if (r.transition || r.transitionProperties) {
2112
- const l = {
2113
- key: e,
2114
- effectId: r.effectId,
2115
- transition: r.transition,
2116
- properties: r.transitionProperties,
2117
- childSelector: J(r, {
2118
- asCombinator: !0,
2119
- addItemFilter: !0,
2120
- useFirstChild: c
2121
- }),
2122
- selectorCondition: o
2123
- };
2124
- if (u = E.getController(e), !u)
2125
- return;
2126
- u.renderStyle(qt(l));
2127
- }
2128
- P[n]?.add(t, s, r, i, {
2129
- reducedMotion: E.forceReducedMotion,
2130
- targetController: u,
2131
- selectorCondition: o,
2132
- allowA11yTriggers: E.allowA11yTriggers
2133
- });
2134
- }
2135
- function Bn(e) {
2136
- const t = e.key, n = E.getInstance(t);
2137
- if (!n)
2138
- return console.warn(`No instance found for key: ${t}`), E.setController(t, e), !1;
2139
- const { triggers: s = [] } = n?.get(t) || {}, r = s.length > 0;
2140
- n.setController(t, e), s.forEach((o, c) => {
2141
- const u = $(o.conditions, n.dataCache.conditions);
2142
- if (u) {
2143
- const l = `${t}::trigger::${c}`;
2144
- n.setupMediaQueryListener(l, u, t, () => {
2145
- e.update();
2146
- });
2147
- }
2148
- (!u || u.matches) && (o.listContainer && e.watchChildList(o.listContainer), Ye(t, e, n, o));
2149
- });
2150
- let i = !1;
2151
- return n && (i = Ge(t, e, n)), r || i;
2152
- }
2153
- function Qn(e, t, n) {
2154
- const s = e.key, r = E.getInstance(s);
2155
- if (r) {
2156
- const { triggers: i = [] } = r?.get(s) || {};
2157
- i.forEach((o, c) => {
2158
- if (o.listContainer !== t)
2159
- return;
2160
- const u = $(o.conditions, r.dataCache.conditions);
2161
- if (u) {
2162
- const l = `${s}::listTrigger::${t}::${c}`;
2163
- r.setupMediaQueryListener(l, u, s, () => {
2164
- e.update();
2165
- });
2166
- }
2167
- (!u || u.matches) && Ye(s, e, r, o, n);
2168
- }), Ge(s, e, r, t, n);
2169
- }
2170
- }
2171
- function Xn(e, t = !1) {
2172
- const n = e.key, s = E.getInstance(n);
2173
- if (!s)
2174
- return;
2175
- const r = [...s.get(n)?.selectors.values() || []].filter(Boolean).join(",");
2176
- let i;
2177
- r ? (i = [...e.element.querySelectorAll(r)], e.useFirstChild || i.push(e.element)) : i = [e.element], Ke(i), s.deleteController(n, t);
2178
- }
2179
- function Ke(e) {
2180
- const t = Object.values(P);
2181
- for (const n of e)
2182
- for (const s of t)
2183
- s.remove(n);
2184
- }
2185
- const ie = "interactEffect";
2186
- class Un {
2187
- element;
2188
- key;
2189
- connected;
2190
- sheet;
2191
- useFirstChild;
2192
- _observers;
2193
- constructor(t, n, s) {
2194
- this.element = t, this.key = n, this.connected = !1, this.sheet = null, this._observers = /* @__PURE__ */ new WeakMap(), this.useFirstChild = s?.useFirstChild ?? !1;
2195
- }
2196
- connect(t) {
2197
- if (this.connected)
2198
- return;
2199
- const n = this.element.dataset.interactKey;
2200
- if (t = t || this.key || n, !t) {
2201
- console.warn("Interact: No key provided");
2202
- return;
2203
- }
2204
- n !== t && (n && console.warn(
2205
- `Interact: Key mismatch between element ${n} and parameter ${t}, updating element key`
2206
- ), this.element.dataset.interactKey = t), this.key = t, this.connected = Bn(this);
2207
- }
2208
- disconnect({ removeFromCache: t = !1 } = {}) {
2209
- if ((this.key || this.element.dataset.interactKey) && Xn(this, t), this.sheet) {
2210
- const s = document.adoptedStyleSheets.indexOf(this.sheet);
2211
- document.adoptedStyleSheets.splice(s, 1);
2212
- }
2213
- this._observers = /* @__PURE__ */ new WeakMap(), this.sheet = null, this.connected = !1;
2214
- }
2215
- update() {
2216
- this.disconnect(), this.connect();
2217
- }
2218
- renderStyle(t) {
2219
- if (!this.sheet)
2220
- this.sheet = new CSSStyleSheet(), this.sheet.replaceSync(t.join(`
2221
- `)), document.adoptedStyleSheets.push(this.sheet);
2222
- else {
2223
- let n = this.sheet.cssRules.length;
2224
- for (const s of t)
2225
- try {
2226
- this.sheet.insertRule(s, n), n++;
2227
- } catch (r) {
2228
- console.error(r);
2229
- }
2230
- }
2231
- }
2232
- toggleEffect(t, n, s, r) {
2233
- if (s === null)
2234
- return;
2235
- if (!r && this.element.toggleEffect) {
2236
- this.element.toggleEffect(t, n, s);
2237
- return;
2238
- }
2239
- const i = new Set(
2240
- this.element.dataset[ie]?.split(" ") || []
2241
- );
2242
- n === "toggle" ? i.has(t) ? i.delete(t) : i.add(t) : n === "add" ? i.add(t) : n === "remove" ? i.delete(t) : n === "clear" && i.clear(), (s || this.element).dataset[ie] = Array.from(i).join(" ");
2243
- }
2244
- getActiveEffects() {
2245
- const n = (this.element.dataset[ie] || "").trim();
2246
- return n ? n.split(/\s+/) : [];
2247
- }
2248
- watchChildList(t) {
2249
- const n = this.element.querySelector(t);
2250
- if (n) {
2251
- let s = this._observers.get(n);
2252
- s || (s = new MutationObserver(this._childListChangeHandler.bind(this, t)), this._observers.set(n, s), s.observe(n, { childList: !0 }));
2253
- }
2254
- }
2255
- _childListChangeHandler(t, n) {
2256
- const s = this.key || this.element.dataset.interactKey, r = [], i = [];
2257
- n.forEach((o) => {
2258
- o.removedNodes.forEach((c) => {
2259
- c instanceof HTMLElement && r.push(c);
2260
- }), o.addedNodes.forEach((c) => {
2261
- c instanceof HTMLElement && i.push(c);
2262
- });
2263
- }), Ke(r), s && Qn(this, t, i);
2264
- }
2265
- }
2266
- function ns(e, t) {
2267
- new Un(e, t).connect();
2268
- }
2269
- function ss(e) {
2270
- const t = E.getController(e);
2271
- t && t.disconnect({ removeFromCache: !0 });
2272
- }
2273
- const Jn = (e, t, n, s) => {
2274
- let i = `[data-interact-key="${e.replace(/"/g, "'")}"]`;
2275
- const o = J(t, { asCombinator: !0, useFirstChild: s });
2276
- return o && (i = `${i} ${o}`), n && (i = j(i, n)), i;
2277
- };
2278
- function is(e, t = !1) {
2279
- const n = [], s = /* @__PURE__ */ new Set();
2280
- return e.interactions.forEach(
2281
- ({
2282
- key: r,
2283
- selector: i,
2284
- listContainer: o,
2285
- listItemSelector: c,
2286
- trigger: u,
2287
- params: l,
2288
- effects: a,
2289
- conditions: f
2290
- }) => {
2291
- if (u === "viewEnter") {
2292
- const v = l;
2293
- (!v?.type || v.type === "once") && a.forEach((h) => {
2294
- const g = h?.effectId && e.effects[h.effectId] || h, {
2295
- key: y,
2296
- selector: p,
2297
- listContainer: w,
2298
- listItemSelector: b,
2299
- conditions: T
2300
- } = g;
2301
- if (!(!y || y === r) || !(!p && !i || p === i) || !(!w && !o || w === o) || !(!b && !c || b === c)) return;
2302
- const me = e.conditions || {}, ge = Q(
2303
- T,
2304
- me
2305
- ), ee = Q(
2306
- f,
2307
- me
2308
- );
2309
- if (!(!ge && !ee || ge === ee)) return;
2310
- const te = Jn(
2311
- r,
2312
- g,
2313
- ee,
2314
- t
2315
- );
2316
- s.has(te) || (s.add(te), n.push(`@media (prefers-reduced-motion: no-preference) {
2317
- ${te}:not([data-interact-enter]) {
2318
- visibility: hidden;
2319
- transform: none;
2320
- translate: none;
2321
- scale: none;
2322
- rotate: none;
2323
- }
2324
- }`));
2325
- });
2326
- }
2327
- }
2328
- ), n.join(`
2329
- `);
2330
- }
2331
- export {
2332
- Un as I,
2333
- E as a,
2334
- ns as b,
2335
- is as g,
2336
- ss as r
2337
- };
2338
- //# sourceMappingURL=index-BfcN_rkn.mjs.map