@kolkrabbi/design-editor 0.46.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{BindDot-B0VcuOag.js → BindDot-Cx-M0iQt.js} +9 -8
  2. package/dist/{BufferResource-BfLgK37S.js → BufferResource-Di5teicy.js} +2 -2
  3. package/dist/{CanvasPool-YNSF8hsR.js → CanvasPool-JdLj49b-.js} +1 -1
  4. package/dist/CanvasRenderer-fXDObOOi.js +2 -0
  5. package/dist/{FederatedEventTarget-BJgROaRQ.js → FederatedEventTarget-CH0bzxx1.js} +1 -1
  6. package/dist/{FilterSystem-BUrPNXx-.js → FilterSystem-C-ZoyuTO.js} +3 -3
  7. package/dist/{Geometry-C5s5KpWq.js → Geometry-D4tiuMOr.js} +1 -1
  8. package/dist/KolboxView-BjYfn_tl.js +21615 -0
  9. package/dist/{RenderTargetSystem-oFwWv5IW.js → RenderTargetSystem-Bom_vhlS.js} +1 -1
  10. package/dist/{Timeline-Ck1rBV8S.js → Timeline-CRr43b4B.js} +49 -53
  11. package/dist/TreePicker-DXsAlHK6.js +209 -0
  12. package/dist/WebGLRenderer-4hvrGmfW.js +2 -0
  13. package/dist/WebGPURenderer-BjzMV7Pg.js +2 -0
  14. package/dist/__vite-browser-external-y2xWjzgx.js +780 -0
  15. package/dist/browserAll-BFE0MRLW.js +6 -0
  16. package/dist/{canvasUtils-BoNfkAod.js → canvasUtils-DUNsu3ct.js} +1 -1
  17. package/dist/{core-BBb9Tk4Q.js → core-BbKj9Svq.js} +5877 -8206
  18. package/dist/core.js +6 -5
  19. package/dist/design-editor.css +2 -1
  20. package/dist/design-editor.js +7 -3644
  21. package/dist/{effectCategories-Ccye-8LP.js → effectCategories-wHY9ih8L.js} +8966 -4985
  22. package/dist/effects-D7J0e5xl.js +447 -0
  23. package/dist/effects.js +1 -1
  24. package/dist/{generators-BdVXv0jY.js → generators-BtRZ3Stj.js} +2473 -2538
  25. package/dist/generators.js +1 -1
  26. package/dist/{getTextureBatchBindGroup-CNWhZRbV.js → getTextureBatchBindGroup-ZMqkwiZS.js} +1 -1
  27. package/dist/{host-meUhieO9.js → host-0qv2SCjk.js} +1 -1
  28. package/dist/{host-9pJ7NvnR.js → host-II9SeVCH.js} +50 -50
  29. package/dist/init-DkGhdexn.js +4 -0
  30. package/dist/kolbox-sheet.js +0 -0
  31. package/dist/kolbox.css +3 -0
  32. package/dist/{morphStore-D6mkLJ-8.js → morphStore-s-rjCe-y.js} +1 -1
  33. package/dist/{motion-wsc6Qd7S.js → motion-CKtZAccJ.js} +765 -762
  34. package/dist/motion.js +1 -1
  35. package/dist/{pipeline-CMpuPUaX.js → pipeline-hZsOKbHd.js} +12 -12
  36. package/dist/{previewScale-SYKvfhUm.js → previewScale-C6EBx--U.js} +8 -8
  37. package/dist/{rolls-KpWCAeDv.js → rolls-Cnu6g8th.js} +10671 -4810
  38. package/dist/src-3UkpFoNW.js +3430 -0
  39. package/dist/{src-B5o6fGRJ.js → src-D-TQbBo2.js} +1 -2
  40. package/dist/{store-iBb0I6hk.js → store-YIW6P2zN.js} +289 -269
  41. package/dist/useLayerEdit-W_Tf3adq.js +455 -0
  42. package/dist/webworkerAll-0WBQ2FBr.js +2 -0
  43. package/package.json +16 -13
  44. package/dist/CanvasRenderer-Bl0rlqNq.js +0 -2
  45. package/dist/TreePicker-Dv0zpJwe.js +0 -166
  46. package/dist/WebGLRenderer-CXxpVIx3.js +0 -2
  47. package/dist/WebGPURenderer-BwLEUYBa.js +0 -2
  48. package/dist/browserAll-CAzdTUbR.js +0 -6
  49. package/dist/chunk-3b4jIN3o.js +0 -13
  50. package/dist/effects-B47bpwGh.js +0 -447
  51. package/dist/init-jApIMi04.js +0 -4
  52. package/dist/useLayerEdit-Ba7RA6qX.js +0 -454
  53. package/dist/webworkerAll-DEZhpG90.js +0 -2
@@ -0,0 +1,3430 @@
1
+ import { C as e, E as t, T as n, d as r, o as i, s as a, u as o, w as s } from "./__vite-browser-external-y2xWjzgx.js";
2
+ import { $t as c, B as l, D as u, F as d, Gn as f, I as p, In as m, J as h, Kn as g, L as _, Mr as v, P as y, Xn as b, Xt as x, Zn as S, a as C, bn as w, bt as T, d as E, en as D, er as O, f as k, i as A, j, n as M, o as N, p as P, qn as F, r as ee } from "./rolls-Cnu6g8th.js";
3
+ import { n as I, r as L, t as R } from "./useLayerEdit-W_Tf3adq.js";
4
+ import { C as te, D as z, E as B, _ as V, a as H, c as U, d as ne, f as W, g as re, i as ie, l as ae, m as oe, n as se, r as ce, t as le, u as ue, v as G, w as de, x as K, y as fe } from "./effectCategories-wHY9ih8L.js";
5
+ import { r as pe } from "./TreePicker-DXsAlHK6.js";
6
+ import { A as me, F as he, I as ge, M as _e, P as ve, R as ye, V as be, _ as xe, g as Se, h as Ce, j as we, v as Te, x as Ee, y as De, z as Oe } from "./generators-BtRZ3Stj.js";
7
+ import { b as ke, u as Ae } from "./store-YIW6P2zN.js";
8
+ import { a as je, c as Me, d as Ne, f as Pe, i as Fe, l as Ie, n as Le, o as Re, p as ze, r as Be, s as q, t as Ve, u as He } from "./morphStore-s-rjCe-y.js";
9
+ import { n as Ue, r as We, t as Ge } from "./BindDot-Cx-M0iQt.js";
10
+ import { n as Ke, r as qe } from "./effects-D7J0e5xl.js";
11
+ import { c as Je, d as Ye, l as Xe, n as Ze, o as Qe } from "./motion-CKtZAccJ.js";
12
+ import { t as $e } from "./Timeline-CRr43b4B.js";
13
+ import { Ct as et, H as tt, I as nt, K as rt, M as it, Mt as at, N as ot, Nt as st, O as ct, Qt as lt, V as ut, X as dt, _n as ft, _t as pt, c as mt, cn as ht, ct as gt, d as _t, en as vt, h as yt, hn as bt, ht as xt, in as St, j as Ct, jt as wt, l as Tt, m as Et, mn as Dt, nn as Ot, on as kt, ot as At, p as jt, pn as Mt, rn as Nt, s as Pt, sn as Ft, t as It, tn as Lt, u as Rt, un as zt, v as Bt, wt as Vt, xt as Ht } from "./core-BbKj9Svq.js";
14
+ import { Button as J, ButtonGroup as Ut, Divider as Wt, MultiSelect as Gt, StepList as Kt, Tag as qt, Tooltip as Jt, useGrabEdge as Yt, useModal as Xt } from "@kolkrabbi/kol-component";
15
+ import { Suspense as Zt, createContext as Qt, lazy as $t, useContext as en, useEffect as Y, useRef as X, useState as Z, useSyncExternalStore as tn } from "react";
16
+ import { Fragment as nn, jsx as Q, jsxs as $ } from "react/jsx-runtime";
17
+ import { IconLoader as rn } from "@kolkrabbi/kol-icons";
18
+ import { useDragResize as an, useTheme as on } from "@kolkrabbi/kol-framework";
19
+ import { createPortal as sn } from "react-dom";
20
+ //#region src/editor/kolbox/host.js
21
+ var cn = {
22
+ client: null,
23
+ store: () => null,
24
+ account: null
25
+ };
26
+ function ln(e) {
27
+ let t = cn.account;
28
+ Object.assign(cn, e), "account" in e && e.account !== t && queueMicrotask(() => window.dispatchEvent(new CustomEvent("kolbox:account")));
29
+ }
30
+ var un = () => cn.client, dn = (e) => cn.store(e), fn = () => cn.account, pn = (e) => {
31
+ let t = e, n = /* @__PURE__ */ new Set(), r = (e) => (n.add(e), () => n.delete(e));
32
+ return {
33
+ set: (e) => {
34
+ e !== t && (t = e, n.forEach((e) => e()));
35
+ },
36
+ use: () => tn(r, () => t, () => t)
37
+ };
38
+ }, mn = pn(null), hn = pn(null), gn = mn.set;
39
+ mn.use, hn.set;
40
+ var _n = hn.use, vn = [
41
+ {
42
+ id: "shape",
43
+ label: "Shape",
44
+ icon: "line-circle"
45
+ },
46
+ {
47
+ id: "blend",
48
+ label: "Blend",
49
+ icon: "shaper-scurve"
50
+ },
51
+ {
52
+ id: "crossfade",
53
+ label: "Crossfade",
54
+ icon: "dashed-circle"
55
+ }
56
+ ], yn = {
57
+ shape: [
58
+ ["Loops", ["morph-circle", "star-morph"]],
59
+ ["Loops", [
60
+ "square-circle",
61
+ "blob",
62
+ "lissajous"
63
+ ]],
64
+ ["Loops", [
65
+ "morph-circle",
66
+ "star-morph",
67
+ "blob",
68
+ "spiral"
69
+ ]],
70
+ ["Math", ["math-spinner", "math-threads"]],
71
+ ["Field", ["halftone", "checker-field"]],
72
+ ["Flow", ["flow-obstacles", "flow-voronoi"]]
73
+ ],
74
+ crossfade: [
75
+ ["Scanline", ["scanline", "plasma"]],
76
+ ["Scanline", [
77
+ "scanline",
78
+ "flow-charges",
79
+ "math-surface"
80
+ ]],
81
+ ["Field", ["plasma", "math-field"]],
82
+ ["Field", ["gradient-field", "optic-moire"]],
83
+ ["Penrose", ["penrose-02-diffgrow", "flow-growth"]],
84
+ ["Penrose", [
85
+ "penrose-01-packing-lloyd",
86
+ "optic-reaction",
87
+ "abstract-rd",
88
+ "flow-voronoi"
89
+ ]],
90
+ ["Math", ["math-threads", "flow-ascii"]],
91
+ ["Math", ["math-waveform", "scanline"]]
92
+ ],
93
+ blend: [
94
+ [
95
+ "Scanline",
96
+ "scanline",
97
+ 2
98
+ ],
99
+ [
100
+ "Scanline",
101
+ "scanline",
102
+ 3
103
+ ],
104
+ [
105
+ "Field",
106
+ "plasma",
107
+ 2
108
+ ],
109
+ [
110
+ "Math",
111
+ "math-curves",
112
+ 2
113
+ ],
114
+ [
115
+ "Math",
116
+ "math-spinner",
117
+ 4
118
+ ],
119
+ [
120
+ "Optic",
121
+ "optic-moire",
122
+ 2
123
+ ],
124
+ [
125
+ "Flow",
126
+ "flow-obstacles",
127
+ 2
128
+ ]
129
+ ]
130
+ }, bn = null;
131
+ function xn(e) {
132
+ if (!bn) {
133
+ bn = /* @__PURE__ */ new Map();
134
+ let e = /* @__PURE__ */ new Set();
135
+ for (let t of oe) for (let n of B(t.id)) e.has(n.id) || fe(n) || (e.add(n.id), bn.has(n.loop) || bn.set(n.loop, []), bn.get(n.loop).push(n));
136
+ }
137
+ return bn.get(e) ?? [];
138
+ }
139
+ var Sn = (e, t) => e.length < t ? null : Array.from({ length: t }, (n, r) => e[Math.round(r * (e.length - 1) / (t - 1))]), Cn = null;
140
+ function wn() {
141
+ if (Cn) return Cn;
142
+ let e = [];
143
+ for (let t of vn) for (let n of yn[t.id]) {
144
+ let [r] = n, i = t.id === "blend" ? Sn(xn(n[1]), n[2]) : n[1].map((e) => xn(e)[0]);
145
+ if (!i || i.some((e) => !e) || new Set(i.map((e) => e.id)).size < i.length) continue;
146
+ let a = i.map((e) => e.label).join(" → "), o = `ship:morph:${t.id}:${i.map((e) => e.id).join("--")}`;
147
+ e.push({
148
+ id: o,
149
+ type: t.id,
150
+ typeLabel: t.label,
151
+ category: r,
152
+ sub: `${t.label} · ${r}`,
153
+ label: a,
154
+ steps: i,
155
+ morph: {
156
+ mode: t.id,
157
+ loopId: i[0].loop,
158
+ steps: i.map(xe),
159
+ curve: "in-out",
160
+ cycle: "loop",
161
+ resolution: 0,
162
+ syncLoop: !1,
163
+ seconds: 2 * i.length
164
+ }
165
+ });
166
+ }
167
+ return Cn = e;
168
+ }
169
+ var Tn = () => vn.map((e) => ({
170
+ label: e.label,
171
+ subs: [...new Set(wn().filter((t) => t.type === e.id).map((e) => e.sub))]
172
+ })), En = (e, t) => wn().find((n) => n.type === e && (!t || n.category === t)), Dn = (e) => wn().find((t) => t.id === e);
173
+ function On(e) {
174
+ e && (Re({
175
+ active: !0,
176
+ ...e.morph,
177
+ fileId: null,
178
+ fileName: e.label,
179
+ presetId: e.id
180
+ }), i.setLoopSeconds(e.morph.seconds), /\/morph\/?$/.test(window.location.pathname) || bt("/morph"));
181
+ }
182
+ //#endregion
183
+ //#region src/editor/labs/catalog.js
184
+ var kn = {
185
+ "fx:halftone": "ptrn-dot",
186
+ "fx:scanline": "grid-horizontal",
187
+ "fx:crt": "desktop",
188
+ "fx:refraction": "circle",
189
+ "fx:fx-rack": "target",
190
+ "fx:pattern": "ptrn-checker",
191
+ "fx:other": "more",
192
+ "gen:Scanline": "grid-horizontal",
193
+ "gen:Pattern": "ptrn-checker",
194
+ "gen:Loops": "refresh",
195
+ "gen:Math": "sum",
196
+ "gen:Penrose": "a-framed",
197
+ "gen:Flow": "wave",
198
+ "gen:Letter Gap": "letter-spacing",
199
+ "gen:Drift": "dith-flow",
200
+ "gen:Gradients": "circle",
201
+ "gen:Soft Forms": "paint-drop",
202
+ "gen:3D Scene": "ball",
203
+ "kin:Type": "font-01",
204
+ "kin:Kinetic": "font-01",
205
+ "misc:Para Type": "aa",
206
+ "vec:Distressor": "scribble",
207
+ "vec:Modulator": "dashed-circle"
208
+ }, An = {
209
+ effects: "filter",
210
+ generative: "layers",
211
+ vector: "pen-nib",
212
+ composition: "type",
213
+ morph: "swap",
214
+ mode: "mode-toggle-01"
215
+ }, jn = [
216
+ "Moiré",
217
+ "Mesh Gradient",
218
+ "Reaction",
219
+ "Halftone"
220
+ ], Mn = [
221
+ {
222
+ label: "Spaced",
223
+ patch: {
224
+ geometry: "rows",
225
+ mark: "dots"
226
+ }
227
+ },
228
+ {
229
+ label: "Glyph",
230
+ patch: { mark: "glyph" }
231
+ },
232
+ {
233
+ label: "Lattice",
234
+ patch: { mark: "lattice" }
235
+ },
236
+ {
237
+ label: "Vortex",
238
+ patch: {
239
+ geometry: "radial",
240
+ swirl: .8,
241
+ rayCount: 220
242
+ }
243
+ },
244
+ {
245
+ label: "Rings",
246
+ patch: { geometry: "rings" }
247
+ },
248
+ {
249
+ label: "Spiral",
250
+ patch: { geometry: "spiral" }
251
+ }
252
+ ], Nn = (e = {}) => {
253
+ let t = e.geometry ?? "rows";
254
+ return t === "radial" ? "Vortex" : t === "rings" ? "Rings" : t === "spiral" ? "Spiral" : e.mark === "glyph" ? "Glyph" : e.mark === "lattice" ? "Lattice" : "Spaced";
255
+ };
256
+ function Pn({ layer: e, setOnly: t, addFilter: n, patchFilter: r, carriedSource: i }) {
257
+ let a = () => e?.type === "photo" ? (e.filters ?? []).filter((e) => e?.id === "fx-media") : [], o = (e, o) => {
258
+ let s = a(), c = t("photo", {
259
+ ...i(),
260
+ filters: s,
261
+ fxGroup: null
262
+ });
263
+ c && (n(c, e), o && r(c, s.length, o)), window.dispatchEvent(new CustomEvent("kol:open-effects"));
264
+ }, s = (e) => {
265
+ t("photo", {
266
+ ...i(),
267
+ filters: a(),
268
+ fxGroup: e
269
+ }), window.dispatchEvent(new CustomEvent("kol:open-effects"));
270
+ }, c = (e, n) => {
271
+ t("loop", de(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
272
+ }, l = (e) => {
273
+ t("kinetic", {
274
+ presetId: e.id,
275
+ presetLabel: e.label,
276
+ comp: Ye(e)
277
+ }), window.dispatchEvent(new CustomEvent("kol:open-params"));
278
+ }, u = e?.presetId ?? null, d = (e?.filters ?? []).find((e) => e?.id !== "fx-media")?.id ?? null, f = u ? B(e?.loopGroup).find((e) => e.id === u) ?? null : null, p = (n, r = "loop", i) => {
279
+ let a = B(n), o = [...new Set(a.map((e) => e.sub).filter(Boolean))], s = (e) => r === "misc" ? () => {
280
+ t("misc", de(e, n)), window.dispatchEvent(new CustomEvent("kol:open-params"));
281
+ } : () => c(e, n);
282
+ return o.length ? o.map((t) => ({
283
+ label: t,
284
+ onSelect: s(z(n, t)[0]),
285
+ active: e?.loopGroup === n && f?.sub === t
286
+ })) : [{
287
+ label: i ?? V(n).label,
288
+ onSelect: s(a[0]),
289
+ active: e?.loopGroup === n
290
+ }];
291
+ }, m = (e) => e.groups.flatMap((t) => {
292
+ let n = e.labels?.[t] ?? V(t).label, r = B(t).some((e) => e.sub), i = p(t, "loop", n);
293
+ return e.groups.length > 1 && r ? [{
294
+ label: n,
295
+ children: i
296
+ }] : i;
297
+ });
298
+ return [
299
+ {
300
+ id: "color",
301
+ label: "Color",
302
+ icon: "clr-tri",
303
+ onSelect: Ae,
304
+ pages: []
305
+ },
306
+ {
307
+ id: "sec:effects",
308
+ label: "Effects"
309
+ },
310
+ ...ce(W).map((t) => ({
311
+ id: `fx:${t.id}`,
312
+ label: t.label,
313
+ icon: kn[`fx:${t.id}`] ?? "square",
314
+ pages: t.rack ? le.map((t) => ({
315
+ label: t.label,
316
+ onSelect: () => s(t.id),
317
+ active: e?.fxGroup === t.id
318
+ })) : t.id === "pattern" ? jn.map((t) => ({
319
+ label: t,
320
+ onSelect: () => c(z("optic", t)[0], "optic"),
321
+ active: e?.loopGroup === "optic" && f?.sub === t
322
+ })) : t.id === "scanline" ? Mn.map((t) => ({
323
+ label: t.label,
324
+ onSelect: () => o("scanline", t.patch),
325
+ active: !e?.fxGroup && d === "scanline" && Nn((e?.filters ?? []).find((e) => e?.id === "scanline")?.params) === t.label
326
+ })) : t.filters.map((t) => ({
327
+ label: t.label ?? t.id,
328
+ onSelect: () => o(t.id),
329
+ active: !e?.fxGroup && d === t.id
330
+ }))
331
+ })),
332
+ {
333
+ id: "sec:generative",
334
+ label: "Generative"
335
+ },
336
+ ...Oe.map((e) => ({
337
+ id: `gen:${e.label}`,
338
+ label: e.label,
339
+ icon: kn[`gen:${e.label}`] ?? "square",
340
+ pages: m(e)
341
+ })),
342
+ {
343
+ id: "sec:morph",
344
+ label: "Morph"
345
+ },
346
+ ...vn.map((e) => ({
347
+ id: `morph:${e.id}`,
348
+ label: e.label,
349
+ icon: e.icon,
350
+ pages: [...new Set(wn().filter((t) => t.type === e.id).map((e) => e.category))].map((t) => ({
351
+ label: t,
352
+ onSelect: () => On(En(e.id, t)),
353
+ active: (() => {
354
+ let n = wn().find((e) => e.id === Le().presetId);
355
+ return n?.type === e.id && n.category === t;
356
+ })()
357
+ }))
358
+ })),
359
+ {
360
+ id: "sec:vector",
361
+ label: "Vector"
362
+ },
363
+ {
364
+ id: "vec:Distressor",
365
+ label: "Distressor",
366
+ icon: kn["vec:Distressor"] ?? "square",
367
+ pages: p("distress")
368
+ },
369
+ {
370
+ id: "vec:Modulator",
371
+ label: "Modulator",
372
+ icon: kn["vec:Modulator"] ?? "square",
373
+ pages: p("modulator")
374
+ },
375
+ {
376
+ id: "sec:composition",
377
+ label: "Composition"
378
+ },
379
+ ...Xe.map((t) => ({
380
+ id: `kin:${t.label}`,
381
+ label: t.label,
382
+ icon: kn[`kin:${t.label}`] ?? "square",
383
+ pages: t.subs.map((t) => ({
384
+ label: t,
385
+ onSelect: () => l(Je.find((e) => e.sub === t)),
386
+ active: e?.type === "kinetic" && Je.some((e) => e.sub === t && e.id === u)
387
+ }))
388
+ })),
389
+ ...be.map((e) => ({
390
+ id: `misc:${e.label}`,
391
+ label: e.label,
392
+ icon: kn[`misc:${e.label}`] ?? "square",
393
+ pages: e.groups.flatMap((e) => p(e, "misc"))
394
+ }))
395
+ ];
396
+ }
397
+ //#endregion
398
+ //#region src/editor/labs/LabsNav.jsx
399
+ function Fn() {
400
+ let { addFilter: e, patchFilter: t } = h(), { layer: n, setOnly: r } = Te(), i = X(null);
401
+ Y(() => {
402
+ n?.type === "photo" && n.src && (i.current = {
403
+ src: n.src,
404
+ srcType: n.srcType,
405
+ fit: n.fit
406
+ });
407
+ }, [
408
+ n?.type,
409
+ n?.src,
410
+ n?.srcType,
411
+ n?.fit
412
+ ]);
413
+ let a = Pn({
414
+ layer: n,
415
+ setOnly: r,
416
+ addFilter: e,
417
+ patchFilter: t,
418
+ carriedSource: () => n?.type === "photo" ? {
419
+ src: n.src,
420
+ srcType: n.srcType,
421
+ fit: n.fit
422
+ } : i.current ?? {}
423
+ });
424
+ return Y(() => {
425
+ let e = /* @__PURE__ */ new Map(), t = [];
426
+ return a.forEach((n) => {
427
+ if (n.id.startsWith("sec:")) {
428
+ let e = n.id.slice(4);
429
+ t.push({
430
+ icon: An[e] ?? "square",
431
+ path: `${Pt}${n.id}`,
432
+ label: n.label,
433
+ sub: []
434
+ });
435
+ return;
436
+ }
437
+ let r = `${Pt}${n.id}`, i = n.pages ?? [], a = n.onSelect ?? i[0]?.onSelect ?? i[0]?.children?.[0]?.onSelect;
438
+ a && e.set(r, a);
439
+ let o = t[t.length - 1], s = {
440
+ icon: n.icon,
441
+ path: r,
442
+ label: n.label
443
+ };
444
+ o?.sub ? o.sub.push(s) : t.push(s);
445
+ }), mt({
446
+ items: t,
447
+ dispatch: (t) => {
448
+ let n = e.get(t);
449
+ return n ? (n(), !0) : !1;
450
+ }
451
+ }), () => mt(null);
452
+ }), null;
453
+ }
454
+ //#endregion
455
+ //#region src/editor/morph/MorphTab.jsx
456
+ var In = (e, t) => JSON.stringify(e) === JSON.stringify(t), Ln = [
457
+ {
458
+ key: "curve",
459
+ label: "Curve",
460
+ type: "select",
461
+ options: Ne,
462
+ section: "Curve"
463
+ },
464
+ {
465
+ key: "cycle",
466
+ label: "Cycle",
467
+ type: "select",
468
+ options: Pe,
469
+ section: "Curve"
470
+ },
471
+ {
472
+ key: "syncLoop",
473
+ label: "Sync loop",
474
+ type: "toggle",
475
+ section: "Curve"
476
+ },
477
+ {
478
+ key: "resolution",
479
+ label: "Resolution",
480
+ type: "range",
481
+ min: 0,
482
+ max: 1024,
483
+ step: 1,
484
+ default: 0,
485
+ format: (e) => e || "Auto",
486
+ when: (e) => e.mode === "shape"
487
+ }
488
+ ];
489
+ function Rn({ layer: e, readOnly: t = !1, editTabs: n = null }) {
490
+ let r = _(), a = He(), { steps: s, curve: c, cycle: l, mode: u, resolution: d, editing: m, fileId: v, editRequest: y } = a, { updateLayer: x, removeLayer: S, setCurrentPresetId: C, setCurrentPresetName: w, palette: T } = h(), { setOnly: E } = Te(), { buildSavedSpec: D } = Vt(), { addItem: O, updateItem: k } = ke(), A = Xt(), j = o(), M = R(e?.id ?? null, { history: "coalesce" }), [N, P] = Z("generate"), F = s[0], ee = s.every((e) => e.loopId === F?.loopId), L = s.filter((e) => !at(K(e.loopId)) || !wt(K(e.loopId))), te = L.length === 0, z = {
491
+ blend: ee ? null : "Blend tweens one generator — these steps are different generators",
492
+ shape: te ? null : `No outline to morph: ${L.map((e) => Me(e, s.indexOf(e))).join(", ")} (GL)`,
493
+ crossfade: te ? null : `Cannot fade: ${L.map((e) => Me(e, s.indexOf(e))).join(", ")} (GL)`
494
+ }, B = [
495
+ {
496
+ value: "shape",
497
+ label: "Shape",
498
+ disabled: !!z.shape,
499
+ tooltip: z.shape ?? void 0
500
+ },
501
+ {
502
+ value: "blend",
503
+ label: "Blend",
504
+ disabled: !!z.blend,
505
+ tooltip: z.blend ?? void 0
506
+ },
507
+ {
508
+ value: "crossfade",
509
+ label: "Crossfade",
510
+ disabled: !!z.crossfade,
511
+ tooltip: z.crossfade ?? void 0
512
+ }
513
+ ];
514
+ Y(() => {
515
+ if (t || s.length < 2 || !z[u]) return;
516
+ let e = [
517
+ "shape",
518
+ "crossfade",
519
+ "blend"
520
+ ].find((e) => !z[e]);
521
+ e && q({ mode: e });
522
+ }, [
523
+ u,
524
+ ee,
525
+ te,
526
+ s.length,
527
+ t
528
+ ]), Y(() => {
529
+ !t && s.length === 0 && e?.type === "loop" && e.loopId && !e.morph && Ve(Se(e));
530
+ }, []);
531
+ let V = X(s.length), H = () => {
532
+ let t = s.length < V.current;
533
+ if (V.current = s.length, s.length < 2) {
534
+ if (!e || !t) return;
535
+ if (s.length === 0) {
536
+ S(e.id);
537
+ return;
538
+ }
539
+ let n = {};
540
+ for (let t in e) e[t]?.bind === "track" && (n[t] = e[t].keys?.[0]?.v);
541
+ let r = s[0];
542
+ x(e.id, {
543
+ ...n,
544
+ loopGroup: r.loopGroup,
545
+ presetId: r.presetId,
546
+ presetLabel: r.presetLabel,
547
+ loopId: r.loopId,
548
+ ...r.params,
549
+ morph: null,
550
+ morphT: null
551
+ });
552
+ return;
553
+ }
554
+ let n = {
555
+ loopGroup: F.loopGroup,
556
+ presetId: F.presetId,
557
+ presetLabel: F.presetLabel,
558
+ loopId: F.loopId
559
+ }, r = {
560
+ mode: u,
561
+ steps: s.map((e, t) => ({
562
+ loopId: e.loopId,
563
+ params: e.params,
564
+ label: Me(e, t)
565
+ })),
566
+ cycle: l,
567
+ curve: c,
568
+ resolution: d,
569
+ syncLoop: a.syncLoop,
570
+ name: a.fileName
571
+ }, i = u === "blend" ? {
572
+ ...n,
573
+ ...ze({
574
+ snapshots: s.map((e) => e.params),
575
+ schema: K(F.loopId)?.params ?? [],
576
+ curve: c,
577
+ cycle: l
578
+ }).patch,
579
+ morph: r,
580
+ morphT: null
581
+ } : {
582
+ ...n,
583
+ ...F.params,
584
+ morph: r,
585
+ morphT: {
586
+ bind: "track",
587
+ keys: st(s.length, l, c)
588
+ }
589
+ };
590
+ e ? x(e.id, i) : E("loop", i);
591
+ }, U = X(H);
592
+ U.current = H;
593
+ let ne = JSON.stringify([
594
+ u,
595
+ s.map((e) => [e.loopId, e.params]),
596
+ c,
597
+ l,
598
+ d,
599
+ a.syncLoop
600
+ ]), W = X(null);
601
+ Y(() => {
602
+ t || m != null || ne === W.current || s.length >= 2 && z[u] || (W.current = ne, U.current());
603
+ }, [
604
+ ne,
605
+ m,
606
+ s.length,
607
+ t
608
+ ]), Y(() => {
609
+ if (t || m == null || !e) return;
610
+ let n = Be(e, K(e.loopId)?.params ?? []);
611
+ In(n, s[m]?.params) || Ie(m, n);
612
+ }, [e]), Y(() => {
613
+ t || !j || m == null || (q({ editing: null }), W.current = null);
614
+ }, [
615
+ j,
616
+ m,
617
+ t
618
+ ]), Y(() => () => {
619
+ !t && a.editing != null && (q({ editing: null }), U.current());
620
+ }, []);
621
+ let re = (e) => {
622
+ let t = s[e];
623
+ t && (i.pause(), q({ editing: e }), E("loop", {
624
+ loopGroup: t.loopGroup,
625
+ presetId: t.presetId,
626
+ presetLabel: t.presetLabel,
627
+ loopId: t.loopId,
628
+ ...t.params,
629
+ morph: null,
630
+ morphT: null
631
+ }));
632
+ };
633
+ return Y(() => {
634
+ t || y == null || (q({ editRequest: null }), re(y));
635
+ }, [y]), /* @__PURE__ */ $("div", {
636
+ className: "flex flex-col gap-5",
637
+ children: [
638
+ /* @__PURE__ */ Q(g, {
639
+ layout: "joined",
640
+ tone: "sunken",
641
+ value: u,
642
+ onChange: (e) => !t && q({ mode: e }),
643
+ options: B,
644
+ size: r,
645
+ className: p(r)
646
+ }),
647
+ !t && /* @__PURE__ */ Q(b, {
648
+ divided: !0,
649
+ children: /* @__PURE__ */ Q(pe, {
650
+ tree: Tn(),
651
+ presets: wn(),
652
+ current: Dn(a.presetId) ?? { typeLabel: vn.find((e) => e.id === u)?.label },
653
+ subLabel: (e) => e.split(" · ").pop(),
654
+ onPick: On
655
+ })
656
+ }),
657
+ /* @__PURE__ */ $(b, {
658
+ divided: !0,
659
+ children: [
660
+ /* @__PURE__ */ Q(Kt, {
661
+ items: s.map((e, t) => ({
662
+ id: t,
663
+ label: Me(e, t)
664
+ })),
665
+ activeIndex: m,
666
+ reorder: "grab",
667
+ readOnly: t,
668
+ size: r,
669
+ onSelect: re,
670
+ onRemove: Fe,
671
+ onMove: je,
672
+ onAdd: () => q({
673
+ active: !0,
674
+ picker: "preset"
675
+ }),
676
+ addLabel: "Add a step"
677
+ }),
678
+ s.length < 2 && !t && /* @__PURE__ */ Q("p", {
679
+ className: "kol-mono-12 text-meta",
680
+ children: "Two steps or more and the stage plays the morph."
681
+ }),
682
+ s.length >= 2 && z[u] && /* @__PURE__ */ Q("p", {
683
+ className: "kol-mono-12 text-meta",
684
+ children: z[u]
685
+ })
686
+ ]
687
+ }),
688
+ m != null && !t && e && n && /* @__PURE__ */ $(b, {
689
+ label: `Step ${m + 1}`,
690
+ divided: !0,
691
+ children: [
692
+ /* @__PURE__ */ Q(g, {
693
+ layout: "joined",
694
+ tone: "sunken",
695
+ value: N,
696
+ onChange: P,
697
+ options: n,
698
+ size: r,
699
+ className: p(r)
700
+ }),
701
+ /* @__PURE__ */ Q(De, {
702
+ layer: e,
703
+ setProp: M.setProp,
704
+ patch: M.patch,
705
+ updateLayer: x,
706
+ palette: T,
707
+ tab: N,
708
+ tabStrip: null,
709
+ inline: !0,
710
+ picker: !1
711
+ }),
712
+ /* @__PURE__ */ $("p", {
713
+ className: "kol-mono-12 text-emphasis",
714
+ children: [
715
+ "Editing step ",
716
+ m + 1,
717
+ " — press Play to run the morph."
718
+ ]
719
+ })
720
+ ]
721
+ }),
722
+ /* @__PURE__ */ Q(I, {
723
+ schema: Ln,
724
+ layer: a,
725
+ setProp: (e, n) => {
726
+ !t && (typeof n != "object" || !n) && q({ [e]: n });
727
+ },
728
+ inline: !0
729
+ }),
730
+ !t && s.length >= 2 && /* @__PURE__ */ Q(b, {
731
+ divided: !0,
732
+ children: /* @__PURE__ */ Q(f, {
733
+ tone: "primary",
734
+ size: r,
735
+ className: "w-full",
736
+ onClick: async () => {
737
+ if (s.length < 2) return;
738
+ let e = a.fileName;
739
+ if (!v && (e = await A.prompt("Name this morph:", ""), e === null)) return;
740
+ m != null && (q({ editing: null }), U.current());
741
+ let t = {
742
+ ...await D(e || null),
743
+ mode: "morph",
744
+ morph: {
745
+ mode: u,
746
+ loopId: a.loopId,
747
+ steps: s,
748
+ curve: c,
749
+ cycle: l,
750
+ resolution: d,
751
+ syncLoop: a.syncLoop,
752
+ seconds: i.getLoopSeconds()
753
+ }
754
+ };
755
+ if (v) {
756
+ k("preset", v, t);
757
+ return;
758
+ }
759
+ let n = O("preset", t);
760
+ n && (q({
761
+ fileId: n,
762
+ fileName: e || null
763
+ }), C(n), w(e || null));
764
+ },
765
+ children: v ? "Save" : "Save…"
766
+ })
767
+ })
768
+ ]
769
+ });
770
+ }
771
+ //#endregion
772
+ //#region src/editor/params/QuickMotion.jsx
773
+ var zn = [
774
+ {
775
+ value: "breathe",
776
+ label: "Breathe",
777
+ source: "lfo-sine",
778
+ rate: 1
779
+ },
780
+ {
781
+ value: "sweep",
782
+ label: "Sweep",
783
+ source: "lfo-triangle",
784
+ rate: 1
785
+ },
786
+ {
787
+ value: "jitter",
788
+ label: "Jitter",
789
+ source: "lfo-square",
790
+ rate: 8
791
+ }
792
+ ], Bn = .2;
793
+ function Vn(e) {
794
+ if (!u(e)) return "off";
795
+ if (e.bind !== "mod") return "custom";
796
+ let t = zn.find((t) => t.source === e.source && (e.transform?.rate ?? 1) === t.rate);
797
+ return t ? t.value : "custom";
798
+ }
799
+ function Hn({ schema: e, layer: t, setProp: n, label: r = "Modulate" }) {
800
+ let a = _(), o = D(e ?? [], t).filter((e) => e.type === "range" && e.animatable !== !1 && c(e) !== "anim" && e.min != null && e.max != null && !/seed/i.test(e.key));
801
+ if (!o.length) return null;
802
+ let s = (e, r) => {
803
+ let a = t[e.key];
804
+ if (r === "off") {
805
+ let r = a?.transform?.range;
806
+ n(e.key, Array.isArray(r) ? (r[0] + r[1]) / 2 : j(a, i.getCtx(), t) ?? e.default ?? e.min);
807
+ return;
808
+ }
809
+ let o = zn.find((e) => e.value === r);
810
+ if (!o) return;
811
+ let s = Number(j(a, i.getCtx(), t) ?? e.default ?? e.min), c = (e.max - e.min) * Bn, l = Math.max(e.min, s - c), u = Math.min(e.max, s + c);
812
+ n(e.key, {
813
+ bind: "mod",
814
+ source: o.source,
815
+ transform: {
816
+ range: [l, u],
817
+ rate: o.rate
818
+ }
819
+ });
820
+ };
821
+ return /* @__PURE__ */ Q(b, {
822
+ label: r,
823
+ divided: !0,
824
+ children: o.map((e) => {
825
+ let n = Vn(t[e.key]), r = [
826
+ {
827
+ value: "off",
828
+ label: "Off"
829
+ },
830
+ ...zn.map(({ value: e, label: t }) => ({
831
+ value: e,
832
+ label: t
833
+ })),
834
+ ...n === "custom" ? [{
835
+ value: "custom",
836
+ label: "Custom"
837
+ }] : []
838
+ ];
839
+ return /* @__PURE__ */ Q(S, {
840
+ label: e.label,
841
+ align: "fill",
842
+ labelWidth: d,
843
+ children: /* @__PURE__ */ Q(F, {
844
+ size: a,
845
+ variant: "subtle",
846
+ className: "w-full",
847
+ options: r,
848
+ value: n,
849
+ onChange: (t) => t !== "custom" && s(e, t)
850
+ })
851
+ }, e.key);
852
+ })
853
+ });
854
+ }
855
+ //#endregion
856
+ //#region src/editor/params/InputRows.jsx
857
+ var Un = [
858
+ {
859
+ value: "off",
860
+ label: "Off"
861
+ },
862
+ {
863
+ value: "mouseX",
864
+ label: "Mouse X"
865
+ },
866
+ {
867
+ value: "mouseY",
868
+ label: "Mouse Y"
869
+ },
870
+ {
871
+ value: "audio-level",
872
+ label: "Mic"
873
+ },
874
+ {
875
+ value: "audio-bass",
876
+ label: "Beat"
877
+ },
878
+ {
879
+ value: "lfo-sine",
880
+ label: "LFO"
881
+ }
882
+ ], Wn = new Set(Un.map((e) => e.value));
883
+ function Gn({ schema: e, layer: t, setProp: n, inputs: a = null }) {
884
+ let o = _(), s = D(e ?? [], t).filter((e) => e.type === "range" && e.animatable !== !1 && e.min != null && e.max != null && !/seed/i.test(e.key));
885
+ if (!s.length) return null;
886
+ let c = new Map(s.map((e) => [e.key, e])), l = (a ?? []).filter((e) => c.has(e)), d = [...l, ...s.map((e) => e.key).filter((e) => !l.includes(e))], p = l.length ? l : d.slice(0, 3), m = (e) => {
887
+ let n = t[e];
888
+ return u(n) && n.bind === "mod" && Wn.has(n.source);
889
+ }, h = d.filter(m), g = (e) => {
890
+ let n = c.get(e);
891
+ return Number(j(t[e], i.getCtx(), t) ?? n.default ?? n.min);
892
+ }, v = (e, i, a = u(t[e]) ? t[e].transform?.base ?? g(e) : g(e)) => {
893
+ let o = c.get(e);
894
+ r(i)?.ensure?.().catch(() => {}), n(e, {
895
+ bind: "mod",
896
+ source: i,
897
+ transform: {
898
+ range: [o.min, o.max],
899
+ base: a,
900
+ ...i.startsWith("lfo") ? { rate: 1 } : {}
901
+ }
902
+ });
903
+ }, y = (e) => n(e, u(t[e]) ? t[e].transform?.base ?? g(e) : g(e)), x = p.find((e) => !m(e)) ?? d.find((e) => !m(e));
904
+ return /* @__PURE__ */ $(b, {
905
+ label: "Inputs",
906
+ divided: !0,
907
+ children: [h.map((e) => /* @__PURE__ */ Q(Gt, {
908
+ size: o,
909
+ className: "w-full [&>button]:w-full",
910
+ groups: [{
911
+ id: "source",
912
+ label: "Source",
913
+ options: Un
914
+ }, {
915
+ id: "drives",
916
+ label: "Drives",
917
+ options: d.map((e) => ({
918
+ value: e,
919
+ label: c.get(e).label + (p.includes(e) ? " ★" : "")
920
+ }))
921
+ }],
922
+ value: {
923
+ source: t[e].source,
924
+ drives: e
925
+ },
926
+ label: `${Un.find((n) => n.value === t[e].source)?.label} → ${c.get(e).label}`,
927
+ onChange: (n, r) => {
928
+ if (n === "source") {
929
+ r === "off" ? y(e) : v(e, r);
930
+ return;
931
+ }
932
+ if (r === e || m(r)) return;
933
+ let i = t[e].source;
934
+ y(e), v(r, i);
935
+ }
936
+ }, e)), x && /* @__PURE__ */ Q(f, {
937
+ size: o,
938
+ iconLeft: "plus",
939
+ className: "w-full",
940
+ onClick: () => v(x, "mouseX"),
941
+ children: "Add input"
942
+ })]
943
+ });
944
+ }
945
+ //#endregion
946
+ //#region src/editor/labs/ModelSource.jsx
947
+ var Kn = /\.(obj|glb|gltf|stl)$/i, qn = (e) => Kn.test(e.key ?? e.name ?? ""), Jn = (e) => (e.match(Kn)?.[1] ?? "obj").toLowerCase(), Yn = (e) => e?.startsWith("data:") ? "Local file" : decodeURIComponent(String(e ?? "").split("/").pop() || "—");
948
+ function Xn({ layer: e, setProp: t }) {
949
+ let n = _(), [r, i] = Z(!1), a = X(null), o = (e, n) => {
950
+ t("meshSrc", e), t("meshType", n);
951
+ };
952
+ return /* @__PURE__ */ $(b, {
953
+ label: "Model",
954
+ divided: !0,
955
+ children: [
956
+ /* @__PURE__ */ Q("span", {
957
+ className: "kol-mono-12 text-meta truncate",
958
+ children: Yn(e.meshSrc)
959
+ }),
960
+ /* @__PURE__ */ $("div", {
961
+ className: "grid grid-cols-2 gap-2",
962
+ children: [/* @__PURE__ */ Q(f, {
963
+ tone: "primary",
964
+ size: n,
965
+ onClick: () => i(!0),
966
+ children: "From library"
967
+ }), /* @__PURE__ */ Q(f, {
968
+ tone: "primary",
969
+ size: n,
970
+ onClick: () => a.current?.click(),
971
+ children: "Upload"
972
+ })]
973
+ }),
974
+ /* @__PURE__ */ Q("input", {
975
+ ref: a,
976
+ type: "file",
977
+ accept: ".obj,.glb,.gltf,.stl",
978
+ className: "hidden",
979
+ onChange: (e) => {
980
+ let t = e.target.files?.[0];
981
+ if (e.target.value = "", !t) return;
982
+ let n = new FileReader();
983
+ n.onload = () => o(n.result, Jn(t.name)), n.readAsDataURL(t);
984
+ }
985
+ }),
986
+ /* @__PURE__ */ Q(Bt, {
987
+ open: r,
988
+ accept: qn,
989
+ onClose: () => i(!1),
990
+ onSelect: (e) => {
991
+ i(!1), o(Ct(e), Jn(e));
992
+ }
993
+ })
994
+ ]
995
+ });
996
+ }
997
+ //#endregion
998
+ //#region src/editor/labs/useLabsKeys.js
999
+ function Zn(e, t) {
1000
+ Y(() => {
1001
+ let n = (n) => {
1002
+ n.key !== "r" && n.key !== "R" || n.metaKey || n.ctrlKey || n.altKey || pt(n) || (n.preventDefault(), n.shiftKey ? t?.() : e?.());
1003
+ };
1004
+ return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
1005
+ });
1006
+ }
1007
+ //#endregion
1008
+ //#region src/editor/labs/LabsParams.jsx
1009
+ var Qn = [{
1010
+ value: "effect",
1011
+ label: "Effect"
1012
+ }, {
1013
+ value: "anim",
1014
+ label: "Motion"
1015
+ }], $n = [
1016
+ {
1017
+ value: "generate",
1018
+ label: "Generate"
1019
+ },
1020
+ {
1021
+ value: "style",
1022
+ label: "Style"
1023
+ },
1024
+ {
1025
+ value: "anim",
1026
+ label: "Animation"
1027
+ }
1028
+ ], er = [
1029
+ {
1030
+ value: "generate",
1031
+ label: "Gen"
1032
+ },
1033
+ {
1034
+ value: "style",
1035
+ label: "Style"
1036
+ },
1037
+ {
1038
+ value: "anim",
1039
+ label: "Anim"
1040
+ }
1041
+ ];
1042
+ function tr({ options: e, active: t, onPick: n, spread: r = !1, pills: i = !1 }) {
1043
+ let a = _();
1044
+ return e?.length ? i ? /* @__PURE__ */ Q("div", {
1045
+ className: "flex items-center gap-1 flex-wrap",
1046
+ children: e.map((e) => /* @__PURE__ */ Q(qt, {
1047
+ size: "xs",
1048
+ hash: !1,
1049
+ active: e.value === t,
1050
+ onClick: () => n(e.value),
1051
+ children: e.label
1052
+ }, e.value))
1053
+ }) : /* @__PURE__ */ Q(g, {
1054
+ layout: "joined",
1055
+ tone: "sunken",
1056
+ value: t ?? null,
1057
+ onChange: n,
1058
+ options: e,
1059
+ size: a,
1060
+ ariaLabel: "Siblings",
1061
+ className: p(a)
1062
+ }) : null;
1063
+ }
1064
+ function nr() {
1065
+ let { undo: e, redo: t, canUndo: n, canRedo: r } = h(), i = _(), a = (e, t) => e ? t : /* @__PURE__ */ Q("span", {
1066
+ "aria-hidden": "true",
1067
+ className: "invisible pointer-events-none",
1068
+ children: t
1069
+ });
1070
+ return /* @__PURE__ */ $(nn, { children: [a(n, /* @__PURE__ */ Q(Jt, {
1071
+ label: "Undo",
1072
+ shortcut: "⌘Z",
1073
+ children: /* @__PURE__ */ Q(f, {
1074
+ size: i,
1075
+ iconOnly: "arrow-left",
1076
+ "aria-label": "Undo",
1077
+ tabIndex: n ? void 0 : -1,
1078
+ onClick: e
1079
+ })
1080
+ })), a(r, /* @__PURE__ */ Q(Jt, {
1081
+ label: "Redo",
1082
+ shortcut: "⇧⌘Z",
1083
+ children: /* @__PURE__ */ Q(f, {
1084
+ size: i,
1085
+ iconOnly: "arrow-right",
1086
+ "aria-label": "Redo",
1087
+ tabIndex: r ? void 0 : -1,
1088
+ onClick: t
1089
+ })
1090
+ }))] });
1091
+ }
1092
+ function rr({ chips: e, active: t, onPick: n, spread: r, pills: i, title: a, tabStrip: o, preStrip: s, fx: c = !1, scope: l, ghostLabels: u, children: f }) {
1093
+ let p = _() === "sm";
1094
+ return /* @__PURE__ */ $("div", {
1095
+ className: `flex flex-col gap-5${c ? " kol-labs-fx" : ""}`,
1096
+ "data-label-scope": l,
1097
+ children: [
1098
+ a && p && /* @__PURE__ */ $("div", {
1099
+ className: "flex items-center gap-1",
1100
+ children: [/* @__PURE__ */ Q("p", {
1101
+ className: "kol-eyebrow text-fg-96 flex-1 min-w-0",
1102
+ children: a
1103
+ }), /* @__PURE__ */ Q(nr, {})]
1104
+ }),
1105
+ e && /* @__PURE__ */ Q(tr, {
1106
+ options: e,
1107
+ active: t,
1108
+ onPick: n,
1109
+ spread: r,
1110
+ pills: i
1111
+ }),
1112
+ s,
1113
+ o,
1114
+ f,
1115
+ u?.length > 0 && /* @__PURE__ */ Q("div", {
1116
+ "aria-hidden": "true",
1117
+ className: "invisible h-0 overflow-hidden flex flex-col",
1118
+ children: u.map((e, t) => /* @__PURE__ */ Q("span", {
1119
+ className: "kol-helper-10 tracking-widest whitespace-nowrap",
1120
+ style: { width: d },
1121
+ children: String(e).toUpperCase()
1122
+ }, t))
1123
+ })
1124
+ ]
1125
+ });
1126
+ }
1127
+ function ir({ layer: e, showMod: n }) {
1128
+ let r = t(), i = _(), [a, o] = Z("effect");
1129
+ Y(() => {
1130
+ let e = () => o("effect");
1131
+ return window.addEventListener("kol:open-effects", e), () => window.removeEventListener("kol:open-effects", e);
1132
+ }, []);
1133
+ let { addFilter: l, replaceFilter: u, removeFilter: m, toggleFilter: v, updateLayer: y, palette: w } = h(), T = R(e.id, { history: "coalesce" }), E = x(e), D = E.findIndex((e) => !e.def?.first), O = D < 0 ? E.length : D, A = D < 0 ? null : E[D], j = ce(W).find((e) => e.id === se(A?.id)), N = j?.id === "halftone", ee = N ? (j?.filters ?? []).map((e) => ({
1134
+ value: e.id,
1135
+ label: e.label
1136
+ })) : null, te = !N && A ? A.def.label : null, z = (t) => {
1137
+ if (!A) {
1138
+ l(e.id, t);
1139
+ return;
1140
+ }
1141
+ t !== A.id && u(e.id, O, t);
1142
+ }, B = E.map(({ def: e, ...t }) => t), V = A ? {
1143
+ ...e,
1144
+ ...A.params,
1145
+ id: e.id
1146
+ } : e, H = (e) => (t, n) => {
1147
+ let r = B.map((r, i) => i === e ? {
1148
+ ...r,
1149
+ params: {
1150
+ ...r.params,
1151
+ [t]: n
1152
+ }
1153
+ } : r);
1154
+ T.patch({ filters: r });
1155
+ }, U = H(O), re = n ? (e) => /* @__PURE__ */ Q(Ge, {
1156
+ layer: V,
1157
+ param: e,
1158
+ setProp: U
1159
+ }) : void 0, ie = (t) => {
1160
+ let n = B.map((e, n) => n === O ? {
1161
+ ...e,
1162
+ params: {
1163
+ ...e.params,
1164
+ ...t
1165
+ }
1166
+ } : e);
1167
+ y(e.id, { filters: n });
1168
+ };
1169
+ Zn(() => {
1170
+ A && y(e.id, { filters: B.map((e, t) => t === 0 ? {
1171
+ ...e,
1172
+ params: {}
1173
+ } : e) });
1174
+ }, () => {
1175
+ A && ie(C(V, M(A.def.params, V), P()));
1176
+ });
1177
+ let oe = e.fxGroup ? le.find((t) => t.id === e.fxGroup) : null;
1178
+ if (oe) {
1179
+ let t = {
1180
+ chain: E,
1181
+ layer: e,
1182
+ hostView: V,
1183
+ toggleFilter: v,
1184
+ removeFilter: m,
1185
+ setStagePropAt: H,
1186
+ palette: w,
1187
+ showMod: n
1188
+ }, r = [{
1189
+ value: "",
1190
+ label: "Add effect…"
1191
+ }, ...ne(oe, W).map((e) => ({
1192
+ value: e.id,
1193
+ label: `${e.label ?? e.id}${e.kind === "pixi" ? " · GPU" : ""}`
1194
+ }))];
1195
+ return /* @__PURE__ */ $(rr, {
1196
+ title: "Effects",
1197
+ fx: !0,
1198
+ tabStrip: /* @__PURE__ */ Q(g, {
1199
+ layout: "joined",
1200
+ tone: "sunken",
1201
+ value: a,
1202
+ onChange: o,
1203
+ options: Qn,
1204
+ size: i,
1205
+ className: p(i)
1206
+ }),
1207
+ children: [a === "effect" && /* @__PURE__ */ $(nn, { children: [
1208
+ /* @__PURE__ */ $(b, {
1209
+ label: "Effect stack",
1210
+ divided: !0,
1211
+ children: [E.length === 0 && /* @__PURE__ */ Q(L, {
1212
+ className: "kol-mono-10 text-meta",
1213
+ children: "No effects yet — add one below."
1214
+ }), /* @__PURE__ */ Q(cr, {
1215
+ ...t,
1216
+ from: 0
1217
+ })]
1218
+ }),
1219
+ /* @__PURE__ */ Q(Wt, {}),
1220
+ E.length < 8 && /* @__PURE__ */ Q(b, {
1221
+ label: oe.label,
1222
+ divided: !0,
1223
+ children: /* @__PURE__ */ Q(F, {
1224
+ variant: "subtle",
1225
+ size: i,
1226
+ className: "w-full",
1227
+ options: r,
1228
+ value: "",
1229
+ onChange: (t) => {
1230
+ t && l(e.id, t);
1231
+ }
1232
+ })
1233
+ })
1234
+ ] }), a === "anim" && A?.def?.sweeps && /* @__PURE__ */ Q(qe, {
1235
+ sweeps: Array.isArray(A.params.sweeps) ? A.params.sweeps : [],
1236
+ onChange: (e) => U("sweeps", e),
1237
+ inline: !0
1238
+ })]
1239
+ });
1240
+ }
1241
+ if (!A) return /* @__PURE__ */ Q(rr, {
1242
+ chips: ee,
1243
+ active: null,
1244
+ onPick: z,
1245
+ spread: N,
1246
+ fx: !0,
1247
+ tabStrip: /* @__PURE__ */ Q(g, {
1248
+ layout: "joined",
1249
+ tone: "sunken",
1250
+ value: a,
1251
+ onChange: o,
1252
+ options: Qn,
1253
+ size: i,
1254
+ className: p(i)
1255
+ }),
1256
+ children: /* @__PURE__ */ Q(I, {
1257
+ schema: yt,
1258
+ layer: e,
1259
+ setProp: T.setProp,
1260
+ palette: w,
1261
+ renderAnimate: (t) => /* @__PURE__ */ Q(Ge, {
1262
+ layer: e,
1263
+ param: t,
1264
+ setProp: T.setProp
1265
+ }),
1266
+ tab: a === "anim" ? "anim" : "style",
1267
+ emptyHint: "Pick an effect from the nav."
1268
+ })
1269
+ });
1270
+ let G = A.def.params.filter((e) => c(e) !== "anim"), de = ae(A.def.id), K = de ? G.findIndex((e) => e.key === de) : -1, fe = G.length;
1271
+ if (K >= 0) {
1272
+ let e = K;
1273
+ for (; e + 1 < G.length && G[e + 1].type === "select";) e++;
1274
+ fe = e + 1;
1275
+ }
1276
+ let pe = K > 0 ? G.slice(0, K) : [], me = K >= 0 ? G.slice(K, fe).map((e) => ({
1277
+ ...e,
1278
+ section: void 0
1279
+ })) : G, ye = {
1280
+ layer: V,
1281
+ setProp: U,
1282
+ palette: w,
1283
+ renderAnimate: re,
1284
+ inline: !0
1285
+ };
1286
+ return /* @__PURE__ */ $(rr, {
1287
+ chips: ee,
1288
+ active: A.id,
1289
+ onPick: z,
1290
+ spread: N,
1291
+ title: te,
1292
+ fx: !0,
1293
+ scope: A.id,
1294
+ ghostLabels: A.def.params.map((e) => e.label).filter(Boolean),
1295
+ tabStrip: /* @__PURE__ */ Q(g, {
1296
+ layout: "joined",
1297
+ tone: "sunken",
1298
+ value: a,
1299
+ onChange: o,
1300
+ options: Qn,
1301
+ size: i,
1302
+ className: p(i)
1303
+ }),
1304
+ children: [a === "effect" && /* @__PURE__ */ $(nn, { children: [
1305
+ pe.length > 0 && /* @__PURE__ */ Q(I, {
1306
+ schema: pe,
1307
+ ...ye
1308
+ }),
1309
+ /* @__PURE__ */ $(b, {
1310
+ divided: !0,
1311
+ children: [/* @__PURE__ */ Q(I, {
1312
+ schema: me,
1313
+ ...ye
1314
+ }), /* @__PURE__ */ Q(Ke, {
1315
+ inline: !0,
1316
+ def: A.def,
1317
+ view: V,
1318
+ tab: "effect",
1319
+ onPatch: ie,
1320
+ levels: /* @__PURE__ */ $(nn, { children: [
1321
+ [
1322
+ ["type", "Type"],
1323
+ ["category", "Category"],
1324
+ ["preset", "Preset"]
1325
+ ].filter(([e]) => _e(A.def, e)).map(([t, n]) => /* @__PURE__ */ Q(f, {
1326
+ tone: "primary",
1327
+ size: i,
1328
+ className: "flex-1 min-w-0",
1329
+ "aria-label": `Randomize ${n.toLowerCase()}`,
1330
+ onClick: () => {
1331
+ let n = k(P() >>> 0);
1332
+ if (t === "preset") {
1333
+ let e = ge(A.def, V, n);
1334
+ e != null && ie(ue(A.def, e));
1335
+ return;
1336
+ }
1337
+ let r = he(A.id, t, n);
1338
+ r && u(e.id, O, r);
1339
+ },
1340
+ children: n
1341
+ }, t)),
1342
+ /* @__PURE__ */ Q(f, {
1343
+ tone: "primary",
1344
+ size: i,
1345
+ className: "flex-1 min-w-0",
1346
+ "aria-label": "Randomize settings",
1347
+ onClick: () => {
1348
+ ie(ve(V, M(A.def.params.filter((e) => c(e) !== "anim"), V), k(P() >>> 0)));
1349
+ },
1350
+ children: "Settings"
1351
+ }),
1352
+ /* @__PURE__ */ Q(Ee, {
1353
+ def: A.def,
1354
+ isFilter: !0
1355
+ })
1356
+ ] })
1357
+ })]
1358
+ }),
1359
+ /* @__PURE__ */ Q(Wt, {}),
1360
+ fe < G.length && /* @__PURE__ */ $(nn, { children: [/* @__PURE__ */ Q(I, {
1361
+ schema: G.slice(fe),
1362
+ ...ye
1363
+ }), /* @__PURE__ */ Q(Wt, {})] }),
1364
+ /* @__PURE__ */ Q(lr, {
1365
+ chain: E,
1366
+ from: O + 1,
1367
+ layer: e,
1368
+ hostView: V,
1369
+ addFilter: l,
1370
+ removeFilter: m,
1371
+ toggleFilter: v,
1372
+ setStagePropAt: H,
1373
+ palette: w,
1374
+ showMod: n
1375
+ })
1376
+ ] }), a === "anim" && /* @__PURE__ */ $(nn, { children: [
1377
+ /* @__PURE__ */ Q(Gn, {
1378
+ schema: A.def.params,
1379
+ layer: V,
1380
+ setProp: U,
1381
+ inputs: A.def.inputs
1382
+ }),
1383
+ /* @__PURE__ */ Q(I, {
1384
+ schema: A.def.params,
1385
+ ...ye,
1386
+ tab: "anim"
1387
+ }),
1388
+ A.def.orbit && /* @__PURE__ */ Q(b, {
1389
+ label: "Interaction",
1390
+ divided: !0,
1391
+ children: /* @__PURE__ */ Q(S, {
1392
+ label: "ORBIT (C)",
1393
+ align: "fill",
1394
+ labelWidth: d,
1395
+ children: /* @__PURE__ */ Q(g, {
1396
+ layout: "joined",
1397
+ tone: "sunken",
1398
+ size: i,
1399
+ className: "w-full",
1400
+ value: r.grab && V.orbit !== !1 ? "on" : "off",
1401
+ options: [{
1402
+ value: "off",
1403
+ label: "Off"
1404
+ }, {
1405
+ value: "on",
1406
+ label: "On"
1407
+ }],
1408
+ onChange: (e) => {
1409
+ U("orbit", e === "on"), e === "on" && !r.grab && s("grab", !0);
1410
+ }
1411
+ })
1412
+ })
1413
+ }),
1414
+ /* @__PURE__ */ Q(b, {
1415
+ divided: !0,
1416
+ children: /* @__PURE__ */ Q(Ke, {
1417
+ inline: !0,
1418
+ def: A.def,
1419
+ view: V,
1420
+ tab: "anim",
1421
+ onPatch: ie
1422
+ })
1423
+ }),
1424
+ A.def.sweeps && /* @__PURE__ */ Q(qe, {
1425
+ sweeps: Array.isArray(A.params.sweeps) ? A.params.sweeps : [],
1426
+ onChange: (e) => U("sweeps", e),
1427
+ inline: !0
1428
+ }),
1429
+ /* @__PURE__ */ Q(Hn, {
1430
+ schema: A.def.params,
1431
+ layer: V,
1432
+ setProp: U
1433
+ }),
1434
+ /* @__PURE__ */ Q(sr, {
1435
+ chain: E,
1436
+ layer: e,
1437
+ hostView: V,
1438
+ addFilter: l,
1439
+ removeFilter: m,
1440
+ setStagePropAt: H,
1441
+ palette: w,
1442
+ showMod: n
1443
+ })
1444
+ ] })]
1445
+ });
1446
+ }
1447
+ var ar = W.filter((e) => !e.kind && !e.first);
1448
+ function or({ layer: e, edit: t, palette: n, showMod: r }) {
1449
+ let { addFilter: i, removeFilter: a, toggleFilter: o } = h(), s = x(e), c = s.map(({ def: e, ...t }) => t);
1450
+ return /* @__PURE__ */ Q(lr, {
1451
+ chain: s,
1452
+ from: 0,
1453
+ filters: ar,
1454
+ layer: e,
1455
+ hostView: e,
1456
+ addFilter: i,
1457
+ removeFilter: a,
1458
+ toggleFilter: o,
1459
+ setStagePropAt: (e) => (n, r) => t.patch({ filters: c.map((t, i) => i === e ? {
1460
+ ...t,
1461
+ params: {
1462
+ ...t.params,
1463
+ [n]: r
1464
+ }
1465
+ } : t) }),
1466
+ palette: n,
1467
+ showMod: r
1468
+ });
1469
+ }
1470
+ function sr({ chain: e, layer: t, hostView: n, addFilter: r, removeFilter: i, setStagePropAt: a, palette: o, showMod: s }) {
1471
+ let c = _(), l = e.findIndex((e) => e.id === "fx-media"), u = l < 0 ? null : e[l], d = u ? {
1472
+ ...n,
1473
+ ...u.params,
1474
+ id: t.id
1475
+ } : null, p = u ? a(l) : null;
1476
+ return /* @__PURE__ */ Q(b, {
1477
+ label: "Media",
1478
+ divided: !0,
1479
+ children: u?.def ? /* @__PURE__ */ $(nn, { children: [/* @__PURE__ */ Q(I, {
1480
+ schema: u.def.params,
1481
+ layer: d,
1482
+ setProp: p,
1483
+ palette: o,
1484
+ inline: !0,
1485
+ renderAnimate: s ? (e) => /* @__PURE__ */ Q(Ge, {
1486
+ layer: d,
1487
+ param: e,
1488
+ setProp: p
1489
+ }) : void 0
1490
+ }), /* @__PURE__ */ Q(f, {
1491
+ tone: "primary",
1492
+ size: c,
1493
+ className: "w-full",
1494
+ iconLeft: "x",
1495
+ iconSize: 12,
1496
+ onClick: () => i(t.id, l),
1497
+ children: "Remove media motion"
1498
+ })] }) : e.length < 8 && /* @__PURE__ */ Q(f, {
1499
+ tone: "primary",
1500
+ size: c,
1501
+ className: "w-full",
1502
+ iconLeft: "plus",
1503
+ iconSize: 12,
1504
+ onClick: () => r(t.id, "fx-media"),
1505
+ children: "Add media motion"
1506
+ })
1507
+ });
1508
+ }
1509
+ function cr({ chain: e, from: t = 0, layer: n, hostView: r, toggleFilter: i, removeFilter: a, setStagePropAt: o, palette: s, showMod: l }) {
1510
+ let u = _();
1511
+ return e.slice(t).map((e, d) => {
1512
+ let p = d + t, m = e.enabled !== !1, h = {
1513
+ ...r,
1514
+ ...e.params,
1515
+ id: n.id
1516
+ }, g = o(p);
1517
+ return /* @__PURE__ */ $("div", {
1518
+ className: "flex flex-col gap-2 p-2 rounded bg-oq-04",
1519
+ children: [/* @__PURE__ */ $("div", {
1520
+ className: "flex items-center gap-2",
1521
+ children: [/* @__PURE__ */ Q(O, {
1522
+ size: u,
1523
+ checked: m,
1524
+ onChange: () => i(n.id, p),
1525
+ label: e.def?.label ?? e.id
1526
+ }), /* @__PURE__ */ Q(Jt, {
1527
+ asChild: !0,
1528
+ label: "Delete effect",
1529
+ children: /* @__PURE__ */ Q(f, {
1530
+ tone: "ghost",
1531
+ quiet: !0,
1532
+ size: "xs",
1533
+ iconOnly: "x",
1534
+ "aria-label": "Delete effect",
1535
+ className: "ml-auto shrink-0",
1536
+ onClick: () => a(n.id, p)
1537
+ })
1538
+ })]
1539
+ }), m && e.def && /* @__PURE__ */ Q(I, {
1540
+ schema: e.def.params.filter((e) => c(e) !== "anim"),
1541
+ layer: h,
1542
+ setProp: g,
1543
+ palette: s,
1544
+ inline: !0,
1545
+ renderAnimate: l ? (e) => /* @__PURE__ */ Q(Ge, {
1546
+ layer: h,
1547
+ param: e,
1548
+ setProp: g
1549
+ }) : void 0
1550
+ })]
1551
+ }, e.key ?? p);
1552
+ });
1553
+ }
1554
+ function lr({ chain: e, from: t = 1, filters: n = null, layer: r, hostView: i, addFilter: a, removeFilter: o, toggleFilter: s, setStagePropAt: c, palette: l, showMod: u }) {
1555
+ let d = _(), f = [{
1556
+ value: "",
1557
+ label: "Add FX…"
1558
+ }, ...(n ?? U(W)).map((e) => ({
1559
+ value: e.id,
1560
+ label: e.label ?? e.id
1561
+ }))];
1562
+ return /* @__PURE__ */ $(b, {
1563
+ label: "Post-Processing",
1564
+ divided: !0,
1565
+ children: [/* @__PURE__ */ Q(cr, {
1566
+ chain: e,
1567
+ from: t,
1568
+ layer: r,
1569
+ hostView: i,
1570
+ toggleFilter: s,
1571
+ removeFilter: o,
1572
+ setStagePropAt: c,
1573
+ palette: l,
1574
+ showMod: u
1575
+ }), e.length < 8 && /* @__PURE__ */ Q(F, {
1576
+ variant: "subtle",
1577
+ size: d,
1578
+ className: "w-full",
1579
+ options: f,
1580
+ value: "",
1581
+ onChange: (e) => {
1582
+ e && a(r.id, e);
1583
+ }
1584
+ })]
1585
+ });
1586
+ }
1587
+ function ur({ layer: e, showMod: t, tree: n }) {
1588
+ let r = _(), [i, a] = Z("generate"), { updateLayer: o, palette: s } = h(), { setOnly: c } = Te(), l = R(e.id, { history: "coalesce" }), u = B(e.loopGroup).find((t) => t.id === e.presetId), d = V(e.loopGroup), f = (n ?? Oe).find((t) => t.groups.includes(e.loopGroup)), m = f?.labels?.[e.loopGroup] ?? d?.label ?? "", v = f && f.label !== m ? `${f.label} / ${m}` : m, y = e.loopGroup === "paratype" && u?.sub === "Glyphs" ? z("paratype", "Glyphs") : null, b = y ? y.map((e) => ({
1589
+ value: e.id,
1590
+ label: e.label
1591
+ })) : null, x = (t) => {
1592
+ let n = y?.find((e) => e.id === t);
1593
+ n && t !== e.presetId && c(e.type, de(n, e.loopGroup));
1594
+ }, S = () => {
1595
+ u && c(e.type, de(u, e.loopGroup));
1596
+ };
1597
+ return Zn(S, () => {
1598
+ let t = K(e.loopId)?.params ?? [];
1599
+ o(e.id, C(e, M(t, e), P(), { withFilters: !0 }));
1600
+ }), /* @__PURE__ */ $(rr, {
1601
+ title: v,
1602
+ chips: b,
1603
+ active: e.presetId,
1604
+ onPick: x,
1605
+ pills: !0,
1606
+ scope: e.loopId,
1607
+ ghostLabels: (K(e.loopId)?.params ?? []).filter((e) => e.type !== "color" && e.label).map((e) => e.label),
1608
+ tabStrip: /* @__PURE__ */ Q(g, {
1609
+ layout: "joined",
1610
+ tone: "sunken",
1611
+ value: i,
1612
+ onChange: a,
1613
+ options: r === "sm" ? $n : er,
1614
+ size: r,
1615
+ className: p(r)
1616
+ }),
1617
+ children: [
1618
+ i === "anim" && /* @__PURE__ */ Q(Gn, {
1619
+ schema: K(e.loopId)?.params ?? [],
1620
+ layer: e,
1621
+ setProp: l.setProp,
1622
+ inputs: K(e.loopId)?.inputs
1623
+ }),
1624
+ /* @__PURE__ */ Q(De, {
1625
+ layer: e,
1626
+ setProp: l.setProp,
1627
+ patch: l.patch,
1628
+ updateLayer: o,
1629
+ palette: s,
1630
+ renderAnimate: t ? (t) => /* @__PURE__ */ Q(Ge, {
1631
+ layer: e,
1632
+ param: t,
1633
+ setProp: l.setProp
1634
+ }) : void 0,
1635
+ tab: i,
1636
+ tabStrip: null,
1637
+ tree: n,
1638
+ inline: !0,
1639
+ onReset: S
1640
+ }),
1641
+ i === "generate" && e.loopId === "scene3d" && e.primitive === "mesh" && /* @__PURE__ */ Q(Xn, {
1642
+ layer: e,
1643
+ setProp: l.setProp
1644
+ }),
1645
+ i === "style" && /* @__PURE__ */ Q(or, {
1646
+ layer: e,
1647
+ edit: l,
1648
+ palette: s,
1649
+ showMod: t
1650
+ }),
1651
+ i === "anim" && /* @__PURE__ */ Q(Hn, {
1652
+ schema: K(e.loopId)?.params ?? [],
1653
+ layer: e,
1654
+ setProp: l.setProp
1655
+ })
1656
+ ]
1657
+ });
1658
+ }
1659
+ function dr({ layer: e, showMod: t }) {
1660
+ let n = _(), [r, i] = Z("generate"), { updateLayer: a, palette: o } = h(), { setOnly: s } = Te(), c = R(e.id, { history: "coalesce" }), l = Je.find((t) => t.id === e.presetId), u = Xe.find((e) => e.subs.includes(l?.sub))?.label ?? "Kinetic";
1661
+ return Zn(() => {
1662
+ l && s("kinetic", {
1663
+ presetId: l.id,
1664
+ presetLabel: l.label,
1665
+ comp: Ye(l)
1666
+ });
1667
+ }, () => {
1668
+ let t = P(), n = k(t >>> 0), r = e.comp ?? { instances: [] };
1669
+ (r.instances ?? []).forEach((e, t) => {
1670
+ r = Qe(r, t, n);
1671
+ }), a(e.id, {
1672
+ comp: r,
1673
+ _rollSeed: t
1674
+ });
1675
+ }), /* @__PURE__ */ Q(rr, {
1676
+ title: u,
1677
+ tabStrip: /* @__PURE__ */ Q(g, {
1678
+ layout: "joined",
1679
+ tone: "sunken",
1680
+ value: r,
1681
+ onChange: i,
1682
+ options: n === "sm" ? $n : er,
1683
+ size: n,
1684
+ className: p(n)
1685
+ }),
1686
+ children: /* @__PURE__ */ Q(Ze, {
1687
+ layer: e,
1688
+ setProp: c.setProp,
1689
+ updateLayer: a,
1690
+ palette: o,
1691
+ renderAnimate: t ? (t) => /* @__PURE__ */ Q(Ge, {
1692
+ layer: e,
1693
+ param: t,
1694
+ setProp: c.setProp
1695
+ }) : () => null,
1696
+ tab: r,
1697
+ tabStrip: null
1698
+ })
1699
+ });
1700
+ }
1701
+ function fr() {
1702
+ let { layer: e } = Te(), t = He(), n = _(), r = We();
1703
+ return Y(() => {
1704
+ let e = (e) => {
1705
+ e.key !== "m" && e.key !== "M" || e.metaKey || e.ctrlKey || e.altKey || pt(e) || Ue();
1706
+ };
1707
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1708
+ }, []), t.active ? /* @__PURE__ */ Q(rr, {
1709
+ title: "Morph",
1710
+ children: /* @__PURE__ */ Q(Rn, {
1711
+ layer: e,
1712
+ editTabs: n === "sm" ? $n : er
1713
+ })
1714
+ }) : e ? e.type === "photo" ? /* @__PURE__ */ Q(ir, {
1715
+ layer: e,
1716
+ showMod: r
1717
+ }, e.id) : e.type === "loop" ? /* @__PURE__ */ Q(ur, {
1718
+ layer: e,
1719
+ showMod: r
1720
+ }, e.id) : e.type === "misc" ? /* @__PURE__ */ Q(ur, {
1721
+ layer: e,
1722
+ showMod: r,
1723
+ tree: be
1724
+ }, e.id) : e.type === "kinetic" ? /* @__PURE__ */ Q(dr, {
1725
+ layer: e,
1726
+ showMod: r
1727
+ }, e.id) : /* @__PURE__ */ Q(L, { children: "This layer has no labs surface." }) : /* @__PURE__ */ Q(L, { children: "Pick an effect or generator from the nav." });
1728
+ }
1729
+ //#endregion
1730
+ //#region src/editor/mobile/CategoryScreen.jsx
1731
+ function pr(e) {
1732
+ Y(() => {
1733
+ let t = (t) => {
1734
+ t.key === "Escape" && e?.();
1735
+ };
1736
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
1737
+ }, [e]), Y(() => {
1738
+ let e = i.isPlaying();
1739
+ return i.pause(), () => {
1740
+ e && i.play();
1741
+ };
1742
+ }, []);
1743
+ }
1744
+ function mr({ onPick: e, onInsert: t, onBack: n, onDismiss: r }) {
1745
+ return pr(r ?? n), /* @__PURE__ */ Q("div", {
1746
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
1747
+ style: { zIndex: "var(--kol-z-modal)" },
1748
+ children: /* @__PURE__ */ $("div", {
1749
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1750
+ style: { background: "var(--kol-surface-primary)" },
1751
+ children: [
1752
+ /* @__PURE__ */ Q("div", {
1753
+ className: "kol-eyebrow text-body",
1754
+ children: "Pick a generator"
1755
+ }),
1756
+ /* @__PURE__ */ Q("div", {
1757
+ className: "flex flex-col gap-2",
1758
+ children: Oe.map((t) => {
1759
+ let n = kn[`gen:${t.label}`] ?? "square";
1760
+ return /* @__PURE__ */ Q(J, {
1761
+ tone: "primary",
1762
+ size: "lg",
1763
+ className: Lt,
1764
+ iconLeft: n,
1765
+ iconRight: n,
1766
+ onClick: () => e(t),
1767
+ children: t.label
1768
+ }, t.label);
1769
+ })
1770
+ }),
1771
+ /* @__PURE__ */ $("div", {
1772
+ className: "flex flex-col gap-2",
1773
+ children: [t && /* @__PURE__ */ Q(J, {
1774
+ tone: "grey",
1775
+ size: "lg",
1776
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1777
+ iconLeft: "image",
1778
+ iconRight: "image",
1779
+ onClick: t,
1780
+ children: "Insert image or video"
1781
+ }), n && /* @__PURE__ */ Q(J, {
1782
+ tone: "grey",
1783
+ size: "lg",
1784
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1785
+ iconLeft: "arrow-left",
1786
+ iconRight: "arrow-left",
1787
+ onClick: n,
1788
+ children: "Back"
1789
+ })]
1790
+ })
1791
+ ]
1792
+ })
1793
+ });
1794
+ }
1795
+ //#endregion
1796
+ //#region src/editor/labs/LabsSourcePicker.jsx
1797
+ var hr = (e) => /\.svg$/i.test(e.key) || /svg/i.test(e.contentType || "");
1798
+ function gr(e) {
1799
+ let { patch: t } = R(e.id), n = X(null), [r, i] = Z(!1), a = e.type === "loop" && e.loopGroup === "distress";
1800
+ return {
1801
+ nodes: /* @__PURE__ */ $(nn, { children: [/* @__PURE__ */ Q("input", {
1802
+ ref: n,
1803
+ type: "file",
1804
+ accept: a ? ".svg,image/svg+xml" : "image/*,video/*",
1805
+ className: "hidden",
1806
+ onChange: (n) => {
1807
+ let r = n.target.files?.[0];
1808
+ if (n.target.value = "", r) {
1809
+ if (a) {
1810
+ let e = new FileReader();
1811
+ e.onload = () => t({ svgSrc: e.result }), e.readAsText(r);
1812
+ return;
1813
+ }
1814
+ if (r.type.startsWith("video/")) {
1815
+ w(e.id, r), t({
1816
+ src: URL.createObjectURL(r),
1817
+ srcType: "video"
1818
+ });
1819
+ return;
1820
+ }
1821
+ nt(r).then((e) => t({
1822
+ src: e,
1823
+ srcType: "image"
1824
+ }));
1825
+ }
1826
+ }
1827
+ }), /* @__PURE__ */ Q(Bt, {
1828
+ open: r,
1829
+ accept: a ? hr : ["image", "video"],
1830
+ onClose: () => i(!1),
1831
+ onSelect: (e, { contentType: n } = {}) => {
1832
+ if (a) {
1833
+ t({ svgSrc: Ct(e) });
1834
+ return;
1835
+ }
1836
+ t({
1837
+ src: Ct(e),
1838
+ srcType: ct(n) ? "video" : "image"
1839
+ });
1840
+ }
1841
+ })] }),
1842
+ svgMode: a,
1843
+ openLibrary: () => i(!0),
1844
+ openUpload: () => n.current?.click(),
1845
+ openCamera: () => {
1846
+ tt(e.id).then(() => t({
1847
+ src: null,
1848
+ srcType: "webcam"
1849
+ })).catch(() => {});
1850
+ }
1851
+ };
1852
+ }
1853
+ [
1854
+ {
1855
+ value: "library",
1856
+ label: "Library"
1857
+ },
1858
+ {
1859
+ value: "upload",
1860
+ label: "Upload"
1861
+ },
1862
+ {
1863
+ value: "camera",
1864
+ label: "Camera"
1865
+ }
1866
+ ].slice(0, 2);
1867
+ function _r({ layer: e }) {
1868
+ let t = gr(e);
1869
+ return /* @__PURE__ */ $("div", {
1870
+ className: "flex flex-col gap-2",
1871
+ children: [
1872
+ /* @__PURE__ */ Q(f, {
1873
+ tone: "primary",
1874
+ size: "lg",
1875
+ className: Lt,
1876
+ iconLeft: "image",
1877
+ iconRight: "image",
1878
+ onClick: t.openLibrary,
1879
+ children: "From library"
1880
+ }),
1881
+ /* @__PURE__ */ Q(f, {
1882
+ tone: "primary",
1883
+ size: "lg",
1884
+ className: Lt,
1885
+ iconLeft: "upload",
1886
+ iconRight: "upload",
1887
+ onClick: t.openUpload,
1888
+ children: "Upload"
1889
+ }),
1890
+ !t.svgMode && /* @__PURE__ */ Q(f, {
1891
+ tone: "primary",
1892
+ size: "lg",
1893
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
1894
+ iconLeft: "camera",
1895
+ iconRight: "camera",
1896
+ onClick: t.openCamera,
1897
+ children: "Camera"
1898
+ }),
1899
+ t.nodes
1900
+ ]
1901
+ });
1902
+ }
1903
+ function vr({ layer: e, title: t, onBack: n }) {
1904
+ return pr(n), /* @__PURE__ */ Q("div", {
1905
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
1906
+ style: { zIndex: "calc(var(--kol-z-sticky) - 2)" },
1907
+ children: /* @__PURE__ */ $("div", {
1908
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
1909
+ style: { background: "var(--kol-surface-primary)" },
1910
+ children: [
1911
+ /* @__PURE__ */ $("div", {
1912
+ className: "flex flex-col gap-2",
1913
+ children: [/* @__PURE__ */ Q("span", {
1914
+ className: "kol-eyebrow text-body",
1915
+ children: t
1916
+ }), /* @__PURE__ */ Q("span", {
1917
+ className: "kol-mono-12 text-meta",
1918
+ children: "Pick the media it works on."
1919
+ })]
1920
+ }),
1921
+ /* @__PURE__ */ Q(_r, { layer: e }),
1922
+ /* @__PURE__ */ Q(f, {
1923
+ tone: "grey",
1924
+ size: "lg",
1925
+ className: Lt,
1926
+ iconLeft: "arrow-left",
1927
+ iconRight: "arrow-left",
1928
+ onClick: n,
1929
+ children: "Back"
1930
+ })
1931
+ ]
1932
+ })
1933
+ });
1934
+ }
1935
+ //#endregion
1936
+ //#region src/editor/components/PanelHeader.jsx
1937
+ function yr({ title: e, onCollapse: t, action: n, className: r = "px-3" }) {
1938
+ return /* @__PURE__ */ $("div", {
1939
+ className: `flex w-full shrink-0 items-center ${r}`,
1940
+ children: [/* @__PURE__ */ $("button", {
1941
+ className: "kol-helper-12 text-meta flex flex-1 items-center gap-2 py-2.5",
1942
+ onClick: t,
1943
+ children: [/* @__PURE__ */ Q("span", { children: e }), /* @__PURE__ */ Q(rn, {
1944
+ name: "chevron-down",
1945
+ size: 16,
1946
+ className: "text-oq-48"
1947
+ })]
1948
+ }), n]
1949
+ });
1950
+ }
1951
+ function br({ label: e, onOpen: t, size: n = "lg", tone: r = "primary", children: i }) {
1952
+ return /* @__PURE__ */ $("div", {
1953
+ className: "pointer-events-none fixed bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-[var(--fxr-rail,0px)] right-0 z-10 flex flex-nowrap items-center gap-2 px-3 [&>*]:pointer-events-auto",
1954
+ children: [/* @__PURE__ */ Q(J, {
1955
+ tone: r,
1956
+ size: n,
1957
+ onClick: t,
1958
+ className: "min-w-0 shrink",
1959
+ children: /* @__PURE__ */ $("span", {
1960
+ className: "flex items-center gap-2 min-w-0",
1961
+ children: [/* @__PURE__ */ Q("span", {
1962
+ className: "truncate",
1963
+ children: e
1964
+ }), /* @__PURE__ */ Q(rn, {
1965
+ name: "chevron-down",
1966
+ size: 16,
1967
+ className: "rotate-180 shrink-0"
1968
+ })]
1969
+ })
1970
+ }), i]
1971
+ });
1972
+ }
1973
+ var xr = {
1974
+ half: "50dvh",
1975
+ tall: "85dvh"
1976
+ }, Sr = 4;
1977
+ function Cr({ tall: e, onToggle: t, onDrag: n, onResize: r, onResizeEnd: i }) {
1978
+ let a = X(null);
1979
+ Yt(a, { axis: "x" });
1980
+ let o = X({
1981
+ y: null,
1982
+ h0: 0,
1983
+ moved: !1,
1984
+ swallow: !1,
1985
+ last: 0
1986
+ }).current;
1987
+ return /* @__PURE__ */ Q("button", {
1988
+ ref: a,
1989
+ type: "button",
1990
+ "aria-label": e ? "Lower the sheet" : "Raise the sheet",
1991
+ "aria-pressed": e,
1992
+ className: "kol-sheet-grab relative flex h-6 w-full shrink-0 touch-none items-center justify-center",
1993
+ onPointerDown: (e) => {
1994
+ o.y = e.clientY, o.moved = !1, o.h0 = window.innerHeight - e.currentTarget.getBoundingClientRect().top, e.currentTarget.setPointerCapture?.(e.pointerId);
1995
+ },
1996
+ onPointerMove: (e) => {
1997
+ if (o.y === null) return;
1998
+ let t = e.clientY - o.y;
1999
+ Math.abs(t) > Sr && (o.moved = !0), o.moved && r && (o.last = o.h0 - t, r(o.last));
2000
+ },
2001
+ onPointerUp: (e) => {
2002
+ if (o.y === null) return;
2003
+ let t = e.clientY - o.y;
2004
+ o.y = null, o.moved && (o.swallow = !0, r ? i?.(o.h0 - t) : n?.(t < 0 ? -1 : 1));
2005
+ },
2006
+ onPointerCancel: () => {
2007
+ o.y = null;
2008
+ },
2009
+ onClick: () => {
2010
+ if (o.swallow) {
2011
+ o.swallow = !1;
2012
+ return;
2013
+ }
2014
+ t?.();
2015
+ },
2016
+ children: /* @__PURE__ */ Q("span", { className: "h-1 w-9 rounded-full bg-oq-16" })
2017
+ });
2018
+ }
2019
+ //#endregion
2020
+ //#region src/editor/labs/LabsCatalogCard.jsx
2021
+ var wr = new Set(["#rail/sec:effects"]);
2022
+ function Tr({ onPicked: e, onClose: t, initialOpen: n = null, hasMedia: r = !0, onNeedMedia: i }) {
2023
+ let { items: a, dispatch: o } = Tt(), [s, c] = Z(n);
2024
+ pr(t);
2025
+ let l = a.find((e) => e.path === s) ?? null, u = l ? l.sub : a;
2026
+ return /* @__PURE__ */ Q("div", {
2027
+ className: "fixed bottom-0 top-12 md:top-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
2028
+ style: { zIndex: "calc(var(--kol-z-sticky) - 2)" },
2029
+ onClick: (e) => {
2030
+ e.target === e.currentTarget && t?.();
2031
+ },
2032
+ children: /* @__PURE__ */ $("div", {
2033
+ className: "my-auto w-full max-w-sm rounded p-4 flex flex-col gap-6",
2034
+ style: { background: "var(--kol-surface-primary)" },
2035
+ children: [/* @__PURE__ */ Q("span", {
2036
+ className: "kol-eyebrow text-body",
2037
+ children: l ? l.label : "Labs"
2038
+ }), /* @__PURE__ */ $("div", {
2039
+ className: "flex flex-col gap-2",
2040
+ children: [u.map((t) => /* @__PURE__ */ Q(J, {
2041
+ tone: "primary",
2042
+ size: "lg",
2043
+ className: Lt,
2044
+ iconLeft: t.icon,
2045
+ iconRight: t.icon,
2046
+ onClick: () => {
2047
+ if (!l && wr.has(t.path) && !r && i) {
2048
+ i(t.path);
2049
+ return;
2050
+ }
2051
+ if (!l && t.sub?.length) {
2052
+ c(t.path);
2053
+ return;
2054
+ }
2055
+ o?.(t.path) && e?.();
2056
+ },
2057
+ children: t.label
2058
+ }, t.path)), l && /* @__PURE__ */ Q(J, {
2059
+ tone: "grey",
2060
+ size: "lg",
2061
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
2062
+ iconLeft: "arrow-left",
2063
+ iconRight: "arrow-left",
2064
+ onClick: () => c(null),
2065
+ children: "Back"
2066
+ })]
2067
+ })]
2068
+ })
2069
+ });
2070
+ }
2071
+ //#endregion
2072
+ //#region src/editor/labs/sheetLabels.js
2073
+ function Er(e) {
2074
+ if (Le().active) return {
2075
+ title: "Morph",
2076
+ pill: "Morph"
2077
+ };
2078
+ if (!e) return {
2079
+ title: "Labs",
2080
+ pill: "Labs"
2081
+ };
2082
+ if (e.type === "loop" || e.type === "misc") return {
2083
+ title: V(e.loopGroup)?.label ?? "Labs",
2084
+ kind: e.presetLabel,
2085
+ pill: e.presetLabel
2086
+ };
2087
+ if (e.type === "photo") {
2088
+ let t = x(e)[0]?.def?.label ?? "Media";
2089
+ return {
2090
+ title: t,
2091
+ pill: t
2092
+ };
2093
+ }
2094
+ let t = e.presetLabel ?? "Labs";
2095
+ return {
2096
+ title: t,
2097
+ pill: t
2098
+ };
2099
+ }
2100
+ //#endregion
2101
+ //#region src/editor/labs/LabsView.jsx
2102
+ var Dr = .85, Or = .3, kr = 2.5, Ar = {
2103
+ 0: 1,
2104
+ 1: .5,
2105
+ 2: 1,
2106
+ 3: 1.5,
2107
+ 4: 2
2108
+ }, jr = "px-2 py-1 rounded border border-oq-08 bg-surface-secondary kol-mono-12 text-emphasis tabular-nums";
2109
+ function Mr() {
2110
+ let { layer: t } = Te(), { removeLayer: n, layers: r, updateLayer: a, beginTransaction: o, commitTransaction: s, select: c } = h(), [l, u] = Z(null);
2111
+ Y(() => {
2112
+ let e = (e) => {
2113
+ let { id: t, index: n } = e.detail || {};
2114
+ if (l?.id === t) {
2115
+ u(null);
2116
+ return;
2117
+ }
2118
+ r.some((e) => e.id === t && e.type === "kinetic" && !e.locked) && (c(t), u({
2119
+ id: t,
2120
+ index: n ?? 0
2121
+ }));
2122
+ };
2123
+ return window.addEventListener("kol:kinetic-edit", e), () => window.removeEventListener("kol:kinetic-edit", e);
2124
+ }, [
2125
+ r,
2126
+ l,
2127
+ c
2128
+ ]);
2129
+ let d = l && r.find((e) => e.id === l.id && e.type === "kinetic"), f = t?.type === "photo" && !t.src && t.srcType !== "webcam", [p, m] = Z(1), [g, _] = Z(!1), v = T(g), y = X(null), b = (e) => Math.min(kr, Math.max(Or, e)), x = (e) => m((t) => b(t * (e > 0 ? 1.25 : .8))), { tool: S } = lt(), C = S === "orbit", w = X(C);
2130
+ w.current = C, Y(() => {
2131
+ let t = y.current;
2132
+ if (!t) return;
2133
+ let n = (t) => {
2134
+ w.current || (t.preventDefault(), !e().zoomLock && m((e) => b(e * (t.deltaY > 0 ? .94 : 1.06))));
2135
+ };
2136
+ return t.addEventListener("wheel", n, { passive: !1 }), () => t.removeEventListener("wheel", n);
2137
+ }, []), Y(() => {
2138
+ let t = (t) => {
2139
+ if (!(t.metaKey || t.ctrlKey || t.altKey) && !pt(t)) {
2140
+ if (t.key === "f" || t.key === "F") {
2141
+ _((e) => !e);
2142
+ return;
2143
+ }
2144
+ if (!(e().zoomLock && (t.key === "-" || t.key === "_" || t.key === "+" || t.key === "=" || Ar[t.key] !== void 0))) {
2145
+ if (t.key === "-" || t.key === "_") {
2146
+ x(-1);
2147
+ return;
2148
+ }
2149
+ if (t.key === "+" || t.key === "=") {
2150
+ x(1);
2151
+ return;
2152
+ }
2153
+ Ar[t.key] !== void 0 && m(Ar[t.key]);
2154
+ }
2155
+ }
2156
+ };
2157
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
2158
+ }, []);
2159
+ let [E, D] = Z({
2160
+ x: 0,
2161
+ y: 0
2162
+ }), O = X({
2163
+ pts: /* @__PURE__ */ new Map(),
2164
+ start: null,
2165
+ tap: null
2166
+ }), k = X({
2167
+ zoom: p,
2168
+ pan: E
2169
+ });
2170
+ k.current = {
2171
+ zoom: p,
2172
+ pan: E
2173
+ };
2174
+ let A = (e) => {
2175
+ if (e.pointerType !== "touch") return;
2176
+ let t = O.current;
2177
+ if (t.pts.set(e.pointerId, {
2178
+ x: e.clientX,
2179
+ y: e.clientY
2180
+ }), t.tap = t.pts.size === 1 ? {
2181
+ id: e.pointerId,
2182
+ x: e.clientX,
2183
+ y: e.clientY,
2184
+ at: performance.now()
2185
+ } : null, t.pts.size === 2) {
2186
+ let [n, r] = [...t.pts.values()], a = y.current.getBoundingClientRect(), o = a.left + a.width / 2, s = a.top + a.height / 2, c = (n.x + r.x) / 2, l = (n.y + r.y) / 2, { zoom: u, pan: d } = k.current;
2187
+ t.start = {
2188
+ d: Math.hypot(n.x - r.x, n.y - r.y),
2189
+ cx: o,
2190
+ cy: s,
2191
+ z0: u,
2192
+ qx: (c - o - d.x) / u,
2193
+ qy: (l - s - d.y) / u
2194
+ }, i.setStagePointer?.(null), e.stopPropagation();
2195
+ }
2196
+ }, j = (t) => {
2197
+ let n = O.current;
2198
+ if (!(t.pointerType !== "touch" || !n.pts.has(t.pointerId)) && (n.pts.set(t.pointerId, {
2199
+ x: t.clientX,
2200
+ y: t.clientY
2201
+ }), n.pts.size >= 2 && n.start)) {
2202
+ t.stopPropagation();
2203
+ let [r, i] = [...n.pts.values()], a = n.start, o = e().zoomLock ? a.z0 : b(a.z0 * (Math.hypot(r.x - i.x, r.y - i.y) / a.d)), s = (r.x + i.x) / 2, c = (r.y + i.y) / 2;
2204
+ m(o), D({
2205
+ x: s - a.cx - o * a.qx,
2206
+ y: c - a.cy - o * a.qy
2207
+ });
2208
+ }
2209
+ }, M = (e) => {
2210
+ let n = O.current;
2211
+ if (e.pointerType !== "touch") return;
2212
+ let r = n.tap;
2213
+ r && r.id === e.pointerId && e.type === "pointerup" && !n.start && performance.now() - r.at < 350 && Math.hypot(e.clientX - r.x, e.clientY - r.y) < 12 && (t?.type === "loop" ? K(t.loopId) : null)?.group !== "penrose" && i.toggle(), r?.id === e.pointerId && (n.tap = null), n.pts.delete(e.pointerId), n.pts.size < 2 && (n.start = null);
2214
+ };
2215
+ return /* @__PURE__ */ $("div", {
2216
+ ref: y,
2217
+ className: "relative w-full h-full flex items-center justify-center overflow-hidden touch-none",
2218
+ style: { background: "var(--kol-surface-secondary)" },
2219
+ onDoubleClick: () => {
2220
+ m(1), D({
2221
+ x: 0,
2222
+ y: 0
2223
+ });
2224
+ },
2225
+ onPointerDownCapture: A,
2226
+ onPointerMoveCapture: j,
2227
+ onPointerUpCapture: M,
2228
+ onPointerCancelCapture: M,
2229
+ children: [
2230
+ /* @__PURE__ */ Q("div", {
2231
+ style: {
2232
+ flex: "none",
2233
+ width: `${p * Dr * 100}%`,
2234
+ height: `${p * Dr * 100}%`,
2235
+ transform: `translate(${E.x}px, ${E.y}px)`
2236
+ },
2237
+ children: /* @__PURE__ */ Q(Rt, { overlay: d ? (e) => /* @__PURE__ */ Q(ut, {
2238
+ layer: d,
2239
+ initialIndex: l.index,
2240
+ toVirtual: e,
2241
+ updateLayer: a,
2242
+ beginTransaction: o,
2243
+ commitTransaction: s,
2244
+ onExit: () => u(null)
2245
+ }) : void 0 })
2246
+ }),
2247
+ f && /* @__PURE__ */ Q(vr, {
2248
+ layer: t,
2249
+ title: Er(t).title,
2250
+ onBack: () => n(t.id)
2251
+ }),
2252
+ g && /* @__PURE__ */ Q("div", {
2253
+ className: "absolute bottom-3 right-3 z-[var(--kol-z-base)] flex items-center gap-2 [@media(pointer:coarse)]:bottom-1",
2254
+ children: /* @__PURE__ */ Q(Jt, {
2255
+ label: "Framerate — press F to hide",
2256
+ children: /* @__PURE__ */ $("span", {
2257
+ className: jr,
2258
+ children: [v, " fps"]
2259
+ })
2260
+ })
2261
+ })
2262
+ ]
2263
+ });
2264
+ }
2265
+ function Nr() {
2266
+ let e = X(null), { grabProps: t } = an(e, {
2267
+ token: "kol-rail",
2268
+ side: "right"
2269
+ });
2270
+ return Y(() => {
2271
+ let e = document.documentElement, t = !1, n = () => {
2272
+ let t = parseFloat(getComputedStyle(e).getPropertyValue("--kol-shell-rail-width"));
2273
+ return Number.isFinite(t) ? t <= 49 : null;
2274
+ }, r = () => e.getAttribute("data-rail") === "collapsed", i = () => [...document.querySelectorAll(".kol-rail-grab")].sort((e, t) => e.getBoundingClientRect().left - t.getBoundingClientRect().left)[0], a = () => {
2275
+ let e = i();
2276
+ if (!e) return;
2277
+ let t = e.getBoundingClientRect(), n = {
2278
+ bubbles: !0,
2279
+ cancelable: !0,
2280
+ pointerId: 1,
2281
+ clientX: t.left + t.width / 2,
2282
+ clientY: t.top + t.height / 2
2283
+ };
2284
+ e.dispatchEvent(new PointerEvent("pointerdown", n)), e.dispatchEvent(new PointerEvent("pointerup", n));
2285
+ }, o = () => {
2286
+ if (t) return;
2287
+ let i = n();
2288
+ i === null || i === r() || (t = !0, i ? e.setAttribute("data-rail", "collapsed") : e.removeAttribute("data-rail"), t = !1);
2289
+ }, s = () => {
2290
+ if (t) return;
2291
+ let e = n();
2292
+ e === null || e === r() || (t = !0, a(), t = !1);
2293
+ };
2294
+ o();
2295
+ let c = new MutationObserver(o);
2296
+ c.observe(e, {
2297
+ attributes: !0,
2298
+ attributeFilter: ["style"]
2299
+ });
2300
+ let l = new MutationObserver(s);
2301
+ return l.observe(e, {
2302
+ attributes: !0,
2303
+ attributeFilter: ["data-rail"]
2304
+ }), () => {
2305
+ c.disconnect(), l.disconnect();
2306
+ };
2307
+ }, []), /* @__PURE__ */ $("div", {
2308
+ ref: e,
2309
+ className: "kol-compose-rail kol-compose-rail--inspector",
2310
+ children: [/* @__PURE__ */ Q("div", { ...t }), /* @__PURE__ */ Q("div", {
2311
+ className: "kol-compose-inspector-body",
2312
+ children: /* @__PURE__ */ Q(fr, {})
2313
+ })]
2314
+ });
2315
+ }
2316
+ var Pr = Qt(null);
2317
+ function Fr() {
2318
+ let { tall: e, setTall: t, collapseParams: n, setSheetPx: r } = en(Pr);
2319
+ return /* @__PURE__ */ Q(Cr, {
2320
+ tall: e,
2321
+ onToggle: () => {
2322
+ r(null), t((e) => !e);
2323
+ },
2324
+ onResize: (e) => r(Math.max(96, Math.min(window.innerHeight * .92, e))),
2325
+ onResizeEnd: (e) => {
2326
+ e < 96 && (r(null), n());
2327
+ }
2328
+ });
2329
+ }
2330
+ var Ir = [
2331
+ 2,
2332
+ 4,
2333
+ 8,
2334
+ 12,
2335
+ 16
2336
+ ];
2337
+ function Lr({ paramsOpen: e, setParamsOpen: t, catalog: n, toggleCatalog: r, railHeight: i }) {
2338
+ let { playing: o, loopSeconds: s, play: c, pause: l, stop: u, rewind: d, setLoopSeconds: f } = a(), [p, m] = Z(!0), h = [
2339
+ {
2340
+ icon: "home-01",
2341
+ path: "#home",
2342
+ label: "Home",
2343
+ onPress: () => bt("/")
2344
+ },
2345
+ {
2346
+ icon: "grid",
2347
+ path: "#catalog",
2348
+ label: "Catalog",
2349
+ onPress: r,
2350
+ selected: n
2351
+ },
2352
+ {
2353
+ icon: "slider-01",
2354
+ path: "#params",
2355
+ label: "Params",
2356
+ onPress: () => t((e) => !e),
2357
+ selected: e
2358
+ },
2359
+ {
2360
+ icon: "play-solid",
2361
+ path: "#transport",
2362
+ label: "Transport",
2363
+ onPress: () => m((e) => !e),
2364
+ selected: p
2365
+ }
2366
+ ], g = [{
2367
+ icon: "download",
2368
+ label: "Output",
2369
+ onPress: () => {
2370
+ t(!0), dt("Output");
2371
+ }
2372
+ }, {
2373
+ icon: "file",
2374
+ label: "File",
2375
+ onPress: () => {
2376
+ t(!0), dt("File");
2377
+ }
2378
+ }], _ = p ? {
2379
+ items: [
2380
+ {
2381
+ id: "play",
2382
+ icon: "play",
2383
+ label: "Play",
2384
+ onPress: c,
2385
+ selected: o
2386
+ },
2387
+ {
2388
+ id: "pause",
2389
+ icon: "pause",
2390
+ label: "Pause",
2391
+ onPress: l,
2392
+ selected: !o
2393
+ },
2394
+ {
2395
+ id: "loop",
2396
+ icon: "stopwatch-solid",
2397
+ label: "Loop length"
2398
+ },
2399
+ {
2400
+ id: "stop",
2401
+ icon: "stop",
2402
+ label: "Stop",
2403
+ onPress: u
2404
+ },
2405
+ {
2406
+ id: "rewind",
2407
+ icon: "rewind",
2408
+ label: "Rewind",
2409
+ onPress: d
2410
+ }
2411
+ ],
2412
+ sheetFor: { loop: Ir.map((e) => ({
2413
+ label: `${e} s`,
2414
+ checked: s === e,
2415
+ onPress: () => f(e)
2416
+ })) }
2417
+ } : void 0;
2418
+ return Y(() => {
2419
+ gn({
2420
+ items: h,
2421
+ actions: g,
2422
+ transport: _,
2423
+ railOpen: e,
2424
+ railHeight: i
2425
+ });
2426
+ }, [
2427
+ e,
2428
+ n,
2429
+ p,
2430
+ o,
2431
+ s,
2432
+ i
2433
+ ]), Y(() => () => gn(null), []), null;
2434
+ }
2435
+ function Rr() {
2436
+ return /* @__PURE__ */ Q("div", {
2437
+ className: "kol-compose-rail kol-compose-rail--inspector",
2438
+ children: /* @__PURE__ */ Q("div", {
2439
+ className: "kol-compose-inspector-body",
2440
+ children: /* @__PURE__ */ Q(fr, {})
2441
+ })
2442
+ });
2443
+ }
2444
+ var zr = {
2445
+ topbar: () => null,
2446
+ canvas: Mr,
2447
+ panels: [
2448
+ {
2449
+ slot: "canvas.footer",
2450
+ order: 0,
2451
+ Component: $e
2452
+ },
2453
+ {
2454
+ slot: "right.body",
2455
+ order: 0,
2456
+ Component: Nr
2457
+ },
2458
+ {
2459
+ slot: "right.footer",
2460
+ order: 0,
2461
+ Component: Et
2462
+ }
2463
+ ]
2464
+ }, Br = {
2465
+ ...zr,
2466
+ panels: [{
2467
+ slot: "right.header",
2468
+ order: 0,
2469
+ Component: Fr
2470
+ }, ...zr.panels.map((e) => e.Component === Nr ? {
2471
+ ...e,
2472
+ Component: Rr
2473
+ } : e)]
2474
+ };
2475
+ function Vr() {
2476
+ let { setAspect: t } = h(), n = X(!1);
2477
+ Y(() => {
2478
+ if (n.current) return;
2479
+ n.current = !0;
2480
+ let r = e();
2481
+ r.defaultAspect && r.defaultAspect !== "custom" && t(r.defaultAspect), r.defaultLoopSeconds && i.setLoopSeconds(r.defaultLoopSeconds);
2482
+ }, []);
2483
+ let { clearHistory: r } = h();
2484
+ Y(() => {
2485
+ let e = setTimeout(r, 800);
2486
+ return () => clearTimeout(e);
2487
+ }, [r]);
2488
+ }
2489
+ function Hr() {
2490
+ let { selectedId: n, select: r } = h(), { layer: a, setOnly: o } = Te(), c = kt(vt), l = Nt() && !ht() || c;
2491
+ Y(() => {
2492
+ l && document.documentElement.removeAttribute("data-rail");
2493
+ }, [l]);
2494
+ let [u, d] = Z(!0), [f, p] = Z(!1), [m, g] = Z(null), _ = m ? `${m}px` : f ? xr.tall : xr.half, v = { "--kol-sheet-h": _ }, b = _n(), x = He(), [S, C] = Z(() => !a);
2495
+ Y(() => {
2496
+ C(!a);
2497
+ }, [a?.id]);
2498
+ let [w, T] = Z(null), E = a?.type === "photo" && (!!a.src || a.srcType === "webcam");
2499
+ Y(() => {
2500
+ w && E && C(!0);
2501
+ }, [w, E]), Y(() => {
2502
+ a || T(null);
2503
+ }, [a]), Y(() => {
2504
+ if (!a || l) return;
2505
+ let e = 0, t = 0;
2506
+ return e = requestAnimationFrame(() => {
2507
+ t = requestAnimationFrame(() => document.documentElement.removeAttribute("data-rail"));
2508
+ }), () => {
2509
+ cancelAnimationFrame(e), cancelAnimationFrame(t);
2510
+ };
2511
+ }, [a?.id]), Y(() => {
2512
+ if (!x.active || l) return;
2513
+ let e = 0, t = 0;
2514
+ return e = requestAnimationFrame(() => {
2515
+ t = requestAnimationFrame(() => document.documentElement.removeAttribute("data-rail"));
2516
+ }), () => {
2517
+ cancelAnimationFrame(e), cancelAnimationFrame(t);
2518
+ };
2519
+ }, [x.active, l]), Y(() => Ht((e) => o("photo", {
2520
+ src: e.url,
2521
+ srcType: e.srcType
2522
+ })), [o]), Y(() => {
2523
+ if (!l) return;
2524
+ let e = () => d(!0);
2525
+ return window.addEventListener("kol:open-params", e), window.addEventListener("kol:open-effects", e), () => {
2526
+ window.removeEventListener("kol:open-params", e), window.removeEventListener("kol:open-effects", e);
2527
+ };
2528
+ }, [l]), xt(), Y(() => (ft("labs"), () => ft(null)), []), Vr();
2529
+ let D = X(!1);
2530
+ Y(() => {
2531
+ if (D.current) return;
2532
+ D.current = !0;
2533
+ let e = et();
2534
+ if (e.open || e.fresh) return;
2535
+ let t = new URLSearchParams(window.location.search).get("preset"), n = t ? G(t) : null;
2536
+ n && o("loop", de(te(t), n));
2537
+ }, [o]);
2538
+ let { tool: O, setTool: k } = lt(), A = X(O);
2539
+ A.current = O;
2540
+ let { updateLayer: j, undo: M, redo: N } = h(), P = X({
2541
+ undo: M,
2542
+ redo: N
2543
+ });
2544
+ P.current = {
2545
+ undo: M,
2546
+ redo: N
2547
+ };
2548
+ let F = !!t().grab;
2549
+ Y(() => {
2550
+ k(F ? "orbit" : "select");
2551
+ }, [F, k]);
2552
+ let ee = X(a);
2553
+ ee.current = a;
2554
+ let I = X(j);
2555
+ return I.current = j, Y(() => {
2556
+ let t = (t) => {
2557
+ if (pt(t)) return;
2558
+ if ((t.metaKey || t.ctrlKey) && (t.key === "z" || t.key === "Z")) {
2559
+ t.preventDefault(), t.shiftKey ? P.current.redo() : P.current.undo();
2560
+ return;
2561
+ }
2562
+ if (t.code === "Space") {
2563
+ t.preventDefault(), i.toggle();
2564
+ return;
2565
+ }
2566
+ if ((t.key === "s" || t.key === "S") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2567
+ window.dispatchEvent(new CustomEvent("kol:show-shortcuts"));
2568
+ return;
2569
+ }
2570
+ if ((t.key === "c" || t.key === "C") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2571
+ s("grab", !e().grab);
2572
+ return;
2573
+ }
2574
+ if ((t.key === "z" || t.key === "Z") && !t.metaKey && !t.ctrlKey && !t.altKey) {
2575
+ s("zoomLock", !e().zoomLock);
2576
+ return;
2577
+ }
2578
+ let n = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && we[t.key.length === 1 ? t.key.toLowerCase() : t.key];
2579
+ if (n && ee.current) {
2580
+ let e = ye(ee.current, n[1], n[0]);
2581
+ e && (t.preventDefault(), I.current(ee.current.id, e));
2582
+ }
2583
+ };
2584
+ return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
2585
+ }, [k]), Y(() => {
2586
+ if (!a?.presetId) return;
2587
+ let e = new URLSearchParams(window.location.search);
2588
+ e.get("preset") !== a.presetId && (e.delete("view"), e.set("preset", a.presetId), a.loopGroup ? e.set("cat", a.loopGroup) : e.delete("cat"), window.history.replaceState(null, "", `${window.location.pathname}?${e}`));
2589
+ }, [a?.presetId, a?.loopGroup]), Y(() => {
2590
+ a && n !== a.id && r(a.id);
2591
+ }, [
2592
+ a,
2593
+ n,
2594
+ r
2595
+ ]), /* @__PURE__ */ $("div", {
2596
+ className: "kol-editor-labs contents",
2597
+ "data-touch": l || void 0,
2598
+ "data-params": u ? "open" : void 0,
2599
+ "data-empty": a || x.active ? void 0 : "",
2600
+ style: v,
2601
+ children: [
2602
+ /* @__PURE__ */ Q(Fn, {}),
2603
+ l ? /* @__PURE__ */ $(Pr.Provider, {
2604
+ value: {
2605
+ collapseParams: () => d(!1),
2606
+ tall: f,
2607
+ setTall: p,
2608
+ setSheetPx: g,
2609
+ catalog: S,
2610
+ toggleCatalog: () => C((e) => !e)
2611
+ },
2612
+ children: [/* @__PURE__ */ Q(y.Provider, {
2613
+ value: "md",
2614
+ children: /* @__PURE__ */ Q(rt, {
2615
+ registry: Br,
2616
+ rightIn: (e) => b ? sn(/* @__PURE__ */ Q("div", {
2617
+ className: "kol-editor-labs flex flex-col h-full",
2618
+ "data-touch": "",
2619
+ "data-params": "open",
2620
+ style: v,
2621
+ children: e
2622
+ }), b) : null
2623
+ })
2624
+ }), /* @__PURE__ */ Q(Lr, {
2625
+ paramsOpen: u,
2626
+ setParamsOpen: d,
2627
+ catalog: S,
2628
+ toggleCatalog: () => C((e) => !e),
2629
+ railHeight: _
2630
+ })]
2631
+ }) : /* @__PURE__ */ Q(rt, { registry: zr }),
2632
+ S && !x.picker && !(x.active && !a) && /* @__PURE__ */ Q(Tr, {
2633
+ initialOpen: w,
2634
+ hasMedia: E,
2635
+ onNeedMedia: (e) => {
2636
+ T(e), o("photo", {
2637
+ filters: [],
2638
+ fxGroup: null
2639
+ });
2640
+ },
2641
+ onPicked: () => {
2642
+ T(null), C(!1);
2643
+ },
2644
+ onClose: () => {
2645
+ T(null), C(!1);
2646
+ }
2647
+ })
2648
+ ]
2649
+ });
2650
+ }
2651
+ var Ur = "kol.editor.labs-draft";
2652
+ function Wr() {
2653
+ let e = /\/morph\/?$/.test(typeof window > "u" ? "" : window.location.pathname);
2654
+ return Y(() => (q(e ? { active: !0 } : {
2655
+ active: !1,
2656
+ editing: null
2657
+ }), () => q({
2658
+ active: !1,
2659
+ editing: null
2660
+ })), [e]), /* @__PURE__ */ $(jt, {
2661
+ draftKey: Ur,
2662
+ children: [
2663
+ /* @__PURE__ */ Q(Hr, {}),
2664
+ /* @__PURE__ */ Q(At, {}),
2665
+ /* @__PURE__ */ Q(Ce, {})
2666
+ ]
2667
+ });
2668
+ }
2669
+ //#endregion
2670
+ //#region src/editor/mobile/EffectScreen.jsx
2671
+ function Gr({ layer: e, chain: t, onPick: n, onBack: r }) {
2672
+ let [i, a] = Z(null);
2673
+ pr(r);
2674
+ let { engineHost: o } = ie(e), s = o && !t.some((e) => e.def?.kind === "engine"), c = H(W.filter((e) => e.kind !== "engine" || s)), l = c.find((e) => e.id === i) ?? null;
2675
+ return /* @__PURE__ */ Q("div", {
2676
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center overflow-y-auto p-6",
2677
+ style: { zIndex: "var(--kol-z-modal)" },
2678
+ children: /* @__PURE__ */ $("div", {
2679
+ className: "my-auto w-full max-w-sm rounded p-8 flex flex-col gap-6",
2680
+ style: { background: "var(--kol-surface-primary)" },
2681
+ children: [
2682
+ /* @__PURE__ */ Q("div", {
2683
+ className: "kol-eyebrow text-body",
2684
+ children: l ? l.label : "Pick an effect"
2685
+ }),
2686
+ /* @__PURE__ */ Q("div", {
2687
+ className: "flex flex-col gap-2",
2688
+ children: (l ? l.filters : c).map((e) => /* @__PURE__ */ Q(J, {
2689
+ tone: "primary",
2690
+ size: "lg",
2691
+ className: Lt,
2692
+ iconLeft: l ? "filter" : "chevron-right",
2693
+ iconRight: l ? "filter" : "chevron-right",
2694
+ onClick: () => l ? n(e.id) : a(e.id),
2695
+ children: e.label
2696
+ }, e.id))
2697
+ }),
2698
+ /* @__PURE__ */ Q(J, {
2699
+ tone: "grey",
2700
+ size: "lg",
2701
+ className: Lt,
2702
+ iconLeft: "arrow-left",
2703
+ iconRight: "arrow-left",
2704
+ onClick: () => l ? a(null) : r(),
2705
+ children: "Back"
2706
+ })
2707
+ ]
2708
+ })
2709
+ });
2710
+ }
2711
+ //#endregion
2712
+ //#region src/editor/mobile/MobileOverlay.jsx
2713
+ var Kr = { background: "var(--kol-surface-primary)" }, qr = [
2714
+ {
2715
+ value: "generate",
2716
+ label: "Generate"
2717
+ },
2718
+ {
2719
+ value: "effects",
2720
+ label: "Effects"
2721
+ },
2722
+ {
2723
+ value: "transport",
2724
+ label: "Transport"
2725
+ },
2726
+ {
2727
+ value: "output",
2728
+ label: "Output"
2729
+ }
2730
+ ], Jr = qr.filter((e) => e.value !== "generate"), Yr = "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-1 [&_.kol-seg-cell]:overflow-hidden [@media(hover:none)]:[&_.kol-seg-cell:hover]:text-[var(--kol-oq-48)]", Xr = {
2731
+ lg: 9.6,
2732
+ sm: 7.2
2733
+ }, Zr = 10, Qr = 232;
2734
+ function $r(e, t) {
2735
+ let n = t === "sm" ? Qr : Math.min(window.innerWidth, 480) - 24, r = [], i = [], a = 0;
2736
+ for (let o of e) {
2737
+ let e = o.label.length * Xr[t] + Zr, s = Math.max(a, e);
2738
+ i.length && (i.length + 1) * s > n ? (r.push(i), i = [o], a = e) : (i.push(o), a = s);
2739
+ }
2740
+ return i.length && r.push(i), r;
2741
+ }
2742
+ function ei({ cells: e, size: t }) {
2743
+ return $r(e, t).map((e, n) => /* @__PURE__ */ Q(Ut, {
2744
+ layout: "joined",
2745
+ value: null,
2746
+ onChange: (t) => e.find((e) => e.value === t)?.run(),
2747
+ options: e,
2748
+ size: t,
2749
+ ariaLabel: "Randomize scope",
2750
+ className: Yr
2751
+ }, n));
2752
+ }
2753
+ var ti = [
2754
+ 2,
2755
+ 4,
2756
+ 8,
2757
+ 16
2758
+ ].map((e) => ({
2759
+ value: String(e),
2760
+ label: `${e}s`
2761
+ }));
2762
+ function ni({ size: e }) {
2763
+ let { loopSeconds: t, setLoopSeconds: n } = a();
2764
+ return /* @__PURE__ */ Q(Ut, {
2765
+ layout: "joined",
2766
+ value: String(t),
2767
+ onChange: (e) => n(Number(e)),
2768
+ options: ti,
2769
+ size: e,
2770
+ ariaLabel: "Loop length"
2771
+ });
2772
+ }
2773
+ var ri = [
2774
+ {
2775
+ value: "9:16",
2776
+ label: "9:16"
2777
+ },
2778
+ {
2779
+ value: "3:5",
2780
+ label: "3:5"
2781
+ },
2782
+ {
2783
+ value: "4:5",
2784
+ label: "4:5"
2785
+ },
2786
+ {
2787
+ value: "1:1",
2788
+ label: "1:1"
2789
+ }
2790
+ ], ii = [
2791
+ {
2792
+ value: "5:4",
2793
+ label: "5:4"
2794
+ },
2795
+ {
2796
+ value: "5:3",
2797
+ label: "5:3"
2798
+ },
2799
+ {
2800
+ value: "16:9",
2801
+ label: "16:9"
2802
+ },
2803
+ {
2804
+ value: "fill",
2805
+ label: "Fill"
2806
+ }
2807
+ ];
2808
+ function ai({ layer: e, onSwitchCategory: t, onInsert: n, onRestart: r, aspectValue: a, onAspect: o, openEffects: s = !1, rail: c = !1, onRail: l, onSheet: u }) {
2809
+ let d = He(), { updateLayer: f, addFilter: p, removeFilter: m } = h(), { onExportPng: g } = Vt(), [_, y] = Z(!1), [b, S] = Z(!0), [w, T] = Z(!1), [D, O] = Z(!1), [k, j] = Z("generate"), [P, F] = Z(!1), [I, L] = Z(!1), { aspect: R } = h(), [te, z] = Z(null), H = E(e);
2810
+ Y(() => {
2811
+ s && (S(!0), O(!0));
2812
+ }, [s]);
2813
+ let U = c ? "sm" : "lg", ne = c && !!e && b && !_;
2814
+ Y(() => (l?.(ne), () => l?.(!1)), [ne]);
2815
+ let W = !c && e && b && !_ ? te ? `${te}px` : P ? xr.tall : xr.half : null;
2816
+ Y(() => (u?.(W), () => u?.(null)), [W]);
2817
+ let re = () => {
2818
+ let t = e?.type === "loop" && B(e.loopGroup).find((t) => t.id === e.presetId);
2819
+ t && f(e.id, de(t, e.loopGroup));
2820
+ };
2821
+ if (Zn(re, () => {
2822
+ e?.type === "loop" && f(e.id, C(e, M(K(e.loopId)?.params ?? [], e), H.take(), { withFilters: !0 }));
2823
+ }), !e) return null;
2824
+ if (_) return /* @__PURE__ */ Q("button", {
2825
+ "aria-label": "Show controls",
2826
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] z-20",
2827
+ onClick: () => y(!1)
2828
+ });
2829
+ let ae = e.type === "loop", oe = ae ? `${V(e.loopGroup).label} · ${e.presetLabel}` : "Media", se = ae ? K(e.loopId)?.params ?? [] : [], ce = ae ? N(se, e) : [], le = () => f(e.id, C(e, M(se, e), H.take(), { withFilters: !0 })), ue = (t) => f(e.id, C(e, t.params, H.take(), { stripNoRandom: !!t.motion })), G = () => {
2830
+ let t = A(e, H.take());
2831
+ t && f(e.id, t);
2832
+ }, fe = x(e), { effectable: pe } = ie(e), he = () => {
2833
+ let t = ee(e, H.take());
2834
+ t && f(e.id, { filters: t });
2835
+ };
2836
+ if (!b) return /* @__PURE__ */ $(br, {
2837
+ label: ae ? e.presetLabel : "Media",
2838
+ onOpen: () => S(!0),
2839
+ size: U,
2840
+ children: [
2841
+ (ae || fe.length > 0) && /* @__PURE__ */ Q(Jt, {
2842
+ label: "Randomize all",
2843
+ children: /* @__PURE__ */ Q(J, {
2844
+ tone: "primary",
2845
+ size: U,
2846
+ iconOnly: "bolt",
2847
+ "aria-label": "Randomize all",
2848
+ onClick: le,
2849
+ className: "shrink-0"
2850
+ })
2851
+ }),
2852
+ /* @__PURE__ */ Q(Jt, {
2853
+ label: "Download",
2854
+ children: /* @__PURE__ */ Q(J, {
2855
+ tone: "primary",
2856
+ size: U,
2857
+ iconOnly: "download",
2858
+ "aria-label": "Download",
2859
+ onClick: () => g(2),
2860
+ className: "shrink-0"
2861
+ })
2862
+ }),
2863
+ /* @__PURE__ */ Q(Jt, {
2864
+ label: "Hide UI",
2865
+ children: /* @__PURE__ */ Q(J, {
2866
+ tone: "primary",
2867
+ size: U,
2868
+ iconOnly: "eye-off",
2869
+ "aria-label": "Hide UI",
2870
+ onClick: () => y(!0),
2871
+ className: "shrink-0"
2872
+ })
2873
+ }),
2874
+ /* @__PURE__ */ Q(Jt, {
2875
+ label: a === "fill" ? "Back to the frame" : "Fill the screen",
2876
+ children: /* @__PURE__ */ Q(J, {
2877
+ tone: "primary",
2878
+ size: U,
2879
+ iconOnly: "maximize",
2880
+ "aria-label": a === "fill" ? "Back to the frame" : "Fill the screen",
2881
+ "aria-pressed": a === "fill",
2882
+ onClick: () => o(a === "fill" ? R : "fill"),
2883
+ className: "shrink-0"
2884
+ })
2885
+ })
2886
+ ]
2887
+ });
2888
+ let ge = [...ae ? qr : Jr, ...ae && d.steps.length >= 2 ? [{
2889
+ value: "morph",
2890
+ label: "Morph"
2891
+ }] : []].filter((e) => (e.value !== "effects" || pe) && (e.value !== "transport" || v("motion"))), _e = ge.some((e) => e.value === k) ? k : ge[0].value;
2892
+ return /* @__PURE__ */ $(nn, { children: [
2893
+ /* @__PURE__ */ Q(me, {
2894
+ open: I,
2895
+ onClose: () => L(!1),
2896
+ schema: se,
2897
+ layer: e,
2898
+ size: U
2899
+ }),
2900
+ w && /* @__PURE__ */ Q(mr, {
2901
+ onPick: (e) => {
2902
+ t(e), T(!1);
2903
+ },
2904
+ onInsert: () => {
2905
+ T(!1), n();
2906
+ },
2907
+ onBack: () => {
2908
+ T(!1), r();
2909
+ },
2910
+ onDismiss: () => T(!1)
2911
+ }),
2912
+ D && /* @__PURE__ */ Q(Gr, {
2913
+ layer: e,
2914
+ chain: fe,
2915
+ onPick: (t) => {
2916
+ p(e.id, t), O(!1);
2917
+ },
2918
+ onBack: () => O(!1)
2919
+ }),
2920
+ /* @__PURE__ */ $("div", {
2921
+ className: c ? "fixed top-0 right-0 bottom-0 z-10 flex w-[var(--kol-sidenav-w,320px)] flex-col overflow-y-auto border-l border-oq-08" : "fixed right-0 left-[var(--fxr-rail,0px)] bottom-0 z-10 flex flex-col pb-[env(safe-area-inset-bottom)]",
2922
+ style: c ? Kr : {
2923
+ ...Kr,
2924
+ top: `calc(100dvh - ${W ?? xr.half})`
2925
+ },
2926
+ children: [
2927
+ !c && /* @__PURE__ */ Q(Cr, {
2928
+ tall: P,
2929
+ onToggle: () => {
2930
+ z(null), F((e) => !e);
2931
+ },
2932
+ onResize: (e) => z(Math.max(96, Math.min(window.innerHeight * .92, e))),
2933
+ onResizeEnd: (e) => {
2934
+ e < 96 && (z(null), S(!1));
2935
+ }
2936
+ }),
2937
+ /* @__PURE__ */ Q(yr, {
2938
+ title: oe,
2939
+ onCollapse: () => S(!1),
2940
+ className: c ? "px-4 pt-2.5 pb-1.5" : "px-3",
2941
+ action: /* @__PURE__ */ Q(J, {
2942
+ tone: "ghost",
2943
+ quiet: !0,
2944
+ size: "sm",
2945
+ onClick: r,
2946
+ children: "Start over"
2947
+ })
2948
+ }),
2949
+ /* @__PURE__ */ $("div", {
2950
+ className: c ? "px-4 pb-5" : "min-h-0 flex-1 overflow-y-auto px-3 pb-3",
2951
+ children: [
2952
+ /* @__PURE__ */ Q(Ut, {
2953
+ layout: "joined",
2954
+ value: _e,
2955
+ onChange: j,
2956
+ options: ge,
2957
+ size: U,
2958
+ className: c ? Yr : "[&_.kol-seg-cell]:min-w-0 [&_.kol-seg-cell]:px-2 [&_.kol-seg-cell]:overflow-hidden"
2959
+ }),
2960
+ _e === "morph" && ae && /* @__PURE__ */ Q(Rn, {
2961
+ layer: e,
2962
+ readOnly: !0
2963
+ }),
2964
+ _e === "generate" && ae && /* @__PURE__ */ $("div", {
2965
+ className: "flex flex-col gap-2 pt-3",
2966
+ children: [
2967
+ /* @__PURE__ */ $("div", {
2968
+ className: "grid grid-cols-2 gap-2",
2969
+ children: [/* @__PURE__ */ Q(J, {
2970
+ tone: "primary",
2971
+ size: U,
2972
+ iconRight: "refresh",
2973
+ onClick: G,
2974
+ children: "Preset"
2975
+ }), /* @__PURE__ */ Q(J, {
2976
+ tone: "primary",
2977
+ size: U,
2978
+ onClick: () => T(!0),
2979
+ children: "Generator"
2980
+ })]
2981
+ }),
2982
+ /* @__PURE__ */ $("div", {
2983
+ className: "flex gap-2",
2984
+ children: [
2985
+ /* @__PURE__ */ Q(J, {
2986
+ tone: "primary",
2987
+ size: U,
2988
+ className: "flex-1 min-w-0",
2989
+ onClick: le,
2990
+ children: "Randomize all"
2991
+ }),
2992
+ /* @__PURE__ */ Q(Jt, {
2993
+ label: "What Randomize all rolls",
2994
+ children: /* @__PURE__ */ Q(J, {
2995
+ tone: "primary",
2996
+ size: U,
2997
+ iconOnly: "nav-settings",
2998
+ "aria-label": "What Randomize all rolls",
2999
+ onClick: () => L(!0),
3000
+ className: "shrink-0"
3001
+ })
3002
+ }),
3003
+ /* @__PURE__ */ Q(Jt, {
3004
+ label: "Reset to defaults",
3005
+ shortcut: "R",
3006
+ children: /* @__PURE__ */ Q(J, {
3007
+ tone: "primary",
3008
+ size: U,
3009
+ iconOnly: "refresh",
3010
+ "aria-label": "Reset to defaults",
3011
+ onClick: re,
3012
+ className: "shrink-0"
3013
+ })
3014
+ })
3015
+ ]
3016
+ }),
3017
+ ce.length > 0 && /* @__PURE__ */ Q(ei, {
3018
+ size: U,
3019
+ cells: [...ce.map((e) => ({
3020
+ value: e.id,
3021
+ label: e.label,
3022
+ run: () => ue(e)
3023
+ })), {
3024
+ value: "__retrigger",
3025
+ label: "Re-trigger",
3026
+ run: () => i.rewind()
3027
+ }]
3028
+ })
3029
+ ]
3030
+ }),
3031
+ _e === "effects" && /* @__PURE__ */ $("div", {
3032
+ className: "flex flex-col gap-2 pt-3",
3033
+ children: [/* @__PURE__ */ $("div", {
3034
+ className: "grid grid-cols-2 gap-2",
3035
+ children: [
3036
+ /* @__PURE__ */ Q(J, {
3037
+ tone: "primary",
3038
+ size: U,
3039
+ onClick: () => O(!0),
3040
+ children: "Add effect"
3041
+ }),
3042
+ fe.length > 0 && /* @__PURE__ */ Q(J, {
3043
+ tone: "primary",
3044
+ size: U,
3045
+ onClick: he,
3046
+ children: "Randomize"
3047
+ }),
3048
+ " "
3049
+ ]
3050
+ }), fe.map((t, n) => {
3051
+ let r = {
3052
+ ...e,
3053
+ ...t.params,
3054
+ id: e.id
3055
+ }, i = t.def ? N(t.def.params, r) : [], a = (t) => {
3056
+ let i = C(r, t.params, H.take(), { stripNoRandom: !!t.motion }), a = fe.map(({ def: e, ...t }) => t);
3057
+ f(e.id, { filters: a.map((e, t) => t === n ? {
3058
+ ...e,
3059
+ params: {
3060
+ ...e.params,
3061
+ ...i
3062
+ }
3063
+ } : e) });
3064
+ };
3065
+ return /* @__PURE__ */ $("div", {
3066
+ className: "flex flex-col gap-2",
3067
+ children: [/* @__PURE__ */ Q(J, {
3068
+ tone: "grey",
3069
+ size: U,
3070
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3071
+ iconLeft: "trash",
3072
+ iconRight: "trash",
3073
+ onClick: () => m(e.id, n),
3074
+ children: `${n + 1}. ${t.def?.label ?? t.id}`
3075
+ }), i.length > 0 && /* @__PURE__ */ Q(ei, {
3076
+ size: U,
3077
+ cells: i.map((e) => ({
3078
+ value: e.id,
3079
+ label: e.label,
3080
+ run: () => a(e)
3081
+ }))
3082
+ })]
3083
+ }, t.key);
3084
+ })]
3085
+ }),
3086
+ _e === "transport" && v("motion") && /* @__PURE__ */ $("div", {
3087
+ className: "flex flex-col gap-2 pt-3",
3088
+ children: [(() => {
3089
+ let e = v("motion").TransportBar;
3090
+ return /* @__PURE__ */ Q(e, { size: U });
3091
+ })(), /* @__PURE__ */ Q(ni, { size: U })]
3092
+ }),
3093
+ _e === "output" && /* @__PURE__ */ $("div", {
3094
+ className: "flex flex-col gap-2 pt-3",
3095
+ children: [
3096
+ /* @__PURE__ */ Q(Ut, {
3097
+ layout: "joined",
3098
+ value: a,
3099
+ onChange: o,
3100
+ options: ri,
3101
+ size: U,
3102
+ ariaLabel: "Aspect"
3103
+ }),
3104
+ /* @__PURE__ */ Q(Ut, {
3105
+ layout: "joined",
3106
+ value: a,
3107
+ onChange: o,
3108
+ options: ii,
3109
+ size: U,
3110
+ ariaLabel: "Aspect (landscape) and fill"
3111
+ }),
3112
+ /* @__PURE__ */ $("div", {
3113
+ className: "grid grid-cols-2 gap-2",
3114
+ children: [
3115
+ /* @__PURE__ */ Q(J, {
3116
+ tone: "primary",
3117
+ size: U,
3118
+ onClick: () => gt({ focusName: !0 }),
3119
+ children: "Save…"
3120
+ }),
3121
+ /* @__PURE__ */ Q(J, {
3122
+ tone: "primary",
3123
+ size: U,
3124
+ onClick: () => g(2),
3125
+ children: "Download"
3126
+ }),
3127
+ /* @__PURE__ */ Q(J, {
3128
+ tone: "primary",
3129
+ size: U,
3130
+ onClick: () => y(!0),
3131
+ children: "Hide UI"
3132
+ }),
3133
+ /* @__PURE__ */ Q(J, {
3134
+ tone: "primary",
3135
+ size: U,
3136
+ onClick: r,
3137
+ children: "Start over"
3138
+ })
3139
+ ]
3140
+ })
3141
+ ]
3142
+ })
3143
+ ]
3144
+ })
3145
+ ]
3146
+ })
3147
+ ] });
3148
+ }
3149
+ //#endregion
3150
+ //#region src/editor/mobile/MobileView.jsx
3151
+ function oi({ onGenerate: e, onEffects: t, chromes: n }) {
3152
+ return /* @__PURE__ */ Q("div", {
3153
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col items-center justify-center p-6",
3154
+ style: { zIndex: "var(--kol-z-modal)" },
3155
+ children: /* @__PURE__ */ $("div", {
3156
+ className: "w-full max-w-sm rounded p-8 flex flex-col gap-6",
3157
+ style: { background: "var(--kol-surface-primary)" },
3158
+ children: [n ? /* @__PURE__ */ $("div", {
3159
+ className: "flex flex-col gap-2",
3160
+ children: [/* @__PURE__ */ Q("span", {
3161
+ className: "kol-eyebrow text-body",
3162
+ children: "Select chrome"
3163
+ }), /* @__PURE__ */ Q("span", {
3164
+ className: "kol-mono-16 text-emphasis",
3165
+ children: "FXR"
3166
+ })]
3167
+ }) : /* @__PURE__ */ Q("span", {
3168
+ className: "kol-eyebrow text-body",
3169
+ children: Dt("randomiser").label
3170
+ }), /* @__PURE__ */ $("div", {
3171
+ className: "flex flex-col gap-2",
3172
+ children: [
3173
+ /* @__PURE__ */ Q(J, {
3174
+ tone: "primary",
3175
+ size: "lg",
3176
+ className: Lt,
3177
+ iconLeft: zt.randomiser,
3178
+ iconRight: zt.randomiser,
3179
+ onClick: e,
3180
+ children: "Generate"
3181
+ }),
3182
+ /* @__PURE__ */ Q(J, {
3183
+ tone: "primary",
3184
+ size: "lg",
3185
+ className: Lt,
3186
+ iconLeft: "filter",
3187
+ iconRight: "filter",
3188
+ onClick: t,
3189
+ children: "Effects"
3190
+ }),
3191
+ n && St() && /* @__PURE__ */ Q(J, {
3192
+ tone: "primary",
3193
+ size: "lg",
3194
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3195
+ iconLeft: zt.editor,
3196
+ iconRight: zt.editor,
3197
+ onClick: Ot,
3198
+ children: Dt("editor").label
3199
+ }),
3200
+ n && /* @__PURE__ */ Q(J, {
3201
+ tone: "primary",
3202
+ size: "lg",
3203
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3204
+ iconLeft: zt.labs,
3205
+ iconRight: zt.labs,
3206
+ onClick: Mt,
3207
+ children: Dt("labs").label
3208
+ }),
3209
+ n && /* @__PURE__ */ Q(J, {
3210
+ tone: "primary",
3211
+ size: "lg",
3212
+ className: "w-full [&>span]:w-full [&>span]:justify-between",
3213
+ iconLeft: "swap",
3214
+ iconRight: "swap",
3215
+ onClick: () => bt("/morph"),
3216
+ children: "Morph"
3217
+ })
3218
+ ]
3219
+ })]
3220
+ })
3221
+ });
3222
+ }
3223
+ function si() {
3224
+ let { layers: e, addLayer: t, removeLayer: n, updateLayer: r, canvasW: a, canvasH: o, aspect: s, setAspect: c } = h(), { setTool: u } = lt(), d = Nt() && !ht(), f = Ft(), p = () => {
3225
+ let e = new URLSearchParams(window.location.search);
3226
+ return e.get("open") ? "live" : e.get("start") === "category" ? "category" : "entry";
3227
+ }, [g, _] = Z(p), [v, y] = Z(!1), [b, x] = Z(null), [S, C] = Z("contain"), [w, T] = Z(!1), [E, D] = Z(null), [O, k] = Z({
3228
+ s: 1,
3229
+ x: 0,
3230
+ y: 0
3231
+ }), A = X(null), j = X({
3232
+ pts: /* @__PURE__ */ new Map(),
3233
+ start: null,
3234
+ live: {
3235
+ s: 1,
3236
+ x: 0,
3237
+ y: 0
3238
+ }
3239
+ }), M = X(null), N = () => {
3240
+ let [e, t] = [...j.current.pts.values()];
3241
+ return {
3242
+ d: Math.hypot(e.x - t.x, e.y - t.y),
3243
+ mx: (e.x + t.x) / 2,
3244
+ my: (e.y + t.y) / 2
3245
+ };
3246
+ }, P = (e) => `translate(${e.x}px, ${e.y}px) scale(${e.s})`, F = (e) => {
3247
+ if (j.current.pts.set(e.pointerId, {
3248
+ x: e.clientX,
3249
+ y: e.clientY
3250
+ }), M.current = j.current.pts.size === 1 ? {
3251
+ id: e.pointerId,
3252
+ x: e.clientX,
3253
+ y: e.clientY,
3254
+ t: performance.now()
3255
+ } : null, j.current.pts.size === 2) {
3256
+ let t = A.current?.getBoundingClientRect(), n = N(), r = (t?.left ?? 0) - O.x, a = (t?.top ?? 0) - O.y;
3257
+ j.current.start = {
3258
+ ...n,
3259
+ ox: r,
3260
+ oy: a,
3261
+ v: O,
3262
+ px: (n.mx - r - O.x) / O.s,
3263
+ py: (n.my - a - O.y) / O.s
3264
+ }, j.current.live = O, i.setStagePointer(null), e.stopPropagation();
3265
+ }
3266
+ }, ee = (e) => {
3267
+ let t = j.current;
3268
+ if (t.pts.has(e.pointerId) && (t.pts.set(e.pointerId, {
3269
+ x: e.clientX,
3270
+ y: e.clientY
3271
+ }), t.pts.size >= 2 && t.start)) {
3272
+ e.stopPropagation();
3273
+ let n = N(), r = t.start, i = Math.min(4, Math.max(.5, r.v.s * (n.d / r.d)));
3274
+ t.live = {
3275
+ s: i,
3276
+ x: n.mx - r.ox - i * r.px,
3277
+ y: n.my - r.oy - i * r.py
3278
+ }, A.current && (A.current.style.transform = P(t.live));
3279
+ }
3280
+ }, I = (e) => {
3281
+ let t = M.current;
3282
+ t && t.id === e.pointerId && e.type === "pointerup" && g === "live" && performance.now() - t.t < 350 && Math.hypot(e.clientX - t.x, e.clientY - t.y) < 12 && (L?.type === "loop" ? K(L.loopId) : null)?.group !== "penrose" && i.toggle(), t?.id === e.pointerId && (M.current = null), j.current.pts.delete(e.pointerId), j.current.pts.size < 2 && j.current.start && (j.current.start = null, k(j.current.live));
3283
+ };
3284
+ on(), Y(() => (ft("randomiser"), () => ft(null)), []), Y(() => {
3285
+ c("4:5"), u("orbit");
3286
+ }, []);
3287
+ let L = e.find((e) => e.id === b) ?? (e.length === 1 ? e[0] : null), R = g === "live" && L?.type === "photo" && !L.src && L.srcType !== "webcam";
3288
+ Y(() => {
3289
+ if (!R) return;
3290
+ let e = (e) => {
3291
+ e.key === "Escape" && H();
3292
+ };
3293
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3294
+ }), Y(() => {
3295
+ if (!R) return;
3296
+ let e = i.isPlaying();
3297
+ return i.pause(), () => {
3298
+ e && i.play();
3299
+ };
3300
+ }, [R]);
3301
+ let te = (e) => {
3302
+ let n = re(e);
3303
+ n && (x(t("loop", n)), _("live"));
3304
+ }, z = (e) => {
3305
+ let t = re(e);
3306
+ t && b && r(b, t);
3307
+ }, B = () => {
3308
+ x(t("photo", {
3309
+ fit: "cover",
3310
+ x: 0,
3311
+ y: 0,
3312
+ w: l,
3313
+ h: Math.round(l * o / a)
3314
+ })), _("live");
3315
+ };
3316
+ Y(() => {
3317
+ let e = new URL(window.location.href), t = e.searchParams.get("start");
3318
+ t && (t === "effects" && (y(!0), B()), e.searchParams.delete("start"), window.history.replaceState(window.history.state, "", e));
3319
+ }, []);
3320
+ let V = (e) => {
3321
+ if (e === "fill") {
3322
+ C("cover");
3323
+ return;
3324
+ }
3325
+ C("contain"), c(e);
3326
+ let t = m[e];
3327
+ b && t && r(b, {
3328
+ x: 0,
3329
+ y: 0,
3330
+ w: l,
3331
+ h: Math.round(l * t.h / t.w)
3332
+ });
3333
+ }, H = () => {
3334
+ for (let t of [...e]) n(t.id);
3335
+ x(null), k({
3336
+ s: 1,
3337
+ x: 0,
3338
+ y: 0
3339
+ }), y(!1), _(p());
3340
+ };
3341
+ return /* @__PURE__ */ $("div", {
3342
+ className: "kol-editor-randomiser relative h-dvh bg-black",
3343
+ children: [
3344
+ /* @__PURE__ */ Q("div", {
3345
+ ref: A,
3346
+ className: "absolute inset-y-0 left-0 touch-none overflow-hidden",
3347
+ style: {
3348
+ transform: P(O),
3349
+ transformOrigin: "0 0",
3350
+ right: w ? "var(--kol-sidenav-w, 320px)" : 0,
3351
+ bottom: E ?? 0
3352
+ },
3353
+ onPointerDownCapture: F,
3354
+ onPointerMoveCapture: ee,
3355
+ onPointerUpCapture: I,
3356
+ onPointerCancelCapture: I,
3357
+ onPointerLeave: I,
3358
+ children: /* @__PURE__ */ Q(_t, { fit: S })
3359
+ }),
3360
+ g === "entry" && /* @__PURE__ */ Q(oi, {
3361
+ chromes: d,
3362
+ onGenerate: () => _("category"),
3363
+ onEffects: () => {
3364
+ y(!0), B();
3365
+ }
3366
+ }),
3367
+ g === "category" && /* @__PURE__ */ Q(mr, {
3368
+ onPick: te,
3369
+ onInsert: B,
3370
+ onBack: () => _("entry")
3371
+ }),
3372
+ g === "live" && !R && /* @__PURE__ */ Q(ai, {
3373
+ layer: L,
3374
+ onSwitchCategory: z,
3375
+ onInsert: () => {
3376
+ H(), B();
3377
+ },
3378
+ onRestart: H,
3379
+ aspectValue: S === "cover" ? "fill" : s,
3380
+ openEffects: v && !R,
3381
+ onAspect: V,
3382
+ rail: !d && !f,
3383
+ onRail: T,
3384
+ onSheet: D
3385
+ }),
3386
+ R && /* @__PURE__ */ $("div", {
3387
+ className: "fixed inset-y-0 right-0 left-[var(--fxr-rail,0px)] kol-overlay-scrim flex flex-col",
3388
+ style: { zIndex: "var(--kol-z-modal)" },
3389
+ children: [/* @__PURE__ */ Q("div", {
3390
+ className: "flex-1 min-h-0",
3391
+ children: /* @__PURE__ */ Q(_r, { layer: L })
3392
+ }), /* @__PURE__ */ Q("div", {
3393
+ className: "flex justify-center pb-[max(0.75rem,env(safe-area-inset-bottom))]",
3394
+ children: /* @__PURE__ */ Q(J, {
3395
+ tone: "outline",
3396
+ size: "lg",
3397
+ onClick: H,
3398
+ children: "Back"
3399
+ })
3400
+ })]
3401
+ })
3402
+ ]
3403
+ });
3404
+ }
3405
+ function ci() {
3406
+ return /* @__PURE__ */ $(jt, {
3407
+ persistDraft: !1,
3408
+ children: [/* @__PURE__ */ Q(si, {}), /* @__PURE__ */ Q(At, {})]
3409
+ });
3410
+ }
3411
+ //#endregion
3412
+ //#region src/index.jsx
3413
+ function li(e = {}) {
3414
+ return e.variant === "kolbox" ? /* @__PURE__ */ Q(di, { ...e }) : /* @__PURE__ */ Q(It, { ...e });
3415
+ }
3416
+ var ui = $t(() => import("./KolboxView-BjYfn_tl.js"));
3417
+ function di({ mediaProxyBase: e, mediaClient: t, settingsStore: r, pages: i, account: a }) {
3418
+ return e != null && ot(e), t && it(t), Y(() => {
3419
+ if (r) return n(r), () => n(null);
3420
+ }, [r]), on(), ln({
3421
+ client: t ?? null,
3422
+ store: () => r ?? null,
3423
+ account: a ?? null
3424
+ }), /* @__PURE__ */ Q(Zt, {
3425
+ fallback: null,
3426
+ children: /* @__PURE__ */ Q(ui, { pages: i })
3427
+ });
3428
+ }
3429
+ //#endregion
3430
+ export { dn as _, Vr as a, kn as c, vn as d, En as f, un as g, fn as h, Wr as i, An as l, wn as m, ci as n, Er as o, Dn as p, Ur as r, Zn as s, li as t, Pn as u };