@algorisys/tinyfly 0.69.0 → 0.70.1
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 +8 -7
- package/lib/browser/tinyfly.iife.js +21 -4
- package/lib/browser/tinyfly.js +1741 -1654
- package/lib/browser/tinyfly.umd.js +21 -4
- package/lib/embed/tinyfly-embed.iife.js +21 -4
- package/lib/embed/tinyfly-embed.js +971 -884
- package/lib/types/browser/index.d.ts +1 -1
- package/lib/types/embed/controls.d.ts +17 -1
- package/lib/types/embed/index.d.ts +1 -1
- package/lib/types/embed/mount.d.ts +2 -0
- package/package.json +1 -1
|
@@ -17,13 +17,13 @@ function gt(e) {
|
|
|
17
17
|
function de(e) {
|
|
18
18
|
return e.property === "motionPath" && "motionPathConfig" in e;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function zt(e, t, n = "start") {
|
|
21
21
|
if (t <= 1) return 0;
|
|
22
|
-
if (typeof
|
|
23
|
-
const
|
|
24
|
-
return Math.abs(e -
|
|
22
|
+
if (typeof n == "number") {
|
|
23
|
+
const s = Math.max(0, Math.min(t - 1, n));
|
|
24
|
+
return Math.abs(e - s);
|
|
25
25
|
}
|
|
26
|
-
switch (
|
|
26
|
+
switch (n) {
|
|
27
27
|
case "end":
|
|
28
28
|
return t - 1 - e;
|
|
29
29
|
case "center":
|
|
@@ -36,27 +36,27 @@ function Gt(e, t, s = "start") {
|
|
|
36
36
|
}
|
|
37
37
|
function fe(e, t = "start") {
|
|
38
38
|
if (e <= 1) return 0;
|
|
39
|
-
let
|
|
40
|
-
for (let
|
|
41
|
-
|
|
42
|
-
return
|
|
39
|
+
let n = 0;
|
|
40
|
+
for (let s = 0; s < e; s++)
|
|
41
|
+
n = Math.max(n, zt(s, e, t));
|
|
42
|
+
return n;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const r = fe(t,
|
|
49
|
-
return r === 0 ? 0 :
|
|
44
|
+
function Gt(e, t, n) {
|
|
45
|
+
if (n.offsets) return n.offsets[e] ?? 0;
|
|
46
|
+
const s = n.from ?? "start", i = zt(e, t, s);
|
|
47
|
+
if (n.amount !== void 0) {
|
|
48
|
+
const r = fe(t, s);
|
|
49
|
+
return r === 0 ? 0 : n.amount * i / r;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
51
|
+
return n.each !== void 0 ? n.each * i : 0;
|
|
52
52
|
}
|
|
53
53
|
function pe(e, t) {
|
|
54
|
-
return Array.from({ length: e }, (
|
|
54
|
+
return Array.from({ length: e }, (n, s) => Gt(s, e, t));
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function xt(e, t) {
|
|
57
57
|
return e <= 1 ? 0 : Math.max(...pe(e, t));
|
|
58
58
|
}
|
|
59
|
-
const Z = 1, Qt = 6e4, et = Qt / Z,
|
|
59
|
+
const Z = 1, Qt = 6e4, et = Qt / Z, B = {
|
|
60
60
|
stiffness: 180,
|
|
61
61
|
damping: 12,
|
|
62
62
|
mass: 1,
|
|
@@ -89,7 +89,7 @@ class me {
|
|
|
89
89
|
/** Once at rest we stop simulating; every later time returns `to`. */
|
|
90
90
|
settledStep = null;
|
|
91
91
|
constructor(t) {
|
|
92
|
-
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ??
|
|
92
|
+
this.from = t.from, this.to = t.to, this.stiffness = t.stiffness ?? B.stiffness, this.damping = t.damping ?? B.damping, this.mass = t.mass ?? B.mass, this.restDelta = t.restDelta ?? B.restDelta, this.restSpeed = t.restSpeed ?? B.restSpeed, this.distance = Math.abs(this.to - this.from) || 1, this.samples = [this.from], this.velocity = t.velocity ?? B.velocity, this.isAtRest(this.from) && (this.settledStep = 0);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Whether a position/velocity pair counts as settled.
|
|
@@ -107,11 +107,11 @@ class me {
|
|
|
107
107
|
*/
|
|
108
108
|
valueAt(t) {
|
|
109
109
|
if (t <= 0) return this.from;
|
|
110
|
-
const
|
|
111
|
-
if (this.simulateTo(
|
|
110
|
+
const n = Math.floor(t / Z);
|
|
111
|
+
if (this.simulateTo(n + 1), this.settledStep !== null && n >= this.settledStep)
|
|
112
112
|
return this.to;
|
|
113
|
-
const
|
|
114
|
-
return
|
|
113
|
+
const s = this.samples[Math.min(n, this.samples.length - 1)], i = this.samples[Math.min(n + 1, this.samples.length - 1)], r = t / Z - n;
|
|
114
|
+
return s + (i - s) * r;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* How long the spring takes to settle, in milliseconds — the natural duration
|
|
@@ -123,11 +123,11 @@ class me {
|
|
|
123
123
|
/** Advance the cached simulation until it holds at least `steps` samples. */
|
|
124
124
|
simulateTo(t) {
|
|
125
125
|
if (this.settledStep !== null) return;
|
|
126
|
-
const
|
|
127
|
-
for (; this.samples.length <
|
|
128
|
-
const
|
|
129
|
-
this.velocity += c *
|
|
130
|
-
const l =
|
|
126
|
+
const n = Math.min(t, et + 1), s = Z / 1e3;
|
|
127
|
+
for (; this.samples.length < n; ) {
|
|
128
|
+
const i = this.samples[this.samples.length - 1], r = i - this.to, a = -this.stiffness * r, o = -this.damping * this.velocity, c = (a + o) / this.mass;
|
|
129
|
+
this.velocity += c * s;
|
|
130
|
+
const l = i + this.velocity * s;
|
|
131
131
|
if (this.samples.push(l), this.isAtRest(l)) {
|
|
132
132
|
this.settledStep = this.samples.length - 1;
|
|
133
133
|
return;
|
|
@@ -136,73 +136,73 @@ class me {
|
|
|
136
136
|
this.samples.length > et && (this.settledStep = et);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
const
|
|
140
|
-
function
|
|
141
|
-
const t = e.friction ??
|
|
142
|
-
return t > 0 ? t :
|
|
139
|
+
const St = 4, ge = 2e-3, ye = 1e-4, be = 6e4;
|
|
140
|
+
function wt(e) {
|
|
141
|
+
const t = e.friction ?? St;
|
|
142
|
+
return t > 0 ? t : St;
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
return e.from + e.velocity /
|
|
144
|
+
function ve(e) {
|
|
145
|
+
return e.from + e.velocity / wt(e);
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function ke(e, t) {
|
|
148
148
|
if (t === void 0) return e;
|
|
149
149
|
if (typeof t == "number")
|
|
150
150
|
return t > 0 ? Math.round(e / t) * t : e;
|
|
151
151
|
if (t.length === 0) return e;
|
|
152
|
-
let
|
|
153
|
-
for (const
|
|
154
|
-
Math.abs(
|
|
155
|
-
return
|
|
152
|
+
let n = t[0];
|
|
153
|
+
for (const s of t)
|
|
154
|
+
Math.abs(s - e) < Math.abs(n - e) && (n = s);
|
|
155
|
+
return n;
|
|
156
156
|
}
|
|
157
157
|
function Zt(e) {
|
|
158
|
-
let t =
|
|
158
|
+
let t = ke(ve(e), e.end);
|
|
159
159
|
return e.min !== void 0 && (t = Math.max(e.min, t)), e.max !== void 0 && (t = Math.min(e.max, t)), t;
|
|
160
160
|
}
|
|
161
161
|
function Kt(e) {
|
|
162
162
|
const t = Math.abs(Zt(e) - e.from);
|
|
163
163
|
if (t === 0) return 0;
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
return Math.min(be,
|
|
164
|
+
const n = e.restDelta ?? Math.max(ye, t * ge);
|
|
165
|
+
if (n >= t) return 0;
|
|
166
|
+
const s = Math.log(t / n) / wt(e);
|
|
167
|
+
return Math.min(be, s * 1e3);
|
|
168
168
|
}
|
|
169
169
|
function Tt(e, t) {
|
|
170
170
|
if (t <= 0) return e.from;
|
|
171
|
-
const
|
|
172
|
-
if (t >= Kt(e)) return
|
|
173
|
-
const
|
|
174
|
-
return e.from + (
|
|
171
|
+
const n = Zt(e);
|
|
172
|
+
if (t >= Kt(e)) return n;
|
|
173
|
+
const s = wt(e);
|
|
174
|
+
return e.from + (n - e.from) * (1 - Math.exp(-s * t / 1e3));
|
|
175
175
|
}
|
|
176
|
-
const yt = (e) => e,
|
|
176
|
+
const yt = (e) => e, xe = (e) => e * e, we = (e) => 1 - (1 - e) * (1 - e), Me = (e) => e < 0.5 ? 2 * e * e : 1 - Math.pow(-2 * e + 2, 2) / 2, Jt = (e) => e * e * e, te = (e) => 1 - Math.pow(1 - e, 3), ee = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2, Se = Jt, Te = te, _e = ee, Ae = {
|
|
177
177
|
linear: yt,
|
|
178
|
-
"ease-in":
|
|
178
|
+
"ease-in": Se,
|
|
179
179
|
"ease-out": Te,
|
|
180
180
|
"ease-in-out": _e,
|
|
181
|
-
"ease-in-quad":
|
|
182
|
-
"ease-out-quad":
|
|
183
|
-
"ease-in-out-quad":
|
|
181
|
+
"ease-in-quad": xe,
|
|
182
|
+
"ease-out-quad": we,
|
|
183
|
+
"ease-in-out-quad": Me,
|
|
184
184
|
"ease-in-cubic": Jt,
|
|
185
185
|
"ease-out-cubic": te,
|
|
186
186
|
"ease-in-out-cubic": ee
|
|
187
187
|
};
|
|
188
|
-
function
|
|
189
|
-
const [t, s, i
|
|
188
|
+
function Ee(e) {
|
|
189
|
+
const [t, n, s, i] = e, r = 3 * t, a = 3 * (s - t) - r, o = 1 - r - a, c = 3 * n, l = 3 * (i - n) - c, u = 1 - c - l, h = (p) => ((o * p + a) * p + r) * p, d = (p) => ((u * p + l) * p + c) * p, f = (p) => (3 * o * p + 2 * a) * p + r, g = (p) => {
|
|
190
190
|
let m = p;
|
|
191
|
-
for (let
|
|
192
|
-
const
|
|
193
|
-
if (Math.abs(
|
|
191
|
+
for (let k = 0; k < 8; k++) {
|
|
192
|
+
const M = h(m) - p;
|
|
193
|
+
if (Math.abs(M) < 1e-7)
|
|
194
194
|
return m;
|
|
195
195
|
const y = f(m);
|
|
196
196
|
if (Math.abs(y) < 1e-7)
|
|
197
197
|
break;
|
|
198
|
-
m -=
|
|
198
|
+
m -= M / y;
|
|
199
199
|
}
|
|
200
|
-
let b = 0,
|
|
201
|
-
for (m = p; b <
|
|
202
|
-
const
|
|
203
|
-
if (Math.abs(
|
|
200
|
+
let b = 0, v = 1;
|
|
201
|
+
for (m = p; b < v; ) {
|
|
202
|
+
const k = h(m);
|
|
203
|
+
if (Math.abs(k - p) < 1e-7)
|
|
204
204
|
return m;
|
|
205
|
-
p >
|
|
205
|
+
p > k ? b = m : v = m, m = (b + v) / 2;
|
|
206
206
|
}
|
|
207
207
|
return m;
|
|
208
208
|
};
|
|
@@ -215,51 +215,51 @@ function Pe(e) {
|
|
|
215
215
|
}
|
|
216
216
|
function ct(e, t = "out") {
|
|
217
217
|
if (t === "out") return e;
|
|
218
|
-
const
|
|
219
|
-
return t === "in" ?
|
|
218
|
+
const n = (s) => 1 - e(1 - s);
|
|
219
|
+
return t === "in" ? n : (s) => s < 0.5 ? n(s * 2) / 2 : e(s * 2 - 1) / 2 + 0.5;
|
|
220
220
|
}
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
return (
|
|
221
|
+
function Pe(e = 1, t = 0.3) {
|
|
222
|
+
const n = Math.max(1, e), s = t / (2 * Math.PI) * Math.asin(1 / n);
|
|
223
|
+
return (i) => i <= 0 ? 0 : i >= 1 ? 1 : n * Math.pow(2, -10 * i) * Math.sin((i - s) * (2 * Math.PI) / t) + 1;
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const Ce = (e) => {
|
|
226
226
|
if (e <= 0) return 0;
|
|
227
227
|
if (e >= 1) return 1;
|
|
228
228
|
if (e < 1 / 2.75) return 7.5625 * e * e;
|
|
229
229
|
if (e < 2 / 2.75) {
|
|
230
|
-
const
|
|
231
|
-
return 7.5625 *
|
|
230
|
+
const i = e - 0.5454545454545454;
|
|
231
|
+
return 7.5625 * i * i + 0.75;
|
|
232
232
|
}
|
|
233
233
|
if (e < 2.5 / 2.75) {
|
|
234
|
-
const
|
|
235
|
-
return 7.5625 *
|
|
234
|
+
const i = e - 0.8181818181818182;
|
|
235
|
+
return 7.5625 * i * i + 0.9375;
|
|
236
236
|
}
|
|
237
|
-
const
|
|
238
|
-
return 7.5625 *
|
|
237
|
+
const s = e - 2.625 / 2.75;
|
|
238
|
+
return 7.5625 * s * s + 0.984375;
|
|
239
239
|
};
|
|
240
|
-
function
|
|
240
|
+
function Ie(e = 1.70158) {
|
|
241
241
|
return (t) => {
|
|
242
242
|
if (t <= 0) return 0;
|
|
243
243
|
if (t >= 1) return 1;
|
|
244
|
-
const
|
|
245
|
-
return
|
|
244
|
+
const n = t - 1;
|
|
245
|
+
return n * n * ((e + 1) * n + e) + 1;
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
248
|
function Re(e, t = "end") {
|
|
249
|
-
const
|
|
250
|
-
return (
|
|
251
|
-
if (
|
|
252
|
-
if (
|
|
253
|
-
const
|
|
249
|
+
const n = Math.max(1, Math.floor(e));
|
|
250
|
+
return (s) => {
|
|
251
|
+
if (s >= 1) return 1;
|
|
252
|
+
if (s <= 0) return t === "start" || t === "both" ? t === "start" ? 1 / n : 1 / (n + 1) : 0;
|
|
253
|
+
const i = Math.floor(s * n);
|
|
254
254
|
switch (t) {
|
|
255
255
|
case "start":
|
|
256
|
-
return Math.min(1, (
|
|
256
|
+
return Math.min(1, (i + 1) / n);
|
|
257
257
|
case "both":
|
|
258
|
-
return (
|
|
258
|
+
return (i + 1) / (n + 1);
|
|
259
259
|
case "none":
|
|
260
|
-
return
|
|
260
|
+
return n === 1 ? 0 : Math.min(1, i / (n - 1));
|
|
261
261
|
default:
|
|
262
|
-
return
|
|
262
|
+
return i / n;
|
|
263
263
|
}
|
|
264
264
|
};
|
|
265
265
|
}
|
|
@@ -268,15 +268,15 @@ function $e(e) {
|
|
|
268
268
|
case "steps":
|
|
269
269
|
return Re(e.count, e.position);
|
|
270
270
|
case "elastic":
|
|
271
|
-
return ct(
|
|
271
|
+
return ct(Pe(e.amplitude, e.period), e.mode);
|
|
272
272
|
case "bounce":
|
|
273
|
-
return ct(
|
|
273
|
+
return ct(Ce, e.mode);
|
|
274
274
|
case "back":
|
|
275
|
-
return ct(
|
|
275
|
+
return ct(Ie(e.overshoot), e.mode);
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
function De(e) {
|
|
279
|
-
return e === void 0 ? yt : he(e) ?
|
|
279
|
+
return e === void 0 ? yt : he(e) ? Ee(e.points) : ue(e) ? $e(e) : Ae[e] ?? yt;
|
|
280
280
|
}
|
|
281
281
|
const _t = 32, Le = 256, H = /* @__PURE__ */ new Map(), Oe = /[MmLlHhVvCcSsQqTtAaZz]/, Ne = /^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/, Fe = {
|
|
282
282
|
M: 2,
|
|
@@ -292,88 +292,88 @@ const _t = 32, Le = 256, H = /* @__PURE__ */ new Map(), Oe = /[MmLlHhVvCcSsQqTtA
|
|
|
292
292
|
};
|
|
293
293
|
function Xe(e) {
|
|
294
294
|
const t = [];
|
|
295
|
-
let
|
|
296
|
-
const
|
|
297
|
-
for (;
|
|
295
|
+
let n = 0, s = null;
|
|
296
|
+
const i = () => {
|
|
297
|
+
for (; n < e.length && /[\s,]/.test(e[n]); ) n++;
|
|
298
298
|
};
|
|
299
|
-
for (;
|
|
300
|
-
const r = e[
|
|
299
|
+
for (; n < e.length && (i(), !(n >= e.length)); ) {
|
|
300
|
+
const r = e[n];
|
|
301
301
|
if (Oe.test(r)) {
|
|
302
|
-
|
|
302
|
+
s = { type: r, args: [] }, t.push(s), n++;
|
|
303
303
|
continue;
|
|
304
304
|
}
|
|
305
|
-
if (!
|
|
306
|
-
const a =
|
|
305
|
+
if (!s) break;
|
|
306
|
+
const a = s.type === "A" || s.type === "a", o = s.args.length % 7;
|
|
307
307
|
if (a && (o === 3 || o === 4)) {
|
|
308
308
|
if (r !== "0" && r !== "1") break;
|
|
309
|
-
|
|
309
|
+
s.args.push(r === "1" ? 1 : 0), n++;
|
|
310
310
|
continue;
|
|
311
311
|
}
|
|
312
|
-
const c = Ne.exec(e.slice(
|
|
312
|
+
const c = Ne.exec(e.slice(n));
|
|
313
313
|
if (!c) break;
|
|
314
|
-
|
|
314
|
+
s.args.push(parseFloat(c[0])), n += c[0].length;
|
|
315
315
|
}
|
|
316
316
|
return t;
|
|
317
317
|
}
|
|
318
|
-
function Ye(e, t, s, i,
|
|
318
|
+
function Ye(e, t, n, s, i, r, a, o, c) {
|
|
319
319
|
if (e === o && t === c) return [];
|
|
320
|
-
let l = Math.abs(
|
|
320
|
+
let l = Math.abs(n), u = Math.abs(s);
|
|
321
321
|
if (l === 0 || u === 0) return [[e, t, o, c, o, c]];
|
|
322
|
-
const h =
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
325
|
-
l *=
|
|
326
|
-
}
|
|
327
|
-
const
|
|
328
|
-
const ot =
|
|
329
|
-
return
|
|
330
|
-
},
|
|
331
|
-
let
|
|
332
|
-
!a &&
|
|
333
|
-
const
|
|
334
|
-
const
|
|
335
|
-
return [d *
|
|
336
|
-
},
|
|
337
|
-
const
|
|
338
|
-
return [d *
|
|
339
|
-
},
|
|
340
|
-
for (let
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
function
|
|
347
|
-
const r = 1 -
|
|
348
|
-
return r * r * r * e + 3 * r * r *
|
|
349
|
-
}
|
|
350
|
-
function At(e, t, s, i
|
|
351
|
-
const r = 1 -
|
|
352
|
-
return 3 * r * r * (t - e) + 6 * r *
|
|
353
|
-
}
|
|
354
|
-
function
|
|
322
|
+
const h = i * Math.PI / 180, d = Math.cos(h), f = Math.sin(h), g = (e - o) / 2, p = (t - c) / 2, m = d * g + f * p, b = -f * g + d * p, v = m * m / (l * l) + b * b / (u * u);
|
|
323
|
+
if (v > 1) {
|
|
324
|
+
const A = Math.sqrt(v);
|
|
325
|
+
l *= A, u *= A;
|
|
326
|
+
}
|
|
327
|
+
const k = r === a ? -1 : 1, M = l * l * u * u - l * l * b * b - u * u * m * m, y = l * l * b * b + u * u * m * m, S = k * Math.sqrt(Math.max(0, M / y)), x = S * l * b / u, P = -S * u * m / l, Y = d * x - f * P + (e + o) / 2, T = f * x + d * P + (t + c) / 2, R = (A, I, D, W) => {
|
|
328
|
+
const ot = A * D + I * W, tt = Math.sqrt((A * A + I * I) * (D * D + W * W)), j = Math.acos(Math.max(-1, Math.min(1, ot / tt)));
|
|
329
|
+
return A * W - I * D < 0 ? -j : j;
|
|
330
|
+
}, _ = R(1, 0, (m - x) / l, (b - P) / u);
|
|
331
|
+
let C = R((m - x) / l, (b - P) / u, (-m - x) / l, (-b - P) / u);
|
|
332
|
+
!a && C > 0 && (C -= 2 * Math.PI), a && C < 0 && (C += 2 * Math.PI);
|
|
333
|
+
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
|
+
const I = l * Math.cos(A), D = u * Math.sin(A);
|
|
335
|
+
return [d * I - f * D + Y, f * I + d * D + T];
|
|
336
|
+
}, O = (A) => {
|
|
337
|
+
const I = -l * Math.sin(A), D = u * Math.cos(A);
|
|
338
|
+
return [d * I - f * D, f * I + d * D];
|
|
339
|
+
}, $ = [];
|
|
340
|
+
for (let A = 0; A < L; A++) {
|
|
341
|
+
const I = _ + A * w, D = I + w, [W, ot] = N(I), [tt, j] = A === L - 1 ? [o, c] : N(D), [ae, oe] = O(I), [ce, le] = O(D);
|
|
342
|
+
$.push([W + E * ae, ot + E * oe, tt - E * ce, j - E * le, tt, j]);
|
|
343
|
+
}
|
|
344
|
+
return $;
|
|
345
|
+
}
|
|
346
|
+
function X(e, t, n, s, i) {
|
|
347
|
+
const r = 1 - i;
|
|
348
|
+
return r * r * r * e + 3 * r * r * i * t + 3 * r * i * i * n + i * i * i * s;
|
|
349
|
+
}
|
|
350
|
+
function At(e, t, n, s, i) {
|
|
351
|
+
const r = 1 - i;
|
|
352
|
+
return 3 * r * r * (t - e) + 6 * r * i * (n - t) + 3 * i * i * (s - n);
|
|
353
|
+
}
|
|
354
|
+
function z(e, t, n, s) {
|
|
355
355
|
return {
|
|
356
356
|
subpath: 0,
|
|
357
357
|
type: "L",
|
|
358
|
-
points: [
|
|
358
|
+
points: [n, s],
|
|
359
359
|
startX: e,
|
|
360
360
|
startY: t,
|
|
361
|
-
endX:
|
|
362
|
-
endY:
|
|
363
|
-
length: Math.hypot(
|
|
361
|
+
endX: n,
|
|
362
|
+
endY: s,
|
|
363
|
+
length: Math.hypot(n - e, s - t)
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
const [
|
|
366
|
+
function nt(e, t, n) {
|
|
367
|
+
const [s, i, r, a, o, c] = n, l = [0];
|
|
368
368
|
let u = e, h = t, d = 0;
|
|
369
369
|
for (let f = 1; f <= _t; f++) {
|
|
370
|
-
const g = f / _t, p =
|
|
370
|
+
const g = f / _t, p = X(e, s, r, o, g), m = X(t, i, a, c, g);
|
|
371
371
|
d += Math.hypot(p - u, m - h), l.push(d), u = p, h = m;
|
|
372
372
|
}
|
|
373
373
|
return {
|
|
374
374
|
subpath: 0,
|
|
375
375
|
type: "C",
|
|
376
|
-
points: [
|
|
376
|
+
points: [s, i, r, a, o, c],
|
|
377
377
|
startX: e,
|
|
378
378
|
startY: t,
|
|
379
379
|
endX: o,
|
|
@@ -382,97 +382,97 @@ function st(e, t, s) {
|
|
|
382
382
|
lengths: l
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function it(e) {
|
|
386
386
|
const t = H.get(e);
|
|
387
387
|
if (t) return t;
|
|
388
|
-
const
|
|
389
|
-
let
|
|
388
|
+
const n = [];
|
|
389
|
+
let s = 0, i = 0, r = 0, a = 0, o = null, c = null, l = -1;
|
|
390
390
|
const u = /* @__PURE__ */ new Set(), h = (p) => {
|
|
391
|
-
l < 0 && (l = 0), p.subpath = l,
|
|
391
|
+
l < 0 && (l = 0), p.subpath = l, n.push(p);
|
|
392
392
|
};
|
|
393
393
|
for (const { type: p, args: m } of Xe(e)) {
|
|
394
|
-
const b = p.toUpperCase(),
|
|
394
|
+
const b = p.toUpperCase(), v = p !== b, k = Fe[b];
|
|
395
395
|
if (b === "Z") {
|
|
396
|
-
(
|
|
396
|
+
(s !== r || i !== a) && h(z(s, i, r, a)), l >= 0 && u.add(l), s = r, i = a, o = c = null;
|
|
397
397
|
continue;
|
|
398
398
|
}
|
|
399
|
-
for (let
|
|
400
|
-
const y = m.slice(
|
|
401
|
-
let
|
|
399
|
+
for (let M = 0; M + k <= m.length; M += k) {
|
|
400
|
+
const y = m.slice(M, M + k), S = v ? s : 0, x = v ? i : 0;
|
|
401
|
+
let P = null, Y = null;
|
|
402
402
|
switch (b) {
|
|
403
403
|
case "M":
|
|
404
|
-
|
|
404
|
+
M === 0 ? (s = y[0] + S, i = y[1] + x, r = s, a = i, (l < 0 || n[n.length - 1]?.subpath === l) && l++) : (h(z(s, i, y[0] + S, y[1] + x)), s = y[0] + S, i = y[1] + x);
|
|
405
405
|
break;
|
|
406
406
|
case "L":
|
|
407
|
-
h(
|
|
407
|
+
h(z(s, i, y[0] + S, y[1] + x)), s = y[0] + S, i = y[1] + x;
|
|
408
408
|
break;
|
|
409
409
|
case "H":
|
|
410
|
-
h(
|
|
410
|
+
h(z(s, i, y[0] + S, i)), s = y[0] + S;
|
|
411
411
|
break;
|
|
412
412
|
case "V":
|
|
413
|
-
h(
|
|
413
|
+
h(z(s, i, s, y[0] + x)), i = y[0] + x;
|
|
414
414
|
break;
|
|
415
415
|
case "C": {
|
|
416
|
-
const
|
|
417
|
-
h(
|
|
416
|
+
const T = [y[0] + S, y[1] + x, y[2] + S, y[3] + x, y[4] + S, y[5] + x];
|
|
417
|
+
h(nt(s, i, T)), P = [T[2], T[3]], s = T[4], i = T[5];
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
420
|
case "S": {
|
|
421
|
-
const [
|
|
422
|
-
h(
|
|
421
|
+
const [T, R] = o ? [2 * s - o[0], 2 * i - o[1]] : [s, i], _ = [T, R, y[0] + S, y[1] + x, y[2] + S, y[3] + x];
|
|
422
|
+
h(nt(s, i, _)), P = [_[2], _[3]], s = _[4], i = _[5];
|
|
423
423
|
break;
|
|
424
424
|
}
|
|
425
425
|
case "Q":
|
|
426
426
|
case "T": {
|
|
427
|
-
let
|
|
428
|
-
b === "Q" ? (
|
|
429
|
-
const
|
|
427
|
+
let T = s, R = i;
|
|
428
|
+
b === "Q" ? (T = y[0] + S, R = y[1] + x) : c && (T = 2 * s - c[0], R = 2 * i - c[1]);
|
|
429
|
+
const _ = b === "Q" ? y[2] + S : y[0] + S, C = b === "Q" ? y[3] + x : y[1] + x;
|
|
430
430
|
h(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
431
|
+
nt(s, i, [
|
|
432
|
+
s + 2 / 3 * (T - s),
|
|
433
|
+
i + 2 / 3 * (R - i),
|
|
434
|
+
_ + 2 / 3 * (T - _),
|
|
435
|
+
C + 2 / 3 * (R - C),
|
|
436
|
+
_,
|
|
437
|
+
C
|
|
438
438
|
])
|
|
439
|
-
),
|
|
439
|
+
), Y = [T, R], s = _, i = C;
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case "A": {
|
|
443
|
-
const
|
|
444
|
-
let
|
|
445
|
-
for (const
|
|
446
|
-
h(
|
|
447
|
-
|
|
443
|
+
const T = y[5] + S, R = y[6] + x;
|
|
444
|
+
let _ = s, C = i;
|
|
445
|
+
for (const L of Ye(s, i, y[0], y[1], y[2], y[3], y[4], T, R))
|
|
446
|
+
h(nt(_, C, L)), _ = L[4], C = L[5];
|
|
447
|
+
s = T, i = R;
|
|
448
448
|
break;
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
|
-
o =
|
|
451
|
+
o = P, c = Y;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
|
-
const d =
|
|
455
|
-
for (let p = 0; p <
|
|
456
|
-
const m =
|
|
457
|
-
let b = p,
|
|
458
|
-
for (; b <
|
|
459
|
-
const
|
|
460
|
-
f.push({ start: p, end: b, length:
|
|
454
|
+
const d = n.reduce((p, m) => p + m.length, 0), f = [];
|
|
455
|
+
for (let p = 0; p < n.length; ) {
|
|
456
|
+
const m = n[p].subpath;
|
|
457
|
+
let b = p, v = 0;
|
|
458
|
+
for (; b < n.length && n[b].subpath === m; ) v += n[b++].length;
|
|
459
|
+
const k = n[p], M = n[b - 1], y = u.has(m) || Math.abs(M.endX - k.startX) < 1e-9 && Math.abs(M.endY - k.startY) < 1e-9;
|
|
460
|
+
f.push({ start: p, end: b, length: v, closed: y }), p = b;
|
|
461
461
|
}
|
|
462
|
-
const g = { segments:
|
|
462
|
+
const g = { segments: n, totalLength: d, subpaths: f };
|
|
463
463
|
return H.size >= Le && H.delete(H.keys().next().value), H.set(e, g), g;
|
|
464
464
|
}
|
|
465
465
|
function qe(e, t) {
|
|
466
|
-
const
|
|
466
|
+
const n = e.lengths;
|
|
467
467
|
if (t <= 0) return 0;
|
|
468
468
|
if (t >= e.length) return 1;
|
|
469
|
-
let
|
|
470
|
-
for (;
|
|
471
|
-
const o =
|
|
472
|
-
|
|
469
|
+
let s = 0, i = n.length - 1;
|
|
470
|
+
for (; s < i - 1; ) {
|
|
471
|
+
const o = s + i >> 1;
|
|
472
|
+
n[o] < t ? s = o : i = o;
|
|
473
473
|
}
|
|
474
|
-
const r =
|
|
475
|
-
return (
|
|
474
|
+
const r = n[i] - n[s], a = r > 0 ? (t - n[s]) / r : 0;
|
|
475
|
+
return (s + a) / (n.length - 1);
|
|
476
476
|
}
|
|
477
477
|
function Ve(e, t) {
|
|
478
478
|
if (e.type === "L") {
|
|
@@ -483,234 +483,234 @@ function Ve(e, t) {
|
|
|
483
483
|
angle: Math.atan2(e.endY - e.startY, e.endX - e.startX) * 180 / Math.PI
|
|
484
484
|
};
|
|
485
485
|
}
|
|
486
|
-
const [s, i,
|
|
487
|
-
let l = At(e.startX,
|
|
486
|
+
const [n, s, i, r, a, o] = e.points, c = qe(e, t);
|
|
487
|
+
let l = At(e.startX, n, i, a, c), u = At(e.startY, s, r, o, c);
|
|
488
488
|
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), d =
|
|
489
|
+
const h = c < 0.5 ? Math.min(1, c + 1e-3) : Math.max(0, c - 1e-3), d = X(e.startX, n, i, a, h), f = X(e.startY, s, r, o, h), g = X(e.startX, n, i, a, c), p = X(e.startY, s, r, o, c);
|
|
490
490
|
l = c < 0.5 ? d - g : g - d, u = c < 0.5 ? f - p : p - f;
|
|
491
491
|
}
|
|
492
492
|
return {
|
|
493
|
-
x:
|
|
494
|
-
y:
|
|
493
|
+
x: X(e.startX, n, i, a, c),
|
|
494
|
+
y: X(e.startY, s, r, o, c),
|
|
495
495
|
angle: Math.atan2(u, l) * 180 / Math.PI
|
|
496
496
|
};
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
if (
|
|
500
|
-
let
|
|
501
|
-
for (let r =
|
|
498
|
+
function ne(e, t, n = 0, s = e.length) {
|
|
499
|
+
if (s <= n) return { x: 0, y: 0, angle: 0 };
|
|
500
|
+
let i = 0;
|
|
501
|
+
for (let r = n; r < s; r++) {
|
|
502
502
|
const a = e[r];
|
|
503
|
-
if (
|
|
504
|
-
return Ve(a, t -
|
|
505
|
-
|
|
503
|
+
if (i + a.length >= t || r === s - 1)
|
|
504
|
+
return Ve(a, t - i);
|
|
505
|
+
i += a.length;
|
|
506
506
|
}
|
|
507
507
|
return { x: 0, y: 0, angle: 0 };
|
|
508
508
|
}
|
|
509
509
|
function We(e, t) {
|
|
510
|
-
const { segments:
|
|
511
|
-
return
|
|
512
|
-
}
|
|
513
|
-
const Be = 24, Ue = 320, je = 2.5,
|
|
514
|
-
let lt = 0,
|
|
515
|
-
const
|
|
516
|
-
function
|
|
517
|
-
const { segments:
|
|
518
|
-
if (
|
|
510
|
+
const { segments: n, totalLength: s } = it(e);
|
|
511
|
+
return ne(n, Math.max(0, Math.min(1, t)) * s);
|
|
512
|
+
}
|
|
513
|
+
const Be = 24, Ue = 320, je = 2.5, G = 72, He = 0.2, ze = 128, st = /* @__PURE__ */ new Map();
|
|
514
|
+
let lt = 0, q;
|
|
515
|
+
const Et = (e) => Math.round(e * 100) / 100;
|
|
516
|
+
function Pt(e, t) {
|
|
517
|
+
const { segments: n, subpaths: s, totalLength: i } = it(e);
|
|
518
|
+
if (n.length === 0) return [];
|
|
519
519
|
if (t) {
|
|
520
|
-
const r =
|
|
521
|
-
return [{ segments:
|
|
520
|
+
const r = s.every((a) => a.closed);
|
|
521
|
+
return [{ segments: n, start: 0, end: n.length, length: i, closed: r }];
|
|
522
522
|
}
|
|
523
|
-
return
|
|
523
|
+
return s.filter((r) => r.length > 0).map((r) => ({ segments: n, start: r.start, end: r.end, length: r.length, closed: r.closed }));
|
|
524
524
|
}
|
|
525
525
|
function bt(e, t) {
|
|
526
|
-
const
|
|
527
|
-
return [
|
|
526
|
+
const n = e.closed ? (t % 1 + 1) % 1 : Math.max(0, Math.min(1, t)), s = ne(e.segments, n * e.length, e.start, e.end);
|
|
527
|
+
return [s.x, s.y];
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function Ct(e) {
|
|
530
530
|
const t = [];
|
|
531
|
-
let
|
|
532
|
-
for (let
|
|
533
|
-
|
|
531
|
+
let n = 0;
|
|
532
|
+
for (let s = e.start; s < e.end; s++)
|
|
533
|
+
n += e.segments[s].length, e.length > 0 && t.push(n / e.length);
|
|
534
534
|
return t;
|
|
535
535
|
}
|
|
536
|
-
function
|
|
537
|
-
const
|
|
538
|
-
for (let
|
|
539
|
-
|
|
540
|
-
return
|
|
536
|
+
function It(e, t) {
|
|
537
|
+
const n = [];
|
|
538
|
+
for (let s = 0; s < t; s++)
|
|
539
|
+
n.push(bt(e, e.closed ? s / t : s / (t - 1)));
|
|
540
|
+
return n;
|
|
541
541
|
}
|
|
542
542
|
function Rt(e) {
|
|
543
|
-
let t = 0,
|
|
544
|
-
for (const [
|
|
545
|
-
t +=
|
|
546
|
-
return t /= e.length,
|
|
547
|
-
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
550
|
-
if (
|
|
551
|
-
return { offset:
|
|
552
|
-
const
|
|
543
|
+
let t = 0, n = 0;
|
|
544
|
+
for (const [s, i] of e)
|
|
545
|
+
t += s, n += i;
|
|
546
|
+
return t /= e.length, n /= e.length, e.map(([s, i]) => [s - t, i - n]);
|
|
547
|
+
}
|
|
548
|
+
function Ge(e, t, n) {
|
|
549
|
+
const s = e.closed && t.closed;
|
|
550
|
+
if (n !== void 0)
|
|
551
|
+
return { offset: s ? Math.abs(n) % G / G : 0, reversed: n < 0 };
|
|
552
|
+
const i = Rt(It(e, G)), r = Rt(It(t, G)), a = G;
|
|
553
553
|
let o = { offset: 0, reversed: !1 }, c = 1 / 0;
|
|
554
554
|
for (const l of [!1, !0]) {
|
|
555
|
-
const u =
|
|
555
|
+
const u = s ? a : 1;
|
|
556
556
|
for (let h = 0; h < u; h++) {
|
|
557
557
|
let d = 0;
|
|
558
558
|
for (let f = 0; f < a && d < c; f++) {
|
|
559
|
-
const g =
|
|
559
|
+
const g = s ? l ? (h - f + a) % a : (f + h) % a : l ? a - 1 - f : f, p = i[f][0] - r[g][0], m = i[f][1] - r[g][1];
|
|
560
560
|
d += p * p + m * m;
|
|
561
561
|
}
|
|
562
|
-
d < c && (c = d, o = { offset:
|
|
562
|
+
d < c && (c = d, o = { offset: s ? h / a : 0, reversed: l });
|
|
563
563
|
}
|
|
564
564
|
}
|
|
565
565
|
return o;
|
|
566
566
|
}
|
|
567
|
-
function Qe(e, t,
|
|
568
|
-
return
|
|
567
|
+
function Qe(e, t, n) {
|
|
568
|
+
return n ? ((t.reversed ? t.offset - e : e + t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
569
569
|
}
|
|
570
|
-
function Ze(e, t,
|
|
571
|
-
return
|
|
570
|
+
function Ze(e, t, n) {
|
|
571
|
+
return n ? ((t.reversed ? t.offset - e : e - t.offset) % 1 + 1) % 1 : t.reversed ? 1 - e : e;
|
|
572
572
|
}
|
|
573
|
-
function Ke(e, t,
|
|
574
|
-
const
|
|
573
|
+
function Ke(e, t, n) {
|
|
574
|
+
const s = e.closed && t.closed, i = Ge(e, t, n.shapeIndex), r = Math.max(
|
|
575
575
|
Be,
|
|
576
576
|
Math.min(Ue, Math.ceil(Math.max(e.length, t.length) / je))
|
|
577
577
|
), a = /* @__PURE__ */ new Set(), o = (h) => a.add(Math.round(h * 1e7) / 1e7);
|
|
578
578
|
for (let h = 0; h <= r; h++) o(h / r);
|
|
579
|
-
for (const h of
|
|
580
|
-
for (const h of
|
|
579
|
+
for (const h of Ct(e)) o(h);
|
|
580
|
+
for (const h of Ct(t)) o(Ze(h, i, s));
|
|
581
581
|
let c = [...a].sort((h, d) => h - d);
|
|
582
|
-
|
|
582
|
+
s && (c = c.filter((h) => h < 1));
|
|
583
583
|
const l = [], u = [];
|
|
584
584
|
for (const h of c)
|
|
585
|
-
l.push(...bt(e, h)), u.push(...bt(t, Qe(h,
|
|
586
|
-
return Je({ from: l, to: u, closed:
|
|
585
|
+
l.push(...bt(e, h)), u.push(...bt(t, Qe(h, i, s)));
|
|
586
|
+
return Je({ from: l, to: u, closed: s });
|
|
587
587
|
}
|
|
588
588
|
function Je(e) {
|
|
589
589
|
const t = e.from.length / 2;
|
|
590
590
|
if (t <= 3) return e;
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
const
|
|
594
|
-
for (;
|
|
595
|
-
const [a, o] =
|
|
591
|
+
const n = new Uint8Array(t);
|
|
592
|
+
n[0] = 1, n[t - 1] = 1;
|
|
593
|
+
const s = [[0, t - 1]];
|
|
594
|
+
for (; s.length > 0; ) {
|
|
595
|
+
const [a, o] = s.pop();
|
|
596
596
|
let c = -1, l = He;
|
|
597
597
|
for (let u = a + 1; u < o; u++) {
|
|
598
598
|
const h = Math.max($t(e.from, a, o, u), $t(e.to, a, o, u));
|
|
599
599
|
h > l && (l = h, c = u);
|
|
600
600
|
}
|
|
601
|
-
c !== -1 && (
|
|
601
|
+
c !== -1 && (n[c] = 1, s.push([a, c], [c, o]));
|
|
602
602
|
}
|
|
603
|
-
const
|
|
603
|
+
const i = [], r = [];
|
|
604
604
|
for (let a = 0; a < t; a++)
|
|
605
|
-
|
|
606
|
-
return { from:
|
|
605
|
+
n[a] && (i.push(e.from[a * 2], e.from[a * 2 + 1]), r.push(e.to[a * 2], e.to[a * 2 + 1]));
|
|
606
|
+
return { from: i, to: r, closed: e.closed };
|
|
607
607
|
}
|
|
608
|
-
function $t(e, t,
|
|
609
|
-
const
|
|
608
|
+
function $t(e, t, n, s) {
|
|
609
|
+
const i = e[t * 2], r = e[t * 2 + 1], a = e[n * 2] - i, o = e[n * 2 + 1] - r, c = e[s * 2] - i, l = e[s * 2 + 1] - r, u = a * a + o * o, h = u === 0 ? 0 : Math.max(0, Math.min(1, (c * a + l * o) / u));
|
|
610
610
|
return Math.hypot(c - h * a, l - h * o);
|
|
611
611
|
}
|
|
612
|
-
function
|
|
613
|
-
const
|
|
614
|
-
if (
|
|
615
|
-
const r =
|
|
612
|
+
function tn(e, t, n) {
|
|
613
|
+
const s = n.shapeIndex;
|
|
614
|
+
if (q && q.from === e && q.to === t && q.shapeIndex === s) return q.plan;
|
|
615
|
+
const r = st.get(String(s ?? "auto"))?.get(e)?.get(t);
|
|
616
616
|
if (r)
|
|
617
|
-
return
|
|
618
|
-
const a =
|
|
619
|
-
pairs: o.map((f, g) => Ke(f, c[g],
|
|
617
|
+
return q = { from: e, to: t, shapeIndex: s, plan: r }, r;
|
|
618
|
+
const a = it(e).subpaths.filter((f) => f.length > 0).length === it(t).subpaths.filter((f) => f.length > 0).length, o = Pt(e, !a), c = Pt(t, !a), l = {
|
|
619
|
+
pairs: o.map((f, g) => Ke(f, c[g], n))
|
|
620
620
|
};
|
|
621
|
-
lt >=
|
|
622
|
-
const u = String(
|
|
623
|
-
|
|
621
|
+
lt >= ze && (st.clear(), lt = 0);
|
|
622
|
+
const u = String(s ?? "auto"), h = st.get(u) ?? /* @__PURE__ */ new Map();
|
|
623
|
+
st.set(u, h);
|
|
624
624
|
const d = h.get(e) ?? /* @__PURE__ */ new Map();
|
|
625
|
-
return h.set(e, d), d.set(t, l), lt++,
|
|
625
|
+
return h.set(e, d), d.set(t, l), lt++, q = { from: e, to: t, shapeIndex: s, plan: l }, l;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function en(e, t, n, s = {}) {
|
|
628
628
|
if (!e) return t;
|
|
629
629
|
if (!t) return e;
|
|
630
|
-
const
|
|
631
|
-
if (
|
|
632
|
-
if (
|
|
633
|
-
const r =
|
|
634
|
-
if (r.pairs.length === 0) return
|
|
630
|
+
const i = Math.max(0, Math.min(1, n));
|
|
631
|
+
if (i === 0) return e;
|
|
632
|
+
if (i === 1) return t;
|
|
633
|
+
const r = tn(e, t, s);
|
|
634
|
+
if (r.pairs.length === 0) return i < 0.5 ? e : t;
|
|
635
635
|
let a = "";
|
|
636
636
|
for (const o of r.pairs) {
|
|
637
637
|
for (let c = 0; c < o.from.length; c += 2) {
|
|
638
|
-
const l =
|
|
638
|
+
const l = Et(o.from[c] + (o.to[c] - o.from[c]) * i), u = Et(o.from[c + 1] + (o.to[c + 1] - o.from[c + 1]) * i);
|
|
639
639
|
a += `${c === 0 ? a ? " M" : "M" : " L"}${l} ${u}`;
|
|
640
640
|
}
|
|
641
641
|
o.closed && (a += " Z");
|
|
642
642
|
}
|
|
643
643
|
return a;
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function nn(e) {
|
|
646
646
|
return /^\s*[Mm]\s*[-+]?(?:\d|\.\d)/.test(e);
|
|
647
647
|
}
|
|
648
|
-
const
|
|
648
|
+
const F = (e, t, n) => e + (t - e) * n, se = 512, ht = /* @__PURE__ */ new Map(), ut = /* @__PURE__ */ new Map();
|
|
649
649
|
function Dt(e) {
|
|
650
650
|
const t = ht.get(e);
|
|
651
651
|
if (t) return t;
|
|
652
|
-
const
|
|
653
|
-
parseInt(
|
|
654
|
-
parseInt(
|
|
655
|
-
parseInt(
|
|
652
|
+
const n = e.replace("#", ""), s = [
|
|
653
|
+
parseInt(n.slice(0, 2), 16),
|
|
654
|
+
parseInt(n.slice(2, 4), 16),
|
|
655
|
+
parseInt(n.slice(4, 6), 16)
|
|
656
656
|
];
|
|
657
|
-
return ht.size <
|
|
657
|
+
return ht.size < se && ht.set(e, s), s;
|
|
658
658
|
}
|
|
659
|
-
const Lt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Nt = (e) => e.startsWith("rgba"),
|
|
660
|
-
function
|
|
661
|
-
return `#${dt(e)}${dt(t)}${dt(
|
|
659
|
+
const Lt = (e) => e.charCodeAt(0) === 35, Ot = (e) => e.startsWith("rgb"), Nt = (e) => e.startsWith("rgba"), sn = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/, dt = (e) => Math.round(e).toString(16).padStart(2, "0");
|
|
660
|
+
function rn(e, t, n) {
|
|
661
|
+
return `#${dt(e)}${dt(t)}${dt(n)}`;
|
|
662
662
|
}
|
|
663
663
|
function Ft(e) {
|
|
664
664
|
const t = ut.get(e);
|
|
665
665
|
if (t) return t;
|
|
666
|
-
const
|
|
667
|
-
if (!
|
|
666
|
+
const n = e.match(sn);
|
|
667
|
+
if (!n)
|
|
668
668
|
throw new Error(`Invalid rgb color: ${e}`);
|
|
669
|
-
const
|
|
670
|
-
return ut.size <
|
|
669
|
+
const s = parseInt(n[1], 10), i = parseInt(n[2], 10), r = parseInt(n[3], 10), a = n[4] !== void 0 ? [s, i, r, parseFloat(n[4])] : [s, i, r];
|
|
670
|
+
return ut.size < se && ut.set(e, a), a;
|
|
671
671
|
}
|
|
672
|
-
const
|
|
672
|
+
const an = (e, t, n) => {
|
|
673
673
|
if (Lt(e) && Lt(t)) {
|
|
674
|
-
const [
|
|
675
|
-
return
|
|
674
|
+
const [s, i, r] = Dt(e), [a, o, c] = Dt(t), l = F(s, a, n), u = F(i, o, n), h = F(r, c, n);
|
|
675
|
+
return rn(l, u, h);
|
|
676
676
|
}
|
|
677
677
|
if ((Ot(e) || Nt(e)) && (Ot(t) || Nt(t))) {
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
const c =
|
|
678
|
+
const s = Ft(e), i = Ft(t), r = Math.round(F(s[0], i[0], n)), a = Math.round(F(s[1], i[1], n)), o = Math.round(F(s[2], i[2], n));
|
|
679
|
+
if (s.length === 4 || i.length === 4) {
|
|
680
|
+
const c = s[3] ?? 1, l = i[3] ?? 1, u = F(c, l, n);
|
|
681
681
|
return `rgba(${r}, ${a}, ${o}, ${u})`;
|
|
682
682
|
}
|
|
683
683
|
return `rgb(${r}, ${a}, ${o})`;
|
|
684
684
|
}
|
|
685
|
-
return
|
|
686
|
-
},
|
|
687
|
-
const
|
|
688
|
-
for (let r = 0; r <
|
|
689
|
-
|
|
690
|
-
return
|
|
691
|
-
}, Xt = (e, t,
|
|
692
|
-
function
|
|
693
|
-
return typeof e == "number" ?
|
|
694
|
-
}
|
|
695
|
-
function
|
|
696
|
-
const t = [...e.keyframes].sort((
|
|
685
|
+
return n < 1 ? e : t;
|
|
686
|
+
}, on = (e, t, n) => {
|
|
687
|
+
const s = Math.min(e.length, t.length), i = [];
|
|
688
|
+
for (let r = 0; r < s; r++)
|
|
689
|
+
i.push(F(e[r], t[r], n));
|
|
690
|
+
return i;
|
|
691
|
+
}, Xt = (e, t, n) => n < 1 ? e : t, cn = (e, t, n) => en(e, t, n);
|
|
692
|
+
function ln(e) {
|
|
693
|
+
return typeof e == "number" ? F : Array.isArray(e) ? on : typeof e == "string" ? e.startsWith("#") || e.startsWith("rgb") ? an : nn(e) ? cn : Xt : Xt;
|
|
694
|
+
}
|
|
695
|
+
function hn(e) {
|
|
696
|
+
const t = [...e.keyframes].sort((n, s) => n.time - s.time);
|
|
697
697
|
return {
|
|
698
698
|
...e,
|
|
699
699
|
keyframes: t
|
|
700
700
|
};
|
|
701
701
|
}
|
|
702
|
-
function
|
|
702
|
+
function V(e) {
|
|
703
703
|
return e.targets && e.targets.length > 0 ? e.targets : [e.target];
|
|
704
704
|
}
|
|
705
|
-
function
|
|
706
|
-
const
|
|
707
|
-
return !
|
|
705
|
+
function U(e, t, n, s) {
|
|
706
|
+
const i = n ?? 0;
|
|
707
|
+
return !s || t <= 1 ? i : i + Gt(e, t, s);
|
|
708
708
|
}
|
|
709
709
|
class ft {
|
|
710
710
|
track;
|
|
711
711
|
targets;
|
|
712
712
|
constructor(t) {
|
|
713
|
-
this.track = t, this.targets =
|
|
713
|
+
this.track = t, this.targets = V(t);
|
|
714
714
|
}
|
|
715
715
|
/**
|
|
716
716
|
* Get the interpolated value at a specific time.
|
|
@@ -719,7 +719,7 @@ class ft {
|
|
|
719
719
|
* that need every target should use `getTargetValues`.
|
|
720
720
|
*/
|
|
721
721
|
getValueAtTime(t) {
|
|
722
|
-
return this.valueForOffset(t -
|
|
722
|
+
return this.valueForOffset(t - U(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
723
723
|
}
|
|
724
724
|
/**
|
|
725
725
|
* Every target's value at a specific time, in target order.
|
|
@@ -728,12 +728,12 @@ class ft {
|
|
|
728
728
|
* each sampled at its own offset time.
|
|
729
729
|
*/
|
|
730
730
|
getTargetValues(t) {
|
|
731
|
-
const
|
|
732
|
-
for (let
|
|
733
|
-
const r =
|
|
734
|
-
a !== void 0 &&
|
|
731
|
+
const n = this.targets.length, s = [];
|
|
732
|
+
for (let i = 0; i < n; i++) {
|
|
733
|
+
const r = U(i, n, this.track.delay, this.track.stagger), a = this.valueForOffset(t - r);
|
|
734
|
+
a !== void 0 && s.push({ target: this.targets[i], value: a, start: r + this.track.keyframes[0].time });
|
|
735
735
|
}
|
|
736
|
-
return
|
|
736
|
+
return s;
|
|
737
737
|
}
|
|
738
738
|
/**
|
|
739
739
|
* Get the duration of this track — the last keyframe, plus any delay, the
|
|
@@ -743,8 +743,8 @@ class ft {
|
|
|
743
743
|
const { keyframes: t } = this.track;
|
|
744
744
|
if (t.length === 0)
|
|
745
745
|
return 0;
|
|
746
|
-
const
|
|
747
|
-
return
|
|
746
|
+
const n = t[t.length - 1].time, s = this.track.stagger ? xt(this.targets.length, this.track.stagger) : 0;
|
|
747
|
+
return n + (this.track.delay ?? 0) + s + (this.track.endDelay ?? 0);
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
750
750
|
* Get the track metadata.
|
|
@@ -754,129 +754,129 @@ class ft {
|
|
|
754
754
|
}
|
|
755
755
|
/** Interpolated value at a time already shifted into the track's own frame. */
|
|
756
756
|
valueForOffset(t) {
|
|
757
|
-
const { keyframes:
|
|
758
|
-
if (
|
|
757
|
+
const { keyframes: n } = this.track;
|
|
758
|
+
if (n.length === 0)
|
|
759
759
|
return;
|
|
760
|
-
if (
|
|
761
|
-
return
|
|
762
|
-
if (t >=
|
|
763
|
-
return
|
|
764
|
-
const { from:
|
|
765
|
-
if (!
|
|
760
|
+
if (n.length === 1 || t <= n[0].time)
|
|
761
|
+
return n[0].value;
|
|
762
|
+
if (t >= n[n.length - 1].time)
|
|
763
|
+
return n[n.length - 1].value;
|
|
764
|
+
const { from: s, to: i } = this.findSurroundingKeyframes(t);
|
|
765
|
+
if (!s || !i)
|
|
766
766
|
return;
|
|
767
|
-
if (
|
|
768
|
-
return
|
|
769
|
-
const r =
|
|
770
|
-
return
|
|
767
|
+
if (s.time === t)
|
|
768
|
+
return s.value;
|
|
769
|
+
const r = i.time - s.time, a = (t - s.time) / r, c = De(i.easing)(a);
|
|
770
|
+
return ln(s.value)(s.value, i.value, c);
|
|
771
771
|
}
|
|
772
772
|
/**
|
|
773
773
|
* Find the keyframes surrounding a given time.
|
|
774
774
|
*/
|
|
775
775
|
findSurroundingKeyframes(t) {
|
|
776
|
-
const { keyframes:
|
|
777
|
-
for (let
|
|
778
|
-
if (t >= s
|
|
779
|
-
return { from: s
|
|
776
|
+
const { keyframes: n } = this.track;
|
|
777
|
+
for (let s = 0; s < n.length - 1; s++)
|
|
778
|
+
if (t >= n[s].time && t <= n[s + 1].time)
|
|
779
|
+
return { from: n[s], to: n[s + 1] };
|
|
780
780
|
return { from: null, to: null };
|
|
781
781
|
}
|
|
782
782
|
}
|
|
783
|
-
class
|
|
783
|
+
class un {
|
|
784
784
|
track;
|
|
785
785
|
targets;
|
|
786
786
|
sampler;
|
|
787
787
|
constructor(t) {
|
|
788
|
-
this.track = t, this.targets =
|
|
788
|
+
this.track = t, this.targets = V(t), this.sampler = new me(t.spring);
|
|
789
789
|
}
|
|
790
790
|
getValueAtTime(t) {
|
|
791
|
-
return this.sampler.valueAt(t -
|
|
791
|
+
return this.sampler.valueAt(t - U(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
792
792
|
}
|
|
793
793
|
getTargetValues(t) {
|
|
794
|
-
const
|
|
795
|
-
for (let
|
|
796
|
-
const r =
|
|
797
|
-
|
|
794
|
+
const n = this.targets.length, s = [];
|
|
795
|
+
for (let i = 0; i < n; i++) {
|
|
796
|
+
const r = U(i, n, this.track.delay, this.track.stagger);
|
|
797
|
+
s.push({ target: this.targets[i], value: this.sampler.valueAt(t - r), start: r });
|
|
798
798
|
}
|
|
799
|
-
return
|
|
799
|
+
return s;
|
|
800
800
|
}
|
|
801
801
|
/** Settle time plus delay and the widest stagger offset. */
|
|
802
802
|
getDuration() {
|
|
803
|
-
const t = this.track.stagger ?
|
|
803
|
+
const t = this.track.stagger ? xt(this.targets.length, this.track.stagger) : 0;
|
|
804
804
|
return this.sampler.settleTime() + (this.track.delay ?? 0) + t;
|
|
805
805
|
}
|
|
806
806
|
getTrack() {
|
|
807
807
|
return this.track;
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
-
class
|
|
810
|
+
class dn {
|
|
811
811
|
track;
|
|
812
812
|
targets;
|
|
813
813
|
duration;
|
|
814
814
|
constructor(t) {
|
|
815
|
-
this.track = t, this.targets =
|
|
815
|
+
this.track = t, this.targets = V(t), this.duration = Kt(t.inertia);
|
|
816
816
|
}
|
|
817
817
|
getValueAtTime(t) {
|
|
818
|
-
return Tt(this.track.inertia, t -
|
|
818
|
+
return Tt(this.track.inertia, t - U(0, this.targets.length, this.track.delay, this.track.stagger));
|
|
819
819
|
}
|
|
820
820
|
getTargetValues(t) {
|
|
821
|
-
const
|
|
822
|
-
for (let
|
|
823
|
-
const r =
|
|
824
|
-
|
|
821
|
+
const n = this.targets.length, s = [];
|
|
822
|
+
for (let i = 0; i < n; i++) {
|
|
823
|
+
const r = U(i, n, this.track.delay, this.track.stagger);
|
|
824
|
+
s.push({ target: this.targets[i], value: Tt(this.track.inertia, t - r), start: r });
|
|
825
825
|
}
|
|
826
|
-
return
|
|
826
|
+
return s;
|
|
827
827
|
}
|
|
828
828
|
/** Settle time plus delay and the widest stagger offset. */
|
|
829
829
|
getDuration() {
|
|
830
|
-
const t = this.track.stagger ?
|
|
830
|
+
const t = this.track.stagger ? xt(this.targets.length, this.track.stagger) : 0;
|
|
831
831
|
return this.duration + (this.track.delay ?? 0) + t;
|
|
832
832
|
}
|
|
833
833
|
getTrack() {
|
|
834
834
|
return this.track;
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
function
|
|
838
|
-
const
|
|
837
|
+
function fn(e, t) {
|
|
838
|
+
const n = { ...We(e.pathData, t) };
|
|
839
839
|
if (e.matrix) {
|
|
840
|
-
const [
|
|
841
|
-
|
|
842
|
-
const h =
|
|
843
|
-
|
|
840
|
+
const [s, i, r, a, o, c] = e.matrix, { x: l, y: u } = n;
|
|
841
|
+
n.x = s * l + r * u + o, n.y = i * l + a * u + c;
|
|
842
|
+
const h = n.angle * Math.PI / 180, d = Math.cos(h), f = Math.sin(h);
|
|
843
|
+
n.angle = Math.atan2(i * d + a * f, s * d + r * f) * 180 / Math.PI;
|
|
844
844
|
}
|
|
845
|
-
return e.autoRotate && e.rotateOffset && (
|
|
845
|
+
return e.autoRotate && e.rotateOffset && (n.angle += e.rotateOffset), n;
|
|
846
846
|
}
|
|
847
847
|
const pt = {
|
|
848
848
|
upperCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
849
849
|
lowerCase: "abcdefghijklmnopqrstuvwxyz",
|
|
850
850
|
upperAndLowerCase: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
851
851
|
numbers: "0123456789"
|
|
852
|
-
},
|
|
853
|
-
function
|
|
854
|
-
const t = pt[e ?? "upperCase"] ?? e ?? pt.upperCase,
|
|
855
|
-
return
|
|
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(
|
|
852
|
+
}, pn = 20;
|
|
853
|
+
function mn(e) {
|
|
854
|
+
const t = pt[e ?? "upperCase"] ?? e ?? pt.upperCase, n = Array.from(t);
|
|
855
|
+
return n.length > 0 ? n : Array.from(pt.upperCase);
|
|
856
|
+
}
|
|
857
|
+
function gn(e, t, n) {
|
|
858
|
+
let s = (e | 0) ^ Math.imul(t + 1, 2654435761) ^ Math.imul(n + 1, 2246822507);
|
|
859
|
+
return s = Math.imul(s ^ s >>> 16, 2146121005), s = Math.imul(s ^ s >>> 15, 2221713035), (s ^ s >>> 16) >>> 0;
|
|
860
|
+
}
|
|
861
|
+
function yn(e, t, n = 0) {
|
|
862
|
+
const s = e.from ?? "", i = e.to, r = Math.max(0, Math.min(1, t));
|
|
863
|
+
if (r <= 0) return s;
|
|
864
|
+
if (r >= 1) return i;
|
|
865
|
+
const a = Array.from(s), o = Array.from(i), c = e.rightToLeft ?? !1;
|
|
866
866
|
if (e.mode === "type") {
|
|
867
|
-
const
|
|
868
|
-
return c ? a.slice(0, Math.max(0, a.length -
|
|
867
|
+
const v = Math.round(r * Math.max(a.length, o.length));
|
|
868
|
+
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
869
|
}
|
|
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), d = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), f =
|
|
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), d = e.tweenLength === !1 ? o.length : Math.round(a.length + (o.length - a.length) * r), f = mn(e.chars), g = e.refreshRate ?? pn, p = g > 0 ? Math.floor(n * g / 1e3) : 0, m = e.seed ?? 1;
|
|
871
871
|
let b = "";
|
|
872
|
-
for (let
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
` ? b +=
|
|
872
|
+
for (let v = 0; v < d; v++) {
|
|
873
|
+
const k = c ? v >= d - h : v < h, M = c ? o[o.length - (d - v)] : o[v];
|
|
874
|
+
k && M !== void 0 || M === " " || M === `
|
|
875
|
+
` ? b += M : b += f[gn(m, v, p) % f.length];
|
|
876
876
|
}
|
|
877
877
|
return b;
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class bn {
|
|
880
880
|
id;
|
|
881
881
|
name;
|
|
882
882
|
_captions;
|
|
@@ -902,8 +902,8 @@ class ys {
|
|
|
902
902
|
onComplete = null;
|
|
903
903
|
constructor(t) {
|
|
904
904
|
if (this.id = t.id, this.name = t.name, this._captions = t.captions, this._config = t.config ?? {}, this._explicitDuration = t.config?.duration, t.tracks)
|
|
905
|
-
for (const
|
|
906
|
-
this.addTrack(
|
|
905
|
+
for (const n of t.tracks)
|
|
906
|
+
this.addTrack(n);
|
|
907
907
|
}
|
|
908
908
|
get tracks() {
|
|
909
909
|
return [...this._tracks];
|
|
@@ -919,8 +919,8 @@ class ys {
|
|
|
919
919
|
if (this._explicitDuration = t, t !== void 0)
|
|
920
920
|
this._config = { ...this._config, duration: t };
|
|
921
921
|
else if (this._config.duration !== void 0) {
|
|
922
|
-
const
|
|
923
|
-
delete
|
|
922
|
+
const n = { ...this._config };
|
|
923
|
+
delete n.duration, this._config = n;
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
get currentTime() {
|
|
@@ -970,8 +970,8 @@ class ys {
|
|
|
970
970
|
* Seek to a specific time.
|
|
971
971
|
*/
|
|
972
972
|
seek(t) {
|
|
973
|
-
const
|
|
974
|
-
this._currentTime = Math.max(0, Math.min(t,
|
|
973
|
+
const n = this.duration > 0 ? this.duration : 1 / 0;
|
|
974
|
+
this._currentTime = Math.max(0, Math.min(t, n)), this._repeatDelayRemaining = 0, this._wrapAfterDelay = !1;
|
|
975
975
|
}
|
|
976
976
|
/**
|
|
977
977
|
* Toggle or set playback direction.
|
|
@@ -986,34 +986,34 @@ class ys {
|
|
|
986
986
|
tick(t) {
|
|
987
987
|
if (this._playbackState !== "playing")
|
|
988
988
|
return;
|
|
989
|
-
const
|
|
990
|
-
if (
|
|
989
|
+
const n = this.duration;
|
|
990
|
+
if (n <= 0)
|
|
991
991
|
return;
|
|
992
|
-
let
|
|
992
|
+
let i = t * this.speed;
|
|
993
993
|
if (this._repeatDelayRemaining > 0) {
|
|
994
|
-
const o = Math.min(this._repeatDelayRemaining,
|
|
995
|
-
if (this._repeatDelayRemaining -= o,
|
|
994
|
+
const o = Math.min(this._repeatDelayRemaining, i);
|
|
995
|
+
if (this._repeatDelayRemaining -= o, i -= o, this._repeatDelayRemaining > 0) {
|
|
996
996
|
this.onUpdate?.(this.getStateAtTime(this._currentTime));
|
|
997
997
|
return;
|
|
998
998
|
}
|
|
999
999
|
this._wrapAfterDelay && (this._wrapAfterDelay = !1, this._currentTime = 0);
|
|
1000
1000
|
}
|
|
1001
1001
|
const r = 1e3;
|
|
1002
|
-
for (let o = 0; o < r &&
|
|
1002
|
+
for (let o = 0; o < r && i > 0 && this._playbackState === "playing"; o++)
|
|
1003
1003
|
if (this._direction === "forward") {
|
|
1004
|
-
const c =
|
|
1005
|
-
if (
|
|
1006
|
-
if (
|
|
1004
|
+
const c = n - this._currentTime;
|
|
1005
|
+
if (i >= c) {
|
|
1006
|
+
if (i -= c, this._currentTime = n, !this._handleEndReached())
|
|
1007
1007
|
break;
|
|
1008
1008
|
} else
|
|
1009
|
-
this._currentTime +=
|
|
1009
|
+
this._currentTime += i, i = 0;
|
|
1010
1010
|
} else {
|
|
1011
1011
|
const c = this._currentTime;
|
|
1012
|
-
if (
|
|
1013
|
-
if (
|
|
1012
|
+
if (i >= c) {
|
|
1013
|
+
if (i -= c, this._currentTime = 0, !this._handleStartReached())
|
|
1014
1014
|
break;
|
|
1015
1015
|
} else
|
|
1016
|
-
this._currentTime -=
|
|
1016
|
+
this._currentTime -= i, i = 0;
|
|
1017
1017
|
}
|
|
1018
1018
|
const a = this.getStateAtTime(this._currentTime);
|
|
1019
1019
|
this.onUpdate?.(a);
|
|
@@ -1022,17 +1022,17 @@ class ys {
|
|
|
1022
1022
|
* Get the animation state at a specific time.
|
|
1023
1023
|
*/
|
|
1024
1024
|
getStateAtTime(t) {
|
|
1025
|
-
const
|
|
1025
|
+
const n = /* @__PURE__ */ new Map();
|
|
1026
1026
|
if (this._hasSharedWrites())
|
|
1027
|
-
this._resolveShared(t,
|
|
1027
|
+
this._resolveShared(t, n);
|
|
1028
1028
|
else
|
|
1029
|
-
for (const [
|
|
1030
|
-
const r =
|
|
1031
|
-
for (const { target: a, value: o, start: c } of
|
|
1032
|
-
this._write(
|
|
1029
|
+
for (const [s, i] of this._trackPlayers) {
|
|
1030
|
+
const r = i.getTrack().property;
|
|
1031
|
+
for (const { target: a, value: o, start: c } of i.getTargetValues(t))
|
|
1032
|
+
this._write(n, s, a, r, o, t - c);
|
|
1033
1033
|
}
|
|
1034
1034
|
return {
|
|
1035
|
-
values:
|
|
1035
|
+
values: n,
|
|
1036
1036
|
currentTime: this._currentTime,
|
|
1037
1037
|
playbackState: this._playbackState,
|
|
1038
1038
|
direction: this._direction,
|
|
@@ -1052,38 +1052,38 @@ class ys {
|
|
|
1052
1052
|
* a later tween holds its starting value, but does not apply it until its
|
|
1053
1053
|
* turn. `findConflicts()` reports overlaps by the same rule.
|
|
1054
1054
|
*/
|
|
1055
|
-
_resolveShared(t,
|
|
1056
|
-
const
|
|
1057
|
-
for (const [
|
|
1055
|
+
_resolveShared(t, n) {
|
|
1056
|
+
const s = /* @__PURE__ */ new Map();
|
|
1057
|
+
for (const [i, r] of this._trackPlayers) {
|
|
1058
1058
|
const a = r.getTrack().property;
|
|
1059
1059
|
for (const { target: o, value: c, start: l } of r.getTargetValues(t)) {
|
|
1060
|
-
const u = `${o}\0${a}`, h = l <= t, d =
|
|
1061
|
-
(!d || (h !== d.started ? h : h ? l >= d.start : l <= d.start)) &&
|
|
1060
|
+
const u = `${o}\0${a}`, h = l <= t, d = s.get(u);
|
|
1061
|
+
(!d || (h !== d.started ? h : h ? l >= d.start : l <= d.start)) && s.set(u, { trackId: i, target: o, property: a, value: c, start: l, started: h });
|
|
1062
1062
|
}
|
|
1063
1063
|
}
|
|
1064
|
-
for (const { trackId:
|
|
1065
|
-
this._write(
|
|
1064
|
+
for (const { trackId: i, target: r, property: a, value: o, start: c } of s.values())
|
|
1065
|
+
this._write(n, i, r, a, o, t - c);
|
|
1066
1066
|
}
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Write one track's value for a target, expanding the progress of motion paths
|
|
1069
1069
|
* (into x/y/rotation) and text tracks (into the string). `elapsed` is the time
|
|
1070
1070
|
* since this target's animation on the track started.
|
|
1071
1071
|
*/
|
|
1072
|
-
_write(t, s, i,
|
|
1072
|
+
_write(t, n, s, i, r, a) {
|
|
1073
1073
|
if (r === void 0) return;
|
|
1074
|
-
let o = t.get(
|
|
1075
|
-
o || (o = /* @__PURE__ */ new Map(), t.set(
|
|
1076
|
-
const c = this._textTracks.get(
|
|
1074
|
+
let o = t.get(s);
|
|
1075
|
+
o || (o = /* @__PURE__ */ new Map(), t.set(s, o));
|
|
1076
|
+
const c = this._textTracks.get(n);
|
|
1077
1077
|
if (c && typeof r == "number") {
|
|
1078
|
-
o.set("text",
|
|
1078
|
+
o.set("text", yn(c.textConfig, r, Math.max(0, a)));
|
|
1079
1079
|
return;
|
|
1080
1080
|
}
|
|
1081
|
-
const l = this._motionPathTracks.get(
|
|
1081
|
+
const l = this._motionPathTracks.get(n);
|
|
1082
1082
|
if (l && typeof r == "number") {
|
|
1083
|
-
const u =
|
|
1083
|
+
const u = fn(l.motionPathConfig, r);
|
|
1084
1084
|
o.set("motionPathX", u.x), o.set("motionPathY", u.y), l.motionPathConfig.autoRotate && o.set("motionPathRotate", u.angle);
|
|
1085
1085
|
} else
|
|
1086
|
-
o.set(
|
|
1086
|
+
o.set(i, r);
|
|
1087
1087
|
}
|
|
1088
1088
|
/** Cached: does any target+property have more than one track? */
|
|
1089
1089
|
_sharedWrites = null;
|
|
@@ -1091,14 +1091,14 @@ class ys {
|
|
|
1091
1091
|
if (this._sharedWrites === null) {
|
|
1092
1092
|
const t = /* @__PURE__ */ new Set();
|
|
1093
1093
|
this._sharedWrites = !1;
|
|
1094
|
-
t: for (const
|
|
1095
|
-
for (const
|
|
1096
|
-
const
|
|
1097
|
-
if (t.has(
|
|
1094
|
+
t: for (const n of this._tracks)
|
|
1095
|
+
for (const s of V(n)) {
|
|
1096
|
+
const i = `${s}\0${n.property}`;
|
|
1097
|
+
if (t.has(i)) {
|
|
1098
1098
|
this._sharedWrites = !0;
|
|
1099
1099
|
break t;
|
|
1100
1100
|
}
|
|
1101
|
-
t.add(
|
|
1101
|
+
t.add(i);
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
1104
|
return this._sharedWrites;
|
|
@@ -1108,17 +1108,17 @@ class ys {
|
|
|
1108
1108
|
*/
|
|
1109
1109
|
addTrack(t) {
|
|
1110
1110
|
if (this._tracks.push(t), this._sharedWrites = null, mt(t)) {
|
|
1111
|
-
this._trackPlayers.set(t.id, new
|
|
1111
|
+
this._trackPlayers.set(t.id, new dn(t));
|
|
1112
1112
|
return;
|
|
1113
1113
|
}
|
|
1114
1114
|
if (gt(t)) {
|
|
1115
|
-
this._trackPlayers.set(t.id, new
|
|
1115
|
+
this._trackPlayers.set(t.id, new un(t)), this._springTracks.set(t.id, t);
|
|
1116
1116
|
return;
|
|
1117
1117
|
}
|
|
1118
1118
|
if (Ht(t))
|
|
1119
1119
|
this._trackPlayers.set(t.id, new ft(t)), this._textTracks.set(t.id, t);
|
|
1120
1120
|
else if (de(t)) {
|
|
1121
|
-
const
|
|
1121
|
+
const n = {
|
|
1122
1122
|
id: t.id,
|
|
1123
1123
|
target: t.target,
|
|
1124
1124
|
property: t.property,
|
|
@@ -1128,7 +1128,7 @@ class ys {
|
|
|
1128
1128
|
targets: t.targets,
|
|
1129
1129
|
stagger: t.stagger
|
|
1130
1130
|
};
|
|
1131
|
-
this._trackPlayers.set(t.id, new ft(
|
|
1131
|
+
this._trackPlayers.set(t.id, new ft(n)), this._motionPathTracks.set(t.id, t);
|
|
1132
1132
|
} else
|
|
1133
1133
|
this._trackPlayers.set(t.id, new ft(t));
|
|
1134
1134
|
}
|
|
@@ -1137,20 +1137,20 @@ class ys {
|
|
|
1137
1137
|
* (which decides ties when tracks overlap). The new track may have a
|
|
1138
1138
|
* different id. Does nothing if no track has `trackId`.
|
|
1139
1139
|
*/
|
|
1140
|
-
replaceTrack(t,
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
const
|
|
1140
|
+
replaceTrack(t, n) {
|
|
1141
|
+
const s = this._tracks.findIndex((r) => r.id === t);
|
|
1142
|
+
if (s < 0) return;
|
|
1143
|
+
const i = this._tracks.slice(s + 1);
|
|
1144
1144
|
this.removeTrack(t);
|
|
1145
|
-
for (const r of
|
|
1146
|
-
this.addTrack(
|
|
1147
|
-
for (const r of
|
|
1145
|
+
for (const r of i) this.removeTrack(r.id);
|
|
1146
|
+
this.addTrack(n);
|
|
1147
|
+
for (const r of i) this.addTrack(r);
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
1150
|
* Remove a track by its ID.
|
|
1151
1151
|
*/
|
|
1152
1152
|
removeTrack(t) {
|
|
1153
|
-
this._tracks = this._tracks.filter((
|
|
1153
|
+
this._tracks = this._tracks.filter((n) => n.id !== t), this._sharedWrites = null, this._trackPlayers.delete(t), this._motionPathTracks.delete(t), this._springTracks.delete(t), this._textTracks.delete(t);
|
|
1154
1154
|
}
|
|
1155
1155
|
/**
|
|
1156
1156
|
* Tracks matching a filter. All provided fields must match (AND).
|
|
@@ -1160,7 +1160,7 @@ class ys {
|
|
|
1160
1160
|
* the tracks it produced.
|
|
1161
1161
|
*/
|
|
1162
1162
|
getTracks(t = {}) {
|
|
1163
|
-
return this._tracks.filter((
|
|
1163
|
+
return this._tracks.filter((n) => this._matches(n, t));
|
|
1164
1164
|
}
|
|
1165
1165
|
/**
|
|
1166
1166
|
* Remove every track matching a filter. Returns the ids removed.
|
|
@@ -1169,23 +1169,23 @@ class ys {
|
|
|
1169
1169
|
* tweens on an element.
|
|
1170
1170
|
*/
|
|
1171
1171
|
removeTracks(t = {}) {
|
|
1172
|
-
const
|
|
1173
|
-
for (const
|
|
1174
|
-
this.removeTrack(
|
|
1175
|
-
return
|
|
1172
|
+
const n = this.getTracks(t).map((s) => s.id);
|
|
1173
|
+
for (const s of n)
|
|
1174
|
+
this.removeTrack(s);
|
|
1175
|
+
return n;
|
|
1176
1176
|
}
|
|
1177
1177
|
/**
|
|
1178
1178
|
* The time span a track is active over: [start, end] in milliseconds.
|
|
1179
1179
|
*/
|
|
1180
1180
|
getTrackSpan(t) {
|
|
1181
|
-
const
|
|
1182
|
-
if (!
|
|
1183
|
-
const
|
|
1184
|
-
if (gt(
|
|
1185
|
-
return { from:
|
|
1186
|
-
const r =
|
|
1181
|
+
const n = this._trackPlayers.get(t);
|
|
1182
|
+
if (!n) return;
|
|
1183
|
+
const s = n.getTrack(), i = s.delay ?? 0;
|
|
1184
|
+
if (gt(s) || mt(s))
|
|
1185
|
+
return { from: i, to: n.getDuration() };
|
|
1186
|
+
const r = s.keyframes;
|
|
1187
1187
|
if (!(!r || r.length === 0))
|
|
1188
|
-
return { from: r[0].time +
|
|
1188
|
+
return { from: r[0].time + i, to: n.getDuration() };
|
|
1189
1189
|
}
|
|
1190
1190
|
/**
|
|
1191
1191
|
* Overlapping writes to the same target+property.
|
|
@@ -1197,33 +1197,33 @@ class ys {
|
|
|
1197
1197
|
*/
|
|
1198
1198
|
findConflicts() {
|
|
1199
1199
|
const t = [];
|
|
1200
|
-
for (let
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1203
|
-
for (let r = 0; r <
|
|
1200
|
+
for (let n = 0; n < this._tracks.length; n++) {
|
|
1201
|
+
const s = this._tracks[n], i = this.getTrackSpan(s.id);
|
|
1202
|
+
if (i)
|
|
1203
|
+
for (let r = 0; r < n; r++) {
|
|
1204
1204
|
const a = this._tracks[r];
|
|
1205
|
-
if (a.property !==
|
|
1206
|
-
const o =
|
|
1205
|
+
if (a.property !== s.property) continue;
|
|
1206
|
+
const o = V(a).filter((h) => V(s).includes(h));
|
|
1207
1207
|
if (o.length === 0) continue;
|
|
1208
1208
|
const c = this.getTrackSpan(a.id);
|
|
1209
|
-
if (!c || !(c.from <=
|
|
1210
|
-
const u =
|
|
1209
|
+
if (!c || !(c.from <= i.to && i.from <= c.to)) continue;
|
|
1210
|
+
const u = i.from >= c.from;
|
|
1211
1211
|
for (const h of o)
|
|
1212
1212
|
t.push({
|
|
1213
1213
|
target: h,
|
|
1214
|
-
property:
|
|
1215
|
-
losingTrackId: u ? a.id :
|
|
1216
|
-
winningTrackId: u ?
|
|
1214
|
+
property: s.property,
|
|
1215
|
+
losingTrackId: u ? a.id : s.id,
|
|
1216
|
+
winningTrackId: u ? s.id : a.id
|
|
1217
1217
|
});
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
1220
|
return t;
|
|
1221
1221
|
}
|
|
1222
|
-
_matches(t,
|
|
1223
|
-
if (
|
|
1224
|
-
if (
|
|
1225
|
-
const
|
|
1226
|
-
if (!
|
|
1222
|
+
_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 && !V(t).includes(n.target)) return !1;
|
|
1224
|
+
if (n.timeRange) {
|
|
1225
|
+
const s = this.getTrackSpan(t.id);
|
|
1226
|
+
if (!s || s.to < n.timeRange.from || s.from > n.timeRange.to) return !1;
|
|
1227
1227
|
}
|
|
1228
1228
|
return !0;
|
|
1229
1229
|
}
|
|
@@ -1246,12 +1246,12 @@ class ys {
|
|
|
1246
1246
|
}
|
|
1247
1247
|
/** The timeline's markers, in time order (empty when it has none). */
|
|
1248
1248
|
get markers() {
|
|
1249
|
-
return [...this._config.markers ?? []].sort((t,
|
|
1249
|
+
return [...this._config.markers ?? []].sort((t, n) => t.time - n.time);
|
|
1250
1250
|
}
|
|
1251
1251
|
/** Replace the markers (kept in time order); an empty list removes them. */
|
|
1252
1252
|
setMarkers(t) {
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1253
|
+
const n = t && t.length > 0 ? [...t].sort((i, r) => i.time - r.time).map((i) => ({ ...i })) : void 0, s = { ...this._config };
|
|
1254
|
+
n ? s.markers = n : delete s.markers, this._config = s;
|
|
1255
1255
|
}
|
|
1256
1256
|
/** Caption text per language, per marker id */
|
|
1257
1257
|
get captions() {
|
|
@@ -1259,9 +1259,9 @@ class ys {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
/** Replace the captions; languages with no captions are dropped. */
|
|
1261
1261
|
setCaptions(t) {
|
|
1262
|
-
const
|
|
1263
|
-
for (const [
|
|
1264
|
-
this._captions = Object.keys(
|
|
1262
|
+
const n = {};
|
|
1263
|
+
for (const [s, i] of Object.entries(t ?? {})) n[s] = { ...i };
|
|
1264
|
+
this._captions = Object.keys(n).length > 0 ? n : void 0;
|
|
1265
1265
|
}
|
|
1266
1266
|
/** Start the between-iterations pause, if the timeline configures one. */
|
|
1267
1267
|
_armRepeatDelay() {
|
|
@@ -1269,8 +1269,8 @@ class ys {
|
|
|
1269
1269
|
}
|
|
1270
1270
|
_calculateDuration() {
|
|
1271
1271
|
let t = 0;
|
|
1272
|
-
for (const [,
|
|
1273
|
-
t = Math.max(t,
|
|
1272
|
+
for (const [, n] of this._trackPlayers)
|
|
1273
|
+
t = Math.max(t, n.getDuration());
|
|
1274
1274
|
return t;
|
|
1275
1275
|
}
|
|
1276
1276
|
/**
|
|
@@ -1290,25 +1290,25 @@ class ys {
|
|
|
1290
1290
|
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
1291
|
}
|
|
1292
1292
|
}
|
|
1293
|
-
const
|
|
1294
|
-
function
|
|
1295
|
-
const
|
|
1293
|
+
const vn = 100;
|
|
1294
|
+
function kn(e, t, n, s) {
|
|
1295
|
+
const i = [], r = [], { duration: a, alternate: o } = s, c = (f, g, p, m) => {
|
|
1296
1296
|
r.push([f, g]);
|
|
1297
1297
|
const b = [];
|
|
1298
|
-
e.forEach((
|
|
1299
|
-
(p === "forward" ? (m ?
|
|
1300
|
-
}), b.sort((
|
|
1301
|
-
for (const
|
|
1298
|
+
e.forEach((v, k) => {
|
|
1299
|
+
(p === "forward" ? (m ? v >= f : v > f) && v <= g : (m ? v <= f : v < f) && v >= g) && b.push(k);
|
|
1300
|
+
}), b.sort((v, k) => (p === "forward" ? e[v] - e[k] : e[k] - e[v]) || v - k);
|
|
1301
|
+
for (const v of b) i.push({ kind: "event", index: v, direction: p });
|
|
1302
1302
|
};
|
|
1303
1303
|
let l = t.time, u = t.direction, h = t.fresh === !0;
|
|
1304
|
-
const d = Math.min(
|
|
1304
|
+
const d = Math.min(vn, Math.max(0, n.iteration - t.iteration));
|
|
1305
1305
|
for (let f = 0; f < d; f++) {
|
|
1306
1306
|
const g = u === "forward" ? a : 0;
|
|
1307
|
-
c(l, g, u, h),
|
|
1307
|
+
c(l, g, u, h), i.push({ kind: "repeat" }), o ? (u = u === "forward" ? "reverse" : "forward", l = g, h = !1) : (l = u === "forward" ? 0 : a, h = !0);
|
|
1308
1308
|
}
|
|
1309
|
-
return d > 0 &&
|
|
1309
|
+
return d > 0 && s.holding && !o ? { crossings: i, passes: r } : (c(l, n.time, u, h), { crossings: i, passes: r });
|
|
1310
1310
|
}
|
|
1311
|
-
function
|
|
1311
|
+
function xn(e) {
|
|
1312
1312
|
return { ...e, ...Array.isArray(e.end) && { end: [...e.end] } };
|
|
1313
1313
|
}
|
|
1314
1314
|
function Q(e) {
|
|
@@ -1320,7 +1320,7 @@ function Q(e) {
|
|
|
1320
1320
|
...e.stagger !== void 0 && { stagger: { ...e.stagger } }
|
|
1321
1321
|
};
|
|
1322
1322
|
}
|
|
1323
|
-
function
|
|
1323
|
+
function wn(e) {
|
|
1324
1324
|
if (mt(e)) {
|
|
1325
1325
|
const t = e;
|
|
1326
1326
|
return {
|
|
@@ -1328,7 +1328,7 @@ function Ms(e) {
|
|
|
1328
1328
|
target: t.target,
|
|
1329
1329
|
property: t.property,
|
|
1330
1330
|
kind: "inertia",
|
|
1331
|
-
inertia:
|
|
1331
|
+
inertia: xn(t.inertia),
|
|
1332
1332
|
...Q(t)
|
|
1333
1333
|
};
|
|
1334
1334
|
}
|
|
@@ -1350,22 +1350,22 @@ function Ms(e) {
|
|
|
1350
1350
|
target: t.target,
|
|
1351
1351
|
property: "text",
|
|
1352
1352
|
textConfig: { ...t.textConfig },
|
|
1353
|
-
keyframes: [...t.keyframes].sort((
|
|
1353
|
+
keyframes: [...t.keyframes].sort((n, s) => n.time - s.time),
|
|
1354
1354
|
...Q(t)
|
|
1355
1355
|
};
|
|
1356
1356
|
}
|
|
1357
1357
|
if (e.property === "motionPath" && "motionPathConfig" in e) {
|
|
1358
|
-
const t = e,
|
|
1358
|
+
const t = e, n = [...t.keyframes].sort((s, i) => s.time - i.time);
|
|
1359
1359
|
return {
|
|
1360
1360
|
id: t.id,
|
|
1361
1361
|
target: t.target,
|
|
1362
1362
|
property: "motionPath",
|
|
1363
1363
|
motionPathConfig: { ...t.motionPathConfig },
|
|
1364
|
-
keyframes:
|
|
1364
|
+
keyframes: n,
|
|
1365
1365
|
...Q(t)
|
|
1366
1366
|
};
|
|
1367
1367
|
}
|
|
1368
|
-
return
|
|
1368
|
+
return hn({
|
|
1369
1369
|
id: e.id,
|
|
1370
1370
|
target: e.target,
|
|
1371
1371
|
property: e.property,
|
|
@@ -1379,15 +1379,15 @@ function rt(e) {
|
|
|
1379
1379
|
throw new Error(
|
|
1380
1380
|
`tinyfly: this animation uses format version ${t}, but this tinyfly reads up to version ${J}. Update tinyfly to play it.`
|
|
1381
1381
|
);
|
|
1382
|
-
return new
|
|
1382
|
+
return new bn({
|
|
1383
1383
|
id: e.id,
|
|
1384
1384
|
name: e.name,
|
|
1385
1385
|
config: e.config,
|
|
1386
|
-
tracks: e.tracks.map(
|
|
1386
|
+
tracks: e.tracks.map(wn),
|
|
1387
1387
|
captions: e.captions
|
|
1388
1388
|
});
|
|
1389
1389
|
}
|
|
1390
|
-
const
|
|
1390
|
+
const Mn = /* @__PURE__ */ new Set([
|
|
1391
1391
|
"blur",
|
|
1392
1392
|
"brightness",
|
|
1393
1393
|
"glow",
|
|
@@ -1396,25 +1396,25 @@ const Ss = /* @__PURE__ */ new Set([
|
|
|
1396
1396
|
"shadowY",
|
|
1397
1397
|
"shadowBlur",
|
|
1398
1398
|
"shadowColor"
|
|
1399
|
-
]),
|
|
1400
|
-
function
|
|
1399
|
+
]), Sn = "#ffffff", Tn = "rgba(0, 0, 0, 0.5)";
|
|
1400
|
+
function _n(e) {
|
|
1401
1401
|
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
|
|
1404
|
-
t.push(`drop-shadow(${
|
|
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 ?? Sn})`), e.shadowX !== void 0 || e.shadowY !== void 0 || e.shadowBlur !== void 0) {
|
|
1403
|
+
const n = e.shadowX ?? 0, s = e.shadowY ?? 0, i = Math.max(0, e.shadowBlur ?? 0);
|
|
1404
|
+
t.push(`drop-shadow(${n}px ${s}px ${i}px ${e.shadowColor ?? Tn})`);
|
|
1405
1405
|
}
|
|
1406
1406
|
return t.length > 0 ? t.join(" ") : null;
|
|
1407
1407
|
}
|
|
1408
|
-
function
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1408
|
+
function An(e, t) {
|
|
1409
|
+
const n = e.childNodes.length === 1 ? e.firstChild : null;
|
|
1410
|
+
if (n && n.nodeType === 3) {
|
|
1411
|
+
const s = n;
|
|
1412
|
+
s.data !== t && (s.data = t);
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
e.textContent !== t && (e.textContent = t);
|
|
1416
1416
|
}
|
|
1417
|
-
function
|
|
1417
|
+
function En(e) {
|
|
1418
1418
|
if (!("ownerSVGElement" in e)) return;
|
|
1419
1419
|
const t = e.style;
|
|
1420
1420
|
!t || t.transformBox || (t.transformBox = "fill-box", t.transformOrigin || (t.transformOrigin = "50% 50%"));
|
|
@@ -1445,7 +1445,7 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1445
1445
|
"gap",
|
|
1446
1446
|
"rowGap",
|
|
1447
1447
|
"columnGap"
|
|
1448
|
-
]),
|
|
1448
|
+
]), Pn = /* @__PURE__ */ new Set([
|
|
1449
1449
|
"x",
|
|
1450
1450
|
"y",
|
|
1451
1451
|
"z",
|
|
@@ -1463,7 +1463,7 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1463
1463
|
"motionPathX",
|
|
1464
1464
|
"motionPathY",
|
|
1465
1465
|
"motionPathRotate"
|
|
1466
|
-
]),
|
|
1466
|
+
]), Cn = /* @__PURE__ */ new Set(["originX", "originY"]), In = /* @__PURE__ */ new Set(["clipTop", "clipRight", "clipBottom", "clipLeft"]), Rn = {
|
|
1467
1467
|
fill: "backgroundColor",
|
|
1468
1468
|
stroke: "borderColor",
|
|
1469
1469
|
strokeWidth: "borderWidth",
|
|
@@ -1478,14 +1478,14 @@ const Yt = /* @__PURE__ */ new Set([
|
|
|
1478
1478
|
strokeDashoffset: "strokeDashoffset",
|
|
1479
1479
|
fillOpacity: "fillOpacity",
|
|
1480
1480
|
strokeOpacity: "strokeOpacity"
|
|
1481
|
-
},
|
|
1482
|
-
class
|
|
1481
|
+
}, $n = "http://www.w3.org/2000/svg";
|
|
1482
|
+
class vt {
|
|
1483
1483
|
targets = /* @__PURE__ */ new Map();
|
|
1484
1484
|
/**
|
|
1485
1485
|
* Register an HTML element as an animation target.
|
|
1486
1486
|
*/
|
|
1487
|
-
registerTarget(t,
|
|
1488
|
-
this.targets.set(t,
|
|
1487
|
+
registerTarget(t, n) {
|
|
1488
|
+
this.targets.set(t, n);
|
|
1489
1489
|
}
|
|
1490
1490
|
/**
|
|
1491
1491
|
* Unregister a target by its ID.
|
|
@@ -1509,32 +1509,32 @@ class kt {
|
|
|
1509
1509
|
* Apply animation state to all registered targets.
|
|
1510
1510
|
*/
|
|
1511
1511
|
applyState(t) {
|
|
1512
|
-
for (const [
|
|
1513
|
-
const
|
|
1514
|
-
|
|
1512
|
+
for (const [n, s] of t.values) {
|
|
1513
|
+
const i = this.targets.get(n);
|
|
1514
|
+
i && this.applyProperties(i, s);
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
1517
|
/**
|
|
1518
1518
|
* Apply properties to a single element.
|
|
1519
1519
|
*/
|
|
1520
|
-
applyProperties(t,
|
|
1521
|
-
const
|
|
1522
|
-
let
|
|
1523
|
-
const o =
|
|
1524
|
-
for (const [d, f] of
|
|
1520
|
+
applyProperties(t, n) {
|
|
1521
|
+
const s = [];
|
|
1522
|
+
let i = null, r = null, a = null;
|
|
1523
|
+
const o = n.has("motionPathX"), c = n.has("motionPathY"), l = n.has("motionPathRotate");
|
|
1524
|
+
for (const [d, f] of n)
|
|
1525
1525
|
if (!(d === "x" && o) && !(d === "y" && c) && !((d === "rotate" || d === "rotateZ") && l)) {
|
|
1526
|
-
if (
|
|
1526
|
+
if (Pn.has(d)) {
|
|
1527
1527
|
const g = this.buildTransformPart(d, f);
|
|
1528
|
-
g &&
|
|
1529
|
-
} else if (
|
|
1530
|
-
typeof f == "number" && ((
|
|
1531
|
-
else if (
|
|
1528
|
+
g && s.push(g);
|
|
1529
|
+
} else if (Cn.has(d))
|
|
1530
|
+
typeof f == "number" && ((i ??= {})[d] = f);
|
|
1531
|
+
else if (In.has(d))
|
|
1532
1532
|
typeof f == "number" && ((r ??= {})[d] = f);
|
|
1533
|
-
else if (
|
|
1533
|
+
else if (Mn.has(d))
|
|
1534
1534
|
(a ??= {})[d] = f;
|
|
1535
1535
|
else if (d !== "perspective") {
|
|
1536
1536
|
if (d !== "shine") if (d === "text" && typeof f == "string")
|
|
1537
|
-
|
|
1537
|
+
An(t, f);
|
|
1538
1538
|
else if (d === "d" && typeof f == "string") {
|
|
1539
1539
|
const g = t;
|
|
1540
1540
|
(g.tagName?.toLowerCase() === "path" ? g : g.querySelector?.("path"))?.setAttribute?.("d", f);
|
|
@@ -1542,11 +1542,11 @@ class kt {
|
|
|
1542
1542
|
this.applyStyleProperty(t, d, f);
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
|
-
const u =
|
|
1545
|
+
const u = n.get("shine");
|
|
1546
1546
|
typeof u == "number" && this.applyShine(t, u);
|
|
1547
|
-
const h =
|
|
1548
|
-
if (typeof h == "number" &&
|
|
1549
|
-
const d =
|
|
1547
|
+
const h = n.get("perspective");
|
|
1548
|
+
if (typeof h == "number" && s.unshift(`perspective(${h}px)`), s.length > 0 && (t.style.transform = s.join(" "), En(t)), i) {
|
|
1549
|
+
const d = i.originX ?? 50, f = i.originY ?? 50;
|
|
1550
1550
|
t.style.transformOrigin = `${d}% ${f}%`;
|
|
1551
1551
|
}
|
|
1552
1552
|
if (r) {
|
|
@@ -1554,44 +1554,44 @@ class kt {
|
|
|
1554
1554
|
t.style.clipPath = `inset(${d}% ${f}% ${g}% ${p}%)`;
|
|
1555
1555
|
}
|
|
1556
1556
|
if (a) {
|
|
1557
|
-
const d =
|
|
1557
|
+
const d = _n(a);
|
|
1558
1558
|
d && (t.style.filter = d);
|
|
1559
1559
|
}
|
|
1560
1560
|
}
|
|
1561
1561
|
/**
|
|
1562
1562
|
* Build a transform function string for a property.
|
|
1563
1563
|
*/
|
|
1564
|
-
buildTransformPart(t,
|
|
1565
|
-
if (typeof
|
|
1564
|
+
buildTransformPart(t, n) {
|
|
1565
|
+
if (typeof n != "number") return null;
|
|
1566
1566
|
switch (t) {
|
|
1567
1567
|
case "x":
|
|
1568
1568
|
case "motionPathX":
|
|
1569
|
-
return `translateX(${
|
|
1569
|
+
return `translateX(${n}px)`;
|
|
1570
1570
|
case "y":
|
|
1571
1571
|
case "motionPathY":
|
|
1572
|
-
return `translateY(${
|
|
1572
|
+
return `translateY(${n}px)`;
|
|
1573
1573
|
case "z":
|
|
1574
|
-
return `translateZ(${
|
|
1574
|
+
return `translateZ(${n}px)`;
|
|
1575
1575
|
case "rotate":
|
|
1576
1576
|
case "rotateZ":
|
|
1577
1577
|
case "motionPathRotate":
|
|
1578
|
-
return `rotate(${
|
|
1578
|
+
return `rotate(${n}deg)`;
|
|
1579
1579
|
case "rotateX":
|
|
1580
|
-
return `rotateX(${
|
|
1580
|
+
return `rotateX(${n}deg)`;
|
|
1581
1581
|
case "rotateY":
|
|
1582
|
-
return `rotateY(${
|
|
1582
|
+
return `rotateY(${n}deg)`;
|
|
1583
1583
|
case "scale":
|
|
1584
|
-
return `scale(${
|
|
1584
|
+
return `scale(${n})`;
|
|
1585
1585
|
case "scaleX":
|
|
1586
|
-
return `scaleX(${
|
|
1586
|
+
return `scaleX(${n})`;
|
|
1587
1587
|
case "scaleY":
|
|
1588
|
-
return `scaleY(${
|
|
1588
|
+
return `scaleY(${n})`;
|
|
1589
1589
|
case "scaleZ":
|
|
1590
|
-
return `scaleZ(${
|
|
1590
|
+
return `scaleZ(${n})`;
|
|
1591
1591
|
case "skewX":
|
|
1592
|
-
return `skewX(${
|
|
1592
|
+
return `skewX(${n}deg)`;
|
|
1593
1593
|
case "skewY":
|
|
1594
|
-
return `skewY(${
|
|
1594
|
+
return `skewY(${n}deg)`;
|
|
1595
1595
|
default:
|
|
1596
1596
|
return null;
|
|
1597
1597
|
}
|
|
@@ -1604,31 +1604,31 @@ class kt {
|
|
|
1604
1604
|
* white highlight band on top of a solid layer of the element's base colour,
|
|
1605
1605
|
* so the text stays visible while the sheen passes over the glyphs.
|
|
1606
1606
|
*/
|
|
1607
|
-
applyShine(t,
|
|
1607
|
+
applyShine(t, n) {
|
|
1608
1608
|
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(${
|
|
1609
|
+
const s = t.dataset.shineBase, i = -20 + n * 140, r = t.style;
|
|
1610
|
+
r.color = "transparent", r.backgroundImage = `linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.9) 50%, transparent 60%), linear-gradient(${s}, ${s})`, r.backgroundSize = "250% 100%, 100% 100%", r.backgroundPosition = `${i}% 0, 0 0`, r.backgroundRepeat = "no-repeat", r.webkitBackgroundClip = "text", r.backgroundClip = "text";
|
|
1611
1611
|
}
|
|
1612
1612
|
/**
|
|
1613
1613
|
* Apply a single style property to an element.
|
|
1614
1614
|
*/
|
|
1615
|
-
applyStyleProperty(t,
|
|
1616
|
-
let
|
|
1617
|
-
if (t.namespaceURI ===
|
|
1618
|
-
const o = Array.isArray(
|
|
1619
|
-
t.style[qt[
|
|
1615
|
+
applyStyleProperty(t, n, s) {
|
|
1616
|
+
let i;
|
|
1617
|
+
if (t.namespaceURI === $n && n in qt) {
|
|
1618
|
+
const o = Array.isArray(s) ? s.join(", ") : String(s);
|
|
1619
|
+
t.style[qt[n]] = o;
|
|
1620
1620
|
return;
|
|
1621
|
-
} else
|
|
1621
|
+
} else n === "fill" && t.dataset?.elementType === "text" ? i = "color" : i = Rn[n] ?? n;
|
|
1622
1622
|
let a;
|
|
1623
|
-
typeof
|
|
1623
|
+
typeof s == "number" ? Yt.has(n) || Yt.has(i) ? a = `${s}px` : a = String(s) : Array.isArray(s) ? a = s.join(", ") : a = s, t.style[i] = a;
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
1626
|
class Vt {
|
|
1627
1627
|
media;
|
|
1628
1628
|
offset;
|
|
1629
1629
|
driftTolerance;
|
|
1630
|
-
constructor(t,
|
|
1631
|
-
this.media = t, this.offset =
|
|
1630
|
+
constructor(t, n = {}) {
|
|
1631
|
+
this.media = t, this.offset = n.offset ?? 0, this.driftTolerance = Math.max(0, n.driftTolerance ?? 0.15);
|
|
1632
1632
|
}
|
|
1633
1633
|
/** Map a timeline time (ms) to the media's time (seconds), never negative. */
|
|
1634
1634
|
targetTime(t) {
|
|
@@ -1640,9 +1640,9 @@ class Vt {
|
|
|
1640
1640
|
* @param timelineTimeMs current timeline time in milliseconds
|
|
1641
1641
|
* @param isPlaying whether the timeline is playing
|
|
1642
1642
|
*/
|
|
1643
|
-
update(t,
|
|
1644
|
-
const
|
|
1645
|
-
|
|
1643
|
+
update(t, n) {
|
|
1644
|
+
const s = this.targetTime(t);
|
|
1645
|
+
n ? (this.media.paused && this.safePlay(), Math.abs(this.media.currentTime - s) > this.driftTolerance && (this.media.currentTime = s)) : (this.media.paused || this.media.pause(), this.media.currentTime !== s && (this.media.currentTime = s));
|
|
1646
1646
|
}
|
|
1647
1647
|
/** Hard-align the media to a timeline time (used on explicit seeks). */
|
|
1648
1648
|
seek(t) {
|
|
@@ -1662,15 +1662,15 @@ class Vt {
|
|
|
1662
1662
|
});
|
|
1663
1663
|
}
|
|
1664
1664
|
}
|
|
1665
|
-
function
|
|
1666
|
-
const r =
|
|
1665
|
+
function Dn(e, t, n, s, i) {
|
|
1666
|
+
const r = n - i;
|
|
1667
1667
|
if (r < 0) {
|
|
1668
1668
|
t.paused || t.pause(), t.currentTime = 0;
|
|
1669
1669
|
return;
|
|
1670
1670
|
}
|
|
1671
|
-
e.update(r,
|
|
1671
|
+
e.update(r, s);
|
|
1672
1672
|
}
|
|
1673
|
-
class
|
|
1673
|
+
class Mt {
|
|
1674
1674
|
container;
|
|
1675
1675
|
timeline = null;
|
|
1676
1676
|
adapter;
|
|
@@ -1701,15 +1701,15 @@ class wt {
|
|
|
1701
1701
|
/** `autoplay` waits for the first time the container is seen */
|
|
1702
1702
|
autoplayWhenSeen = !1;
|
|
1703
1703
|
onDocumentVisibility = () => this.updateVisibility();
|
|
1704
|
-
constructor(t,
|
|
1704
|
+
constructor(t, n = {}) {
|
|
1705
1705
|
if (typeof t == "string") {
|
|
1706
|
-
const
|
|
1707
|
-
if (!
|
|
1706
|
+
const s = document.querySelector(t);
|
|
1707
|
+
if (!s)
|
|
1708
1708
|
throw new Error(`Container not found: ${t}`);
|
|
1709
|
-
this.container =
|
|
1709
|
+
this.container = s;
|
|
1710
1710
|
} else
|
|
1711
1711
|
this.container = t;
|
|
1712
|
-
this.options =
|
|
1712
|
+
this.options = n, this.adapter = new vt();
|
|
1713
1713
|
}
|
|
1714
1714
|
/**
|
|
1715
1715
|
* Load animation from a URL or JSON object.
|
|
@@ -1718,15 +1718,15 @@ class wt {
|
|
|
1718
1718
|
this.scenarioList = [], this.scenarioId = void 0, await this.loadSource(t);
|
|
1719
1719
|
}
|
|
1720
1720
|
async loadSource(t) {
|
|
1721
|
-
let
|
|
1721
|
+
let n;
|
|
1722
1722
|
if (typeof t == "string") {
|
|
1723
|
-
const
|
|
1724
|
-
if (!
|
|
1725
|
-
throw new Error(`Failed to load animation: ${
|
|
1726
|
-
|
|
1723
|
+
const s = await fetch(t);
|
|
1724
|
+
if (!s.ok)
|
|
1725
|
+
throw new Error(`Failed to load animation: ${s.statusText}`);
|
|
1726
|
+
n = await s.json();
|
|
1727
1727
|
} else
|
|
1728
|
-
|
|
1729
|
-
this.useDefinition(
|
|
1728
|
+
n = t;
|
|
1729
|
+
this.useDefinition(n), this.showInitialFrame(), this.watchReducedMotion(), this.watchVisibility(), this.options.autoplay && !this.reducedMotion && (this.options.playWhenVisible && !this.onScreen ? this.autoplayWhenSeen = !0 : this.play());
|
|
1730
1730
|
}
|
|
1731
1731
|
/**
|
|
1732
1732
|
* Make a definition the current timeline: targets, symbols and media bound, no
|
|
@@ -1734,8 +1734,8 @@ class wt {
|
|
|
1734
1734
|
* scenario's timeline can be used again.
|
|
1735
1735
|
*/
|
|
1736
1736
|
useDefinition(t) {
|
|
1737
|
-
const
|
|
1738
|
-
this.options.speed !== void 0 && (
|
|
1737
|
+
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 = rt({ ...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
1739
|
}
|
|
1740
1740
|
// --- scenarios: the reader chooses which timeline plays --------------------
|
|
1741
1741
|
/**
|
|
@@ -1743,16 +1743,16 @@ class wt {
|
|
|
1743
1743
|
* with `setScenario`; the embed's controls and `data-tinyfly-choose` hotspots
|
|
1744
1744
|
* call it.
|
|
1745
1745
|
*/
|
|
1746
|
-
async loadScenarios(t,
|
|
1746
|
+
async loadScenarios(t, n = {}) {
|
|
1747
1747
|
if (t.length === 0) throw new Error("tinyfly: loadScenarios needs at least one scenario");
|
|
1748
|
-
const
|
|
1748
|
+
const s = /* @__PURE__ */ new Set();
|
|
1749
1749
|
for (const r of t) {
|
|
1750
|
-
if (
|
|
1751
|
-
|
|
1750
|
+
if (s.has(r.id)) throw new Error(`tinyfly: scenario id "${r.id}" is used more than once`);
|
|
1751
|
+
s.add(r.id);
|
|
1752
1752
|
}
|
|
1753
|
-
const
|
|
1754
|
-
if (!
|
|
1755
|
-
this.scenarioList = [...t], this.scenarioId =
|
|
1753
|
+
const i = n.initial === void 0 ? t[0] : t.find((r) => r.id === n.initial);
|
|
1754
|
+
if (!i) throw new Error(`tinyfly: there is no scenario "${n.initial}"`);
|
|
1755
|
+
this.scenarioList = [...t], this.scenarioId = i.id, await this.loadSource(i.timeline);
|
|
1756
1756
|
}
|
|
1757
1757
|
/** The scenarios to choose from (empty for a single timeline). */
|
|
1758
1758
|
get scenarios() {
|
|
@@ -1770,28 +1770,28 @@ class wt {
|
|
|
1770
1770
|
* new scenario's final frame shows. Returns false for an unknown id.
|
|
1771
1771
|
*/
|
|
1772
1772
|
setScenario(t) {
|
|
1773
|
-
const
|
|
1774
|
-
if (!
|
|
1773
|
+
const n = this.scenarioList.find((o) => o.id === t);
|
|
1774
|
+
if (!n || !this.timeline) return !1;
|
|
1775
1775
|
if (t === this.scenarioId) return !0;
|
|
1776
|
-
const
|
|
1777
|
-
this.stopAnimationLoop(), this.stepping = !1, this.pausedByVisibility = !1, this.restoreAuthored(), this.scenarioId = t, this.useDefinition(
|
|
1776
|
+
const s = this.isPlaying, i = this.currentTime >= this.duration - 0.5, r = this.currentMarker?.id;
|
|
1777
|
+
this.stopAnimationLoop(), this.stepping = !1, this.pausedByVisibility = !1, this.restoreAuthored(), this.scenarioId = t, this.useDefinition(n.timeline), this.lastMarkerId = null;
|
|
1778
1778
|
let a = 0;
|
|
1779
|
-
return this.reducedMotion ||
|
|
1779
|
+
return this.reducedMotion || i ? a = this.duration : r !== void 0 && (a = this.markers.find((o) => o.id === r)?.time ?? 0), this.seek(a), s && !this.reducedMotion ? (this.stepping = this.options.stepMode === !0, this.startPlaying()) : this.notify(), !0;
|
|
1780
1780
|
}
|
|
1781
1781
|
/** Remember how an element was authored, the first time it becomes a target. */
|
|
1782
1782
|
rememberAuthored(t) {
|
|
1783
1783
|
if (this.authored.has(t)) return;
|
|
1784
|
-
const
|
|
1785
|
-
t.children.length === 0 && (
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1784
|
+
const n = { style: t.getAttribute("style") };
|
|
1785
|
+
t.children.length === 0 && (n.text = t.textContent ?? "");
|
|
1786
|
+
const s = t.tagName.toLowerCase() === "path" ? t : t.querySelector("path");
|
|
1787
|
+
s && (n.path = { element: s, d: s.getAttribute("d") }), this.authored.set(t, n);
|
|
1788
1788
|
}
|
|
1789
1789
|
/** Put every target back the way it was authored. */
|
|
1790
1790
|
restoreAuthored() {
|
|
1791
|
-
for (const [t,
|
|
1792
|
-
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1791
|
+
for (const [t, n] of this.authored) {
|
|
1792
|
+
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 s = t.dataset;
|
|
1794
|
+
s && delete s.shineBase;
|
|
1795
1795
|
}
|
|
1796
1796
|
}
|
|
1797
1797
|
// --- teaching: frames, markers, reduced motion, visibility -----------------
|
|
@@ -1816,43 +1816,43 @@ class wt {
|
|
|
1816
1816
|
/** The last marker at or before the playhead. */
|
|
1817
1817
|
get currentMarker() {
|
|
1818
1818
|
const t = this.currentTime;
|
|
1819
|
-
let
|
|
1820
|
-
for (const
|
|
1821
|
-
if (
|
|
1819
|
+
let n;
|
|
1820
|
+
for (const s of this.markers)
|
|
1821
|
+
if (s.time <= t + 0.5) n = s;
|
|
1822
1822
|
else break;
|
|
1823
|
-
return
|
|
1823
|
+
return n;
|
|
1824
1824
|
}
|
|
1825
1825
|
/**
|
|
1826
1826
|
* Caption for a marker (default: the current one) in a language (default: the
|
|
1827
1827
|
* container's closest `lang`, then the document's), falling back to the
|
|
1828
1828
|
* marker's own label.
|
|
1829
1829
|
*/
|
|
1830
|
-
caption(t,
|
|
1831
|
-
const
|
|
1832
|
-
if (!
|
|
1833
|
-
const
|
|
1834
|
-
return r(this.options.captions) ?? r(this.timeline?.captions) ??
|
|
1830
|
+
caption(t, n) {
|
|
1831
|
+
const s = t ? this.markers.find((a) => a.id === t) : this.currentMarker;
|
|
1832
|
+
if (!s) return;
|
|
1833
|
+
const i = n ?? this.language(), r = (a) => a?.[i]?.[s.id] ?? a?.[i.split("-")[0]]?.[s.id];
|
|
1834
|
+
return r(this.options.captions) ?? r(this.timeline?.captions) ?? s.label;
|
|
1835
1835
|
}
|
|
1836
1836
|
/** Move to the next marker: animated, or a jump under reduced motion. At the last marker, to the end. */
|
|
1837
1837
|
next() {
|
|
1838
1838
|
if (!this.timeline) return;
|
|
1839
|
-
const t = this.currentTime,
|
|
1839
|
+
const t = this.currentTime, n = this.markers.find((s) => s.time > t + 0.5);
|
|
1840
1840
|
if (this.reducedMotion) {
|
|
1841
|
-
this.seek(
|
|
1841
|
+
this.seek(n ? n.time : this.duration);
|
|
1842
1842
|
return;
|
|
1843
1843
|
}
|
|
1844
|
-
t >= this.duration - 0.5 || (this.stepping =
|
|
1844
|
+
t >= this.duration - 0.5 || (this.stepping = n !== void 0, this.startPlaying());
|
|
1845
1845
|
}
|
|
1846
1846
|
/** Jump back to the previous marker (or the start). */
|
|
1847
1847
|
prev() {
|
|
1848
1848
|
if (!this.timeline) return;
|
|
1849
|
-
const t = this.currentTime,
|
|
1850
|
-
this.pause(), this.seek(
|
|
1849
|
+
const t = this.currentTime, n = [...this.markers].reverse().find((s) => s.time < t - 0.5);
|
|
1850
|
+
this.pause(), this.seek(n ? n.time : 0);
|
|
1851
1851
|
}
|
|
1852
1852
|
/** Jump to a marker by id, paused there. */
|
|
1853
1853
|
goToMarker(t) {
|
|
1854
|
-
const
|
|
1855
|
-
|
|
1854
|
+
const n = this.markers.find((s) => s.id === t);
|
|
1855
|
+
n && (this.pause(), this.seek(n.time));
|
|
1856
1856
|
}
|
|
1857
1857
|
language() {
|
|
1858
1858
|
return this.container.closest("[lang]")?.getAttribute("lang") || (typeof document < "u" ? document.documentElement.lang : "") || "en";
|
|
@@ -1861,8 +1861,8 @@ class wt {
|
|
|
1861
1861
|
if (!this.timeline) return;
|
|
1862
1862
|
const t = this.options.initialFrame ?? "start";
|
|
1863
1863
|
if (t === "none") return;
|
|
1864
|
-
const
|
|
1865
|
-
this.timeline.seek(Math.max(0, Math.min(this.timeline.duration,
|
|
1864
|
+
const n = t === "end" ? this.timeline.duration : t === "start" ? 0 : t;
|
|
1865
|
+
this.timeline.seek(Math.max(0, Math.min(this.timeline.duration, n))), this.applyState();
|
|
1866
1866
|
}
|
|
1867
1867
|
watchReducedMotion() {
|
|
1868
1868
|
this.options.respectReducedMotion === !1 || typeof window > "u" || typeof window.matchMedia != "function" || (this.reducedQuery ??= window.matchMedia("(prefers-reduced-motion: reduce)"), this.reducedQuery.addEventListener?.("change", this.onReducedChange), this.reducedQuery.matches && this.applyReducedMotion());
|
|
@@ -1874,8 +1874,8 @@ class wt {
|
|
|
1874
1874
|
watchVisibility() {
|
|
1875
1875
|
if (!(!this.options.playWhenVisible || typeof window > "u")) {
|
|
1876
1876
|
if (typeof IntersectionObserver == "function") {
|
|
1877
|
-
this.visibilityObserver?.disconnect(), this.visibilityObserver = new IntersectionObserver((
|
|
1878
|
-
for (const
|
|
1877
|
+
this.visibilityObserver?.disconnect(), this.visibilityObserver = new IntersectionObserver((n) => {
|
|
1878
|
+
for (const s of n) this.onScreen = s.isIntersecting;
|
|
1879
1879
|
this.updateVisibility();
|
|
1880
1880
|
}), this.visibilityObserver.observe(this.container);
|
|
1881
1881
|
const t = this.container.getBoundingClientRect?.();
|
|
@@ -1891,8 +1891,8 @@ class wt {
|
|
|
1891
1891
|
/** Report the current marker if it changed since the last frame. */
|
|
1892
1892
|
announceMarker() {
|
|
1893
1893
|
if (!this.options.onMarker) return;
|
|
1894
|
-
const t = this.currentMarker,
|
|
1895
|
-
|
|
1894
|
+
const t = this.currentMarker, n = t?.id;
|
|
1895
|
+
n !== this.lastMarkerId && (this.lastMarkerId = n, this.options.onMarker(t));
|
|
1896
1896
|
}
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Find embedded media elements (`[data-tinyfly-media]`) in the container and
|
|
@@ -1900,46 +1900,46 @@ class wt {
|
|
|
1900
1900
|
* scene elements; the `data-tinyfly-start` attribute sets when each begins.
|
|
1901
1901
|
*/
|
|
1902
1902
|
scanMedia() {
|
|
1903
|
-
this.mediaTargets = [], this.container.querySelectorAll("[data-tinyfly-media]").forEach((
|
|
1904
|
-
const
|
|
1905
|
-
r !== null && (
|
|
1903
|
+
this.mediaTargets = [], this.container.querySelectorAll("[data-tinyfly-media]").forEach((n) => {
|
|
1904
|
+
const s = n, i = Number(s.getAttribute("data-tinyfly-start") ?? "0") || 0, r = s.getAttribute("data-volume");
|
|
1905
|
+
r !== null && (s.volume = Math.max(0, Math.min(1, Number(r) || 0))), this.mediaTargets.push({ el: s, startTime: i, sync: new Vt(s) });
|
|
1906
1906
|
});
|
|
1907
1907
|
}
|
|
1908
1908
|
/** Sync all discovered media targets to a timeline time. */
|
|
1909
|
-
syncAllMedia(t,
|
|
1910
|
-
for (const
|
|
1911
|
-
|
|
1909
|
+
syncAllMedia(t, n) {
|
|
1910
|
+
for (const s of this.mediaTargets)
|
|
1911
|
+
Dn(s.sync, s.el, t, n, s.startTime);
|
|
1912
1912
|
}
|
|
1913
1913
|
/**
|
|
1914
1914
|
* Load animation from inline JSON string.
|
|
1915
1915
|
*/
|
|
1916
1916
|
loadFromString(t) {
|
|
1917
|
-
const
|
|
1918
|
-
this.load(
|
|
1917
|
+
const n = JSON.parse(t);
|
|
1918
|
+
this.load(n);
|
|
1919
1919
|
}
|
|
1920
1920
|
/**
|
|
1921
1921
|
* Register a target element by name.
|
|
1922
1922
|
*/
|
|
1923
|
-
registerTarget(t,
|
|
1924
|
-
if (typeof
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1923
|
+
registerTarget(t, n) {
|
|
1924
|
+
if (typeof n == "string") {
|
|
1925
|
+
const s = this.container.querySelector(n);
|
|
1926
|
+
s && (this.rememberAuthored(s), this.targets[t] = s, this.adapter.registerTarget(t, s));
|
|
1927
1927
|
} else
|
|
1928
|
-
this.rememberAuthored(
|
|
1928
|
+
this.rememberAuthored(n), this.targets[t] = n, this.adapter.registerTarget(t, n);
|
|
1929
1929
|
}
|
|
1930
1930
|
/**
|
|
1931
1931
|
* Auto-register targets using data-tinyfly attribute.
|
|
1932
1932
|
*/
|
|
1933
1933
|
autoRegisterTargets() {
|
|
1934
|
-
this.container.querySelectorAll("[data-tinyfly]").forEach((
|
|
1935
|
-
const
|
|
1936
|
-
if (
|
|
1937
|
-
const
|
|
1938
|
-
|
|
1939
|
-
}), this.timeline && new Set(this.timeline.tracks.map((
|
|
1940
|
-
if (!this.targets[
|
|
1941
|
-
const
|
|
1942
|
-
|
|
1934
|
+
this.container.querySelectorAll("[data-tinyfly]").forEach((n) => {
|
|
1935
|
+
const s = n.closest("[data-tinyfly-symbol]");
|
|
1936
|
+
if (s && s !== n) return;
|
|
1937
|
+
const i = n.getAttribute("data-tinyfly");
|
|
1938
|
+
i && this.registerTarget(i, n);
|
|
1939
|
+
}), this.timeline && new Set(this.timeline.tracks.map((s) => s.target)).forEach((s) => {
|
|
1940
|
+
if (!this.targets[s]) {
|
|
1941
|
+
const i = this.container.querySelector(`[data-tinyfly="${s}"]`) || this.container.querySelector(`.${s}`) || this.container.querySelector(`#${s}`);
|
|
1942
|
+
i && this.registerTarget(s, i);
|
|
1943
1943
|
}
|
|
1944
1944
|
});
|
|
1945
1945
|
}
|
|
@@ -1952,14 +1952,14 @@ class wt {
|
|
|
1952
1952
|
this.symbolInstances = [];
|
|
1953
1953
|
const t = this.options.symbols;
|
|
1954
1954
|
if (!t || t.length === 0) return;
|
|
1955
|
-
const
|
|
1956
|
-
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((
|
|
1957
|
-
const
|
|
1958
|
-
if (!
|
|
1959
|
-
const r =
|
|
1955
|
+
const n = new Map(t.map((s) => [s.id, s]));
|
|
1956
|
+
this.container.querySelectorAll("[data-tinyfly-symbol]").forEach((s) => {
|
|
1957
|
+
const i = s.getAttribute("data-tinyfly-symbol");
|
|
1958
|
+
if (!i) return;
|
|
1959
|
+
const r = n.get(i);
|
|
1960
1960
|
if (!r || !r.timeline.tracks?.length) return;
|
|
1961
|
-
const a = new
|
|
1962
|
-
|
|
1961
|
+
const a = new vt();
|
|
1962
|
+
s.querySelectorAll("[data-tinyfly]").forEach((o) => {
|
|
1963
1963
|
const c = o.getAttribute("data-tinyfly");
|
|
1964
1964
|
c && a.registerTarget(c, o);
|
|
1965
1965
|
}), this.symbolInstances.push({ adapter: a, timeline: rt(r.timeline) });
|
|
@@ -1971,8 +1971,8 @@ class wt {
|
|
|
1971
1971
|
* the media follows its play/pause/seek and rate, with drift corrected as it
|
|
1972
1972
|
* plays. Pass `{ offset }` to start the media at a timeline offset.
|
|
1973
1973
|
*/
|
|
1974
|
-
attachMedia(t,
|
|
1975
|
-
this.mediaSync = new Vt(t,
|
|
1974
|
+
attachMedia(t, n) {
|
|
1975
|
+
this.mediaSync = new Vt(t, n), this.timeline && (this.mediaSync.setRate(this.timeline.speed), this.mediaSync.update(this.timeline.currentTime, this.isPlaying));
|
|
1976
1976
|
}
|
|
1977
1977
|
/** Detach and pause the currently synced media, if any. */
|
|
1978
1978
|
detachMedia() {
|
|
@@ -2051,12 +2051,12 @@ class wt {
|
|
|
2051
2051
|
startAnimationLoop() {
|
|
2052
2052
|
if (this.animationFrameId !== void 0) return;
|
|
2053
2053
|
this.lastTime = performance.now();
|
|
2054
|
-
const t = (
|
|
2054
|
+
const t = (n) => {
|
|
2055
2055
|
if (this.isDestroyed || !this.timeline) return;
|
|
2056
|
-
const
|
|
2057
|
-
this.lastTime =
|
|
2058
|
-
const
|
|
2059
|
-
this.timeline.tick(
|
|
2056
|
+
const s = n - (this.lastTime ?? n);
|
|
2057
|
+
this.lastTime = n;
|
|
2058
|
+
const i = this.playhead;
|
|
2059
|
+
this.timeline.tick(s), this.stopAtMarker(i), this.applyState();
|
|
2060
2060
|
const r = this.timeline.playbackState === "playing";
|
|
2061
2061
|
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
2062
|
};
|
|
@@ -2067,21 +2067,21 @@ class wt {
|
|
|
2067
2067
|
* stepping, or any marker with `pause` — put the playhead exactly there and pause.
|
|
2068
2068
|
*/
|
|
2069
2069
|
stopAtMarker(t) {
|
|
2070
|
-
const
|
|
2071
|
-
this.playhead =
|
|
2072
|
-
const
|
|
2073
|
-
if (
|
|
2074
|
-
const { crossings: r } =
|
|
2075
|
-
|
|
2070
|
+
const n = this.timeline, s = { time: n.currentTime, iteration: n.loopIteration, direction: n.direction };
|
|
2071
|
+
this.playhead = s;
|
|
2072
|
+
const i = this.markers;
|
|
2073
|
+
if (i.length === 0) return;
|
|
2074
|
+
const { crossings: r } = kn(
|
|
2075
|
+
i.map((a) => a.time),
|
|
2076
2076
|
t,
|
|
2077
|
-
|
|
2078
|
-
{ duration:
|
|
2077
|
+
s,
|
|
2078
|
+
{ duration: n.duration, alternate: n.config.alternate === !0, holding: n.repeatDelayRemaining > 0 }
|
|
2079
2079
|
);
|
|
2080
2080
|
for (const a of r) {
|
|
2081
2081
|
if (a.kind !== "event") continue;
|
|
2082
|
-
const o =
|
|
2082
|
+
const o = i[a.index];
|
|
2083
2083
|
if (this.stepping || o.pause) {
|
|
2084
|
-
this.stepping = !1,
|
|
2084
|
+
this.stepping = !1, n.pause(), n.seek(o.time), this.playhead = { time: o.time, iteration: n.loopIteration, direction: n.direction };
|
|
2085
2085
|
return;
|
|
2086
2086
|
}
|
|
2087
2087
|
}
|
|
@@ -2093,20 +2093,20 @@ class wt {
|
|
|
2093
2093
|
if (!this.timeline) return;
|
|
2094
2094
|
const t = this.timeline.currentTime;
|
|
2095
2095
|
this.adapter.applyState(this.timeline.getStateAtTime(t)), this.announceMarker(), this.notify();
|
|
2096
|
-
for (const
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2096
|
+
for (const n of this.symbolInstances) {
|
|
2097
|
+
const s = n.timeline.duration;
|
|
2098
|
+
n.adapter.applyState(n.timeline.getStateAtTime(s > 0 ? t % s : t));
|
|
2099
2099
|
}
|
|
2100
2100
|
}
|
|
2101
2101
|
}
|
|
2102
|
-
async function
|
|
2103
|
-
const
|
|
2104
|
-
return await
|
|
2102
|
+
async function as(e, t, n = {}) {
|
|
2103
|
+
const s = new Mt(e, { ...n, autoplay: !0 });
|
|
2104
|
+
return await s.load(t), s;
|
|
2105
2105
|
}
|
|
2106
|
-
function
|
|
2107
|
-
return new
|
|
2106
|
+
function os(e, t = {}) {
|
|
2107
|
+
return new Mt(e, t);
|
|
2108
2108
|
}
|
|
2109
|
-
const
|
|
2109
|
+
const Ln = {
|
|
2110
2110
|
play: "Play",
|
|
2111
2111
|
pause: "Pause",
|
|
2112
2112
|
prev: "Previous step",
|
|
@@ -2118,8 +2118,10 @@ const Ds = {
|
|
|
2118
2118
|
step: "Step",
|
|
2119
2119
|
of: "of",
|
|
2120
2120
|
stepFormat: "{index} / {total}",
|
|
2121
|
-
scenario: "Scenario"
|
|
2122
|
-
|
|
2121
|
+
scenario: "Scenario",
|
|
2122
|
+
fullscreen: "Full screen",
|
|
2123
|
+
exitFullscreen: "Exit full screen"
|
|
2124
|
+
}, Wt = "tinyfly-controls-style", On = `
|
|
2123
2125
|
.tf-ctl { --tf-ctl-fg: #1d1d1f; --tf-ctl-bg: #f4f2ee; --tf-ctl-accent: #c2410c; --tf-ctl-radius: 8px;
|
|
2124
2126
|
font: 14px/1.4 var(--tf-ctl-font, system-ui, sans-serif); color: var(--tf-ctl-fg); margin-top: 8px; }
|
|
2125
2127
|
.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); }
|
|
@@ -2150,124 +2152,155 @@ const Ds = {
|
|
|
2150
2152
|
.tf-ctl-choice-slider input { flex: 1 1 140px; accent-color: var(--tf-ctl-accent); }
|
|
2151
2153
|
.tf-ctl-choice-slider input:focus-visible { outline: 2px solid var(--tf-ctl-accent); outline-offset: 2px; }
|
|
2152
2154
|
.tf-ctl-choice-slider output { font-variant-numeric: tabular-nums; min-width: 4em; }
|
|
2155
|
+
.tf-ctl-fullscreen { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; }
|
|
2156
|
+
.tf-ctl-fullscreen svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
|
|
2157
|
+
/* Full screen, by either route. The figure becomes a column: the drawing takes the room
|
|
2158
|
+
that's left after the controls and captions. !important because the host page's own
|
|
2159
|
+
figure rules (a max-width, a min-width that makes a diagram scroll on phones) would
|
|
2160
|
+
otherwise keep the drawing at its in-page size. */
|
|
2161
|
+
.tf-fullscreen { box-sizing: border-box !important; display: flex !important; flex-direction: column; width: 100% !important; max-width: none !important; height: 100vh; height: 100dvh; margin: 0 !important; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important; overflow: auto !important; background: var(--tf-fullscreen-bg, #fff); }
|
|
2162
|
+
.tf-fullscreen > * { flex: none; }
|
|
2163
|
+
.tf-fullscreen > svg, .tf-fullscreen > canvas { flex: 1 1 0; min-height: 0; width: 100% !important; min-width: 0 !important; height: 100% !important; }
|
|
2164
|
+
.tf-fullscreen-overlay { position: fixed !important; inset: 0; z-index: 2147483000; }
|
|
2165
|
+
/* A short landscape screen (a phone on its side): stacking the controls under the drawing
|
|
2166
|
+
leaves the drawing a thin strip, so put them in a column beside it instead. */
|
|
2167
|
+
@media (orientation: landscape) and (max-height: 520px) {
|
|
2168
|
+
.tf-fullscreen { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(200px, 34%); grid-auto-rows: min-content; column-gap: 12px; align-content: start; }
|
|
2169
|
+
.tf-fullscreen > svg, .tf-fullscreen > canvas { grid-column: 1; grid-row: 1 / span 12; height: calc(100vh - 24px) !important; height: calc(100dvh - 24px) !important; }
|
|
2170
|
+
.tf-fullscreen > :not(svg):not(canvas) { grid-column: 2; }
|
|
2171
|
+
}
|
|
2153
2172
|
`;
|
|
2154
|
-
let
|
|
2155
|
-
function
|
|
2173
|
+
let Nn = 0;
|
|
2174
|
+
function Fn(e) {
|
|
2156
2175
|
if (e.getElementById(Wt)) return;
|
|
2157
2176
|
const t = e.createElement("style");
|
|
2158
|
-
t.id = Wt, t.textContent =
|
|
2177
|
+
t.id = Wt, t.textContent = On, e.head.appendChild(t);
|
|
2159
2178
|
}
|
|
2160
|
-
function
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2179
|
+
function Xn(e, t, n = {}) {
|
|
2180
|
+
const s = t.ownerDocument;
|
|
2181
|
+
Fn(s);
|
|
2182
|
+
const i = { ...Ln, ...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 = s.createElement("div");
|
|
2164
2183
|
c.className = "tf-ctl";
|
|
2165
|
-
const l =
|
|
2184
|
+
const l = s.createElement("div");
|
|
2166
2185
|
l.className = "tf-ctl-bar", l.setAttribute("role", "group");
|
|
2167
|
-
const u = (
|
|
2168
|
-
const $ =
|
|
2169
|
-
return $.type = "button", $.className = `tf-ctl-btn ${O}`.trim(), $.setAttribute("aria-label",
|
|
2170
|
-
}, h = u(
|
|
2186
|
+
const u = (w, E, N, O = "") => {
|
|
2187
|
+
const $ = s.createElement("button");
|
|
2188
|
+
return $.type = "button", $.className = `tf-ctl-btn ${O}`.trim(), $.setAttribute("aria-label", w), $.title = w, $.textContent = E, $.addEventListener("click", N), $;
|
|
2189
|
+
}, h = u(i.restart, "⟲", () => {
|
|
2171
2190
|
e.pause(), e.seek(0);
|
|
2172
|
-
}), d = u(
|
|
2191
|
+
}), d = u(i.prev, "◀", () => e.prev()), f = u(i.play, "▶", () => e.isPlaying ? e.pause() : p(), "tf-ctl-primary"), g = u(i.next, "▶|", () => e.next()), p = () => {
|
|
2173
2192
|
e.currentTime >= e.duration - 0.5 && e.seek(0), e.play();
|
|
2174
|
-
}, m =
|
|
2175
|
-
m.type = "range", m.className = "tf-ctl-scrub", m.min = "0", m.max = "1000", m.step = "1", m.setAttribute("aria-label",
|
|
2193
|
+
}, m = s.createElement("input");
|
|
2194
|
+
m.type = "range", m.className = "tf-ctl-scrub", m.min = "0", m.max = "1000", m.step = "1", m.setAttribute("aria-label", i.scrub), m.addEventListener("input", () => {
|
|
2176
2195
|
e.pause(), e.seek(Number(m.value) / 1e3 * e.duration);
|
|
2177
2196
|
});
|
|
2178
|
-
const b =
|
|
2197
|
+
const b = s.createElement("span");
|
|
2179
2198
|
b.className = "tf-ctl-step";
|
|
2180
|
-
const
|
|
2181
|
-
|
|
2182
|
-
for (const
|
|
2183
|
-
const
|
|
2184
|
-
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
const
|
|
2188
|
-
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
const y =
|
|
2192
|
-
|
|
2193
|
-
const S =
|
|
2194
|
-
S
|
|
2195
|
-
const
|
|
2196
|
-
|
|
2197
|
-
const
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
const
|
|
2201
|
-
|
|
2202
|
-
const
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2199
|
+
const v = s.createElement("select");
|
|
2200
|
+
v.className = "tf-ctl-speed", v.setAttribute("aria-label", i.speed);
|
|
2201
|
+
for (const w of r) {
|
|
2202
|
+
const E = s.createElement("option");
|
|
2203
|
+
E.value = String(w), E.textContent = `${w}×`, w === 1 && (E.selected = !0), v.appendChild(E);
|
|
2204
|
+
}
|
|
2205
|
+
v.addEventListener("change", () => e.setSpeed(Number(v.value))), l.append(h, d, f, g, m, b), r.length > 0 && l.append(v), c.append(l);
|
|
2206
|
+
const k = n.fullscreen ? Wn(t, s, i) : void 0;
|
|
2207
|
+
k && l.append(k.button);
|
|
2208
|
+
const M = s.createElement("p");
|
|
2209
|
+
M.className = "tf-ctl-caption", M.setAttribute("aria-live", "polite"), n.captions !== !1 && c.append(M);
|
|
2210
|
+
const y = s.createElement("div");
|
|
2211
|
+
y.className = "tf-ctl-question", y.hidden = !0;
|
|
2212
|
+
const S = s.createElement("span"), x = u(i.reveal, i.reveal, () => e.play(), "tf-ctl-primary");
|
|
2213
|
+
y.append(S, x), c.append(y);
|
|
2214
|
+
const P = Yn(e, s, i.scenario, n.scenarioControl ?? "buttons");
|
|
2215
|
+
P && c.append(P.element);
|
|
2216
|
+
const Y = n.mount;
|
|
2217
|
+
Y ? Y.appendChild(c) : t.insertAdjacentElement("afterend", c);
|
|
2218
|
+
const T = () => {
|
|
2219
|
+
const w = e.isPlaying;
|
|
2220
|
+
f.textContent = w ? "❚❚" : "▶", f.setAttribute("aria-label", w ? i.pause : i.play), f.title = w ? i.pause : i.play;
|
|
2221
|
+
const E = e.duration;
|
|
2222
|
+
s.activeElement !== m && (m.value = String(E > 0 ? Math.round(e.currentTime / E * 1e3) : 0));
|
|
2223
|
+
const N = e.markers;
|
|
2224
|
+
if (d.hidden = g.hidden = b.hidden = N.length === 0, N.length > 0) {
|
|
2225
|
+
const O = e.currentMarker, $ = O ? N.indexOf(O) + 1 : 0;
|
|
2226
|
+
b.textContent = i.stepFormat.replace("{index}", String($)).replace("{total}", String(N.length)), b.setAttribute("aria-label", `${i.step} ${$} ${i.of} ${N.length}`), d.disabled = e.currentTime <= 0.5, g.disabled = e.currentTime >= E - 0.5;
|
|
2227
|
+
const A = e.caption() ?? "";
|
|
2228
|
+
M.textContent !== A && (M.textContent = A), M.hidden = !o();
|
|
2229
|
+
const I = !w && O?.question !== void 0 && Math.abs(e.currentTime - O.time) < 1;
|
|
2230
|
+
y.hidden = !I, I && S.textContent !== O.question && (S.textContent = O.question);
|
|
2210
2231
|
} else
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
},
|
|
2214
|
-
|
|
2215
|
-
const
|
|
2216
|
-
!
|
|
2217
|
-
const C = /* @__PURE__ */ new WeakSet(),
|
|
2218
|
-
if (C.has(
|
|
2219
|
-
const
|
|
2220
|
-
if (!(
|
|
2221
|
-
switch (
|
|
2232
|
+
y.hidden = !0, M.hidden = !0;
|
|
2233
|
+
P?.update();
|
|
2234
|
+
}, R = e.subscribe(T);
|
|
2235
|
+
T();
|
|
2236
|
+
const _ = n.keyboardScope ?? t;
|
|
2237
|
+
!_.hasAttribute("tabindex") && _.tabIndex < 0 && (_.tabIndex = 0);
|
|
2238
|
+
const C = /* @__PURE__ */ new WeakSet(), L = (w) => {
|
|
2239
|
+
if (C.has(w) || (C.add(w), w.defaultPrevented || w.altKey || w.ctrlKey || w.metaKey)) return;
|
|
2240
|
+
const E = w.target;
|
|
2241
|
+
if (!(E.tagName === "INPUT" || E.tagName === "SELECT") && !(w.key === " " && E.tagName === "BUTTON"))
|
|
2242
|
+
switch (w.key) {
|
|
2222
2243
|
case " ":
|
|
2223
|
-
|
|
2244
|
+
w.preventDefault(), e.isPlaying ? e.pause() : p();
|
|
2224
2245
|
break;
|
|
2225
2246
|
case "ArrowRight":
|
|
2226
2247
|
if (!a()) return;
|
|
2227
|
-
|
|
2248
|
+
w.preventDefault(), e.next();
|
|
2228
2249
|
break;
|
|
2229
2250
|
case "ArrowLeft":
|
|
2230
2251
|
if (!a()) return;
|
|
2231
|
-
|
|
2252
|
+
w.preventDefault(), e.prev();
|
|
2232
2253
|
break;
|
|
2233
2254
|
case "Home":
|
|
2234
|
-
|
|
2255
|
+
w.preventDefault(), e.pause(), e.seek(0);
|
|
2256
|
+
break;
|
|
2257
|
+
case "f":
|
|
2258
|
+
case "F":
|
|
2259
|
+
if (!k) return;
|
|
2260
|
+
w.preventDefault(), k.active ? k.exit() : k.enter();
|
|
2235
2261
|
break;
|
|
2236
2262
|
}
|
|
2237
2263
|
};
|
|
2238
|
-
return
|
|
2264
|
+
return _.addEventListener("keydown", L), c.addEventListener("keydown", L), {
|
|
2239
2265
|
element: c,
|
|
2266
|
+
fullscreen: k && {
|
|
2267
|
+
get active() {
|
|
2268
|
+
return k.active;
|
|
2269
|
+
},
|
|
2270
|
+
enter: k.enter,
|
|
2271
|
+
exit: k.exit
|
|
2272
|
+
},
|
|
2240
2273
|
destroy() {
|
|
2241
|
-
|
|
2274
|
+
k?.destroy(), R(), _.removeEventListener("keydown", L), c.removeEventListener("keydown", L), c.remove();
|
|
2242
2275
|
}
|
|
2243
2276
|
};
|
|
2244
2277
|
}
|
|
2245
|
-
function
|
|
2246
|
-
const
|
|
2247
|
-
if (
|
|
2248
|
-
if (
|
|
2278
|
+
function Yn(e, t, n, s) {
|
|
2279
|
+
const i = e.scenarios;
|
|
2280
|
+
if (i.length < 2) return;
|
|
2281
|
+
if (s === "slider") {
|
|
2249
2282
|
const u = t.createElement("div");
|
|
2250
2283
|
u.className = "tf-ctl-choice-slider";
|
|
2251
2284
|
const h = t.createElement("span");
|
|
2252
|
-
h.textContent =
|
|
2285
|
+
h.textContent = n, h.setAttribute("aria-hidden", "true");
|
|
2253
2286
|
const d = t.createElement("input");
|
|
2254
|
-
d.type = "range", d.min = "0", d.max = String(
|
|
2287
|
+
d.type = "range", d.min = "0", d.max = String(i.length - 1), d.step = "1", d.setAttribute("aria-label", n);
|
|
2255
2288
|
const f = t.createElement("output");
|
|
2256
2289
|
return f.setAttribute("aria-hidden", "true"), d.addEventListener("input", () => {
|
|
2257
|
-
const p =
|
|
2290
|
+
const p = i[Number(d.value)];
|
|
2258
2291
|
p && e.setScenario(p.id);
|
|
2259
2292
|
}), u.append(h, d, f), { element: u, update: () => {
|
|
2260
|
-
const p = Math.max(0,
|
|
2293
|
+
const p = Math.max(0, i.findIndex((b) => b.id === e.scenario));
|
|
2261
2294
|
t.activeElement !== d && (d.value = String(p));
|
|
2262
|
-
const m =
|
|
2295
|
+
const m = i[p].label;
|
|
2263
2296
|
f.textContent !== m && (f.textContent = m), d.setAttribute("aria-valuetext", m);
|
|
2264
2297
|
} };
|
|
2265
2298
|
}
|
|
2266
2299
|
const r = t.createElement("fieldset");
|
|
2267
2300
|
r.className = "tf-ctl-choices";
|
|
2268
2301
|
const a = t.createElement("legend");
|
|
2269
|
-
a.textContent =
|
|
2270
|
-
const o = `tf-ctl-scenario-${++
|
|
2302
|
+
a.textContent = n, r.append(a);
|
|
2303
|
+
const o = `tf-ctl-scenario-${++Nn}`, c = i.map((u) => {
|
|
2271
2304
|
const h = t.createElement("label");
|
|
2272
2305
|
h.className = "tf-ctl-choice";
|
|
2273
2306
|
const d = t.createElement("input");
|
|
@@ -2284,68 +2317,121 @@ function Xs(e, t, s, i) {
|
|
|
2284
2317
|
}
|
|
2285
2318
|
} };
|
|
2286
2319
|
}
|
|
2287
|
-
const
|
|
2320
|
+
const qn = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/></svg>', Vn = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/></svg>';
|
|
2321
|
+
function Wn(e, t, n) {
|
|
2322
|
+
const s = t, i = e, r = t.createElement("button");
|
|
2323
|
+
r.type = "button", r.className = "tf-ctl-btn tf-ctl-fullscreen";
|
|
2324
|
+
let a, o = "";
|
|
2325
|
+
const c = () => {
|
|
2326
|
+
const p = a !== void 0;
|
|
2327
|
+
r.innerHTML = p ? Vn : qn;
|
|
2328
|
+
const m = p ? n.exitFullscreen : n.fullscreen;
|
|
2329
|
+
r.setAttribute("aria-label", m), r.title = m, r.setAttribute("aria-pressed", String(p)), e.classList.toggle("tf-fullscreen", p), e.classList.toggle("tf-fullscreen-overlay", a === "overlay");
|
|
2330
|
+
}, l = () => s.fullscreenElement ?? s.webkitFullscreenElement ?? null, u = () => {
|
|
2331
|
+
l() === e ? a = "native" : a === "native" && (a = void 0), c();
|
|
2332
|
+
}, h = (p) => {
|
|
2333
|
+
p.key === "Escape" && g();
|
|
2334
|
+
}, d = () => {
|
|
2335
|
+
a = "overlay", o = t.documentElement.style.overflow, t.documentElement.style.overflow = "hidden", t.addEventListener("keydown", h), c();
|
|
2336
|
+
};
|
|
2337
|
+
async function f() {
|
|
2338
|
+
if (a) return;
|
|
2339
|
+
const p = i.requestFullscreen?.bind(i) ?? i.webkitRequestFullscreen?.bind(i), m = s.fullscreenEnabled ?? s.webkitFullscreenEnabled ?? !1;
|
|
2340
|
+
if (p && m)
|
|
2341
|
+
try {
|
|
2342
|
+
if (await p(), l() === e) {
|
|
2343
|
+
a = "native", c();
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
} catch {
|
|
2347
|
+
}
|
|
2348
|
+
d();
|
|
2349
|
+
}
|
|
2350
|
+
async function g() {
|
|
2351
|
+
if (a === "overlay")
|
|
2352
|
+
t.removeEventListener("keydown", h), t.documentElement.style.overflow = o, a = void 0, c();
|
|
2353
|
+
else if (a === "native") {
|
|
2354
|
+
a = void 0, c();
|
|
2355
|
+
const p = s.exitFullscreen?.bind(s) ?? s.webkitExitFullscreen?.bind(s);
|
|
2356
|
+
l() === e && p && await p();
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
return r.addEventListener("click", () => {
|
|
2360
|
+
a ? g() : f();
|
|
2361
|
+
}), t.addEventListener("fullscreenchange", u), t.addEventListener("webkitfullscreenchange", u), c(), {
|
|
2362
|
+
button: r,
|
|
2363
|
+
get active() {
|
|
2364
|
+
return a !== void 0;
|
|
2365
|
+
},
|
|
2366
|
+
enter: f,
|
|
2367
|
+
exit: g,
|
|
2368
|
+
destroy() {
|
|
2369
|
+
g(), t.removeEventListener("fullscreenchange", u), t.removeEventListener("webkitfullscreenchange", u), r.remove();
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
const Bt = "tinyfly-choices-style", Bn = `
|
|
2288
2374
|
[data-tinyfly-choose] { cursor: pointer; }
|
|
2289
2375
|
[data-tinyfly-choose]:focus-visible { outline: 2px solid var(--tf-ctl-accent, #c2410c); outline-offset: 2px; }
|
|
2290
2376
|
`;
|
|
2291
|
-
function
|
|
2377
|
+
function Un(e) {
|
|
2292
2378
|
if (e.getElementById(Bt)) return;
|
|
2293
2379
|
const t = e.createElement("style");
|
|
2294
|
-
t.id = Bt, t.textContent =
|
|
2380
|
+
t.id = Bt, t.textContent = Bn, e.head.appendChild(t);
|
|
2295
2381
|
}
|
|
2296
|
-
function
|
|
2297
|
-
const
|
|
2298
|
-
if (
|
|
2382
|
+
function jn(e, t) {
|
|
2383
|
+
const n = Array.from(t.querySelectorAll("[data-tinyfly-choose]"));
|
|
2384
|
+
if (n.length === 0) return () => {
|
|
2299
2385
|
};
|
|
2300
|
-
|
|
2301
|
-
const
|
|
2302
|
-
for (const o of
|
|
2386
|
+
Un(t.ownerDocument);
|
|
2387
|
+
const s = [], i = [];
|
|
2388
|
+
for (const o of n) {
|
|
2303
2389
|
const c = o.getAttribute("data-tinyfly-choose") ?? "", l = [], u = (g, p) => {
|
|
2304
2390
|
o.hasAttribute(g) || (o.setAttribute(g, p), l.push(g));
|
|
2305
2391
|
};
|
|
2306
2392
|
u("role", "button"), u("tabindex", "0");
|
|
2307
2393
|
const h = e.scenarios.find((g) => g.id === c)?.label;
|
|
2308
|
-
h !== void 0 && u("aria-label", h), o.setAttribute("aria-pressed", "false"), l.push("aria-pressed"),
|
|
2394
|
+
h !== void 0 && u("aria-label", h), o.setAttribute("aria-pressed", "false"), l.push("aria-pressed"), s.push({ element: o, attributes: l });
|
|
2309
2395
|
const d = () => e.setScenario(c), f = (g) => {
|
|
2310
2396
|
const p = g.key;
|
|
2311
2397
|
p !== "Enter" && p !== " " || (g.preventDefault(), d());
|
|
2312
2398
|
};
|
|
2313
|
-
o.addEventListener("click", d), o.addEventListener("keydown", f),
|
|
2399
|
+
o.addEventListener("click", d), o.addEventListener("keydown", f), i.push(() => {
|
|
2314
2400
|
o.removeEventListener("click", d), o.removeEventListener("keydown", f);
|
|
2315
2401
|
});
|
|
2316
2402
|
}
|
|
2317
2403
|
const r = () => {
|
|
2318
|
-
for (const { element: o } of
|
|
2404
|
+
for (const { element: o } of s)
|
|
2319
2405
|
o.setAttribute("aria-pressed", String(o.getAttribute("data-tinyfly-choose") === e.scenario));
|
|
2320
2406
|
}, a = e.subscribe(r);
|
|
2321
2407
|
return r(), () => {
|
|
2322
2408
|
a();
|
|
2323
|
-
for (const o of
|
|
2324
|
-
for (const { element: o, attributes: c } of
|
|
2409
|
+
for (const o of i) o();
|
|
2410
|
+
for (const { element: o, attributes: c } of s) for (const l of c) o.removeAttribute(l);
|
|
2325
2411
|
};
|
|
2326
2412
|
}
|
|
2327
|
-
const at = /* @__PURE__ */ new WeakMap(),
|
|
2328
|
-
let
|
|
2329
|
-
function K(e, t,
|
|
2413
|
+
const at = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap();
|
|
2414
|
+
let Hn = 0;
|
|
2415
|
+
function K(e, t, n) {
|
|
2330
2416
|
if (e)
|
|
2331
2417
|
try {
|
|
2332
2418
|
return JSON.parse(e);
|
|
2333
|
-
} catch (
|
|
2334
|
-
console.warn(`tinyfly: invalid ${t} JSON on`,
|
|
2419
|
+
} catch (s) {
|
|
2420
|
+
console.warn(`tinyfly: invalid ${t} JSON on`, n, s);
|
|
2335
2421
|
return;
|
|
2336
2422
|
}
|
|
2337
2423
|
}
|
|
2338
|
-
async function
|
|
2339
|
-
const
|
|
2340
|
-
if (
|
|
2341
|
-
const
|
|
2424
|
+
async function zn(e, t = {}) {
|
|
2425
|
+
const n = at.get(e);
|
|
2426
|
+
if (n) return n;
|
|
2427
|
+
const s = Array.from(e.querySelectorAll("script[data-tinyfly-timeline]")), i = s[0], r = e.getAttribute("data-src"), a = Qn(e.getAttribute("data-markers")), o = s.length > 1 || i?.hasAttribute("data-scenario") ? Gn(s, a, e) : void 0;
|
|
2342
2428
|
if (o && o.length === 0) return;
|
|
2343
|
-
let c =
|
|
2429
|
+
let c = i && !o ? K(i.textContent, "timeline", e) : void 0;
|
|
2344
2430
|
if (!c && r && a) {
|
|
2345
2431
|
const f = await fetch(r);
|
|
2346
2432
|
f.ok && (c = await f.json());
|
|
2347
2433
|
}
|
|
2348
|
-
if (c && a && (c =
|
|
2434
|
+
if (c && a && (c = ie(c, a)), !c && !r && !o) {
|
|
2349
2435
|
console.warn('tinyfly: embed has no timeline (a <script type="application/json" data-tinyfly-timeline> or data-src)', e);
|
|
2350
2436
|
return;
|
|
2351
2437
|
}
|
|
@@ -2355,17 +2441,18 @@ async function Bs(e, t = {}) {
|
|
|
2355
2441
|
...l && { captions: l },
|
|
2356
2442
|
...K(e.getAttribute("data-options"), "data-options", e)
|
|
2357
2443
|
};
|
|
2358
|
-
|
|
2359
|
-
const h = new
|
|
2444
|
+
Kn(e);
|
|
2445
|
+
const h = new Mt(e, u), d = { element: e, player: h };
|
|
2360
2446
|
if (at.set(e, d), e.setAttribute("data-tinyfly-mounted", ""), o) {
|
|
2361
2447
|
const f = e.getAttribute("data-scenario") ?? void 0;
|
|
2362
|
-
await h.loadScenarios(o, { initial: o.some((g) => g.id === f) ? f : void 0 }),
|
|
2448
|
+
await h.loadScenarios(o, { initial: o.some((g) => g.id === f) ? f : void 0 }), kt.set(e, jn(h, e));
|
|
2363
2449
|
} else
|
|
2364
2450
|
await h.load(c ?? r);
|
|
2365
2451
|
if (e.getAttribute("data-controls") !== "false") {
|
|
2366
2452
|
const f = K(e.getAttribute("data-labels"), "data-labels", e), g = e.querySelector("figcaption"), p = e.getAttribute("data-scenario-legend"), m = e.getAttribute("data-scenario-control");
|
|
2367
|
-
d.controls =
|
|
2453
|
+
d.controls = Xn(h, e, {
|
|
2368
2454
|
...t.controls,
|
|
2455
|
+
...e.getAttribute("data-fullscreen") === "true" ? { fullscreen: !0 } : {},
|
|
2369
2456
|
...m === "slider" || m === "buttons" ? { scenarioControl: m } : {},
|
|
2370
2457
|
labels: { ...t.controls?.labels, ...f, ...p ? { scenario: p } : {} },
|
|
2371
2458
|
// Inside the figure, before its figcaption, so the caption stays last.
|
|
@@ -2374,150 +2461,150 @@ async function Bs(e, t = {}) {
|
|
|
2374
2461
|
}
|
|
2375
2462
|
return d;
|
|
2376
2463
|
}
|
|
2377
|
-
function
|
|
2378
|
-
const
|
|
2379
|
-
return e.forEach((
|
|
2380
|
-
const a = K(
|
|
2464
|
+
function Gn(e, t, n) {
|
|
2465
|
+
const s = [];
|
|
2466
|
+
return e.forEach((i, r) => {
|
|
2467
|
+
const a = K(i.textContent, "timeline", n);
|
|
2381
2468
|
if (!a) return;
|
|
2382
|
-
const o =
|
|
2383
|
-
if (
|
|
2384
|
-
console.warn(`tinyfly: scenario id "${o}" is used more than once; the later one is skipped`,
|
|
2469
|
+
const o = i.getAttribute("data-scenario") || `scenario-${r + 1}`;
|
|
2470
|
+
if (s.some((l) => l.id === o)) {
|
|
2471
|
+
console.warn(`tinyfly: scenario id "${o}" is used more than once; the later one is skipped`, n);
|
|
2385
2472
|
return;
|
|
2386
2473
|
}
|
|
2387
|
-
const c =
|
|
2388
|
-
|
|
2389
|
-
}),
|
|
2474
|
+
const c = i.getAttribute("data-scenario-label") ?? void 0;
|
|
2475
|
+
s.push({ id: o, label: c, timeline: t ? ie(a, t) : a });
|
|
2476
|
+
}), s;
|
|
2390
2477
|
}
|
|
2391
|
-
function
|
|
2392
|
-
return e.config.markers?.length ? e : { ...e, config: { ...e.config, markers: t.map((
|
|
2478
|
+
function ie(e, t) {
|
|
2479
|
+
return e.config.markers?.length ? e : { ...e, config: { ...e.config, markers: t.map((n, s) => ({ id: `step-${s + 1}`, time: n })) } };
|
|
2393
2480
|
}
|
|
2394
|
-
function
|
|
2481
|
+
function Qn(e) {
|
|
2395
2482
|
if (!e) return;
|
|
2396
|
-
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((
|
|
2483
|
+
const t = e.split(/[\s,]+/).filter(Boolean).map(Number).filter((n) => Number.isFinite(n) && n >= 0).sort((n, s) => n - s);
|
|
2397
2484
|
return t.length > 0 ? t : void 0;
|
|
2398
2485
|
}
|
|
2399
|
-
async function
|
|
2400
|
-
const
|
|
2401
|
-
return (await Promise.all(
|
|
2486
|
+
async function Zn(e = document, t = {}) {
|
|
2487
|
+
const n = Array.from(e.querySelectorAll("[data-tinyfly-embed]"));
|
|
2488
|
+
return (await Promise.all(n.map((i) => zn(i, t)))).filter((i) => i !== void 0);
|
|
2402
2489
|
}
|
|
2403
|
-
function
|
|
2490
|
+
function cs(e) {
|
|
2404
2491
|
const t = at.get(e);
|
|
2405
|
-
t && (
|
|
2492
|
+
t && (kt.get(e)?.(), kt.delete(e), t.controls?.destroy(), t.player.destroy(), at.delete(e), e.removeAttribute("data-tinyfly-mounted"));
|
|
2406
2493
|
}
|
|
2407
|
-
function
|
|
2494
|
+
function Kn(e) {
|
|
2408
2495
|
const t = e.querySelector("svg");
|
|
2409
2496
|
if (!t || t.hasAttribute("role") || t.hasAttribute("aria-hidden")) return;
|
|
2410
|
-
const
|
|
2411
|
-
t.setAttribute("role", "img"),
|
|
2497
|
+
const n = e.getAttribute("data-alt"), s = e.querySelector("figcaption");
|
|
2498
|
+
t.setAttribute("role", "img"), n ? t.setAttribute("aria-label", n) : s && (s.id ||= `tinyfly-caption-${++Hn}`, t.setAttribute("aria-labelledby", s.id));
|
|
2412
2499
|
}
|
|
2413
|
-
function
|
|
2500
|
+
function Jn() {
|
|
2414
2501
|
if (!(typeof document < "u" ? document.currentScript : null)?.hasAttribute("data-tinyfly-auto")) return;
|
|
2415
2502
|
const t = () => {
|
|
2416
|
-
|
|
2503
|
+
Zn();
|
|
2417
2504
|
};
|
|
2418
2505
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", t, { once: !0 }) : t();
|
|
2419
2506
|
}
|
|
2420
2507
|
function re(e) {
|
|
2421
2508
|
const t = /* @__PURE__ */ new Set();
|
|
2422
|
-
for (const
|
|
2509
|
+
for (const n of e.matchAll(/data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(n[2] ?? n[3]);
|
|
2423
2510
|
return [...t];
|
|
2424
2511
|
}
|
|
2425
|
-
function
|
|
2426
|
-
const
|
|
2512
|
+
function ts(e, t = {}) {
|
|
2513
|
+
const n = [], s = (l) => n.push({ level: "error", message: l }), i = (l) => n.push({ level: "warning", message: l });
|
|
2427
2514
|
if ((e.formatVersion ?? 1) > J)
|
|
2428
|
-
return
|
|
2515
|
+
return s(`format version ${e.formatVersion} is newer than this tinyfly reads (${J})`), n;
|
|
2429
2516
|
let r = 0;
|
|
2430
2517
|
try {
|
|
2431
2518
|
r = rt(e).duration;
|
|
2432
2519
|
} catch (l) {
|
|
2433
|
-
return
|
|
2520
|
+
return s(`the timeline does not load: ${l instanceof Error ? l.message : String(l)}`), n;
|
|
2434
2521
|
}
|
|
2435
2522
|
const a = e.config?.duration;
|
|
2436
2523
|
if (a !== void 0)
|
|
2437
2524
|
for (const l of e.tracks) {
|
|
2438
2525
|
if (!("keyframes" in l)) continue;
|
|
2439
2526
|
const u = l.keyframes.filter((h) => h.time > a);
|
|
2440
|
-
u.length > 0 &&
|
|
2527
|
+
u.length > 0 && s(`track "${l.id}" has a keyframe at ${u[0].time}ms, after the ${a}ms duration`);
|
|
2441
2528
|
}
|
|
2442
2529
|
const o = e.config?.markers ?? [], c = /* @__PURE__ */ new Set();
|
|
2443
2530
|
o.forEach((l, u) => {
|
|
2444
|
-
c.has(l.id) &&
|
|
2531
|
+
c.has(l.id) && s(`marker id "${l.id}" is used more than once`), c.add(l.id), (l.time < 0 || l.time > r) && s(`marker "${l.id}" at ${l.time}ms is outside the animation (0–${r}ms)`), u > 0 && l.time < o[u - 1].time && s(`marker "${l.id}" comes before "${o[u - 1].id}" in time; list markers in order`);
|
|
2445
2532
|
});
|
|
2446
2533
|
for (const [l, u] of Object.entries(e.captions ?? {})) {
|
|
2447
2534
|
for (const h of Object.keys(u))
|
|
2448
|
-
c.has(h) ||
|
|
2535
|
+
c.has(h) || s(`caption "${h}" (${l}) has no marker with that id`);
|
|
2449
2536
|
for (const h of c)
|
|
2450
|
-
h in u ||
|
|
2537
|
+
h in u || i(`marker "${h}" has no ${l} caption; its label is shown instead`);
|
|
2451
2538
|
}
|
|
2452
2539
|
if (t.markup !== void 0) {
|
|
2453
2540
|
const l = new Set(re(t.markup)), u = /* @__PURE__ */ new Set();
|
|
2454
2541
|
for (const h of e.tracks)
|
|
2455
2542
|
for (const d of [h.target, ...h.targets ?? []])
|
|
2456
|
-
u.add(d), l.has(d) ||
|
|
2457
|
-
for (const h of l) u.has(h) ||
|
|
2543
|
+
u.add(d), l.has(d) || s(`track "${h.id}" targets "${d}", but no element has data-tinyfly="${d}"`);
|
|
2544
|
+
for (const h of l) u.has(h) || i(`data-tinyfly="${h}" is never animated`);
|
|
2458
2545
|
}
|
|
2459
|
-
return
|
|
2546
|
+
return n;
|
|
2460
2547
|
}
|
|
2461
|
-
function
|
|
2548
|
+
function es(e) {
|
|
2462
2549
|
const t = /* @__PURE__ */ new Set();
|
|
2463
|
-
for (const
|
|
2550
|
+
for (const n of e.matchAll(/data-tinyfly-choose\s*=\s*("([^"]*)"|'([^']*)')/g)) t.add(n[2] ?? n[3]);
|
|
2464
2551
|
return [...t];
|
|
2465
2552
|
}
|
|
2466
|
-
function
|
|
2467
|
-
const
|
|
2468
|
-
e.length === 1 &&
|
|
2469
|
-
const
|
|
2553
|
+
function ls(e, t = {}) {
|
|
2554
|
+
const n = [];
|
|
2555
|
+
e.length === 1 && n.push({ level: "warning", message: "only one scenario, so the reader has nothing to choose" });
|
|
2556
|
+
const s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
2470
2557
|
for (const r of e) {
|
|
2471
|
-
if (
|
|
2472
|
-
|
|
2558
|
+
if (s.has(r.id)) {
|
|
2559
|
+
n.push({ level: "error", message: `scenario id "${r.id}" is used more than once` });
|
|
2473
2560
|
continue;
|
|
2474
2561
|
}
|
|
2475
|
-
|
|
2476
|
-
for (const a of
|
|
2477
|
-
/is never animated$/.test(a.message) ||
|
|
2478
|
-
for (const a of r.timeline.tracks) for (const o of [a.target, ...a.targets ?? []])
|
|
2562
|
+
s.add(r.id);
|
|
2563
|
+
for (const a of ts(r.timeline, t))
|
|
2564
|
+
/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 ?? []]) i.add(o);
|
|
2479
2566
|
}
|
|
2480
2567
|
if (t.markup !== void 0) {
|
|
2481
|
-
for (const r of
|
|
2482
|
-
|
|
2568
|
+
for (const r of es(t.markup))
|
|
2569
|
+
s.has(r) || n.push({ level: "error", message: `data-tinyfly-choose="${r}" names no scenario` });
|
|
2483
2570
|
for (const r of re(t.markup))
|
|
2484
|
-
|
|
2571
|
+
i.has(r) || n.push({ level: "warning", message: `data-tinyfly="${r}" is never animated in any scenario` });
|
|
2485
2572
|
}
|
|
2486
|
-
return
|
|
2573
|
+
return n;
|
|
2487
2574
|
}
|
|
2488
|
-
function
|
|
2489
|
-
const
|
|
2575
|
+
function hs(e, t, n = "end") {
|
|
2576
|
+
const s = rt(t), i = t.config?.markers ?? [], r = n === "start" ? 0 : n === "end" ? s.duration : typeof n == "number" ? n : i.find((d) => d.id === n)?.time ?? s.duration, a = s.getStateAtTime(Math.max(0, Math.min(s.duration, r))), o = new vt(), c = /* @__PURE__ */ new Map(), l = ss(e);
|
|
2490
2577
|
for (const d of e.matchAll(Ut)) {
|
|
2491
2578
|
const f = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(d[2] ?? "");
|
|
2492
2579
|
if (!f) continue;
|
|
2493
2580
|
const g = f[2] ?? f[3];
|
|
2494
2581
|
if (c.has(g)) continue;
|
|
2495
|
-
const p =
|
|
2582
|
+
const p = ns(l(d.index ?? 0));
|
|
2496
2583
|
c.set(g, p), o.registerTarget(g, p);
|
|
2497
2584
|
}
|
|
2498
2585
|
o.applyState(a);
|
|
2499
2586
|
let u = "", h = 0;
|
|
2500
2587
|
for (const d of e.matchAll(Ut)) {
|
|
2501
|
-
const [f, g, p = "", m] = d, b = d.index ?? 0,
|
|
2502
|
-
if (!
|
|
2588
|
+
const [f, g, p = "", m] = d, b = d.index ?? 0, v = /data-tinyfly\s*=\s*("([^"]*)"|'([^']*)')/.exec(p), k = v ? c.get(v[2] ?? v[3]) : void 0;
|
|
2589
|
+
if (!k || Object.keys(k.style).length === 0 && k.text === void 0) continue;
|
|
2503
2590
|
u += e.slice(h, b);
|
|
2504
|
-
const
|
|
2505
|
-
let
|
|
2506
|
-
if (
|
|
2591
|
+
const M = Object.entries(k.style).map(([x, P]) => `${is(x)}: ${P}`).join("; "), y = /\sstyle\s*=\s*("([^"]*)"|'([^']*)')/.exec(p);
|
|
2592
|
+
let S = p;
|
|
2593
|
+
if (M)
|
|
2507
2594
|
if (y) {
|
|
2508
|
-
const
|
|
2509
|
-
|
|
2595
|
+
const x = `${(y[2] ?? y[3]).trim().replace(/;?$/, ";")} ${M}`.trim();
|
|
2596
|
+
S = p.replace(y[0], ` style="${jt(x)}"`);
|
|
2510
2597
|
} else
|
|
2511
|
-
|
|
2512
|
-
if (u += `<${g}${
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2598
|
+
S = `${p} style="${jt(M)}"`;
|
|
2599
|
+
if (u += `<${g}${S}${m ? " /" : ""}>`, h = b + f.length, k.text !== void 0 && !m) {
|
|
2600
|
+
const x = e.indexOf(`</${g}`, h), P = x === -1 ? "" : e.slice(h, x);
|
|
2601
|
+
x !== -1 && !P.includes("<") && (u += rs(k.text), h = x);
|
|
2515
2602
|
}
|
|
2516
2603
|
}
|
|
2517
2604
|
return u + e.slice(h);
|
|
2518
2605
|
}
|
|
2519
2606
|
const Ut = /<([a-zA-Z][\w:-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?)*)\s*(\/?)>/g;
|
|
2520
|
-
function
|
|
2607
|
+
function ns(e) {
|
|
2521
2608
|
const t = {
|
|
2522
2609
|
style: {},
|
|
2523
2610
|
dataset: {},
|
|
@@ -2526,44 +2613,44 @@ function Ks(e) {
|
|
|
2526
2613
|
get textContent() {
|
|
2527
2614
|
return t.text ?? "";
|
|
2528
2615
|
},
|
|
2529
|
-
set textContent(
|
|
2530
|
-
t.text =
|
|
2616
|
+
set textContent(n) {
|
|
2617
|
+
t.text = n;
|
|
2531
2618
|
}
|
|
2532
2619
|
};
|
|
2533
2620
|
return e && (t.ownerSVGElement = null), t;
|
|
2534
2621
|
}
|
|
2535
|
-
function
|
|
2536
|
-
const t = [],
|
|
2537
|
-
let
|
|
2538
|
-
for (;
|
|
2539
|
-
const
|
|
2540
|
-
t.push([
|
|
2622
|
+
function ss(e) {
|
|
2623
|
+
const t = [], n = /<svg[\s>]/gi;
|
|
2624
|
+
let s;
|
|
2625
|
+
for (; s = n.exec(e); ) {
|
|
2626
|
+
const i = e.toLowerCase().indexOf("</svg>", s.index);
|
|
2627
|
+
t.push([s.index + 1, i === -1 ? e.length : i]);
|
|
2541
2628
|
}
|
|
2542
|
-
return (
|
|
2629
|
+
return (i) => t.some(([r, a]) => i > r && i < a);
|
|
2543
2630
|
}
|
|
2544
|
-
function
|
|
2545
|
-
const t = e.replace(/[A-Z]/g, (
|
|
2631
|
+
function is(e) {
|
|
2632
|
+
const t = e.replace(/[A-Z]/g, (n) => `-${n.toLowerCase()}`);
|
|
2546
2633
|
return /^(webkit|moz|ms)-/.test(t) ? `-${t}` : t;
|
|
2547
2634
|
}
|
|
2548
2635
|
function jt(e) {
|
|
2549
2636
|
return e.replace(/&/g, "&").replace(/"/g, """);
|
|
2550
2637
|
}
|
|
2551
|
-
function
|
|
2638
|
+
function rs(e) {
|
|
2552
2639
|
return e.replace(/&/g, "&").replace(/</g, "<");
|
|
2553
2640
|
}
|
|
2554
|
-
|
|
2641
|
+
Jn();
|
|
2555
2642
|
export {
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2643
|
+
Ln as DEFAULT_LABELS,
|
|
2644
|
+
Mt as TinyflyPlayer,
|
|
2645
|
+
jn as bindChoiceHotspots,
|
|
2646
|
+
os as create,
|
|
2647
|
+
Xn as createControls,
|
|
2648
|
+
zn as mount,
|
|
2649
|
+
Zn as mountAll,
|
|
2650
|
+
as as play,
|
|
2651
|
+
hs as renderFrame,
|
|
2565
2652
|
re as targetNamesIn,
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2653
|
+
cs as unmount,
|
|
2654
|
+
ts as validateEmbed,
|
|
2655
|
+
ls as validateScenarios
|
|
2569
2656
|
};
|