@mkbabb/keyframes.js 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,156 @@
1
+ import { f as e, l as t } from "./timeline-BjcmprQ6.js";
2
+ //#region src/animation/sequence.ts
3
+ var n = class {
4
+ entries = [];
5
+ labels = /* @__PURE__ */ new Map();
6
+ cursor = 0;
7
+ _time = 0;
8
+ respectReducedMotion;
9
+ playback = new t();
10
+ _boundFrame;
11
+ _resolvePlay = null;
12
+ _playOrigin = void 0;
13
+ _playingPromise = null;
14
+ _rate = 1;
15
+ _repeatCount = 1;
16
+ _yoyoOn = !1;
17
+ _paused = !1;
18
+ _lastClock = void 0;
19
+ constructor(e) {
20
+ this.respectReducedMotion = e?.respectReducedMotion ?? !1, this._boundFrame = this._frame.bind(this);
21
+ }
22
+ get duration() {
23
+ let e = 0;
24
+ for (let t of this.entries) {
25
+ let n = t.at + t.animation.options.duration;
26
+ n > e && (e = n);
27
+ }
28
+ return e;
29
+ }
30
+ get time() {
31
+ return this._time;
32
+ }
33
+ get progress() {
34
+ return this.duration === 0 ? 0 : this._time / this.duration;
35
+ }
36
+ set progress(t) {
37
+ this.seek(e(t, 0, 1) * this.duration);
38
+ }
39
+ get rate() {
40
+ return this._rate;
41
+ }
42
+ label(e, t) {
43
+ return this.labels.set(e, this.resolvePosition(t)), this;
44
+ }
45
+ add(e, t) {
46
+ let n = this.resolvePosition(t);
47
+ return this.entries.push({
48
+ animation: e,
49
+ at: n
50
+ }), this.entries.sort((e, t) => e.at - t.at), this.cursor = n + e.options.duration, this;
51
+ }
52
+ resolvePosition(e) {
53
+ if (e === void 0) return this.cursor;
54
+ if (typeof e == "number") return e;
55
+ let t = /^([+-])=(\d*\.?\d+)$/.exec(e);
56
+ if (t) {
57
+ let e = t[1] === "+" ? 1 : -1;
58
+ return this.cursor + e * Number.parseFloat(t[2]);
59
+ }
60
+ let n = this.labels.get(e);
61
+ if (n === void 0) throw Error(`Sequence: unknown position "${e}". Register it with .label("${e}", at) first, or pass a number / "+=n" / "-=n".`);
62
+ return n;
63
+ }
64
+ seek(e) {
65
+ return this._time = e, this._applyAt(e), this;
66
+ }
67
+ _applyAt(t) {
68
+ for (let { animation: n, at: r } of this.entries) {
69
+ let i = e(t - r, 0, n.options.duration);
70
+ n.interpFrames(i, !0);
71
+ }
72
+ }
73
+ _fold(t) {
74
+ let n = this.duration;
75
+ if (n <= 0) return 0;
76
+ let r = e(t, 0, n * this._repeatCount), i = Math.floor(r / n), a = r - i * n;
77
+ return a === 0 && i > 0 && (--i, a = n), this._yoyoOn && i % 2 == 1 ? n - a : a;
78
+ }
79
+ setTargets(...e) {
80
+ for (let { animation: t } of this.entries) t.setTargets(...e);
81
+ return this;
82
+ }
83
+ get finished() {
84
+ return this._playingPromise ?? Promise.resolve();
85
+ }
86
+ play() {
87
+ if (this._playingPromise) return this._playingPromise;
88
+ if (this.respectReducedMotion && r()) return this.seek(this.duration), Promise.resolve();
89
+ for (let { animation: e, at: t } of this.entries) e.startTime = t, e.started = !0, e.managed = !0;
90
+ this._time = 0, this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0;
91
+ let e = new Promise((e) => {
92
+ this._resolvePlay = e, this.playback.loop(this._boundFrame);
93
+ });
94
+ return this._playingPromise = e, e.finally(() => {
95
+ this._playingPromise = null;
96
+ }), e;
97
+ }
98
+ async _frame(e) {
99
+ this._playOrigin === void 0 && (this._playOrigin = this._rate === 0 ? e : e - this._time / this._rate), this._lastClock = e;
100
+ let t = (e - this._playOrigin) * this._rate, n = this.duration * this._repeatCount, r = this._rate >= 0 ? t >= n : t <= 0, i = r ? this._rate >= 0 ? this._restPhase() : 0 : this._fold(t);
101
+ if (this._time = i, this._isForwardMonotone()) for (let { animation: e, at: t } of this.entries) i >= t && i - t < e.options.duration && await e.advanceTo(i);
102
+ if (this._applyAt(i), r) {
103
+ this._settle();
104
+ let e = this._resolvePlay;
105
+ return this._resolvePlay = null, e?.(), !1;
106
+ }
107
+ return !0;
108
+ }
109
+ _isForwardMonotone() {
110
+ return this._rate === 1 && this._repeatCount === 1 && !this._yoyoOn;
111
+ }
112
+ _restPhase() {
113
+ let e = this.duration;
114
+ return this._yoyoOn && (this._repeatCount - 1) % 2 == 1 ? 0 : e;
115
+ }
116
+ _reanchor() {
117
+ if (!this._playingPromise) return;
118
+ let e = this._lastClock;
119
+ if (e === void 0) {
120
+ this._playOrigin = void 0;
121
+ return;
122
+ }
123
+ this._playOrigin = this._rate === 0 ? e : e - this._time / this._rate;
124
+ }
125
+ _settle() {
126
+ for (let { animation: e } of this.entries) e.managed = !1, e.started = !1, e.startTime = void 0;
127
+ this._playOrigin = void 0, this._lastClock = void 0, this._paused = !1;
128
+ }
129
+ stop() {
130
+ this.playback.stop(), this._settle();
131
+ let e = this._resolvePlay;
132
+ return this._resolvePlay = null, e?.(), this;
133
+ }
134
+ pause() {
135
+ return !this._playingPromise || this._paused ? this : (this._paused = !0, this.playback.stop(), this._playOrigin = void 0, this);
136
+ }
137
+ resume() {
138
+ return !this._playingPromise || !this._paused ? this : (this._paused = !1, this._playOrigin = void 0, this._lastClock = void 0, this.playback.loop(this._boundFrame), this);
139
+ }
140
+ timeScale(e) {
141
+ if (!Number.isFinite(e)) throw Error(`Sequence.timeScale(n): n must be a finite number, got ${e}.`);
142
+ return this._rate = e, this._reanchor(), this;
143
+ }
144
+ reverse() {
145
+ return this._rate = -this._rate, this._reanchor(), this;
146
+ }
147
+ repeat(e) {
148
+ if (e !== Infinity && (!Number.isInteger(e) || e < 1)) throw Error(`Sequence.repeat(count): count must be a positive integer or Infinity, got ${e}.`);
149
+ return this._repeatCount = e, this;
150
+ }
151
+ yoyo(e = !0) {
152
+ return this._yoyoOn = e, this;
153
+ }
154
+ }, r = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
155
+ //#endregion
156
+ export { n as t };
@@ -0,0 +1,51 @@
1
+ import { a as e } from "./timeline-BjcmprQ6.js";
2
+ //#region src/animation/springLinearStops.ts
3
+ function t(t) {
4
+ let n = t.sampleCount ?? 24, r = t.settleThreshold ?? .001, i = t.maxDuration ?? t.response * 4, a = new e({
5
+ response: t.response,
6
+ dampingFraction: t.dampingFraction,
7
+ initial: 0,
8
+ settleThreshold: r,
9
+ velocitySettleThreshold: r
10
+ });
11
+ a.target = 1;
12
+ let o = ["0"], s = i / (n + 1);
13
+ for (let e = 1; e <= n; e++) {
14
+ a._stepSeconds(s);
15
+ let t = e / (n + 1) * 100, r = a.settled ? 1 : a.value;
16
+ o.push(`${r.toFixed(5)} ${t.toFixed(3)}%`);
17
+ }
18
+ return o.push("1"), a.dispose(), `linear(${o.join(", ")})`;
19
+ }
20
+ //#endregion
21
+ //#region src/animation/springTimingFunction.ts
22
+ function n(n) {
23
+ let r = n.sampleCount ?? 64, i = n.settleThreshold ?? .001, a = n.maxDuration ?? n.response * 4, o = new e({
24
+ response: n.response,
25
+ dampingFraction: n.dampingFraction,
26
+ initial: 0,
27
+ settleThreshold: i,
28
+ velocitySettleThreshold: i
29
+ });
30
+ o.target = 1;
31
+ let s = new Float64Array(r + 1);
32
+ s[0] = 0;
33
+ let c = a / r;
34
+ for (let e = 1; e <= r; e++) o._stepSeconds(c), s[e] = o.settled ? 1 : o.value;
35
+ s[r] = 1, o.dispose();
36
+ let l = (e) => {
37
+ if (e <= 0) return 0;
38
+ if (e >= 1) return 1;
39
+ let t = e * r, n = Math.floor(t), i = t - n, a = s[n];
40
+ return a + (s[n + 1] - a) * i;
41
+ }, u = {
42
+ response: n.response,
43
+ dampingFraction: n.dampingFraction
44
+ };
45
+ return n.settleThreshold !== void 0 && (u.settleThreshold = n.settleThreshold), n.maxDuration !== void 0 && (u.maxDuration = n.maxDuration), {
46
+ fn: l,
47
+ css: t(u)
48
+ };
49
+ }
50
+ //#endregion
51
+ export { t as n, n as t };
@@ -2,8 +2,9 @@
2
2
  var e = (e) => typeof e == "string" ? JSON.stringify(e) : typeof e == "function" ? `[function ${e.name || "anonymous"}]` : String(e), t = class extends Error {
3
3
  option;
4
4
  value;
5
- constructor(t, n, r) {
6
- super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n;
5
+ code;
6
+ constructor(t, n, r, i) {
7
+ super(`Invalid value for animation option "${t}": ${e(n)} — ${r}`), this.name = "AnimationOptionError", this.option = t, this.value = n, i !== void 0 && (this.code = i);
7
8
  }
8
9
  }, n = class extends Error {
9
10
  easingName;
@@ -25,7 +26,7 @@ var i = (e) => typeof e == "function" ? { fn: e } : e, a = /^(linear|ease|ease-i
25
26
  async function c(e) {
26
27
  let t;
27
28
  try {
28
- t = await import("./engine-Cj0T6OIH.js");
29
+ t = await import("./engine-BKm1GcJT.js");
29
30
  } catch (t) {
30
31
  throw Error(`keyframes: the engine chunk failed to load while resolving easing "${e}" — the easing registry is unreachable.`, { cause: t });
31
32
  }
@@ -35,40 +36,28 @@ async function c(e) {
35
36
  return a && (i.css = a), i;
36
37
  }
37
38
  //#endregion
38
- //#region src/animation/internal/binarySearch.ts
39
- function l(e, t, n, r) {
40
- let i = 0, a = e.length - 1;
41
- for (; i <= a;) {
42
- let o = i + a >> 1, s = e[o];
43
- if (t < n(s)) a = o - 1;
44
- else if (t > r(s)) i = o + 1;
45
- else return o;
46
- }
47
- return -1;
48
- }
49
- //#endregion
50
39
  //#region src/animation/internal/leaves.ts
51
- var u = 1e3 / 60;
52
- function d(e, t, n) {
40
+ var l = 1e3 / 60;
41
+ function u(e, t, n) {
53
42
  return Math.min(Math.max(e, t), n);
54
43
  }
55
- function f(e, t, n, r = 0, i = 1) {
44
+ function d(e, t, n, r = 0, i = 1) {
56
45
  if (n === t) throw Error("fromMax and fromMin cannot be equal");
57
46
  let a = (i - r) / (n - t);
58
47
  return (e - t) * a + r;
59
48
  }
60
- function p(e, t, n) {
49
+ function f(e, t, n) {
61
50
  return (1 - n) * e + n * t;
62
51
  }
63
- function m(e) {
52
+ function p(e) {
64
53
  if (typeof window < "u" && window.requestAnimationFrame) return window.requestAnimationFrame(e);
65
- let t = u, n = Date.now();
54
+ let t = l, n = Date.now();
66
55
  return setTimeout(() => {
67
56
  let r = Date.now(), i = r - n;
68
- n = r, t = Math.max(0, u - i), e(r);
57
+ n = r, t = Math.max(0, l - i), e(r);
69
58
  }, t);
70
59
  }
71
- function h(e) {
60
+ function m(e) {
72
61
  if (e != null) {
73
62
  if (typeof e == "number" && typeof window < "u" && window.cancelAnimationFrame) return window.cancelAnimationFrame(e);
74
63
  clearTimeout(e);
@@ -76,16 +65,19 @@ function h(e) {
76
65
  }
77
66
  //#endregion
78
67
  //#region src/animation/internal/reduced-motion.ts
79
- var g = "(prefers-reduced-motion: reduce)", _ = null, v;
80
- function y() {
68
+ var h = "(prefers-reduced-motion: reduce)", g = null, _;
69
+ function v() {
81
70
  let e = typeof window > "u" ? void 0 : window.matchMedia;
82
- return typeof e == "function" ? _ !== null && v === e ? _ : (v = e, _ = e.call(window, g), _) : (_ = null, v = e, null);
71
+ return typeof e == "function" ? g !== null && _ === e ? g : (_ = e, g = e.call(window, h), g) : (g = null, _ = e, null);
83
72
  }
84
- function b() {
85
- return y()?.matches ?? !1;
73
+ function y() {
74
+ return v()?.matches ?? !1;
75
+ }
76
+ function b(e) {
77
+ return e === !1 || e === void 0 || !y() ? 1 : e === !0 || e < 0 ? 0 : e > 1 ? 1 : e;
86
78
  }
87
79
  function x(e, t, n) {
88
- return e && b() ? t() : n();
80
+ return !e && e !== 0 || !y() ? n() : e === !0 || e === 0 ? t() : n();
89
81
  }
90
82
  //#endregion
91
83
  //#region src/animation/playback.ts
@@ -100,35 +92,35 @@ var S = class {
100
92
  }
101
93
  _run(e) {
102
94
  let t = ++this._gen, n = (e) => {
103
- t === this._gen && (e ? this._rafId = m(r) : this._cleanup());
95
+ t === this._gen && (e ? this._rafId = p(r) : this._cleanup());
104
96
  }, r = (t) => {
105
97
  let r = e(t);
106
98
  r && typeof r.then == "function" ? r.then(n) : n(r);
107
99
  };
108
- this._rafId = m(r);
100
+ this._rafId = p(r);
109
101
  }
110
- play(e, t, n) {
102
+ play = (e, t, n) => {
111
103
  if (e <= 0) throw Error("RAFPlayback.play() requires a duration > 0.");
112
104
  return this.stop(), x(n?.respectReducedMotion, () => (t(1), Promise.resolve()), () => new Promise((n) => {
113
105
  this._resolve = n, this._startTime = void 0, this._run((n) => {
114
106
  this._startTime === void 0 && (this._startTime = n);
115
- let r = d((n - this._startTime) / e, 0, 1);
107
+ let r = u((n - this._startTime) / e, 0, 1);
116
108
  return t(r), r < 1;
117
109
  });
118
110
  }));
119
- }
120
- drive(e, t) {
111
+ };
112
+ drive = (e, t) => {
121
113
  this._rafId === null && (this._lastFrameT = 0, this._run((n) => {
122
114
  let r = this._lastFrameT ? n - this._lastFrameT : 16.667;
123
115
  return this._lastFrameT = n, e.tickDt(r), t?.(), !e.settled;
124
116
  }));
125
- }
126
- loop(e) {
117
+ };
118
+ loop = (e) => {
127
119
  this.stop(), this._run(e);
128
- }
129
- stop() {
130
- this._gen++, this._rafId !== null && h(this._rafId), this._cleanup();
131
- }
120
+ };
121
+ stop = () => {
122
+ this._gen++, this._rafId !== null && m(this._rafId), this._cleanup();
123
+ };
132
124
  _cleanup() {
133
125
  this._rafId = null, this._startTime = void 0, this._lastFrameT = 0;
134
126
  let e = this._resolve;
@@ -164,7 +156,7 @@ var S = class {
164
156
  return this.isSettled;
165
157
  }
166
158
  setTarget(e) {
167
- this.options.clamp && (e = d(e, 0, 1));
159
+ this.options.clamp && (e = u(e, 0, 1));
168
160
  let t = Math.abs(e - this.targetValue);
169
161
  t > 0 && t >= this.options.targetEpsilon && (this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
170
162
  this.isSettled = !1, this._onFrame && this._startLoop();
@@ -176,7 +168,7 @@ var S = class {
176
168
  tickDt(e) {
177
169
  if (this.isSettled) return this.currentValue;
178
170
  let t = 1 - Math.exp(-this.options.damping * e / 16.667);
179
- return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = d(this.currentValue, 0, 1)), this.currentValue;
171
+ return this.currentValue += (this.targetValue - this.currentValue) * t, Math.abs(this.targetValue - this.currentValue) < this.options.snapThreshold && (this.currentValue = this.targetValue, this.isSettled = !0), this.options.clamp && (this.currentValue = u(this.currentValue, 0, 1)), this.currentValue;
180
172
  }
181
173
  snap() {
182
174
  this.currentValue = this.targetValue, this.isSettled = !0, this._playback.stop();
@@ -200,7 +192,150 @@ var S = class {
200
192
  _startLoop() {
201
193
  this._playback.drive(this, () => this._onFrame?.(this.currentValue));
202
194
  }
203
- }, T = class {
195
+ };
196
+ //#endregion
197
+ //#region src/animation/spring.ts
198
+ function T(e) {
199
+ let { visualDuration: t, duration: n, bounce: r = 0, ...i } = e, a = t ?? n ?? E.response, o = 1 - u(r, -1, 1);
200
+ return {
201
+ ...i,
202
+ response: a,
203
+ dampingFraction: o
204
+ };
205
+ }
206
+ var E = {
207
+ response: .5,
208
+ dampingFraction: .86,
209
+ initial: 0,
210
+ initialVelocity: 0,
211
+ settleThreshold: .001,
212
+ velocitySettleThreshold: .001,
213
+ respectReducedMotion: !1
214
+ }, D = class e {
215
+ options;
216
+ targetValue;
217
+ currentValue;
218
+ currentVelocity;
219
+ isSettled;
220
+ elapsed;
221
+ originValue;
222
+ originVelocity;
223
+ amplitudeScale = 1;
224
+ omega;
225
+ zeta;
226
+ omegaD;
227
+ subscribers = /* @__PURE__ */ new Set();
228
+ disposed = !1;
229
+ _playback = new S();
230
+ _onFrame = void 0;
231
+ constructor(e) {
232
+ this.options = {
233
+ ...E,
234
+ ...e
235
+ }, this.targetValue = this.options.initial, this.currentValue = this.options.initial, this.currentVelocity = this.options.initialVelocity, this.isSettled = this.options.initialVelocity === 0, this.elapsed = 0, this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.amplitudeScale = b(this.options.respectReducedMotion), this.omega = 2 * Math.PI / this.options.response, this.zeta = this.options.dampingFraction, this.omegaD = this.zeta < 1 ? this.omega * Math.sqrt(1 - this.zeta * this.zeta) : 0;
236
+ }
237
+ static fromDuration(t) {
238
+ return new e(T(t ?? {}));
239
+ }
240
+ get target() {
241
+ return this.targetValue;
242
+ }
243
+ get value() {
244
+ return this.currentValue;
245
+ }
246
+ get velocity() {
247
+ return this.currentVelocity;
248
+ }
249
+ get settled() {
250
+ return this.isSettled;
251
+ }
252
+ set target(e) {
253
+ e === this.targetValue && !this.options.initialVelocity || this.reseatTarget(e);
254
+ }
255
+ reseatTarget(e) {
256
+ this.targetValue = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
257
+ this.originValue = this.currentValue, this.originVelocity = this.currentVelocity, this.elapsed = 0, this.isSettled = !1, this.amplitudeScale = b(this.options.respectReducedMotion), this._onFrame && this._startLoop();
258
+ });
259
+ }
260
+ _snapSettled() {
261
+ this.currentValue = this.targetValue, this.currentVelocity = 0, this.originValue = this.targetValue, this.originVelocity = 0, this.elapsed = 0, this.isSettled = !0, this.emit(), this._playback.stop();
262
+ }
263
+ tickDt(e) {
264
+ return this._stepSeconds(e / 1e3);
265
+ }
266
+ _stepSeconds(e) {
267
+ return this.disposed || this.isSettled || e <= 0 ? this.currentValue : (this.elapsed += e, this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
268
+ }
269
+ tickToTime(e) {
270
+ return this.disposed || this.isSettled ? this.currentValue : (this.elapsed = Math.max(0, e), this.evaluateAt(this.elapsed), this.checkSettled(), this.emit(), this.currentValue);
271
+ }
272
+ evaluateAt(e) {
273
+ let t = this.amplitudeScale, n = this.originValue + t * (this.targetValue - this.originValue), r = this.originValue - n, i = this.originVelocity, a = this.omega, o = this.zeta, s, c;
274
+ if (o < 1) {
275
+ let t = this.omegaD, n = Math.exp(-o * a * e), l = r, u = (i + o * a * r) / t, d = Math.cos(t * e), f = Math.sin(t * e);
276
+ s = n * (l * d + u * f), c = n * ((u * t - l * o * a) * d - (l * t + u * o * a) * f);
277
+ } else if (o === 1) {
278
+ let t = Math.exp(-a * e), n = r, o = i + a * r;
279
+ s = t * (n + o * e), c = t * (o - a * (n + o * e));
280
+ } else {
281
+ let t = a * Math.sqrt(o * o - 1), n = -o * a + t, l = -o * a - t, u = (i - l * r) / (n - l), d = r - u, f = Math.exp(n * e), p = Math.exp(l * e);
282
+ s = u * f + d * p, c = u * n * f + d * l * p;
283
+ }
284
+ this.currentValue = n + s, this.currentVelocity = c;
285
+ }
286
+ checkSettled() {
287
+ let e = this.amplitudeScale, t = this.originValue + e * (this.targetValue - this.originValue), n = Math.abs(this.currentValue - t), r = Math.abs(this.currentVelocity);
288
+ n < this.options.settleThreshold && r < this.options.velocitySettleThreshold && (this.currentValue = t, this.currentVelocity = 0, this.isSettled = !0);
289
+ }
290
+ snap() {
291
+ this._snapSettled();
292
+ }
293
+ reset(e, t) {
294
+ let n = e ?? 0, r = t ?? 0;
295
+ this.targetValue = n, this.currentValue = n, this.currentVelocity = r, this.originValue = n, this.originVelocity = r, this.elapsed = 0, this.amplitudeScale = b(this.options.respectReducedMotion), this.isSettled = r === 0, this.emit(), this._playback.stop();
296
+ }
297
+ subscribe(e) {
298
+ return this.subscribers.add(e), () => {
299
+ this.subscribers.delete(e);
300
+ };
301
+ }
302
+ emit() {
303
+ if (this.subscribers.size !== 0) for (let e of this.subscribers) e(this.currentValue, this.currentVelocity);
304
+ }
305
+ dispose() {
306
+ this.disposed = !0, this._playback.stop(), this.subscribers.clear();
307
+ }
308
+ play(e) {
309
+ this.disposed || (this._onFrame = e, x(this.options.respectReducedMotion, () => this._snapSettled(), () => {
310
+ if (this.isSettled) {
311
+ e?.(this.currentValue, this.currentVelocity);
312
+ return;
313
+ }
314
+ this._startLoop();
315
+ }));
316
+ }
317
+ stop() {
318
+ this._onFrame = void 0, this._playback.stop();
319
+ }
320
+ _startLoop() {
321
+ this._playback.drive(this, () => this._onFrame?.(this.currentValue, this.currentVelocity));
322
+ }
323
+ };
324
+ function O(e) {
325
+ let t = e.curr.time - e.prev.time;
326
+ return t <= 0 ? 0 : (e.curr.value - e.prev.value) / (t / 1e3);
327
+ }
328
+ function k(e, t, n) {
329
+ let r = O(e), i = new D({
330
+ ...n,
331
+ initial: e.curr.value,
332
+ initialVelocity: r
333
+ });
334
+ return i.target = t, i;
335
+ }
336
+ //#endregion
337
+ //#region src/animation/timeline.ts
338
+ var A = class {
204
339
  smoother;
205
340
  _easingFn;
206
341
  currentProgress = 0;
@@ -212,7 +347,7 @@ var S = class {
212
347
  this._easingFn = n == null ? (e) => e : i(n).fn, e?.smoothing === !1 ? this.smoother = null : this.smoother = new w(e?.smoothing);
213
348
  }
214
349
  applyPipeline() {
215
- let e = d(this.sample(), 0, 1);
350
+ let e = u(this.sample(), 0, 1);
216
351
  e = this._easingFn(e);
217
352
  let t = this.boundaryEpsilon;
218
353
  return e <= t ? e = 0 : e >= 1 - t && (e = 1), e;
@@ -240,7 +375,7 @@ var S = class {
240
375
  let t = e ?? 0;
241
376
  this.smoother && this.smoother.reset(t), this.currentProgress = t;
242
377
  }
243
- }, E = class extends T {
378
+ }, j = class extends A {
244
379
  threshold;
245
380
  getScrollY;
246
381
  getViewportHeight;
@@ -251,7 +386,7 @@ var S = class {
251
386
  let e = this.getViewportHeight() * this.threshold;
252
387
  return e <= 0 ? 0 : this.getScrollY() / e;
253
388
  }
254
- }, D = class extends T {
389
+ }, M = class extends A {
255
390
  value = 0;
256
391
  constructor(e) {
257
392
  super({
@@ -266,7 +401,7 @@ var S = class {
266
401
  return this.value;
267
402
  }
268
403
  };
269
- function O(e) {
404
+ function N(e) {
270
405
  if (typeof window > "u") return null;
271
406
  if (e.kind === "scroll") {
272
407
  if (globalThis.ScrollTimeline === void 0) return null;
@@ -278,4 +413,4 @@ function O(e) {
278
413
  return e.axis !== void 0 && (t.axis = e.axis), e.inset !== void 0 && (t.inset = e.inset), new globalThis.ViewTimeline(t);
279
414
  }
280
415
  //#endregion
281
- export { r as _, w as a, d as c, l as d, s as f, n as g, t as h, O as i, p as l, i as m, E as n, S as o, c as p, T as r, x as s, D as t, f as u };
416
+ export { i as _, D as a, r as b, w as c, x as d, u as f, c as g, s as h, N as i, S as l, d as m, j as n, O as o, f as p, A as r, k as s, M as t, b as u, t as v, n as y };