@ssgoi/core 2.5.5 → 2.5.6

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 (36) hide show
  1. package/dist/animator/animate/css-runner.d.ts +17 -0
  2. package/dist/animator/animate/css-runner.d.ts.map +1 -0
  3. package/dist/animator/animate/index.d.ts +42 -0
  4. package/dist/animator/animate/index.d.ts.map +1 -0
  5. package/dist/animator/animate/tick-runner.d.ts +16 -0
  6. package/dist/animator/animate/tick-runner.d.ts.map +1 -0
  7. package/dist/animator/animate/types.d.ts +31 -0
  8. package/dist/animator/animate/types.d.ts.map +1 -0
  9. package/dist/animator/animation-scheduler.d.ts +4 -17
  10. package/dist/animator/animation-scheduler.d.ts.map +1 -1
  11. package/dist/animator/index.d.ts +32 -32
  12. package/dist/animator/index.d.ts.map +1 -1
  13. package/dist/animator/spring-core.d.ts +63 -0
  14. package/dist/animator/spring-core.d.ts.map +1 -0
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.js +588 -631
  17. package/dist/ssgoi-transition/create-ssgoi-transition-context.d.ts.map +1 -1
  18. package/dist/ssgoi-transition/create-swipe-detector.d.ts +1 -0
  19. package/dist/ssgoi-transition/create-swipe-detector.d.ts.map +1 -1
  20. package/dist/transition/create-transition-callback.d.ts +2 -2
  21. package/dist/transition/create-transition-callback.d.ts.map +1 -1
  22. package/dist/transition/transition-strategy.d.ts +16 -16
  23. package/dist/transition/transition-strategy.d.ts.map +1 -1
  24. package/dist/transition/transition.d.ts +2 -18
  25. package/dist/transition/transition.d.ts.map +1 -1
  26. package/dist/types.cjs +1 -1
  27. package/dist/types.d.ts +74 -34
  28. package/dist/types.d.ts.map +1 -1
  29. package/dist/types.js +21 -6
  30. package/dist/view-transitions/drill.d.ts.map +1 -1
  31. package/dist/view-transitions/hero.d.ts.map +1 -1
  32. package/dist/view-transitions/index.cjs +9 -9
  33. package/dist/view-transitions/index.js +271 -257
  34. package/package.json +1 -1
  35. package/dist/animator/animate.d.ts +0 -35
  36. package/dist/animator/animate.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,38 +1,38 @@
1
- var _ = Object.defineProperty;
2
- var F = (n, t, e) => t in n ? _(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var m = (n, t, e) => F(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { isMultiSpring as V } from "./types.js";
5
- import { isSingleSpring as at } from "./types.js";
6
- import { j as lt } from "./jaemin-BWkrXq0V.js";
7
- class $ {
1
+ var $ = Object.defineProperty;
2
+ var j = (n, t, i) => t in n ? $(n, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[t] = i;
3
+ var p = (n, t, i) => j(n, typeof t != "symbol" ? t + "" : t, i);
4
+ import { isMultiSpring as M } from "./types.js";
5
+ import { isCssAnimation as vt, isSingleSpring as St, isTickAnimation as Ct, validateAnimationMode as Et } from "./types.js";
6
+ import { j as At } from "./jaemin-BWkrXq0V.js";
7
+ class B {
8
8
  constructor() {
9
- m(this, "listeners", /* @__PURE__ */ new Set());
10
- m(this, "rafId", null);
11
- m(this, "isRunning", !1);
9
+ p(this, "listeners", /* @__PURE__ */ new Set());
10
+ p(this, "rafId", null);
11
+ p(this, "isRunning", !1);
12
12
  // Timing
13
- m(this, "startTime", Date.now());
14
- m(this, "lastUpdate", this.startTime);
15
- m(this, "elapsed", 0);
13
+ p(this, "startTime", Date.now());
14
+ p(this, "lastUpdate", this.startTime);
15
+ p(this, "elapsed", 0);
16
16
  // Lag smoothing (mobile optimization)
17
- m(this, "lagThreshold", 500);
17
+ p(this, "lagThreshold", 500);
18
18
  // ms - detect tab switches, backgrounding
19
- m(this, "adjustedLag", 33);
19
+ p(this, "adjustedLag", 33);
20
20
  // ms - max time jump to prevent animation skip
21
- m(this, "maxDeltaTime", 33);
21
+ p(this, "maxDeltaTime", 33);
22
22
  // ms - clamp for physics stability (30fps minimum)
23
23
  // FPS throttling
24
- m(this, "gap", 1e3 / 240);
24
+ p(this, "gap", 1e3 / 240);
25
25
  // max 240fps
26
- m(this, "nextTime", this.gap);
27
- m(this, "tick", () => {
26
+ p(this, "nextTime", this.gap);
27
+ p(this, "tick", () => {
28
28
  const t = Date.now();
29
- let i = t - this.lastUpdate;
30
- i > this.lagThreshold || i < 0 ? (this.startTime += i - this.adjustedLag, i = this.adjustedLag) : i > this.maxDeltaTime && (i = this.maxDeltaTime), this.lastUpdate = t;
31
- const r = t - this.startTime, o = r - this.nextTime;
32
- if (o > 0) {
33
- const s = i / 1e3;
34
- this.elapsed = r / 1e3, this.nextTime += o + (o >= this.gap ? 4 : this.gap - o), this.listeners.forEach((d) => {
35
- d(s, this.elapsed);
29
+ let e = t - this.lastUpdate;
30
+ e > this.lagThreshold || e < 0 ? (this.startTime += e - this.adjustedLag, e = this.adjustedLag) : e > this.maxDeltaTime && (e = this.maxDeltaTime), this.lastUpdate = t;
31
+ const o = t - this.startTime, r = o - this.nextTime;
32
+ if (r > 0) {
33
+ const s = e / 1e3;
34
+ this.elapsed = o / 1e3, this.nextTime += r + (r >= this.gap ? 4 : this.gap - r), this.listeners.forEach((a) => {
35
+ a(s, this.elapsed);
36
36
  });
37
37
  }
38
38
  this.listeners.size > 0 ? this.rafId = requestAnimationFrame(this.tick) : (this.isRunning = !1, this.rafId = null);
@@ -51,8 +51,8 @@ class $ {
51
51
  * @param threshold - Time threshold to detect lag (default: 500ms)
52
52
  * @param adjustedLag - Max time jump when lag detected (default: 33ms)
53
53
  */
54
- lagSmoothing(t, e) {
55
- this.lagThreshold = t, this.adjustedLag = Math.min(e, t);
54
+ lagSmoothing(t, i) {
55
+ this.lagThreshold = t, this.adjustedLag = Math.min(i, t);
56
56
  }
57
57
  /**
58
58
  * Set maximum FPS
@@ -68,189 +68,233 @@ class $ {
68
68
  return this.elapsed;
69
69
  }
70
70
  }
71
- const I = new $();
72
- function k(n) {
71
+ const I = new B();
72
+ function z(n) {
73
+ const t = n.stiffness, i = n.damping, e = 1, o = Math.sqrt(t / e), r = i / (2 * Math.sqrt(t * e));
74
+ return { omega: o, zeta: r };
75
+ }
76
+ function H(n, t, i, e) {
77
+ const { omega: o, zeta: r } = i, { position: s, velocity: a } = n, c = Math.min(e, 0.033), m = -2 * c * r * o * a, h = c * o * o * (t - s), u = a + m + h;
78
+ return {
79
+ position: s + c * u,
80
+ velocity: u
81
+ };
82
+ }
83
+ const K = 0.01, U = 0.01, N = 0.05;
84
+ function W(n, t) {
85
+ const i = Math.abs(t - n.position), e = Math.abs(n.velocity);
86
+ return i < K && e < U;
87
+ }
88
+ function q(n) {
73
89
  const {
74
90
  from: t,
75
- to: e,
76
- stiffness: i,
77
- damping: r,
78
- mass: o,
79
- velocity: s = 0,
80
- onUpdate: d,
81
- onComplete: l
91
+ to: i,
92
+ spring: e,
93
+ velocity: o = 0,
94
+ onUpdate: r,
95
+ onComplete: s,
96
+ onStart: a
82
97
  } = n;
83
- let h = t, u = s, a = !0;
84
- const p = Math.sqrt(i / o), c = r / (2 * Math.sqrt(i * o)), g = 0.01, w = 0.01;
85
- let f = 0;
86
- const y = 0.05, S = (T) => {
87
- if (!a) return;
88
- const C = Math.min(T, 0.033), v = -2 * C * c * p * u, b = C * p * p * (e - h);
89
- u += v + b, h += C * u;
90
- const E = Math.abs(e - h), A = Math.abs(u);
91
- if (E < g && A < w) {
92
- if (f += C, f >= y) {
93
- h = e, u = 0, a = !1, d(h), I.unsubscribe(S), l();
94
- return;
98
+ let c = { position: t, velocity: o }, m = !0, h = 0, u = !1;
99
+ const g = z(e), l = (w) => {
100
+ if (m) {
101
+ if (u || (u = !0, a == null || a()), c = H(c, i, g, w), W(c, i)) {
102
+ if (h += Math.min(w, 0.033), h >= N) {
103
+ c = { position: i, velocity: 0 }, m = !1, r(c.position), I.unsubscribe(l), s();
104
+ return;
105
+ }
106
+ } else
107
+ h = 0;
108
+ r(c.position);
109
+ }
110
+ };
111
+ return I.subscribe(l), {
112
+ stop: () => {
113
+ m && (m = !1, I.unsubscribe(l));
114
+ },
115
+ getPosition: () => c.position,
116
+ getVelocity: () => c.velocity,
117
+ isRunning: () => m
118
+ };
119
+ }
120
+ const x = 1e3 / 60;
121
+ function G(n, t, i, e = 0) {
122
+ const o = z(i), r = 600;
123
+ let s = { position: n, velocity: e }, a = 0;
124
+ const c = [];
125
+ for (let m = 0; m < r; m++) {
126
+ const h = m * x;
127
+ if (c.push({
128
+ time: h,
129
+ position: s.position,
130
+ velocity: s.velocity
131
+ }), s = H(s, t, o, x / 1e3), W(s, t)) {
132
+ if (a += x / 1e3, a >= N) {
133
+ c.push({
134
+ time: (m + 1) * x,
135
+ position: t,
136
+ velocity: 0
137
+ });
138
+ break;
95
139
  }
96
140
  } else
97
- f = 0;
98
- d(h);
141
+ a = 0;
142
+ }
143
+ return c;
144
+ }
145
+ function D(n, t) {
146
+ if (n.length === 0)
147
+ return { position: 0, velocity: 0 };
148
+ const i = n[0], e = n[n.length - 1];
149
+ if (t <= 0)
150
+ return { position: i.position, velocity: i.velocity };
151
+ if (t >= e.time)
152
+ return { position: e.position, velocity: e.velocity };
153
+ let o = 0, r = n.length - 1;
154
+ for (; o < r - 1; ) {
155
+ const m = Math.floor((o + r) / 2);
156
+ n[m].time <= t ? o = m : r = m;
157
+ }
158
+ const s = n[o], a = n[r], c = (t - s.time) / (a.time - s.time);
159
+ return {
160
+ position: s.position + (a.position - s.position) * c,
161
+ velocity: s.velocity + (a.velocity - s.velocity) * c
99
162
  };
100
- return I.subscribe(S), {
163
+ }
164
+ function J(n, t) {
165
+ return n.map((i) => t(i.position));
166
+ }
167
+ function Q(n) {
168
+ const {
169
+ element: t,
170
+ from: i,
171
+ to: e,
172
+ spring: o,
173
+ velocity: r = 0,
174
+ style: s,
175
+ onComplete: a,
176
+ onStart: c
177
+ } = n, m = G(i, e, o, r);
178
+ if (m.length === 0)
179
+ return c == null || c(), a(), {
180
+ stop: () => {
181
+ },
182
+ getPosition: () => e,
183
+ getVelocity: () => 0,
184
+ isRunning: () => !1
185
+ };
186
+ const h = J(m, s), u = m[m.length - 1], g = u.time, l = t.animate(h, {
187
+ duration: g,
188
+ fill: "forwards",
189
+ easing: "linear"
190
+ // Spring physics already applied in keyframes
191
+ });
192
+ let w = !0;
193
+ const d = performance.now();
194
+ return c == null || c(), l.onfinish = () => {
195
+ w && (w = !1, a());
196
+ }, {
101
197
  stop: () => {
102
- a && (a = !1, I.unsubscribe(S));
103
- }
198
+ w && (w = !1, l.cancel());
199
+ },
200
+ getPosition: () => {
201
+ if (!w)
202
+ return u.position;
203
+ const f = performance.now() - d;
204
+ return D(m, f).position;
205
+ },
206
+ getVelocity: () => {
207
+ if (!w)
208
+ return 0;
209
+ const f = performance.now() - d;
210
+ return D(m, f).velocity;
211
+ },
212
+ isRunning: () => w
104
213
  };
105
214
  }
106
- class O {
215
+ function Z(n) {
216
+ const { from: t, to: i, spring: e, velocity: o, onComplete: r, onStart: s, tick: a, css: c } = n;
217
+ if (a && c)
218
+ throw new Error("Cannot use both 'tick' and 'css' options together");
219
+ return !a && !c ? (s == null || s(), r(), {
220
+ stop: () => {
221
+ },
222
+ getPosition: () => i,
223
+ getVelocity: () => 0,
224
+ isRunning: () => !1
225
+ }) : c ? Q({
226
+ element: c.element,
227
+ from: t,
228
+ to: i,
229
+ spring: e,
230
+ velocity: o,
231
+ style: c.style,
232
+ onComplete: r,
233
+ onStart: s
234
+ }) : q({
235
+ from: t,
236
+ to: i,
237
+ spring: e,
238
+ velocity: o,
239
+ onUpdate: a,
240
+ onComplete: r,
241
+ onStart: s
242
+ });
243
+ }
244
+ class k {
107
245
  constructor(t) {
108
- m(this, "options");
109
- m(this, "currentValue");
110
- m(this, "velocity");
111
- m(this, "isAnimating", !1);
112
- m(this, "controls", null);
113
- // For object animations
114
- m(this, "animationMap", null);
115
- m(this, "activeAnimations", /* @__PURE__ */ new Set());
116
- m(this, "completedAnimations", /* @__PURE__ */ new Set());
117
- m(this, "updatedProperties", /* @__PURE__ */ new Set());
118
- m(this, "animate", (t = !1) => {
119
- !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
120
- const e = t ? this.options.from : this.options.to;
121
- if (typeof this.currentValue == "object" && this.currentValue !== null) {
122
- this.animateObject(e);
123
- return;
124
- }
125
- let i = this.currentValue, r = performance.now();
126
- const o = {
127
- from: this.currentValue,
128
- to: e,
129
- stiffness: this.options.spring.stiffness,
130
- damping: this.options.spring.damping,
131
- mass: 1
132
- };
133
- typeof this.velocity == "number" && (o.velocity = this.velocity * 1e3), this.controls = k({
134
- ...o,
135
- onUpdate: (s) => {
136
- const d = performance.now(), l = (d - r) / 1e3;
137
- if (l > 0) {
138
- if (typeof s == "number" && typeof i == "number") {
139
- const h = (s - i) / l;
140
- this.velocity = h / 1e3;
141
- } else if (typeof s == "object" && s !== null) {
142
- const h = {};
143
- Object.keys(s).forEach((u) => {
144
- const a = s[u], p = i[u];
145
- if (typeof a == "number" && typeof p == "number") {
146
- const c = (a - p) / l;
147
- h[u] = c / 1e3;
148
- }
149
- }), this.velocity = h;
150
- }
151
- i = s, r = d;
152
- }
153
- this.currentValue = s, this.options.onUpdate(s);
154
- },
155
- onComplete: () => {
156
- this.currentValue = e, this.isAnimating = !1, this.controls = null, typeof this.velocity == "object" && this.velocity !== null ? Object.keys(this.velocity).forEach((s) => {
157
- this.velocity[s] = 0;
158
- }) : this.velocity = 0, this.options.onComplete();
159
- }
160
- });
161
- });
162
- m(this, "animateObject", (t) => {
163
- const e = this.currentValue, i = Object.keys(e);
164
- this.animationMap = /* @__PURE__ */ new Map(), this.activeAnimations.clear(), this.completedAnimations.clear(), this.updatedProperties.clear();
165
- const r = { ...e }, o = {};
166
- let s = !1;
167
- const d = () => {
168
- const l = i.filter((u) => !this.completedAnimations.has(u));
169
- if (l.every(
170
- (u) => this.updatedProperties.has(u)
171
- ) && l.length > 0) {
172
- if (typeof this.velocity == "object" && this.velocity) {
173
- const u = performance.now();
174
- Object.keys(r).forEach((a) => {
175
- if (o[a]) {
176
- const p = (u - o[a]) / 1e3, c = this.currentValue[a], g = r[a];
177
- typeof c == "number" && typeof g == "number" && p > 0 && (this.velocity[a] = (g - c) / p / 1e3);
178
- }
179
- o[a] = u;
180
- });
181
- }
182
- this.currentValue = { ...r }, this.options.onUpdate(this.currentValue), this.updatedProperties.clear(), !s && this.options.onStart && (s = !0, this.options.onStart());
183
- }
184
- };
185
- i.forEach((l) => {
186
- this.activeAnimations.add(l);
187
- const h = {
188
- from: e[l],
189
- to: t[l],
190
- stiffness: this.options.spring.stiffness,
191
- damping: this.options.spring.damping,
192
- mass: 1
193
- };
194
- typeof this.velocity == "object" && this.velocity && l in this.velocity && (h.velocity = this.velocity[l] * 1e3);
195
- const u = k({
196
- ...h,
197
- onUpdate: (a) => {
198
- r[l] = a, this.updatedProperties.add(l), d();
199
- },
200
- onComplete: () => {
201
- this.completedAnimations.add(l), this.updatedProperties.delete(l), this.completedAnimations.size === i.length && (this.currentValue = t, this.isAnimating = !1, this.animationMap = null, typeof this.velocity == "object" && this.velocity && Object.keys(this.velocity).forEach((a) => {
202
- this.velocity[a] = 0;
203
- }), this.options.onComplete());
204
- }
205
- });
206
- this.animationMap.set(l, u);
207
- });
208
- });
209
- if (this.options = {
246
+ p(this, "options");
247
+ p(this, "controls", null);
248
+ p(this, "isAnimating", !1);
249
+ p(this, "currentValue");
250
+ p(this, "currentVelocity", 0);
251
+ if (t.tick && t.css)
252
+ throw new Error("Cannot use both 'tick' and 'css' options together");
253
+ this.options = {
210
254
  from: t.from ?? 0,
211
255
  to: t.to ?? 1,
212
- spring: t.spring ?? { stiffness: 100, damping: 10 },
213
- onUpdate: t.onUpdate ?? (() => {
214
- }),
256
+ spring: t.spring ?? { stiffness: 300, damping: 30 },
257
+ tick: t.tick,
258
+ css: t.css,
215
259
  onComplete: t.onComplete ?? (() => {
216
260
  }),
217
261
  onStart: t.onStart
218
- }, this.currentValue = this.options.from, typeof this.options.from == "object" && this.options.from !== null) {
219
- const e = {};
220
- Object.keys(this.options.from).forEach((i) => {
221
- e[i] = 0;
222
- }), this.velocity = e;
223
- } else
224
- this.velocity = 0;
262
+ }, this.currentValue = this.options.from;
263
+ }
264
+ runAnimation(t) {
265
+ this.isAnimating = !0, this.controls = Z({
266
+ from: this.currentValue,
267
+ to: t,
268
+ spring: this.options.spring,
269
+ velocity: this.currentVelocity,
270
+ tick: this.options.tick,
271
+ css: this.options.css,
272
+ onStart: this.options.onStart,
273
+ onComplete: () => {
274
+ this.currentValue = t, this.currentVelocity = 0, this.isAnimating = !1, this.controls = null, this.options.onComplete();
275
+ }
276
+ });
225
277
  }
226
- // Animation control methods
227
278
  forward() {
228
- this.stop(), this.animate(!1);
279
+ this.stop(), this.runAnimation(this.options.to);
229
280
  }
230
281
  backward() {
231
- this.stop(), this.animate(!0);
282
+ this.stop(), this.runAnimation(this.options.from);
232
283
  }
233
284
  reverse() {
234
285
  const t = this.options.from;
235
- if (this.options.from = this.options.to, this.options.to = t, this.isAnimating) {
236
- const e = this.shouldReverse();
237
- this.stop(), this.animate(!e);
238
- }
239
- }
240
- shouldReverse() {
241
- return typeof this.currentValue == "number" && typeof this.options.from == "number" && typeof this.options.to == "number" ? this.currentValue > (this.options.from + this.options.to) / 2 : !1;
286
+ this.options.from = this.options.to, this.options.to = t, this.isAnimating && (this.stop(), this.runAnimation(this.options.to));
242
287
  }
243
288
  stop() {
244
- this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null), this.animationMap && (this.animationMap.forEach((t) => {
245
- t.stop();
246
- }), this.animationMap.clear(), this.animationMap = null), this.updatedProperties.clear();
289
+ this.controls && (this.currentValue = this.controls.getPosition(), this.currentVelocity = this.controls.getVelocity(), this.controls.stop(), this.controls = null), this.isAnimating = !1;
247
290
  }
248
- // State getters
249
291
  getVelocity() {
250
- return this.velocity;
292
+ var t;
293
+ return ((t = this.controls) == null ? void 0 : t.getVelocity()) ?? this.currentVelocity;
251
294
  }
252
295
  getCurrentValue() {
253
- return this.currentValue;
296
+ var t;
297
+ return ((t = this.controls) == null ? void 0 : t.getPosition()) ?? this.currentValue;
254
298
  }
255
299
  getIsAnimating() {
256
300
  return this.isAnimating;
@@ -258,42 +302,36 @@ class O {
258
302
  getCurrentState() {
259
303
  return {
260
304
  type: "single",
261
- position: this.currentValue,
262
- velocity: this.velocity,
305
+ position: this.getCurrentValue(),
306
+ velocity: this.getVelocity(),
263
307
  from: this.options.from,
264
308
  to: this.options.to
265
309
  };
266
310
  }
267
- // State setters
268
- setVelocity(t) {
269
- this.velocity = t;
270
- }
271
311
  setValue(t) {
272
312
  this.currentValue = t;
273
313
  }
274
- // Configuration
314
+ setVelocity(t) {
315
+ this.currentVelocity = t;
316
+ }
275
317
  updateOptions(t) {
276
- if (this.options = { ...this.options, ...t }, this.isAnimating && this.controls) {
277
- const e = this.shouldReverse();
278
- this.stop(), this.animate(!e);
279
- }
318
+ this.options = { ...this.options, ...t };
280
319
  }
281
- // Static factory method
282
- static fromState(t, e) {
283
- const i = new O(e);
284
- return i.setValue(t.position), i.setVelocity(t.velocity), i;
320
+ static fromState(t, i) {
321
+ const e = new k(i);
322
+ return e.setValue(t.position), e.setVelocity(t.velocity), e;
285
323
  }
286
324
  }
287
- class j {
325
+ class L {
288
326
  constructor(t) {
289
- m(this, "config");
290
- m(this, "animators", /* @__PURE__ */ new Map());
291
- m(this, "springOrder", []);
292
- m(this, "completedCount", 0);
293
- m(this, "completedAnimators", /* @__PURE__ */ new Set());
294
- m(this, "direction", "forward");
295
- m(this, "idCounter", 0);
296
- m(this, "timeoutIds", []);
327
+ p(this, "config");
328
+ p(this, "animators", /* @__PURE__ */ new Map());
329
+ p(this, "springOrder", []);
330
+ p(this, "completedCount", 0);
331
+ p(this, "completedAnimators", /* @__PURE__ */ new Set());
332
+ p(this, "direction", "forward");
333
+ p(this, "idCounter", 0);
334
+ p(this, "timeoutIds", []);
297
335
  this.config = t, this.initializeAnimators();
298
336
  }
299
337
  generateId() {
@@ -301,168 +339,102 @@ class j {
301
339
  }
302
340
  initializeAnimators() {
303
341
  this.config.springs.forEach((t) => {
304
- const e = this.generateId(), i = new O({
342
+ const i = this.generateId(), e = new k({
305
343
  from: t.from,
306
344
  to: t.to,
307
345
  spring: t.spring,
308
- onUpdate: t.tick,
309
- onComplete: () => this.onAnimatorComplete(e),
346
+ tick: t.tick,
347
+ onComplete: () => this.onAnimatorComplete(i),
310
348
  onStart: t.onStart
311
349
  });
312
- this.animators.set(e, {
313
- id: e,
350
+ this.animators.set(i, {
351
+ id: i,
314
352
  item: t,
315
- animator: i,
353
+ animator: e,
316
354
  startTime: null
317
- }), this.springOrder.push(e);
355
+ }), this.springOrder.push(i);
318
356
  });
319
357
  }
320
- /**
321
- * Normalize schedule configuration to unified internal representation
322
- * Uses discriminated union and early return pattern
323
- *
324
- * @param direction - "forward" or "backward" direction
325
- */
326
358
  normalizeSchedule(t) {
327
- const e = this.config.schedule ?? "overlap";
328
- return this.springOrder.map((i, r) => {
329
- const o = this.animators.get(i);
330
- if (!o)
359
+ const i = this.config.schedule ?? "overlap";
360
+ return this.springOrder.map((e, o) => {
361
+ const r = this.animators.get(e);
362
+ if (!r)
331
363
  throw new Error(
332
- `AnimationScheduler: animator with id "${i}" not found during normalization`
364
+ `AnimationScheduler: animator with id "${e}" not found`
333
365
  );
334
- if (e === "overlap")
335
- return {
336
- type: "offset",
337
- id: i,
338
- delay: 0
339
- };
340
- if (e === "wait")
341
- return t === "forward" && r === 0 ? {
342
- type: "offset",
343
- id: i,
344
- delay: 0
345
- } : t === "backward" && r === this.springOrder.length - 1 ? {
346
- type: "offset",
347
- id: i,
348
- delay: 0
349
- } : {
350
- type: "wait",
351
- id: i
352
- };
353
- const s = o.item.offset ?? 0;
366
+ if (i === "overlap")
367
+ return { type: "offset", id: e, delay: 0 };
368
+ if (i === "wait")
369
+ return t === "forward" && o === 0 ? { type: "offset", id: e, delay: 0 } : t === "backward" && o === this.springOrder.length - 1 ? { type: "offset", id: e, delay: 0 } : { type: "wait", id: e };
370
+ const s = r.item.offset ?? 0;
354
371
  if (t === "forward")
355
- return {
356
- type: "offset",
357
- id: i,
358
- delay: s
359
- };
360
- const d = this.animators.size === 0 ? 0 : Math.max(
361
- ...Array.from(this.animators.values()).map(
362
- (l) => l.item.offset ?? 0
363
- )
372
+ return { type: "offset", id: e, delay: s };
373
+ const a = Math.max(
374
+ ...Array.from(this.animators.values()).map((c) => c.item.offset ?? 0)
364
375
  );
365
- return {
366
- type: "offset",
367
- id: i,
368
- delay: d - s
369
- };
376
+ return { type: "offset", id: e, delay: a - s };
370
377
  });
371
378
  }
372
379
  onAnimatorComplete(t) {
373
- var i, r, o, s, d, l;
374
- const e = this.animators.get(t);
375
- if (!e) {
376
- console.warn(
377
- `AnimationScheduler: animator with id "${t}" not found on completion`
378
- );
379
- return;
380
- }
381
- this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (r = (i = e.item).onComplete) == null || r.call(i), (s = (o = this.config).onProgress) == null || s.call(o, this.completedCount, this.config.springs.length), this.handleWaitModeChaining(t), this.completedCount === this.config.springs.length && ((l = (d = this.config).onEnd) == null || l.call(d)));
380
+ var e, o, r, s, a, c;
381
+ const i = this.animators.get(t);
382
+ !i || this.completedAnimators.has(t) || (this.completedAnimators.add(t), this.completedCount++, (o = (e = i.item).onComplete) == null || o.call(e), (s = (r = this.config).onProgress) == null || s.call(r, this.completedCount, this.config.springs.length), this.handleWaitModeChaining(t), this.completedCount === this.config.springs.length && ((c = (a = this.config).onEnd) == null || c.call(a)));
382
383
  }
383
- /**
384
- * Handle wait mode chaining: start next/previous spring after completion
385
- */
386
384
  handleWaitModeChaining(t) {
387
385
  if (this.config.schedule !== "wait")
388
386
  return;
389
- const e = this.springOrder.indexOf(t);
387
+ const i = this.springOrder.indexOf(t);
390
388
  if (this.direction === "forward") {
391
- const o = this.springOrder[e + 1];
392
- if (!o)
393
- return;
394
- const s = this.animators.get(o);
395
- s && s.startTime === null && this.startAnimator(o);
396
- return;
389
+ const e = this.springOrder[i + 1];
390
+ if (e) {
391
+ const o = this.animators.get(e);
392
+ o && o.startTime === null && this.startAnimator(e);
393
+ }
394
+ } else {
395
+ const e = this.springOrder[i - 1];
396
+ if (e) {
397
+ const o = this.animators.get(e);
398
+ o && o.startTime === null && this.startBackwardAnimator(e);
399
+ }
397
400
  }
398
- const i = this.springOrder[e - 1];
399
- if (!i)
400
- return;
401
- const r = this.animators.get(i);
402
- r && r.startTime === null && this.startBackwardAnimator(i);
403
401
  }
404
402
  startAnimator(t) {
405
- const e = this.animators.get(t);
406
- if (!e) {
407
- console.warn(
408
- `AnimationScheduler: animator with id "${t}" not found on start`
409
- );
410
- return;
411
- }
412
- if (e.startTime !== null) {
413
- console.warn(
414
- `AnimationScheduler: animator with id "${t}" already started`
415
- );
416
- return;
417
- }
418
- e.startTime = Date.now(), e.animator.forward();
403
+ const i = this.animators.get(t);
404
+ !i || i.startTime !== null || (i.startTime = Date.now(), i.animator.forward());
419
405
  }
420
406
  startBackwardAnimator(t) {
421
- const e = this.animators.get(t);
422
- if (!e) {
423
- console.warn(
424
- `AnimationScheduler: animator with id "${t}" not found on backward start`
425
- );
426
- return;
427
- }
428
- if (e.startTime !== null) {
429
- console.warn(
430
- `AnimationScheduler: animator with id "${t}" already started`
431
- );
432
- return;
433
- }
434
- e.startTime = Date.now(), e.animator.backward();
407
+ const i = this.animators.get(t);
408
+ !i || i.startTime !== null || (i.startTime = Date.now(), i.animator.backward());
435
409
  }
436
410
  forward() {
437
- var e, i;
438
- this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), (i = (e = this.config).onStart) == null || i.call(e), this.normalizeSchedule("forward").forEach((r) => {
439
- if (r.type === "wait")
440
- return;
441
- if (r.delay === 0) {
442
- this.startAnimator(r.id);
443
- return;
444
- }
445
- const o = window.setTimeout(
446
- () => this.startAnimator(r.id),
447
- r.delay
448
- );
449
- this.timeoutIds.push(o);
411
+ var i, e;
412
+ this.stop(), this.direction = "forward", this.completedCount = 0, this.completedAnimators.clear(), (e = (i = this.config).onStart) == null || e.call(i), this.normalizeSchedule("forward").forEach((o) => {
413
+ if (o.type !== "wait")
414
+ if (o.delay === 0)
415
+ this.startAnimator(o.id);
416
+ else {
417
+ const r = window.setTimeout(
418
+ () => this.startAnimator(o.id),
419
+ o.delay
420
+ );
421
+ this.timeoutIds.push(r);
422
+ }
450
423
  });
451
424
  }
452
425
  backward() {
453
- var e, i;
454
- this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), (i = (e = this.config).onStart) == null || i.call(e), this.normalizeSchedule("backward").forEach((r) => {
455
- if (r.type === "wait")
456
- return;
457
- if (r.delay === 0) {
458
- this.startBackwardAnimator(r.id);
459
- return;
460
- }
461
- const o = window.setTimeout(
462
- () => this.startBackwardAnimator(r.id),
463
- r.delay
464
- );
465
- this.timeoutIds.push(o);
426
+ var i, e;
427
+ this.stop(), this.direction = "backward", this.completedCount = 0, this.completedAnimators.clear(), (e = (i = this.config).onStart) == null || e.call(i), this.normalizeSchedule("backward").forEach((o) => {
428
+ if (o.type !== "wait")
429
+ if (o.delay === 0)
430
+ this.startBackwardAnimator(o.id);
431
+ else {
432
+ const r = window.setTimeout(
433
+ () => this.startBackwardAnimator(o.id),
434
+ o.delay
435
+ );
436
+ this.timeoutIds.push(r);
437
+ }
466
438
  });
467
439
  }
468
440
  stop() {
@@ -470,34 +442,28 @@ class j {
470
442
  t.animator.stop(), t.startTime = null;
471
443
  });
472
444
  }
473
- reverse(t) {
474
- ((t == null ? void 0 : t.offsetMode) ?? "immediate") !== "immediate" && console.warn(
475
- 'AnimationScheduler.reverse(): Only "immediate" offsetMode is currently supported. Falling back to "immediate".'
476
- ), this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((i) => {
477
- if (i.startTime === null)
445
+ reverse() {
446
+ this.direction = this.direction === "forward" ? "backward" : "forward", this.animators.forEach((t) => {
447
+ if (t.startTime === null)
478
448
  return;
479
- const r = i.animator.getCurrentState();
480
- if (r.type !== "single")
449
+ const i = t.animator.getCurrentState();
450
+ if (i.type !== "single")
481
451
  return;
482
- if (r.position === r.to) {
483
- const s = O.fromState(
452
+ if (i.position === i.to) {
453
+ const o = k.fromState(
454
+ { position: 1, velocity: 0 },
484
455
  {
485
- position: 1,
486
- velocity: 0
487
- },
488
- {
489
- from: i.item.to ?? 1,
490
- to: i.item.from ?? 0,
491
- spring: i.item.spring,
492
- onUpdate: i.item.tick,
493
- onComplete: () => this.onAnimatorComplete(i.id),
494
- onStart: i.item.onStart
456
+ from: t.item.to ?? 1,
457
+ to: t.item.from ?? 0,
458
+ spring: t.item.spring,
459
+ tick: t.item.tick,
460
+ onComplete: () => this.onAnimatorComplete(t.id),
461
+ onStart: t.item.onStart
495
462
  }
496
463
  );
497
- s.forward(), i.animator = s;
498
- return;
499
- }
500
- i.animator.reverse();
464
+ o.forward(), t.animator = o;
465
+ } else
466
+ t.animator.reverse();
501
467
  });
502
468
  }
503
469
  getCurrentState() {
@@ -509,13 +475,13 @@ class j {
509
475
  };
510
476
  }
511
477
  }
512
- const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
478
+ const X = Symbol.for("TRANSITION_STRATEGY"), tt = (n) => ({
513
479
  runIn: async (t) => {
514
- const { currentAnimation: e } = n;
515
- if (e && e.direction === "out") {
516
- const s = e.controller.getCurrentState();
517
- if (e.controller.stop(), s.type === "multi")
518
- return e.controller.reverse(), {
480
+ const { currentAnimation: i } = n;
481
+ if (i && i.direction === "out") {
482
+ const s = i.controller.getCurrentState();
483
+ if (i.controller.stop(), s.type === "multi")
484
+ return i.controller.reverse(), {
519
485
  state: {
520
486
  position: 0,
521
487
  velocity: 0
@@ -525,24 +491,24 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
525
491
  direction: "forward"
526
492
  };
527
493
  if (t.out) {
528
- const d = await t.out, { from: l = 1, to: h = 0 } = d;
494
+ const a = await t.out, { from: c = 1, to: m = 0 } = a;
529
495
  return {
530
- config: d,
496
+ config: a,
531
497
  state: {
532
498
  position: s.position,
533
499
  velocity: s.velocity
534
500
  },
535
- from: l,
501
+ from: c,
536
502
  // OUT animation's from
537
- to: h,
503
+ to: m,
538
504
  // OUT animation's to
539
505
  direction: "backward"
540
- // Will actually go 0→1
506
+ // Will actually go 0→1 (backward means toward 'from')
541
507
  };
542
508
  }
543
509
  }
544
- const i = await t.in;
545
- if (!i)
510
+ const e = await t.in;
511
+ if (!e)
546
512
  return {
547
513
  state: {
548
514
  position: 0,
@@ -552,9 +518,9 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
552
518
  to: 1,
553
519
  direction: "forward"
554
520
  };
555
- if ("springs" in i)
521
+ if ("springs" in e)
556
522
  return {
557
- config: i,
523
+ config: e,
558
524
  state: {
559
525
  position: 0,
560
526
  velocity: 0
@@ -563,24 +529,24 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
563
529
  to: 1,
564
530
  direction: "forward"
565
531
  };
566
- const { from: r = 0, to: o = 1 } = i;
532
+ const { from: o = 0, to: r = 1 } = e;
567
533
  return {
568
- config: i,
534
+ config: e,
569
535
  state: {
570
- position: r,
536
+ position: o,
571
537
  velocity: 0
572
538
  },
573
- from: r,
574
- to: o,
539
+ from: o,
540
+ to: r,
575
541
  direction: "forward"
576
542
  };
577
543
  },
578
544
  runOut: async (t) => {
579
- const { currentAnimation: e } = n;
580
- if (e && e.direction === "in") {
581
- const s = e.controller.getCurrentState();
582
- if (e.controller.stop(), s.type === "multi")
583
- return e.controller.reverse(), {
545
+ const { currentAnimation: i } = n;
546
+ if (i && i.direction === "in") {
547
+ const s = i.controller.getCurrentState();
548
+ if (i.controller.stop(), s.type === "multi")
549
+ return i.controller.reverse(), {
584
550
  state: {
585
551
  position: 1,
586
552
  velocity: 0
@@ -590,24 +556,24 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
590
556
  direction: "forward"
591
557
  };
592
558
  if (t.in) {
593
- const d = await t.in, { from: l = 0, to: h = 1 } = d;
559
+ const a = await t.in, { from: c = 0, to: m = 1 } = a;
594
560
  return {
595
- config: d,
561
+ config: a,
596
562
  state: {
597
563
  position: s.position,
598
564
  velocity: s.velocity
599
565
  },
600
- from: l,
566
+ from: c,
601
567
  // IN animation's from
602
- to: h,
568
+ to: m,
603
569
  // IN animation's to
604
570
  direction: "backward"
605
- // Will actually go 1→0
571
+ // Will actually go 1→0 (backward means toward 'from')
606
572
  };
607
573
  }
608
574
  }
609
- const i = await t.out;
610
- if (!i)
575
+ const e = await t.out;
576
+ if (!e)
611
577
  return {
612
578
  state: {
613
579
  position: 1,
@@ -617,9 +583,9 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
617
583
  to: 0,
618
584
  direction: "forward"
619
585
  };
620
- if ("springs" in i)
586
+ if ("springs" in e)
621
587
  return {
622
- config: i,
588
+ config: e,
623
589
  state: {
624
590
  position: 1,
625
591
  velocity: 0
@@ -628,19 +594,19 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
628
594
  to: 0,
629
595
  direction: "forward"
630
596
  };
631
- const { from: r = 1, to: o = 0 } = i;
597
+ const { from: o = 1, to: r = 0 } = e;
632
598
  return {
633
- config: i,
599
+ config: e,
634
600
  state: {
635
- position: r,
601
+ position: o,
636
602
  velocity: 0
637
603
  },
638
- from: r,
639
- to: o,
604
+ from: o,
605
+ to: r,
640
606
  direction: "forward"
641
607
  };
642
608
  }
643
- }), N = () => ({
609
+ }), it = () => ({
644
610
  runIn: async (n) => {
645
611
  const t = await n.in;
646
612
  if (!t)
@@ -664,15 +630,15 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
664
630
  to: 1,
665
631
  direction: "forward"
666
632
  };
667
- const { from: e = 0, to: i = 1 } = t;
633
+ const { from: i = 0, to: e = 1 } = t;
668
634
  return {
669
635
  config: t,
670
636
  state: {
671
- position: e,
637
+ position: i,
672
638
  velocity: 0
673
639
  },
674
- from: e,
675
- to: i,
640
+ from: i,
641
+ to: e,
676
642
  direction: "forward"
677
643
  };
678
644
  },
@@ -699,385 +665,376 @@ const U = Symbol.for("TRANSITION_STRATEGY"), H = (n) => ({
699
665
  to: 0,
700
666
  direction: "forward"
701
667
  };
702
- const { from: e = 1, to: i = 0 } = t;
668
+ const { from: i = 1, to: e = 0 } = t;
703
669
  return {
704
670
  config: t,
705
671
  state: {
706
- position: e,
672
+ position: i,
707
673
  velocity: 0
708
674
  },
709
- from: e,
710
- to: i,
675
+ from: i,
676
+ to: e,
711
677
  direction: "forward"
712
678
  };
713
679
  }
714
680
  });
715
- function W(n, t) {
716
- var u;
717
- let e = null, i = null, r = null, o = null;
681
+ function et(n, t) {
682
+ var h;
683
+ let i = null, e = null, o = null, r = null;
718
684
  const s = {
719
685
  get currentAnimation() {
720
- return e;
686
+ return i;
721
687
  }
722
- }, d = ((u = t == null ? void 0 : t.strategy) == null ? void 0 : u.call(t, s)) || H(s), l = async (a) => {
723
- var S, T, C;
724
- i && (i.remove(), i = null);
725
- const p = n(), c = p.in && await p.in(a), g = !(t != null && t.strategy) && p.out ? p.out(a) : void 0;
726
- if (!c)
688
+ }, a = ((h = t == null ? void 0 : t.strategy) == null ? void 0 : h.call(t, s)) || tt(s), c = async (u) => {
689
+ var S, E, A;
690
+ e && (e.remove(), e = null);
691
+ const g = n(), l = g.in && await g.in(u), w = !(t != null && t.strategy) && g.out ? g.out(u) : void 0;
692
+ if (!l)
727
693
  return;
728
- if (V(c)) {
694
+ if (M(l)) {
729
695
  const v = {
730
- in: Promise.resolve(c),
731
- out: g && Promise.resolve(g)
696
+ in: Promise.resolve(l),
697
+ out: w && Promise.resolve(w)
732
698
  };
733
- if (!(await d.runIn(v)).config) {
734
- e && (e.direction = "in");
699
+ if (!(await a.runIn(v)).config) {
700
+ i && (i.direction = "in");
735
701
  return;
736
702
  }
737
- (S = c.prepare) == null || S.call(c, a), c.wait && await c.wait();
738
- const E = new j({
739
- ...c,
703
+ (S = l.prepare) == null || S.call(l, u), l.wait && await l.wait();
704
+ const C = new L({
705
+ ...l,
740
706
  onEnd: () => {
741
- var A;
742
- e = null, (A = c.onEnd) == null || A.call(c);
707
+ var b;
708
+ i = null, (b = l.onEnd) == null || b.call(l);
743
709
  }
744
710
  });
745
- e = {
746
- controller: E,
747
- direction: "in"
748
- }, E.forward();
711
+ i = { controller: C, direction: "in" }, C.forward();
749
712
  return;
750
713
  }
751
- const w = {
752
- in: Promise.resolve(c),
753
- out: g && Promise.resolve(g)
754
- }, f = await d.runIn(w);
755
- if (!f.config)
714
+ const d = {
715
+ in: Promise.resolve(l),
716
+ out: w && Promise.resolve(w)
717
+ }, f = await a.runIn(d);
718
+ if (!f.config || "springs" in f.config)
756
719
  return;
757
- if ("springs" in f.config) {
758
- console.error("Unexpected MultiSpringConfig in single-spring path");
759
- return;
760
- }
761
- (C = (T = f.config).prepare) == null || C.call(T, a), f.config.wait && await f.config.wait();
762
- const y = O.fromState(f.state, {
720
+ (A = (E = f.config).prepare) == null || A.call(E, u), f.config.wait && await f.config.wait();
721
+ const y = k.fromState(f.state, {
763
722
  from: f.from,
764
723
  to: f.to,
765
724
  spring: f.config.spring,
725
+ tick: f.config.tick,
726
+ css: f.config.css ? { element: u, style: f.config.css } : void 0,
766
727
  onStart: f.config.onStart,
767
- onUpdate: f.config.tick,
768
728
  onComplete: () => {
769
- var v, b;
770
- e = null, (b = (v = f.config) == null ? void 0 : v.onEnd) == null || b.call(v);
729
+ var v, T;
730
+ i = null, (T = (v = f.config) == null ? void 0 : v.onEnd) == null || T.call(v);
771
731
  }
772
732
  });
773
- e = { controller: y, direction: "in" }, f.direction === "forward" ? y.forward() : y.backward();
774
- }, h = async (a) => {
775
- var S, T, C;
776
- i = a;
777
- const p = n(), c = p.out && await p.out(a);
778
- if (!c)
733
+ i = { controller: y, direction: "in" }, f.direction === "forward" ? y.forward() : y.backward();
734
+ }, m = async (u) => {
735
+ var S, E, A;
736
+ e = u;
737
+ const g = n(), l = g.out && await g.out(u);
738
+ if (!l)
779
739
  return;
780
- if (V(c)) {
740
+ if (M(l)) {
781
741
  const v = {
782
742
  in: void 0,
783
- // Don't fetch IN config for exit transitions
784
- out: Promise.resolve(c)
743
+ out: Promise.resolve(l)
785
744
  };
786
- if (!(await d.runOut(v)).config) {
787
- e && (e.direction = "out"), i && (i.remove(), i = null);
745
+ if (!(await a.runOut(v)).config) {
746
+ i && (i.direction = "out"), e && (e.remove(), e = null);
788
747
  return;
789
748
  }
790
- (S = c.prepare) == null || S.call(c, a), y(), c.wait && await c.wait();
791
- const E = new j({
792
- ...c,
749
+ (S = l.prepare) == null || S.call(l, u), y(), l.wait && await l.wait();
750
+ const C = new L({
751
+ ...l,
793
752
  onEnd: () => {
794
- var A, P;
795
- (A = c.onEnd) == null || A.call(c), i && (i.remove(), i = null), e = null, (P = t == null ? void 0 : t.onCleanupEnd) == null || P.call(t);
753
+ var b, O;
754
+ (b = l.onEnd) == null || b.call(l), e && (e.remove(), e = null), i = null, (O = t == null ? void 0 : t.onCleanupEnd) == null || O.call(t);
796
755
  }
797
756
  });
798
- e = {
799
- controller: E,
800
- direction: "out"
801
- }, E.forward();
757
+ i = { controller: C, direction: "out" }, C.forward();
802
758
  return;
803
759
  }
804
- const g = {
760
+ const w = {
805
761
  in: void 0,
806
- // Don't fetch IN config for exit transitions
807
- out: Promise.resolve(c)
808
- }, w = await d.runOut(g);
809
- if (!w.config)
810
- return;
811
- if ("springs" in w.config) {
812
- console.error("Unexpected MultiSpringConfig in single-spring path");
762
+ out: Promise.resolve(l)
763
+ }, d = await a.runOut(w);
764
+ if (!d.config || "springs" in d.config)
813
765
  return;
814
- }
815
- (C = (T = w.config).prepare) == null || C.call(T, a), y(), w.config.wait && await w.config.wait();
816
- const f = O.fromState(w.state, {
817
- from: w.from,
818
- to: w.to,
819
- spring: w.config.spring,
820
- onStart: w.config.onStart,
821
- onUpdate: w.config.tick,
766
+ (A = (E = d.config).prepare) == null || A.call(E, u), y(), d.config.wait && await d.config.wait();
767
+ const f = k.fromState(d.state, {
768
+ from: d.from,
769
+ to: d.to,
770
+ spring: d.config.spring,
771
+ tick: d.config.tick,
772
+ css: d.config.css ? { element: u, style: d.config.css } : void 0,
773
+ onStart: d.config.onStart,
822
774
  onComplete: () => {
823
- var v, b, E;
824
- (b = (v = w.config) == null ? void 0 : v.onEnd) == null || b.call(v), i && (i.remove(), i = null), e = null, (E = t == null ? void 0 : t.onCleanupEnd) == null || E.call(t);
775
+ var v, T, C;
776
+ (T = (v = d.config) == null ? void 0 : v.onEnd) == null || T.call(v), e && (e.remove(), e = null), i = null, (C = t == null ? void 0 : t.onCleanupEnd) == null || C.call(t);
825
777
  }
826
778
  });
827
- e = { controller: f, direction: "out" }, w.direction === "forward" ? f.forward() : f.backward();
779
+ i = { controller: f, direction: "out" }, d.direction === "forward" ? f.forward() : f.backward();
828
780
  function y() {
829
- !r || !i || (o && r.contains(o) ? r.insertBefore(i, o) : r.appendChild(i));
781
+ !o || !e || (r && o.contains(r) ? o.insertBefore(e, r) : o.appendChild(e));
830
782
  }
831
783
  };
832
- return (a) => {
833
- if (a)
834
- return r = a.parentElement, o = a.nextElementSibling, l(a), () => {
835
- if (a.isConnected) {
836
- const p = a.cloneNode(!0);
837
- h(p);
784
+ return (u) => {
785
+ if (u)
786
+ return o = u.parentElement, r = u.nextElementSibling, c(u), () => {
787
+ if (u.isConnected) {
788
+ const g = u.cloneNode(!0);
789
+ m(g);
838
790
  } else
839
- h(a);
791
+ m(u);
840
792
  };
841
793
  };
842
794
  }
843
- const Y = 3, X = (n) => {
795
+ const nt = 3, ot = (n) => {
844
796
  if (!n) return null;
845
797
  const t = n.split(`
846
- `).map((e) => e.trim());
847
- for (let e = Y; e < Math.min(t.length, 6); e++) {
848
- const i = t[e], r = i == null ? void 0 : i.match(/\(?([^):]+):(\d+):(\d+)\)?$/);
849
- if (!r)
798
+ `).map((i) => i.trim());
799
+ for (let i = nt; i < Math.min(t.length, 6); i++) {
800
+ const e = t[i], o = e == null ? void 0 : e.match(/\(?([^):]+):(\d+):(\d+)\)?$/);
801
+ if (!o)
850
802
  continue;
851
- const o = r[1] ?? "", s = r[2] ?? "0", d = r[3] ?? "0";
852
- return { file: o.split(/[\\/]/).pop() || o, line: s, column: d };
803
+ const r = o[1] ?? "", s = o[2] ?? "0", a = o[3] ?? "0";
804
+ return { file: r.split(/[\\/]/).pop() || r, line: s, column: a };
853
805
  }
854
806
  return null;
855
- }, M = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
856
- function B(n, t, e) {
857
- M.set(n, t);
858
- let i = R.get(n);
859
- return i || (i = W(
807
+ }, R = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
808
+ function rt(n, t, i) {
809
+ R.set(n, t);
810
+ let e = V.get(n);
811
+ return e || (e = et(
860
812
  () => {
861
- const r = M.get(n);
862
- return r || (console.warn(`Transition "${String(n)}" not found`), {});
813
+ const o = R.get(n);
814
+ return o || (console.warn(`Transition "${String(n)}" not found`), {});
863
815
  },
864
816
  {
865
- strategy: e,
866
- onCleanupEnd: () => z(n)
817
+ strategy: i,
818
+ onCleanupEnd: () => Y(n)
867
819
  }
868
- ), R.set(n, i), i);
820
+ ), V.set(n, e), e);
869
821
  }
870
- function z(n) {
871
- M.delete(n), R.delete(n);
822
+ function Y(n) {
823
+ R.delete(n), V.delete(n);
872
824
  }
873
- function K() {
874
- const n = X(new Error().stack);
825
+ function st() {
826
+ const n = ot(new Error().stack);
875
827
  return n ? `auto_${n.file}_${n.line}_${n.column}` : Symbol(`ssgoi_auto_${Date.now()}`);
876
828
  }
877
- const D = globalThis.FinalizationRegistry, L = D ? (
829
+ const _ = globalThis.FinalizationRegistry, F = _ ? (
878
830
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
879
- new D((n) => {
831
+ new _((n) => {
880
832
  try {
881
- z(n);
833
+ Y(n);
882
834
  } catch {
883
835
  }
884
836
  })
885
837
  ) : void 0;
886
- function nt(n) {
887
- const t = n.key ?? K();
888
- if (n.ref && L)
838
+ function gt(n) {
839
+ const t = n.key ?? st();
840
+ if (n.ref && F)
889
841
  try {
890
- L.register(n.ref, t);
842
+ F.register(n.ref, t);
891
843
  } catch {
892
844
  }
893
- return B(
845
+ return rt(
894
846
  t,
895
847
  {
896
848
  in: n.in,
897
849
  out: n.out
898
850
  },
899
- n[U]
851
+ n[X]
900
852
  );
901
853
  }
902
- function q(n) {
903
- const t = n.filter((e) => e.symmetric).map((e) => ({
904
- from: e.to,
905
- to: e.from,
906
- transition: e.transition
854
+ function ct(n) {
855
+ const t = n.filter((i) => i.symmetric).map((i) => ({
856
+ from: i.to,
857
+ to: i.from,
858
+ transition: i.transition
907
859
  }));
908
860
  return [...n, ...t];
909
861
  }
910
- function G(n) {
911
- let t = !1, e = 0, i = 0, r = !1;
912
- const o = 50, s = 50, d = (c) => {
862
+ function at(n) {
863
+ let t = !1, i = 0, e = 0, o = !1;
864
+ const r = 50, s = (w) => {
913
865
  if (!n) return;
914
- const g = c.touches[0];
915
- g && (r = g.clientX < s, r && (e = g.clientX, i = g.clientY));
916
- }, l = (c) => {
917
- if (!n || !r || t) return;
918
- const g = c.touches[0];
919
- if (!g) return;
920
- const w = g.clientX - e, f = g.clientY - i;
921
- w > o && Math.abs(w) > Math.abs(f) && (t = !0, setTimeout(() => {
922
- t = !1;
923
- }, 500));
924
- }, h = () => {
925
- n && (r = !1, e = 0, i = 0);
866
+ const d = w.touches[0];
867
+ d && (o = d.clientX < r, o && (i = d.clientX, e = d.clientY));
868
+ }, a = (w) => {
869
+ if (!n || !o) return;
870
+ const d = w.touches[0];
871
+ if (!d) return;
872
+ const f = d.clientX - i, y = d.clientY - e;
873
+ f > window.outerWidth / 2 - 5 && Math.abs(f) > Math.abs(y) ? t = !0 : t = !1;
874
+ }, c = () => {
875
+ n && (o = !1, i = 0, e = 0);
876
+ }, m = () => t, h = () => {
877
+ typeof window > "u" || n && (window.addEventListener("touchstart", s, { passive: !0 }), window.addEventListener("touchmove", a, { passive: !0 }), window.addEventListener("touchend", c, { passive: !0 }));
878
+ }, u = () => {
879
+ typeof window > "u" || (window.removeEventListener("touchstart", s), window.removeEventListener("touchmove", a), window.removeEventListener("touchend", c));
926
880
  };
881
+ let g = 0;
927
882
  return {
928
- initialize: () => {
929
- typeof window > "u" || n && (window.addEventListener("touchstart", d, { passive: !0 }), window.addEventListener("touchmove", l, { passive: !0 }), window.addEventListener("touchend", h, { passive: !0 }));
930
- },
931
- cleanup: () => {
932
- typeof window > "u" || (window.removeEventListener("touchstart", d), window.removeEventListener("touchmove", l), window.removeEventListener("touchend", h));
933
- },
934
- isSwipePending: () => t
883
+ initialize: h,
884
+ cleanup: u,
885
+ isSwipePending: m,
886
+ resetSwipeDetection: () => {
887
+ g++, g > 1 && (g = 0, t = !1);
888
+ }
935
889
  };
936
890
  }
937
- const J = (n) => {
891
+ const lt = (n) => {
938
892
  let t = n.parentElement;
939
893
  for (; t && t !== document.body; ) {
940
- const e = window.getComputedStyle(t), i = e.overflow + e.overflowY + e.overflowX;
941
- if (i.includes("auto") || i.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
894
+ const i = window.getComputedStyle(t), e = i.overflow + i.overflowY + i.overflowX;
895
+ if (e.includes("auto") || e.includes("scroll") || t.scrollHeight > t.clientHeight || t.scrollWidth > t.clientWidth)
942
896
  return t;
943
897
  t = t.parentElement;
944
898
  }
945
899
  return document.documentElement;
946
- }, Q = (n) => {
900
+ }, ut = (n) => {
947
901
  let t = n.parentElement;
948
902
  for (; t && t !== document.body; ) {
949
- const e = window.getComputedStyle(t).position;
950
- if (e === "relative" || e === "absolute" || e === "fixed" || e === "sticky")
903
+ const i = window.getComputedStyle(t).position;
904
+ if (i === "relative" || i === "absolute" || i === "fixed" || i === "sticky")
951
905
  return t;
952
906
  t = t.parentElement;
953
907
  }
954
908
  return document.body;
955
909
  };
956
- function Z() {
910
+ function ft() {
957
911
  let n = null, t = null;
958
- const e = /* @__PURE__ */ new Map();
959
- let i = null;
960
- const r = () => {
961
- n && i && e.set(i, {
912
+ const i = /* @__PURE__ */ new Map();
913
+ let e = null;
914
+ const o = () => {
915
+ n && e && i.set(e, {
962
916
  x: n.scrollLeft,
963
917
  y: n.scrollTop
964
918
  });
965
919
  };
966
920
  return {
967
- initializeContext: (u, a) => {
968
- t = u, n || (n = J(u), (n === document.documentElement ? window : n).addEventListener("scroll", r, {
921
+ initializeContext: (h, u) => {
922
+ t = h, n || (n = lt(h), (n === document.documentElement ? window : n).addEventListener("scroll", o, {
969
923
  passive: !0
970
- })), i = a;
924
+ })), e = u;
971
925
  },
972
- calculateScrollOffset: (u, a) => {
973
- const p = u && e.has(u) ? e.get(u) : { x: 0, y: 0 }, c = a && e.has(a) ? e.get(a) : { x: 0, y: 0 };
926
+ calculateScrollOffset: (h, u) => {
927
+ const g = h && i.has(h) ? i.get(h) : { x: 0, y: 0 }, l = u && i.has(u) ? i.get(u) : { x: 0, y: 0 };
974
928
  return {
975
- x: -c.x + p.x,
976
- y: -c.y + p.y
929
+ x: -l.x + g.x,
930
+ y: -l.y + g.y
977
931
  };
978
932
  },
979
933
  getScrollContainer: () => n,
980
- getPositionedParentElement: () => t ? Q(t) : document.body,
981
- getScrollPosition: (u) => u && e.has(u) ? e.get(u) : { x: 0, y: 0 }
934
+ getPositionedParentElement: () => t ? ut(t) : document.body,
935
+ getScrollPosition: (h) => h && i.has(h) ? i.get(h) : { x: 0, y: 0 }
982
936
  };
983
937
  }
984
- function x(n, t) {
938
+ function P(n, t) {
985
939
  if (t === "*")
986
940
  return !0;
987
941
  if (t.endsWith("/*")) {
988
- const e = t.slice(0, -2);
989
- return n === e || n.startsWith(e + "/");
942
+ const i = t.slice(0, -2);
943
+ return n === i || n.startsWith(i + "/");
990
944
  }
991
945
  return n === t;
992
946
  }
993
- function tt(n, t, e) {
994
- for (const i of e)
995
- if (x(n, i.from) && x(t, i.to))
996
- return i.transition;
997
- for (const i of e)
998
- if ((i.from === "*" || x(n, i.from)) && (i.to === "*" || x(t, i.to)))
999
- return i.transition;
947
+ function mt(n, t, i) {
948
+ for (const e of i)
949
+ if (P(n, e.from) && P(t, e.to))
950
+ return e.transition;
951
+ for (const e of i)
952
+ if ((e.from === "*" || P(n, e.from)) && (e.to === "*" || P(t, e.to)))
953
+ return e.transition;
1000
954
  return null;
1001
955
  }
1002
- function ot(n) {
956
+ function pt(n) {
1003
957
  const {
1004
958
  transitions: t = [],
1005
- defaultTransition: e,
1006
- middleware: i = (f, y) => ({ from: f, to: y }),
959
+ defaultTransition: i,
960
+ middleware: e = (f, y) => ({ from: f, to: y }),
1007
961
  // Identity function as default
1008
- skipOnIosSwipe: r = !0
962
+ skipOnIosSwipe: o = !0
1009
963
  // Default to true - skip animations on iOS swipe
1010
964
  } = n;
1011
- let o = null;
1012
- const s = q(t), {
1013
- initializeContext: d,
1014
- calculateScrollOffset: l,
1015
- getScrollContainer: h,
1016
- getPositionedParentElement: u,
1017
- getScrollPosition: a
1018
- } = Z(), p = G(r);
1019
- p.initialize();
1020
- function c() {
1021
- if (o != null && o.from && (o != null && o.to)) {
1022
- const { from: f, to: y } = i(
1023
- o.from,
1024
- o.to
1025
- ), T = tt(
965
+ let r = null;
966
+ const s = ct(t), {
967
+ initializeContext: a,
968
+ calculateScrollOffset: c,
969
+ getScrollContainer: m,
970
+ getPositionedParentElement: h,
971
+ getScrollPosition: u
972
+ } = ft(), g = at(o);
973
+ g.initialize();
974
+ function l() {
975
+ if (r != null && r.from && (r != null && r.to)) {
976
+ const { from: f, to: y } = e(
977
+ r.from,
978
+ r.to
979
+ ), E = mt(
1026
980
  f,
1027
981
  y,
1028
982
  s
1029
- ) || e, C = l(
1030
- o.from,
1031
- o.to
983
+ ) || i, A = c(
984
+ r.from,
985
+ r.to
1032
986
  ), v = {
1033
- scrollOffset: C,
1034
- scroll: a(o.from),
987
+ scrollOffset: A,
988
+ scroll: u(r.from),
1035
989
  get scrollingElement() {
1036
- return h() || document.documentElement;
990
+ return m() || document.documentElement;
1037
991
  },
1038
992
  get positionedParent() {
1039
- return u();
993
+ return h();
1040
994
  }
1041
- }, b = {
1042
- scrollOffset: C,
995
+ }, T = {
996
+ scrollOffset: A,
1043
997
  get scroll() {
1044
- return o ? a(o.to) : { x: 0, y: 0 };
998
+ return r ? u(r.to) : { x: 0, y: 0 };
1045
999
  },
1046
1000
  get scrollingElement() {
1047
- return h() || document.documentElement;
1001
+ return m() || document.documentElement;
1048
1002
  },
1049
1003
  get positionedParent() {
1050
- return u();
1004
+ return h();
1051
1005
  }
1052
1006
  };
1053
- T && (T.out && o.outResolve && o.outResolve(
1054
- (E) => T.out(E, v)
1055
- ), T.in && o.inResolve && o.inResolve(
1056
- (E) => T.in(E, b)
1057
- )), o = null;
1007
+ E && (E.out && r.outResolve && r.outResolve(
1008
+ (C) => E.out(C, v)
1009
+ ), E.in && r.inResolve && r.inResolve(
1010
+ (C) => E.in(C, T)
1011
+ )), r = null;
1058
1012
  }
1059
1013
  }
1060
- const g = async (f, y) => p.isSwipePending() ? () => ({}) : y === "in" && (!o || !o.from) ? () => ({}) : (o || (o = {}), y === "out" ? (o.from = f, new Promise((S) => {
1061
- o.outResolve = S, c();
1062
- })) : (o.to = f, new Promise((S) => {
1063
- o.inResolve = S, c();
1014
+ const w = async (f, y) => g.isSwipePending() ? (g.resetSwipeDetection(), () => ({})) : y === "in" && (!r || !r.from) ? () => ({}) : (r || (r = {}), y === "out" ? (r.from = f, new Promise((S) => {
1015
+ r.outResolve = S, l();
1016
+ })) : (r.to = f, new Promise((S) => {
1017
+ r.inResolve = S, l();
1064
1018
  })));
1065
1019
  return (f) => ({
1066
1020
  key: f,
1067
- in: async (y) => (d(y, f), (await g(f, "in"))(y)),
1068
- out: async (y) => (await g(f, "out"))(y),
1021
+ in: async (y) => (a(y, f), (await w(f, "in"))(y)),
1022
+ out: async (y) => (await w(f, "out"))(y),
1069
1023
  // Add page transition strategy for page-level transitions
1070
- [U]: N
1024
+ [X]: it
1071
1025
  });
1072
1026
  }
1073
1027
  export {
1074
- U as TRANSITION_STRATEGY,
1075
- H as createDefaultStrategy,
1076
- N as createPageTransitionStrategy,
1077
- ot as createSggoiTransitionContext,
1078
- K as generateAutoKey,
1079
- V as isMultiSpring,
1080
- at as isSingleSpring,
1081
- lt as jaeminInternal,
1082
- nt as transition
1028
+ X as TRANSITION_STRATEGY,
1029
+ tt as createDefaultStrategy,
1030
+ it as createPageTransitionStrategy,
1031
+ pt as createSggoiTransitionContext,
1032
+ st as generateAutoKey,
1033
+ vt as isCssAnimation,
1034
+ M as isMultiSpring,
1035
+ St as isSingleSpring,
1036
+ Ct as isTickAnimation,
1037
+ At as jaeminInternal,
1038
+ gt as transition,
1039
+ Et as validateAnimationMode
1083
1040
  };