@kolkrabbi/design-editor 0.26.0 → 0.27.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.
@@ -1,3096 +0,0 @@
1
- import { An as e, At as t, D as n, Dn as r, En as i, F as a, J as o, L as s, Ln as c, M as l, Mn as u, Mt as d, N as f, On as p, Ot as m, Pn as h, Qt as g, Sn as _, T as v, Tn as y, Zt as b, bn as x, d as S, en as C, f as w, hn as ee, jt as T, kt as E, q as D, t as te, tn as O, wn as k } from "./rolls-BGtqxVYq.js";
2
- import { r as ne } from "./TreePicker-nMf17QGH.js";
3
- import { A, C as j, D as M, E as N, O as P, S as re, T as ie, b as F, f as ae, g as oe, k as I, l as se, n as ce, w as le, x as ue, y as de } from "./timelinePinned-BwYq1Msi.js";
4
- import { BezierPathEditor as fe, Button as L, Dropdown as pe, Input as me, LabeledControl as he, MenuDropdownItem as ge, PopoverPanel as _e, SegmentedToggle as ve, SettingsRow as ye, Slider as be, Textarea as xe, ToggleCheckbox as R, Tooltip as z, floatSurfaceClass as Se, glyphSize as Ce, useGrabEdge as we, usePopover as Te } from "@kolkrabbi/kol-component";
5
- import { Fragment as Ee, useEffect as De, useMemo as Oe, useRef as B, useState as V } from "react";
6
- import { Fragment as ke, jsx as H, jsxs as U } from "react/jsx-runtime";
7
- import { Icon as Ae } from "@kolkrabbi/kol-icons";
8
- //#region src/kinetic/animations.js
9
- var W = {
10
- dLen: 0,
11
- dNormal: 0,
12
- scale: 1,
13
- dRot: 0,
14
- opacity: 1,
15
- vf: null
16
- }, je = {
17
- none: () => W,
18
- march: (e) => ({
19
- ...W,
20
- dLen: e.u * e.pathLen * Math.max(1, Math.round(e.m.cycles || 1))
21
- }),
22
- orbit: (e) => ({
23
- ...W,
24
- dLen: e.u * e.pathLen * Math.max(1, Math.round(e.m.cycles || 1))
25
- }),
26
- vfwave: (t) => {
27
- let n = Math.max(1, Math.round(t.m.cycles || 1)), r = .5 + .5 * Math.sin(t.u * e * n - t.i * (t.m.phase ?? .5));
28
- return {
29
- ...W,
30
- vf: { [t.axisTag]: h(t.axisMin, t.axisMax, r) }
31
- };
32
- },
33
- glyphwave: (t) => {
34
- let n = Math.max(1, Math.round(t.m.cycles || 1)), r = Math.sin(t.u * e * n - t.i * (t.m.phase ?? .5));
35
- return {
36
- ...W,
37
- dNormal: (t.m.amp ?? .3) * t.sizePx * r
38
- };
39
- },
40
- cascade: (t) => {
41
- let n = Math.max(1, Math.round(t.m.cycles || 1)), r = .5 + .5 * Math.sin(t.u * e * n - t.i * (t.m.phase ?? .6));
42
- return {
43
- ...W,
44
- scale: h(.25, 1, r),
45
- opacity: h(.15, 1, r)
46
- };
47
- },
48
- sweep: (e) => {
49
- let t = Fe(e);
50
- return {
51
- ...W,
52
- scale: h(.25, 1, t),
53
- opacity: h(.12, 1, t)
54
- };
55
- },
56
- sweepWeight: (e) => {
57
- let t = Fe(e);
58
- return {
59
- ...W,
60
- vf: { [e.axisTag]: h(e.axisMin, e.axisMax, t) }
61
- };
62
- },
63
- sweepShift: (e) => {
64
- let t = Fe(e);
65
- return {
66
- ...W,
67
- dNormal: t * .6 * e.sizePx
68
- };
69
- }
70
- }, Me = (e) => e - Math.floor(e);
71
- function Ne(e, t) {
72
- if (t <= 0) return 0;
73
- let n = Math.min(1, e / t);
74
- return 1 - n * n * (3 - 2 * n);
75
- }
76
- function Pe(t, n, r, i, a, o) {
77
- let s = Me(i * a), c = Math.max(.02, o * .5), l = (e) => {
78
- let t = Math.abs(Me(e) - s);
79
- return Ne(Math.min(t, 1 - t), c);
80
- };
81
- switch (t) {
82
- case "y": return l(r);
83
- case "diagonal": return l(.5 + (n - .5) * .7071 + (r - .5) * .7071);
84
- case "radial": return l(Math.hypot(n - .5, r - .5) / .7071);
85
- case "angular": return l(Math.atan2(r - .5, n - .5) / e + .5);
86
- case "wave": {
87
- let t = Math.max(1, Math.round(1 + (1 - o) * 6));
88
- return .5 + .5 * Math.sin((n * t - i * a) * e);
89
- }
90
- default: return l(n);
91
- }
92
- }
93
- var Fe = (e) => Pe(e.m.field || "x", e.nx ?? .5, e.ny ?? .5, e.u, Math.max(1, Math.round(e.m.cycles || 1)), e.m.amp ?? .35);
94
- function Ie(e, t) {
95
- return (je[e] || je.none)(t);
96
- }
97
- //#endregion
98
- //#region src/kinetic/features.js
99
- var Le = [
100
- {
101
- tag: "liga",
102
- label: "Ligatures"
103
- },
104
- {
105
- tag: "dlig",
106
- label: "Discretionary ligatures"
107
- },
108
- {
109
- tag: "smcp",
110
- label: "Small caps"
111
- },
112
- {
113
- tag: "case",
114
- label: "Case-sensitive forms"
115
- },
116
- {
117
- tag: "onum",
118
- label: "Oldstyle figures"
119
- },
120
- {
121
- tag: "tnum",
122
- label: "Tabular figures"
123
- },
124
- {
125
- tag: "frac",
126
- label: "Fractions"
127
- },
128
- {
129
- tag: "swsh",
130
- label: "Swashes"
131
- },
132
- {
133
- tag: "ss01",
134
- label: "Stylistic set 1"
135
- },
136
- {
137
- tag: "ss02",
138
- label: "Stylistic set 2"
139
- }
140
- ];
141
- function Re(e) {
142
- if (!e) return "normal";
143
- let t = [];
144
- for (let [n, r] of Object.entries(e)) t.push(`"${n}" ${+!!r}`);
145
- return t.length ? t.join(", ") : "normal";
146
- }
147
- //#endregion
148
- //#region src/kinetic/KineticType.js
149
- var ze = "http://www.w3.org/2000/svg", G = (e) => e - Math.floor(e), K = (e) => document.createElementNS(ze, e);
150
- function Be(e, t) {
151
- return !e || !t || t === "none" ? e || "" : t === "upper" ? e.toUpperCase() : t === "lower" ? e.toLowerCase() : t === "title" ? e.replace(/\b\w/g, (e) => e.toUpperCase()) : e;
152
- }
153
- function Ve(e) {
154
- if (!e) return {
155
- bg: "#16202E",
156
- instances: []
157
- };
158
- if (Array.isArray(e.instances)) return e;
159
- let { bg: t, ...n } = e;
160
- return {
161
- bg: t || "#16202E",
162
- instances: [{
163
- id: "main",
164
- ...n
165
- }]
166
- };
167
- }
168
- var He = class {
169
- constructor(e) {
170
- this.host = e, this.params = Ve(null), this.w = 0, this.h = 0, this._rt = /* @__PURE__ */ new Map(), this._instSig = "", this._needsRemeasure = !1;
171
- let t = K("svg");
172
- t.setAttribute("xmlns", ze), t.style.display = "block", t.style.maxWidth = "100%", t.style.maxHeight = "100%", t.style.pointerEvents = "none", t.style.overflow = "hidden", this._clipApplied = !0, this.bg = K("rect"), this.layer = K("g"), this.measEl = K("text"), this.measEl.setAttribute("x", "0"), this.measEl.setAttribute("y", "0"), this.measEl.style.visibility = "hidden", t.append(this.bg, this.layer, this.measEl), e.appendChild(t), this.svg = t, e.__kolKineticEngine = this, typeof document < "u" && document.fonts && document.fonts.ready.then(() => {
173
- this._needsRemeasure = !0;
174
- }).catch(() => {});
175
- }
176
- resize(e, t) {
177
- this.w = e, this.h = t, this.svg.setAttribute("width", e), this.svg.setAttribute("height", t), this.svg.setAttribute("viewBox", `0 0 ${e} ${t}`), this.bg.setAttribute("width", e), this.bg.setAttribute("height", t);
178
- for (let e of this._rt.values()) e.cache = null;
179
- }
180
- setComposition(e) {
181
- this.params = Ve(e);
182
- }
183
- renderAt(e) {
184
- !this.w || !this.h || this._render(u(e));
185
- }
186
- getInstanceRect(e) {
187
- let t = this._rt.get(e);
188
- if (!t || !t.glyphG) return null;
189
- let n;
190
- try {
191
- n = t.glyphG.getBBox();
192
- } catch {
193
- return null;
194
- }
195
- if (!n || !n.width || !n.height) return null;
196
- let r = (this.params.instances || []).find((t) => t.id === e), i = (r?.offset?.x || 0) * this.w, a = (r?.offset?.y || 0) * this.h;
197
- return {
198
- x: n.x + i,
199
- y: n.y + a,
200
- w: n.width,
201
- h: n.height
202
- };
203
- }
204
- hitTest(e, t) {
205
- let n = this.svg.getBoundingClientRect();
206
- if (!n.width || !n.height) return null;
207
- let r = (e - n.left) * (this.w / n.width), i = (t - n.top) * (this.h / n.height), a = this.params.instances || [];
208
- for (let e = a.length - 1; e >= 0; e--) {
209
- let t = this.getInstanceRect(a[e].id);
210
- if (t && r >= t.x && r <= t.x + t.w && i >= t.y && i <= t.y + t.h) return a[e].id;
211
- }
212
- return null;
213
- }
214
- dispose() {
215
- this.host && this.host.__kolKineticEngine === this && delete this.host.__kolKineticEngine, this.svg && this.svg.parentNode === this.host && this.host.removeChild(this.svg);
216
- }
217
- _syncInstances() {
218
- let e = this.params.instances || [], t = e.map((e) => e.id).join("|");
219
- if (t === this._instSig) return;
220
- this._instSig = t;
221
- let n = new Set(e.map((e) => e.id));
222
- for (let [e, t] of this._rt) n.has(e) || (t.group.remove(), this._rt.delete(e));
223
- for (let t of e) {
224
- let e = this._rt.get(t.id);
225
- if (!e) {
226
- let n = K("g"), r = K("path");
227
- r.setAttribute("fill", "none");
228
- let i = K("g");
229
- i.setAttribute("data-glyphs", t.id), n.append(r, i), e = {
230
- group: n,
231
- pathEl: r,
232
- glyphG: i,
233
- glyphEls: [],
234
- cache: null,
235
- glyphKey: "",
236
- closed: !1
237
- }, this._rt.set(t.id, e);
238
- }
239
- this.layer.appendChild(e.group);
240
- }
241
- }
242
- _render(e) {
243
- let t = this.params.clip !== !1;
244
- if (t !== this._clipApplied && (this._clipApplied = t, this.svg.style.overflow = t ? "hidden" : "visible"), this._needsRemeasure) {
245
- this._needsRemeasure = !1;
246
- for (let e of this._rt.values()) e.cache = null;
247
- }
248
- this.bg.setAttribute("fill", this.params.bg || "#16202E"), this._syncInstances();
249
- for (let t of this.params.instances || []) {
250
- let n = this._rt.get(t.id);
251
- n && this._renderInstance(t, n, e);
252
- }
253
- }
254
- _ensureGlyphs(e, t, n, r) {
255
- let i = `${t}|${n.family}|${r}`;
256
- if (i !== e.glyphKey) {
257
- e.glyphKey = i, e.glyphG.textContent = "", e.glyphEls = [];
258
- for (let n = 0; n < r; n++) for (let n of t) {
259
- let t = K("text");
260
- t.setAttribute("text-anchor", "middle"), t.setAttribute("dominant-baseline", "central"), t.textContent = n, e.glyphG.appendChild(t), e.glyphEls.push(t);
261
- }
262
- }
263
- }
264
- _measure(e, t, n, i) {
265
- let a = t.letterSpacing || 0, o = Re(t.opentype), s = `${i}|${n.family}|${t.fontSize}|${a}|${r(t.vf)}|${o}`;
266
- if (e.cache && e.cache.key === s) return e.cache;
267
- let c = this.measEl;
268
- c.style.fontFamily = `'${n.family}'`, c.style.fontSize = `${t.fontSize}px`, c.style.letterSpacing = `${a}px`, c.style.fontVariationSettings = r(t.vf), c.style.fontFeatureSettings = o, c.textContent = i;
269
- let l = i.length, u = Array(l), d = 0;
270
- try {
271
- d = c.getComputedTextLength();
272
- let e = Array(l);
273
- for (let t = 0; t < l; t++) e[t] = c.getStartPositionOfChar(t).x;
274
- for (let t = 0; t < l; t++) u[t] = (e[t] + (t + 1 < l ? e[t + 1] : d)) / 2;
275
- } catch {
276
- d = t.fontSize * .6 * l;
277
- for (let e = 0; e < l; e++) u[e] = (e + .5) * (d / Math.max(1, l));
278
- }
279
- return e.cache = {
280
- key: s,
281
- centers: u,
282
- total: d
283
- }, e.cache;
284
- }
285
- _renderInstance(e, t, n) {
286
- let r = k(e.font), i = e.phase ? G(n + e.phase) : n, a = Be(e.text || "", e.case), o = Math.max(1, Math.round(e.multiply || 1)), s = o > 1 && a ? Array(o).fill(a).join(" ") : a, c = e.path?.type || "line", l = (e.offset?.x || 0) * this.w, u = (e.offset?.y || 0) * this.h;
287
- if (t.group.setAttribute("transform", `translate(${l.toFixed(2)} ${u.toFixed(2)})`), e.morph?.on && !I(c) && !A(c)) {
288
- let n = r.url, a = e.morph.face2 ? k(e.morph.face2) : null, o = a ? a.url : n, l = d(n), u = d(o);
289
- if (l && u) {
290
- this._setKind(t, "morph"), this._renderMorph(e, t, i, l, u, r, s, c);
291
- return;
292
- }
293
- l || T(n).catch(() => {}), !u && o !== n && T(o).catch(() => {});
294
- }
295
- if (this._setKind(t, "text"), P(c)) {
296
- t.pathEl.setAttribute("d", ""), t.pathEl.style.opacity = 0;
297
- let n = Math.max(1, Math.round(e.path?.rows ?? 2)), a = Math.max(1, Math.round(e.path?.cols ?? 3));
298
- if (this._ensureGlyphs(t, s, r, n * a), !s.length) return;
299
- this._measure(t, e, r, s), this._placeArray(e, t, r, i, t.glyphEls, n, a);
300
- return;
301
- }
302
- if (I(c) || A(c)) {
303
- t.pathEl.setAttribute("d", ""), t.pathEl.style.opacity = 0;
304
- let n = Math.max(1, Math.round(e.path?.count ?? 12));
305
- if (this._ensureGlyphs(t, s, r, n), !s.length) return;
306
- this._measure(t, e, r, s), I(c) ? this._placeRadial(e, t, r, i, t.glyphEls, n) : this._placeRings(e, t, r, i, t.glyphEls, n);
307
- return;
308
- }
309
- let f = M(c, this.w, this.h, e.path || {});
310
- t.closed = f.closed, t.pathEl.setAttribute("d", f.d), t.pathEl.setAttribute("stroke", e.showPath ? e.fill || "#888" : "none"), t.pathEl.setAttribute("stroke-width", +!!e.showPath), t.pathEl.style.opacity = e.showPath ? .25 : 0, this._ensureGlyphs(t, s, r, 1), s.length && (this._measure(t, e, r, s), this._placeOnPath(e, t, r, i, t.glyphEls));
311
- }
312
- _styleGlyph(e, t, n, i) {
313
- e.style.fontFamily = `'${n.family}'`, e.style.fontSize = `${t.fontSize}px`, e.style.fontStyle = t.italic ? "italic" : "normal", e.style.fontVariationSettings = r(i.vf ? {
314
- ...t.vf,
315
- ...i.vf
316
- } : t.vf), e.style.fontFeatureSettings = Re(t.opentype), e.setAttribute("fill", t.fill || "#e8e4dc"), e.setAttribute("opacity", i.opacity);
317
- }
318
- _anim(e, t, n) {
319
- let r = e.motions && e.motions.length ? [e.motion, ...e.motions] : [e.motion], i = 0, a = 0, o = 0, s = 1, c = 1, l = null;
320
- for (let e of r) {
321
- if (!e || (e.mode || "none") === "none") continue;
322
- let r = n.axes.find((t) => t.tag === (e.axis || n.axes[0] && n.axes[0].tag)), u = Ie(e.mode, {
323
- ...t,
324
- m: e,
325
- axisTag: r ? r.tag : "wght",
326
- axisMin: r ? r.min : 100,
327
- axisMax: r ? r.max : 900
328
- });
329
- i += u.dLen, a += u.dNormal, o += u.dRot, s *= u.scale, c *= u.opacity, u.vf && (l = {
330
- ...l || {},
331
- ...u.vf
332
- });
333
- }
334
- return {
335
- dLen: i,
336
- dNormal: a,
337
- scale: s,
338
- dRot: o,
339
- opacity: c,
340
- vf: l
341
- };
342
- }
343
- _placeOnPath(e, t, n, r, i) {
344
- let a = t.cache;
345
- if (!a) return;
346
- let o = t.pathEl.getTotalLength();
347
- if (!o) return;
348
- let { centers: s, total: c } = a, l = e.align || "center", d = l === "start" ? 0 : l === "end" ? o - c : (o - c) / 2, f = .75, p = t.closed, m = e.flow === "flow" && !p, h = (e) => p ? (e % o + o) % o : Math.max(0, Math.min(o, e)), g = (e) => {
349
- if (m && (e < 0 || e > o)) {
350
- let n = e < 0 ? 0 : o, r = t.pathEl.getPointAtLength(n), i = t.pathEl.getPointAtLength(Math.max(0, n - f)), a = t.pathEl.getPointAtLength(Math.min(o, n + f)), s = a.x - i.x, c = a.y - i.y, l = Math.hypot(s, c) || 1;
351
- s /= l, c /= l;
352
- let u = e - n;
353
- return {
354
- x: r.x + s * u,
355
- y: r.y + c * u
356
- };
357
- }
358
- return t.pathEl.getPointAtLength(h(e));
359
- }, _ = Math.min(i.length, s.length), v = u(e.stagger || 0), y = Math.max(1, Math.round(e.multiply || 1)), b = (s.length + 2) / y;
360
- for (let t = 0; t < _; t++) {
361
- let a = d + s[t], c = g(a), l = v && y > 1 ? G(r + v * Math.floor(t / b) / y) : r, u = this._anim(e, {
362
- i: t,
363
- n: s.length,
364
- u: l,
365
- sizePx: e.fontSize,
366
- pathLen: o,
367
- nx: this.w ? c.x / this.w : .5,
368
- ny: this.h ? c.y / this.h : .5
369
- }, n), p = a + u.dLen, m = g(p), h = g(p - f), _ = g(p + f), x = Math.atan2(_.y - h.y, _.x - h.x) * 180 / Math.PI;
370
- i[t].setAttribute("transform", `translate(${m.x.toFixed(2)} ${m.y.toFixed(2)}) rotate(${(x + u.dRot).toFixed(2)}) translate(0 ${(-u.dNormal).toFixed(2)}) scale(${u.scale.toFixed(3)})`), this._styleGlyph(i[t], e, n, u);
371
- }
372
- }
373
- _placeArray(e, t, n, r, i, a, o) {
374
- let s = t.cache;
375
- if (!s) return;
376
- let { centers: c, total: l } = s, d = c.length;
377
- if (!d) return;
378
- let f = Math.min(this.w, this.h) * .08, p = (this.w - 2 * f) / o, m = (this.h - 2 * f) / a, h = u(e.stagger || 0), g = a * o;
379
- for (let t = 0; t < g; t++) {
380
- let a = Math.floor(t / o), s = f + t % o * p + p / 2, u = f + a * m + m / 2, _ = s - l / 2, v = h ? G(r + h * t / g) : r;
381
- for (let r = 0; r < d; r++) {
382
- let a = i[t * d + r];
383
- if (!a) continue;
384
- let o = _ + c[r], s = this._anim(e, {
385
- i: t * d + r,
386
- n: g * d,
387
- u: v,
388
- sizePx: e.fontSize,
389
- pathLen: 0,
390
- nx: this.w ? o / this.w : .5,
391
- ny: this.h ? u / this.h : .5
392
- }, n), l = u - s.dNormal;
393
- a.setAttribute("transform", `translate(${o.toFixed(2)} ${l.toFixed(2)}) rotate(${s.dRot.toFixed(2)}) scale(${s.scale.toFixed(3)})`), this._styleGlyph(a, e, n, s);
394
- }
395
- }
396
- }
397
- _placeRadial(t, n, r, i, a, o) {
398
- let s = n.cache;
399
- if (!s) return;
400
- let { centers: c } = s, l = c.length;
401
- if (!l) return;
402
- let d = this.w / 2, f = this.h / 2, p = Math.min(this.w, this.h) * .5, m = p * Math.max(0, Math.min(.95, t.path?.inner ?? .12)), h = Math.round(t.path?.spin ?? 1), g = u(t.stagger || 0);
403
- for (let n = 0; n < o; n++) {
404
- let s = o > 1 ? n / (o - 1) : 0, u = h + (g ? Math.round(g * 2 * s) : 0), _ = n / o * e + i * e * u, v = g ? G(i + g * n / o) : i, y = Math.cos(_), b = Math.sin(_), x = _ * 180 / Math.PI;
405
- for (let e = 0; e < l; e++) {
406
- let i = n * l + e, s = a[i];
407
- if (!s) continue;
408
- let u = m + c[e], h = d + y * u, g = f + b * u, _ = this._anim(t, {
409
- i,
410
- n: o * l,
411
- u: v,
412
- sizePx: t.fontSize,
413
- pathLen: p,
414
- nx: this.w ? h / this.w : .5,
415
- ny: this.h ? g / this.h : .5
416
- }, r), S = u + _.dLen, C = d + y * S, w = f + b * S;
417
- s.setAttribute("transform", `translate(${C.toFixed(2)} ${w.toFixed(2)}) rotate(${(x + _.dRot).toFixed(2)}) translate(0 ${(-_.dNormal).toFixed(2)}) scale(${_.scale.toFixed(3)})`), this._styleGlyph(s, t, r, _);
418
- }
419
- }
420
- }
421
- _placeRings(t, n, r, i, a, o) {
422
- let s = n.cache;
423
- if (!s) return;
424
- let { centers: c, total: l } = s, d = c.length;
425
- if (!d) return;
426
- let f = this.w / 2, p = this.h / 2, m = Math.min(this.w, this.h) * .5 * Math.max(.1, Math.min(1, t.path?.radius ?? .92)), h = m * Math.max(.02, Math.min(.95, t.path?.inner ?? .14)), g = Math.round(t.path?.spin ?? 1), _ = t.path?.twist ?? .5, v = t.path?.grow ?? .6, y = u(t.stagger || 0);
427
- for (let n = 0; n < o; n++) {
428
- let s = o > 1 ? n / (o - 1) : 0, u = Math.max(1, h + s * (m - h)), b = g + (y ? Math.round(y * 2 * s) : 0), x = i * e * b + s * _ * e, S = y ? G(i + y * n / o) : i, C = 1 + v * s;
429
- for (let i = 0; i < d; i++) {
430
- let s = n * d + i, m = a[s];
431
- if (!m) continue;
432
- let h = x + (c[i] - l / 2) / u, g = f + Math.cos(h) * u, _ = p + Math.sin(h) * u, v = this._anim(t, {
433
- i: s,
434
- n: o * d,
435
- u: S,
436
- sizePx: t.fontSize,
437
- pathLen: e * u,
438
- nx: this.w ? g / this.w : .5,
439
- ny: this.h ? _ / this.h : .5
440
- }, r), y = h + v.dLen / u, b = u - v.dNormal, w = f + Math.cos(y) * b, ee = p + Math.sin(y) * b, T = y * 180 / Math.PI + 90 + v.dRot;
441
- m.setAttribute("transform", `translate(${w.toFixed(2)} ${ee.toFixed(2)}) rotate(${T.toFixed(2)}) scale(${(v.scale * C).toFixed(3)})`), this._styleGlyph(m, t, r, v);
442
- }
443
- }
444
- }
445
- _setKind(e, t) {
446
- e.kind !== t && (e.kind = t, e.glyphG.textContent = "", e.glyphEls = [], e.morphEls = [], e.glyphKey = "", e.morphKey = "", e.morphPoolKey = "", e.cache = null);
447
- }
448
- _renderMorph(e, n, r, i, a, o, s, c) {
449
- let l = e.fontSize, u = o.axes || [], d = {};
450
- for (let t of u) d[t.tag] = e.vf?.[t.tag] ?? t.def;
451
- let f = !!e.morph.face2, p = {};
452
- if (!f) for (let t of u) p[t.tag] = e.morph.vf2?.[t.tag] ?? t.max;
453
- let m = l * .12 + (e.letterSpacing || 0), h = e.morph.mode || "morph", g = e.morph.blend ?? .5, _ = e.morph.curve || "flat", v = e.morph.cp1 || {
454
- x: .33,
455
- y: .33
456
- }, y = e.morph.cp2 || {
457
- x: .66,
458
- y: .66
459
- }, b = e.fill || "#e8e4dc", x = JSON.stringify([
460
- s,
461
- e.font,
462
- e.morph.face2 || "",
463
- l,
464
- d,
465
- p,
466
- h,
467
- g,
468
- _,
469
- v,
470
- y,
471
- e.letterSpacing || 0,
472
- b
473
- ]), S = x !== n.morphKey;
474
- if (S) {
475
- n.morphKey = x;
476
- let e = t(i, a, s, l, {
477
- mode: h,
478
- blend: g,
479
- curve: _,
480
- cp1: v,
481
- cp2: y,
482
- coordsA: d,
483
- coordsB: p,
484
- axes: u,
485
- gap: m
486
- });
487
- n.morphData = e;
488
- let r = [], o = 0;
489
- for (let t of e.glyphs) r.push(o + t.advance / 2), o += t.advance;
490
- n.morphCenters = r, n.morphTotal = e.totalAdvance;
491
- }
492
- let C = n.morphData?.glyphs.length || 0;
493
- if (!s.length || !C) {
494
- n.pathEl.setAttribute("d", ""), n.pathEl.style.opacity = 0;
495
- return;
496
- }
497
- let w = P(c), ee = w ? Math.max(1, Math.round(e.path?.rows ?? 2)) : 1, T = w ? Math.max(1, Math.round(e.path?.cols ?? 3)) : 1, E = w ? ee * T : 1, D = this._ensureMorphPool(n, C, E, h);
498
- if ((S || D) && this._refreshMorphPaths(n, E, h, b), w) {
499
- n.pathEl.setAttribute("d", ""), n.pathEl.style.opacity = 0, this._placeMorphArray(e, n, o, r, ee, T);
500
- return;
501
- }
502
- let te = M(c, this.w, this.h, e.path || {});
503
- n.closed = te.closed, n.pathEl.setAttribute("d", te.d), n.pathEl.setAttribute("stroke", e.showPath ? e.fill || "#888" : "none"), n.pathEl.setAttribute("stroke-width", +!!e.showPath), n.pathEl.style.opacity = e.showPath ? .25 : 0, this._placeMorphOnPath(e, n, o, r);
504
- }
505
- _ensureMorphPool(e, t, n, r) {
506
- let i = `${t}|${n}|${r}`;
507
- if (i === e.morphPoolKey) return !1;
508
- e.morphPoolKey = i, e.glyphG.textContent = "", e.morphEls = [];
509
- let a = t * n;
510
- for (let t = 0; t < a; t++) {
511
- let t = K("g");
512
- t.appendChild(K("path")), r === "fade" && t.appendChild(K("path")), e.glyphG.appendChild(t), e.morphEls.push(t);
513
- }
514
- return !0;
515
- }
516
- _refreshMorphPaths(e, t, n, r) {
517
- let i = e.morphData?.glyphs || [], a = i.length;
518
- if (a) for (let t = 0; t < e.morphEls.length; t++) {
519
- let o = e.morphEls[t], s = i[t % a];
520
- if (!s) continue;
521
- let c = o.childNodes;
522
- n === "fade" ? (this._setMorphPath(c[0], s.dA, s.bboxA, r, s.opA), this._setMorphPath(c[1], s.dB, s.bboxB, r, s.opB)) : this._setMorphPath(c[0], s.d, s.bbox, r, 1);
523
- }
524
- }
525
- _setMorphPath(e, t, n, r, i) {
526
- if (!e) return;
527
- e.setAttribute("d", t || ""), e.setAttribute("fill", r), e.setAttribute("fill-rule", "evenodd"), e.setAttribute("opacity", i);
528
- let a = (n.x1 + n.x2) / 2, o = (n.y1 + n.y2) / 2;
529
- e.setAttribute("transform", `translate(${(-a).toFixed(2)} ${(-o).toFixed(2)})`);
530
- }
531
- _placeMorphOnPath(e, t, n, r, i = t.morphEls) {
532
- let a = t.morphCenters, o = t.morphTotal;
533
- if (!a || !i) return;
534
- let s = t.pathEl.getTotalLength();
535
- if (!s) return;
536
- let c = e.align || "center", l = c === "start" ? 0 : c === "end" ? s - o : (s - o) / 2, d = .75, f = t.closed, p = e.flow === "flow" && !f, m = (e) => f ? (e % s + s) % s : Math.max(0, Math.min(s, e)), h = (e) => {
537
- if (p && (e < 0 || e > s)) {
538
- let n = e < 0 ? 0 : s, r = t.pathEl.getPointAtLength(n), i = t.pathEl.getPointAtLength(Math.max(0, n - d)), a = t.pathEl.getPointAtLength(Math.min(s, n + d)), o = a.x - i.x, c = a.y - i.y, l = Math.hypot(o, c) || 1;
539
- o /= l, c /= l;
540
- let u = e - n;
541
- return {
542
- x: r.x + o * u,
543
- y: r.y + c * u
544
- };
545
- }
546
- return t.pathEl.getPointAtLength(m(e));
547
- }, g = e.italic ? " skewX(-12)" : "", _ = Math.min(i.length, a.length), v = u(e.stagger || 0), y = Math.max(1, Math.round(e.multiply || 1)), b = (a.length + 2) / y;
548
- for (let t = 0; t < _; t++) {
549
- let o = l + a[t], c = h(o), u = v && y > 1 ? G(r + v * Math.floor(t / b) / y) : r, f = this._anim(e, {
550
- i: t,
551
- n: a.length,
552
- u,
553
- sizePx: e.fontSize,
554
- pathLen: s,
555
- nx: this.w ? c.x / this.w : .5,
556
- ny: this.h ? c.y / this.h : .5
557
- }, n), p = o + f.dLen, m = h(p), _ = h(p - d), x = h(p + d), S = Math.atan2(x.y - _.y, x.x - _.x) * 180 / Math.PI;
558
- i[t].setAttribute("transform", `translate(${m.x.toFixed(2)} ${m.y.toFixed(2)}) rotate(${(S + f.dRot).toFixed(2)}) translate(0 ${(-f.dNormal).toFixed(2)}) scale(${f.scale.toFixed(3)})${g}`), i[t].setAttribute("opacity", f.opacity);
559
- }
560
- }
561
- _placeMorphArray(e, t, n, r, i, a, o = t.morphEls) {
562
- let s = t.morphCenters, c = t.morphTotal;
563
- if (!s || !o) return;
564
- let l = s.length;
565
- if (!l) return;
566
- let d = Math.min(this.w, this.h) * .08, f = (this.w - 2 * d) / a, p = (this.h - 2 * d) / i, m = e.italic ? " skewX(-12)" : "", h = u(e.stagger || 0), g = i * a;
567
- for (let t = 0; t < g; t++) {
568
- let i = Math.floor(t / a), u = d + t % a * f + f / 2, _ = d + i * p + p / 2, v = u - c / 2, y = h ? G(r + h * t / g) : r;
569
- for (let r = 0; r < l; r++) {
570
- let i = t * l + r, a = o[i];
571
- if (!a) continue;
572
- let c = v + s[r], u = this._anim(e, {
573
- i,
574
- n: g * l,
575
- u: y,
576
- sizePx: e.fontSize,
577
- pathLen: 0,
578
- nx: this.w ? c / this.w : .5,
579
- ny: this.h ? _ / this.h : .5
580
- }, n), d = _ - u.dNormal;
581
- a.setAttribute("transform", `translate(${c.toFixed(2)} ${d.toFixed(2)}) rotate(${u.dRot.toFixed(2)}) scale(${u.scale.toFixed(3)})${m}`), a.setAttribute("opacity", u.opacity);
582
- }
583
- }
584
- }
585
- }, q = (e, t = 0) => e?.instances?.[t] ?? null, J = (e, t, n = 0) => ({
586
- ...e,
587
- instances: (e.instances ?? []).map((e, r) => r === n ? {
588
- ...e,
589
- ...t
590
- } : e)
591
- }), Ue = (e, t) => ({
592
- ...e,
593
- instances: (e.instances ?? []).map((e, n, r) => ({
594
- ...e,
595
- ...t(e, n, r.length)
596
- }))
597
- }), Y = (e, t, n = 0) => J(e, { path: {
598
- ...q(e, n)?.path ?? {},
599
- ...t
600
- } }, n), We = (e, t, n = 0) => J(e, { motion: {
601
- ...q(e, n)?.motion ?? {},
602
- ...t
603
- } }, n), X = (e, t = 0) => q(e, t)?.path?.type ?? "line", Ge = (e, t = 0) => q(e, t)?.motion?.mode ?? "none", Ke = (e, t = 0) => ![
604
- "radial",
605
- "rings",
606
- "array"
607
- ].includes(X(e, t)), qe = [
608
- {
609
- value: "line",
610
- label: "Line"
611
- },
612
- {
613
- value: "arc",
614
- label: "Arc"
615
- },
616
- {
617
- value: "sine",
618
- label: "Sine"
619
- },
620
- {
621
- value: "zigzag",
622
- label: "Zigzag"
623
- },
624
- {
625
- value: "spiral",
626
- label: "Spiral"
627
- },
628
- {
629
- value: "circle",
630
- label: "Circle"
631
- },
632
- {
633
- value: "ellipse",
634
- label: "Ellipse"
635
- },
636
- {
637
- value: "custom",
638
- label: "Custom"
639
- },
640
- {
641
- value: "array",
642
- label: "Array"
643
- },
644
- {
645
- value: "radial",
646
- label: "Radial"
647
- },
648
- {
649
- value: "rings",
650
- label: "Rings"
651
- }
652
- ], Z = (e, t = 0) => q(e, t)?.morph ?? {}, Q = (e, t, n = 0) => J(e, { morph: {
653
- ...q(e, n)?.morph ?? {},
654
- ...t
655
- } }, n), Je = (e, t, n, r = 0) => Q(e, { vf2: {
656
- ...Z(e, r).vf2 ?? {},
657
- [t]: n
658
- } }, r), Ye = (e, t = 0) => !["radial", "rings"].includes(X(e, t)), Xe = (e, t = 0) => Ye(e, t) && !!Z(e, t).on, Ze = (e, t = 0) => Z(e, t).mode ?? "morph", Qe = (e, t = 0) => Xe(e, t) && ["morph", "fade"].includes(Ze(e, t)), $ = (e, t, n = 0) => k(q(e, n)?.font).axes.find((e) => e.tag === t), $e = (e, t, n, r = 0) => {
659
- let i = $(e, t, r), a = i ? Math.min(i.max, Math.max(i.min, n)) : n;
660
- return Je(e, t, Math.round(a), r);
661
- }, et = (e, t, n, r = 0) => {
662
- let i = $(e, t, r), a = i ? Math.min(i.max, Math.max(i.min, n)) : n;
663
- return J(e, { vf: {
664
- ...q(e, r)?.vf ?? {},
665
- [t]: Math.round(a)
666
- } }, r);
667
- }, tt = (e) => ({
668
- key: `vf${e[0].toUpperCase()}${e.slice(1)}`,
669
- label: x[e] || e,
670
- tab: "style",
671
- section: "Axes",
672
- type: "range",
673
- step: 1,
674
- min: (t, n = 0) => $(t, e, n)?.min ?? 0,
675
- max: (t, n = 0) => $(t, e, n)?.max ?? 1e3,
676
- when: (t, n = 0) => !!$(t, e, n),
677
- get: (t, n = 0) => q(t, n)?.vf?.[e] ?? $(t, e, n)?.def ?? 0,
678
- set: (t, n, r = 0) => et(t, e, n, r)
679
- }), nt = (e, t = 0) => Xe(e, t) && Ze(e, t) === "morph" && (Z(e, t).curve ?? "flat") === "custom", rt = (e, t) => ({
680
- key: `morphC${e}${t}`,
681
- label: `P${e} ${t.toUpperCase()}`,
682
- tab: "style",
683
- section: "Morph",
684
- type: "range",
685
- min: 0,
686
- max: 1,
687
- step: .01,
688
- noRandom: !0,
689
- when: nt,
690
- get: (n, r = 0) => Z(n, r)[`cp${e}`]?.[t] ?? (e === 1 ? .33 : .66),
691
- set: (n, r, i = 0) => Q(n, { [`cp${e}`]: {
692
- ...Z(n, i)[`cp${e}`] ?? {
693
- x: e === 1 ? .33 : .66,
694
- y: e === 1 ? .33 : .66
695
- },
696
- [t]: r
697
- } }, i)
698
- }), it = [
699
- {
700
- key: "bg",
701
- label: "Background",
702
- tab: "style",
703
- type: "color",
704
- role: "bg",
705
- noRandom: !0,
706
- get: (e) => e.bg,
707
- set: (e, t) => ({
708
- ...e,
709
- bg: t
710
- })
711
- },
712
- {
713
- key: "fill",
714
- label: "Fill",
715
- tab: "style",
716
- type: "color",
717
- role: "fg",
718
- noRandom: !0,
719
- get: (e, t = 0) => q(e, t)?.fill,
720
- set: (e, t, n = 0) => J(e, { fill: t }, n)
721
- },
722
- {
723
- key: "font",
724
- label: "Font",
725
- tab: "style",
726
- type: "select",
727
- options: _,
728
- noRandom: !0,
729
- get: (e, t = 0) => q(e, t)?.font,
730
- set: (e, t, n = 0) => J(e, {
731
- font: t,
732
- vf: le(t, q(e, n)?.vf)
733
- }, n)
734
- },
735
- {
736
- key: "italic",
737
- label: "Italic",
738
- tab: "style",
739
- type: "select",
740
- noRandom: !0,
741
- options: [{
742
- value: "off",
743
- label: "Off"
744
- }, {
745
- value: "on",
746
- label: "On"
747
- }],
748
- get: (e, t = 0) => q(e, t)?.italic ? "on" : "off",
749
- set: (e, t, n = 0) => J(e, { italic: t === "on" }, n)
750
- },
751
- {
752
- key: "case",
753
- label: "Case",
754
- tab: "style",
755
- type: "select",
756
- noRandom: !0,
757
- options: [
758
- {
759
- value: "none",
760
- label: "Aa"
761
- },
762
- {
763
- value: "upper",
764
- label: "AA"
765
- },
766
- {
767
- value: "lower",
768
- label: "aa"
769
- },
770
- {
771
- value: "title",
772
- label: "Tt"
773
- }
774
- ],
775
- get: (e, t = 0) => q(e, t)?.case ?? "none",
776
- set: (e, t, n = 0) => J(e, { case: t }, n)
777
- },
778
- {
779
- key: "fontSize",
780
- label: "Font size",
781
- tab: "style",
782
- type: "range",
783
- min: 8,
784
- max: 1200,
785
- step: 1,
786
- rMin: 36,
787
- rMax: 150,
788
- get: (e, t = 0) => q(e, t)?.fontSize ?? 26,
789
- set: (e, t, n = 0) => J(e, { fontSize: Math.round(t) }, n)
790
- },
791
- {
792
- key: "letterSpacing",
793
- label: "Letter spacing",
794
- tab: "style",
795
- type: "range",
796
- min: -10,
797
- max: 400,
798
- step: .5,
799
- rMin: 0,
800
- rMax: 12,
801
- get: (e, t = 0) => q(e, t)?.letterSpacing ?? 0,
802
- set: (e, t, n = 0) => J(e, { letterSpacing: t }, n)
803
- },
804
- {
805
- key: "align",
806
- label: "Align",
807
- tab: "style",
808
- type: "select",
809
- noRandom: !0,
810
- when: Ke,
811
- options: [
812
- {
813
- value: "start",
814
- label: "Start"
815
- },
816
- {
817
- value: "center",
818
- label: "Center"
819
- },
820
- {
821
- value: "end",
822
- label: "End"
823
- }
824
- ],
825
- get: (e, t = 0) => q(e, t)?.align ?? "center",
826
- set: (e, t, n = 0) => J(e, { align: t }, n)
827
- },
828
- {
829
- key: "multiply",
830
- label: "Copies",
831
- tab: "style",
832
- type: "range",
833
- min: 1,
834
- max: 24,
835
- step: 1,
836
- noRandom: !0,
837
- when: Ke,
838
- get: (e, t = 0) => q(e, t)?.multiply ?? 1,
839
- set: (e, t, n = 0) => J(e, { multiply: Math.round(t) }, n)
840
- },
841
- tt("wdth"),
842
- tt("wght"),
843
- {
844
- key: "arrangement",
845
- label: "Arrangement",
846
- tab: "style",
847
- section: "Arrangement",
848
- type: "select",
849
- noRandom: !0,
850
- options: qe,
851
- get: X,
852
- set: (e, t, n = 0) => Y(e, { type: t }, n)
853
- },
854
- {
855
- key: "spokes",
856
- label: "Spokes",
857
- tab: "style",
858
- section: "Arrangement",
859
- type: "range",
860
- min: 2,
861
- max: 32,
862
- step: 1,
863
- rMin: 6,
864
- rMax: 28,
865
- when: (e, t = 0) => X(e, t) === "radial",
866
- get: (e, t = 0) => q(e, t)?.path?.count ?? 12,
867
- set: (e, t, n = 0) => Y(e, { count: Math.round(t) }, n)
868
- },
869
- {
870
- key: "rings",
871
- label: "Rings",
872
- tab: "style",
873
- section: "Arrangement",
874
- type: "range",
875
- min: 2,
876
- max: 24,
877
- step: 1,
878
- rMin: 4,
879
- rMax: 16,
880
- when: (e, t = 0) => X(e, t) === "rings",
881
- get: (e, t = 0) => q(e, t)?.path?.count ?? 12,
882
- set: (e, t, n = 0) => Y(e, { count: Math.round(t) }, n)
883
- },
884
- {
885
- key: "inner",
886
- label: "Inner radius",
887
- tab: "style",
888
- section: "Arrangement",
889
- type: "range",
890
- min: 0,
891
- max: .9,
892
- step: .01,
893
- rMin: .04,
894
- rMax: .4,
895
- when: (e, t = 0) => X(e, t) === "radial" || X(e, t) === "rings",
896
- get: (e, t = 0) => q(e, t)?.path?.inner ?? .12,
897
- set: (e, t, n = 0) => Y(e, { inner: t }, n)
898
- },
899
- {
900
- key: "ringRadius",
901
- label: "Radius",
902
- tab: "style",
903
- section: "Arrangement",
904
- type: "range",
905
- min: .1,
906
- max: 1,
907
- step: .01,
908
- rMin: .6,
909
- rMax: 1,
910
- when: (e, t = 0) => X(e, t) === "rings",
911
- get: (e, t = 0) => q(e, t)?.path?.radius ?? .92,
912
- set: (e, t, n = 0) => Y(e, { radius: t }, n)
913
- },
914
- {
915
- key: "twist",
916
- label: "Twist",
917
- tab: "style",
918
- section: "Arrangement",
919
- type: "range",
920
- min: 0,
921
- max: 2,
922
- step: .05,
923
- rMin: 0,
924
- rMax: 1.5,
925
- when: (e, t = 0) => X(e, t) === "rings",
926
- get: (e, t = 0) => q(e, t)?.path?.twist ?? .5,
927
- set: (e, t, n = 0) => Y(e, { twist: t }, n)
928
- },
929
- {
930
- key: "grow",
931
- label: "Grow",
932
- tab: "style",
933
- section: "Arrangement",
934
- type: "range",
935
- min: 0,
936
- max: 2,
937
- step: .05,
938
- rMin: 0,
939
- rMax: 1.5,
940
- when: (e, t = 0) => X(e, t) === "rings",
941
- get: (e, t = 0) => q(e, t)?.path?.grow ?? .6,
942
- set: (e, t, n = 0) => Y(e, { grow: t }, n)
943
- },
944
- {
945
- key: "pathRadius",
946
- label: "Radius",
947
- tab: "style",
948
- section: "Arrangement",
949
- type: "range",
950
- min: .2,
951
- max: 1,
952
- step: .01,
953
- rMin: .5,
954
- rMax: 1,
955
- when: (e, t = 0) => [
956
- "circle",
957
- "ellipse",
958
- "spiral"
959
- ].includes(X(e, t)),
960
- get: (e, t = 0) => q(e, t)?.path?.radius ?? .72,
961
- set: (e, t, n = 0) => Y(e, { radius: t }, n)
962
- },
963
- {
964
- key: "turns",
965
- label: "Turns",
966
- tab: "style",
967
- section: "Arrangement",
968
- type: "range",
969
- min: 1,
970
- max: 8,
971
- rMin: 1,
972
- rMax: 6,
973
- step: 1,
974
- rMin: 2,
975
- rMax: 5,
976
- when: (e, t = 0) => X(e, t) === "spiral",
977
- get: (e, t = 0) => q(e, t)?.path?.turns ?? 3,
978
- set: (e, t, n = 0) => Y(e, { turns: Math.round(t) }, n)
979
- },
980
- {
981
- key: "amp",
982
- label: "Amplitude",
983
- tab: "style",
984
- section: "Arrangement",
985
- type: "range",
986
- min: 0,
987
- max: 1,
988
- step: .05,
989
- rMin: .2,
990
- rMax: .7,
991
- when: (e, t = 0) => [
992
- "arc",
993
- "sine",
994
- "zigzag"
995
- ].includes(X(e, t)),
996
- get: (e, t = 0) => q(e, t)?.path?.amp ?? .4,
997
- set: (e, t, n = 0) => Y(e, { amp: t }, n)
998
- },
999
- {
1000
- key: "freq",
1001
- label: "Frequency",
1002
- tab: "style",
1003
- section: "Arrangement",
1004
- type: "range",
1005
- min: 1,
1006
- max: 6,
1007
- step: 1,
1008
- rMin: 1,
1009
- rMax: 4,
1010
- when: (e, t = 0) => ["sine", "zigzag"].includes(X(e, t)),
1011
- get: (e, t = 0) => q(e, t)?.path?.freq ?? 2,
1012
- set: (e, t, n = 0) => Y(e, { freq: Math.round(t) }, n)
1013
- },
1014
- {
1015
- key: "rows",
1016
- label: "Rows",
1017
- tab: "style",
1018
- section: "Arrangement",
1019
- type: "range",
1020
- min: 1,
1021
- max: 6,
1022
- step: 1,
1023
- rMin: 2,
1024
- rMax: 4,
1025
- when: (e, t = 0) => X(e, t) === "array",
1026
- get: (e, t = 0) => q(e, t)?.path?.rows ?? 2,
1027
- set: (e, t, n = 0) => Y(e, { rows: Math.round(t) }, n)
1028
- },
1029
- {
1030
- key: "cols",
1031
- label: "Columns",
1032
- tab: "style",
1033
- section: "Arrangement",
1034
- type: "range",
1035
- min: 1,
1036
- max: 8,
1037
- step: 1,
1038
- rMin: 2,
1039
- rMax: 6,
1040
- when: (e, t = 0) => X(e, t) === "array",
1041
- get: (e, t = 0) => q(e, t)?.path?.cols ?? 3,
1042
- set: (e, t, n = 0) => Y(e, { cols: Math.round(t) }, n)
1043
- },
1044
- {
1045
- key: "flow",
1046
- label: "Paragraph",
1047
- tab: "style",
1048
- section: "Arrangement",
1049
- type: "select",
1050
- noRandom: !0,
1051
- when: Ke,
1052
- options: [{
1053
- value: "flow",
1054
- label: "Flow"
1055
- }, {
1056
- value: "contain",
1057
- label: "Contain"
1058
- }],
1059
- get: (e, t = 0) => q(e, t)?.flow ?? "flow",
1060
- set: (e, t, n = 0) => J(e, { flow: t }, n)
1061
- },
1062
- {
1063
- key: "showPath",
1064
- label: "Show path",
1065
- tab: "style",
1066
- section: "Arrangement",
1067
- type: "select",
1068
- noRandom: !0,
1069
- when: Ke,
1070
- options: [{
1071
- value: "off",
1072
- label: "Off"
1073
- }, {
1074
- value: "on",
1075
- label: "On"
1076
- }],
1077
- get: (e, t = 0) => q(e, t)?.showPath ? "on" : "off",
1078
- set: (e, t, n = 0) => J(e, { showPath: t === "on" }, n)
1079
- },
1080
- {
1081
- key: "offsetX",
1082
- label: "X",
1083
- tab: "style",
1084
- section: "Position",
1085
- type: "range",
1086
- min: -1,
1087
- max: 1,
1088
- step: .01,
1089
- noRandom: !0,
1090
- get: (e, t = 0) => q(e, t)?.offset?.x ?? 0,
1091
- set: (e, t, n = 0) => J(e, { offset: {
1092
- ...q(e, n)?.offset ?? {},
1093
- x: t
1094
- } }, n)
1095
- },
1096
- {
1097
- key: "offsetY",
1098
- label: "Y",
1099
- tab: "style",
1100
- section: "Position",
1101
- type: "range",
1102
- min: -1,
1103
- max: 1,
1104
- step: .01,
1105
- noRandom: !0,
1106
- get: (e, t = 0) => q(e, t)?.offset?.y ?? 0,
1107
- set: (e, t, n = 0) => J(e, { offset: {
1108
- ...q(e, n)?.offset ?? {},
1109
- y: t
1110
- } }, n)
1111
- },
1112
- {
1113
- key: "morphOn",
1114
- label: "Morph outlines",
1115
- tab: "style",
1116
- section: "Morph",
1117
- type: "select",
1118
- noRandom: !0,
1119
- when: Ye,
1120
- options: [{
1121
- value: "off",
1122
- label: "Off"
1123
- }, {
1124
- value: "on",
1125
- label: "On"
1126
- }],
1127
- get: (e, t = 0) => Z(e, t).on ? "on" : "off",
1128
- set: (e, t, n = 0) => Q(e, { on: t === "on" }, n)
1129
- },
1130
- {
1131
- key: "morphMode",
1132
- label: "Mode",
1133
- tab: "style",
1134
- section: "Morph",
1135
- type: "select",
1136
- when: Xe,
1137
- options: E,
1138
- get: Ze,
1139
- set: (e, t, n = 0) => Q(e, { mode: t }, n)
1140
- },
1141
- {
1142
- key: "morphFace2",
1143
- label: "Cut B face",
1144
- tab: "style",
1145
- section: "Morph",
1146
- type: "select",
1147
- noRandom: !0,
1148
- when: Qe,
1149
- options: (e, t = 0) => [{
1150
- value: "",
1151
- label: "Off"
1152
- }, ..._.filter((n) => n.value !== q(e, t)?.font)],
1153
- get: (e, t = 0) => Z(e, t).face2 ?? "",
1154
- set: (e, t, n = 0) => Q(e, { face2: t }, n)
1155
- },
1156
- {
1157
- key: "morphVf2Wdth",
1158
- label: "Cut B · Width",
1159
- tab: "style",
1160
- section: "Morph",
1161
- type: "range",
1162
- min: 64,
1163
- max: 172,
1164
- step: 1,
1165
- when: (e, t = 0) => Qe(e, t) && !Z(e, t).face2 && !!$(e, "wdth", t),
1166
- get: (e, t = 0) => Z(e, t).vf2?.wdth ?? $(e, "wdth", t)?.max ?? 172,
1167
- set: (e, t, n = 0) => $e(e, "wdth", t, n)
1168
- },
1169
- {
1170
- key: "morphVf2Wght",
1171
- label: "Cut B · Weight",
1172
- tab: "style",
1173
- section: "Morph",
1174
- type: "range",
1175
- min: 100,
1176
- max: 900,
1177
- step: 1,
1178
- when: (e, t = 0) => Qe(e, t) && !Z(e, t).face2 && !!$(e, "wght", t),
1179
- get: (e, t = 0) => Z(e, t).vf2?.wght ?? $(e, "wght", t)?.max ?? 900,
1180
- set: (e, t, n = 0) => $e(e, "wght", t, n)
1181
- },
1182
- {
1183
- key: "morphCurve",
1184
- label: "Curve",
1185
- tab: "style",
1186
- section: "Morph",
1187
- type: "select",
1188
- when: (e, t = 0) => Xe(e, t) && Ze(e, t) === "morph",
1189
- options: m,
1190
- get: (e, t = 0) => Z(e, t).curve ?? "flat",
1191
- set: (e, t, n = 0) => Q(e, { curve: t }, n)
1192
- },
1193
- rt(1, "x"),
1194
- rt(1, "y"),
1195
- rt(2, "x"),
1196
- rt(2, "y"),
1197
- {
1198
- key: "morphBlend",
1199
- label: "Blend",
1200
- tab: "style",
1201
- section: "Morph",
1202
- type: "range",
1203
- min: 0,
1204
- max: 1,
1205
- step: .01,
1206
- when: (e, t = 0) => Xe(e, t) && Ze(e, t) !== "random",
1207
- get: (e, t = 0) => Z(e, t).blend ?? .5,
1208
- set: (e, t, n = 0) => Q(e, { blend: t }, n)
1209
- },
1210
- {
1211
- key: "morphSeed",
1212
- label: "Seed",
1213
- tab: "style",
1214
- section: "Morph",
1215
- type: "range",
1216
- min: 0,
1217
- max: 1,
1218
- step: .01,
1219
- when: (e, t = 0) => Xe(e, t) && Ze(e, t) === "random",
1220
- get: (e, t = 0) => Z(e, t).blend ?? .5,
1221
- set: (e, t, n = 0) => Q(e, { blend: t }, n)
1222
- },
1223
- {
1224
- key: "mode",
1225
- label: "Motion",
1226
- tab: "anim",
1227
- type: "select",
1228
- noRandom: !0,
1229
- options: [
1230
- {
1231
- value: "none",
1232
- label: "None"
1233
- },
1234
- {
1235
- value: "march",
1236
- label: "March"
1237
- },
1238
- {
1239
- value: "orbit",
1240
- label: "Orbit"
1241
- },
1242
- {
1243
- value: "vfwave",
1244
- label: "Axis wave"
1245
- },
1246
- {
1247
- value: "glyphwave",
1248
- label: "Glyph wave"
1249
- },
1250
- {
1251
- value: "cascade",
1252
- label: "Cascade"
1253
- },
1254
- {
1255
- value: "sweep",
1256
- label: "Sweep"
1257
- },
1258
- {
1259
- value: "sweepWeight",
1260
- label: "Sweep weight"
1261
- },
1262
- {
1263
- value: "sweepShift",
1264
- label: "Sweep shift"
1265
- }
1266
- ],
1267
- get: Ge,
1268
- set: (e, t, n = 0) => We(e, { mode: t }, n)
1269
- },
1270
- {
1271
- key: "cycles",
1272
- label: "Cycles",
1273
- tab: "anim",
1274
- type: "range",
1275
- min: 1,
1276
- max: 8,
1277
- rMin: 1,
1278
- rMax: 4,
1279
- step: 1,
1280
- rMin: 1,
1281
- rMax: 3,
1282
- when: (e, t = 0) => Ge(e, t) !== "none",
1283
- get: (e, t = 0) => q(e, t)?.motion?.cycles ?? 1,
1284
- set: (e, t, n = 0) => We(e, { cycles: Math.round(t) }, n)
1285
- },
1286
- {
1287
- key: "motionAmp",
1288
- label: "Amount",
1289
- tab: "anim",
1290
- type: "range",
1291
- min: .05,
1292
- max: 1,
1293
- step: .05,
1294
- rMin: .15,
1295
- rMax: .6,
1296
- when: (e, t = 0) => [
1297
- "glyphwave",
1298
- "sweep",
1299
- "sweepWeight",
1300
- "sweepShift"
1301
- ].includes(Ge(e, t)),
1302
- get: (e, t = 0) => q(e, t)?.motion?.amp ?? .3,
1303
- set: (e, t, n = 0) => We(e, { amp: t }, n)
1304
- },
1305
- {
1306
- key: "motionPhase",
1307
- label: "Glyph phase",
1308
- tab: "anim",
1309
- type: "range",
1310
- min: 0,
1311
- max: 1.5,
1312
- step: .05,
1313
- rMin: .3,
1314
- rMax: 1,
1315
- when: (e, t = 0) => [
1316
- "vfwave",
1317
- "glyphwave",
1318
- "cascade"
1319
- ].includes(Ge(e, t)),
1320
- get: (e, t = 0) => q(e, t)?.motion?.phase ?? .5,
1321
- set: (e, t, n = 0) => We(e, { phase: t }, n)
1322
- },
1323
- {
1324
- key: "axis",
1325
- label: "Axis",
1326
- tab: "anim",
1327
- type: "select",
1328
- when: (e, t = 0) => ["vfwave", "sweepWeight"].includes(Ge(e, t)) && k(q(e, t)?.font).axes.length > 1,
1329
- options: (e, t = 0) => k(q(e, t)?.font).axes.map((e) => ({
1330
- value: e.tag,
1331
- label: x[e.tag] || e.tag
1332
- })),
1333
- get: (e, t = 0) => q(e, t)?.motion?.axis ?? "wght",
1334
- set: (e, t, n = 0) => We(e, { axis: t }, n)
1335
- },
1336
- {
1337
- key: "field",
1338
- label: "Field",
1339
- tab: "anim",
1340
- type: "select",
1341
- when: (e, t = 0) => [
1342
- "sweep",
1343
- "sweepWeight",
1344
- "sweepShift"
1345
- ].includes(Ge(e, t)),
1346
- options: [
1347
- {
1348
- value: "x",
1349
- label: "Horizontal"
1350
- },
1351
- {
1352
- value: "y",
1353
- label: "Vertical"
1354
- },
1355
- {
1356
- value: "diagonal",
1357
- label: "Diagonal"
1358
- },
1359
- {
1360
- value: "radial",
1361
- label: "Radial"
1362
- },
1363
- {
1364
- value: "angular",
1365
- label: "Angular"
1366
- },
1367
- {
1368
- value: "wave",
1369
- label: "Wave"
1370
- }
1371
- ],
1372
- get: (e, t = 0) => q(e, t)?.motion?.field ?? "x",
1373
- set: (e, t, n = 0) => We(e, { field: t }, n)
1374
- },
1375
- {
1376
- key: "stagger",
1377
- label: "Stagger",
1378
- tab: "anim",
1379
- type: "range",
1380
- min: 0,
1381
- max: 1,
1382
- step: .01,
1383
- get: (e) => q(e)?.stagger ?? 0,
1384
- set: (e, t) => Ue(e, (e, n, r) => ({
1385
- stagger: t,
1386
- phase: r > 1 ? n / r * t : 0
1387
- }))
1388
- },
1389
- {
1390
- key: "spin",
1391
- label: "Spin",
1392
- tab: "anim",
1393
- type: "range",
1394
- min: -8,
1395
- max: 8,
1396
- rMin: 0,
1397
- rMax: 4,
1398
- step: 1,
1399
- rMin: 0,
1400
- rMax: 3,
1401
- when: (e, t = 0) => X(e, t) === "radial" || X(e, t) === "rings",
1402
- get: (e, t = 0) => q(e, t)?.path?.spin ?? 1,
1403
- set: (e, t, n = 0) => Y(e, { spin: Math.round(t) }, n)
1404
- }
1405
- ], at = (e, t, n = 0) => typeof e.options == "function" ? e.options(t, n) : e.options ?? [], ot = (e, t, n = 0) => ({
1406
- min: typeof e.min == "function" ? e.min(t, n) : e.min,
1407
- max: typeof e.max == "function" ? e.max(t, n) : e.max
1408
- });
1409
- function st(e, t = 0, n = Math.random, r = null) {
1410
- let i = e;
1411
- for (let e of it) if (!(e.noRandom || e.type === "color") && !(r && !r.includes(e.tab)) && !(e.when && !e.when(i, t))) {
1412
- if (e.type === "range") {
1413
- let r = ot(e, i, t), a = e.rMin ?? r.min, o = e.rMax ?? r.max, s = e.step ?? 1, c = a + n() * (o - a);
1414
- i = e.set(i, Math.min(o, Math.max(a, Number((Math.round(c / s) * s).toFixed(4)))), t);
1415
- } else if (e.type === "select") {
1416
- let r = at(e, i, t);
1417
- r.length && (i = e.set(i, r[Math.floor(n() * r.length)].value, t));
1418
- }
1419
- }
1420
- return i;
1421
- }
1422
- var ct = (e, t) => `kin:${e}:${t}`;
1423
- function lt(e, t) {
1424
- let n = e;
1425
- for (let e in t) {
1426
- let r = /^kin:(\d+):(.+)$/.exec(e);
1427
- if (!r || typeof t[e] != "number") continue;
1428
- let i = it.find((e) => e.key === r[2]);
1429
- i?.type === "range" && (n = i.set(n, t[e], Number(r[1])));
1430
- }
1431
- return n;
1432
- }
1433
- //#endregion
1434
- //#region src/editor/compose/inspectors/KineticPanel.jsx
1435
- var ut = {
1436
- key: "morphBlend",
1437
- label: "Morph blend",
1438
- type: "range",
1439
- min: 0,
1440
- max: 1,
1441
- step: .01,
1442
- default: .5
1443
- }, dt = new Set([
1444
- "mode",
1445
- "cycles",
1446
- "motionAmp",
1447
- "motionPhase",
1448
- "axis",
1449
- "field"
1450
- ]), ft = {
1451
- mode: "glyphwave",
1452
- cycles: 1,
1453
- phase: .5,
1454
- amp: .3,
1455
- axis: "wght",
1456
- field: "x"
1457
- }, pt = new Set([
1458
- "align",
1459
- "italic",
1460
- "fill",
1461
- "fontSize",
1462
- "vfWght",
1463
- "offsetX",
1464
- "offsetY"
1465
- ]), mt = (e, t) => e ? String.fromCharCode(97 + t.indexOf(e) % 26) : null;
1466
- function ht({ layer: e, setProp: t, updateLayer: n, palette: r, renderAnimate: i, tab: o, tabStrip: c, picker: l = !0 }) {
1467
- let u = s(), d = e.comp ?? {
1468
- bg: "#0b0d12",
1469
- instances: []
1470
- }, f = d.instances ?? [], [p, m] = V(0), h = Math.min(p, Math.max(0, f.length - 1)), _ = (t) => {
1471
- m(t), window.dispatchEvent(new CustomEvent("kol:kinetic-element", { detail: {
1472
- id: e.id,
1473
- index: t,
1474
- from: "panel"
1475
- } }));
1476
- };
1477
- De(() => {
1478
- let t = (t) => {
1479
- t.detail?.id === e.id && t.detail.from === "canvas" && m(t.detail.index);
1480
- };
1481
- return window.addEventListener("kol:kinetic-element", t), () => window.removeEventListener("kol:kinetic-element", t);
1482
- }, [e.id]);
1483
- let [y, x] = V([]), C = (e) => x((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), ee = (e) => {
1484
- let t = f[e]?.group;
1485
- return t ? f.reduce((e, n, r) => n.group === t ? [...e, r] : e, []) : [e];
1486
- }, [T, E] = V(0), O = f[h]?.motions ?? [], k = Math.min(T, O.length), ne = (e) => ({
1487
- ...e,
1488
- instances: (e.instances ?? []).map((e, t) => t === h ? {
1489
- ...e,
1490
- motion: { ...e.motions?.[k - 1] ?? {} }
1491
- } : e)
1492
- }), A = (e) => dt.has(e.key) && k > 0 ? ne(d) : d, j = (t) => {
1493
- t && (n(e.id, {
1494
- presetId: t.id,
1495
- presetLabel: t.label,
1496
- comp: ie(t)
1497
- }), m(0), E(0));
1498
- }, M = (e) => t("comp", e), N = (t) => n(e.id, { comp: {
1499
- ...d,
1500
- instances: t
1501
- } }), P = (e, t) => M({
1502
- ...d,
1503
- instances: f.map((n, r) => r === e ? {
1504
- ...n,
1505
- ...t
1506
- } : n)
1507
- }), re = () => {
1508
- if (y.length < 2) return;
1509
- let e = new Set(f.map((e) => e.group).filter(Boolean)), t = 1;
1510
- for (; e.has(`g${t}`);) t++;
1511
- N(f.map((e) => y.includes(e.id) ? {
1512
- ...e,
1513
- group: `g${t}`
1514
- } : e)), x([]);
1515
- }, ae = () => {
1516
- y.length && (N(f.map((e) => y.includes(e.id) ? {
1517
- ...e,
1518
- group: null
1519
- } : e)), x([]));
1520
- }, oe = (e, t) => {
1521
- if (dt.has(e.key) && k > 0) {
1522
- let n = e.set(ne(d), t, h).instances?.[h]?.motion ?? {};
1523
- P(h, { motions: O.map((e, t) => t === k - 1 ? n : e) });
1524
- return;
1525
- }
1526
- let n = ee(h);
1527
- if (n.length > 1 && pt.has(e.key)) {
1528
- let r = d;
1529
- if (e.key === "fontSize") {
1530
- let i = Number(e.get(d, h)) || 1, a = t / i;
1531
- for (let t of n) {
1532
- let n = Number(e.get(d, t)) || i;
1533
- r = e.set(r, Math.max(8, Math.min(1200, Math.round(n * a))), t);
1534
- }
1535
- } else if (e.key === "offsetX" || e.key === "offsetY") {
1536
- let i = t - (Number(e.get(d, h)) || 0);
1537
- for (let t of n) r = e.set(r, (Number(e.get(d, t)) || 0) + i, t);
1538
- } else for (let i of n) r = e.set(r, t, i);
1539
- M(r);
1540
- return;
1541
- }
1542
- M(e.set(d, t, h));
1543
- }, I = S(e), se = (t = null) => {
1544
- let r = I.take();
1545
- n(e.id, {
1546
- comp: st(d, h, w(r >>> 0), t),
1547
- _rollSeed: r
1548
- });
1549
- }, ce = () => {
1550
- let t = I.take(), r = w(t >>> 0), i = d;
1551
- f.forEach((e, t) => {
1552
- i = st(i, t, r);
1553
- }), n(e.id, {
1554
- comp: i,
1555
- _rollSeed: t
1556
- });
1557
- }, le = () => {
1558
- let t = F.find((t) => t.id === e.presetId), n = F.filter((e) => e.id !== t?.id && (!t || e.sub === t.sub));
1559
- n.length && j(n[Math.floor(w(I.take() >>> 0)() * n.length)]);
1560
- }, ue = () => {
1561
- let e = w(I.take() >>> 0);
1562
- fe(b[Math.floor(e() * b.length)].value, e() < .5);
1563
- }, de = () => j(F.find((t) => t.id === e.presetId) ?? F[0]), fe = (t, r) => {
1564
- let i = g(t, r);
1565
- n(e.id, {
1566
- themeId: t,
1567
- themeInvert: r,
1568
- comp: {
1569
- ...d,
1570
- bg: i.bg,
1571
- instances: f.map((e) => ({
1572
- ...e,
1573
- fill: i.fg
1574
- }))
1575
- }
1576
- });
1577
- }, me = (e) => M({
1578
- ...d,
1579
- instances: f.map((t) => ({
1580
- ...t,
1581
- fill: e
1582
- }))
1583
- }), ge = o === "labs-effect" ? "style" : o, _e = it.filter((e) => e.tab === ge && (!e.when || e.when(A(e), h))), be = f.some((e) => e?.morph?.on), R = f[h];
1584
- return /* @__PURE__ */ U(ke, { children: [
1585
- c,
1586
- l && /* @__PURE__ */ H(gt, {
1587
- layer: e,
1588
- onPreset: j
1589
- }),
1590
- o === "generate" || o === "labs-effect" ? /* @__PURE__ */ U("div", {
1591
- className: "flex flex-col gap-1",
1592
- children: [
1593
- /* @__PURE__ */ H("span", {
1594
- className: "kol-eyebrow text-fg-80",
1595
- children: "Elements"
1596
- }),
1597
- /* @__PURE__ */ H(_t, {
1598
- insts: f,
1599
- idx: h,
1600
- onSelect: _,
1601
- onWrite: N,
1602
- marked: y,
1603
- onMark: C,
1604
- onGroup: re,
1605
- onUngroup: ae
1606
- }),
1607
- /* @__PURE__ */ H(z, {
1608
- label: "Edit elements on the canvas (click to select, drag to move, corners to scale)",
1609
- children: /* @__PURE__ */ H(L, {
1610
- "aria-label": "Edit elements on the canvas (click to select, drag to move, corners to scale)",
1611
- tone: "primary",
1612
- size: u,
1613
- className: "w-full",
1614
- onClick: () => window.dispatchEvent(new CustomEvent("kol:kinetic-edit", { detail: {
1615
- id: e.id,
1616
- index: h
1617
- } })),
1618
- children: "Edit on canvas"
1619
- })
1620
- })
1621
- ]
1622
- }) : f.length > 1 && /* @__PURE__ */ U("span", {
1623
- className: "kol-helper-12 text-meta truncate",
1624
- children: [
1625
- "Element ",
1626
- h + 1,
1627
- " · ",
1628
- R?.text || "—"
1629
- ]
1630
- }),
1631
- (o === "generate" || o === "labs-effect") && /* @__PURE__ */ U(ke, { children: [
1632
- /* @__PURE__ */ H(he, {
1633
- label: "TEXT",
1634
- children: /* @__PURE__ */ H(xe, {
1635
- variant: "filled",
1636
- size: u,
1637
- rows: 2,
1638
- axis: "y",
1639
- value: f[h]?.text ?? "",
1640
- onChange: (e) => P(h, { text: e.target.value })
1641
- })
1642
- }),
1643
- /* @__PURE__ */ U("div", {
1644
- className: "flex flex-col gap-2",
1645
- children: [/* @__PURE__ */ H(ye, {
1646
- label: "Theme",
1647
- align: "fill",
1648
- labelWidth: a,
1649
- children: /* @__PURE__ */ H(pe, {
1650
- variant: "subtle",
1651
- size: u,
1652
- className: "w-full",
1653
- options: b,
1654
- value: e.themeId ?? "kol",
1655
- onChange: (t) => fe(t, !!e.themeInvert)
1656
- })
1657
- }), /* @__PURE__ */ H(ye, {
1658
- label: "Invert",
1659
- align: "fill",
1660
- labelWidth: a,
1661
- children: /* @__PURE__ */ H(ve, {
1662
- size: u,
1663
- className: "w-full",
1664
- options: [{
1665
- value: "off",
1666
- label: "Off"
1667
- }, {
1668
- value: "on",
1669
- label: "On"
1670
- }],
1671
- value: e.themeInvert ? "on" : "off",
1672
- onChange: (t) => fe(e.themeId ?? "kol", t === "on")
1673
- })
1674
- })]
1675
- }),
1676
- /* @__PURE__ */ H(v, {
1677
- inline: !0,
1678
- label: "Text color",
1679
- value: f[0]?.fill,
1680
- onChange: (e) => me(D(e, r) ?? e),
1681
- palette: r
1682
- }),
1683
- /* @__PURE__ */ H(L, {
1684
- tone: "primary",
1685
- size: u,
1686
- className: "w-full",
1687
- onClick: le,
1688
- children: "Randomize preset"
1689
- }),
1690
- /* @__PURE__ */ U("div", {
1691
- className: "flex gap-2",
1692
- children: [/* @__PURE__ */ H(L, {
1693
- tone: "primary",
1694
- size: u,
1695
- className: "flex-1 min-w-0",
1696
- onClick: () => se(),
1697
- children: "Randomize all"
1698
- }), /* @__PURE__ */ H(z, {
1699
- label: "Reset to defaults",
1700
- children: /* @__PURE__ */ H(L, {
1701
- tone: "primary",
1702
- size: u,
1703
- iconOnly: "refresh",
1704
- "aria-label": "Reset to defaults",
1705
- onClick: de,
1706
- className: "shrink-0"
1707
- })
1708
- })]
1709
- }),
1710
- /* @__PURE__ */ U("div", {
1711
- className: "grid grid-cols-2 gap-2",
1712
- children: [
1713
- /* @__PURE__ */ H(L, {
1714
- tone: "primary",
1715
- size: u,
1716
- onClick: ue,
1717
- children: "Color"
1718
- }),
1719
- /* @__PURE__ */ H(L, {
1720
- tone: "primary",
1721
- size: u,
1722
- onClick: () => se(["style"]),
1723
- children: "Type"
1724
- }),
1725
- /* @__PURE__ */ H(L, {
1726
- tone: "primary",
1727
- size: u,
1728
- onClick: () => se(["anim"]),
1729
- children: "Motion"
1730
- }),
1731
- /* @__PURE__ */ H(L, {
1732
- tone: "primary",
1733
- size: u,
1734
- onClick: ce,
1735
- children: "All elements"
1736
- })
1737
- ]
1738
- }),
1739
- /* @__PURE__ */ H(te, { seed: I })
1740
- ] }),
1741
- o === "anim" && /* @__PURE__ */ H(yt, {
1742
- motions: O,
1743
- mIdx: k,
1744
- onSelect: E,
1745
- onAdd: () => {
1746
- N(f.map((e, t) => t === h ? {
1747
- ...e,
1748
- motions: [...O, { ...ft }]
1749
- } : e)), E(O.length + 1);
1750
- },
1751
- onRemove: () => {
1752
- k !== 0 && (N(f.map((e, t) => t === h ? {
1753
- ...e,
1754
- motions: O.filter((e, t) => t !== k - 1)
1755
- } : e)), E(k - 1));
1756
- }
1757
- }),
1758
- o !== "generate" && _e.map((n, a) => /* @__PURE__ */ U(Ee, { children: [
1759
- n.key === "arrangement" && /* @__PURE__ */ U(ke, { children: [/* @__PURE__ */ H("span", {
1760
- className: "kol-eyebrow text-fg-80",
1761
- children: "OpenType"
1762
- }), /* @__PURE__ */ H(bt, {
1763
- value: R?.opentype ?? {},
1764
- onToggle: (e, t) => P(h, { opentype: {
1765
- ...R?.opentype ?? {},
1766
- [e]: t
1767
- } })
1768
- })] }),
1769
- n.section && n.section !== _e[a - 1]?.section && /* @__PURE__ */ H("span", {
1770
- className: "kol-eyebrow text-fg-80",
1771
- children: n.section
1772
- }),
1773
- /* @__PURE__ */ H(vt, {
1774
- knob: n,
1775
- comp: A(n),
1776
- idx: h,
1777
- palette: r,
1778
- onWrite: oe,
1779
- bridge: dt.has(n.key) && k > 0 ? null : {
1780
- layer: e,
1781
- setProp: t,
1782
- renderAnimate: i,
1783
- key: ct(h, n.key)
1784
- }
1785
- }),
1786
- n.key === "showPath" && R?.path?.type === "custom" && /* @__PURE__ */ H(xt, {
1787
- inst: R,
1788
- layer: e,
1789
- onPoints: (e) => P(h, { path: {
1790
- ...R?.path ?? {},
1791
- points: e
1792
- } })
1793
- })
1794
- ] }, n.key)),
1795
- o === "anim" && be && /* @__PURE__ */ H(St, {
1796
- layer: e,
1797
- setProp: t,
1798
- insts: f,
1799
- renderAnimate: i
1800
- })
1801
- ] });
1802
- }
1803
- function gt({ layer: e, onPreset: t }) {
1804
- return /* @__PURE__ */ H(ne, {
1805
- tree: ue,
1806
- presets: F,
1807
- current: F.find((t) => t.id === e.presetId) ?? F[0],
1808
- onPick: t,
1809
- inline: !0
1810
- });
1811
- }
1812
- function _t({ insts: e, idx: t, onSelect: n, onWrite: r, marked: i, onMark: a, onGroup: o, onUngroup: c }) {
1813
- let l = s(), u = () => {
1814
- let t = e.length;
1815
- for (; e.some((e) => e.id === `i${t}`);) t++;
1816
- return `i${t}`;
1817
- }, d = () => {
1818
- let i = {
1819
- id: u(),
1820
- text: "Text"
1821
- };
1822
- e[t]?.fill && (i.fill = e[t].fill), r([...e, j(i, e.length)]), n(e.length);
1823
- }, f = (t) => {
1824
- let i = {
1825
- ...structuredClone(e[t]),
1826
- id: u()
1827
- }, a = [...e];
1828
- a.splice(t + 1, 0, i), r(a), n(t + 1);
1829
- }, p = (t) => {
1830
- e.length <= 1 || (r(e.filter((e, n) => n !== t)), n(Math.min(t, e.length - 2)));
1831
- }, m = (i) => {
1832
- let a = t + i;
1833
- if (a < 0 || a >= e.length) return;
1834
- let o = [...e], [s] = o.splice(t, 1);
1835
- o.splice(a, 0, s), r(o), n(a);
1836
- }, h = [...new Set(e.map((e) => e.group).filter(Boolean))];
1837
- return /* @__PURE__ */ U(ke, { children: [
1838
- /* @__PURE__ */ H("div", {
1839
- className: "flex flex-col gap-1",
1840
- children: e.map((r, o) => {
1841
- let s = mt(r.group, h);
1842
- return /* @__PURE__ */ U("div", {
1843
- onClick: () => n(o),
1844
- className: `flex items-center gap-2 pl-2 pr-1 py-1 rounded cursor-pointer kol-helper-12 ${o === t ? "bg-oq-08 text-emphasis" : "text-body hover:bg-oq-04 hover:text-emphasis"}`,
1845
- children: [
1846
- /* @__PURE__ */ H("span", {
1847
- onClick: (e) => e.stopPropagation(),
1848
- className: "shrink-0",
1849
- style: { lineHeight: 0 },
1850
- children: /* @__PURE__ */ H(R, {
1851
- checked: i.includes(r.id),
1852
- onChange: () => a(r.id)
1853
- })
1854
- }),
1855
- /* @__PURE__ */ H("span", {
1856
- className: "kol-helper-10 text-meta shrink-0",
1857
- children: o + 1
1858
- }),
1859
- /* @__PURE__ */ H("span", {
1860
- className: "truncate flex-1 min-w-0",
1861
- children: r.text || "—"
1862
- }),
1863
- s && /* @__PURE__ */ U("span", {
1864
- className: "shrink-0 kol-helper-10 text-meta",
1865
- children: ["grp ", s]
1866
- }),
1867
- /* @__PURE__ */ H(z, {
1868
- label: "Duplicate element",
1869
- children: /* @__PURE__ */ H(L, {
1870
- tone: "ghost",
1871
- size: l,
1872
- quiet: !0,
1873
- iconOnly: "copy",
1874
- iconSize: 12,
1875
- "aria-label": "Duplicate element",
1876
- onClick: (e) => {
1877
- e.stopPropagation(), f(o);
1878
- }
1879
- })
1880
- }),
1881
- /* @__PURE__ */ H("span", {
1882
- className: e.length <= 1 ? "invisible pointer-events-none" : "contents",
1883
- "aria-hidden": e.length <= 1 || void 0,
1884
- children: /* @__PURE__ */ H(z, {
1885
- label: "Delete element",
1886
- children: /* @__PURE__ */ H(L, {
1887
- tone: "ghost",
1888
- size: l,
1889
- quiet: !0,
1890
- iconOnly: "x",
1891
- iconSize: 10,
1892
- "aria-label": "Delete element",
1893
- onClick: (e) => {
1894
- e.stopPropagation(), p(o);
1895
- }
1896
- })
1897
- })
1898
- })
1899
- ]
1900
- }, r.id ?? o);
1901
- })
1902
- }),
1903
- i.length > 0 && /* @__PURE__ */ U("div", {
1904
- className: "grid grid-cols-2 gap-1",
1905
- children: [i.length >= 2 && /* @__PURE__ */ H(L, {
1906
- tone: "primary",
1907
- size: l,
1908
- onClick: o,
1909
- children: "Group"
1910
- }), /* @__PURE__ */ H(L, {
1911
- tone: "primary",
1912
- size: l,
1913
- onClick: c,
1914
- children: "Ungroup"
1915
- })]
1916
- }),
1917
- /* @__PURE__ */ U("div", {
1918
- className: "flex items-center gap-1",
1919
- children: [
1920
- /* @__PURE__ */ H(L, {
1921
- tone: "primary",
1922
- size: l,
1923
- className: "flex-1",
1924
- iconLeft: "plus",
1925
- iconSize: 12,
1926
- onClick: d,
1927
- children: "Add element"
1928
- }),
1929
- /* @__PURE__ */ H("span", {
1930
- className: t <= 0 ? "invisible pointer-events-none" : "contents",
1931
- "aria-hidden": t <= 0 || void 0,
1932
- children: /* @__PURE__ */ H(z, {
1933
- label: "Move element up",
1934
- children: /* @__PURE__ */ H(L, {
1935
- tone: "ghost",
1936
- size: l,
1937
- quiet: !0,
1938
- iconOnly: "chevron-down",
1939
- className: "rotate-180",
1940
- "aria-label": "Move element up",
1941
- onClick: () => m(-1)
1942
- })
1943
- })
1944
- }),
1945
- /* @__PURE__ */ H("span", {
1946
- className: t >= e.length - 1 ? "invisible pointer-events-none" : "contents",
1947
- "aria-hidden": t >= e.length - 1 || void 0,
1948
- children: /* @__PURE__ */ H(z, {
1949
- label: "Move element down",
1950
- children: /* @__PURE__ */ H(L, {
1951
- tone: "ghost",
1952
- size: l,
1953
- quiet: !0,
1954
- iconOnly: "chevron-down",
1955
- "aria-label": "Move element down",
1956
- onClick: () => m(1)
1957
- })
1958
- })
1959
- })
1960
- ]
1961
- })
1962
- ] });
1963
- }
1964
- function vt({ knob: e, comp: t, idx: r, palette: i, onWrite: o, bridge: c }) {
1965
- let l = s(), u = e.get(t, r), d = (t) => o(e, t);
1966
- if (e.type === "color") return /* @__PURE__ */ H(v, {
1967
- label: e.label,
1968
- value: u,
1969
- onChange: (e) => d(D(e, i) ?? e),
1970
- palette: i,
1971
- inline: !0
1972
- });
1973
- if (e.type === "select") return /* @__PURE__ */ H(ye, {
1974
- label: e.label,
1975
- align: "fill",
1976
- labelWidth: a,
1977
- children: /* @__PURE__ */ H(pe, {
1978
- variant: "subtle",
1979
- size: l,
1980
- className: "w-full",
1981
- options: at(e, t, r),
1982
- value: u,
1983
- onChange: d
1984
- })
1985
- });
1986
- let { min: f, max: p } = ot(e, t, r), m = c && c.layer[c.key], h = n(m), g = typeof m == "number" ? m : u, _ = typeof m == "number" ? (e) => c.setProp(c.key, e) : d;
1987
- return /* @__PURE__ */ H(ye, {
1988
- label: e.label,
1989
- align: "fill",
1990
- labelWidth: a,
1991
- children: /* @__PURE__ */ U("div", {
1992
- className: "flex flex-1 items-center gap-2",
1993
- children: [/* @__PURE__ */ H("div", {
1994
- className: "flex-1 min-w-0",
1995
- children: h ? /* @__PURE__ */ H("div", {
1996
- className: "kol-helper-12 text-meta italic px-1",
1997
- children: "animated"
1998
- }) : /* @__PURE__ */ H(be, {
1999
- min: f,
2000
- max: p,
2001
- step: e.step ?? 1,
2002
- value: typeof g == "number" ? g : f,
2003
- onChange: _,
2004
- displayWidth: String(p).length,
2005
- className: "flex-1"
2006
- })
2007
- }), c?.renderAnimate?.({
2008
- key: c.key,
2009
- label: e.label,
2010
- type: "range",
2011
- min: f,
2012
- max: p,
2013
- step: e.step ?? 1,
2014
- default: typeof u == "number" ? u : f
2015
- })]
2016
- })
2017
- });
2018
- }
2019
- function yt({ motions: e, mIdx: t, onSelect: n, onAdd: r, onRemove: i }) {
2020
- let a = s(), o = [{
2021
- value: "0",
2022
- label: "1"
2023
- }, ...e.map((e, t) => ({
2024
- value: String(t + 1),
2025
- label: String(t + 2)
2026
- }))];
2027
- return /* @__PURE__ */ U("div", {
2028
- className: "flex flex-col gap-1",
2029
- children: [/* @__PURE__ */ H("span", {
2030
- className: "kol-eyebrow text-fg-80",
2031
- children: "Motion layers"
2032
- }), /* @__PURE__ */ U("div", {
2033
- className: "flex items-center gap-1",
2034
- children: [
2035
- /* @__PURE__ */ H("div", {
2036
- className: "flex-1 min-w-0",
2037
- children: /* @__PURE__ */ H(ve, {
2038
- size: a,
2039
- value: String(t),
2040
- onChange: (e) => n(Number(e)),
2041
- options: o
2042
- })
2043
- }),
2044
- /* @__PURE__ */ H(z, {
2045
- label: "Add motion layer",
2046
- children: /* @__PURE__ */ H(L, {
2047
- tone: "ghost",
2048
- size: a,
2049
- quiet: !0,
2050
- iconOnly: "plus",
2051
- iconSize: 12,
2052
- "aria-label": "Add motion layer",
2053
- onClick: r
2054
- })
2055
- }),
2056
- /* @__PURE__ */ H("span", {
2057
- className: t === 0 ? "invisible pointer-events-none" : "contents",
2058
- "aria-hidden": t === 0 || void 0,
2059
- children: /* @__PURE__ */ H(z, {
2060
- label: "Delete motion layer (the primary can only be set to None)",
2061
- children: /* @__PURE__ */ H(L, {
2062
- tone: "ghost",
2063
- size: a,
2064
- quiet: !0,
2065
- iconOnly: "x",
2066
- iconSize: 10,
2067
- "aria-label": "Delete motion layer",
2068
- onClick: i
2069
- })
2070
- })
2071
- })
2072
- ]
2073
- })]
2074
- });
2075
- }
2076
- function bt({ value: e = {}, onToggle: t }) {
2077
- let n = s(), [r, i] = V(!1), a = Te({
2078
- open: r,
2079
- onOpenChange: i,
2080
- placement: "bottom-start",
2081
- offset: -1,
2082
- flip: !1,
2083
- matchReferenceWidth: !0,
2084
- role: "listbox"
2085
- }), o = Le.filter((t) => e[t.tag]).length;
2086
- return /* @__PURE__ */ U("div", {
2087
- className: "relative w-full",
2088
- children: [/* @__PURE__ */ H(L, {
2089
- ref: a.refs.setReference,
2090
- ...a.getReferenceProps(),
2091
- tone: "primary",
2092
- size: n,
2093
- className: "w-full justify-between",
2094
- iconRight: "chevron-down",
2095
- "aria-haspopup": "listbox",
2096
- "aria-expanded": r,
2097
- children: o ? `${o} feature${o > 1 ? "s" : ""}` : "None"
2098
- }), /* @__PURE__ */ H(_e, {
2099
- popover: a,
2100
- panel: !1,
2101
- focus: !1,
2102
- style: {
2103
- backgroundColor: "var(--kol-surface-secondary)",
2104
- color: "var(--kol-surface-on-primary)",
2105
- borderRadius: "0 0 4px 4px",
2106
- zIndex: "var(--kol-z-dropdown)"
2107
- },
2108
- children: /* @__PURE__ */ H("div", {
2109
- className: "flex max-h-[300px] flex-col items-stretch overflow-y-auto",
2110
- role: "listbox",
2111
- children: Le.map((n) => /* @__PURE__ */ H(ge, {
2112
- onClick: () => t(n.tag, !e[n.tag]),
2113
- shortcut: e[n.tag] ? /* @__PURE__ */ H(Ae, {
2114
- name: "check",
2115
- size: 11
2116
- }) : void 0,
2117
- children: n.label
2118
- }, n.tag))
2119
- })
2120
- })]
2121
- });
2122
- }
2123
- function xt({ inst: e, layer: t, onPoints: n }) {
2124
- let r = s(), i = e?.path?.points, a = Array.isArray(i) && i.length >= 2 ? i : N, o = t.w > 0 && t.h > 0 ? t.w / t.h : 1;
2125
- return /* @__PURE__ */ U("div", {
2126
- className: "flex flex-col gap-2",
2127
- children: [/* @__PURE__ */ H(fe, {
2128
- value: a.map(([e, t]) => ({
2129
- x: e,
2130
- y: t
2131
- })),
2132
- onChange: (e) => n(e.map((e) => [Number(e.x.toFixed(3)), Number(e.y.toFixed(3))])),
2133
- aspect: o,
2134
- size: r,
2135
- minPoints: 2,
2136
- ariaLabel: "Custom path points"
2137
- }), /* @__PURE__ */ U("div", {
2138
- className: "grid grid-cols-2 gap-2",
2139
- children: [/* @__PURE__ */ H(L, {
2140
- tone: "primary",
2141
- size: r,
2142
- onClick: () => n([...a, [.5, .5]]),
2143
- children: "Add point"
2144
- }), a.length > 2 && /* @__PURE__ */ H(L, {
2145
- tone: "primary",
2146
- size: r,
2147
- onClick: () => n(a.slice(0, -1)),
2148
- children: "Remove point"
2149
- })]
2150
- })]
2151
- });
2152
- }
2153
- function St({ layer: e, setProp: t, insts: r, renderAnimate: i }) {
2154
- let o = ut, s = e[o.key], c = n(s), l = r.find((e) => e?.morph?.on)?.morph?.blend ?? o.default, u = typeof s == "number" ? s : l, d = c ? /* @__PURE__ */ H("div", {
2155
- className: "kol-helper-12 text-meta italic px-1",
2156
- children: "animated"
2157
- }) : /* @__PURE__ */ H(be, {
2158
- min: o.min,
2159
- max: o.max,
2160
- step: o.step,
2161
- value: u,
2162
- onChange: (e) => t(o.key, e)
2163
- });
2164
- return /* @__PURE__ */ H(ye, {
2165
- label: o.label,
2166
- align: "fill",
2167
- labelWidth: a,
2168
- children: /* @__PURE__ */ U("div", {
2169
- className: "flex flex-1 items-center gap-2",
2170
- children: [/* @__PURE__ */ H("div", {
2171
- className: "flex-1 min-w-0",
2172
- children: d
2173
- }), i(o)]
2174
- })
2175
- });
2176
- }
2177
- //#endregion
2178
- //#region src/editor/params/Timeline.jsx
2179
- var Ct = 268, wt = 14, Tt = 25, Et = [
2180
- 1,
2181
- 2,
2182
- 4
2183
- ], Dt = 96;
2184
- function Ot(e, t) {
2185
- if (e.length === 0) return 0;
2186
- if (t <= e[0].t) return e[0].v;
2187
- let n = e[e.length - 1];
2188
- if (t >= n.t) return n.v;
2189
- let r = 0;
2190
- for (; r < e.length - 1 && e[r + 1].t <= t;) r++;
2191
- let i = e[r], a = e[r + 1];
2192
- if (typeof i.v != "number" || typeof a.v != "number") return i.v;
2193
- let o = a.t - i.t || 1;
2194
- return i.v + (a.v - i.v) * ((t - i.t) / o);
2195
- }
2196
- function kt(e, t = []) {
2197
- for (let r of e) {
2198
- let e = Array.isArray(r.morph?.steps) ? r.morph.steps : null;
2199
- if (e?.length) {
2200
- let i = r.morph.name || "Morph", a = (t) => t.map((t) => e[(Math.round(t.v) % e.length + e.length) % e.length]?.label ?? ""), o = n(r.morphT) && r.morphT.bind === "track" ? r.morphT : null, s = o ? o.keys : oe(e.map((e, t) => t), r.morph.cycle ?? "loop", r.morph.curve ?? "in-out");
2201
- t.push({
2202
- id: `${r.id}:morph`,
2203
- layerId: r.id,
2204
- key: "morphT",
2205
- label: i,
2206
- keys: s,
2207
- header: !0,
2208
- readOnly: !o,
2209
- names: a(s),
2210
- steps: e.length
2211
- });
2212
- }
2213
- for (let i in r) {
2214
- if (i === "morphT" && e?.length) continue;
2215
- let a = r[i];
2216
- n(a) && a.bind === "track" && t.push({
2217
- id: `${r.id}:${i}`,
2218
- layerId: r.id,
2219
- key: i,
2220
- label: `${de(r)} · ${i}`,
2221
- keys: a.keys,
2222
- under: e?.length ? `${r.id}:morph` : null
2223
- });
2224
- }
2225
- Array.isArray(r.children) && kt(r.children, t);
2226
- }
2227
- return t;
2228
- }
2229
- function At(e, t = []) {
2230
- for (let n of e) t.push(n), Array.isArray(n.children) && At(n.children, t);
2231
- return t;
2232
- }
2233
- var jt = (e) => Object.values(e).some((e) => n(e) && e.bind === "mod" && String(e.source).startsWith("audio")), Mt = {
2234
- background: "square",
2235
- pattern: "ptrn-dot",
2236
- photo: "image",
2237
- shape: "rectangle",
2238
- text: "type",
2239
- group: "layers",
2240
- bool: "layers",
2241
- loop: "refresh",
2242
- misc: "refresh",
2243
- kinetic: "type"
2244
- }, Nt = (e) => Mt[e] ?? "rectangle", Pt = (e, t) => `${(e * t).toFixed(2)}`, Ft = (e) => `${String(Math.floor(e)).padStart(2, "0")}:${String(Math.floor(e % 1 * 100)).padStart(2, "0")}`;
2245
- function It({ name: e, label: t, on: n = !0, toggle: r = !1, size: i = 14, onClick: a, disabled: o, className: s = "" }) {
2246
- return /* @__PURE__ */ H(z, {
2247
- label: t,
2248
- variant: "float",
2249
- asChild: !0,
2250
- children: /* @__PURE__ */ H("button", {
2251
- type: "button",
2252
- "aria-label": t,
2253
- "aria-pressed": r ? n : void 0,
2254
- disabled: o,
2255
- onClick: a,
2256
- className: `flex items-center justify-center shrink-0 rounded cursor-pointer outline-none focus-visible:shadow-[var(--kol-float-focus)] disabled:opacity-40 disabled:cursor-default ${n ? "text-oq-96" : "text-oq-48"} ${s}`.trim(),
2257
- children: /* @__PURE__ */ H(Ae, {
2258
- name: e,
2259
- size: i
2260
- })
2261
- })
2262
- });
2263
- }
2264
- function Lt({ track: e, view: t, selected: n, setSelected: r, writeKeys: i, lit: a }) {
2265
- let o = B(null), s = B(null), [, c] = V(0), l = !!e.header, u = !!e.readOnly, { X: d, fracFromEvent: f } = t, p = (t) => n && n.trackId === e.id && n.index === t, m = (t) => {
2266
- if (t.target.closest("[data-diamond]") || t.target.closest("[data-name]") || u) return;
2267
- let n = f(t, o.current), a = Ot(e.keys, n), s = [...e.keys, {
2268
- t: n,
2269
- v: a,
2270
- easing: "linear"
2271
- }].sort((e, t) => e.t - t.t);
2272
- i(e, s), r({
2273
- trackId: e.id,
2274
- index: s.findIndex((e) => e.t === n)
2275
- });
2276
- }, h = (t) => (n) => {
2277
- if (n.stopPropagation(), !u) {
2278
- if (n.altKey) {
2279
- e.keys.length > 1 && (i(e, e.keys.filter((e, n) => n !== t)), r(null));
2280
- return;
2281
- }
2282
- n.currentTarget.setPointerCapture(n.pointerId), s.current = {
2283
- index: t,
2284
- t: e.keys[t].t
2285
- }, r({
2286
- trackId: e.id,
2287
- index: t
2288
- });
2289
- }
2290
- }, g = (e) => (t) => {
2291
- !s.current || s.current.index !== e || (s.current.t = f(t, o.current), c((e) => e + 1));
2292
- }, _ = (t) => () => {
2293
- if (!s.current || s.current.index !== t) return;
2294
- let n = {
2295
- ...e.keys[t],
2296
- t: s.current.t
2297
- };
2298
- if (s.current = null, n.t === e.keys[t].t) return;
2299
- let a = e.keys.map((e, r) => r === t ? n : e).sort((e, t) => e.t - t.t);
2300
- i(e, a), r({
2301
- trackId: e.id,
2302
- index: a.indexOf(n)
2303
- });
2304
- }, v = (t) => (n) => {
2305
- n.stopPropagation(), se({ editRequest: (Math.round(e.keys[t].v) % e.steps + e.steps) % e.steps });
2306
- };
2307
- return /* @__PURE__ */ U("div", {
2308
- ref: o,
2309
- className: `relative flex-1 min-w-0 overflow-hidden rounded-[5px] bg-[var(--kol-float-well)] ${u ? "" : "cursor-copy"}`,
2310
- style: { height: Tt },
2311
- onPointerDown: m,
2312
- children: [
2313
- /* @__PURE__ */ H(Rt, {
2314
- view: t,
2315
- lit: a,
2316
- label: e.label
2317
- }),
2318
- e.keys.map((n, r) => {
2319
- let i = s.current?.index === r ? s.current.t : n.t, a = l ? e.names?.[r] : null;
2320
- return /* @__PURE__ */ H(z, {
2321
- label: l ? `${a} · ${Pt(i, t.loop)} s` : `${Pt(i, t.loop)} s · v=${typeof n.v == "number" ? Math.round(n.v * 100) / 100 : n.v} (alt-click deletes)`,
2322
- variant: "float",
2323
- asChild: !0,
2324
- children: /* @__PURE__ */ H("span", {
2325
- "data-diamond": "",
2326
- onPointerDown: h(r),
2327
- onPointerMove: g(r),
2328
- onPointerUp: _(r),
2329
- className: `absolute top-1/2 -translate-x-1/2 -translate-y-1/2 flex ${u ? "" : "cursor-grab"} ${p(r) ? "text-[var(--kol-accent-primary)]" : "text-oq-96"}`,
2330
- style: { left: `clamp(6px, ${d(i) * 100}%, 100% - 6px)` },
2331
- children: /* @__PURE__ */ H(Ae, {
2332
- name: "diamond",
2333
- size: 12
2334
- })
2335
- })
2336
- }, r);
2337
- }),
2338
- l && e.keys.map((t, n) => {
2339
- let r = s.current?.index === n ? s.current.t : t.t, i = n === e.keys.length - 1 && r > .5;
2340
- return /* @__PURE__ */ H("button", {
2341
- type: "button",
2342
- "data-name": "",
2343
- onPointerDown: (e) => e.stopPropagation(),
2344
- onClick: v(n),
2345
- "aria-label": `Edit step ${e.names?.[n]}`,
2346
- className: "absolute top-0 bottom-0 kol-float-label text-fg-64 hover:text-emphasis truncate cursor-pointer",
2347
- style: {
2348
- left: i ? void 0 : `calc(${d(r) * 100}% + 10px)`,
2349
- right: i ? `calc(${(1 - d(r)) * 100}% + 10px)` : void 0,
2350
- maxWidth: `${100 / e.keys.length}%`
2351
- },
2352
- children: e.names?.[n]
2353
- }, `n${n}`);
2354
- })
2355
- ]
2356
- });
2357
- }
2358
- function Rt({ view: e, lit: t, label: n, mono: r = !1, children: i }) {
2359
- let a = e.X(0), o = e.X(1);
2360
- return /* @__PURE__ */ U("div", {
2361
- className: `absolute top-0.5 h-[21px] rounded ${t ? "bg-fg-16" : "bg-fg-08"}`,
2362
- style: {
2363
- left: `${a * 100}%`,
2364
- width: `${(o - a) * 100}%`
2365
- },
2366
- children: [/* @__PURE__ */ H("span", {
2367
- className: `absolute left-2.5 top-1/2 -translate-y-1/2 ${r ? "kol-float-ruler" : "kol-float-label"} text-fg-64 whitespace-nowrap pointer-events-none`,
2368
- children: n
2369
- }), i]
2370
- });
2371
- }
2372
- function zt({ view: e, lit: t }) {
2373
- return /* @__PURE__ */ H("div", {
2374
- className: "relative flex-1 min-w-0 overflow-hidden rounded-[5px] bg-[var(--kol-float-well)]",
2375
- style: { height: Tt },
2376
- children: /* @__PURE__ */ H(Rt, {
2377
- view: e,
2378
- lit: t,
2379
- label: `${e.loop.toFixed(2)} s`,
2380
- mono: !0
2381
- })
2382
- });
2383
- }
2384
- function Bt({ view: e, lit: t, label: n, wave: r }) {
2385
- return /* @__PURE__ */ H("div", {
2386
- className: "relative flex-1 min-w-0 overflow-hidden rounded-[5px] bg-[var(--kol-float-well)]",
2387
- style: { height: Tt },
2388
- children: /* @__PURE__ */ H(Rt, {
2389
- view: e,
2390
- lit: t,
2391
- label: n,
2392
- children: /* @__PURE__ */ H("span", {
2393
- className: "absolute top-0 bottom-0 left-[120px] right-2.5",
2394
- "aria-hidden": "true",
2395
- children: r.map((e, t) => /* @__PURE__ */ H("span", {
2396
- className: "absolute top-1/2 -translate-y-1/2 w-0.5 bg-oq-40",
2397
- style: {
2398
- left: `${t / Dt * 100}%`,
2399
- height: 2 + Math.round(e * 10)
2400
- }
2401
- }, t))
2402
- })
2403
- })
2404
- });
2405
- }
2406
- function Vt({ layer: e, name: t, sub: n, lit: r, select: i, toggleLayer: a, toggleLayerLock: o, fold: s }) {
2407
- return /* @__PURE__ */ U("div", {
2408
- className: `flex items-center gap-2.5 shrink-0 px-2 rounded-md ${r ? "bg-fg-16" : ""} ${e ? "cursor-pointer" : ""}`,
2409
- style: {
2410
- width: Ct,
2411
- height: Tt,
2412
- paddingLeft: n ? 32 : void 0
2413
- },
2414
- onClick: e ? () => i(e.id) : void 0,
2415
- children: [
2416
- !n && /* @__PURE__ */ H("span", {
2417
- className: "flex shrink-0 text-oq-64",
2418
- "aria-hidden": "true",
2419
- children: /* @__PURE__ */ H(Ae, {
2420
- name: e ? Nt(e.type) : "layers",
2421
- size: 14
2422
- })
2423
- }),
2424
- /* @__PURE__ */ H("span", {
2425
- className: `kol-float-label truncate flex-1 min-w-0 ${n ? "text-fg-64" : "text-emphasis"}`,
2426
- children: t
2427
- }),
2428
- s && /* @__PURE__ */ H(It, {
2429
- name: "chevron-down",
2430
- size: 12,
2431
- label: s.folded ? "Show the morph’s tracks" : "Hide the morph’s tracks",
2432
- onClick: (e) => {
2433
- e.stopPropagation(), s.toggle();
2434
- },
2435
- className: s.folded ? "-rotate-90" : ""
2436
- }),
2437
- e && !n && /* @__PURE__ */ U(ke, { children: [/* @__PURE__ */ H(It, {
2438
- name: e.visible === !1 ? "eye-off" : "eye-on",
2439
- size: 12,
2440
- label: e.visible === !1 ? "Show layer" : "Hide layer",
2441
- toggle: !0,
2442
- on: e.visible !== !1,
2443
- onClick: (t) => {
2444
- t.stopPropagation(), a(e.id);
2445
- }
2446
- }), /* @__PURE__ */ H(It, {
2447
- name: e.locked ? "lock" : "unlock",
2448
- size: 12,
2449
- label: e.locked ? "Unlock layer" : "Lock layer",
2450
- toggle: !0,
2451
- on: !!e.locked,
2452
- onClick: (t) => {
2453
- t.stopPropagation(), o(e.id);
2454
- }
2455
- })] })
2456
- ]
2457
- });
2458
- }
2459
- function Ht({ view: e, seek: t }) {
2460
- let n = B(null), r = B(!1), i = Math.ceil(e.origin - 1e-9), a = Math.floor(e.origin + e.span + 1e-9), o = Array.from({ length: Math.max(0, a - i + 1) }, (e, t) => i + t), s = (r) => t(e.fracFromEvent(r, n.current));
2461
- return /* @__PURE__ */ U("div", {
2462
- className: "flex items-center shrink-0",
2463
- style: {
2464
- height: 15,
2465
- gap: wt
2466
- },
2467
- children: [/* @__PURE__ */ H("span", {
2468
- className: "kol-float-label leading-none text-meta shrink-0",
2469
- style: { width: Ct },
2470
- children: "LAYERS"
2471
- }), /* @__PURE__ */ H("div", {
2472
- ref: n,
2473
- className: "relative flex-1 min-w-0 h-full kol-float-ruler text-meta cursor-ew-resize",
2474
- style: { touchAction: "none" },
2475
- onPointerDown: (e) => {
2476
- r.current = !0, e.currentTarget.setPointerCapture(e.pointerId), s(e);
2477
- },
2478
- onPointerMove: (e) => {
2479
- r.current && s(e);
2480
- },
2481
- onPointerUp: () => {
2482
- r.current = !1;
2483
- },
2484
- onPointerCancel: () => {
2485
- r.current = !1;
2486
- },
2487
- children: o.map((t) => {
2488
- let n = (t - e.origin) / e.span;
2489
- return /* @__PURE__ */ H("span", {
2490
- className: "absolute top-0 leading-[15px] whitespace-nowrap",
2491
- style: {
2492
- left: `${n * 100}%`,
2493
- transform: n <= 0 ? void 0 : n >= 1 ? "translateX(-100%)" : "translateX(-50%)"
2494
- },
2495
- children: e.span <= 16 || t % 4 == 0 ? `${String(t).padStart(2, "0")}s` : ""
2496
- }, t);
2497
- })
2498
- })]
2499
- });
2500
- }
2501
- function Ut({ view: e, now: t }) {
2502
- let n = e.X(t / e.loop);
2503
- return n < 0 || n > 1 ? null : /* @__PURE__ */ U("div", {
2504
- "aria-hidden": "true",
2505
- className: "absolute pointer-events-none",
2506
- style: {
2507
- left: `calc(282px + (100% - 282px) * ${n})`,
2508
- top: -1,
2509
- bottom: 0
2510
- },
2511
- children: [/* @__PURE__ */ H("span", { className: "absolute top-0 bottom-0 w-px bg-fg-96" }), /* @__PURE__ */ H("span", {
2512
- className: "absolute -top-3 -translate-x-1/2 flex items-center justify-center h-4 w-[43px] rounded kol-float-ruler leading-none bg-[var(--kol-surface-on-primary)] text-[var(--kol-surface-primary)]",
2513
- children: Ft(t)
2514
- })]
2515
- });
2516
- }
2517
- var Wt = (e) => Array.isArray(e) ? e : l[e] ?? null, Gt = 132, Kt = 14;
2518
- function qt({ track: e, writeKeys: t, selected: n, setSelected: r }) {
2519
- let i = B(null), [a, o] = V(0), [s, c] = V(null), u = B(null);
2520
- De(() => {
2521
- let e = i.current;
2522
- if (!e) return;
2523
- let t = new ResizeObserver(([e]) => o(e.contentRect.width));
2524
- return t.observe(e), () => t.disconnect();
2525
- }, []);
2526
- let d = s ?? e.keys, f = d.map((e) => e.v), p = Math.min(...f), m = Math.max(...f);
2527
- u.current?.range && ([p, m] = u.current.range), m - p < 1e-9 && (--p, m += 1);
2528
- let h = (e) => e * a, g = (e) => Kt + (1 - (e - p) / (m - p)) * (Gt - 2 * Kt), _ = (e) => {
2529
- let t = i.current.getBoundingClientRect();
2530
- return {
2531
- t: Math.min(1, Math.max(0, (e.clientX - t.left) / t.width)),
2532
- v: p + (1 - (e.clientY - t.top - Kt) / (Gt - 2 * Kt)) * (m - p)
2533
- };
2534
- }, v = d.slice(0, -1).map((e, t) => ({
2535
- i: t,
2536
- a: e,
2537
- b: d[t + 1],
2538
- bez: e.easing === "hold" ? null : Wt(e.easing ?? "linear") ?? l.linear
2539
- })), y = (t, n) => (i) => {
2540
- i.stopPropagation(), i.currentTarget.setPointerCapture(i.pointerId), u.current = {
2541
- kind: t,
2542
- i: n,
2543
- range: [p, m],
2544
- moved: !1
2545
- }, t === "key" && r({
2546
- trackId: e.id,
2547
- index: n
2548
- });
2549
- }, b = (e) => {
2550
- let t = u.current;
2551
- if (!t) return;
2552
- t.moved = !0;
2553
- let n = _(e), r = d.map((e) => ({ ...e }));
2554
- if (t.kind === "key") {
2555
- let e = r[t.i - 1]?.t ?? 0, i = r[t.i + 1]?.t ?? 1;
2556
- r[t.i].t = Math.min(i, Math.max(e, n.t)), r[t.i].v = n.v;
2557
- } else {
2558
- let e = r[t.i], i = r[t.i + 1], a = i.t - e.t || 1e-6, o = Math.abs(i.v - e.v) > 1e-9 ? i.v - e.v : m - p, s = Math.min(1, Math.max(0, (n.t - e.t) / a)), c = (n.v - e.v) / o, u = [...Wt(e.easing ?? "linear") ?? l.linear];
2559
- t.kind === "out" ? (u[0] = s, u[1] = c) : (u[2] = s, u[3] = c), e.easing = u.map((e) => Math.round(e * 1e3) / 1e3);
2560
- }
2561
- c(r);
2562
- }, x = () => {
2563
- let n = u.current;
2564
- if (u.current = null, n?.moved && s) {
2565
- let i = s[n.i];
2566
- t(e, s), n.kind === "key" && r({
2567
- trackId: e.id,
2568
- index: [...s].sort((e, t) => e.t - t.t).indexOf(i)
2569
- });
2570
- }
2571
- c(null);
2572
- }, S = n?.trackId === e.id ? n.index : -1, C = (e, t, n, r, i, a) => /* @__PURE__ */ U("g", { children: [/* @__PURE__ */ H("line", {
2573
- x1: n,
2574
- y1: r,
2575
- x2: e,
2576
- y2: t,
2577
- stroke: "var(--kol-accent-primary)",
2578
- strokeWidth: 1
2579
- }), /* @__PURE__ */ H("circle", {
2580
- cx: e,
2581
- cy: t,
2582
- r: 4,
2583
- fill: "var(--kol-surface-primary)",
2584
- stroke: "var(--kol-accent-primary)",
2585
- strokeWidth: 1.5,
2586
- style: { cursor: "grab" },
2587
- onPointerDown: y(i, a),
2588
- onPointerMove: b,
2589
- onPointerUp: x,
2590
- onPointerCancel: x
2591
- })] }, `${i}${a}`);
2592
- return /* @__PURE__ */ U("div", {
2593
- className: "flex items-stretch",
2594
- style: { gap: wt },
2595
- children: [/* @__PURE__ */ U("span", {
2596
- className: "shrink-0 flex flex-col justify-between items-end kol-float-ruler text-meta py-2",
2597
- style: { width: Ct },
2598
- children: [/* @__PURE__ */ H("span", { children: Math.round(m * 100) / 100 }), /* @__PURE__ */ H("span", { children: Math.round(p * 100) / 100 })]
2599
- }), /* @__PURE__ */ H("div", {
2600
- ref: i,
2601
- className: "relative flex-1 rounded-[5px] bg-[var(--kol-float-well)]",
2602
- style: {
2603
- height: Gt,
2604
- touchAction: "none"
2605
- },
2606
- children: a > 0 && /* @__PURE__ */ U("svg", {
2607
- width: a,
2608
- height: Gt,
2609
- className: "absolute inset-0 overflow-visible",
2610
- children: [
2611
- v.map(({ i: e, a: t, b: n, bez: r }) => r ? /* @__PURE__ */ H("path", {
2612
- d: `M ${h(t.t)} ${g(t.v)} C ${h(t.t + r[0] * (n.t - t.t))} ${g(t.v + r[1] * (n.v - t.v))}, ${h(t.t + r[2] * (n.t - t.t))} ${g(t.v + r[3] * (n.v - t.v))}, ${h(n.t)} ${g(n.v)}`,
2613
- fill: "none",
2614
- stroke: "var(--kol-fg-emphasis)",
2615
- strokeWidth: 1.5
2616
- }, `s${e}`) : /* @__PURE__ */ H("path", {
2617
- d: `M ${h(t.t)} ${g(t.v)} H ${h(n.t)} V ${g(n.v)}`,
2618
- fill: "none",
2619
- stroke: "var(--kol-fg-emphasis)",
2620
- strokeWidth: 1.5,
2621
- strokeDasharray: "3 3"
2622
- }, `s${e}`)),
2623
- v.filter(({ i: e, bez: t }) => t && (e === S || e + 1 === S)).map(({ i: e, a: t, b: n, bez: r }) => {
2624
- let i = Math.abs(n.v - t.v) > 1e-9 ? n.v - t.v : m - p;
2625
- return [e === S ? C(h(t.t + r[0] * (n.t - t.t)), g(t.v + r[1] * i), h(t.t), g(t.v), "out", e) : null, e + 1 === S ? C(h(t.t + r[2] * (n.t - t.t)), g(t.v + r[3] * i), h(n.t), g(n.v), "in", e) : null];
2626
- }),
2627
- d.map((e, t) => /* @__PURE__ */ H("rect", {
2628
- x: h(e.t) - 4.5,
2629
- y: g(e.v) - 4.5,
2630
- width: 9,
2631
- height: 9,
2632
- rx: 1.5,
2633
- transform: `rotate(45 ${h(e.t)} ${g(e.v)})`,
2634
- fill: t === S ? "var(--kol-accent-primary)" : "var(--kol-fg-emphasis)",
2635
- style: { cursor: "grab" },
2636
- onPointerDown: y("key", t),
2637
- onPointerMove: b,
2638
- onPointerUp: x,
2639
- onPointerCancel: x
2640
- }, `k${t}`))
2641
- ]
2642
- })
2643
- })]
2644
- });
2645
- }
2646
- var Jt = [...f, {
2647
- value: "custom",
2648
- label: "Custom"
2649
- }];
2650
- function Yt({ tracks: e, selected: t, setSelected: n, writeKeys: r, len: i }) {
2651
- if (!t) return null;
2652
- let a = e.find((e) => e.id === t.trackId), o = a?.keys[t.index];
2653
- if (!o || a.readOnly) return null;
2654
- let s = (e) => {
2655
- r(a, a.keys.map((n, r) => r === t.index ? {
2656
- ...n,
2657
- ...e
2658
- } : n));
2659
- }, c = typeof o.v == "number", u = Array.isArray(o.easing) ? "custom" : o.easing ?? "linear";
2660
- return /* @__PURE__ */ H("div", {
2661
- className: "flex items-start gap-3 pt-1",
2662
- children: /* @__PURE__ */ U("div", {
2663
- className: "flex items-center gap-2 flex-wrap min-w-0 flex-1",
2664
- children: [
2665
- /* @__PURE__ */ U("span", {
2666
- className: "kol-float-label text-meta shrink-0",
2667
- children: [
2668
- "key @ ",
2669
- Pt(o.t, i),
2670
- " s"
2671
- ]
2672
- }),
2673
- !a.header && /* @__PURE__ */ H(me, {
2674
- variant: "float",
2675
- size: "sm",
2676
- chars: 7,
2677
- type: c ? "number" : "text",
2678
- value: String(o.v),
2679
- onChange: (e) => s({ v: c ? Number(e.target.value) || 0 : e.target.value })
2680
- }),
2681
- /* @__PURE__ */ H(pe, {
2682
- variant: "subtle",
2683
- size: "sm",
2684
- options: Jt,
2685
- value: u,
2686
- onChange: (e) => s({ easing: e === "custom" ? [...Wt(o.easing) ?? l["in-out"]] : e })
2687
- }),
2688
- /* @__PURE__ */ H(L, {
2689
- variant: "float",
2690
- tone: "ghost",
2691
- size: "sm",
2692
- onClick: () => {
2693
- a.keys.length > 1 && r(a, a.keys.filter((e, n) => n !== t.index)), n(null);
2694
- },
2695
- children: "Delete key"
2696
- }),
2697
- /* @__PURE__ */ H(L, {
2698
- variant: "float",
2699
- tone: "ghost",
2700
- size: "sm",
2701
- className: "ml-auto",
2702
- onClick: () => n(null),
2703
- children: "Close"
2704
- })
2705
- ]
2706
- })
2707
- });
2708
- }
2709
- var Xt = "kol-fxr:dock-h", Zt = 128, Qt = 480, $t = () => {
2710
- try {
2711
- let e = Number(localStorage.getItem(Xt));
2712
- return e >= Zt ? e : null;
2713
- } catch {
2714
- return null;
2715
- }
2716
- };
2717
- function en({ onDrag: e, onEnd: t, onReset: n }) {
2718
- let r = B(null), i = B(null), [a, o] = V(!1);
2719
- return we(r, { axis: "x" }), /* @__PURE__ */ H("div", {
2720
- ref: r,
2721
- className: `kol-timeline-grab ${a ? "is-dragging" : ""}`.trim(),
2722
- role: "separator",
2723
- "aria-orientation": "horizontal",
2724
- "aria-label": "Resize the timeline",
2725
- onPointerDown: (e) => {
2726
- e.preventDefault(), e.currentTarget.setPointerCapture(e.pointerId), i.current = e.clientY, o(!0);
2727
- },
2728
- onPointerMove: (t) => {
2729
- i.current != null && e(i.current - t.clientY);
2730
- },
2731
- onPointerUp: (e) => {
2732
- e.currentTarget.releasePointerCapture(e.pointerId), i.current = null, o(!1), t?.();
2733
- },
2734
- onPointerCancel: () => {
2735
- i.current = null, o(!1), t?.();
2736
- },
2737
- onDoubleClick: n
2738
- });
2739
- }
2740
- function tn() {
2741
- let { layers: e } = o(), t = ae(), n = ce();
2742
- return Oe(() => kt(e).length > 0, [e]) || !!t.active || n;
2743
- }
2744
- function nn({ surface: e = "solid" }) {
2745
- let { layers: t, updateLayer: n, selectedIds: r, select: i, toggleLayer: a, toggleLayerLock: s, currentPresetName: c } = o(), { t: l, loopSeconds: u, seek: d } = O(), f = ae(), p = ce(), m = Oe(() => kt(t), [t]), h = Oe(() => f.active && !m.some((e) => e.header) ? [{
2746
- id: "morph:empty",
2747
- layerId: null,
2748
- key: "morphT",
2749
- label: f.fileName || "Morph",
2750
- keys: [],
2751
- header: !0,
2752
- readOnly: !0,
2753
- names: [],
2754
- steps: 0
2755
- }, ...m] : m, [
2756
- m,
2757
- f.active,
2758
- f.fileName
2759
- ]), [g, _] = V(null), [v, y] = V(() => /* @__PURE__ */ new Set()), [b, x] = V(1), [S, w] = V($t), T = B(null);
2760
- De(() => {
2761
- try {
2762
- S ? localStorage.setItem(Xt, String(S)) : localStorage.removeItem(Xt);
2763
- } catch {}
2764
- }, [S]);
2765
- let E = B(Array(Dt).fill(0)), D = Oe(() => At(t), [t]);
2766
- if (D.some(jt) && (E.current.push(ee().level), E.current.shift()), h.length === 0 && !p) return null;
2767
- let te = l * u, k = u / b, ne = b === 1 ? 0 : Math.min(Math.max(0, te - k / 2), u - k), A = {
2768
- loop: u,
2769
- origin: ne,
2770
- span: k,
2771
- X: (e) => (e * u - ne) / k,
2772
- fracFromEvent: (e, t) => {
2773
- let n = t.getBoundingClientRect(), r = ne + Math.min(1, Math.max(0, (e.clientX - n.left) / n.width)) * k;
2774
- return Math.min(1, Math.max(0, r / u));
2775
- }
2776
- }, j = !!C.clock.state.looping, M = (e, t) => {
2777
- let r = [...t].sort((e, t) => e.t - t.t);
2778
- n(e.layerId, { [e.key]: {
2779
- bind: "track",
2780
- keys: r
2781
- } });
2782
- }, N = (e) => y((t) => {
2783
- let n = new Set(t);
2784
- return n.has(e) ? n.delete(e) : n.add(e), n;
2785
- }), P = g && h.find((e) => e.id === g.trackId) || h.find((e) => r.includes(e.layerId) && !e.readOnly) || null, re = () => {
2786
- if (!P) return;
2787
- let e = [...P.keys, {
2788
- t: l,
2789
- v: Ot(P.keys, l),
2790
- easing: "linear"
2791
- }].sort((e, t) => e.t - t.t);
2792
- M(P, e), _({
2793
- trackId: P.id,
2794
- index: e.findIndex((e) => e.t === l)
2795
- });
2796
- }, ie = /* @__PURE__ */ new Map();
2797
- for (let e of h) {
2798
- let t = ie.get(e.layerId) ?? [];
2799
- t.push(e), ie.set(e.layerId, t);
2800
- }
2801
- let F = [];
2802
- for (let e of D) {
2803
- let t = ie.get(e.id) ?? [];
2804
- t.length === 0 ? F.push({
2805
- id: e.id,
2806
- layer: e,
2807
- kind: jt(e) ? "wave" : "clip"
2808
- }) : t.forEach((t, n) => F.push({
2809
- id: t.id,
2810
- layer: e,
2811
- track: t,
2812
- sub: n > 0
2813
- }));
2814
- }
2815
- for (let e of ie.get(null) ?? []) F.push({
2816
- id: e.id,
2817
- layer: null,
2818
- track: e
2819
- });
2820
- let oe = F.filter((e) => !(e.track?.under && v.has(e.track.under))), I = (e) => !!e && r.includes(e.id), se = !!(g && h.find((e) => e.id === g.trackId && !e.header && !e.readOnly));
2821
- return /* @__PURE__ */ U("div", {
2822
- className: "kol-timeline-dock relative p-3 select-none",
2823
- style: {
2824
- height: S ?? void 0,
2825
- maxHeight: S ? void 0 : Qt
2826
- },
2827
- children: [/* @__PURE__ */ H(en, {
2828
- onDrag: (e) => {
2829
- T.current ??= S ?? 0, w(Math.min(Qt, Math.max(Zt, (T.current || 222) + e)));
2830
- },
2831
- onEnd: () => {
2832
- T.current = null;
2833
- },
2834
- onReset: () => w(null)
2835
- }), /* @__PURE__ */ U("div", {
2836
- className: `kol-timeline flex flex-col gap-2 p-3 h-full min-h-0 ${Se(e, !0)}`,
2837
- style: { borderRadius: "var(--kol-float-menu-r)" },
2838
- children: [
2839
- /* @__PURE__ */ U("div", {
2840
- className: "flex items-center justify-between h-6 shrink-0",
2841
- children: [/* @__PURE__ */ U("div", {
2842
- className: "flex items-center gap-3.5",
2843
- children: [
2844
- /* @__PURE__ */ H("span", {
2845
- className: "flex text-oq-96",
2846
- "aria-hidden": "true",
2847
- children: /* @__PURE__ */ H(Ae, {
2848
- name: "layers",
2849
- size: 14
2850
- })
2851
- }),
2852
- /* @__PURE__ */ H("span", {
2853
- className: "kol-float-panel text-emphasis whitespace-nowrap",
2854
- children: c || "Untitled"
2855
- }),
2856
- /* @__PURE__ */ U("span", {
2857
- className: "kol-float-label text-meta whitespace-nowrap",
2858
- children: [
2859
- D.length,
2860
- " ",
2861
- D.length === 1 ? "layer" : "layers"
2862
- ]
2863
- }),
2864
- /* @__PURE__ */ H(It, {
2865
- name: "plus",
2866
- label: "Add a key at the head",
2867
- disabled: !P,
2868
- onClick: re
2869
- })
2870
- ]
2871
- }), /* @__PURE__ */ U("div", {
2872
- className: "flex items-center gap-[18px]",
2873
- children: [
2874
- /* @__PURE__ */ H("span", {
2875
- className: "kol-float-label text-fg-64",
2876
- children: se ? "Curve" : "Keyframes"
2877
- }),
2878
- /* @__PURE__ */ H(It, {
2879
- name: "overlap",
2880
- label: j ? "Loop off" : "Loop on",
2881
- toggle: !0,
2882
- on: j,
2883
- onClick: () => C.clock.set({ looping: !j })
2884
- }),
2885
- /* @__PURE__ */ H(It, {
2886
- name: "cap-round",
2887
- label: "Fit the loop",
2888
- on: b !== 1,
2889
- onClick: () => x(1)
2890
- }),
2891
- /* @__PURE__ */ H(z, {
2892
- label: "Zoom the lanes",
2893
- variant: "float",
2894
- asChild: !0,
2895
- children: /* @__PURE__ */ U("button", {
2896
- type: "button",
2897
- onClick: () => x(Et[(Et.indexOf(b) + 1) % Et.length]),
2898
- className: "kol-float-timecode text-emphasis leading-none cursor-pointer rounded outline-none focus-visible:shadow-[var(--kol-float-focus)]",
2899
- children: [b * 100, "%"]
2900
- })
2901
- }),
2902
- /* @__PURE__ */ H(It, {
2903
- name: "nav-create",
2904
- label: S ? "Fit the timeline to its lanes" : "Expand the timeline",
2905
- on: !!S,
2906
- onClick: () => w(S ? null : Qt)
2907
- })
2908
- ]
2909
- })]
2910
- }),
2911
- /* @__PURE__ */ U("div", {
2912
- className: "relative flex flex-col gap-2 min-h-0",
2913
- children: [
2914
- /* @__PURE__ */ H(Ht, {
2915
- view: A,
2916
- seek: d
2917
- }),
2918
- /* @__PURE__ */ H("div", {
2919
- className: "flex flex-col gap-1 min-h-0 overflow-y-auto",
2920
- children: oe.map((e) => /* @__PURE__ */ U(Ee, { children: [/* @__PURE__ */ U("div", {
2921
- className: "flex items-start shrink-0",
2922
- style: {
2923
- gap: wt,
2924
- height: Tt
2925
- },
2926
- children: [/* @__PURE__ */ H(Vt, {
2927
- layer: e.layer,
2928
- sub: e.sub,
2929
- lit: I(e.layer),
2930
- name: e.sub ? e.track.key : e.layer ? de(e.layer) : e.track.label,
2931
- select: i,
2932
- toggleLayer: a,
2933
- toggleLayerLock: s,
2934
- fold: e.track?.header && h.some((t) => t.under === e.track.id) ? {
2935
- folded: v.has(e.track.id),
2936
- toggle: () => N(e.track.id)
2937
- } : null
2938
- }), e.track ? /* @__PURE__ */ H(Lt, {
2939
- track: e.track,
2940
- view: A,
2941
- selected: g,
2942
- setSelected: _,
2943
- writeKeys: M,
2944
- lit: I(e.layer) || g?.trackId === e.track.id
2945
- }) : e.kind === "wave" ? /* @__PURE__ */ H(Bt, {
2946
- view: A,
2947
- lit: I(e.layer),
2948
- label: `${de(e.layer)} · audio`,
2949
- wave: E.current
2950
- }) : /* @__PURE__ */ H(zt, {
2951
- view: A,
2952
- lit: I(e.layer)
2953
- })]
2954
- }), e.track && g?.trackId === e.track.id && !e.track.header && !e.track.readOnly && e.track.keys.every((e) => typeof e.v == "number") && /* @__PURE__ */ H(qt, {
2955
- track: e.track,
2956
- writeKeys: M,
2957
- selected: g,
2958
- setSelected: _
2959
- })] }, e.id))
2960
- }),
2961
- /* @__PURE__ */ H(Ut, {
2962
- view: A,
2963
- now: te
2964
- })
2965
- ]
2966
- }),
2967
- /* @__PURE__ */ H(Yt, {
2968
- tracks: h,
2969
- selected: g,
2970
- setSelected: _,
2971
- writeKeys: M,
2972
- len: u
2973
- })
2974
- ]
2975
- })]
2976
- });
2977
- }
2978
- //#endregion
2979
- //#region src/editor/params/TransportBar.jsx
2980
- function rn({ seconds: e, onCommit: t, size: n }) {
2981
- let r = String(e), [i, a] = V(r), [o, s] = V(!1);
2982
- return De(() => {
2983
- o || a(r);
2984
- }, [r, o]), /* @__PURE__ */ H(z, {
2985
- label: "Loop length",
2986
- triggerClassName: "flex w-full",
2987
- children: /* @__PURE__ */ H(me, {
2988
- type: "text",
2989
- inputMode: "decimal",
2990
- variant: "property",
2991
- size: n,
2992
- affordance: "Loop /",
2993
- unit: "s",
2994
- chars: 3,
2995
- "aria-label": "Loop length in seconds",
2996
- value: i,
2997
- onFocus: (e) => {
2998
- s(!0), e.target.select();
2999
- },
3000
- onChange: (e) => a(e.target.value),
3001
- onBlur: () => {
3002
- s(!1);
3003
- let e = Number(i.trim());
3004
- if (i.trim() === "" || !Number.isFinite(e)) {
3005
- a(r);
3006
- return;
3007
- }
3008
- t(e);
3009
- },
3010
- onKeyDown: (e) => {
3011
- e.key === "Enter" && e.currentTarget.blur(), e.key === "Escape" && (a(r), s(!1), e.currentTarget.blur());
3012
- },
3013
- className: "justify-center",
3014
- inputClassName: "text-center"
3015
- })
3016
- });
3017
- }
3018
- var an = (e, t) => /* @__PURE__ */ H(Ae, {
3019
- name: e,
3020
- size: Ce(t, !0)
3021
- }), on = {
3022
- sm: "shrink-0 [&_.kol-seg-cell]:flex-none [&_.kol-seg-cell]:px-0 [&_.kol-seg-cell]:w-[var(--kol-ctl-sm)]",
3023
- md: "shrink-0 [&_.kol-seg-cell]:flex-none [&_.kol-seg-cell]:px-0 [&_.kol-seg-cell]:w-[var(--kol-ctl-md)]",
3024
- lg: "shrink-0 [&_.kol-seg-cell]:flex-none [&_.kol-seg-cell]:px-0 [&_.kol-seg-cell]:w-[var(--kol-ctl-lg)]"
3025
- };
3026
- function sn({ size: e = "sm" }) {
3027
- let { playing: t, loopSeconds: n, play: r, pause: i, stop: a, rewind: o, setLoopSeconds: s } = O();
3028
- return /* @__PURE__ */ U("div", {
3029
- className: "flex items-center gap-2",
3030
- children: [
3031
- /* @__PURE__ */ H(ve, {
3032
- size: e,
3033
- ariaLabel: "Playback",
3034
- value: t ? "play" : "pause",
3035
- className: on[e],
3036
- onChange: (e) => e === "play" ? r() : i(),
3037
- options: [{
3038
- value: "play",
3039
- ariaLabel: "Play",
3040
- tooltip: "Play (Space)",
3041
- label: an("play", e)
3042
- }, {
3043
- value: "pause",
3044
- ariaLabel: "Pause",
3045
- tooltip: "Pause (Space)",
3046
- label: an("pause", e)
3047
- }]
3048
- }),
3049
- /* @__PURE__ */ H("div", {
3050
- className: "flex-1 min-w-0",
3051
- children: /* @__PURE__ */ H(rn, {
3052
- seconds: n,
3053
- onCommit: s,
3054
- size: e
3055
- })
3056
- }),
3057
- /* @__PURE__ */ H(ve, {
3058
- size: e,
3059
- ariaLabel: "Reset",
3060
- value: null,
3061
- className: on[e],
3062
- onChange: (e) => e === "stop" ? a() : o(),
3063
- options: [{
3064
- value: "stop",
3065
- ariaLabel: "Stop",
3066
- label: an("stop", e)
3067
- }, {
3068
- value: "rewind",
3069
- ariaLabel: "Rewind",
3070
- label: an("rewind", e)
3071
- }]
3072
- })
3073
- ]
3074
- });
3075
- }
3076
- //#endregion
3077
- //#region src/packs/motion.js
3078
- var cn = {
3079
- layerTypes: ["kinetic"],
3080
- kineticPresetById: re,
3081
- presetComp: ie,
3082
- KINETIC_TREE: ue,
3083
- KINETIC_PRESETS: F,
3084
- KineticType: He,
3085
- applyKnobBridges: lt,
3086
- loadFonts: i,
3087
- warmFontCss: p,
3088
- kineticFontCss: y,
3089
- KineticPanel: ht,
3090
- TimelineDock: nn,
3091
- useTimelineUp: tn,
3092
- TransportBar: sn
3093
- };
3094
- c("motion", cn);
3095
- //#endregion
3096
- export { st as i, nn as n, ht as r, cn as t };