@ssgoi/core 7.2.0 → 7.3.0-beta.2

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 (61) hide show
  1. package/dist/animation/animation.d.ts +21 -0
  2. package/dist/animation/animation.d.ts.map +1 -1
  3. package/dist/animation/host-animation.d.ts +28 -19
  4. package/dist/animation/host-animation.d.ts.map +1 -1
  5. package/dist/animation/multi-animation.d.ts +13 -2
  6. package/dist/animation/multi-animation.d.ts.map +1 -1
  7. package/dist/animation/web-animation.d.ts +76 -4
  8. package/dist/animation/web-animation.d.ts.map +1 -1
  9. package/dist/animation/web-presentation.d.ts +25 -0
  10. package/dist/animation/web-presentation.d.ts.map +1 -0
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.d.ts +4 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +1206 -1184
  15. package/dist/internal.cjs +1 -1
  16. package/dist/internal.js +924 -631
  17. package/dist/{page-motion-MEazegOU.js → page-motion-CoPTk-Gd.js} +1 -1
  18. package/dist/{page-motion-DF3fFkOw.cjs → page-motion-Dhj3UfzO.cjs} +1 -1
  19. package/dist/provider-BLf6XeXT.js +291 -0
  20. package/dist/provider-JDtJ5Jzf.cjs +1 -0
  21. package/dist/retain-opacity-C5ajTKSI.cjs +1 -0
  22. package/dist/retain-opacity-ChyA_fg_.js +1142 -0
  23. package/dist/runtime/index.d.ts +1 -0
  24. package/dist/runtime/index.d.ts.map +1 -1
  25. package/dist/runtime/motion-matching.d.ts +31 -0
  26. package/dist/runtime/motion-matching.d.ts.map +1 -0
  27. package/dist/runtime/timeline.d.ts +6 -2
  28. package/dist/runtime/timeline.d.ts.map +1 -1
  29. package/dist/runtime.cjs +1 -1
  30. package/dist/runtime.js +29 -25
  31. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  32. package/dist/transitions/blind/transition.d.ts.map +1 -1
  33. package/dist/transitions/crossfade.d.ts +1 -6
  34. package/dist/transitions/crossfade.d.ts.map +1 -1
  35. package/dist/transitions/film/transition.d.ts.map +1 -1
  36. package/dist/transitions/hero/in-place.d.ts +5 -2
  37. package/dist/transitions/hero/in-place.d.ts.map +1 -1
  38. package/dist/transitions/hero/provider/chrome/fade.d.ts.map +1 -1
  39. package/dist/transitions/hero/provider/chrome/static.d.ts.map +1 -1
  40. package/dist/transitions/hero/transition.d.ts.map +1 -1
  41. package/dist/transitions/hero/types.d.ts +2 -1
  42. package/dist/transitions/hero/types.d.ts.map +1 -1
  43. package/dist/transitions/shared-visibility.d.ts +2 -0
  44. package/dist/transitions/shared-visibility.d.ts.map +1 -0
  45. package/dist/transitions/sheet/transition.d.ts.map +1 -1
  46. package/dist/transitions/zoom/crossfade.d.ts.map +1 -1
  47. package/dist/transitions/zoom/provider/blur.d.ts.map +1 -1
  48. package/dist/transitions/zoom/transition.d.ts.map +1 -1
  49. package/dist/transitions/zoom/types.d.ts +2 -1
  50. package/dist/transitions/zoom/types.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +4 -0
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/utils/index.d.ts +1 -0
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/retain-opacity.d.ts +7 -0
  56. package/dist/utils/retain-opacity.d.ts.map +1 -0
  57. package/package.json +1 -1
  58. package/dist/multi-animation-Du9W3ZS_.js +0 -503
  59. package/dist/multi-animation-hDUcfD7W.cjs +0 -1
  60. package/dist/provider-Cea0Pfm1.js +0 -232
  61. package/dist/provider-D9Q2URox.cjs +0 -1
@@ -0,0 +1,1142 @@
1
+ var ht = Object.defineProperty;
2
+ var ct = (s, r, t) => r in s ? ht(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
3
+ var h = (s, r, t) => ct(s, typeof r != "symbol" ? r + "" : r, t);
4
+ import { A as ut, c as K, a as dt, r as pt, i as ft, s as mt, I as gt } from "./provider-BLf6XeXT.js";
5
+ const j = {
6
+ reason: "finished",
7
+ owns: () => !0
8
+ };
9
+ class st extends ut {
10
+ constructor() {
11
+ super(...arguments);
12
+ h(this, "_startCondition");
13
+ /** Resource cleanup is separate from successfully reaching the authored goal. */
14
+ h(this, "onDispose");
15
+ /** A composite retains child resources until all participating motion settles. */
16
+ h(this, "deferDisposal", !1);
17
+ }
18
+ /** Custom wrappers can expose their web tracks without host type checks. */
19
+ getMotionTracks() {
20
+ return [];
21
+ }
22
+ /** Validate authored scheduling before a host transfers ownership. */
23
+ validate() {
24
+ }
25
+ /** Opaque custom drivers retain the explicit legacy finish-on-interrupt fallback. */
26
+ get supportsInterruption() {
27
+ return !1;
28
+ }
29
+ /** Invalidate execution without disposing its retained resources. */
30
+ stop() {
31
+ this.pause();
32
+ }
33
+ /** Stop without seeking to an endpoint. Built-in drivers override this. */
34
+ cancel(t) {
35
+ var e;
36
+ this.isComplete || this.complete(), (e = this.onDispose) == null || e.call(this, t);
37
+ }
38
+ /** Scheduling metadata read by the parent immediately before playback. */
39
+ get startCondition() {
40
+ return this._startCondition;
41
+ }
42
+ /** Retune this animation before playback; omitted values stay unchanged. */
43
+ set(t) {
44
+ if (t.startAt) {
45
+ const { after: e, at: i } = t.startAt;
46
+ if (e === this)
47
+ throw new Error("An animation cannot start after itself");
48
+ if (i !== "settled" && (!Number.isFinite(i) || i < 0 || i > 1))
49
+ throw new Error("startAt.at must be a progress from 0 to 1 or settled");
50
+ }
51
+ if (t.integrator !== void 0) {
52
+ if (typeof t.integrator.step != "function" || typeof t.integrator.isSettled != "function")
53
+ throw new Error("An integrator must implement step and isSettled");
54
+ this.setIntegrator(t.integrator);
55
+ }
56
+ return t.startAt !== void 0 && (this._startCondition = t.startAt ? { ...t.startAt } : void 0), this;
57
+ }
58
+ /** Custom drivers can opt into physics editing by implementing this method. */
59
+ setIntegrator(t) {
60
+ throw new Error("This animation does not support replacing its integrator");
61
+ }
62
+ }
63
+ const H = [1, 0, 0, 1, 0, 0], it = (s, r) => [
64
+ s[0] * r[0] + s[2] * r[1],
65
+ s[1] * r[0] + s[3] * r[1],
66
+ s[0] * r[2] + s[2] * r[3],
67
+ s[1] * r[2] + s[3] * r[3],
68
+ s[0] * r[4] + s[2] * r[5] + s[4],
69
+ s[1] * r[4] + s[3] * r[5] + s[5]
70
+ ];
71
+ function G(s) {
72
+ const r = s[0] * s[3] - s[1] * s[2];
73
+ return Math.abs(r) < 1e-10 ? null : [
74
+ s[3] / r,
75
+ -s[1] / r,
76
+ -s[2] / r,
77
+ s[0] / r,
78
+ (s[2] * s[5] - s[3] * s[4]) / r,
79
+ (s[1] * s[4] - s[0] * s[5]) / r
80
+ ];
81
+ }
82
+ const I = (s, r) => [1, 0, 0, 1, s, r], U = (s, r) => [s, 0, 0, r, 0, 0];
83
+ function yt(s, r, t) {
84
+ if (!s || s === "none") return [...H];
85
+ let e = [...H];
86
+ const i = /([a-zA-Z][a-zA-Z0-9]*)\(([^()]*)\)/g;
87
+ let a = "";
88
+ for (const c of s.matchAll(i)) {
89
+ a += c[0];
90
+ const d = c[1].toLowerCase(), u = c[2].trim().split(/\s*,\s*|\s+/);
91
+ if (u.some(
92
+ (n) => !/^[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?(?:px|%|deg|rad|turn)?$/i.test(
93
+ n
94
+ )
95
+ ))
96
+ return null;
97
+ const m = u.map(Number.parseFloat);
98
+ if (m.some((n) => !Number.isFinite(n))) return null;
99
+ const g = (n, y) => {
100
+ var o;
101
+ return m[n] * ((o = u[n]) != null && o.endsWith("%") ? y / 100 : 1);
102
+ }, p = (n) => {
103
+ var y, o;
104
+ return m[n] * ((y = u[n]) != null && y.endsWith("rad") ? 1 : (o = u[n]) != null && o.endsWith("turn") ? 2 * Math.PI : Math.PI / 180);
105
+ };
106
+ let l;
107
+ if (d === "matrix" && m.length === 6) l = m;
108
+ else if (d === "translate" || d === "translate3d") {
109
+ if (d === "translate3d" && m[2] !== 0) return null;
110
+ l = I(g(0, r), u[1] ? g(1, t) : 0);
111
+ } else if (d === "translatex") l = I(g(0, r), 0);
112
+ else if (d === "translatey") l = I(0, g(0, t));
113
+ else if (d === "translatez" && m[0] === 0) l = [...H];
114
+ else if (d === "scale") l = U(m[0], m[1] ?? m[0]);
115
+ else if (d === "scalex") l = U(m[0], 1);
116
+ else if (d === "scaley") l = U(1, m[0]);
117
+ else if (d === "rotate" || d === "rotatez") {
118
+ const n = p(0);
119
+ l = [Math.cos(n), Math.sin(n), -Math.sin(n), Math.cos(n), 0, 0];
120
+ } else return null;
121
+ e = it(e, l);
122
+ }
123
+ return a.replace(/\s/g, "") === s.replace(/\s/g, "") ? e : null;
124
+ }
125
+ function J(s, r) {
126
+ return { schema: s, value: r, velocity: r.map(() => 0) };
127
+ }
128
+ const Q = /[-+]?(?:\d*\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/gi, M = (s) => [
129
+ s[0],
130
+ s[2],
131
+ s[4],
132
+ s[1],
133
+ s[3],
134
+ s[5],
135
+ 0,
136
+ 0,
137
+ 1
138
+ ];
139
+ function B(s, r) {
140
+ return Array.from({ length: 9 }, (t, e) => {
141
+ const i = Math.floor(e / 3), a = e % 3;
142
+ return s[i * 3] * r[a] + s[i * 3 + 1] * r[a + 3] + s[i * 3 + 2] * r[a + 6];
143
+ });
144
+ }
145
+ function rt(s) {
146
+ return Math.abs(s[8]) < 1e-8 || !s.every(Number.isFinite) ? null : s.map((r) => r / s[8]);
147
+ }
148
+ function tt(s, r, t) {
149
+ const e = yt(s, r, t);
150
+ if (e) return M(e);
151
+ if (typeof DOMMatrix > "u") return null;
152
+ const i = s.replace(
153
+ /(translate(?:3d|X|Y)?)\(([^()]*)\)/gi,
154
+ (a, c, d) => {
155
+ const u = d.split(/\s*,\s*|\s+/).map((m, g) => {
156
+ if (!m.endsWith("%")) return m;
157
+ const p = c.toLowerCase() === "translatey" || g === 1 ? t : r;
158
+ return `${Number.parseFloat(m) * p / 100}px`;
159
+ });
160
+ return `${c}(${u.join(",")})`;
161
+ }
162
+ );
163
+ try {
164
+ const a = new DOMMatrix(i);
165
+ return rt([
166
+ a.m11,
167
+ a.m21,
168
+ a.m41,
169
+ a.m12,
170
+ a.m22,
171
+ a.m42,
172
+ a.m14,
173
+ a.m24,
174
+ a.m44
175
+ ]);
176
+ } catch {
177
+ return null;
178
+ }
179
+ }
180
+ const et = "viewport-plane-v1";
181
+ function $(s) {
182
+ var w;
183
+ const r = s.offsetWidth || 1, t = s.offsetHeight || 1, e = typeof getComputedStyle == "function" ? getComputedStyle(s) : null, i = ((e == null ? void 0 : e.transformOrigin) || `${r / 2}px ${t / 2}px`).split(" "), a = Number.parseFloat(i[0]) || 0, c = Number.parseFloat(i[1]) || 0;
184
+ let d = !0;
185
+ if (typeof getComputedStyle == "function")
186
+ for (let C = s.parentElement; C; C = C.parentElement) {
187
+ const S = getComputedStyle(C);
188
+ if (S.transform && S.transform !== "none" || S.perspective && S.perspective !== "none") {
189
+ d = !1;
190
+ break;
191
+ }
192
+ }
193
+ const u = (w = s.getBoundingClientRect) == null ? void 0 : w.call(s), m = tt((e == null ? void 0 : e.transform) || "", r, t) ?? M(H), g = B(
194
+ B(M(I(a, c)), m),
195
+ M(I(-a, -c))
196
+ ), p = [
197
+ [0, 0],
198
+ [r, 0],
199
+ [0, t],
200
+ [r, t]
201
+ ].map(([C, S]) => {
202
+ const F = g[6] * C + g[7] * S + g[8];
203
+ return [
204
+ (g[0] * C + g[1] * S + g[2]) / F,
205
+ (g[3] * C + g[4] * S + g[5]) / F
206
+ ];
207
+ }), l = ((u == null ? void 0 : u.left) ?? 0) - Math.min(...p.map((C) => C[0])), n = ((u == null ? void 0 : u.top) ?? 0) - Math.min(...p.map((C) => C[1])), y = I(l + a, n + c), o = it(I(-a, -c), U(r, t)), f = M(G(y)), b = M(G(o));
208
+ return {
209
+ frame: d ? { left: l, top: n, width: r, height: t } : void 0,
210
+ read(C) {
211
+ const S = {};
212
+ for (const [F, A] of Object.entries(C)) {
213
+ const k = String(A);
214
+ if (F === "transform") {
215
+ if (!d) continue;
216
+ const R = tt(k, r, t), x = R && rt(B(B(M(y), R), M(o)));
217
+ if (x) {
218
+ const [q, N, T, O, V, P, E, v] = x, W = q - T * E, z = O - P * E, Z = N - T * v, Y = V - P * v, L = Math.hypot(W, z);
219
+ if (L > 1e-8) {
220
+ S[F] = J(et, [
221
+ T,
222
+ P,
223
+ Math.atan2(z, W),
224
+ L,
225
+ (W * Y - z * Z) / L,
226
+ (W * Z + z * Y) / L,
227
+ E,
228
+ v
229
+ ]);
230
+ continue;
231
+ }
232
+ }
233
+ }
234
+ const _ = [...k.matchAll(Q)].map(
235
+ (R) => Number(R[0])
236
+ );
237
+ _.length && _.every(Number.isFinite) && (S[F] = J(
238
+ `css:${k.replace(Q, "#")}`,
239
+ _
240
+ ));
241
+ }
242
+ return S;
243
+ },
244
+ write(C) {
245
+ const S = {};
246
+ for (const [F, A] of Object.entries(C))
247
+ if (F === "transform" && A.schema === et) {
248
+ const [k, _, R, x, q, N, T, O] = A.value, V = Math.cos(R), P = Math.sin(R), E = [
249
+ V * x + k * T,
250
+ V * N - P * q + k * O,
251
+ k,
252
+ P * x + _ * T,
253
+ P * N + V * q + _ * O,
254
+ _,
255
+ T,
256
+ O,
257
+ 1
258
+ ], v = B(B(f, E), b);
259
+ Math.abs(v[6]) + Math.abs(v[7]) < 1e-10 && Math.abs(v[8] - 1) < 1e-10 ? S[F] = `matrix(${[v[0], v[3], v[1], v[4], v[2], v[5]].join(",")})` : S[F] = `matrix3d(${[v[0], v[3], 0, v[6], v[1], v[4], 0, v[7], 0, 0, 1, 0, v[2], v[5], 0, v[8]].join(",")})`;
260
+ } else if (A.schema.startsWith("css:")) {
261
+ let k = 0;
262
+ S[F] = A.schema.slice(4).replace(/#/g, () => String(A.value[k++]));
263
+ }
264
+ return S;
265
+ }
266
+ };
267
+ }
268
+ const vt = 1e3 / 60, nt = 1e3 / 30, bt = nt + 1;
269
+ class St {
270
+ constructor() {
271
+ h(this, "drivers", /* @__PURE__ */ new Set());
272
+ h(this, "observers", /* @__PURE__ */ new Set());
273
+ h(this, "frameRequest", null);
274
+ h(this, "previousTimestamp", null);
275
+ h(this, "tick", (r) => {
276
+ this.frameRequest = null;
277
+ const t = this.previousTimestamp === null ? vt : Math.max(0, r - this.previousTimestamp);
278
+ this.previousTimestamp = r;
279
+ const e = {
280
+ delta: Math.min(t, nt),
281
+ rawDelta: t
282
+ };
283
+ this.runPhase(this.drivers, e), this.runPhase(this.observers, e), this.hasCallbacks() ? this.requestFrame() : this.previousTimestamp = null;
284
+ });
285
+ }
286
+ subscribe(r, t = "drive") {
287
+ const e = t === "drive" ? this.drivers : this.observers;
288
+ return e.add(r), this.requestFrame(), () => {
289
+ e.delete(r), this.stopIfIdle();
290
+ };
291
+ }
292
+ requestFrame() {
293
+ this.frameRequest !== null || !this.hasCallbacks() || (this.frameRequest = requestAnimationFrame(this.tick));
294
+ }
295
+ runPhase(r, t) {
296
+ for (const e of [...r])
297
+ r.has(e) && e(t);
298
+ }
299
+ hasCallbacks() {
300
+ return this.drivers.size > 0 || this.observers.size > 0;
301
+ }
302
+ stopIfIdle() {
303
+ this.hasCallbacks() || (this.frameRequest !== null && typeof cancelAnimationFrame < "u" && cancelAnimationFrame(this.frameRequest), this.frameRequest = null, this.previousTimestamp = null);
304
+ }
305
+ }
306
+ const at = new St(), Ct = 2;
307
+ class ot extends st {
308
+ constructor(t) {
309
+ super();
310
+ h(this, "_element");
311
+ h(this, "_integrator");
312
+ /** Role label, see `WebAnimationOptions.label`. */
313
+ h(this, "label");
314
+ h(this, "styleFn");
315
+ h(this, "lowerBound");
316
+ h(this, "upperBound");
317
+ h(this, "currentValue");
318
+ h(this, "currentVelocity", 0);
319
+ h(this, "solverState");
320
+ h(this, "solverTarget", 1);
321
+ h(this, "presentationTime", 0);
322
+ h(this, "renderedStyles", []);
323
+ h(this, "frames", []);
324
+ h(this, "waapi", null);
325
+ h(this, "runId", 0);
326
+ h(this, "waitingForStart", !1);
327
+ h(this, "startReady", !1);
328
+ h(this, "pendingFirstFrame");
329
+ h(this, "stopStartupClock", null);
330
+ h(this, "startupStableFrames", 0);
331
+ h(this, "running", !1);
332
+ h(this, "paused", !1);
333
+ h(this, "settled", !1);
334
+ h(this, "reversing", !1);
335
+ h(this, "disposed", !1);
336
+ h(this, "legacyCompletionCleanup");
337
+ h(this, "motion");
338
+ h(this, "codec");
339
+ h(this, "adopted");
340
+ h(this, "presentationFrames", []);
341
+ h(this, "hold", null);
342
+ h(this, "fallbackCopy", null);
343
+ h(this, "fallbackChannels", /* @__PURE__ */ new Set());
344
+ h(this, "fallbackMode");
345
+ this._element = t.element, this._integrator = t.integrator, this.label = t.label, this.styleFn = t.style, this.lowerBound = t.lowerBound ?? 0, this.upperBound = t.upperBound ?? 1, this.currentValue = this.lowerBound, this.onUpdate = t.onUpdate, this.legacyCompletionCleanup = !!t.onComplete && !t.onDispose, this.onComplete = t.onComplete, this.onDispose = t.onDispose, this.motion = t.motion ?? {};
346
+ }
347
+ get handoffFallbackMode() {
348
+ return this.fallbackMode;
349
+ }
350
+ get handoffFallbacks() {
351
+ return [...this.fallbackChannels];
352
+ }
353
+ /** The DOM node this track drives. */
354
+ get element() {
355
+ return this._element;
356
+ }
357
+ /**
358
+ * Physics that drives this track. Read lazily at `play()` / `reverse()`
359
+ * (the simulation runs then), so replacing it before playback takes effect
360
+ * for the next run — this is what `withOverride` relies on.
361
+ */
362
+ get integrator() {
363
+ return this._integrator;
364
+ }
365
+ set integrator(t) {
366
+ this._integrator = t, this.solverState = void 0;
367
+ }
368
+ setIntegrator(t) {
369
+ this._integrator = t, this.solverState = void 0;
370
+ }
371
+ play() {
372
+ var e;
373
+ const t = this.reversing;
374
+ if (this.reversing = !1, this.paused && this.waapi && !t) {
375
+ if (this.paused = !1, this.running = !0, this.waitingForStart) {
376
+ this.startReady && this.startFramePacedPlayback(this.waapi);
377
+ return;
378
+ }
379
+ this.waapi.play(), (e = this.fallbackCopy) == null || e.play();
380
+ return;
381
+ }
382
+ this.runToward(this.upperBound);
383
+ }
384
+ reverse() {
385
+ this.reversing = !0, this.runToward(this.lowerBound);
386
+ }
387
+ pause() {
388
+ var t, e, i;
389
+ this.running && (this.captureLiveState(), (t = this.waapi) == null || t.pause(), (e = this.fallbackCopy) == null || e.pause(), (i = this.stopStartupClock) == null || i.call(this), this.stopStartupClock = null, this.running = !1, this.paused = !0);
390
+ }
391
+ complete() {
392
+ this.settled || (this.clearWaapi(), this.running = !1, this.paused = !1, this.currentValue = this.upperBound, this.currentVelocity = 0, this.applyStyleAt(this.currentValue), this.settled = !0, this.finish());
393
+ }
394
+ validate() {
395
+ const t = this.motion.handoffDuration ?? 280;
396
+ if (!Number.isFinite(t) || t < 0 || t > 1e4)
397
+ throw new Error(
398
+ "handoffDuration must be finite and between 0 and 10000 ms"
399
+ );
400
+ }
401
+ getMotionTracks() {
402
+ return [this];
403
+ }
404
+ get supportsInterruption() {
405
+ return !this.legacyCompletionCleanup;
406
+ }
407
+ stop() {
408
+ var t, e;
409
+ this.captureLiveState(), this.clearWaapi(), (t = this.hold) == null || t.cancel(), this.hold = null, (e = this.fallbackCopy) == null || e.cancel({ reason: "disposed", owns: () => !0 }), this.fallbackCopy = null, this.running = !1, this.paused = !1;
410
+ }
411
+ cancel(t) {
412
+ this.stop(), this.disposeResources(t);
413
+ }
414
+ disposeResources(t) {
415
+ var e;
416
+ if (!this.disposed && (this.disposed = !0, t.owns(this.element)))
417
+ try {
418
+ (e = this.onDispose) == null || e.call(this, t);
419
+ } catch (i) {
420
+ console.error("[ssgoi] animation cleanup failed", i);
421
+ }
422
+ }
423
+ finish() {
424
+ var t, e, i, a;
425
+ this.presentationTime = ((t = this.frames[this.frames.length - 1]) == null ? void 0 : t.time) ?? 0, this.solverState = void 0, (e = this.hold) == null || e.cancel(), this.hold = null, this.applyStyleAt(this.currentValue), this.clearWaapi(), (i = this.fallbackCopy) == null || i.cancel({ reason: "disposed", owns: () => !0 }), this.fallbackCopy = null, this.deferDisposal || this.disposeResources(j), (a = this.onComplete) == null || a.call(this);
426
+ }
427
+ get motionIdentity() {
428
+ return {
429
+ target: this.element,
430
+ key: this.motion.key,
431
+ role: this.motion.role,
432
+ space: this.motion.space,
433
+ lifetime: this.motion.lifetime
434
+ };
435
+ }
436
+ /** Final output, including any earlier residual, is the next handoff's source. */
437
+ getMotionSnapshot() {
438
+ var a, c;
439
+ this.running && this.captureLiveState();
440
+ const t = this.samplePresentation(
441
+ D(this.waapi) ?? this.presentationTime
442
+ ), e = this.paused || this.waitingForStart && !D(this.waapi) ? 0 : this.playbackRate, i = {
443
+ ...this.styleFn(
444
+ this.currentValue,
445
+ this.lowerBound + this.upperBound - this.currentValue
446
+ ),
447
+ ...(a = this.codec) == null ? void 0 : a.write(t)
448
+ };
449
+ return {
450
+ ...this.motionIdentity,
451
+ displayStyle: i,
452
+ inlineStyle: this.element.style.cssText,
453
+ frame: (c = this.codec) == null ? void 0 : c.frame,
454
+ channels: Object.fromEntries(
455
+ Object.entries(t).map(([d, u]) => [
456
+ d,
457
+ {
458
+ ...u,
459
+ velocity: u.velocity.map((m) => m * e)
460
+ }
461
+ ])
462
+ )
463
+ };
464
+ }
465
+ adopt(t) {
466
+ var d, u, m, g, p;
467
+ this.codec ?? (this.codec = this.motion.codec ?? $(this.element)), this.adopted = t;
468
+ const e = this.codec.read({
469
+ transform: "none",
470
+ opacity: 1,
471
+ ...this.styleFn(
472
+ this.currentValue,
473
+ this.lowerBound + this.upperBound - this.currentValue
474
+ )
475
+ });
476
+ this.fallbackChannels.clear(), this.fallbackMode = void 0;
477
+ const i = this.styleFn(
478
+ this.currentValue,
479
+ this.lowerBound + this.upperBound - this.currentValue
480
+ ), a = t.displayStyle;
481
+ for (const [l, n] of Object.entries(a ?? {}))
482
+ l in i && String(n) !== String(i[l]) && (!t.channels[l] || !e[l]) && this.fallbackChannels.add(l);
483
+ for (const [l, n] of Object.entries(t.channels)) {
484
+ const y = e[l];
485
+ y && !K(n, y) && this.fallbackChannels.add(l);
486
+ }
487
+ if (this.fallbackChannels.size && (this.fallbackMode = "finish"), this.fallbackChannels.size && this.motion.fallback !== "finish") {
488
+ const l = t;
489
+ if (l.frame && l.displayStyle && t.target.cloneNode && t.target.parentElement && !t.target.shadowRoot && !((u = (d = t.target).matches) != null && u.call(
490
+ d,
491
+ "canvas, video, audio, iframe, object, embed"
492
+ )) && !((g = (m = t.target).querySelector) != null && g.call(
493
+ m,
494
+ "canvas, video, audio, iframe, object, embed"
495
+ ))) {
496
+ this.fallbackMode = "crossfade";
497
+ const n = t.target.cloneNode(!0);
498
+ n.removeAttribute("id"), n.removeAttribute("data-ssgoi-transition");
499
+ for (const o of n.querySelectorAll(
500
+ "[id], [data-ssgoi-transition]"
501
+ ))
502
+ o.removeAttribute("id"), o.removeAttribute("data-ssgoi-transition");
503
+ n.style.cssText = l.inlineStyle ?? "", Object.assign(n.style, l.displayStyle, {
504
+ position: "fixed",
505
+ left: `${l.frame.left}px`,
506
+ top: `${l.frame.top}px`,
507
+ width: `${l.frame.width}px`,
508
+ height: `${l.frame.height}px`,
509
+ margin: "0",
510
+ pointerEvents: "none",
511
+ zIndex: "2147483646"
512
+ }), n.setAttribute("aria-hidden", "true"), n.inert = !0, t.target.parentElement.appendChild(n);
513
+ const y = Number(l.displayStyle.opacity ?? 1);
514
+ this.fallbackCopy = new ot({
515
+ element: n,
516
+ integrator: {
517
+ step: (o, f, b) => ({
518
+ position: Math.min(f, o.position + b / 0.18),
519
+ velocity: 0
520
+ }),
521
+ isSettled: (o, f) => o.position >= f
522
+ },
523
+ style: (o, f) => ({ opacity: y * f }),
524
+ onDispose: () => n.remove()
525
+ }), this.adopted = {
526
+ ...t,
527
+ channels: {
528
+ ...t.channels,
529
+ opacity: { schema: "css:#", value: [0], velocity: [0] }
530
+ }
531
+ };
532
+ }
533
+ }
534
+ const c = this.codec.write(this.adopted.channels);
535
+ (p = this.hold) == null || p.cancel(), Object.keys(c).length && (this.hold = this.element.animate([c], {
536
+ duration: 1,
537
+ fill: "both"
538
+ }), this.hold.pause(), this.hold.currentTime = 0);
539
+ }
540
+ /** Presentation channels of frame `index`, corrected when a handoff applied. */
541
+ channelsAt(t) {
542
+ const e = this.presentationFrames[t];
543
+ if (e) return e.channels;
544
+ const i = this.frames[t];
545
+ return this.codec ?? (this.codec = this.motion.codec ?? $(this.element)), this.codec.read({
546
+ transform: "none",
547
+ opacity: 1,
548
+ ...this.styleFn(
549
+ i.position,
550
+ this.lowerBound + this.upperBound - i.position
551
+ )
552
+ });
553
+ }
554
+ samplePresentation(t) {
555
+ const e = this.frames;
556
+ if (!e.length)
557
+ return this.adopted ? { ...this.adopted.channels } : (this.codec ?? (this.codec = this.motion.codec ?? $(this.element)), this.codec.read({
558
+ transform: "none",
559
+ opacity: 1,
560
+ ...this.styleFn(
561
+ this.currentValue,
562
+ this.lowerBound + this.upperBound - this.currentValue
563
+ )
564
+ }));
565
+ let i = e.findIndex((n) => n.time > t);
566
+ i < 0 && (i = e.length - 1);
567
+ const a = Math.max(0, i - 1), c = e[a], d = e[i], u = this.channelsAt(a), m = a === i ? u : this.channelsAt(i), g = (d.time - c.time) / 1e3, p = g ? Math.max(0, Math.min(1, (t - c.time) / (g * 1e3))) : 0, l = {};
568
+ for (const [n, y] of Object.entries(u)) {
569
+ const o = m[n];
570
+ if (!o || !K(y, o)) {
571
+ l[n] = y;
572
+ continue;
573
+ }
574
+ l[n] = {
575
+ schema: y.schema,
576
+ value: y.value.map((f, b) => f + (o.value[b] - f) * p),
577
+ velocity: y.value.map(
578
+ (f, b) => t >= e[e.length - 1].time || !g ? 0 : (o.value[b] - f) / g
579
+ )
580
+ };
581
+ }
582
+ return l;
583
+ }
584
+ /**
585
+ * Drop the WAAPI forwards-fill after the run has settled, letting inline
586
+ * styles govern the resting visual. Call only from `onComplete` (the run is
587
+ * already finished) — otherwise it cancels mid-flight. Unlike `complete()`,
588
+ * it writes no final frame, so a caller can reset the element to its natural
589
+ * state without the lingering fill clobbering it.
590
+ */
591
+ releaseFill() {
592
+ this.clearWaapi();
593
+ }
594
+ get isAnimating() {
595
+ return this.running;
596
+ }
597
+ get isPaused() {
598
+ return this.paused;
599
+ }
600
+ get isComplete() {
601
+ return this.settled;
602
+ }
603
+ get isReversing() {
604
+ return this.reversing;
605
+ }
606
+ get progress() {
607
+ this.running && this.captureLiveState();
608
+ const t = this.upperBound - this.lowerBound;
609
+ if (t === 0) return 0;
610
+ const e = (this.currentValue - this.lowerBound) / t;
611
+ return e < 0 ? 0 : e > 1 ? 1 : e;
612
+ }
613
+ findTimeForProgress(t) {
614
+ if (this.frames.length < 2) return null;
615
+ const e = this.upperBound - this.lowerBound;
616
+ if (e === 0) return 0;
617
+ for (const i of this.frames)
618
+ if ((i.position - this.lowerBound) / e >= t) return i.time;
619
+ return this.frames[this.frames.length - 1].time;
620
+ }
621
+ get playbackRate() {
622
+ return super.playbackRate;
623
+ }
624
+ set playbackRate(t) {
625
+ super.playbackRate = t, this.waapi && (this.waapi.playbackRate = t);
626
+ }
627
+ getPose() {
628
+ return this.running && this.captureLiveState(), [
629
+ {
630
+ element: this._element,
631
+ value: this.currentValue,
632
+ velocity: this.currentVelocity
633
+ }
634
+ ];
635
+ }
636
+ getTimeline() {
637
+ const t = this.frames.map((e, i) => {
638
+ const a = e.position, c = this.lowerBound + this.upperBound - a;
639
+ return {
640
+ time: e.time,
641
+ value: e.position,
642
+ velocity: e.velocity,
643
+ style: this.renderedStyles[i] ?? this.styleFn(a, c)
644
+ };
645
+ });
646
+ return [{ element: this._element, frames: t }];
647
+ }
648
+ matchInto(t) {
649
+ const e = t.find((i) => i.element === this._element);
650
+ e && (this.currentValue = e.value, this.currentVelocity = e.velocity, this.solverState = void 0);
651
+ }
652
+ /* ───────────────────────────────────────────────────────── private */
653
+ runToward(t) {
654
+ var m, g;
655
+ if (this.validate(), this.running || this.paused) {
656
+ const p = this.getMotionSnapshot();
657
+ this.captureLiveState(), this.adopted = p;
658
+ }
659
+ if (this.clearWaapi(), this.running = !1, this.paused = !1, this.settled = !1, this.disposed = !1, this.presentationTime = 0, this.presentationFrames = [], this.solverTarget = t, this.frames = dt(
660
+ this._integrator,
661
+ this.currentValue,
662
+ t,
663
+ this.currentVelocity,
664
+ this.solverState,
665
+ !0
666
+ ), this.frames.length === 0 && this.adopted && (this.frames = [{ time: 0, position: t, velocity: 0 }]), this.frames.length === 0) {
667
+ this.currentValue = t, this.currentVelocity = 0, this.applyStyleAt(t), this.settled = !0, this.finish();
668
+ return;
669
+ }
670
+ const e = (p) => this.styleFn(p.position, this.lowerBound + this.upperBound - p.position), i = this.adopted ? this.bridgeKeyframes(e) : this.frames.map((p) => e(p));
671
+ this.renderedStyles = i, this.adopted = void 0;
672
+ const a = i[0], c = this.frames[this.frames.length - 1], d = c.time;
673
+ this.runId++;
674
+ const u = this._element.animate(i, {
675
+ duration: d,
676
+ fill: "both",
677
+ easing: "linear",
678
+ composite: "replace"
679
+ });
680
+ u.playbackRate = this.playbackRate, u.currentTime = 0, u.pause(), this.waapi = u, (m = this.fallbackCopy) == null || m.play(), (g = this.hold) == null || g.cancel(), this.hold = null, this.waitingForStart = !0, this.startReady = !0, this.pendingFirstFrame = a, this.running = !0, u.onfinish = () => {
681
+ !this.running || this.waapi !== u || (this.running = !1, this.settled = !0, this.currentValue = c.position, this.currentVelocity = 0, this.finish());
682
+ }, this.startFramePacedPlayback(u);
683
+ }
684
+ /**
685
+ * Bake the residual correction into the keyframes: each authored frame is
686
+ * decoded through the codec, offset by the decaying residual, and encoded
687
+ * back. `presentationFrames` records the corrected output so a later
688
+ * interruption samples what is actually displayed.
689
+ */
690
+ bridgeKeyframes(t) {
691
+ var g;
692
+ this.codec = this.motion.codec ?? $(this.element);
693
+ const e = this.codec, i = Math.max(16, this.motion.handoffDuration ?? 280), a = this.frames[this.frames.length - 1];
694
+ for (let p = a.time + 1e3 / 60; p < i + 1e3 / 60; p += 1e3 / 60)
695
+ this.frames.push({ time: p, position: a.position, velocity: 0 });
696
+ const c = this.frames.map(
697
+ (p) => e.read({ transform: "none", opacity: 1, ...t(p) })
698
+ );
699
+ for (let p = 1; p < c.length; p++) {
700
+ const l = c[p - 1].transform, n = c[p].transform;
701
+ if ((l == null ? void 0 : l.schema) === "viewport-plane-v1" && (n == null ? void 0 : n.schema) === l.schema) {
702
+ const y = [...n.value];
703
+ y[2] = l.value[2] + Math.atan2(
704
+ Math.sin(y[2] - l.value[2]),
705
+ Math.cos(y[2] - l.value[2])
706
+ ), c[p].transform = { ...n, value: y };
707
+ }
708
+ }
709
+ const d = c[0], u = c[1] ?? d, m = {};
710
+ for (const [p, l] of Object.entries(
711
+ ((g = this.adopted) == null ? void 0 : g.channels) ?? {}
712
+ )) {
713
+ let n = d[p];
714
+ if (!n) {
715
+ const o = p === "transform" ? { transform: "none" } : p === "opacity" ? { opacity: 1 } : {};
716
+ if (n = e.read(o)[p], n)
717
+ for (const f of c) f[p] = n;
718
+ }
719
+ if (!n || !K(l, n)) continue;
720
+ const y = u[p] ?? n;
721
+ m[p] = {
722
+ offset: l.value.map((o, f) => {
723
+ let b = o - n.value[f];
724
+ return p === "transform" && l.schema === "viewport-plane-v1" && f === 2 && (b = Math.atan2(Math.sin(b), Math.cos(b))), b;
725
+ }),
726
+ velocity: l.velocity.map(
727
+ (o, f) => o / Math.max(Math.abs(this.playbackRate), 1e-4) - (y.value[f] - n.value[f]) * 60
728
+ )
729
+ };
730
+ }
731
+ return this.presentationFrames = this.frames.map((p, l) => {
732
+ const n = { ...c[l] };
733
+ for (const [y, o] of Object.entries(m)) {
734
+ const f = n[y];
735
+ n[y] = {
736
+ ...f,
737
+ value: f.value.map(
738
+ (b, w) => b + pt(
739
+ o.offset[w],
740
+ o.velocity[w],
741
+ p.time / 1e3,
742
+ i / 1e3
743
+ ).value
744
+ )
745
+ };
746
+ }
747
+ return { time: p.time, channels: n };
748
+ }), this.frames.map((p, l) => {
749
+ const n = this.presentationFrames[l].channels;
750
+ return {
751
+ ...t(p),
752
+ ...e.write(
753
+ Object.fromEntries(
754
+ Object.keys(m).map((y) => [y, n[y]])
755
+ )
756
+ )
757
+ };
758
+ });
759
+ }
760
+ clearWaapi() {
761
+ var t, e;
762
+ this.runId++, (t = this.waapi) == null || t.cancel(), this.waapi = null, this.waitingForStart = !1, this.startReady = !1, this.pendingFirstFrame = void 0, (e = this.stopStartupClock) == null || e.call(this), this.stopStartupClock = null, this.startupStableFrames = 0;
763
+ }
764
+ captureLiveState() {
765
+ if (this.frames.length === 0) return;
766
+ const t = D(this.waapi);
767
+ if (t === null) return;
768
+ this.presentationTime = t;
769
+ const { position: e, velocity: i } = ft(this.frames, t);
770
+ this.currentValue = e, this.currentVelocity = i, this.solverState = mt(
771
+ this.frames,
772
+ t,
773
+ this._integrator,
774
+ this.solverTarget
775
+ );
776
+ }
777
+ startFramePacedPlayback(t) {
778
+ if (!(this.waapi !== t || !this.waitingForStart || !this.startReady || this.stopStartupClock)) {
779
+ if (typeof requestAnimationFrame > "u" || this.playbackRate < 0) {
780
+ this.clearStartStyles(), this.handOffToWaapi(t);
781
+ return;
782
+ }
783
+ this.startupStableFrames = 0, this.stopStartupClock = at.subscribe((e) => {
784
+ this.advanceFramePacedStartup(t, e);
785
+ });
786
+ }
787
+ }
788
+ /**
789
+ * Inline start styles are cleared in the same rendering update as the first
790
+ * seek, after the paused 0 ms WAAPI frame has had its own frame. Clearing
791
+ * earlier can expose the underlying, unanimated style while the animation is
792
+ * still pending.
793
+ */
794
+ clearStartStyles() {
795
+ if (this.pendingFirstFrame)
796
+ for (const t of Object.keys(this.pendingFirstFrame))
797
+ this._element.style[t] = "";
798
+ this.pendingFirstFrame = void 0;
799
+ }
800
+ advanceFramePacedStartup(t, e) {
801
+ if (this.waapi !== t || !this.running || this.paused || !this.waitingForStart)
802
+ return;
803
+ const i = this.frames[this.frames.length - 1];
804
+ if (!i) return;
805
+ const a = D(t) ?? 0, c = Math.min(
806
+ i.time,
807
+ a + e.delta * Math.max(0, this.playbackRate)
808
+ );
809
+ if (t.currentTime = c, this.clearStartStyles(), this.captureLiveState(), c >= i.time) {
810
+ this.finishFramePacedRun(t, i);
811
+ return;
812
+ }
813
+ e.rawDelta <= bt ? this.startupStableFrames++ : this.startupStableFrames = 0, !(this.startupStableFrames < Ct) && this.handOffToWaapi(t);
814
+ }
815
+ handOffToWaapi(t) {
816
+ var c, d;
817
+ if (this.waapi !== t || !this.running || this.paused) return;
818
+ (c = this.stopStartupClock) == null || c.call(this), this.stopStartupClock = null, this.waitingForStart = !1, this.startReady = !1, this.startupStableFrames = 0;
819
+ const e = (d = t.timeline) == null ? void 0 : d.currentTime, i = D(t), a = this.playbackRate;
820
+ if (typeof e == "number" && i !== null && a !== 0) {
821
+ t.startTime = e - i / a;
822
+ return;
823
+ }
824
+ t.play();
825
+ }
826
+ finishFramePacedRun(t, e) {
827
+ var i;
828
+ this.waapi !== t || !this.running || ((i = this.stopStartupClock) == null || i.call(this), this.stopStartupClock = null, this.waitingForStart = !1, this.startReady = !1, this.startupStableFrames = 0, this.running = !1, this.settled = !0, this.currentValue = e.position, this.currentVelocity = 0, this.finish());
829
+ }
830
+ applyStyleAt(t) {
831
+ const e = this.lowerBound + this.upperBound - t, i = this.styleFn(t, e);
832
+ for (const [a, c] of Object.entries(i))
833
+ this._element.style[a] = typeof c == "number" ? String(c) : c;
834
+ }
835
+ }
836
+ function D(s) {
837
+ const r = s == null ? void 0 : s.currentTime;
838
+ return typeof r == "number" ? r : null;
839
+ }
840
+ function wt(s) {
841
+ return typeof s.step == "function" ? s : gt.from(s);
842
+ }
843
+ class lt extends st {
844
+ constructor(t, e = {}) {
845
+ super();
846
+ h(this, "_children");
847
+ h(this, "progressChildren");
848
+ h(this, "_startAt");
849
+ h(this, "namedChildren");
850
+ h(this, "restoreChildCallbacks", []);
851
+ h(this, "runId", 0);
852
+ h(this, "pendingComplete", 0);
853
+ h(this, "running", !1);
854
+ h(this, "disposed", !1);
855
+ h(this, "settled", !1);
856
+ h(this, "startedChildren", /* @__PURE__ */ new Set());
857
+ h(this, "lastMethod", "play");
858
+ h(this, "pausedRun", !1);
859
+ h(this, "pendingStartObservers", []);
860
+ this.namedChildren = new Map(
861
+ Array.isArray(t) ? [] : Object.entries(t)
862
+ ), this._children = Array.isArray(t) ? [...t] : [...this.namedChildren.values()];
863
+ for (const i of this._children) i.deferDisposal = !0;
864
+ this.progressChildren = this._children.filter(
865
+ (i) => !(i instanceof lt) || i.progressChildren.length > 0
866
+ ), (e.mode ?? "parallel") === "sequence" ? this._startAt = this._children.map((i, a) => a === 0 ? 0 : 1) : this._startAt = e.startAt ?? [];
867
+ }
868
+ /** Child animations in play order. */
869
+ get children() {
870
+ return this._children;
871
+ }
872
+ /**
873
+ * Per-child start thresholds (see `MultiAnimationOptions.startAt`). Read
874
+ * at run time, so replacing it before `play()` changes the overlap.
875
+ */
876
+ get startAt() {
877
+ return this._startAt;
878
+ }
879
+ set startAt(t) {
880
+ this._startAt = t;
881
+ }
882
+ /** Every `WebAnimation` in this composite, nested composites included. */
883
+ tracks() {
884
+ return this._children.flatMap((t) => [...t.getMotionTracks()]);
885
+ }
886
+ getMotionTracks() {
887
+ return this.tracks();
888
+ }
889
+ validate() {
890
+ this.buildDependencies();
891
+ for (const t of this._children) t.validate();
892
+ }
893
+ /** Select a registered child, which may itself be a composite. */
894
+ select(t) {
895
+ const e = this.namedChildren.get(t);
896
+ if (!e) throw new Error(`Unknown animation child: ${t}`);
897
+ return e;
898
+ }
899
+ set(t, e) {
900
+ if (typeof t == "string") {
901
+ const i = this.select(t);
902
+ return (e == null ? void 0 : e.integrator) !== void 0 && i.set({ integrator: wt(e.integrator) }), this;
903
+ }
904
+ return super.set(t);
905
+ }
906
+ /** Setting the composite explicitly retunes every child in the group. */
907
+ setIntegrator(t) {
908
+ for (const e of this._children) e.set({ integrator: t });
909
+ }
910
+ play() {
911
+ this.startRun("play");
912
+ }
913
+ reverse() {
914
+ this.startRun("reverse");
915
+ }
916
+ pause() {
917
+ this.pausedRun = this.running || this.pausedRun, this.running = !1, this.clearPendingStartObservers();
918
+ for (const t of this._children) t.pause();
919
+ }
920
+ complete() {
921
+ var t;
922
+ if (!this.settled) {
923
+ this.settled = !0, this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers();
924
+ for (const e of this._children) e.complete();
925
+ if (!this.deferDisposal) {
926
+ for (const e of this._children) e.cancel(j);
927
+ this.disposeResources(j);
928
+ }
929
+ (t = this.onComplete) == null || t.call(this);
930
+ }
931
+ }
932
+ get supportsInterruption() {
933
+ return this._children.every((t) => t.supportsInterruption);
934
+ }
935
+ stop() {
936
+ this.runId++, this.running = !1, this.clearPendingStartObservers(), this.restoreCompletionHandlers();
937
+ for (const t of this._children) t.stop();
938
+ }
939
+ cancel(t) {
940
+ this.stop();
941
+ for (const e of this._children) e.cancel(t);
942
+ this.disposeResources(t);
943
+ }
944
+ disposeResources(t) {
945
+ var e;
946
+ if (!this.disposed) {
947
+ this.disposed = !0;
948
+ try {
949
+ (e = this.onDispose) == null || e.call(this, t);
950
+ } catch (i) {
951
+ console.error("[ssgoi] composite cleanup failed", i);
952
+ }
953
+ }
954
+ }
955
+ get progress() {
956
+ if (this.progressChildren.length === 0) return 0;
957
+ let t = 0;
958
+ for (const e of this.progressChildren) t += e.progress;
959
+ return t / this.progressChildren.length;
960
+ }
961
+ getPose() {
962
+ return this._children.flatMap((t) => t.getPose());
963
+ }
964
+ getTimeline() {
965
+ return this._children.flatMap((t) => t.getTimeline());
966
+ }
967
+ matchInto(t) {
968
+ for (const e of this._children) e.matchInto(t);
969
+ }
970
+ get isAnimating() {
971
+ return this._children.some((t) => t.isAnimating);
972
+ }
973
+ get isPaused() {
974
+ return this._children.some((t) => t.isPaused) && this._children.every((t) => t.isPaused || t.isComplete);
975
+ }
976
+ get isComplete() {
977
+ return this.settled;
978
+ }
979
+ get isReversing() {
980
+ return this._children.some((t) => t.isReversing);
981
+ }
982
+ get playbackRate() {
983
+ return super.playbackRate;
984
+ }
985
+ set playbackRate(t) {
986
+ super.playbackRate = t;
987
+ for (const e of this._children) e.playbackRate = t;
988
+ }
989
+ /* ───────────────────────────────────────────────────────── private */
990
+ startRun(t) {
991
+ const e = this.buildDependencies(), i = this.pausedRun && t === this.lastMethod, a = t !== this.lastMethod, c = new Set(this.startedChildren), d = new Set(
992
+ this._children.filter((o) => o.isComplete)
993
+ ), u = t === "reverse" && c.size ? this._children.filter((o) => c.has(o)) : [...this._children], m = t === "reverse" ? [...u].reverse() : u, g = /* @__PURE__ */ new Map();
994
+ if (t === "reverse")
995
+ for (const [o, f] of e) {
996
+ if (!u.includes(o) || !u.includes(f.after))
997
+ continue;
998
+ const b = g.get(f.after) ?? [];
999
+ b.push({
1000
+ after: o,
1001
+ at: f.at === "settled" ? "settled" : 1 - f.at
1002
+ }), g.set(f.after, b);
1003
+ }
1004
+ else
1005
+ for (const [o, f] of e)
1006
+ g.set(o, [f]);
1007
+ if (a || i)
1008
+ for (const o of c)
1009
+ d.has(o) || g.delete(o);
1010
+ this.running && this.pause(), this.restoreCompletionHandlers();
1011
+ const p = ++this.runId;
1012
+ if (this.running = !0, this.pausedRun = !1, this.lastMethod = t, this.disposed = !1, this.settled = !1, this.pendingComplete = u.length, !i && !a && this.startedChildren.clear(), this.pendingComplete === 0) {
1013
+ this.handleFinished();
1014
+ return;
1015
+ }
1016
+ const l = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
1017
+ if (i)
1018
+ for (const o of u)
1019
+ c.has(o) && d.has(o) && (n.add(o), l.add(o), this.pendingComplete--);
1020
+ for (const o of u) {
1021
+ const f = o.onComplete, b = () => {
1022
+ if (!(this.runId !== p || !this.running || l.has(o))) {
1023
+ try {
1024
+ f == null || f();
1025
+ } catch (w) {
1026
+ console.error("[ssgoi] animation completion failed", w);
1027
+ }
1028
+ l.add(o), --this.pendingComplete === 0 && this.handleFinished();
1029
+ }
1030
+ };
1031
+ o.onComplete = b, this.restoreChildCallbacks.push(() => {
1032
+ o.onComplete === b && (o.onComplete = f);
1033
+ });
1034
+ }
1035
+ const y = () => {
1036
+ let o = !0;
1037
+ for (; this.running && this.runId === p && o; ) {
1038
+ o = !1;
1039
+ for (const f of m)
1040
+ !this.running || n.has(f) || (g.get(f) ?? []).some(
1041
+ (w) => !n.has(w.after) || !this.hasReachedThreshold(
1042
+ w.after,
1043
+ w.at,
1044
+ t
1045
+ )
1046
+ ) || (n.add(f), this.startedChildren.add(f), f[t](), o = !0);
1047
+ }
1048
+ n.size === u.length && this.clearPendingStartObservers();
1049
+ };
1050
+ y(), this.pendingComplete === 0 && this.handleFinished(), this.running && n.size !== u.length && this.pendingStartObservers.push(
1051
+ at.subscribe(y, "observe")
1052
+ );
1053
+ }
1054
+ buildDependencies() {
1055
+ const t = /* @__PURE__ */ new Map(), e = new Set(this._children);
1056
+ if (e.size !== this._children.length)
1057
+ throw new Error(
1058
+ "Each child animation must occur once in a MultiAnimation"
1059
+ );
1060
+ this._children.forEach((d, u) => {
1061
+ const m = d.startCondition;
1062
+ if (m) {
1063
+ if (!e.has(m.after))
1064
+ throw new Error(
1065
+ "startAt.after must reference a sibling in the same MultiAnimation"
1066
+ );
1067
+ t.set(d, { ...m });
1068
+ } else u > 0 && this._startAt.some((g) => g > 0) && t.set(d, {
1069
+ after: this._children[u - 1],
1070
+ at: this._startAt[u] ?? 0
1071
+ });
1072
+ });
1073
+ const i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), c = (d) => {
1074
+ if (a.has(d))
1075
+ throw new Error("Animation startAt dependencies form a cycle");
1076
+ if (i.has(d)) return;
1077
+ a.add(d);
1078
+ const u = t.get(d);
1079
+ u && c(u.after), a.delete(d), i.add(d);
1080
+ };
1081
+ return this._children.forEach(c), t;
1082
+ }
1083
+ hasReachedThreshold(t, e, i) {
1084
+ return t.isComplete ? !0 : e === "settled" ? !1 : e <= 0 ? !0 : (i === "play" ? t.progress : 1 - t.progress) >= e;
1085
+ }
1086
+ clearPendingStartObservers() {
1087
+ for (const t of this.pendingStartObservers) t();
1088
+ this.pendingStartObservers = [];
1089
+ }
1090
+ restoreCompletionHandlers() {
1091
+ for (const t of this.restoreChildCallbacks) t();
1092
+ this.restoreChildCallbacks = [];
1093
+ }
1094
+ handleFinished() {
1095
+ var t;
1096
+ if (this.running) {
1097
+ if (this.running = !1, this.settled = !0, this.clearPendingStartObservers(), this.restoreCompletionHandlers(), !this.deferDisposal) {
1098
+ for (const e of this._children) e.cancel(j);
1099
+ this.disposeResources(j);
1100
+ }
1101
+ (t = this.onComplete) == null || t.call(this);
1102
+ }
1103
+ }
1104
+ findTimeForProgress(t) {
1105
+ return null;
1106
+ }
1107
+ }
1108
+ const X = /* @__PURE__ */ new WeakMap();
1109
+ function Mt(s) {
1110
+ const r = X.get(s) ?? {
1111
+ value: s.style.getPropertyValue("opacity"),
1112
+ priority: s.style.getPropertyPriority("opacity"),
1113
+ opacity: typeof getComputedStyle == "function" ? Number.parseFloat(getComputedStyle(s).opacity) : Number.NaN,
1114
+ users: /* @__PURE__ */ new Set()
1115
+ }, t = {};
1116
+ r.users.add(t), X.set(s, r);
1117
+ let e = !1;
1118
+ return {
1119
+ opacity: Number.isFinite(r.opacity) ? r.opacity : 1,
1120
+ set: (i) => {
1121
+ t.value = i, s.style.opacity = String(i);
1122
+ },
1123
+ restore: () => {
1124
+ if (!e) {
1125
+ if (e = !0, r.users.delete(t), r.users.size > 0) {
1126
+ const i = Array.from(r.users), a = i[i.length - 1];
1127
+ (a == null ? void 0 : a.value) !== void 0 && (s.style.opacity = String(a.value));
1128
+ return;
1129
+ }
1130
+ r.value ? s.style.setProperty("opacity", r.value, r.priority) : s.style.removeProperty("opacity"), X.delete(s);
1131
+ }
1132
+ }
1133
+ };
1134
+ }
1135
+ export {
1136
+ st as A,
1137
+ lt as M,
1138
+ ot as W,
1139
+ $ as c,
1140
+ j as f,
1141
+ Mt as r
1142
+ };