@algorisys/tinyfly 0.81.0 → 0.86.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.
- package/README.md +12 -5
- package/lib/addons/adapters.js +363 -248
- package/lib/addons/characters.js +1658 -1342
- package/lib/addons/dom-adapter-Cphr2HZn.js +372 -0
- package/lib/addons/gsap-compat.js +197 -187
- package/lib/addons/load-scene-vp14_Jj-.js +324 -0
- package/lib/addons/scene-3d-webgl.js +237 -0
- package/lib/addons/scene-3d.js +306 -0
- package/lib/addons/shading-ByG9UXd0.js +85 -0
- package/lib/browser/tinyfly-scene-3d-webgl.iife.js +114 -0
- package/lib/browser/tinyfly-scene-3d.iife.js +3 -0
- package/lib/browser/tinyfly.iife.js +4 -4
- package/lib/browser/tinyfly.js +3295 -2613
- package/lib/browser/tinyfly.umd.js +4 -4
- package/lib/cli/tools.js +137 -22
- package/lib/embed/tinyfly-embed.iife.js +4 -4
- package/lib/embed/tinyfly-embed.js +921 -833
- package/lib/engine/tinyfly-engine.js +1022 -776
- package/lib/engine/tinyfly-engine.umd.cjs +2 -2
- package/lib/headless/headless.js +264 -7
- package/lib/player/tinyfly-player.es.js +459 -371
- package/lib/player/tinyfly-player.iife.js +2 -2
- package/lib/player/tinyfly-player.umd.js +2 -2
- package/lib/types/adapters/canvas/canvas-adapter.d.ts +36 -0
- package/lib/types/adapters/transform-3d.d.ts +99 -0
- package/lib/types/adapters/webgl/webgl-adapter.d.ts +17 -0
- package/lib/types/characters/character.d.ts +20 -1
- package/lib/types/characters/dance.d.ts +47 -0
- package/lib/types/characters/index.d.ts +3 -1
- package/lib/types/characters/rig/body-plan.d.ts +3 -1
- package/lib/types/characters/rig/skeleton.d.ts +57 -0
- package/lib/types/characters/scene-objects.d.ts +2 -0
- package/lib/types/characters/species/human.d.ts +8 -0
- package/lib/types/compat/gsap/vars.d.ts +8 -0
- package/lib/types/engine/core/bake.d.ts +3 -1
- package/lib/types/engine/index.d.ts +1 -0
- package/lib/types/engine/interpolation/interpolators.d.ts +10 -3
- package/lib/types/engine/math/index.d.ts +11 -0
- package/lib/types/engine/math/mat4.d.ts +37 -0
- package/lib/types/engine/math/quat.d.ts +39 -0
- package/lib/types/engine/math/vec3.d.ts +16 -0
- package/lib/types/engine/types.d.ts +23 -2
- package/lib/types/scene-3d/camera.d.ts +27 -0
- package/lib/types/scene-3d/canvas-2d-renderer.d.ts +21 -0
- package/lib/types/scene-3d/geometry/extrude.d.ts +17 -0
- package/lib/types/scene-3d/geometry/mesh.d.ts +36 -0
- package/lib/types/scene-3d/geometry/primitives.d.ts +16 -0
- package/lib/types/scene-3d/geometry/triangulate.d.ts +24 -0
- package/lib/types/scene-3d/index.d.ts +20 -0
- package/lib/types/scene-3d/load-scene.d.ts +31 -0
- package/lib/types/scene-3d/object-kind.d.ts +54 -0
- package/lib/types/scene-3d/resolve-scene.d.ts +122 -0
- package/lib/types/scene-3d/scene-3d-adapter.d.ts +46 -0
- package/lib/types/scene-3d/scene-types.d.ts +191 -0
- package/lib/types/scene-3d/shading.d.ts +20 -0
- package/lib/types/scene-3d/validate-scene.d.ts +11 -0
- package/lib/types/scene-3d/webgl/gl-data.d.ts +28 -0
- package/lib/types/scene-3d/webgl/index.d.ts +16 -0
- package/lib/types/scene-3d/webgl/shaders.d.ts +29 -0
- package/lib/types/scene-3d/webgl/webgl2-renderer.d.ts +33 -0
- package/package.json +10 -2
- package/lib/addons/dom-adapter-CrNwoomd.js +0 -243
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
function
|
|
1
|
+
function ue(e) {
|
|
2
2
|
return typeof e == "object" && e !== null && e.type === "cubic-bezier";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function de(e) {
|
|
5
5
|
return typeof e == "object" && e !== null && e.type !== "cubic-bezier";
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
function
|
|
7
|
+
const st = 2;
|
|
8
|
+
function fe(e) {
|
|
9
|
+
return e.some((t) => t.interpolation !== void 0) ? 2 : 1;
|
|
10
|
+
}
|
|
11
|
+
function zt(e) {
|
|
9
12
|
return e.property === "text" && "textConfig" in e;
|
|
10
13
|
}
|
|
11
|
-
function
|
|
14
|
+
function gt(e) {
|
|
12
15
|
return e.kind === "inertia" && "inertia" in e;
|
|
13
16
|
}
|
|
14
|
-
function
|
|
17
|
+
function yt(e) {
|
|
15
18
|
return e.kind === "spring" && "spring" in e;
|
|
16
19
|
}
|
|
17
|
-
function
|
|
20
|
+
function pe(e) {
|
|
18
21
|
return e.property === "motionPath" && "motionPathConfig" in e;
|
|
19
22
|
}
|
|
20
|
-
function
|
|
23
|
+
function Qt(e, t, n = "start") {
|
|
21
24
|
if (t <= 1) return 0;
|
|
22
25
|
if (typeof n == "number") {
|
|
23
|
-
const
|
|
24
|
-
return Math.abs(e -
|
|
26
|
+
const i = Math.max(0, Math.min(t - 1, n));
|
|
27
|
+
return Math.abs(e - i);
|
|
25
28
|
}
|
|
26
29
|
switch (n) {
|
|
27
30
|
case "end":
|
|
@@ -34,29 +37,29 @@ function zt(e, t, n = "start") {
|
|
|
34
37
|
return e;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
|
-
function
|
|
40
|
+
function me(e, t = "start") {
|
|
38
41
|
if (e <= 1) return 0;
|
|
39
42
|
let n = 0;
|
|
40
|
-
for (let
|
|
41
|
-
n = Math.max(n,
|
|
43
|
+
for (let i = 0; i < e; i++)
|
|
44
|
+
n = Math.max(n, Qt(i, e, t));
|
|
42
45
|
return n;
|
|
43
46
|
}
|
|
44
47
|
function Gt(e, t, n) {
|
|
45
48
|
if (n.offsets) return n.offsets[e] ?? 0;
|
|
46
|
-
const
|
|
49
|
+
const i = n.from ?? "start", s = Qt(e, t, i);
|
|
47
50
|
if (n.amount !== void 0) {
|
|
48
|
-
const r =
|
|
49
|
-
return r === 0 ? 0 : n.amount *
|
|
51
|
+
const r = me(t, i);
|
|
52
|
+
return r === 0 ? 0 : n.amount * s / r;
|
|
50
53
|
}
|
|
51
|
-
return n.each !== void 0 ? n.each *
|
|
54
|
+
return n.each !== void 0 ? n.each * s : 0;
|
|
52
55
|
}
|
|
53
|
-
function
|
|
54
|
-
return Array.from({ length: e }, (n,
|
|
56
|
+
function ge(e, t) {
|
|
57
|
+
return Array.from({ length: e }, (n, i) => Gt(i, e, t));
|
|
55
58
|
}
|
|
56
|
-
function
|
|
57
|
-
return e <= 1 ? 0 : Math.max(...
|
|
59
|
+
function wt(e, t) {
|
|
60
|
+
return e <= 1 ? 0 : Math.max(...ge(e, t));
|
|
58
61
|
}
|
|
59
|
-
const Z = 1,
|
|
62
|
+
const Z = 1, Zt = 6e4, et = Zt / Z, B = {
|
|
60
63
|
stiffness: 180,
|
|
61
64
|
damping: 12,
|
|
62
65
|
mass: 1,
|
|
@@ -64,7 +67,7 @@ const Z = 1, Qt = 6e4, et = Qt / Z, B = {
|
|
|
64
67
|
restDelta: 0.01,
|
|
65
68
|
restSpeed: 0.1
|
|
66
69
|
};
|
|
67
|
-
class
|
|
70
|
+
class ye {
|
|
68
71
|
from;
|
|
69
72
|
to;
|
|
70
73
|
stiffness;
|
|
@@ -110,24 +113,24 @@ class me {
|
|
|
110
113
|
const n = Math.floor(t / Z);
|
|
111
114
|
if (this.simulateTo(n + 1), this.settledStep !== null && n >= this.settledStep)
|
|
112
115
|
return this.to;
|
|
113
|
-
const
|
|
114
|
-
return
|
|
116
|
+
const i = this.samples[Math.min(n, this.samples.length - 1)], s = this.samples[Math.min(n + 1, this.samples.length - 1)], r = t / Z - n;
|
|
117
|
+
return i + (s - i) * r;
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
117
120
|
* How long the spring takes to settle, in milliseconds — the natural duration
|
|
118
121
|
* of a spring track. Runs the simulation to completion once.
|
|
119
122
|
*/
|
|
120
123
|
settleTime() {
|
|
121
|
-
return this.simulateTo(et + 1), this.settledStep !== null ? this.settledStep * Z :
|
|
124
|
+
return this.simulateTo(et + 1), this.settledStep !== null ? this.settledStep * Z : Zt;
|
|
122
125
|
}
|
|
123
126
|
/** Advance the cached simulation until it holds at least `steps` samples. */
|
|
124
127
|
simulateTo(t) {
|
|
125
128
|
if (this.settledStep !== null) return;
|
|
126
|
-
const n = Math.min(t, et + 1),
|
|
129
|
+
const n = Math.min(t, et + 1), i = Z / 1e3;
|
|
127
130
|
for (; this.samples.length < n; ) {
|
|
128
|
-
const
|
|
129
|
-
this.velocity += c *
|
|
130
|
-
const l =
|
|
131
|
+
const s = this.samples[this.samples.length - 1], r = s - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, c = (a + o) / this.mass;
|
|
132
|
+
this.velocity += c * i;
|
|
133
|
+
const l = s + this.velocity * i;
|
|
131
134
|
if (this.samples.push(l), this.isAtRest(l)) {
|
|
132
135
|
this.settledStep = this.samples.length - 1;
|
|
133
136
|
return;
|
|
@@ -136,108 +139,108 @@ class me {
|
|
|
136
139
|
this.samples.length > et && (this.settledStep = et);
|
|
137
140
|
}
|
|
138
141
|
}
|
|
139
|
-
const
|
|
140
|
-
function
|
|
141
|
-
const t = e.friction ??
|
|
142
|
-
return t > 0 ? t :
|
|
142
|
+
const Tt = 4, be = 2e-3, ve = 1e-4, ke = 6e4;
|
|
143
|
+
function Mt(e) {
|
|
144
|
+
const t = e.friction ?? Tt;
|
|
145
|
+
return t > 0 ? t : Tt;
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
return e.from + e.velocity /
|
|
147
|
+
function xe(e) {
|
|
148
|
+
return e.from + e.velocity / Mt(e);
|
|
146
149
|
}
|
|
147
|
-
function
|
|
150
|
+
function we(e, t) {
|
|
148
151
|
if (t === void 0) return e;
|
|
149
152
|
if (typeof t == "number")
|
|
150
153
|
return t > 0 ? Math.round(e / t) * t : e;
|
|
151
154
|
if (t.length === 0) return e;
|
|
152
155
|
let n = t[0];
|
|
153
|
-
for (const
|
|
154
|
-
Math.abs(
|
|
156
|
+
for (const i of t)
|
|
157
|
+
Math.abs(i - e) < Math.abs(n - e) && (n = i);
|
|
155
158
|
return n;
|
|
156
159
|
}
|
|
157
|
-
function
|
|
158
|
-
let t =
|
|
160
|
+
function Kt(e) {
|
|
161
|
+
let t = we(xe(e), e.end);
|
|
159
162
|
return e.min !== void 0 && (t = Math.max(e.min, t)), e.max !== void 0 && (t = Math.min(e.max, t)), t;
|
|
160
163
|
}
|
|
161
|
-
function
|
|
162
|
-
const t = Math.abs(
|
|
164
|
+
function Jt(e) {
|
|
165
|
+
const t = Math.abs(Kt(e) - e.from);
|
|
163
166
|
if (t === 0) return 0;
|
|
164
|
-
const n = e.restDelta ?? Math.max(
|
|
167
|
+
const n = e.restDelta ?? Math.max(ve, t * be);
|
|
165
168
|
if (n >= t) return 0;
|
|
166
|
-
const
|
|
167
|
-
return Math.min(
|
|
169
|
+
const i = Math.log(t / n) / Mt(e);
|
|
170
|
+
return Math.min(ke, i * 1e3);
|
|
168
171
|
}
|
|
169
|
-
function
|
|
172
|
+
function _t(e, t) {
|
|
170
173
|
if (t <= 0) return e.from;
|
|
171
|
-
const n =
|
|
172
|
-
if (t >=
|
|
173
|
-
const
|
|
174
|
-
return e.from + (n - e.from) * (1 - Math.exp(-
|
|
175
|
-
}
|
|
176
|
-
const
|
|
177
|
-
linear:
|
|
178
|
-
"ease-in":
|
|
179
|
-
"ease-out":
|
|
180
|
-
"ease-in-out":
|
|
181
|
-
"ease-in-quad":
|
|
182
|
-
"ease-out-quad":
|
|
183
|
-
"ease-in-out-quad":
|
|
184
|
-
"ease-in-cubic":
|
|
185
|
-
"ease-out-cubic":
|
|
186
|
-
"ease-in-out-cubic":
|
|
174
|
+
const n = Kt(e);
|
|
175
|
+
if (t >= Jt(e)) return n;
|
|
176
|
+
const i = Mt(e);
|
|
177
|
+
return e.from + (n - e.from) * (1 - Math.exp(-i * t / 1e3));
|
|
178
|
+
}
|
|
179
|
+
const bt = (e) => e, Me = (e) => e * e, Se = (e) => 1 - (1 - e) * (1 - e), Te = (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2, te = (e) => e * e * e, ee = (e) => 1 - Math.pow(1 - e, 3), ne = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, _e = te, Ae = ee, Ee = ne, Pe = {
|
|
180
|
+
linear: bt,
|
|
181
|
+
"ease-in": _e,
|
|
182
|
+
"ease-out": Ae,
|
|
183
|
+
"ease-in-out": Ee,
|
|
184
|
+
"ease-in-quad": Me,
|
|
185
|
+
"ease-out-quad": Se,
|
|
186
|
+
"ease-in-out-quad": Te,
|
|
187
|
+
"ease-in-cubic": te,
|
|
188
|
+
"ease-out-cubic": ee,
|
|
189
|
+
"ease-in-out-cubic": ne
|
|
187
190
|
};
|
|
188
|
-
function
|
|
189
|
-
const [t, n,
|
|
190
|
-
let
|
|
191
|
+
function Ce(e) {
|
|
192
|
+
const [t, n, i, s] = e, r = 3 * t, a = 3 * (i - t) - r, o = 1 - r - a, c = 3 * n, l = 3 * (s - n) - c, u = 1 - c - l, h = (d) => ((o * d + a) * d + r) * d, f = (d) => ((u * d + l) * d + c) * d, m = (d) => (3 * o * d + 2 * a) * d + r, p = (d) => {
|
|
193
|
+
let g = d;
|
|
191
194
|
for (let k = 0; k < 8; k++) {
|
|
192
|
-
const M = h(
|
|
195
|
+
const M = h(g) - d;
|
|
193
196
|
if (Math.abs(M) < 1e-7)
|
|
194
|
-
return
|
|
195
|
-
const y =
|
|
197
|
+
return g;
|
|
198
|
+
const y = m(g);
|
|
196
199
|
if (Math.abs(y) < 1e-7)
|
|
197
200
|
break;
|
|
198
|
-
|
|
201
|
+
g -= M / y;
|
|
199
202
|
}
|
|
200
203
|
let b = 0, v = 1;
|
|
201
|
-
for (
|
|
202
|
-
const k = h(
|
|
203
|
-
if (Math.abs(k -
|
|
204
|
-
return
|
|
205
|
-
|
|
204
|
+
for (g = d; b < v; ) {
|
|
205
|
+
const k = h(g);
|
|
206
|
+
if (Math.abs(k - d) < 1e-7)
|
|
207
|
+
return g;
|
|
208
|
+
d > k ? b = g : v = g, g = (b + v) / 2;
|
|
206
209
|
}
|
|
207
|
-
return
|
|
210
|
+
return g;
|
|
208
211
|
};
|
|
209
|
-
return (
|
|
210
|
-
if (
|
|
211
|
-
if (
|
|
212
|
-
const
|
|
213
|
-
return
|
|
212
|
+
return (d) => {
|
|
213
|
+
if (d <= 0) return 0;
|
|
214
|
+
if (d >= 1) return 1;
|
|
215
|
+
const g = p(d);
|
|
216
|
+
return f(g);
|
|
214
217
|
};
|
|
215
218
|
}
|
|
216
|
-
function
|
|
219
|
+
function lt(e, t = "out") {
|
|
217
220
|
if (t === "out") return e;
|
|
218
|
-
const n = (
|
|
219
|
-
return t === "in" ? n : (
|
|
221
|
+
const n = (i) => 1 - e(1 - i);
|
|
222
|
+
return t === "in" ? n : (i) => i < 0.5 ? n(i * 2) / 2 : e(i * 2 - 1) / 2 + 0.5;
|
|
220
223
|
}
|
|
221
|
-
function
|
|
222
|
-
const n = Math.max(1, e),
|
|
223
|
-
return (
|
|
224
|
+
function Ie(e = 1, t = 0.3) {
|
|
225
|
+
const n = Math.max(1, e), i = t / (2 * Math.PI) * Math.asin(1 / n);
|
|
226
|
+
return (s) => s <= 0 ? 0 : s >= 1 ? 1 : n * Math.pow(2, -10 * s) * Math.sin((s - i) * (2 * Math.PI) / t) + 1;
|
|
224
227
|
}
|
|
225
|
-
const
|
|
228
|
+
const Re = (e) => {
|
|
226
229
|
if (e <= 0) return 0;
|
|
227
230
|
if (e >= 1) return 1;
|
|
228
231
|
if (e < 1 / 2.75) return 7.5625 * e * e;
|
|
229
232
|
if (e < 2 / 2.75) {
|
|
230
|
-
const
|
|
231
|
-
return 7.5625 *
|
|
233
|
+
const s = e - 0.5454545454545454;
|
|
234
|
+
return 7.5625 * s * s + 0.75;
|
|
232
235
|
}
|
|
233
236
|
if (e < 2.5 / 2.75) {
|
|
234
|
-
const
|
|
235
|
-
return 7.5625 *
|
|
237
|
+
const s = e - 0.8181818181818182;
|
|
238
|
+
return 7.5625 * s * s + 0.9375;
|
|
236
239
|
}
|
|
237
|
-
const
|
|
238
|
-
return 7.5625 *
|
|
240
|
+
const i = e - 2.625 / 2.75;
|
|
241
|
+
return 7.5625 * i * i + 0.984375;
|
|
239
242
|
};
|
|
240
|
-
function
|
|
243
|
+
function $e(e = 1.70158) {
|
|
241
244
|
return (t) => {
|
|
242
245
|
if (t <= 0) return 0;
|
|
243
246
|
if (t >= 1) return 1;
|
|
@@ -245,40 +248,40 @@ function Ie(e = 1.70158) {
|
|
|
245
248
|
return n * n * ((e + 1) * n + e) + 1;
|
|
246
249
|
};
|
|
247
250
|
}
|
|
248
|
-
function
|
|
251
|
+
function De(e, t = "end") {
|
|
249
252
|
const n = Math.max(1, Math.floor(e));
|
|
250
|
-
return (
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
253
|
-
const
|
|
253
|
+
return (i) => {
|
|
254
|
+
if (i >= 1) return 1;
|
|
255
|
+
if (i <= 0) return t === "start" || t === "both" ? t === "start" ? 1 / n : 1 / (n + 1) : 0;
|
|
256
|
+
const s = Math.floor(i * n);
|
|
254
257
|
switch (t) {
|
|
255
258
|
case "start":
|
|
256
|
-
return Math.min(1, (
|
|
259
|
+
return Math.min(1, (s + 1) / n);
|
|
257
260
|
case "both":
|
|
258
|
-
return (
|
|
261
|
+
return (s + 1) / (n + 1);
|
|
259
262
|
case "none":
|
|
260
|
-
return n === 1 ? 0 : Math.min(1,
|
|
263
|
+
return n === 1 ? 0 : Math.min(1, s / (n - 1));
|
|
261
264
|
default:
|
|
262
|
-
return
|
|
265
|
+
return s / n;
|
|
263
266
|
}
|
|
264
267
|
};
|
|
265
268
|
}
|
|
266
|
-
function
|
|
269
|
+
function Le(e) {
|
|
267
270
|
switch (e.type) {
|
|
268
271
|
case "steps":
|
|
269
|
-
return
|
|
272
|
+
return De(e.count, e.position);
|
|
270
273
|
case "elastic":
|
|
271
|
-
return
|
|
274
|
+
return lt(Ie(e.amplitude, e.period), e.mode);
|
|
272
275
|
case "bounce":
|
|
273
|
-
return
|
|
276
|
+
return lt(Re, e.mode);
|
|
274
277
|
case "back":
|
|
275
|
-
return
|
|
278
|
+
return lt($e(e.overshoot), e.mode);
|
|
276
279
|
}
|
|
277
280
|
}
|
|
278
|
-
function
|
|
279
|
-
return e === void 0 ?
|
|
281
|
+
function Oe(e) {
|
|
282
|
+
return e === void 0 ? bt : ue(e) ? Ce(e.points) : de(e) ? Le(e) : Pe[e] ?? bt;
|
|
280
283
|
}
|
|
281
|
-
const
|
|
284
|
+
const At = 32, Ne = 256, H = /* @__PURE__ */ new Map(), Fe = /[MmLlHhVvCcSsQqTtAaZz]/, Xe = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, Ye = {
|
|
282
285
|
M: 2,
|
|
283
286
|
L: 2,
|
|
284
287
|
H: 1,
|
|
@@ -290,191 +293,191 @@ const _t = 32, Le = 256, H = /* @__PURE__ */ new Map(), Oe = /[MmLlHhVvCcSsQqTtA
|
|
|
290
293
|
A: 7,
|
|
291
294
|
Z: 0
|
|
292
295
|
};
|
|
293
|
-
function
|
|
296
|
+
function Ve(e) {
|
|
294
297
|
const t = [];
|
|
295
|
-
let n = 0,
|
|
296
|
-
const
|
|
298
|
+
let n = 0, i = null;
|
|
299
|
+
const s = () => {
|
|
297
300
|
for (; n < e.length && /[\s,]/.test(e[n]); ) n++;
|
|
298
301
|
};
|
|
299
|
-
for (; n < e.length && (
|
|
302
|
+
for (; n < e.length && (s(), !(n >= e.length)); ) {
|
|
300
303
|
const r = e[n];
|
|
301
|
-
if (
|
|
302
|
-
|
|
304
|
+
if (Fe.test(r)) {
|
|
305
|
+
i = { type: r, args: [] }, t.push(i), n++;
|
|
303
306
|
continue;
|
|
304
307
|
}
|
|
305
|
-
if (!
|
|
306
|
-
const a =
|
|
308
|
+
if (!i) break;
|
|
309
|
+
const a = i.type === "A" || i.type === "a", o = i.args.length % 7;
|
|
307
310
|
if (a && (o === 3 || o === 4)) {
|
|
308
311
|
if (r !== "0" && r !== "1") break;
|
|
309
|
-
|
|
312
|
+
i.args.push(r === "1" ? 1 : 0), n++;
|
|
310
313
|
continue;
|
|
311
314
|
}
|
|
312
|
-
const c =
|
|
315
|
+
const c = Xe.exec(e.slice(n));
|
|
313
316
|
if (!c) break;
|
|
314
|
-
|
|
317
|
+
i.args.push(parseFloat(c[0])), n += c[0].length;
|
|
315
318
|
}
|
|
316
319
|
return t;
|
|
317
320
|
}
|
|
318
|
-
function
|
|
321
|
+
function qe(e, t, n, i, s, r, a, o, c) {
|
|
319
322
|
if (e === o && t === c) return [];
|
|
320
|
-
let l = Math.abs(n), u = Math.abs(
|
|
323
|
+
let l = Math.abs(n), u = Math.abs(i);
|
|
321
324
|
if (l === 0 || u === 0) return [[e, t, o, c, o, c]];
|
|
322
|
-
const h =
|
|
325
|
+
const h = s * Math.PI / 180, f = Math.cos(h), m = Math.sin(h), p = (e - o) / 2, d = (t - c) / 2, g = f * p + m * d, b = -m * p + f * d, v = g * g / (l * l) + b * b / (u * u);
|
|
323
326
|
if (v > 1) {
|
|
324
327
|
const A = Math.sqrt(v);
|
|
325
328
|
l *= A, u *= A;
|
|
326
329
|
}
|
|
327
|
-
const k = r === a ? -1 : 1, M = l * l * u * u - l * l * b * b - u * u *
|
|
328
|
-
const
|
|
330
|
+
const k = r === a ? -1 : 1, M = l * l * u * u - l * l * b * b - u * u * g * g, y = l * l * b * b + u * u * g * g, S = k * Math.sqrt(Math.max(0, M / y)), x = S * l * b / u, P = -S * u * g / l, Y = f * x - m * P + (e + o) / 2, T = m * x + f * P + (t + c) / 2, R = (A, I, D, W) => {
|
|
331
|
+
const ct = A * D + I * W, tt = Math.sqrt((A * A + I * I) * (D * D + W * W)), j = Math.acos(Math.max(-1, Math.min(1, ct / tt)));
|
|
329
332
|
return A * W - I * D < 0 ? -j : j;
|
|
330
|
-
}, _ = R(1, 0, (
|
|
331
|
-
let C = R((
|
|
333
|
+
}, _ = R(1, 0, (g - x) / l, (b - P) / u);
|
|
334
|
+
let C = R((g - x) / l, (b - P) / u, (-g - x) / l, (-b - P) / u);
|
|
332
335
|
!a && C > 0 && (C -= 2 * Math.PI), a && C < 0 && (C += 2 * Math.PI);
|
|
333
336
|
const L = Math.max(1, Math.ceil(Math.abs(C) / (Math.PI / 2))), w = C / L, E = 4 / 3 * Math.tan(w / 4), N = (A) => {
|
|
334
337
|
const I = l * Math.cos(A), D = u * Math.sin(A);
|
|
335
|
-
return [
|
|
338
|
+
return [f * I - m * D + Y, m * I + f * D + T];
|
|
336
339
|
}, O = (A) => {
|
|
337
340
|
const I = -l * Math.sin(A), D = u * Math.cos(A);
|
|
338
|
-
return [
|
|
341
|
+
return [f * I - m * D, m * I + f * D];
|
|
339
342
|
}, $ = [];
|
|
340
343
|
for (let A = 0; A < L; A++) {
|
|
341
|
-
const I = _ + A * w, D = I + w, [W,
|
|
342
|
-
$.push([W + E *
|
|
344
|
+
const I = _ + A * w, D = I + w, [W, ct] = N(I), [tt, j] = A === L - 1 ? [o, c] : N(D), [oe, ce] = O(I), [le, he] = O(D);
|
|
345
|
+
$.push([W + E * oe, ct + E * ce, tt - E * le, j - E * he, tt, j]);
|
|
343
346
|
}
|
|
344
347
|
return $;
|
|
345
348
|
}
|
|
346
|
-
function X(e, t, n,
|
|
347
|
-
const r = 1 -
|
|
348
|
-
return r * r * r * e + 3 * r * r *
|
|
349
|
+
function X(e, t, n, i, s) {
|
|
350
|
+
const r = 1 - s;
|
|
351
|
+
return r * r * r * e + 3 * r * r * s * t + 3 * r * s * s * n + s * s * s * i;
|
|
349
352
|
}
|
|
350
|
-
function
|
|
351
|
-
const r = 1 -
|
|
352
|
-
return 3 * r * r * (t - e) + 6 * r *
|
|
353
|
+
function Et(e, t, n, i, s) {
|
|
354
|
+
const r = 1 - s;
|
|
355
|
+
return 3 * r * r * (t - e) + 6 * r * s * (n - t) + 3 * s * s * (i - n);
|
|
353
356
|
}
|
|
354
|
-
function z(e, t, n,
|
|
357
|
+
function z(e, t, n, i) {
|
|
355
358
|
return {
|
|
356
359
|
subpath: 0,
|
|
357
360
|
type: "L",
|
|
358
|
-
points: [n,
|
|
361
|
+
points: [n, i],
|
|
359
362
|
startX: e,
|
|
360
363
|
startY: t,
|
|
361
364
|
endX: n,
|
|
362
|
-
endY:
|
|
363
|
-
length: Math.hypot(n - e,
|
|
365
|
+
endY: i,
|
|
366
|
+
length: Math.hypot(n - e, i - t)
|
|
364
367
|
};
|
|
365
368
|
}
|
|
366
369
|
function nt(e, t, n) {
|
|
367
|
-
const [
|
|
368
|
-
let u = e, h = t,
|
|
369
|
-
for (let
|
|
370
|
-
const
|
|
371
|
-
|
|
370
|
+
const [i, s, r, a, o, c] = n, l = [0];
|
|
371
|
+
let u = e, h = t, f = 0;
|
|
372
|
+
for (let m = 1; m <= At; m++) {
|
|
373
|
+
const p = m / At, d = X(e, i, r, o, p), g = X(t, s, a, c, p);
|
|
374
|
+
f += Math.hypot(d - u, g - h), l.push(f), u = d, h = g;
|
|
372
375
|
}
|
|
373
376
|
return {
|
|
374
377
|
subpath: 0,
|
|
375
378
|
type: "C",
|
|
376
|
-
points: [
|
|
379
|
+
points: [i, s, r, a, o, c],
|
|
377
380
|
startX: e,
|
|
378
381
|
startY: t,
|
|
379
382
|
endX: o,
|
|
380
383
|
endY: c,
|
|
381
|
-
length:
|
|
384
|
+
length: f,
|
|
382
385
|
lengths: l
|
|
383
386
|
};
|
|
384
387
|
}
|
|
385
|
-
function
|
|
388
|
+
function rt(e) {
|
|
386
389
|
const t = H.get(e);
|
|
387
390
|
if (t) return t;
|
|
388
391
|
const n = [];
|
|
389
|
-
let
|
|
390
|
-
const u = /* @__PURE__ */ new Set(), h = (
|
|
391
|
-
l < 0 && (l = 0),
|
|
392
|
+
let i = 0, s = 0, r = 0, a = 0, o = null, c = null, l = -1;
|
|
393
|
+
const u = /* @__PURE__ */ new Set(), h = (d) => {
|
|
394
|
+
l < 0 && (l = 0), d.subpath = l, n.push(d);
|
|
392
395
|
};
|
|
393
|
-
for (const { type:
|
|
394
|
-
const b =
|
|
396
|
+
for (const { type: d, args: g } of Ve(e)) {
|
|
397
|
+
const b = d.toUpperCase(), v = d !== b, k = Ye[b];
|
|
395
398
|
if (b === "Z") {
|
|
396
|
-
(
|
|
399
|
+
(i !== r || s !== a) && h(z(i, s, r, a)), l >= 0 && u.add(l), i = r, s = a, o = c = null;
|
|
397
400
|
continue;
|
|
398
401
|
}
|
|
399
|
-
for (let M = 0; M + k <=
|
|
400
|
-
const y =
|
|
402
|
+
for (let M = 0; M + k <= g.length; M += k) {
|
|
403
|
+
const y = g.slice(M, M + k), S = v ? i : 0, x = v ? s : 0;
|
|
401
404
|
let P = null, Y = null;
|
|
402
405
|
switch (b) {
|
|
403
406
|
case "M":
|
|
404
|
-
M === 0 ? (
|
|
407
|
+
M === 0 ? (i = y[0] + S, s = y[1] + x, r = i, a = s, (l < 0 || n[n.length - 1]?.subpath === l) && l++) : (h(z(i, s, y[0] + S, y[1] + x)), i = y[0] + S, s = y[1] + x);
|
|
405
408
|
break;
|
|
406
409
|
case "L":
|
|
407
|
-
h(z(
|
|
410
|
+
h(z(i, s, y[0] + S, y[1] + x)), i = y[0] + S, s = y[1] + x;
|
|
408
411
|
break;
|
|
409
412
|
case "H":
|
|
410
|
-
h(z(
|
|
413
|
+
h(z(i, s, y[0] + S, s)), i = y[0] + S;
|
|
411
414
|
break;
|
|
412
415
|
case "V":
|
|
413
|
-
h(z(s, i,
|
|
416
|
+
h(z(i, s, i, y[0] + x)), s = y[0] + x;
|
|
414
417
|
break;
|
|
415
418
|
case "C": {
|
|
416
419
|
const T = [y[0] + S, y[1] + x, y[2] + S, y[3] + x, y[4] + S, y[5] + x];
|
|
417
|
-
h(nt(
|
|
420
|
+
h(nt(i, s, T)), P = [T[2], T[3]], i = T[4], s = T[5];
|
|
418
421
|
break;
|
|
419
422
|
}
|
|
420
423
|
case "S": {
|
|
421
|
-
const [T, R] = o ? [2 *
|
|
422
|
-
h(nt(
|
|
424
|
+
const [T, R] = o ? [2 * i - o[0], 2 * s - o[1]] : [i, s], _ = [T, R, y[0] + S, y[1] + x, y[2] + S, y[3] + x];
|
|
425
|
+
h(nt(i, s, _)), P = [_[2], _[3]], i = _[4], s = _[5];
|
|
423
426
|
break;
|
|
424
427
|
}
|
|
425
428
|
case "Q":
|
|
426
429
|
case "T": {
|
|
427
|
-
let T =
|
|
428
|
-
b === "Q" ? (T = y[0] + S, R = y[1] + x) : c && (T = 2 *
|
|
430
|
+
let T = i, R = s;
|
|
431
|
+
b === "Q" ? (T = y[0] + S, R = y[1] + x) : c && (T = 2 * i - c[0], R = 2 * s - c[1]);
|
|
429
432
|
const _ = b === "Q" ? y[2] + S : y[0] + S, C = b === "Q" ? y[3] + x : y[1] + x;
|
|
430
433
|
h(
|
|
431
|
-
nt(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
+
nt(i, s, [
|
|
435
|
+
i + 2 / 3 * (T - i),
|
|
436
|
+
s + 2 / 3 * (R - s),
|
|
434
437
|
_ + 2 / 3 * (T - _),
|
|
435
438
|
C + 2 / 3 * (R - C),
|
|
436
439
|
_,
|
|
437
440
|
C
|
|
438
441
|
])
|
|
439
|
-
), Y = [T, R],
|
|
442
|
+
), Y = [T, R], i = _, s = C;
|
|
440
443
|
break;
|
|
441
444
|
}
|
|
442
445
|
case "A": {
|
|
443
446
|
const T = y[5] + S, R = y[6] + x;
|
|
444
|
-
let _ =
|
|
445
|
-
for (const L of
|
|
447
|
+
let _ = i, C = s;
|
|
448
|
+
for (const L of qe(i, s, y[0], y[1], y[2], y[3], y[4], T, R))
|
|
446
449
|
h(nt(_, C, L)), _ = L[4], C = L[5];
|
|
447
|
-
|
|
450
|
+
i = T, s = R;
|
|
448
451
|
break;
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
454
|
o = P, c = Y;
|
|
452
455
|
}
|
|
453
456
|
}
|
|
454
|
-
const
|
|
455
|
-
for (let
|
|
456
|
-
const
|
|
457
|
-
let b =
|
|
458
|
-
for (; b < n.length && n[b].subpath ===
|
|
459
|
-
const k = n[
|
|
460
|
-
|
|
457
|
+
const f = n.reduce((d, g) => d + g.length, 0), m = [];
|
|
458
|
+
for (let d = 0; d < n.length; ) {
|
|
459
|
+
const g = n[d].subpath;
|
|
460
|
+
let b = d, v = 0;
|
|
461
|
+
for (; b < n.length && n[b].subpath === g; ) v += n[b++].length;
|
|
462
|
+
const k = n[d], M = n[b - 1], y = u.has(g) || Math.abs(M.endX - k.startX) < 1e-9 && Math.abs(M.endY - k.startY) < 1e-9;
|
|
463
|
+
m.push({ start: d, end: b, length: v, closed: y }), d = b;
|
|
461
464
|
}
|
|
462
|
-
const
|
|
463
|
-
return H.size >=
|
|
465
|
+
const p = { segments: n, totalLength: f, subpaths: m };
|
|
466
|
+
return H.size >= Ne && H.delete(H.keys().next().value), H.set(e, p), p;
|
|
464
467
|
}
|
|
465
|
-
function
|
|
468
|
+
function We(e, t) {
|
|
466
469
|
const n = e.lengths;
|
|
467
470
|
if (t <= 0) return 0;
|
|
468
471
|
if (t >= e.length) return 1;
|
|
469
|
-
let
|
|
470
|
-
for (;
|
|
471
|
-
const o =
|
|
472
|
-
n[o] < t ?
|
|
472
|
+
let i = 0, s = n.length - 1;
|
|
473
|
+
for (; i < s - 1; ) {
|
|
474
|
+
const o = i + s >> 1;
|
|
475
|
+
n[o] < t ? i = o : s = o;
|
|
473
476
|
}
|
|
474
|
-
const r = n[
|
|
475
|
-
return (
|
|
477
|
+
const r = n[s] - n[i], a = r > 0 ? (t - n[i]) / r : 0;
|
|
478
|
+
return (i + a) / (n.length - 1);
|
|
476
479
|
}
|
|
477
|
-
function
|
|
480
|
+
function Be(e, t) {
|
|
478
481
|
if (e.type === "L") {
|
|
479
482
|
const h = e.length > 0 ? Math.max(0, Math.min(1, t / e.length)) : 0;
|
|
480
483
|
return {
|
|
@@ -483,234 +486,266 @@ function Ve(e, t) {
|
|
|
483
486
|
angle: Math.atan2(e.endY - e.startY, e.endX - e.startX) * 180 / Math.PI
|
|
484
487
|
};
|
|
485
488
|
}
|
|
486
|
-
const [n,
|
|
487
|
-
let l =
|
|
489
|
+
const [n, i, s, r, a, o] = e.points, c = We(e, t);
|
|
490
|
+
let l = Et(e.startX, n, s, a, c), u = Et(e.startY, i, r, o, c);
|
|
488
491
|
if (Math.hypot(l, u) < 1e-9) {
|
|
489
|
-
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3),
|
|
490
|
-
l = c < 0.5 ?
|
|
492
|
+
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), f = X(e.startX, n, s, a, h), m = X(e.startY, i, r, o, h), p = X(e.startX, n, s, a, c), d = X(e.startY, i, r, o, c);
|
|
493
|
+
l = c < 0.5 ? f - p : p - f, u = c < 0.5 ? m - d : d - m;
|
|
491
494
|
}
|
|
492
495
|
return {
|
|
493
|
-
x: X(e.startX, n,
|
|
494
|
-
y: X(e.startY,
|
|
496
|
+
x: X(e.startX, n, s, a, c),
|
|
497
|
+
y: X(e.startY, i, r, o, c),
|
|
495
498
|
angle: Math.atan2(u, l) * 180 / Math.PI
|
|
496
499
|
};
|
|
497
500
|
}
|
|
498
|
-
function
|
|
499
|
-
if (
|
|
500
|
-
let
|
|
501
|
-
for (let r = n; r <
|
|
501
|
+
function ie(e, t, n = 0, i = e.length) {
|
|
502
|
+
if (i <= n) return { x: 0, y: 0, angle: 0 };
|
|
503
|
+
let s = 0;
|
|
504
|
+
for (let r = n; r < i; r++) {
|
|
502
505
|
const a = e[r];
|
|
503
|
-
if (
|
|
504
|
-
return
|
|
505
|
-
|
|
506
|
+
if (s + a.length >= t || r === i - 1)
|
|
507
|
+
return Be(a, t - s);
|
|
508
|
+
s += a.length;
|
|
506
509
|
}
|
|
507
510
|
return { x: 0, y: 0, angle: 0 };
|
|
508
511
|
}
|
|
509
|
-
function
|
|
510
|
-
const { segments: n, totalLength:
|
|
511
|
-
return
|
|
512
|
-
}
|
|
513
|
-
const
|
|
514
|
-
let
|
|
515
|
-
const
|
|
516
|
-
function
|
|
517
|
-
const { segments: n, subpaths:
|
|
512
|
+
function Ue(e, t) {
|
|
513
|
+
const { segments: n, totalLength: i } = rt(e);
|
|
514
|
+
return ie(n, Math.max(0, Math.min(1, t)) * i);
|
|
515
|
+
}
|
|
516
|
+
const je = 24, He = 320, ze = 2.5, Q = 72, Qe = 0.2, Ge = 128, it = /* @__PURE__ */ new Map();
|
|
517
|
+
let ht = 0, V;
|
|
518
|
+
const Pt = (e) => Math.round(e * 100) / 100;
|
|
519
|
+
function Ct(e, t) {
|
|
520
|
+
const { segments: n, subpaths: i, totalLength: s } = rt(e);
|
|
518
521
|
if (n.length === 0) return [];
|
|
519
522
|
if (t) {
|
|
520
|
-
const r =
|
|
521
|
-
return [{ segments: n, start: 0, end: n.length, length:
|
|
523
|
+
const r = i.every((a) => a.closed);
|
|
524
|
+
return [{ segments: n, start: 0, end: n.length, length: s, closed: r }];
|
|
522
525
|
}
|
|
523
|
-
return
|
|
526
|
+
return i.filter((r) => r.length > 0).map((r) => ({ segments: n, start: r.start, end: r.end, length: r.length, closed: r.closed }));
|
|
524
527
|
}
|
|
525
|
-
function
|
|
526
|
-
const n = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)),
|
|
527
|
-
return [
|
|
528
|
+
function vt(e, t) {
|
|
529
|
+
const n = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), i = ie(e.segments, n * e.length, e.start, e.end);
|
|
530
|
+
return [i.x, i.y];
|
|
528
531
|
}
|
|
529
|
-
function
|
|
532
|
+
function It(e) {
|
|
530
533
|
const t = [];
|
|
531
534
|
let n = 0;
|
|
532
|
-
for (let
|
|
533
|
-
n += e.segments[
|
|
535
|
+
for (let i = e.start; i < e.end; i++)
|
|
536
|
+
n += e.segments[i].length, e.length > 0 && t.push(n / e.length);
|
|
534
537
|
return t;
|
|
535
538
|
}
|
|
536
|
-
function
|
|
539
|
+
function Rt(e, t) {
|
|
537
540
|
const n = [];
|
|
538
|
-
for (let
|
|
539
|
-
n.push(
|
|
541
|
+
for (let i = 0; i < t; i++)
|
|
542
|
+
n.push(vt(e, e.closed ? i / t : i / (t - 1)));
|
|
540
543
|
return n;
|
|
541
544
|
}
|
|
542
|
-
function
|
|
545
|
+
function $t(e) {
|
|
543
546
|
let t = 0, n = 0;
|
|
544
|
-
for (const [
|
|
545
|
-
t +=
|
|
546
|
-
return t /= e.length, n /= e.length, e.map(([
|
|
547
|
+
for (const [i, s] of e)
|
|
548
|
+
t += i, n += s;
|
|
549
|
+
return t /= e.length, n /= e.length, e.map(([i, s]) => [i - t, s - n]);
|
|
547
550
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
551
|
+
function Ze(e, t, n) {
|
|
552
|
+
const i = e.closed && t.closed;
|
|
550
553
|
if (n !== void 0)
|
|
551
|
-
return { offset:
|
|
552
|
-
const
|
|
554
|
+
return { offset: i ? Math.abs(n) % Q / Q : 0, reversed: n < 0 };
|
|
555
|
+
const s = $t(Rt(e, Q)), r = $t(Rt(t, Q)), a = Q;
|
|
553
556
|
let o = { offset: 0, reversed: !1 }, c = 1 / 0;
|
|
554
557
|
for (const l of [!1, !0]) {
|
|
555
|
-
const u =
|
|
558
|
+
const u = i ? a : 1;
|
|
556
559
|
for (let h = 0; h < u; h++) {
|
|
557
|
-
let
|
|
558
|
-
for (let
|
|
559
|
-
const
|
|
560
|
-
|
|
560
|
+
let f = 0;
|
|
561
|
+
for (let m = 0; m < a && f < c; m++) {
|
|
562
|
+
const p = i ? l ? (h - m + a) % a : (m + h) % a : l ? a - 1 - m : m, d = s[m][0] - r[p][0], g = s[m][1] - r[p][1];
|
|
563
|
+
f += d * d + g * g;
|
|
561
564
|
}
|
|
562
|
-
|
|
565
|
+
f < c && (c = f, o = { offset: i ? h / a : 0, reversed: l });
|
|
563
566
|
}
|
|
564
567
|
}
|
|
565
568
|
return o;
|
|
566
569
|
}
|
|
567
|
-
function
|
|
570
|
+
function Ke(e, t, n) {
|
|
568
571
|
return n ? ((t.reversed ? t.offset - e : e + t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
569
572
|
}
|
|
570
|
-
function
|
|
573
|
+
function Je(e, t, n) {
|
|
571
574
|
return n ? ((t.reversed ? t.offset - e : e - t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
572
575
|
}
|
|
573
|
-
function
|
|
574
|
-
const
|
|
575
|
-
|
|
576
|
-
Math.min(
|
|
576
|
+
function tn(e, t, n) {
|
|
577
|
+
const i = e.closed && t.closed, s = Ze(e, t, n.shapeIndex), r = Math.max(
|
|
578
|
+
je,
|
|
579
|
+
Math.min(He, Math.ceil(Math.max(e.length, t.length) / ze))
|
|
577
580
|
), a = /* @__PURE__ */ new Set(), o = (h) => a.add(Math.round(h * 1e7) / 1e7);
|
|
578
581
|
for (let h = 0; h <= r; h++) o(h / r);
|
|
579
|
-
for (const h of
|
|
580
|
-
for (const h of
|
|
581
|
-
let c = [...a].sort((h,
|
|
582
|
-
|
|
582
|
+
for (const h of It(e)) o(h);
|
|
583
|
+
for (const h of It(t)) o(Je(h, s, i));
|
|
584
|
+
let c = [...a].sort((h, f) => h - f);
|
|
585
|
+
i && (c = c.filter((h) => h < 1));
|
|
583
586
|
const l = [], u = [];
|
|
584
587
|
for (const h of c)
|
|
585
|
-
l.push(...
|
|
586
|
-
return
|
|
588
|
+
l.push(...vt(e, h)), u.push(...vt(t, Ke(h, s, i)));
|
|
589
|
+
return en({ from: l, to: u, closed: i });
|
|
587
590
|
}
|
|
588
|
-
function
|
|
591
|
+
function en(e) {
|
|
589
592
|
const t = e.from.length / 2;
|
|
590
593
|
if (t <= 3) return e;
|
|
591
594
|
const n = new Uint8Array(t);
|
|
592
595
|
n[0] = 1, n[t - 1] = 1;
|
|
593
|
-
const
|
|
594
|
-
for (;
|
|
595
|
-
const [a, o] =
|
|
596
|
-
let c = -1, l =
|
|
596
|
+
const i = [[0, t - 1]];
|
|
597
|
+
for (; i.length > 0; ) {
|
|
598
|
+
const [a, o] = i.pop();
|
|
599
|
+
let c = -1, l = Qe;
|
|
597
600
|
for (let u = a + 1; u < o; u++) {
|
|
598
|
-
const h = Math.max(
|
|
601
|
+
const h = Math.max(Dt(e.from, a, o, u), Dt(e.to, a, o, u));
|
|
599
602
|
h > l && (l = h, c = u);
|
|
600
603
|
}
|
|
601
|
-
c !== -1 && (n[c] = 1,
|
|
604
|
+
c !== -1 && (n[c] = 1, i.push([a, c], [c, o]));
|
|
602
605
|
}
|
|
603
|
-
const
|
|
606
|
+
const s = [], r = [];
|
|
604
607
|
for (let a = 0; a < t; a++)
|
|
605
|
-
n[a] && (
|
|
606
|
-
return { from:
|
|
608
|
+
n[a] && (s.push(e.from[a * 2], e.from[a * 2 + 1]), r.push(e.to[a * 2], e.to[a * 2 + 1]));
|
|
609
|
+
return { from: s, to: r, closed: e.closed };
|
|
607
610
|
}
|
|
608
|
-
function
|
|
609
|
-
const
|
|
611
|
+
function Dt(e, t, n, i) {
|
|
612
|
+
const s = e[t * 2], r = e[t * 2 + 1], a = e[n * 2] - s, o = e[n * 2 + 1] - r, c = e[i * 2] - s, l = e[i * 2 + 1] - r, u = a * a + o * o, h = u === 0 ? 0 : Math.max(0, Math.min(1, (c * a + l * o) / u));
|
|
610
613
|
return Math.hypot(c - h * a, l - h * o);
|
|
611
614
|
}
|
|
612
|
-
function
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
const r =
|
|
615
|
+
function nn(e, t, n) {
|
|
616
|
+
const i = n.shapeIndex;
|
|
617
|
+
if (V && V.from === e && V.to === t && V.shapeIndex === i) return V.plan;
|
|
618
|
+
const r = it.get(String(i ?? "auto"))?.get(e)?.get(t);
|
|
616
619
|
if (r)
|
|
617
|
-
return
|
|
618
|
-
const a =
|
|
619
|
-
pairs: o.map((
|
|
620
|
+
return V = { from: e, to: t, shapeIndex: i, plan: r }, r;
|
|
621
|
+
const a = rt(e).subpaths.filter((m) => m.length > 0).length === rt(t).subpaths.filter((m) => m.length > 0).length, o = Ct(e, !a), c = Ct(t, !a), l = {
|
|
622
|
+
pairs: o.map((m, p) => tn(m, c[p], n))
|
|
620
623
|
};
|
|
621
|
-
|
|
622
|
-
const u = String(
|
|
623
|
-
|
|
624
|
-
const
|
|
625
|
-
return h.set(e,
|
|
624
|
+
ht >= Ge && (it.clear(), ht = 0);
|
|
625
|
+
const u = String(i ?? "auto"), h = it.get(u) ?? /* @__PURE__ */ new Map();
|
|
626
|
+
it.set(u, h);
|
|
627
|
+
const f = h.get(e) ?? /* @__PURE__ */ new Map();
|
|
628
|
+
return h.set(e, f), f.set(t, l), ht++, V = { from: e, to: t, shapeIndex: i, plan: l }, l;
|
|
626
629
|
}
|
|
627
|
-
function
|
|
630
|
+
function sn(e, t, n, i = {}) {
|
|
628
631
|
if (!e) return t;
|
|
629
632
|
if (!t) return e;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
633
|
-
const r =
|
|
634
|
-
if (r.pairs.length === 0) return
|
|
633
|
+
const s = Math.max(0, Math.min(1, n));
|
|
634
|
+
if (s === 0) return e;
|
|
635
|
+
if (s === 1) return t;
|
|
636
|
+
const r = nn(e, t, i);
|
|
637
|
+
if (r.pairs.length === 0) return s < 0.5 ? e : t;
|
|
635
638
|
let a = "";
|
|
636
639
|
for (const o of r.pairs) {
|
|
637
640
|
for (let c = 0; c < o.from.length; c += 2) {
|
|
638
|
-
const l =
|
|
641
|
+
const l = Pt(o.from[c] + (o.to[c] - o.from[c]) * s), u = Pt(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * s);
|
|
639
642
|
a += `${c === 0 ? a ? " M" : "M" : " L"}${l} ${u}`;
|
|
640
643
|
}
|
|
641
644
|
o.closed && (a += " Z");
|
|
642
645
|
}
|
|
643
646
|
return a;
|
|
644
647
|
}
|
|
645
|
-
function
|
|
648
|
+
function rn(e) {
|
|
646
649
|
return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e);
|
|
647
650
|
}
|
|
648
|
-
const
|
|
649
|
-
function
|
|
650
|
-
|
|
651
|
+
const an = 0.9995;
|
|
652
|
+
function on() {
|
|
653
|
+
return [0, 0, 0, 1];
|
|
654
|
+
}
|
|
655
|
+
function cn(e, t) {
|
|
656
|
+
return e[0] * t[0] + e[1] * t[1] + e[2] * t[2] + e[3] * t[3];
|
|
657
|
+
}
|
|
658
|
+
function ln(e) {
|
|
659
|
+
return Math.hypot(e[0], e[1], e[2], e[3]);
|
|
660
|
+
}
|
|
661
|
+
function K(e) {
|
|
662
|
+
const t = ln(e);
|
|
663
|
+
return t === 0 ? on() : [e[0] / t, e[1] / t, e[2] / t, e[3] / t];
|
|
664
|
+
}
|
|
665
|
+
function hn(e, t, n) {
|
|
666
|
+
const i = K(e);
|
|
667
|
+
let s = K(t), r = cn(i, s);
|
|
668
|
+
if (r < 0 && (s = [-s[0], -s[1], -s[2], -s[3]], r = -r), r > an)
|
|
669
|
+
return K([
|
|
670
|
+
i[0] + (s[0] - i[0]) * n,
|
|
671
|
+
i[1] + (s[1] - i[1]) * n,
|
|
672
|
+
i[2] + (s[2] - i[2]) * n,
|
|
673
|
+
i[3] + (s[3] - i[3]) * n
|
|
674
|
+
]);
|
|
675
|
+
const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - n) * a) / o, l = Math.sin(n * a) / o;
|
|
676
|
+
return K([
|
|
677
|
+
i[0] * c + s[0] * l,
|
|
678
|
+
i[1] * c + s[1] * l,
|
|
679
|
+
i[2] * c + s[2] * l,
|
|
680
|
+
i[3] * c + s[3] * l
|
|
681
|
+
]);
|
|
682
|
+
}
|
|
683
|
+
const F = (e, t, n) => e + (t - e) * n, se = 512, ut = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Map();
|
|
684
|
+
function Lt(e) {
|
|
685
|
+
const t = ut.get(e);
|
|
651
686
|
if (t) return t;
|
|
652
|
-
const n = e.replace("#", ""),
|
|
687
|
+
const n = e.replace("#", ""), i = [
|
|
653
688
|
parseInt(n.slice(0, 2), 16),
|
|
654
689
|
parseInt(n.slice(2, 4), 16),
|
|
655
690
|
parseInt(n.slice(4, 6), 16)
|
|
656
691
|
];
|
|
657
|
-
return
|
|
692
|
+
return ut.size < se && ut.set(e, i), i;
|
|
658
693
|
}
|
|
659
|
-
const
|
|
660
|
-
function
|
|
661
|
-
return `#${
|
|
694
|
+
const Ot = (e) => e.charCodeAt(0) === 35, Nt = (e) => e.startsWith("rgb"), Ft = (e) => e.startsWith("rgba"), un = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, ft = (e) => Math.round(e).toString(16).padStart(2, "0");
|
|
695
|
+
function dn(e, t, n) {
|
|
696
|
+
return `#${ft(e)}${ft(t)}${ft(n)}`;
|
|
662
697
|
}
|
|
663
|
-
function
|
|
664
|
-
const t =
|
|
698
|
+
function Xt(e) {
|
|
699
|
+
const t = dt.get(e);
|
|
665
700
|
if (t) return t;
|
|
666
|
-
const n = e.match(
|
|
701
|
+
const n = e.match(un);
|
|
667
702
|
if (!n)
|
|
668
703
|
throw new Error(`Invalid rgb color: ${e}`);
|
|
669
|
-
const
|
|
670
|
-
return
|
|
671
|
-
}
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
674
|
-
const [
|
|
675
|
-
return
|
|
676
|
-
}
|
|
677
|
-
if ((
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
const c =
|
|
704
|
+
const i = parseInt(n[1], 10), s = parseInt(n[2], 10), r = parseInt(n[3], 10), a = n[4] !== void 0 ? [i, s, r, parseFloat(n[4])] : [i, s, r];
|
|
705
|
+
return dt.size < se && dt.set(e, a), a;
|
|
706
|
+
}
|
|
707
|
+
const fn = (e, t, n) => {
|
|
708
|
+
if (Ot(e) && Ot(t)) {
|
|
709
|
+
const [i, s, r] = Lt(e), [a, o, c] = Lt(t), l = F(i, a, n), u = F(s, o, n), h = F(r, c, n);
|
|
710
|
+
return dn(l, u, h);
|
|
711
|
+
}
|
|
712
|
+
if ((Nt(e) || Ft(e)) && (Nt(t) || Ft(t))) {
|
|
713
|
+
const i = Xt(e), s = Xt(t), r = Math.round(F(i[0], s[0], n)), a = Math.round(F(i[1], s[1], n)), o = Math.round(F(i[2], s[2], n));
|
|
714
|
+
if (i.length === 4 || s.length === 4) {
|
|
715
|
+
const c = i[3] ?? 1, l = s[3] ?? 1, u = F(c, l, n);
|
|
681
716
|
return `rgba(${r}, ${a}, ${o}, ${u})`;
|
|
682
717
|
}
|
|
683
718
|
return `rgb(${r}, ${a}, ${o})`;
|
|
684
719
|
}
|
|
685
720
|
return n < 1 ? e : t;
|
|
686
|
-
},
|
|
687
|
-
const
|
|
688
|
-
for (let r = 0; r <
|
|
689
|
-
|
|
690
|
-
return
|
|
691
|
-
},
|
|
692
|
-
function
|
|
693
|
-
return typeof e == "number" ? F : Array.isArray(e) ?
|
|
694
|
-
}
|
|
695
|
-
function
|
|
696
|
-
const t = [...e.keyframes].sort((n,
|
|
721
|
+
}, pn = (e, t, n) => {
|
|
722
|
+
const i = Math.min(e.length, t.length), s = [];
|
|
723
|
+
for (let r = 0; r < i; r++)
|
|
724
|
+
s.push(F(e[r], t[r], n));
|
|
725
|
+
return s;
|
|
726
|
+
}, mn = (e, t, n) => hn(e, t, n), Yt = (e, t, n) => n < 1 ? e : t, gn = (e, t, n) => sn(e, t, n);
|
|
727
|
+
function yn(e, t) {
|
|
728
|
+
return t === "slerp" ? mn : typeof e == "number" ? F : Array.isArray(e) ? pn : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? fn : rn(e) ? gn : Yt : Yt;
|
|
729
|
+
}
|
|
730
|
+
function bn(e) {
|
|
731
|
+
const t = [...e.keyframes].sort((n, i) => n.time - i.time);
|
|
697
732
|
return {
|
|
698
733
|
...e,
|
|
699
734
|
keyframes: t
|
|
700
735
|
};
|
|
701
736
|
}
|
|
702
|
-
function
|
|
737
|
+
function q(e) {
|
|
703
738
|
return e.targets && e.targets.length > 0 ? e.targets : [e.target];
|
|
704
739
|
}
|
|
705
|
-
function U(e, t, n,
|
|
706
|
-
const
|
|
707
|
-
return !
|
|
740
|
+
function U(e, t, n, i) {
|
|
741
|
+
const s = n ?? 0;
|
|
742
|
+
return !i || t <= 1 ? s : s + Gt(e, t, i);
|
|
708
743
|
}
|
|
709
|
-
class
|
|
744
|
+
class pt {
|
|
710
745
|
track;
|
|
711
746
|
targets;
|
|
712
747
|
constructor(t) {
|
|
713
|
-
this.track = t, this.targets =
|
|
748
|
+
this.track = t, this.targets = q(t);
|
|
714
749
|
}
|
|
715
750
|
/**
|
|
716
751
|
* Get the interpolated value at a specific time.
|
|
@@ -728,12 +763,12 @@ class ft {
|
|
|
728
763
|
* each sampled at its own offset time.
|
|
729
764
|
*/
|
|
730
765
|
getTargetValues(t) {
|
|
731
|
-
const n = this.targets.length,
|
|
732
|
-
for (let
|
|
733
|
-
const r = U(
|
|
734
|
-
a !== void 0 &&
|
|
766
|
+
const n = this.targets.length, i = [];
|
|
767
|
+
for (let s = 0; s < n; s++) {
|
|
768
|
+
const r = U(s, n, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
|
|
769
|
+
a !== void 0 && i.push({ target: this.targets[s], value: a, start: r + this.track.keyframes[0].time });
|
|
735
770
|
}
|
|
736
|
-
return
|
|
771
|
+
return i;
|
|
737
772
|
}
|
|
738
773
|
/**
|
|
739
774
|
* Get the duration of this track — the last keyframe, plus any delay, the
|
|
@@ -743,8 +778,8 @@ class ft {
|
|
|
743
778
|
const { keyframes: t } = this.track;
|
|
744
779
|
if (t.length === 0)
|
|
745
780
|
return 0;
|
|
746
|
-
const n = t[t.length - 1].time,
|
|
747
|
-
return n + (this.track.delay ?? 0) +
|
|
781
|
+
const n = t[t.length - 1].time, i = this.track.stagger ? wt(this.targets.length, this.track.stagger) : 0;
|
|
782
|
+
return n + (this.track.delay ?? 0) + i + (this.track.endDelay ?? 0);
|
|
748
783
|
}
|
|
749
784
|
/**
|
|
750
785
|
* Get the track metadata.
|
|
@@ -761,122 +796,122 @@ class ft {
|
|
|
761
796
|
return n[0].value;
|
|
762
797
|
if (t >= n[n.length - 1].time)
|
|
763
798
|
return n[n.length - 1].value;
|
|
764
|
-
const { from:
|
|
765
|
-
if (!
|
|
799
|
+
const { from: i, to: s } = this.findSurroundingKeyframes(t);
|
|
800
|
+
if (!i || !s)
|
|
766
801
|
return;
|
|
767
|
-
if (
|
|
768
|
-
return
|
|
769
|
-
const r =
|
|
770
|
-
return
|
|
802
|
+
if (i.time === t)
|
|
803
|
+
return i.value;
|
|
804
|
+
const r = s.time - i.time, a = (t - i.time) / r, c = Oe(s.easing)(a);
|
|
805
|
+
return yn(i.value, this.track.interpolation)(i.value, s.value, c);
|
|
771
806
|
}
|
|
772
807
|
/**
|
|
773
808
|
* Find the keyframes surrounding a given time.
|
|
774
809
|
*/
|
|
775
810
|
findSurroundingKeyframes(t) {
|
|
776
811
|
const { keyframes: n } = this.track;
|
|
777
|
-
for (let
|
|
778
|
-
if (t >= n[
|
|
779
|
-
return { from: n[
|
|
812
|
+
for (let i = 0; i < n.length - 1; i++)
|
|
813
|
+
if (t >= n[i].time && t <= n[i + 1].time)
|
|
814
|
+
return { from: n[i], to: n[i + 1] };
|
|
780
815
|
return { from: null, to: null };
|
|
781
816
|
}
|
|
782
817
|
}
|
|
783
|
-
class
|
|
818
|
+
class vn {
|
|
784
819
|
track;
|
|
785
820
|
targets;
|
|
786
821
|
sampler;
|
|
787
822
|
constructor(t) {
|
|
788
|
-
this.track = t, this.targets =
|
|
823
|
+
this.track = t, this.targets = q(t), this.sampler = new ye(t.spring);
|
|
789
824
|
}
|
|
790
825
|
getValueAtTime(t) {
|
|
791
826
|
return this.sampler.valueAt(t - U(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
792
827
|
}
|
|
793
828
|
getTargetValues(t) {
|
|
794
|
-
const n = this.targets.length,
|
|
795
|
-
for (let
|
|
796
|
-
const r = U(
|
|
797
|
-
|
|
829
|
+
const n = this.targets.length, i = [];
|
|
830
|
+
for (let s = 0; s < n; s++) {
|
|
831
|
+
const r = U(s, n, this.track.delay, this.track.stagger);
|
|
832
|
+
i.push({ target: this.targets[s], value: this.sampler.valueAt(t - r), start: r });
|
|
798
833
|
}
|
|
799
|
-
return
|
|
834
|
+
return i;
|
|
800
835
|
}
|
|
801
836
|
/** Settle time plus delay and the widest stagger offset. */
|
|
802
837
|
getDuration() {
|
|
803
|
-
const t = this.track.stagger ?
|
|
838
|
+
const t = this.track.stagger ? wt(this.targets.length, this.track.stagger) : 0;
|
|
804
839
|
return this.sampler.settleTime() + (this.track.delay ?? 0) + t;
|
|
805
840
|
}
|
|
806
841
|
getTrack() {
|
|
807
842
|
return this.track;
|
|
808
843
|
}
|
|
809
844
|
}
|
|
810
|
-
class
|
|
845
|
+
class kn {
|
|
811
846
|
track;
|
|
812
847
|
targets;
|
|
813
848
|
duration;
|
|
814
849
|
constructor(t) {
|
|
815
|
-
this.track = t, this.targets =
|
|
850
|
+
this.track = t, this.targets = q(t), this.duration = Jt(t.inertia);
|
|
816
851
|
}
|
|
817
852
|
getValueAtTime(t) {
|
|
818
|
-
return
|
|
853
|
+
return _t(this.track.inertia, t - U(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
819
854
|
}
|
|
820
855
|
getTargetValues(t) {
|
|
821
|
-
const n = this.targets.length,
|
|
822
|
-
for (let
|
|
823
|
-
const r = U(
|
|
824
|
-
|
|
856
|
+
const n = this.targets.length, i = [];
|
|
857
|
+
for (let s = 0; s < n; s++) {
|
|
858
|
+
const r = U(s, n, this.track.delay, this.track.stagger);
|
|
859
|
+
i.push({ target: this.targets[s], value: _t(this.track.inertia, t - r), start: r });
|
|
825
860
|
}
|
|
826
|
-
return
|
|
861
|
+
return i;
|
|
827
862
|
}
|
|
828
863
|
/** Settle time plus delay and the widest stagger offset. */
|
|
829
864
|
getDuration() {
|
|
830
|
-
const t = this.track.stagger ?
|
|
865
|
+
const t = this.track.stagger ? wt(this.targets.length, this.track.stagger) : 0;
|
|
831
866
|
return this.duration + (this.track.delay ?? 0) + t;
|
|
832
867
|
}
|
|
833
868
|
getTrack() {
|
|
834
869
|
return this.track;
|
|
835
870
|
}
|
|
836
871
|
}
|
|
837
|
-
function
|
|
838
|
-
const n = { ...
|
|
872
|
+
function xn(e, t) {
|
|
873
|
+
const n = { ...Ue(e.pathData, t) };
|
|
839
874
|
if (e.matrix) {
|
|
840
|
-
const [
|
|
841
|
-
n.x =
|
|
842
|
-
const h = n.angle * Math.PI / 180,
|
|
843
|
-
n.angle = Math.atan2(
|
|
875
|
+
const [i, s, r, a, o, c] = e.matrix, { x: l, y: u } = n;
|
|
876
|
+
n.x = i * l + r * u + o, n.y = s * l + a * u + c;
|
|
877
|
+
const h = n.angle * Math.PI / 180, f = Math.cos(h), m = Math.sin(h);
|
|
878
|
+
n.angle = Math.atan2(s * f + a * m, i * f + r * m) * 180 / Math.PI;
|
|
844
879
|
}
|
|
845
880
|
return e.autoRotate && e.rotateOffset && (n.angle += e.rotateOffset), n;
|
|
846
881
|
}
|
|
847
|
-
const
|
|
882
|
+
const mt = {
|
|
848
883
|
upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
849
884
|
lowerCase: "abcdefghijklmnopqrstuvwxyz",
|
|
850
885
|
upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
851
886
|
numbers: "0123456789"
|
|
852
|
-
},
|
|
853
|
-
function
|
|
854
|
-
const t =
|
|
855
|
-
return n.length > 0 ? n : Array.from(
|
|
856
|
-
}
|
|
857
|
-
function
|
|
858
|
-
let
|
|
859
|
-
return
|
|
860
|
-
}
|
|
861
|
-
function
|
|
862
|
-
const
|
|
863
|
-
if (r <= 0) return
|
|
864
|
-
if (r >= 1) return
|
|
865
|
-
const a = Array.from(
|
|
887
|
+
}, wn = 20;
|
|
888
|
+
function Mn(e) {
|
|
889
|
+
const t = mt[e ?? "upperCase"] ?? e ?? mt.upperCase, n = Array.from(t);
|
|
890
|
+
return n.length > 0 ? n : Array.from(mt.upperCase);
|
|
891
|
+
}
|
|
892
|
+
function Sn(e, t, n) {
|
|
893
|
+
let i = (e | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(n + 1, 2246822507);
|
|
894
|
+
return i = Math.imul(i ^ i >>> 16, 2146121005), i = Math.imul(i ^ i >>> 15, 2221713035), (i ^ i >>> 16) >>> 0;
|
|
895
|
+
}
|
|
896
|
+
function Tn(e, t, n = 0) {
|
|
897
|
+
const i = e.from ?? "", s = e.to, r = Math.max(0, Math.min(1, t));
|
|
898
|
+
if (r <= 0) return i;
|
|
899
|
+
if (r >= 1) return s;
|
|
900
|
+
const a = Array.from(i), o = Array.from(s), c = e.rightToLeft ?? !1;
|
|
866
901
|
if (e.mode === "type") {
|
|
867
902
|
const v = Math.round(r * Math.max(a.length, o.length));
|
|
868
903
|
return c ? a.slice(0, Math.max(0, a.length - v)).join("") + o.slice(Math.max(0, o.length - v)).join("") : o.slice(0, v).join("") + a.slice(v).join("");
|
|
869
904
|
}
|
|
870
|
-
const l = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - l) / (1 - l)), h = Math.floor(u * o.length),
|
|
905
|
+
const l = Math.max(0, Math.min(0.999, e.revealDelay ?? 0)), u = Math.max(0, (r - l) / (1 - l)), h = Math.floor(u * o.length), f = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), m = Mn(e.chars), p = e.refreshRate ?? wn, d = p > 0 ? Math.floor(n * p / 1e3) : 0, g = e.seed ?? 1;
|
|
871
906
|
let b = "";
|
|
872
|
-
for (let v = 0; v <
|
|
873
|
-
const k = c ? v >=
|
|
907
|
+
for (let v = 0; v < f; v++) {
|
|
908
|
+
const k = c ? v >= f - h : v < h, M = c ? o[o.length - (f - v)] : o[v];
|
|
874
909
|
k && M !== void 0 || M === " " || M === `
|
|
875
|
-
` ? b += M : b +=
|
|
910
|
+
` ? b += M : b += m[Sn(g, v, d) % m.length];
|
|
876
911
|
}
|
|
877
912
|
return b;
|
|
878
913
|
}
|
|
879
|
-
class
|
|
914
|
+
class _n {
|
|
880
915
|
id;
|
|
881
916
|
name;
|
|
882
917
|
_captions;
|
|
@@ -989,31 +1024,31 @@ class bn {
|
|
|
989
1024
|
const n = this.duration;
|
|
990
1025
|
if (n <= 0)
|
|
991
1026
|
return;
|
|
992
|
-
let
|
|
1027
|
+
let s = t * this.speed;
|
|
993
1028
|
if (this._repeatDelayRemaining > 0) {
|
|
994
|
-
const o = Math.min(this._repeatDelayRemaining,
|
|
995
|
-
if (this._repeatDelayRemaining -= o,
|
|
1029
|
+
const o = Math.min(this._repeatDelayRemaining, s);
|
|
1030
|
+
if (this._repeatDelayRemaining -= o, s -= o, this._repeatDelayRemaining > 0) {
|
|
996
1031
|
this.onUpdate?.(this.getStateAtTime(this._currentTime));
|
|
997
1032
|
return;
|
|
998
1033
|
}
|
|
999
1034
|
this._wrapAfterDelay && (this._wrapAfterDelay = !1, this._currentTime = 0);
|
|
1000
1035
|
}
|
|
1001
1036
|
const r = 1e3;
|
|
1002
|
-
for (let o = 0; o < r &&
|
|
1037
|
+
for (let o = 0; o < r && s > 0 && this._playbackState === "playing"; o++)
|
|
1003
1038
|
if (this._direction === "forward") {
|
|
1004
1039
|
const c = n - this._currentTime;
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1040
|
+
if (s >= c) {
|
|
1041
|
+
if (s -= c, this._currentTime = n, !this._handleEndReached())
|
|
1007
1042
|
break;
|
|
1008
1043
|
} else
|
|
1009
|
-
this._currentTime +=
|
|
1044
|
+
this._currentTime += s, s = 0;
|
|
1010
1045
|
} else {
|
|
1011
1046
|
const c = this._currentTime;
|
|
1012
|
-
if (
|
|
1013
|
-
if (
|
|
1047
|
+
if (s >= c) {
|
|
1048
|
+
if (s -= c, this._currentTime = 0, !this._handleStartReached())
|
|
1014
1049
|
break;
|
|
1015
1050
|
} else
|
|
1016
|
-
this._currentTime -=
|
|
1051
|
+
this._currentTime -= s, s = 0;
|
|
1017
1052
|
}
|
|
1018
1053
|
const a = this.getStateAtTime(this._currentTime);
|
|
1019
1054
|
this.onUpdate?.(a);
|
|
@@ -1026,10 +1061,10 @@ class bn {
|
|
|
1026
1061
|
if (this._hasSharedWrites())
|
|
1027
1062
|
this._resolveShared(t, n);
|
|
1028
1063
|
else
|
|
1029
|
-
for (const [
|
|
1030
|
-
const r =
|
|
1031
|
-
for (const { target: a, value: o, start: c } of
|
|
1032
|
-
this._write(n,
|
|
1064
|
+
for (const [i, s] of this._trackPlayers) {
|
|
1065
|
+
const r = s.getTrack().property;
|
|
1066
|
+
for (const { target: a, value: o, start: c } of s.getTargetValues(t))
|
|
1067
|
+
this._write(n, i, a, r, o, t - c);
|
|
1033
1068
|
}
|
|
1034
1069
|
return {
|
|
1035
1070
|
values: n,
|
|
@@ -1053,37 +1088,37 @@ class bn {
|
|
|
1053
1088
|
* turn. `findConflicts()` reports overlaps by the same rule.
|
|
1054
1089
|
*/
|
|
1055
1090
|
_resolveShared(t, n) {
|
|
1056
|
-
const
|
|
1057
|
-
for (const [
|
|
1091
|
+
const i = /* @__PURE__ */ new Map();
|
|
1092
|
+
for (const [s, r] of this._trackPlayers) {
|
|
1058
1093
|
const a = r.getTrack().property;
|
|
1059
1094
|
for (const { target: o, value: c, start: l } of r.getTargetValues(t)) {
|
|
1060
|
-
const u = `${o}\0${a}`, h = l <= t,
|
|
1061
|
-
(!
|
|
1095
|
+
const u = `${o}\0${a}`, h = l <= t, f = i.get(u);
|
|
1096
|
+
(!f || (h !== f.started ? h : h ? l >= f.start : l <= f.start)) && i.set(u, { trackId: s, target: o, property: a, value: c, start: l, started: h });
|
|
1062
1097
|
}
|
|
1063
1098
|
}
|
|
1064
|
-
for (const { trackId:
|
|
1065
|
-
this._write(n,
|
|
1099
|
+
for (const { trackId: s, target: r, property: a, value: o, start: c } of i.values())
|
|
1100
|
+
this._write(n, s, r, a, o, t - c);
|
|
1066
1101
|
}
|
|
1067
1102
|
/**
|
|
1068
1103
|
* Write one track's value for a target, expanding the progress of motion paths
|
|
1069
1104
|
* (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
|
|
1070
1105
|
* since this target's animation on the track started.
|
|
1071
1106
|
*/
|
|
1072
|
-
_write(t, n,
|
|
1107
|
+
_write(t, n, i, s, r, a) {
|
|
1073
1108
|
if (r === void 0) return;
|
|
1074
|
-
let o = t.get(
|
|
1075
|
-
o || (o = /* @__PURE__ */ new Map(), t.set(
|
|
1109
|
+
let o = t.get(i);
|
|
1110
|
+
o || (o = /* @__PURE__ */ new Map(), t.set(i, o));
|
|
1076
1111
|
const c = this._textTracks.get(n);
|
|
1077
1112
|
if (c && typeof r == "number") {
|
|
1078
|
-
o.set("text",
|
|
1113
|
+
o.set("text", Tn(c.textConfig, r, Math.max(0, a)));
|
|
1079
1114
|
return;
|
|
1080
1115
|
}
|
|
1081
1116
|
const l = this._motionPathTracks.get(n);
|
|
1082
1117
|
if (l && typeof r == "number") {
|
|
1083
|
-
const u =
|
|
1118
|
+
const u = xn(l.motionPathConfig, r);
|
|
1084
1119
|
o.set("motionPathX", u.x), o.set("motionPathY", u.y), l.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
|
|
1085
1120
|
} else
|
|
1086
|
-
o.set(
|
|
1121
|
+
o.set(s, r);
|
|
1087
1122
|
}
|
|
1088
1123
|
/** Cached: does any target+property have more than one track? */
|
|
1089
1124
|
_sharedWrites = null;
|
|
@@ -1092,13 +1127,13 @@ class bn {
|
|
|
1092
1127
|
const t = /* @__PURE__ */ new Set();
|
|
1093
1128
|
this._sharedWrites = !1;
|
|
1094
1129
|
t: for (const n of this._tracks)
|
|
1095
|
-
for (const
|
|
1096
|
-
const
|
|
1097
|
-
if (t.has(
|
|
1130
|
+
for (const i of q(n)) {
|
|
1131
|
+
const s = `${i}\0${n.property}`;
|
|
1132
|
+
if (t.has(s)) {
|
|
1098
1133
|
this._sharedWrites = !0;
|
|
1099
1134
|
break t;
|
|
1100
1135
|
}
|
|
1101
|
-
t.add(
|
|
1136
|
+
t.add(s);
|
|
1102
1137
|
}
|
|
1103
1138
|
}
|
|
1104
1139
|
return this._sharedWrites;
|
|
@@ -1107,17 +1142,17 @@ class bn {
|
|
|
1107
1142
|
* Add a track to the timeline.
|
|
1108
1143
|
*/
|
|
1109
1144
|
addTrack(t) {
|
|
1110
|
-
if (this._tracks.push(t), this._sharedWrites = null,
|
|
1111
|
-
this._trackPlayers.set(t.id, new
|
|
1145
|
+
if (this._tracks.push(t), this._sharedWrites = null, gt(t)) {
|
|
1146
|
+
this._trackPlayers.set(t.id, new kn(t));
|
|
1112
1147
|
return;
|
|
1113
1148
|
}
|
|
1114
|
-
if (
|
|
1115
|
-
this._trackPlayers.set(t.id, new
|
|
1149
|
+
if (yt(t)) {
|
|
1150
|
+
this._trackPlayers.set(t.id, new vn(t)), this._springTracks.set(t.id, t);
|
|
1116
1151
|
return;
|
|
1117
1152
|
}
|
|
1118
|
-
if (
|
|
1119
|
-
this._trackPlayers.set(t.id, new
|
|
1120
|
-
else if (
|
|
1153
|
+
if (zt(t))
|
|
1154
|
+
this._trackPlayers.set(t.id, new pt(t)), this._textTracks.set(t.id, t);
|
|
1155
|
+
else if (pe(t)) {
|
|
1121
1156
|
const n = {
|
|
1122
1157
|
id: t.id,
|
|
1123
1158
|
target: t.target,
|
|
@@ -1128,9 +1163,9 @@ class bn {
|
|
|
1128
1163
|
targets: t.targets,
|
|
1129
1164
|
stagger: t.stagger
|
|
1130
1165
|
};
|
|
1131
|
-
this._trackPlayers.set(t.id, new
|
|
1166
|
+
this._trackPlayers.set(t.id, new pt(n)), this._motionPathTracks.set(t.id, t);
|
|
1132
1167
|
} else
|
|
1133
|
-
this._trackPlayers.set(t.id, new
|
|
1168
|
+
this._trackPlayers.set(t.id, new pt(t));
|
|
1134
1169
|
}
|
|
1135
1170
|
/**
|
|
1136
1171
|
* Replace a track with a new version, keeping its place in the track order
|
|
@@ -1138,13 +1173,13 @@ class bn {
|
|
|
1138
1173
|
* different id. Does nothing if no track has `trackId`.
|
|
1139
1174
|
*/
|
|
1140
1175
|
replaceTrack(t, n) {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
const
|
|
1176
|
+
const i = this._tracks.findIndex((r) => r.id === t);
|
|
1177
|
+
if (i < 0) return;
|
|
1178
|
+
const s = this._tracks.slice(i + 1);
|
|
1144
1179
|
this.removeTrack(t);
|
|
1145
|
-
for (const r of
|
|
1180
|
+
for (const r of s) this.removeTrack(r.id);
|
|
1146
1181
|
this.addTrack(n);
|
|
1147
|
-
for (const r of
|
|
1182
|
+
for (const r of s) this.addTrack(r);
|
|
1148
1183
|
}
|
|
1149
1184
|
/**
|
|
1150
1185
|
* Remove a track by its ID.
|
|
@@ -1169,9 +1204,9 @@ class bn {
|
|
|
1169
1204
|
* tweens on an element.
|
|
1170
1205
|
*/
|
|
1171
1206
|
removeTracks(t = {}) {
|
|
1172
|
-
const n = this.getTracks(t).map((
|
|
1173
|
-
for (const
|
|
1174
|
-
this.removeTrack(
|
|
1207
|
+
const n = this.getTracks(t).map((i) => i.id);
|
|
1208
|
+
for (const i of n)
|
|
1209
|
+
this.removeTrack(i);
|
|
1175
1210
|
return n;
|
|
1176
1211
|
}
|
|
1177
1212
|
/**
|
|
@@ -1180,12 +1215,12 @@ class bn {
|
|
|
1180
1215
|
getTrackSpan(t) {
|
|
1181
1216
|
const n = this._trackPlayers.get(t);
|
|
1182
1217
|
if (!n) return;
|
|
1183
|
-
const
|
|
1184
|
-
if (
|
|
1185
|
-
return { from:
|
|
1186
|
-
const r =
|
|
1218
|
+
const i = n.getTrack(), s = i.delay ?? 0;
|
|
1219
|
+
if (yt(i) || gt(i))
|
|
1220
|
+
return { from: s, to: n.getDuration() };
|
|
1221
|
+
const r = i.keyframes;
|
|
1187
1222
|
if (!(!r || r.length === 0))
|
|
1188
|
-
return { from: r[0].time +
|
|
1223
|
+
return { from: r[0].time + s, to: n.getDuration() };
|
|
1189
1224
|
}
|
|
1190
1225
|
/**
|
|
1191
1226
|
* Overlapping writes to the same target+property.
|
|
@@ -1198,32 +1233,32 @@ class bn {
|
|
|
1198
1233
|
findConflicts() {
|
|
1199
1234
|
const t = [];
|
|
1200
1235
|
for (let n = 0; n < this._tracks.length; n++) {
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1236
|
+
const i = this._tracks[n], s = this.getTrackSpan(i.id);
|
|
1237
|
+
if (s)
|
|
1203
1238
|
for (let r = 0; r < n; r++) {
|
|
1204
1239
|
const a = this._tracks[r];
|
|
1205
|
-
if (a.property !==
|
|
1206
|
-
const o =
|
|
1240
|
+
if (a.property !== i.property) continue;
|
|
1241
|
+
const o = q(a).filter((h) => q(i).includes(h));
|
|
1207
1242
|
if (o.length === 0) continue;
|
|
1208
1243
|
const c = this.getTrackSpan(a.id);
|
|
1209
|
-
if (!c || !(c.from <=
|
|
1210
|
-
const u =
|
|
1244
|
+
if (!c || !(c.from <= s.to && s.from <= c.to)) continue;
|
|
1245
|
+
const u = s.from >= c.from;
|
|
1211
1246
|
for (const h of o)
|
|
1212
1247
|
t.push({
|
|
1213
1248
|
target: h,
|
|
1214
|
-
property:
|
|
1215
|
-
losingTrackId: u ? a.id :
|
|
1216
|
-
winningTrackId: u ?
|
|
1249
|
+
property: i.property,
|
|
1250
|
+
losingTrackId: u ? a.id : i.id,
|
|
1251
|
+
winningTrackId: u ? i.id : a.id
|
|
1217
1252
|
});
|
|
1218
1253
|
}
|
|
1219
1254
|
}
|
|
1220
1255
|
return t;
|
|
1221
1256
|
}
|
|
1222
1257
|
_matches(t, n) {
|
|
1223
|
-
if (n.id !== void 0 && t.id !== n.id || n.property !== void 0 && t.property !== n.property || n.target !== void 0 && !
|
|
1258
|
+
if (n.id !== void 0 && t.id !== n.id || n.property !== void 0 && t.property !== n.property || n.target !== void 0 && !q(t).includes(n.target)) return !1;
|
|
1224
1259
|
if (n.timeRange) {
|
|
1225
|
-
const
|
|
1226
|
-
if (!
|
|
1260
|
+
const i = this.getTrackSpan(t.id);
|
|
1261
|
+
if (!i || i.to < n.timeRange.from || i.from > n.timeRange.to) return !1;
|
|
1227
1262
|
}
|
|
1228
1263
|
return !0;
|
|
1229
1264
|
}
|
|
@@ -1232,7 +1267,7 @@ class bn {
|
|
|
1232
1267
|
*/
|
|
1233
1268
|
toDefinition() {
|
|
1234
1269
|
return {
|
|
1235
|
-
formatVersion:
|
|
1270
|
+
formatVersion: fe(this._tracks),
|
|
1236
1271
|
id: this.id,
|
|
1237
1272
|
name: this.name,
|
|
1238
1273
|
config: { ...this._config },
|
|
@@ -1250,8 +1285,8 @@ class bn {
|
|
|
1250
1285
|
}
|
|
1251
1286
|
/** Replace the markers (kept in time order); an empty list removes them. */
|
|
1252
1287
|
setMarkers(t) {
|
|
1253
|
-
const n = t && t.length > 0 ? [...t].sort((
|
|
1254
|
-
n ?
|
|
1288
|
+
const n = t && t.length > 0 ? [...t].sort((s, r) => s.time - r.time).map((s) => ({ ...s })) : void 0, i = { ...this._config };
|
|
1289
|
+
n ? i.markers = n : delete i.markers, this._config = i;
|
|
1255
1290
|
}
|
|
1256
1291
|
/** Caption text per language, per marker id */
|
|
1257
1292
|
get captions() {
|
|
@@ -1260,7 +1295,7 @@ class bn {
|
|
|
1260
1295
|
/** Replace the captions; languages with no captions are dropped. */
|
|
1261
1296
|
setCaptions(t) {
|
|
1262
1297
|
const n = {};
|
|
1263
|
-
for (const [
|
|
1298
|
+
for (const [i, s] of Object.entries(t ?? {})) n[i] = { ...s };
|
|
1264
1299
|
this._captions = Object.keys(n).length > 0 ? n : void 0;
|
|
1265
1300
|
}
|
|
1266
1301
|
/** Start the between-iterations pause, if the timeline configures one. */
|
|
@@ -1290,28 +1325,28 @@ class bn {
|
|
|
1290
1325
|
return this._config.alternate && (t === -1 || this._loopIteration < t) ? (this._loopIteration++, this._armRepeatDelay(), this._direction = "forward", this._repeatDelayRemaining === 0) : (this._playbackState = "idle", this.onComplete?.(), !1);
|
|
1291
1326
|
}
|
|
1292
1327
|
}
|
|
1293
|
-
const
|
|
1294
|
-
function
|
|
1295
|
-
const
|
|
1296
|
-
r.push([
|
|
1328
|
+
const An = 100;
|
|
1329
|
+
function En(e, t, n, i) {
|
|
1330
|
+
const s = [], r = [], { duration: a, alternate: o } = i, c = (m, p, d, g) => {
|
|
1331
|
+
r.push([m, p]);
|
|
1297
1332
|
const b = [];
|
|
1298
1333
|
e.forEach((v, k) => {
|
|
1299
|
-
(
|
|
1300
|
-
}), b.sort((v, k) => (
|
|
1301
|
-
for (const v of b)
|
|
1334
|
+
(d === "forward" ? (g ? v >= m : v > m) && v <= p : (g ? v <= m : v < m) && v >= p) && b.push(k);
|
|
1335
|
+
}), b.sort((v, k) => (d === "forward" ? e[v] - e[k] : e[k] - e[v]) || v - k);
|
|
1336
|
+
for (const v of b) s.push({ kind: "event", index: v, direction: d });
|
|
1302
1337
|
};
|
|
1303
1338
|
let l = t.time, u = t.direction, h = t.fresh === !0;
|
|
1304
|
-
const
|
|
1305
|
-
for (let
|
|
1306
|
-
const
|
|
1307
|
-
c(l,
|
|
1339
|
+
const f = Math.min(An, Math.max(0, n.iteration - t.iteration));
|
|
1340
|
+
for (let m = 0; m < f; m++) {
|
|
1341
|
+
const p = u === "forward" ? a : 0;
|
|
1342
|
+
c(l, p, u, h), s.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", l = p, h = !1) : (l = u === "forward" ? 0 : a, h = !0);
|
|
1308
1343
|
}
|
|
1309
|
-
return
|
|
1344
|
+
return f > 0 && i.holding && !o ? { crossings: s, passes: r } : (c(l, n.time, u, h), { crossings: s, passes: r });
|
|
1310
1345
|
}
|
|
1311
|
-
function
|
|
1346
|
+
function Pn(e) {
|
|
1312
1347
|
return { ...e, ...Array.isArray(e.end) && { end: [...e.end] } };
|
|
1313
1348
|
}
|
|
1314
|
-
function
|
|
1349
|
+
function G(e) {
|
|
1315
1350
|
const t = e.endDelay;
|
|
1316
1351
|
return {
|
|
1317
1352
|
...e.delay !== void 0 && { delay: e.delay },
|
|
@@ -1320,19 +1355,19 @@ function Q(e) {
|
|
|
1320
1355
|
...e.stagger !== void 0 && { stagger: { ...e.stagger } }
|
|
1321
1356
|
};
|
|
1322
1357
|
}
|
|
1323
|
-
function
|
|
1324
|
-
if (
|
|
1358
|
+
function Cn(e) {
|
|
1359
|
+
if (gt(e)) {
|
|
1325
1360
|
const t = e;
|
|
1326
1361
|
return {
|
|
1327
1362
|
id: t.id,
|
|
1328
1363
|
target: t.target,
|
|
1329
1364
|
property: t.property,
|
|
1330
1365
|
kind: "inertia",
|
|
1331
|
-
inertia:
|
|
1332
|
-
...
|
|
1366
|
+
inertia: Pn(t.inertia),
|
|
1367
|
+
...G(t)
|
|
1333
1368
|
};
|
|
1334
1369
|
}
|
|
1335
|
-
if (
|
|
1370
|
+
if (yt(e)) {
|
|
1336
1371
|
const t = e;
|
|
1337
1372
|
return {
|
|
1338
1373
|
id: t.id,
|
|
@@ -1340,54 +1375,79 @@ function wn(e) {
|
|
|
1340
1375
|
property: t.property,
|
|
1341
1376
|
kind: "spring",
|
|
1342
1377
|
spring: { ...t.spring },
|
|
1343
|
-
...
|
|
1378
|
+
...G(t)
|
|
1344
1379
|
};
|
|
1345
1380
|
}
|
|
1346
|
-
if (
|
|
1381
|
+
if (zt(e)) {
|
|
1347
1382
|
const t = e;
|
|
1348
1383
|
return {
|
|
1349
1384
|
id: t.id,
|
|
1350
1385
|
target: t.target,
|
|
1351
1386
|
property: "text",
|
|
1352
1387
|
textConfig: { ...t.textConfig },
|
|
1353
|
-
keyframes: [...t.keyframes].sort((n,
|
|
1354
|
-
...
|
|
1388
|
+
keyframes: [...t.keyframes].sort((n, i) => n.time - i.time),
|
|
1389
|
+
...G(t)
|
|
1355
1390
|
};
|
|
1356
1391
|
}
|
|
1357
1392
|
if (e.property === "motionPath" && "motionPathConfig" in e) {
|
|
1358
|
-
const t = e, n = [...t.keyframes].sort((
|
|
1393
|
+
const t = e, n = [...t.keyframes].sort((i, s) => i.time - s.time);
|
|
1359
1394
|
return {
|
|
1360
1395
|
id: t.id,
|
|
1361
1396
|
target: t.target,
|
|
1362
1397
|
property: "motionPath",
|
|
1363
1398
|
motionPathConfig: { ...t.motionPathConfig },
|
|
1364
1399
|
keyframes: n,
|
|
1365
|
-
...
|
|
1400
|
+
...G(t)
|
|
1366
1401
|
};
|
|
1367
1402
|
}
|
|
1368
|
-
return
|
|
1403
|
+
return bn({
|
|
1369
1404
|
id: e.id,
|
|
1370
1405
|
target: e.target,
|
|
1371
1406
|
property: e.property,
|
|
1372
1407
|
keyframes: e.keyframes,
|
|
1373
|
-
...
|
|
1408
|
+
...e.interpolation !== void 0 && { interpolation: e.interpolation },
|
|
1409
|
+
...G(e)
|
|
1374
1410
|
});
|
|
1375
1411
|
}
|
|
1376
|
-
function
|
|
1412
|
+
function at(e) {
|
|
1377
1413
|
const t = e.formatVersion ?? 1;
|
|
1378
|
-
if (t >
|
|
1414
|
+
if (t > st)
|
|
1379
1415
|
throw new Error(
|
|
1380
|
-
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${
|
|
1416
|
+
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${st}. Update tinyfly to play it.`
|
|
1381
1417
|
);
|
|
1382
|
-
return new
|
|
1418
|
+
return new _n({
|
|
1383
1419
|
id: e.id,
|
|
1384
1420
|
name: e.name,
|
|
1385
1421
|
config: e.config,
|
|
1386
|
-
tracks: e.tracks.map(
|
|
1422
|
+
tracks: e.tracks.map(Cn),
|
|
1387
1423
|
captions: e.captions
|
|
1388
1424
|
});
|
|
1389
1425
|
}
|
|
1390
|
-
|
|
1426
|
+
function In(e) {
|
|
1427
|
+
const [t, n, i, s] = e;
|
|
1428
|
+
return [
|
|
1429
|
+
1 - 2 * (n * n + i * i),
|
|
1430
|
+
2 * (t * n + i * s),
|
|
1431
|
+
2 * (t * i - n * s),
|
|
1432
|
+
0,
|
|
1433
|
+
2 * (t * n - i * s),
|
|
1434
|
+
1 - 2 * (t * t + i * i),
|
|
1435
|
+
2 * (n * i + t * s),
|
|
1436
|
+
0,
|
|
1437
|
+
2 * (t * i + n * s),
|
|
1438
|
+
2 * (n * i - t * s),
|
|
1439
|
+
1 - 2 * (t * t + n * n),
|
|
1440
|
+
0,
|
|
1441
|
+
0,
|
|
1442
|
+
0,
|
|
1443
|
+
0,
|
|
1444
|
+
1
|
|
1445
|
+
];
|
|
1446
|
+
}
|
|
1447
|
+
function Rn(e) {
|
|
1448
|
+
return !Array.isArray(e) || e.length !== 4 ? null : `matrix3d(${In(K(e)).map((n) => Math.round(n * 1e6) / 1e6 + 0).join(", ")})`;
|
|
1449
|
+
}
|
|
1450
|
+
const $n = /* @__PURE__ */ new Set([
|
|
1391
1451
|
"blur",
|
|
1392
1452
|
"brightness",
|
|
1393
1453
|
"glow",
|
|
@@ -1396,30 +1456,30 @@ const Mn = /* @__PURE__ */ new Set([
|
|
|
1396
1456
|
"shadowY",
|
|
1397
1457
|
"shadowBlur",
|
|
1398
1458
|
"shadowColor"
|
|
1399
|
-
]),
|
|
1400
|
-
function
|
|
1459
|
+
]), Dn = "#ffffff", Ln = "rgba(0, 0, 0, 0.5)";
|
|
1460
|
+
function On(e) {
|
|
1401
1461
|
const t = [];
|
|
1402
|
-
if (e.blur !== void 0 && t.push(`blur(${Math.max(0, e.blur)}px)`), e.brightness !== void 0 && t.push(`brightness(${Math.max(0, e.brightness)})`), e.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, e.glow)}px ${e.glowColor ??
|
|
1403
|
-
const n = e.shadowX ?? 0,
|
|
1404
|
-
t.push(`drop-shadow(${n}px ${
|
|
1462
|
+
if (e.blur !== void 0 && t.push(`blur(${Math.max(0, e.blur)}px)`), e.brightness !== void 0 && t.push(`brightness(${Math.max(0, e.brightness)})`), e.glow !== void 0 && t.push(`drop-shadow(0 0 ${Math.max(0, e.glow)}px ${e.glowColor ?? Dn})`), e.shadowX !== void 0 || e.shadowY !== void 0 || e.shadowBlur !== void 0) {
|
|
1463
|
+
const n = e.shadowX ?? 0, i = e.shadowY ?? 0, s = Math.max(0, e.shadowBlur ?? 0);
|
|
1464
|
+
t.push(`drop-shadow(${n}px ${i}px ${s}px ${e.shadowColor ?? Ln})`);
|
|
1405
1465
|
}
|
|
1406
1466
|
return t.length > 0 ? t.join(" ") : null;
|
|
1407
1467
|
}
|
|
1408
|
-
function
|
|
1468
|
+
function Nn(e, t) {
|
|
1409
1469
|
const n = e.childNodes.length === 1 ? e.firstChild : null;
|
|
1410
1470
|
if (n && n.nodeType === 3) {
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1471
|
+
const i = n;
|
|
1472
|
+
i.data !== t && (i.data = t);
|
|
1413
1473
|
return;
|
|
1414
1474
|
}
|
|
1415
1475
|
e.textContent !== t && (e.textContent = t);
|
|
1416
1476
|
}
|
|
1417
|
-
function
|
|
1477
|
+
function Fn(e) {
|
|
1418
1478
|
if (!("ownerSVGElement" in e)) return;
|
|
1419
1479
|
const t = e.style;
|
|
1420
1480
|
!t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
|
|
1421
1481
|
}
|
|
1422
|
-
const
|
|
1482
|
+
const Vt = /* @__PURE__ */ new Set([
|
|
1423
1483
|
"width",
|
|
1424
1484
|
"height",
|
|
1425
1485
|
"top",
|
|
@@ -1445,7 +1505,7 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1445
1505
|
"gap",
|
|
1446
1506
|
"rowGap",
|
|
1447
1507
|
"columnGap"
|
|
1448
|
-
]),
|
|
1508
|
+
]), Xn = /* @__PURE__ */ new Set([
|
|
1449
1509
|
"x",
|
|
1450
1510
|
"y",
|
|
1451
1511
|
"z",
|
|
@@ -1459,11 +1519,31 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1459
1519
|
"scaleZ",
|
|
1460
1520
|
"skewX",
|
|
1461
1521
|
"skewY",
|
|
1522
|
+
// A rotation as an [x, y, z, w] quaternion (a track with `interpolation: 'slerp'`)
|
|
1523
|
+
"quaternion",
|
|
1462
1524
|
// Motion path properties
|
|
1463
1525
|
"motionPathX",
|
|
1464
1526
|
"motionPathY",
|
|
1465
1527
|
"motionPathRotate"
|
|
1466
|
-
]),
|
|
1528
|
+
]), Yn = [
|
|
1529
|
+
"x",
|
|
1530
|
+
"motionPathX",
|
|
1531
|
+
"y",
|
|
1532
|
+
"motionPathY",
|
|
1533
|
+
"z",
|
|
1534
|
+
"rotate",
|
|
1535
|
+
"rotateZ",
|
|
1536
|
+
"motionPathRotate",
|
|
1537
|
+
"rotateX",
|
|
1538
|
+
"rotateY",
|
|
1539
|
+
"quaternion",
|
|
1540
|
+
"scale",
|
|
1541
|
+
"scaleX",
|
|
1542
|
+
"scaleY",
|
|
1543
|
+
"scaleZ",
|
|
1544
|
+
"skewX",
|
|
1545
|
+
"skewY"
|
|
1546
|
+
], Vn = /* @__PURE__ */ new Set(["childPerspective", "perspectiveOriginX", "perspectiveOriginY"]), qn = /* @__PURE__ */ new Set(["originX", "originY"]), Wn = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), Bn = /* @__PURE__ */ new Set(["drawOn"]), Un = {
|
|
1467
1547
|
fill: "backgroundColor",
|
|
1468
1548
|
stroke: "borderColor",
|
|
1469
1549
|
strokeWidth: "borderWidth",
|
|
@@ -1478,8 +1558,8 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1478
1558
|
strokeDashoffset: "strokeDashoffset",
|
|
1479
1559
|
fillOpacity: "fillOpacity",
|
|
1480
1560
|
strokeOpacity: "strokeOpacity"
|
|
1481
|
-
},
|
|
1482
|
-
class
|
|
1561
|
+
}, jn = "http://www.w3.org/2000/svg";
|
|
1562
|
+
class kt {
|
|
1483
1563
|
targets = /* @__PURE__ */ new Map();
|
|
1484
1564
|
/**
|
|
1485
1565
|
* Register an HTML element as an animation target.
|
|
@@ -1509,59 +1589,67 @@ class vt {
|
|
|
1509
1589
|
* Apply animation state to all registered targets.
|
|
1510
1590
|
*/
|
|
1511
1591
|
applyState(t) {
|
|
1512
|
-
for (const [n,
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1592
|
+
for (const [n, i] of t.values) {
|
|
1593
|
+
const s = this.targets.get(n);
|
|
1594
|
+
s && this.applyProperties(s, i);
|
|
1515
1595
|
}
|
|
1516
1596
|
}
|
|
1517
1597
|
/**
|
|
1518
1598
|
* Apply properties to a single element.
|
|
1519
1599
|
*/
|
|
1520
1600
|
applyProperties(t, n) {
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
typeof
|
|
1531
|
-
else if (
|
|
1532
|
-
typeof
|
|
1533
|
-
else if (
|
|
1534
|
-
(
|
|
1535
|
-
else if (
|
|
1536
|
-
if (
|
|
1537
|
-
|
|
1538
|
-
else if (
|
|
1601
|
+
let i = null, s = null, r = null, a = null, o = null;
|
|
1602
|
+
const c = n.has("motionPathX"), l = n.has("motionPathY"), u = n.has("motionPathRotate");
|
|
1603
|
+
for (const [p, d] of n)
|
|
1604
|
+
if (!(p === "x" && c) && !(p === "y" && l) && !((p === "rotate" || p === "rotateZ") && u) && !Bn.has(p)) {
|
|
1605
|
+
if (Xn.has(p))
|
|
1606
|
+
(i ??= {})[p] = d;
|
|
1607
|
+
else if (Vn.has(p))
|
|
1608
|
+
typeof d == "number" && ((s ??= {})[p] = d);
|
|
1609
|
+
else if (qn.has(p))
|
|
1610
|
+
typeof d == "number" && ((r ??= {})[p] = d);
|
|
1611
|
+
else if (Wn.has(p))
|
|
1612
|
+
typeof d == "number" && ((a ??= {})[p] = d);
|
|
1613
|
+
else if ($n.has(p))
|
|
1614
|
+
(o ??= {})[p] = d;
|
|
1615
|
+
else if (p !== "perspective") {
|
|
1616
|
+
if (p !== "shine") if (p === "text" && typeof d == "string")
|
|
1617
|
+
Nn(t, d);
|
|
1618
|
+
else if (p === "d" && typeof d == "string") {
|
|
1539
1619
|
const g = t;
|
|
1540
|
-
(g.tagName?.toLowerCase() === "path" ? g : g.querySelector?.("path"))?.setAttribute?.("d",
|
|
1620
|
+
(g.tagName?.toLowerCase() === "path" ? g : g.querySelector?.("path"))?.setAttribute?.("d", d);
|
|
1541
1621
|
} else
|
|
1542
|
-
this.applyStyleProperty(t,
|
|
1622
|
+
this.applyStyleProperty(t, p, d);
|
|
1543
1623
|
}
|
|
1544
1624
|
}
|
|
1545
|
-
const
|
|
1546
|
-
typeof
|
|
1547
|
-
const
|
|
1548
|
-
if (typeof
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1625
|
+
const h = n.get("shine");
|
|
1626
|
+
typeof h == "number" && this.applyShine(t, h);
|
|
1627
|
+
const f = [], m = n.get("perspective");
|
|
1628
|
+
if (typeof m == "number" && m > 0 && f.push(`perspective(${m}px)`), i)
|
|
1629
|
+
for (const p of Yn) {
|
|
1630
|
+
const d = i[p];
|
|
1631
|
+
if (d === void 0) continue;
|
|
1632
|
+
const g = this.buildTransformPart(p, d);
|
|
1633
|
+
g && f.push(g);
|
|
1634
|
+
}
|
|
1635
|
+
if (f.length > 0 && (t.style.transform = f.join(" "), Fn(t)), s && (s.childPerspective !== void 0 && (t.style.perspective = `${s.childPerspective}px`), (s.perspectiveOriginX !== void 0 || s.perspectiveOriginY !== void 0) && (t.style.perspectiveOrigin = `${s.perspectiveOriginX ?? 50}% ${s.perspectiveOriginY ?? 50}%`)), r) {
|
|
1636
|
+
const p = r.originX ?? 50, d = r.originY ?? 50;
|
|
1637
|
+
t.style.transformOrigin = `${p}% ${d}%`;
|
|
1555
1638
|
}
|
|
1556
1639
|
if (a) {
|
|
1557
|
-
const d =
|
|
1558
|
-
|
|
1640
|
+
const p = a.clipTop ?? 0, d = a.clipRight ?? 0, g = a.clipBottom ?? 0, b = a.clipLeft ?? 0;
|
|
1641
|
+
t.style.clipPath = `inset(${p}% ${d}% ${g}% ${b}%)`;
|
|
1642
|
+
}
|
|
1643
|
+
if (o) {
|
|
1644
|
+
const p = On(o);
|
|
1645
|
+
p && (t.style.filter = p);
|
|
1559
1646
|
}
|
|
1560
1647
|
}
|
|
1561
1648
|
/**
|
|
1562
1649
|
* Build a transform function string for a property.
|
|
1563
1650
|
*/
|
|
1564
1651
|
buildTransformPart(t, n) {
|
|
1652
|
+
if (t === "quaternion") return Rn(n);
|
|
1565
1653
|
if (typeof n != "number") return null;
|
|
1566
1654
|
switch (t) {
|
|
1567
1655
|
case "x":
|
|
@@ -1606,24 +1694,24 @@ class vt {
|
|
|
1606
1694
|
*/
|
|
1607
1695
|
applyShine(t, n) {
|
|
1608
1696
|
t.dataset.shineBase || (t.dataset.shineBase = t.style.color || "currentColor");
|
|
1609
|
-
const
|
|
1610
|
-
r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${
|
|
1697
|
+
const i = t.dataset.shineBase, s = -20 + n * 140, r = t.style;
|
|
1698
|
+
r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${i}, ${i})`, r.backgroundSize = "250% 100%, 100% 100%", r.backgroundPosition = `${s}% 0, 0 0`, r.backgroundRepeat = "no-repeat", r.webkitBackgroundClip = "text", r.backgroundClip = "text";
|
|
1611
1699
|
}
|
|
1612
1700
|
/**
|
|
1613
1701
|
* Apply a single style property to an element.
|
|
1614
1702
|
*/
|
|
1615
|
-
applyStyleProperty(t, n,
|
|
1616
|
-
let
|
|
1617
|
-
if (t.namespaceURI ===
|
|
1618
|
-
const o = Array.isArray(
|
|
1703
|
+
applyStyleProperty(t, n, i) {
|
|
1704
|
+
let s;
|
|
1705
|
+
if (t.namespaceURI === jn && n in qt) {
|
|
1706
|
+
const o = Array.isArray(i) ? i.join(", ") : String(i);
|
|
1619
1707
|
t.style[qt[n]] = o;
|
|
1620
1708
|
return;
|
|
1621
|
-
} else n === "fill" && t.dataset?.elementType === "text" ?
|
|
1709
|
+
} else n === "fill" && t.dataset?.elementType === "text" ? s = "color" : s = Un[n] ?? n;
|
|
1622
1710
|
let a;
|
|
1623
|
-
typeof
|
|
1711
|
+
typeof i == "number" ? Vt.has(n) || Vt.has(s) ? a = `${i}px` : a = String(i) : Array.isArray(i) ? a = i.join(", ") : a = i, t.style[s] = a;
|
|
1624
1712
|
}
|
|
1625
1713
|
}
|
|
1626
|
-
class
|
|
1714
|
+
class Wt {
|
|
1627
1715
|
media;
|
|
1628
1716
|
offset;
|
|
1629
1717
|
driftTolerance;
|
|
@@ -1641,8 +1729,8 @@ class Vt {
|
|
|
1641
1729
|
* @param isPlaying whether the timeline is playing
|
|
1642
1730
|
*/
|
|
1643
1731
|
update(t, n) {
|
|
1644
|
-
const
|
|
1645
|
-
n ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime -
|
|
1732
|
+
const i = this.targetTime(t);
|
|
1733
|
+
n ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime - i) > this.driftTolerance && (this.media.currentTime = i)) : (this.media.paused || this.media.pause(), this.media.currentTime !== i && (this.media.currentTime = i));
|
|
1646
1734
|
}
|
|
1647
1735
|
/** Hard-align the media to a timeline time (used on explicit seeks). */
|
|
1648
1736
|
seek(t) {
|
|
@@ -1662,15 +1750,15 @@ class Vt {
|
|
|
1662
1750
|
});
|
|
1663
1751
|
}
|
|
1664
1752
|
}
|
|
1665
|
-
function
|
|
1666
|
-
const r = n -
|
|
1753
|
+
function Hn(e, t, n, i, s) {
|
|
1754
|
+
const r = n - s;
|
|
1667
1755
|
if (r < 0) {
|
|
1668
1756
|
t.paused || t.pause(), t.currentTime = 0;
|
|
1669
1757
|
return;
|
|
1670
1758
|
}
|
|
1671
|
-
e.update(r,
|
|
1759
|
+
e.update(r, i);
|
|
1672
1760
|
}
|
|
1673
|
-
class
|
|
1761
|
+
class St {
|
|
1674
1762
|
container;
|
|
1675
1763
|
timeline = null;
|
|
1676
1764
|
adapter;
|
|
@@ -1703,13 +1791,13 @@ class Mt {
|
|
|
1703
1791
|
onDocumentVisibility = () => this.updateVisibility();
|
|
1704
1792
|
constructor(t, n = {}) {
|
|
1705
1793
|
if (typeof t == "string") {
|
|
1706
|
-
const
|
|
1707
|
-
if (!
|
|
1794
|
+
const i = document.querySelector(t);
|
|
1795
|
+
if (!i)
|
|
1708
1796
|
throw new Error(`Container not found: ${t}`);
|
|
1709
|
-
this.container =
|
|
1797
|
+
this.container = i;
|
|
1710
1798
|
} else
|
|
1711
1799
|
this.container = t;
|
|
1712
|
-
this.options = n, this.adapter = new
|
|
1800
|
+
this.options = n, this.adapter = new kt();
|
|
1713
1801
|
}
|
|
1714
1802
|
/**
|
|
1715
1803
|
* Load animation from a URL or JSON object.
|
|
@@ -1720,10 +1808,10 @@ class Mt {
|
|
|
1720
1808
|
async loadSource(t) {
|
|
1721
1809
|
let n;
|
|
1722
1810
|
if (typeof t == "string") {
|
|
1723
|
-
const
|
|
1724
|
-
if (!
|
|
1725
|
-
throw new Error(`Failed to load animation: ${
|
|
1726
|
-
n = await
|
|
1811
|
+
const i = await fetch(t);
|
|
1812
|
+
if (!i.ok)
|
|
1813
|
+
throw new Error(`Failed to load animation: ${i.statusText}`);
|
|
1814
|
+
n = await i.json();
|
|
1727
1815
|
} else
|
|
1728
1816
|
n = t;
|
|
1729
1817
|
this.useDefinition(n), this.showInitialFrame(), this.watchReducedMotion(), this.watchVisibility(), this.options.autoplay && !this.reducedMotion && (this.options.playWhenVisible && !this.onScreen ? this.autoplayWhenSeen = !0 : this.play());
|
|
@@ -1735,7 +1823,7 @@ class Mt {
|
|
|
1735
1823
|
*/
|
|
1736
1824
|
useDefinition(t) {
|
|
1737
1825
|
const n = { ...t.config };
|
|
1738
|
-
this.options.speed !== void 0 && (n.speed = this.options.speed), this.options.loop !== void 0 && (n.loop = this.options.loop), this.options.alternate !== void 0 && (n.alternate = this.options.alternate), this.timeline =
|
|
1826
|
+
this.options.speed !== void 0 && (n.speed = this.options.speed), this.options.loop !== void 0 && (n.loop = this.options.loop), this.options.alternate !== void 0 && (n.alternate = this.options.alternate), this.timeline = at({ ...t, config: n }), this.markerList = this.timeline.markers, this.lastMarkerId = null, this.options.onComplete && (this.timeline.onComplete = this.options.onComplete), this.options.onUpdate && (this.timeline.onUpdate = this.options.onUpdate), this.autoRegisterTargets(), this.setupSymbolInstances(), this.scanMedia();
|
|
1739
1827
|
}
|
|
1740
1828
|
// --- scenarios: the reader chooses which timeline plays --------------------
|
|
1741
1829
|
/**
|
|
@@ -1745,14 +1833,14 @@ class Mt {
|
|
|
1745
1833
|
*/
|
|
1746
1834
|
async loadScenarios(t, n = {}) {
|
|
1747
1835
|
if (t.length === 0) throw new Error("tinyfly: loadScenarios needs at least one scenario");
|
|
1748
|
-
const
|
|
1836
|
+
const i = /* @__PURE__ */ new Set();
|
|
1749
1837
|
for (const r of t) {
|
|
1750
|
-
if (
|
|
1751
|
-
|
|
1838
|
+
if (i.has(r.id)) throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);
|
|
1839
|
+
i.add(r.id);
|
|
1752
1840
|
}
|
|
1753
|
-
const
|
|
1754
|
-
if (!
|
|
1755
|
-
this.scenarioList = [...t], this.scenarioId =
|
|
1841
|
+
const s = n.initial === void 0 ? t[0] : t.find((r) => r.id === n.initial);
|
|
1842
|
+
if (!s) throw new Error(`tinyfly: there is no scenario "${n.initial}"`);
|
|
1843
|
+
this.scenarioList = [...t], this.scenarioId = s.id, await this.loadSource(s.timeline);
|
|
1756
1844
|
}
|
|
1757
1845
|
/** The scenarios to choose from (empty for a single timeline). */
|
|
1758
1846
|
get scenarios() {
|
|
@@ -1773,25 +1861,25 @@ class Mt {
|
|
|
1773
1861
|
const n = this.scenarioList.find((o) => o.id === t);
|
|
1774
1862
|
if (!n || !this.timeline) return !1;
|
|
1775
1863
|
if (t === this.scenarioId) return !0;
|
|
1776
|
-
const
|
|
1864
|
+
const i = this.isPlaying, s = this.currentTime >= this.duration - 0.5, r = this.currentMarker?.id;
|
|
1777
1865
|
this.stopAnimationLoop(), this.stepping = !1, this.pausedByVisibility = !1, this.restoreAuthored(), this.scenarioId = t, this.useDefinition(n.timeline), this.lastMarkerId = null;
|
|
1778
1866
|
let a = 0;
|
|
1779
|
-
return this.reducedMotion ||
|
|
1867
|
+
return this.reducedMotion || s ? a = this.duration : r !== void 0 && (a = this.markers.find((o) => o.id === r)?.time ?? 0), this.seek(a), i && !this.reducedMotion ? (this.stepping = this.options.stepMode === !0, this.startPlaying()) : this.notify(), !0;
|
|
1780
1868
|
}
|
|
1781
1869
|
/** Remember how an element was authored, the first time it becomes a target. */
|
|
1782
1870
|
rememberAuthored(t) {
|
|
1783
1871
|
if (this.authored.has(t)) return;
|
|
1784
1872
|
const n = { style: t.getAttribute("style") };
|
|
1785
1873
|
t.children.length === 0 && (n.text = t.textContent ?? "");
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1874
|
+
const i = t.tagName.toLowerCase() === "path" ? t : t.querySelector("path");
|
|
1875
|
+
i && (n.path = { element: i, d: i.getAttribute("d") }), this.authored.set(t, n);
|
|
1788
1876
|
}
|
|
1789
1877
|
/** Put every target back the way it was authored. */
|
|
1790
1878
|
restoreAuthored() {
|
|
1791
1879
|
for (const [t, n] of this.authored) {
|
|
1792
1880
|
n.style === null ? t.removeAttribute("style") : t.setAttribute("style", n.style), n.text !== void 0 && t.textContent !== n.text && (t.textContent = n.text), n.path && (n.path.d === null ? n.path.element.removeAttribute("d") : n.path.element.setAttribute("d", n.path.d));
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1881
|
+
const i = t.dataset;
|
|
1882
|
+
i && delete i.shineBase;
|
|
1795
1883
|
}
|
|
1796
1884
|
}
|
|
1797
1885
|
// --- teaching: frames, markers, reduced motion, visibility -----------------
|
|
@@ -1817,8 +1905,8 @@ class Mt {
|
|
|
1817
1905
|
get currentMarker() {
|
|
1818
1906
|
const t = this.currentTime;
|
|
1819
1907
|
let n;
|
|
1820
|
-
for (const
|
|
1821
|
-
if (
|
|
1908
|
+
for (const i of this.markers)
|
|
1909
|
+
if (i.time <= t + 0.5) n = i;
|
|
1822
1910
|
else break;
|
|
1823
1911
|
return n;
|
|
1824
1912
|
}
|
|
@@ -1828,15 +1916,15 @@ class Mt {
|
|
|
1828
1916
|
* marker's own label.
|
|
1829
1917
|
*/
|
|
1830
1918
|
caption(t, n) {
|
|
1831
|
-
const
|
|
1832
|
-
if (!
|
|
1833
|
-
const
|
|
1834
|
-
return r(this.options.captions) ?? r(this.timeline?.captions) ??
|
|
1919
|
+
const i = t ? this.markers.find((a) => a.id === t) : this.currentMarker;
|
|
1920
|
+
if (!i) return;
|
|
1921
|
+
const s = n ?? this.language(), r = (a) => a?.[s]?.[i.id] ?? a?.[s.split("-")[0]]?.[i.id];
|
|
1922
|
+
return r(this.options.captions) ?? r(this.timeline?.captions) ?? i.label;
|
|
1835
1923
|
}
|
|
1836
1924
|
/** Move to the next marker: animated, or a jump under reduced motion. At the last marker, to the end. */
|
|
1837
1925
|
next() {
|
|
1838
1926
|
if (!this.timeline) return;
|
|
1839
|
-
const t = this.currentTime, n = this.markers.find((
|
|
1927
|
+
const t = this.currentTime, n = this.markers.find((i) => i.time > t + 0.5);
|
|
1840
1928
|
if (this.reducedMotion) {
|
|
1841
1929
|
this.seek(n ? n.time : this.duration);
|
|
1842
1930
|
return;
|
|
@@ -1846,12 +1934,12 @@ class Mt {
|
|
|
1846
1934
|
/** Jump back to the previous marker (or the start). */
|
|
1847
1935
|
prev() {
|
|
1848
1936
|
if (!this.timeline) return;
|
|
1849
|
-
const t = this.currentTime, n = [...this.markers].reverse().find((
|
|
1937
|
+
const t = this.currentTime, n = [...this.markers].reverse().find((i) => i.time < t - 0.5);
|
|
1850
1938
|
this.pause(), this.seek(n ? n.time : 0);
|
|
1851
1939
|
}
|
|
1852
1940
|
/** Jump to a marker by id, paused there. */
|
|
1853
1941
|
goToMarker(t) {
|
|
1854
|
-
const n = this.markers.find((
|
|
1942
|
+
const n = this.markers.find((i) => i.id === t);
|
|
1855
1943
|
n && (this.pause(), this.seek(n.time));
|
|
1856
1944
|
}
|
|
1857
1945
|
language() {
|
|
@@ -1875,7 +1963,7 @@ class Mt {
|
|
|
1875
1963
|
if (!(!this.options.playWhenVisible || typeof window > "u")) {
|
|
1876
1964
|
if (typeof IntersectionObserver == "function") {
|
|
1877
1965
|
this.visibilityObserver?.disconnect(), this.visibilityObserver = new IntersectionObserver((n) => {
|
|
1878
|
-
for (const
|
|
1966
|
+
for (const i of n) this.onScreen = i.isIntersecting;
|
|
1879
1967
|
this.updateVisibility();
|
|
1880
1968
|
}), this.visibilityObserver.observe(this.container);
|
|
1881
1969
|
const t = this.container.getBoundingClientRect?.();
|
|
@@ -1901,14 +1989,14 @@ class Mt {
|
|
|
1901
1989
|
*/
|
|
1902
1990
|
scanMedia() {
|
|
1903
1991
|
this.mediaTargets = [], this.container.querySelectorAll("[data-tinyfly-media]").forEach((n) => {
|
|
1904
|
-
const
|
|
1905
|
-
r !== null && (
|
|
1992
|
+
const i = n, s = Number(i.getAttribute("data-tinyfly-start") ?? "0") || 0, r = i.getAttribute("data-volume");
|
|
1993
|
+
r !== null && (i.volume = Math.max(0, Math.min(1, Number(r) || 0))), this.mediaTargets.push({ el: i, startTime: s, sync: new Wt(i) });
|
|
1906
1994
|
});
|
|
1907
1995
|
}
|
|
1908
1996
|
/** Sync all discovered media targets to a timeline time. */
|
|
1909
1997
|
syncAllMedia(t, n) {
|
|
1910
|
-
for (const
|
|
1911
|
-
|
|
1998
|
+
for (const i of this.mediaTargets)
|
|
1999
|
+
Hn(i.sync, i.el, t, n, i.startTime);
|
|
1912
2000
|
}
|
|
1913
2001
|
/**
|
|
1914
2002
|
* Load animation from inline JSON string.
|
|
@@ -1922,8 +2010,8 @@ class Mt {
|
|
|
1922
2010
|
*/
|
|
1923
2011
|
registerTarget(t, n) {
|
|
1924
2012
|
if (typeof n == "string") {
|
|
1925
|
-
const
|
|
1926
|
-
|
|
2013
|
+
const i = this.container.querySelector(n);
|
|
2014
|
+
i && (this.rememberAuthored(i), this.targets[t] = i, this.adapter.registerTarget(t, i));
|
|
1927
2015
|
} else
|
|
1928
2016
|
this.rememberAuthored(n), this.targets[t] = n, this.adapter.registerTarget(t, n);
|
|
1929
2017
|
}
|
|
@@ -1932,14 +2020,14 @@ class Mt {
|
|
|
1932
2020
|
*/
|
|
1933
2021
|
autoRegisterTargets() {
|
|
1934
2022
|
this.container.querySelectorAll("[data-tinyfly]").forEach((n) => {
|
|
1935
|
-
const
|
|
1936
|
-
if (
|
|
1937
|
-
const
|
|
1938
|
-
|
|
1939
|
-
}), this.timeline && new Set(this.timeline.tracks.map((
|
|
1940
|
-
if (!this.targets[
|
|
1941
|
-
const
|
|
1942
|
-
|
|
2023
|
+
const i = n.closest("[data-tinyfly-symbol]");
|
|
2024
|
+
if (i && i !== n) return;
|
|
2025
|
+
const s = n.getAttribute("data-tinyfly");
|
|
2026
|
+
s && this.registerTarget(s, n);
|
|
2027
|
+
}), this.timeline && new Set(this.timeline.tracks.map((i) => i.target)).forEach((i) => {
|
|
2028
|
+
if (!this.targets[i]) {
|
|
2029
|
+
const s = this.container.querySelector(`[data-tinyfly="${i}"]`) || this.container.querySelector(`.${i}`) || this.container.querySelector(`#${i}`);
|
|
2030
|
+
s && this.registerTarget(i, s);
|
|
1943
2031
|
}
|
|
1944
2032
|
});
|
|
1945
2033
|
}
|
|
@@ -1952,17 +2040,17 @@ class Mt {
|
|
|
1952
2040
|
this.symbolInstances = [];
|
|
1953
2041
|
const t = this.options.symbols;
|
|
1954
2042
|
if (!t || t.length === 0) return;
|
|
1955
|
-
const n = new Map(t.map((
|
|
1956
|
-
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((
|
|
1957
|
-
const
|
|
1958
|
-
if (!
|
|
1959
|
-
const r = n.get(
|
|
2043
|
+
const n = new Map(t.map((i) => [i.id, i]));
|
|
2044
|
+
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((i) => {
|
|
2045
|
+
const s = i.getAttribute("data-tinyfly-symbol");
|
|
2046
|
+
if (!s) return;
|
|
2047
|
+
const r = n.get(s);
|
|
1960
2048
|
if (!r || !r.timeline.tracks?.length) return;
|
|
1961
|
-
const a = new
|
|
1962
|
-
|
|
2049
|
+
const a = new kt();
|
|
2050
|
+
i.querySelectorAll("[data-tinyfly]").forEach((o) => {
|
|
1963
2051
|
const c = o.getAttribute("data-tinyfly");
|
|
1964
2052
|
c && a.registerTarget(c, o);
|
|
1965
|
-
}), this.symbolInstances.push({ adapter: a, timeline:
|
|
2053
|
+
}), this.symbolInstances.push({ adapter: a, timeline: at(r.timeline) });
|
|
1966
2054
|
});
|
|
1967
2055
|
}
|
|
1968
2056
|
/**
|
|
@@ -1972,7 +2060,7 @@ class Mt {
|
|
|
1972
2060
|
* plays. Pass `{ offset }` to start the media at a timeline offset.
|
|
1973
2061
|
*/
|
|
1974
2062
|
attachMedia(t, n) {
|
|
1975
|
-
this.mediaSync = new
|
|
2063
|
+
this.mediaSync = new Wt(t, n), this.timeline && (this.mediaSync.setRate(this.timeline.speed), this.mediaSync.update(this.timeline.currentTime, this.isPlaying));
|
|
1976
2064
|
}
|
|
1977
2065
|
/** Detach and pause the currently synced media, if any. */
|
|
1978
2066
|
detachMedia() {
|
|
@@ -2053,10 +2141,10 @@ class Mt {
|
|
|
2053
2141
|
this.lastTime = performance.now();
|
|
2054
2142
|
const t = (n) => {
|
|
2055
2143
|
if (this.isDestroyed || !this.timeline) return;
|
|
2056
|
-
const
|
|
2144
|
+
const i = n - (this.lastTime ?? n);
|
|
2057
2145
|
this.lastTime = n;
|
|
2058
|
-
const
|
|
2059
|
-
this.timeline.tick(
|
|
2146
|
+
const s = this.playhead;
|
|
2147
|
+
this.timeline.tick(i), this.stopAtMarker(s), this.applyState();
|
|
2060
2148
|
const r = this.timeline.playbackState === "playing";
|
|
2061
2149
|
this.mediaSync?.update(this.timeline.currentTime, r), this.syncAllMedia(this.timeline.currentTime, r), this.timeline.playbackState === "playing" ? this.animationFrameId = requestAnimationFrame(t) : (this.animationFrameId = void 0, this.notify());
|
|
2062
2150
|
};
|
|
@@ -2067,19 +2155,19 @@ class Mt {
|
|
|
2067
2155
|
* stepping, or any marker with `pause` — put the playhead exactly there and pause.
|
|
2068
2156
|
*/
|
|
2069
2157
|
stopAtMarker(t) {
|
|
2070
|
-
const n = this.timeline,
|
|
2071
|
-
this.playhead =
|
|
2072
|
-
const
|
|
2073
|
-
if (
|
|
2074
|
-
const { crossings: r } =
|
|
2075
|
-
|
|
2158
|
+
const n = this.timeline, i = { time: n.currentTime, iteration: n.loopIteration, direction: n.direction };
|
|
2159
|
+
this.playhead = i;
|
|
2160
|
+
const s = this.markers;
|
|
2161
|
+
if (s.length === 0) return;
|
|
2162
|
+
const { crossings: r } = En(
|
|
2163
|
+
s.map((a) => a.time),
|
|
2076
2164
|
t,
|
|
2077
|
-
|
|
2165
|
+
i,
|
|
2078
2166
|
{ duration: n.duration, alternate: n.config.alternate === !0, holding: n.repeatDelayRemaining > 0 }
|
|
2079
2167
|
);
|
|
2080
2168
|
for (const a of r) {
|
|
2081
2169
|
if (a.kind !== "event") continue;
|
|
2082
|
-
const o =
|
|
2170
|
+
const o = s[a.index];
|
|
2083
2171
|
if (this.stepping || o.pause) {
|
|
2084
2172
|
this.stepping = !1, n.pause(), n.seek(o.time), this.playhead = { time: o.time, iteration: n.loopIteration, direction: n.direction };
|
|
2085
2173
|
return;
|
|
@@ -2094,19 +2182,19 @@ class Mt {
|
|
|
2094
2182
|
const t = this.timeline.currentTime;
|
|
2095
2183
|
this.adapter.applyState(this.timeline.getStateAtTime(t)), this.announceMarker(), this.notify();
|
|
2096
2184
|
for (const n of this.symbolInstances) {
|
|
2097
|
-
const
|
|
2098
|
-
n.adapter.applyState(n.timeline.getStateAtTime(
|
|
2185
|
+
const i = n.timeline.duration;
|
|
2186
|
+
n.adapter.applyState(n.timeline.getStateAtTime(i > 0 ? t % i : t));
|
|
2099
2187
|
}
|
|
2100
2188
|
}
|
|
2101
2189
|
}
|
|
2102
|
-
async function
|
|
2103
|
-
const
|
|
2104
|
-
return await
|
|
2190
|
+
async function vi(e, t, n = {}) {
|
|
2191
|
+
const i = new St(e, { ...n, autoplay: !0 });
|
|
2192
|
+
return await i.load(t), i;
|
|
2105
2193
|
}
|
|
2106
|
-
function
|
|
2107
|
-
return new
|
|
2194
|
+
function ki(e, t = {}) {
|
|
2195
|
+
return new St(e, t);
|
|
2108
2196
|
}
|
|
2109
|
-
const
|
|
2197
|
+
const zn = {
|
|
2110
2198
|
play: "Play",
|
|
2111
2199
|
pause: "Pause",
|
|
2112
2200
|
prev: "Previous step",
|
|
@@ -2121,7 +2209,7 @@ const On = {
|
|
|
2121
2209
|
scenario: "Scenario",
|
|
2122
2210
|
fullscreen: "Full screen",
|
|
2123
2211
|
exitFullscreen: "Exit full screen"
|
|
2124
|
-
},
|
|
2212
|
+
}, Bt = "tinyfly-controls-style", Qn = `
|
|
2125
2213
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
2126
2214
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
2127
2215
|
.tf-ctl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; border-radius: var(--tf-ctl-radius); background: var(--tf-ctl-bg); }
|
|
@@ -2170,60 +2258,60 @@ const On = {
|
|
|
2170
2258
|
.tf-fullscreen > :not(svg):not(canvas) { grid-column: 2; }
|
|
2171
2259
|
}
|
|
2172
2260
|
`;
|
|
2173
|
-
let
|
|
2174
|
-
function
|
|
2175
|
-
if (e.getElementById(
|
|
2261
|
+
let Gn = 0;
|
|
2262
|
+
function Zn(e) {
|
|
2263
|
+
if (e.getElementById(Bt)) return;
|
|
2176
2264
|
const t = e.createElement("style");
|
|
2177
|
-
t.id =
|
|
2265
|
+
t.id = Bt, t.textContent = Qn, e.head.appendChild(t);
|
|
2178
2266
|
}
|
|
2179
|
-
function
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
const
|
|
2267
|
+
function Kn(e, t, n = {}) {
|
|
2268
|
+
const i = t.ownerDocument;
|
|
2269
|
+
Zn(i);
|
|
2270
|
+
const s = { ...zn, ...n.labels }, r = n.speeds ?? [0.5, 1, 2], a = () => e.markers.length > 0, o = () => e.markers.some((w) => w.label !== void 0 || e.caption(w.id) !== void 0), c = i.createElement("div");
|
|
2183
2271
|
c.className = "tf-ctl";
|
|
2184
|
-
const l =
|
|
2272
|
+
const l = i.createElement("div");
|
|
2185
2273
|
l.className = "tf-ctl-bar", l.setAttribute("role", "group");
|
|
2186
2274
|
const u = (w, E, N, O = "") => {
|
|
2187
|
-
const $ =
|
|
2275
|
+
const $ = i.createElement("button");
|
|
2188
2276
|
return $.type = "button", $.className = `tf-ctl-btn ${O}`.trim(), $.setAttribute("aria-label", w), $.title = w, $.textContent = E, $.addEventListener("click", N), $;
|
|
2189
|
-
}, h = u(
|
|
2277
|
+
}, h = u(s.restart, "⟲", () => {
|
|
2190
2278
|
e.pause(), e.seek(0);
|
|
2191
|
-
}),
|
|
2279
|
+
}), f = u(s.prev, "|◀", () => e.prev()), m = u(s.play, "▶", () => e.isPlaying ? e.pause() : d(), "tf-ctl-primary"), p = u(s.next, "▶|", () => e.next()), d = () => {
|
|
2192
2280
|
e.currentTime >= e.duration - 0.5 && e.seek(0), e.play();
|
|
2193
|
-
},
|
|
2194
|
-
|
|
2195
|
-
e.pause(), e.seek(Number(
|
|
2281
|
+
}, g = i.createElement("input");
|
|
2282
|
+
g.type = "range", g.className = "tf-ctl-scrub", g.min = "0", g.max = "1000", g.step = "1", g.setAttribute("aria-label", s.scrub), g.addEventListener("input", () => {
|
|
2283
|
+
e.pause(), e.seek(Number(g.value) / 1e3 * e.duration);
|
|
2196
2284
|
});
|
|
2197
|
-
const b =
|
|
2285
|
+
const b = i.createElement("span");
|
|
2198
2286
|
b.className = "tf-ctl-step";
|
|
2199
|
-
const v =
|
|
2200
|
-
v.className = "tf-ctl-speed", v.setAttribute("aria-label",
|
|
2287
|
+
const v = i.createElement("select");
|
|
2288
|
+
v.className = "tf-ctl-speed", v.setAttribute("aria-label", s.speed);
|
|
2201
2289
|
for (const w of r) {
|
|
2202
|
-
const E =
|
|
2290
|
+
const E = i.createElement("option");
|
|
2203
2291
|
E.value = String(w), E.textContent = `${w}×`, w === 1 && (E.selected = !0), v.appendChild(E);
|
|
2204
2292
|
}
|
|
2205
|
-
v.addEventListener("change", () => e.setSpeed(Number(v.value))), l.append(h,
|
|
2206
|
-
const k = n.fullscreen ?
|
|
2293
|
+
v.addEventListener("change", () => e.setSpeed(Number(v.value))), l.append(h, f, m, p, g, b), r.length > 0 && l.append(v), c.append(l);
|
|
2294
|
+
const k = n.fullscreen ? ni(t, i, s) : void 0;
|
|
2207
2295
|
k && l.append(k.button);
|
|
2208
|
-
const M =
|
|
2296
|
+
const M = i.createElement("p");
|
|
2209
2297
|
M.className = "tf-ctl-caption", M.setAttribute("aria-live", "polite"), n.captions !== !1 && c.append(M);
|
|
2210
|
-
const y =
|
|
2298
|
+
const y = i.createElement("div");
|
|
2211
2299
|
y.className = "tf-ctl-question", y.hidden = !0;
|
|
2212
|
-
const S =
|
|
2300
|
+
const S = i.createElement("span"), x = u(s.reveal, s.reveal, () => e.play(), "tf-ctl-primary");
|
|
2213
2301
|
y.append(S, x), c.append(y);
|
|
2214
|
-
const P =
|
|
2302
|
+
const P = Jn(e, i, s.scenario, n.scenarioControl ?? "buttons");
|
|
2215
2303
|
P && c.append(P.element);
|
|
2216
2304
|
const Y = n.mount;
|
|
2217
2305
|
Y ? Y.appendChild(c) : t.insertAdjacentElement("afterend", c);
|
|
2218
2306
|
const T = () => {
|
|
2219
2307
|
const w = e.isPlaying;
|
|
2220
|
-
|
|
2308
|
+
m.textContent = w ? "❚❚" : "▶", m.setAttribute("aria-label", w ? s.pause : s.play), m.title = w ? s.pause : s.play;
|
|
2221
2309
|
const E = e.duration;
|
|
2222
|
-
|
|
2310
|
+
i.activeElement !== g && (g.value = String(E > 0 ? Math.round(e.currentTime / E * 1e3) : 0));
|
|
2223
2311
|
const N = e.markers;
|
|
2224
|
-
if (
|
|
2312
|
+
if (f.hidden = p.hidden = b.hidden = N.length === 0, N.length > 0) {
|
|
2225
2313
|
const O = e.currentMarker, $ = O ? N.indexOf(O) + 1 : 0;
|
|
2226
|
-
b.textContent =
|
|
2314
|
+
b.textContent = s.stepFormat.replace("{index}", String($)).replace("{total}", String(N.length)), b.setAttribute("aria-label", `${s.step} ${$} ${s.of} ${N.length}`), f.disabled = e.currentTime <= 0.5, p.disabled = e.currentTime >= E - 0.5;
|
|
2227
2315
|
const A = e.caption() ?? "";
|
|
2228
2316
|
M.textContent !== A && (M.textContent = A), M.hidden = !o();
|
|
2229
2317
|
const I = !w && O?.question !== void 0 && Math.abs(e.currentTime - O.time) < 1;
|
|
@@ -2241,7 +2329,7 @@ function Yn(e, t, n = {}) {
|
|
|
2241
2329
|
if (!(E.tagName === "INPUT" || E.tagName === "SELECT") && !(w.key === " " && E.tagName === "BUTTON"))
|
|
2242
2330
|
switch (w.key) {
|
|
2243
2331
|
case " ":
|
|
2244
|
-
w.preventDefault(), e.isPlaying ? e.pause() :
|
|
2332
|
+
w.preventDefault(), e.isPlaying ? e.pause() : d();
|
|
2245
2333
|
break;
|
|
2246
2334
|
case "ArrowRight":
|
|
2247
2335
|
if (!a()) return;
|
|
@@ -2275,40 +2363,40 @@ function Yn(e, t, n = {}) {
|
|
|
2275
2363
|
}
|
|
2276
2364
|
};
|
|
2277
2365
|
}
|
|
2278
|
-
function
|
|
2279
|
-
const
|
|
2280
|
-
if (
|
|
2281
|
-
if (
|
|
2366
|
+
function Jn(e, t, n, i) {
|
|
2367
|
+
const s = e.scenarios;
|
|
2368
|
+
if (s.length < 2) return;
|
|
2369
|
+
if (i === "slider") {
|
|
2282
2370
|
const u = t.createElement("div");
|
|
2283
2371
|
u.className = "tf-ctl-choice-slider";
|
|
2284
2372
|
const h = t.createElement("span");
|
|
2285
2373
|
h.textContent = n, h.setAttribute("aria-hidden", "true");
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2288
|
-
const
|
|
2289
|
-
return
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2292
|
-
}), u.append(h,
|
|
2293
|
-
const
|
|
2294
|
-
t.activeElement !==
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2374
|
+
const f = t.createElement("input");
|
|
2375
|
+
f.type = "range", f.min = "0", f.max = String(s.length - 1), f.step = "1", f.setAttribute("aria-label", n);
|
|
2376
|
+
const m = t.createElement("output");
|
|
2377
|
+
return m.setAttribute("aria-hidden", "true"), f.addEventListener("input", () => {
|
|
2378
|
+
const d = s[Number(f.value)];
|
|
2379
|
+
d && e.setScenario(d.id);
|
|
2380
|
+
}), u.append(h, f, m), { element: u, update: () => {
|
|
2381
|
+
const d = Math.max(0, s.findIndex((b) => b.id === e.scenario));
|
|
2382
|
+
t.activeElement !== f && (f.value = String(d));
|
|
2383
|
+
const g = s[d].label;
|
|
2384
|
+
m.textContent !== g && (m.textContent = g), f.setAttribute("aria-valuetext", g);
|
|
2297
2385
|
} };
|
|
2298
2386
|
}
|
|
2299
2387
|
const r = t.createElement("fieldset");
|
|
2300
2388
|
r.className = "tf-ctl-choices";
|
|
2301
2389
|
const a = t.createElement("legend");
|
|
2302
2390
|
a.textContent = n, r.append(a);
|
|
2303
|
-
const o = `tf-ctl-scenario-${++
|
|
2391
|
+
const o = `tf-ctl-scenario-${++Gn}`, c = s.map((u) => {
|
|
2304
2392
|
const h = t.createElement("label");
|
|
2305
2393
|
h.className = "tf-ctl-choice";
|
|
2306
|
-
const
|
|
2307
|
-
|
|
2308
|
-
|
|
2394
|
+
const f = t.createElement("input");
|
|
2395
|
+
f.type = "radio", f.name = o, f.value = u.id, f.addEventListener("change", () => {
|
|
2396
|
+
f.checked && e.setScenario(u.id);
|
|
2309
2397
|
});
|
|
2310
|
-
const
|
|
2311
|
-
return
|
|
2398
|
+
const m = t.createElement("span");
|
|
2399
|
+
return m.textContent = u.label, h.append(f, m), r.append(h), f;
|
|
2312
2400
|
});
|
|
2313
2401
|
return { element: r, update: () => {
|
|
2314
2402
|
for (const u of c) {
|
|
@@ -2317,294 +2405,294 @@ function qn(e, t, n, s) {
|
|
|
2317
2405
|
}
|
|
2318
2406
|
} };
|
|
2319
2407
|
}
|
|
2320
|
-
const
|
|
2321
|
-
function
|
|
2322
|
-
const
|
|
2408
|
+
const ti = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>', ei = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';
|
|
2409
|
+
function ni(e, t, n) {
|
|
2410
|
+
const i = t, s = e, r = t.createElement("button");
|
|
2323
2411
|
r.type = "button", r.className = "tf-ctl-btn tf-ctl-fullscreen";
|
|
2324
2412
|
let a, o = "";
|
|
2325
2413
|
const c = () => {
|
|
2326
|
-
const
|
|
2327
|
-
r.innerHTML =
|
|
2328
|
-
const
|
|
2329
|
-
r.setAttribute("aria-label",
|
|
2330
|
-
}, l = () =>
|
|
2414
|
+
const d = a !== void 0;
|
|
2415
|
+
r.innerHTML = d ? ei : ti;
|
|
2416
|
+
const g = d ? n.exitFullscreen : n.fullscreen;
|
|
2417
|
+
r.setAttribute("aria-label", g), r.title = g, r.setAttribute("aria-pressed", String(d)), e.classList.toggle("tf-fullscreen", d), e.classList.toggle("tf-fullscreen-overlay", a === "overlay");
|
|
2418
|
+
}, l = () => i.fullscreenElement ?? i.webkitFullscreenElement ?? null, u = () => {
|
|
2331
2419
|
l() === e ? a = "native" : a === "native" && (a = void 0), c();
|
|
2332
|
-
}, h = (
|
|
2333
|
-
|
|
2334
|
-
},
|
|
2420
|
+
}, h = (d) => {
|
|
2421
|
+
d.key === "Escape" && p();
|
|
2422
|
+
}, f = () => {
|
|
2335
2423
|
a = "overlay", o = t.documentElement.style.overflow, t.documentElement.style.overflow = "hidden", t.addEventListener("keydown", h), c();
|
|
2336
2424
|
};
|
|
2337
|
-
async function
|
|
2425
|
+
async function m() {
|
|
2338
2426
|
if (a) return;
|
|
2339
|
-
const
|
|
2340
|
-
if (
|
|
2427
|
+
const d = s.requestFullscreen?.bind(s) ?? s.webkitRequestFullscreen?.bind(s), g = i.fullscreenEnabled ?? i.webkitFullscreenEnabled ?? !1;
|
|
2428
|
+
if (d && g)
|
|
2341
2429
|
try {
|
|
2342
|
-
if (await
|
|
2430
|
+
if (await d(), l() === e) {
|
|
2343
2431
|
a = "native", c();
|
|
2344
2432
|
return;
|
|
2345
2433
|
}
|
|
2346
2434
|
} catch {
|
|
2347
2435
|
}
|
|
2348
|
-
|
|
2436
|
+
f();
|
|
2349
2437
|
}
|
|
2350
|
-
async function
|
|
2438
|
+
async function p() {
|
|
2351
2439
|
if (a === "overlay")
|
|
2352
2440
|
t.removeEventListener("keydown", h), t.documentElement.style.overflow = o, a = void 0, c();
|
|
2353
2441
|
else if (a === "native") {
|
|
2354
2442
|
a = void 0, c();
|
|
2355
|
-
const
|
|
2356
|
-
l() === e &&
|
|
2443
|
+
const d = i.exitFullscreen?.bind(i) ?? i.webkitExitFullscreen?.bind(i);
|
|
2444
|
+
l() === e && d && await d();
|
|
2357
2445
|
}
|
|
2358
2446
|
}
|
|
2359
2447
|
return r.addEventListener("click", () => {
|
|
2360
|
-
a ?
|
|
2448
|
+
a ? p() : m();
|
|
2361
2449
|
}), t.addEventListener("fullscreenchange", u), t.addEventListener("webkitfullscreenchange", u), c(), {
|
|
2362
2450
|
button: r,
|
|
2363
2451
|
get active() {
|
|
2364
2452
|
return a !== void 0;
|
|
2365
2453
|
},
|
|
2366
|
-
enter:
|
|
2367
|
-
exit:
|
|
2454
|
+
enter: m,
|
|
2455
|
+
exit: p,
|
|
2368
2456
|
destroy() {
|
|
2369
|
-
|
|
2457
|
+
p(), t.removeEventListener("fullscreenchange", u), t.removeEventListener("webkitfullscreenchange", u), r.remove();
|
|
2370
2458
|
}
|
|
2371
2459
|
};
|
|
2372
2460
|
}
|
|
2373
|
-
const
|
|
2461
|
+
const Ut = "tinyfly-choices-style", ii = `
|
|
2374
2462
|
[data-tinyfly-choose] { cursor: pointer; }
|
|
2375
2463
|
[data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
|
|
2376
2464
|
`;
|
|
2377
|
-
function
|
|
2378
|
-
if (e.getElementById(
|
|
2465
|
+
function si(e) {
|
|
2466
|
+
if (e.getElementById(Ut)) return;
|
|
2379
2467
|
const t = e.createElement("style");
|
|
2380
|
-
t.id =
|
|
2468
|
+
t.id = Ut, t.textContent = ii, e.head.appendChild(t);
|
|
2381
2469
|
}
|
|
2382
|
-
function
|
|
2470
|
+
function ri(e, t) {
|
|
2383
2471
|
const n = Array.from(t.querySelectorAll("[data-tinyfly-choose]"));
|
|
2384
2472
|
if (n.length === 0) return () => {
|
|
2385
2473
|
};
|
|
2386
|
-
|
|
2387
|
-
const
|
|
2474
|
+
si(t.ownerDocument);
|
|
2475
|
+
const i = [], s = [];
|
|
2388
2476
|
for (const o of n) {
|
|
2389
|
-
const c = o.getAttribute("data-tinyfly-choose") ?? "", l = [], u = (
|
|
2390
|
-
o.hasAttribute(
|
|
2477
|
+
const c = o.getAttribute("data-tinyfly-choose") ?? "", l = [], u = (p, d) => {
|
|
2478
|
+
o.hasAttribute(p) || (o.setAttribute(p, d), l.push(p));
|
|
2391
2479
|
};
|
|
2392
2480
|
u("role", "button"), u("tabindex", "0");
|
|
2393
|
-
const h = e.scenarios.find((
|
|
2394
|
-
h !== void 0 && u("aria-label", h), o.setAttribute("aria-pressed", "false"), l.push("aria-pressed"),
|
|
2395
|
-
const
|
|
2396
|
-
const
|
|
2397
|
-
|
|
2481
|
+
const h = e.scenarios.find((p) => p.id === c)?.label;
|
|
2482
|
+
h !== void 0 && u("aria-label", h), o.setAttribute("aria-pressed", "false"), l.push("aria-pressed"), i.push({ element: o, attributes: l });
|
|
2483
|
+
const f = () => e.setScenario(c), m = (p) => {
|
|
2484
|
+
const d = p.key;
|
|
2485
|
+
d !== "Enter" && d !== " " || (p.preventDefault(), f());
|
|
2398
2486
|
};
|
|
2399
|
-
o.addEventListener("click",
|
|
2400
|
-
o.removeEventListener("click",
|
|
2487
|
+
o.addEventListener("click", f), o.addEventListener("keydown", m), s.push(() => {
|
|
2488
|
+
o.removeEventListener("click", f), o.removeEventListener("keydown", m);
|
|
2401
2489
|
});
|
|
2402
2490
|
}
|
|
2403
2491
|
const r = () => {
|
|
2404
|
-
for (const { element: o } of
|
|
2492
|
+
for (const { element: o } of i)
|
|
2405
2493
|
o.setAttribute("aria-pressed", String(o.getAttribute("data-tinyfly-choose") === e.scenario));
|
|
2406
2494
|
}, a = e.subscribe(r);
|
|
2407
2495
|
return r(), () => {
|
|
2408
2496
|
a();
|
|
2409
|
-
for (const o of
|
|
2410
|
-
for (const { element: o, attributes: c } of
|
|
2497
|
+
for (const o of s) o();
|
|
2498
|
+
for (const { element: o, attributes: c } of i) for (const l of c) o.removeAttribute(l);
|
|
2411
2499
|
};
|
|
2412
2500
|
}
|
|
2413
|
-
const
|
|
2414
|
-
let
|
|
2415
|
-
function
|
|
2501
|
+
const ot = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
|
|
2502
|
+
let ai = 0;
|
|
2503
|
+
function J(e, t, n) {
|
|
2416
2504
|
if (e)
|
|
2417
2505
|
try {
|
|
2418
2506
|
return JSON.parse(e);
|
|
2419
|
-
} catch (
|
|
2420
|
-
console.warn(`tinyfly: invalid ${t} JSON on`, n,
|
|
2507
|
+
} catch (i) {
|
|
2508
|
+
console.warn(`tinyfly: invalid ${t} JSON on`, n, i);
|
|
2421
2509
|
return;
|
|
2422
2510
|
}
|
|
2423
2511
|
}
|
|
2424
|
-
async function
|
|
2425
|
-
const n =
|
|
2512
|
+
async function oi(e, t = {}) {
|
|
2513
|
+
const n = ot.get(e);
|
|
2426
2514
|
if (n) return n;
|
|
2427
|
-
const
|
|
2515
|
+
const i = Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")), s = i[0], r = e.getAttribute("data-src"), a = li(e.getAttribute("data-markers")), o = i.length > 1 || s?.hasAttribute("data-scenario") ? ci(i, a, e) : void 0;
|
|
2428
2516
|
if (o && o.length === 0) return;
|
|
2429
|
-
let c =
|
|
2517
|
+
let c = s && !o ? J(s.textContent, "timeline", e) : void 0;
|
|
2430
2518
|
if (!c && r && a) {
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2519
|
+
const m = await fetch(r);
|
|
2520
|
+
m.ok && (c = await m.json());
|
|
2433
2521
|
}
|
|
2434
|
-
if (c && a && (c =
|
|
2522
|
+
if (c && a && (c = re(c, a)), !c && !r && !o) {
|
|
2435
2523
|
console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)', e);
|
|
2436
2524
|
return;
|
|
2437
2525
|
}
|
|
2438
|
-
const l =
|
|
2526
|
+
const l = J(e.querySelector("script[data-tinyfly-captions]")?.textContent, "captions", e), u = {
|
|
2439
2527
|
playWhenVisible: !0,
|
|
2440
2528
|
...t.player,
|
|
2441
2529
|
...l && { captions: l },
|
|
2442
|
-
...
|
|
2530
|
+
...J(e.getAttribute("data-options"), "data-options", e)
|
|
2443
2531
|
};
|
|
2444
|
-
|
|
2445
|
-
const h = new
|
|
2446
|
-
if (
|
|
2447
|
-
const
|
|
2448
|
-
await h.loadScenarios(o, { initial: o.some((
|
|
2532
|
+
ui(e);
|
|
2533
|
+
const h = new St(e, u), f = { element: e, player: h };
|
|
2534
|
+
if (ot.set(e, f), e.setAttribute("data-tinyfly-mounted", ""), o) {
|
|
2535
|
+
const m = e.getAttribute("data-scenario") ?? void 0;
|
|
2536
|
+
await h.loadScenarios(o, { initial: o.some((p) => p.id === m) ? m : void 0 }), xt.set(e, ri(h, e));
|
|
2449
2537
|
} else
|
|
2450
2538
|
await h.load(c ?? r);
|
|
2451
2539
|
if (e.getAttribute("data-controls") !== "false") {
|
|
2452
|
-
const
|
|
2453
|
-
|
|
2540
|
+
const m = J(e.getAttribute("data-labels"), "data-labels", e), p = e.querySelector("figcaption"), d = e.getAttribute("data-scenario-legend"), g = e.getAttribute("data-scenario-control");
|
|
2541
|
+
f.controls = Kn(h, e, {
|
|
2454
2542
|
...t.controls,
|
|
2455
2543
|
...e.getAttribute("data-fullscreen") === "true" ? { fullscreen: !0 } : {},
|
|
2456
|
-
...
|
|
2457
|
-
labels: { ...t.controls?.labels, ...
|
|
2544
|
+
...g === "slider" || g === "buttons" ? { scenarioControl: g } : {},
|
|
2545
|
+
labels: { ...t.controls?.labels, ...m, ...d ? { scenario: d } : {} },
|
|
2458
2546
|
// Inside the figure, before its figcaption, so the caption stays last.
|
|
2459
2547
|
mount: void 0
|
|
2460
|
-
}),
|
|
2548
|
+
}), p ? e.insertBefore(f.controls.element, p) : e.appendChild(f.controls.element);
|
|
2461
2549
|
}
|
|
2462
|
-
return
|
|
2550
|
+
return f;
|
|
2463
2551
|
}
|
|
2464
|
-
function
|
|
2465
|
-
const
|
|
2466
|
-
return e.forEach((
|
|
2467
|
-
const a =
|
|
2552
|
+
function ci(e, t, n) {
|
|
2553
|
+
const i = [];
|
|
2554
|
+
return e.forEach((s, r) => {
|
|
2555
|
+
const a = J(s.textContent, "timeline", n);
|
|
2468
2556
|
if (!a) return;
|
|
2469
|
-
const o =
|
|
2470
|
-
if (
|
|
2557
|
+
const o = s.getAttribute("data-scenario") || `scenario-${r + 1}`;
|
|
2558
|
+
if (i.some((l) => l.id === o)) {
|
|
2471
2559
|
console.warn(`tinyfly: scenario id "${o}" is used more than once; the later one is skipped`, n);
|
|
2472
2560
|
return;
|
|
2473
2561
|
}
|
|
2474
|
-
const c =
|
|
2475
|
-
|
|
2476
|
-
}),
|
|
2562
|
+
const c = s.getAttribute("data-scenario-label") ?? void 0;
|
|
2563
|
+
i.push({ id: o, label: c, timeline: t ? re(a, t) : a });
|
|
2564
|
+
}), i;
|
|
2477
2565
|
}
|
|
2478
|
-
function
|
|
2479
|
-
return e.config.markers?.length ? e : { ...e, config: { ...e.config, markers: t.map((n,
|
|
2566
|
+
function re(e, t) {
|
|
2567
|
+
return e.config.markers?.length ? e : { ...e, config: { ...e.config, markers: t.map((n, i) => ({ id: `step-${i + 1}`, time: n })) } };
|
|
2480
2568
|
}
|
|
2481
|
-
function
|
|
2569
|
+
function li(e) {
|
|
2482
2570
|
if (!e) return;
|
|
2483
|
-
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((n) => Number.isFinite(n) && n >= 0).sort((n,
|
|
2571
|
+
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((n) => Number.isFinite(n) && n >= 0).sort((n, i) => n - i);
|
|
2484
2572
|
return t.length > 0 ? t : void 0;
|
|
2485
2573
|
}
|
|
2486
|
-
async function
|
|
2574
|
+
async function hi(e = document, t = {}) {
|
|
2487
2575
|
const n = Array.from(e.querySelectorAll("[data-tinyfly-embed]"));
|
|
2488
|
-
return (await Promise.all(n.map((
|
|
2576
|
+
return (await Promise.all(n.map((s) => oi(s, t)))).filter((s) => s !== void 0);
|
|
2489
2577
|
}
|
|
2490
|
-
function
|
|
2491
|
-
const t =
|
|
2492
|
-
t && (
|
|
2578
|
+
function xi(e) {
|
|
2579
|
+
const t = ot.get(e);
|
|
2580
|
+
t && (xt.get(e)?.(), xt.delete(e), t.controls?.destroy(), t.player.destroy(), ot.delete(e), e.removeAttribute("data-tinyfly-mounted"));
|
|
2493
2581
|
}
|
|
2494
|
-
function
|
|
2582
|
+
function ui(e) {
|
|
2495
2583
|
const t = e.querySelector("svg");
|
|
2496
2584
|
if (!t || t.hasAttribute("role") || t.hasAttribute("aria-hidden")) return;
|
|
2497
|
-
const n = e.getAttribute("data-alt"),
|
|
2498
|
-
t.setAttribute("role", "img"), n ? t.setAttribute("aria-label", n) :
|
|
2585
|
+
const n = e.getAttribute("data-alt"), i = e.querySelector("figcaption");
|
|
2586
|
+
t.setAttribute("role", "img"), n ? t.setAttribute("aria-label", n) : i && (i.id ||= `tinyfly-caption-${++ai}`, t.setAttribute("aria-labelledby", i.id));
|
|
2499
2587
|
}
|
|
2500
|
-
function
|
|
2588
|
+
function di() {
|
|
2501
2589
|
if (!(typeof document < "u" ? document.currentScript : null)?.hasAttribute("data-tinyfly-auto")) return;
|
|
2502
2590
|
const t = () => {
|
|
2503
|
-
|
|
2591
|
+
hi();
|
|
2504
2592
|
};
|
|
2505
2593
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t, { once: !0 }) : t();
|
|
2506
2594
|
}
|
|
2507
|
-
function
|
|
2595
|
+
function ae(e) {
|
|
2508
2596
|
const t = /* @__PURE__ */ new Set();
|
|
2509
2597
|
for (const n of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(n[2] ?? n[3]);
|
|
2510
2598
|
return [...t];
|
|
2511
2599
|
}
|
|
2512
|
-
function
|
|
2513
|
-
const n = [],
|
|
2514
|
-
if ((e.formatVersion ?? 1) >
|
|
2515
|
-
return
|
|
2600
|
+
function fi(e, t = {}) {
|
|
2601
|
+
const n = [], i = (l) => n.push({ level: "error", message: l }), s = (l) => n.push({ level: "warning", message: l });
|
|
2602
|
+
if ((e.formatVersion ?? 1) > st)
|
|
2603
|
+
return i(`format version ${e.formatVersion} is newer than this tinyfly reads (${st})`), n;
|
|
2516
2604
|
let r = 0;
|
|
2517
2605
|
try {
|
|
2518
|
-
r =
|
|
2606
|
+
r = at(e).duration;
|
|
2519
2607
|
} catch (l) {
|
|
2520
|
-
return
|
|
2608
|
+
return i(`the timeline does not load: ${l instanceof Error ? l.message : String(l)}`), n;
|
|
2521
2609
|
}
|
|
2522
2610
|
const a = e.config?.duration;
|
|
2523
2611
|
if (a !== void 0)
|
|
2524
2612
|
for (const l of e.tracks) {
|
|
2525
2613
|
if (!("keyframes" in l)) continue;
|
|
2526
2614
|
const u = l.keyframes.filter((h) => h.time > a);
|
|
2527
|
-
u.length > 0 &&
|
|
2615
|
+
u.length > 0 && i(`track "${l.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`);
|
|
2528
2616
|
}
|
|
2529
2617
|
const o = e.config?.markers ?? [], c = /* @__PURE__ */ new Set();
|
|
2530
2618
|
o.forEach((l, u) => {
|
|
2531
|
-
c.has(l.id) &&
|
|
2619
|
+
c.has(l.id) && i(`marker id "${l.id}" is used more than once`), c.add(l.id), (l.time < 0 || l.time > r) && i(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`), u > 0 && l.time < o[u - 1].time && i(`marker "${l.id}" comes before "${o[u - 1].id}" in time; list markers in order`);
|
|
2532
2620
|
});
|
|
2533
2621
|
for (const [l, u] of Object.entries(e.captions ?? {})) {
|
|
2534
2622
|
for (const h of Object.keys(u))
|
|
2535
|
-
c.has(h) ||
|
|
2623
|
+
c.has(h) || i(`caption "${h}" (${l}) has no marker with that id`);
|
|
2536
2624
|
for (const h of c)
|
|
2537
|
-
h in u ||
|
|
2625
|
+
h in u || s(`marker "${h}" has no ${l} caption; its label is shown instead`);
|
|
2538
2626
|
}
|
|
2539
2627
|
if (t.markup !== void 0) {
|
|
2540
|
-
const l = new Set(
|
|
2628
|
+
const l = new Set(ae(t.markup)), u = /* @__PURE__ */ new Set();
|
|
2541
2629
|
for (const h of e.tracks)
|
|
2542
|
-
for (const
|
|
2543
|
-
u.add(
|
|
2544
|
-
for (const h of l) u.has(h) ||
|
|
2630
|
+
for (const f of [h.target, ...h.targets ?? []])
|
|
2631
|
+
u.add(f), l.has(f) || i(`track "${h.id}" targets "${f}", but no element has data-tinyfly="${f}"`);
|
|
2632
|
+
for (const h of l) u.has(h) || s(`data-tinyfly="${h}" is never animated`);
|
|
2545
2633
|
}
|
|
2546
2634
|
return n;
|
|
2547
2635
|
}
|
|
2548
|
-
function
|
|
2636
|
+
function pi(e) {
|
|
2549
2637
|
const t = /* @__PURE__ */ new Set();
|
|
2550
2638
|
for (const n of e.matchAll(/data-tinyfly-choose\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(n[2] ?? n[3]);
|
|
2551
2639
|
return [...t];
|
|
2552
2640
|
}
|
|
2553
|
-
function
|
|
2641
|
+
function wi(e, t = {}) {
|
|
2554
2642
|
const n = [];
|
|
2555
2643
|
e.length === 1 && n.push({ level: "warning", message: "only one scenario, so the reader has nothing to choose" });
|
|
2556
|
-
const
|
|
2644
|
+
const i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
2557
2645
|
for (const r of e) {
|
|
2558
|
-
if (
|
|
2646
|
+
if (i.has(r.id)) {
|
|
2559
2647
|
n.push({ level: "error", message: `scenario id "${r.id}" is used more than once` });
|
|
2560
2648
|
continue;
|
|
2561
2649
|
}
|
|
2562
|
-
|
|
2563
|
-
for (const a of
|
|
2650
|
+
i.add(r.id);
|
|
2651
|
+
for (const a of fi(r.timeline, t))
|
|
2564
2652
|
/is never animated$/.test(a.message) || n.push({ level: a.level, message: `scenario "${r.id}": ${a.message}` });
|
|
2565
|
-
for (const a of r.timeline.tracks) for (const o of [a.target, ...a.targets ?? []])
|
|
2653
|
+
for (const a of r.timeline.tracks) for (const o of [a.target, ...a.targets ?? []]) s.add(o);
|
|
2566
2654
|
}
|
|
2567
2655
|
if (t.markup !== void 0) {
|
|
2568
|
-
for (const r of
|
|
2569
|
-
|
|
2570
|
-
for (const r of
|
|
2571
|
-
|
|
2656
|
+
for (const r of pi(t.markup))
|
|
2657
|
+
i.has(r) || n.push({ level: "error", message: `data-tinyfly-choose="${r}" names no scenario` });
|
|
2658
|
+
for (const r of ae(t.markup))
|
|
2659
|
+
s.has(r) || n.push({ level: "warning", message: `data-tinyfly="${r}" is never animated in any scenario` });
|
|
2572
2660
|
}
|
|
2573
2661
|
return n;
|
|
2574
2662
|
}
|
|
2575
|
-
function
|
|
2576
|
-
const
|
|
2577
|
-
for (const
|
|
2578
|
-
const
|
|
2579
|
-
if (!
|
|
2580
|
-
const
|
|
2581
|
-
if (c.has(
|
|
2582
|
-
const
|
|
2583
|
-
c.set(
|
|
2663
|
+
function Mi(e, t, n = "end") {
|
|
2664
|
+
const i = at(t), s = t.config?.markers ?? [], r = n === "start" ? 0 : n === "end" ? i.duration : typeof n == "number" ? n : s.find((f) => f.id === n)?.time ?? i.duration, a = i.getStateAtTime(Math.max(0, Math.min(i.duration, r))), o = new kt(), c = /* @__PURE__ */ new Map(), l = gi(e);
|
|
2665
|
+
for (const f of e.matchAll(jt)) {
|
|
2666
|
+
const m = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(f[2] ?? "");
|
|
2667
|
+
if (!m) continue;
|
|
2668
|
+
const p = m[2] ?? m[3];
|
|
2669
|
+
if (c.has(p)) continue;
|
|
2670
|
+
const d = mi(l(f.index ?? 0));
|
|
2671
|
+
c.set(p, d), o.registerTarget(p, d);
|
|
2584
2672
|
}
|
|
2585
2673
|
o.applyState(a);
|
|
2586
2674
|
let u = "", h = 0;
|
|
2587
|
-
for (const
|
|
2588
|
-
const [
|
|
2675
|
+
for (const f of e.matchAll(jt)) {
|
|
2676
|
+
const [m, p, d = "", g] = f, b = f.index ?? 0, v = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(d), k = v ? c.get(v[2] ?? v[3]) : void 0;
|
|
2589
2677
|
if (!k || Object.keys(k.style).length === 0 && k.text === void 0) continue;
|
|
2590
2678
|
u += e.slice(h, b);
|
|
2591
|
-
const M = Object.entries(k.style).map(([x, P]) => `${
|
|
2592
|
-
let S =
|
|
2679
|
+
const M = Object.entries(k.style).map(([x, P]) => `${yi(x)}: ${P}`).join("; "), y = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(d);
|
|
2680
|
+
let S = d;
|
|
2593
2681
|
if (M)
|
|
2594
2682
|
if (y) {
|
|
2595
2683
|
const x = `${(y[2] ?? y[3]).trim().replace(/;?$/, ";")} ${M}`.trim();
|
|
2596
|
-
S =
|
|
2684
|
+
S = d.replace(y[0], ` style="${Ht(x)}"`);
|
|
2597
2685
|
} else
|
|
2598
|
-
S = `${
|
|
2599
|
-
if (u += `<${
|
|
2600
|
-
const x = e.indexOf(`</${
|
|
2601
|
-
x !== -1 && !P.includes("<") && (u +=
|
|
2686
|
+
S = `${d} style="${Ht(M)}"`;
|
|
2687
|
+
if (u += `<${p}${S}${g ? " /" : ""}>`, h = b + m.length, k.text !== void 0 && !g) {
|
|
2688
|
+
const x = e.indexOf(`</${p}`, h), P = x === -1 ? "" : e.slice(h, x);
|
|
2689
|
+
x !== -1 && !P.includes("<") && (u += bi(k.text), h = x);
|
|
2602
2690
|
}
|
|
2603
2691
|
}
|
|
2604
2692
|
return u + e.slice(h);
|
|
2605
2693
|
}
|
|
2606
|
-
const
|
|
2607
|
-
function
|
|
2694
|
+
const jt = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
|
|
2695
|
+
function mi(e) {
|
|
2608
2696
|
const t = {
|
|
2609
2697
|
style: {},
|
|
2610
2698
|
dataset: {},
|
|
@@ -2619,38 +2707,38 @@ function ss(e) {
|
|
|
2619
2707
|
};
|
|
2620
2708
|
return e && (t.ownerSVGElement = null), t;
|
|
2621
2709
|
}
|
|
2622
|
-
function
|
|
2710
|
+
function gi(e) {
|
|
2623
2711
|
const t = [], n = /<svg[\s>]/gi;
|
|
2624
|
-
let
|
|
2625
|
-
for (;
|
|
2626
|
-
const
|
|
2627
|
-
t.push([
|
|
2712
|
+
let i;
|
|
2713
|
+
for (; i = n.exec(e); ) {
|
|
2714
|
+
const s = e.toLowerCase().indexOf("</svg>", i.index);
|
|
2715
|
+
t.push([i.index + 1, s === -1 ? e.length : s]);
|
|
2628
2716
|
}
|
|
2629
|
-
return (
|
|
2717
|
+
return (s) => t.some(([r, a]) => s > r && s < a);
|
|
2630
2718
|
}
|
|
2631
|
-
function
|
|
2719
|
+
function yi(e) {
|
|
2632
2720
|
const t = e.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`);
|
|
2633
2721
|
return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
|
|
2634
2722
|
}
|
|
2635
|
-
function
|
|
2723
|
+
function Ht(e) {
|
|
2636
2724
|
return e.replace(/&/g, "&").replace(/"/g, """);
|
|
2637
2725
|
}
|
|
2638
|
-
function
|
|
2726
|
+
function bi(e) {
|
|
2639
2727
|
return e.replace(/&/g, "&").replace(/</g, "<");
|
|
2640
2728
|
}
|
|
2641
|
-
|
|
2729
|
+
di();
|
|
2642
2730
|
export {
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2731
|
+
zn as DEFAULT_LABELS,
|
|
2732
|
+
St as TinyflyPlayer,
|
|
2733
|
+
ri as bindChoiceHotspots,
|
|
2734
|
+
ki as create,
|
|
2735
|
+
Kn as createControls,
|
|
2736
|
+
oi as mount,
|
|
2737
|
+
hi as mountAll,
|
|
2738
|
+
vi as play,
|
|
2739
|
+
Mi as renderFrame,
|
|
2740
|
+
ae as targetNamesIn,
|
|
2741
|
+
xi as unmount,
|
|
2742
|
+
fi as validateEmbed,
|
|
2743
|
+
wi as validateScenarios
|
|
2656
2744
|
};
|