@kolkrabbi/design-editor 0.46.0 → 0.47.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 (50) hide show
  1. package/dist/{BindDot-B0VcuOag.js → BindDot-B85UV79g.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-n6kEPJtV.js +21615 -0
  9. package/dist/{RenderTargetSystem-oFwWv5IW.js → RenderTargetSystem-Bom_vhlS.js} +1 -1
  10. package/dist/{Timeline-Ck1rBV8S.js → Timeline-EbecYeGh.js} +49 -47
  11. package/dist/TreePicker-2RUSyGl4.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-9UlJPBwX.js} +6272 -6239
  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-CCpYmxS0.js} +8965 -4984
  22. package/dist/effects-DspYFJAM.js +447 -0
  23. package/dist/effects.js +1 -1
  24. package/dist/{generators-BdVXv0jY.js → generators-DY4_ymWh.js} +2386 -2416
  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-Bo6itV50.js} +50 -50
  29. package/dist/init-DkGhdexn.js +4 -0
  30. package/dist/{morphStore-D6mkLJ-8.js → morphStore-Bm30Ekce.js} +1 -1
  31. package/dist/{motion-wsc6Qd7S.js → motion-BOWE4m3Q.js} +762 -759
  32. package/dist/motion.js +1 -1
  33. package/dist/{pipeline-CMpuPUaX.js → pipeline-hZsOKbHd.js} +12 -12
  34. package/dist/{previewScale-SYKvfhUm.js → previewScale-C6EBx--U.js} +8 -8
  35. package/dist/{rolls-KpWCAeDv.js → rolls-DugKaHUw.js} +10549 -4517
  36. package/dist/src-BlvCHYVY.js +3672 -0
  37. package/dist/{src-B5o6fGRJ.js → src-D-TQbBo2.js} +1 -2
  38. package/dist/{store-iBb0I6hk.js → store-BMGP1qou.js} +295 -275
  39. package/dist/{useLayerEdit-Ba7RA6qX.js → useLayerEdit-B5nF5I9b.js} +103 -102
  40. package/dist/webworkerAll-0WBQ2FBr.js +2 -0
  41. package/package.json +12 -9
  42. package/dist/CanvasRenderer-Bl0rlqNq.js +0 -2
  43. package/dist/TreePicker-Dv0zpJwe.js +0 -166
  44. package/dist/WebGLRenderer-CXxpVIx3.js +0 -2
  45. package/dist/WebGPURenderer-BwLEUYBa.js +0 -2
  46. package/dist/browserAll-CAzdTUbR.js +0 -6
  47. package/dist/chunk-3b4jIN3o.js +0 -13
  48. package/dist/effects-B47bpwGh.js +0 -447
  49. package/dist/init-jApIMi04.js +0 -4
  50. package/dist/webworkerAll-DEZhpG90.js +0 -2
@@ -1,4 +1,5 @@
1
- import { D as e, Dn as t, In as n, J as r, L as i, Ln as a, Mn as o, Pn as s, Rn as c, Rt as l, _ as u, b as ee, er as d, f, g as p, h as te, m, p as h, v as g, x as ne, y as re } from "./rolls-KpWCAeDv.js";
1
+ import { _ as e, d as t, g as n, m as r, o as i, v as a } from "./__vite-browser-external-y2xWjzgx.js";
2
+ import { D as o, Fr as s, J as c, L as l, _ as u, b as ee, f as d, g as te, h as f, m as p, p as m, v as h, x as g, xn as ne, y as re } from "./rolls-DugKaHUw.js";
2
3
  import { Button as _, ButtonGroup as ie, CloseButton as v, ColorPickerPopover as ae, Dropdown as y, FullscreenOverlay as b, FunctionPlot as x, Input as S, LabeledControl as C, MenuDropdownItem as w, ModalShell as T, Section as E, Slider as D, Stepper as O, Tooltip as k } from "@kolkrabbi/kol-component";
3
4
  import { createContext as oe, useCallback as A, useContext as se, useEffect as j, useMemo as ce, useRef as le, useState as M, useSyncExternalStore as N } from "react";
4
5
  import { Fragment as ue, jsx as P, jsxs as F } from "react/jsx-runtime";
@@ -39,27 +40,27 @@ var fe = [
39
40
  }
40
41
  ], I = 196, L = 64;
41
42
  function pe({ expr: e }) {
42
- let [n, r] = M(0);
43
+ let [t, n] = M(0);
43
44
  j(() => {
44
- let e = 0, n = () => {
45
- r(t.getCtx().t ?? 0), e = requestAnimationFrame(n);
45
+ let e = 0, t = () => {
46
+ n(i.getCtx().t ?? 0), e = requestAnimationFrame(t);
46
47
  };
47
- return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
48
+ return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
48
49
  }, []);
49
- let i = s(e), a = t.getLoopSeconds(), o = I, c = Array.from({ length: 197 }, (e, t) => i.ok ? i.fn(t / o * a) : 0);
50
+ let a = r(e), o = i.getLoopSeconds(), s = I, c = Array.from({ length: 197 }, (e, t) => a.ok ? a.fn(t / s * o) : 0);
50
51
  return /* @__PURE__ */ P(x, {
51
52
  samples: c,
52
53
  min: Math.min(0, ...c),
53
54
  max: Math.max(1, ...c),
54
- cursor: n,
55
+ cursor: t,
55
56
  height: L,
56
57
  ariaLabel: "Expression plot over one loop"
57
58
  });
58
59
  }
59
- function me({ layer: t, param: r, setProp: s }) {
60
- let l = i(), u = t[r.key], [ee, d] = M(null), [f, p] = M(!1), [te, m] = M(!1);
61
- if (!e(u) || u.bind !== "mod") return null;
62
- let h = u.source, g = u.transform ?? {}, ne = h.startsWith("lfo-"), re = h === "midi", v = n(h), ae = h === "expr", y = g.expr ?? "wave(t)", b = (e) => s(r.key, {
60
+ function R({ layer: r, param: i, setProp: s }) {
61
+ let c = l(), u = r[i.key], [ee, d] = M(null), [te, f] = M(!1), [p, m] = M(!1);
62
+ if (!o(u) || u.bind !== "mod") return null;
63
+ let h = u.source, g = u.transform ?? {}, ne = h.startsWith("lfo-"), re = h === "midi", v = n(h), ae = h === "expr", y = g.expr ?? "wave(t)", b = (e) => s(i.key, {
63
64
  ...u,
64
65
  transform: {
65
66
  ...g,
@@ -70,17 +71,17 @@ function me({ layer: t, param: r, setProp: s }) {
70
71
  let t = String(e).trim();
71
72
  t && t !== y && b({ expr: t });
72
73
  }, T = async () => {
73
- p(!0);
74
- let e = await c();
75
- p(!1), e != null && b({ cc: e });
74
+ f(!0);
75
+ let e = await a();
76
+ f(!1), e != null && b({ cc: e });
76
77
  }, E = async () => {
77
78
  m(!0);
78
- let e = await a();
79
- m(!1), e && s(r.key, {
79
+ let t = await e();
80
+ m(!1), t && s(i.key, {
80
81
  ...u,
81
- source: e
82
+ source: t
82
83
  });
83
- }, O = g.range ?? (r.min != null && r.max != null ? [r.min, r.max] : [0, 1]), k = (e, t) => {
84
+ }, O = g.range ?? (i.min != null && i.max != null ? [i.min, i.max] : [0, 1]), k = (e, t) => {
84
85
  let n = Number(e);
85
86
  return Number.isFinite(n) ? n : t;
86
87
  };
@@ -96,7 +97,7 @@ function me({ layer: t, param: r, setProp: s }) {
96
97
  className: "flex-1 min-w-0",
97
98
  children: /* @__PURE__ */ P(S, {
98
99
  variant: "filled",
99
- size: l,
100
+ size: c,
100
101
  type: "number",
101
102
  width: "100%",
102
103
  value: O[0],
@@ -111,7 +112,7 @@ function me({ layer: t, param: r, setProp: s }) {
111
112
  className: "flex-1 min-w-0",
112
113
  children: /* @__PURE__ */ P(S, {
113
114
  variant: "filled",
114
- size: l,
115
+ size: c,
115
116
  type: "number",
116
117
  width: "100%",
117
118
  value: O[1],
@@ -127,7 +128,7 @@ function me({ layer: t, param: r, setProp: s }) {
127
128
  label: "Invert",
128
129
  children: /* @__PURE__ */ P(ie, {
129
130
  layout: "joined",
130
- size: l,
131
+ size: c,
131
132
  className: "w-full",
132
133
  options: [{
133
134
  value: "off",
@@ -187,7 +188,7 @@ function me({ layer: t, param: r, setProp: s }) {
187
188
  label: "Expression",
188
189
  children: /* @__PURE__ */ P(S, {
189
190
  variant: "ghost",
190
- size: l,
191
+ size: c,
191
192
  value: ee ?? y,
192
193
  onChange: (e) => d(e.target.value),
193
194
  onBlur: (e) => x(e.target.value),
@@ -214,58 +215,58 @@ function me({ layer: t, param: r, setProp: s }) {
214
215
  label: g?.cc == null ? "MIDI · no CC yet" : `MIDI · CC ${g.cc}`,
215
216
  children: /* @__PURE__ */ P(_, {
216
217
  tone: "outline",
217
- size: l,
218
+ size: c,
218
219
  onClick: T,
219
- children: f ? "Move a knob…" : "Learn"
220
+ children: te ? "Move a knob…" : "Learn"
220
221
  })
221
222
  }),
222
223
  v && /* @__PURE__ */ P(C, {
223
- label: o(h)?.label ?? "Gamepad",
224
+ label: t(h)?.label ?? "Gamepad",
224
225
  children: /* @__PURE__ */ P(_, {
225
226
  tone: "outline",
226
- size: l,
227
+ size: c,
227
228
  onClick: E,
228
- children: te ? "Move a control…" : "Learn"
229
+ children: p ? "Move a control…" : "Learn"
229
230
  })
230
231
  })
231
232
  ]
232
233
  });
233
234
  }
234
- function he({ layer: t, schema: n, setProp: r }) {
235
- let i = (n ?? []).filter((n) => {
236
- let r = t[n.key];
237
- return e(r) && r.bind === "mod";
235
+ function me({ layer: e, schema: n, setProp: r }) {
236
+ let i = (n ?? []).filter((t) => {
237
+ let n = e[t.key];
238
+ return o(n) && n.bind === "mod";
238
239
  });
239
240
  return i.length === 0 ? null : /* @__PURE__ */ F("div", {
240
241
  className: "flex flex-col gap-4",
241
242
  children: [/* @__PURE__ */ P("span", {
242
243
  className: "kol-eyebrow text-fg-80",
243
244
  children: "Modulation"
244
- }), i.map((e) => {
245
- let n = o(t[e.key].source);
245
+ }), i.map((n) => {
246
+ let i = t(e[n.key].source);
246
247
  return /* @__PURE__ */ F("div", {
247
248
  className: "flex flex-col gap-2 pt-3 border-t border-oq-08",
248
249
  children: [/* @__PURE__ */ F("div", {
249
250
  className: "flex items-center justify-between",
250
251
  children: [/* @__PURE__ */ P("span", {
251
252
  className: "kol-helper-12 text-emphasis",
252
- children: e.label ?? e.key
253
+ children: n.label ?? n.key
253
254
  }), /* @__PURE__ */ P("span", {
254
255
  className: "kol-helper-10 text-meta",
255
- children: n?.label ?? t[e.key].source
256
+ children: i?.label ?? e[n.key].source
256
257
  })]
257
- }), /* @__PURE__ */ P(me, {
258
- layer: t,
259
- param: e,
258
+ }), /* @__PURE__ */ P(R, {
259
+ layer: e,
260
+ param: n,
260
261
  setProp: r
261
262
  })]
262
- }, e.key);
263
+ }, n.key);
263
264
  })]
264
265
  });
265
266
  }
266
267
  //#endregion
267
268
  //#region src/editor/modes/pattern/RuleRow.jsx
268
- var R = [
269
+ var z = [
269
270
  {
270
271
  value: "all",
271
272
  label: "All cells"
@@ -294,7 +295,7 @@ var R = [
294
295
  value: "expression",
295
296
  label: "Expression…"
296
297
  }
297
- ], z = [
298
+ ], B = [
298
299
  {
299
300
  value: 0,
300
301
  label: "0°"
@@ -311,19 +312,19 @@ var R = [
311
312
  value: 270,
312
313
  label: "270°"
313
314
  }
314
- ], ge = [
315
+ ], he = [
315
316
  "every-col",
316
317
  "every-row",
317
318
  "both",
318
319
  "every-nth",
319
320
  "checker"
320
- ], _e = [
321
+ ], ge = [
321
322
  0,
322
323
  90,
323
324
  180,
324
325
  270
325
- ], ve = 1, ye = () => `r${ve++}`, be = () => ({
326
- id: ye(),
326
+ ], _e = 1, ve = () => `r${_e++}`, ye = () => ({
327
+ id: ve(),
327
328
  selectKind: "every-col",
328
329
  n: 2,
329
330
  offset: 0,
@@ -337,9 +338,9 @@ var R = [
337
338
  flipV: !1,
338
339
  hide: !1,
339
340
  opacity: 1
340
- }), xe = (e) => e[Math.floor(Math.random() * e.length)], Se = () => ({
341
- id: ye(),
342
- selectKind: xe(ge),
341
+ }), be = (e) => e[Math.floor(Math.random() * e.length)], xe = () => ({
342
+ id: ve(),
343
+ selectKind: be(he),
343
344
  n: Math.floor(Math.random() * 5) + 2,
344
345
  offset: Math.floor(Math.random() * 3),
345
346
  n2: Math.floor(Math.random() * 5) + 2,
@@ -347,13 +348,13 @@ var R = [
347
348
  expression: "sin(col * 0.6) + cos(row * 0.6)",
348
349
  groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
349
350
  groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
350
- rotate: xe(_e),
351
+ rotate: be(ge),
351
352
  flipH: Math.random() > .6,
352
353
  flipV: Math.random() > .6,
353
354
  hide: Math.random() > .85,
354
355
  opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
355
356
  });
356
- function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
357
+ function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
357
358
  return /* @__PURE__ */ P(O, {
358
359
  size: "sm",
359
360
  value: e,
@@ -363,7 +364,7 @@ function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
363
364
  className: "w-full"
364
365
  });
365
366
  }
366
- function Ce({ active: e, onClick: t, children: n, title: r }) {
367
+ function Se({ active: e, onClick: t, children: n, title: r }) {
367
368
  return /* @__PURE__ */ P(k, {
368
369
  label: r,
369
370
  children: /* @__PURE__ */ P(_, {
@@ -376,7 +377,7 @@ function Ce({ active: e, onClick: t, children: n, title: r }) {
376
377
  })
377
378
  });
378
379
  }
379
- function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
380
+ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
380
381
  let i = (n) => t({
381
382
  ...e,
382
383
  ...n
@@ -393,7 +394,7 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
393
394
  variant: "subtle",
394
395
  size: "sm",
395
396
  className: "w-full",
396
- options: R,
397
+ options: z,
397
398
  value: e.selectKind,
398
399
  onChange: (e) => i({ selectKind: e })
399
400
  })
@@ -430,14 +431,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
430
431
  className: "grid grid-cols-2 gap-2",
431
432
  children: [/* @__PURE__ */ P(E, {
432
433
  label: "N",
433
- children: /* @__PURE__ */ P(B, {
434
+ children: /* @__PURE__ */ P(V, {
434
435
  value: e.n,
435
436
  onChange: (e) => i({ n: e }),
436
437
  min: 1
437
438
  })
438
439
  }), /* @__PURE__ */ P(E, {
439
440
  label: "Offset",
440
- children: /* @__PURE__ */ P(B, {
441
+ children: /* @__PURE__ */ P(V, {
441
442
  value: e.offset,
442
443
  onChange: (e) => i({ offset: e })
443
444
  })
@@ -447,14 +448,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
447
448
  className: "grid grid-cols-2 gap-2",
448
449
  children: [/* @__PURE__ */ P(E, {
449
450
  label: "Row N",
450
- children: /* @__PURE__ */ P(B, {
451
+ children: /* @__PURE__ */ P(V, {
451
452
  value: e.n2,
452
453
  onChange: (e) => i({ n2: e }),
453
454
  min: 1
454
455
  })
455
456
  }), /* @__PURE__ */ P(E, {
456
457
  label: "Row offset",
457
- children: /* @__PURE__ */ P(B, {
458
+ children: /* @__PURE__ */ P(V, {
458
459
  value: e.offset2,
459
460
  onChange: (e) => i({ offset2: e })
460
461
  })
@@ -478,14 +479,14 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
478
479
  className: "grid grid-cols-2 gap-2",
479
480
  children: [/* @__PURE__ */ P(E, {
480
481
  label: "Group W",
481
- children: /* @__PURE__ */ P(B, {
482
+ children: /* @__PURE__ */ P(V, {
482
483
  value: e.groupW,
483
484
  onChange: (e) => i({ groupW: Math.max(1, e) }),
484
485
  min: 1
485
486
  })
486
487
  }), /* @__PURE__ */ P(E, {
487
488
  label: "Group H",
488
- children: /* @__PURE__ */ P(B, {
489
+ children: /* @__PURE__ */ P(V, {
489
490
  value: e.groupH,
490
491
  onChange: (e) => i({ groupH: Math.max(1, e) }),
491
492
  min: 1
@@ -498,23 +499,23 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
498
499
  /* @__PURE__ */ P(y, {
499
500
  variant: "subtle",
500
501
  size: "sm",
501
- options: z,
502
+ options: B,
502
503
  value: e.rotate,
503
504
  onChange: (e) => i({ rotate: Number(e) })
504
505
  }),
505
- /* @__PURE__ */ P(Ce, {
506
+ /* @__PURE__ */ P(Se, {
506
507
  active: e.flipH,
507
508
  onClick: () => i({ flipH: !e.flipH }),
508
509
  title: "Flip horizontal",
509
510
  children: "⇋"
510
511
  }),
511
- /* @__PURE__ */ P(Ce, {
512
+ /* @__PURE__ */ P(Se, {
512
513
  active: e.flipV,
513
514
  onClick: () => i({ flipV: !e.flipV }),
514
515
  title: "Flip vertical",
515
516
  children: "⇵"
516
517
  }),
517
- /* @__PURE__ */ P(Ce, {
518
+ /* @__PURE__ */ P(Se, {
518
519
  active: e.hide,
519
520
  onClick: () => i({ hide: !e.hide }),
520
521
  title: "Hide cell",
@@ -537,8 +538,8 @@ function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
537
538
  }
538
539
  //#endregion
539
540
  //#region src/editor/library/mergeRemote.js
540
- var Te = (e) => e?.updatedAt ?? e?.savedAt ?? 0, Ee = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
541
- function De(e, t) {
541
+ var we = (e) => e?.updatedAt ?? e?.savedAt ?? 0, Te = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
542
+ function Ee(e, t) {
542
543
  let n = {}, r = [], i = /* @__PURE__ */ new Map();
543
544
  for (let e of t || []) i.has(e.kind) || i.set(e.kind, /* @__PURE__ */ new Map()), i.get(e.kind).set(e.id, e);
544
545
  let a = new Set([...Object.keys(e || {}), ...i.keys()]);
@@ -550,7 +551,7 @@ function De(e, t) {
550
551
  o.push(n);
551
552
  continue;
552
553
  }
553
- if (Ee(n)) {
554
+ if (Te(n)) {
554
555
  s.add(n.id), e && !e.deleted && r.push({
555
556
  op: "remove",
556
557
  kind: t,
@@ -567,7 +568,7 @@ function De(e, t) {
567
568
  continue;
568
569
  }
569
570
  if (e.deleted) {
570
- if (e.updatedAt > Te(n)) continue;
571
+ if (e.updatedAt > we(n)) continue;
571
572
  o.push(n), r.push({
572
573
  op: "put",
573
574
  kind: t,
@@ -575,7 +576,7 @@ function De(e, t) {
575
576
  });
576
577
  continue;
577
578
  }
578
- e.updatedAt > Te(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < Te(n) && r.push({
579
+ e.updatedAt > we(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < we(n) && r.push({
579
580
  op: "put",
580
581
  kind: t,
581
582
  item: n
@@ -583,7 +584,7 @@ function De(e, t) {
583
584
  }
584
585
  let c = new Set(o.map((e) => e.id));
585
586
  for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
586
- if (Ee(e.spec)) {
587
+ if (Te(e.spec)) {
587
588
  r.push({
588
589
  op: "remove",
589
590
  kind: t,
@@ -602,19 +603,19 @@ function De(e, t) {
602
603
  }
603
604
  //#endregion
604
605
  //#region src/editor/library/libraryApi.js
605
- var V = null;
606
- function Oe(e) {
607
- V = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Re();
606
+ var H = null;
607
+ function De(e) {
608
+ H = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Le();
608
609
  }
609
- function ke() {
610
- return V;
610
+ function Oe() {
611
+ return H;
611
612
  }
612
- var H = class extends Error {
613
+ var U = class extends Error {
613
614
  constructor() {
614
615
  super("unauthorized"), this.name = "UnauthorizedError";
615
616
  }
616
617
  };
617
- function Ae(e, t) {
618
+ function ke(e, t) {
618
619
  let n = `Bearer ${t}`, r = async (t, r = {}) => {
619
620
  let i = await fetch(`${e}${t}`, {
620
621
  ...r,
@@ -624,7 +625,7 @@ function Ae(e, t) {
624
625
  ...r.headers || {}
625
626
  }
626
627
  });
627
- if (i.status === 401) throw new H();
628
+ if (i.status === 401) throw new U();
628
629
  if (!i.ok) throw Error(`library api ${i.status}`);
629
630
  return i.json();
630
631
  };
@@ -648,33 +649,33 @@ function Ae(e, t) {
648
649
  }
649
650
  };
650
651
  }
651
- var je = "kol.fxr.library-session", U = null, Me = /* @__PURE__ */ new Set(), W = () => Me.forEach((e) => e());
652
- function Ne() {
653
- return U;
652
+ var Ae = "kol.fxr.library-session", W = null, je = /* @__PURE__ */ new Set(), G = () => je.forEach((e) => e());
653
+ function Me() {
654
+ return W;
654
655
  }
655
- var Pe = () => N((e) => (Me.add(e), () => Me.delete(e)), Ne, Ne), Fe = () => Pe()?.user ?? null;
656
- function G(e) {
656
+ var Ne = () => N((e) => (je.add(e), () => je.delete(e)), Me, Me), Pe = () => Ne()?.user ?? null;
657
+ function K(e) {
657
658
  try {
658
- e ? localStorage.setItem(je, JSON.stringify(e)) : localStorage.removeItem(je);
659
+ e ? localStorage.setItem(Ae, JSON.stringify(e)) : localStorage.removeItem(Ae);
659
660
  } catch {}
660
661
  }
661
- var Ie = () => {
662
+ var Fe = () => {
662
663
  try {
663
- return JSON.parse(localStorage.getItem(je) || "null");
664
+ return JSON.parse(localStorage.getItem(Ae) || "null");
664
665
  } catch {
665
666
  return null;
666
667
  }
667
668
  };
668
- function Le(e, t) {
669
- let { next: n, pushes: r } = De(Z(), t);
670
- lt({
671
- ...Z(),
669
+ function Ie(e, t) {
670
+ let { next: n, pushes: r } = Ee(Q(), t);
671
+ ct({
672
+ ...Q(),
672
673
  ...n
673
674
  });
674
675
  for (let t of r) e.push(t).catch(() => {});
675
676
  }
676
- async function K(e, t = {}, n) {
677
- let r = await fetch(`${V}${e}`, {
677
+ async function q(e, t = {}, n) {
678
+ let r = await fetch(`${H}${e}`, {
678
679
  ...t,
679
680
  headers: {
680
681
  "content-type": "application/json",
@@ -682,50 +683,50 @@ async function K(e, t = {}, n) {
682
683
  ...t.headers || {}
683
684
  }
684
685
  });
685
- if (r.status === 401) throw new H();
686
+ if (r.status === 401) throw new U();
686
687
  let i = await r.json().catch(() => ({}));
687
688
  if (!r.ok) throw Error(i.error || `library api ${r.status}`);
688
689
  return i;
689
690
  }
690
- function Re() {
691
- if (U || !V) return;
692
- let e = Ie();
693
- if (!e?.token || e.base !== V || !(e.expiresAt > Date.now()) || !e.user) return;
694
- let t = Ae(V, e.token);
695
- U = {
691
+ function Le() {
692
+ if (W || !H) return;
693
+ let e = Fe();
694
+ if (!e?.token || e.base !== H || !(e.expiresAt > Date.now()) || !e.user) return;
695
+ let t = ke(H, e.token);
696
+ W = {
696
697
  backend: t,
697
698
  user: e.user,
698
699
  token: e.token
699
- }, W(), K("/api/me", {}, e.token).then(({ user: t }) => {
700
- U?.token === e.token && (U = {
701
- ...U,
700
+ }, G(), q("/api/me", {}, e.token).then(({ user: t }) => {
701
+ W?.token === e.token && (W = {
702
+ ...W,
702
703
  user: t
703
- }, G({
704
+ }, K({
704
705
  ...e,
705
706
  user: t
706
- }), W());
707
+ }), G());
707
708
  }).catch((e) => {
708
- e instanceof H && q();
709
- }), t.hydrate().then((e) => Le(t, e)).catch((e) => {
710
- e instanceof H ? q() : console.warn("library sync: hydrate failed —", e?.message || e);
709
+ e instanceof U && J();
710
+ }), t.hydrate().then((e) => Ie(t, e)).catch((e) => {
711
+ e instanceof U ? J() : console.warn("library sync: hydrate failed —", e?.message || e);
711
712
  });
712
713
  }
713
- async function ze({ token: e, expiresAt: t, user: n }) {
714
- let r = Ae(V, e), i = await r.hydrate();
715
- return Le(r, i), U = {
714
+ async function Re({ token: e, expiresAt: t, user: n }) {
715
+ let r = ke(H, e), i = await r.hydrate();
716
+ return Ie(r, i), W = {
716
717
  backend: r,
717
718
  user: n,
718
719
  token: e
719
- }, G({
720
- base: V,
720
+ }, K({
721
+ base: H,
721
722
  token: e,
722
723
  expiresAt: t,
723
724
  user: n
724
- }), W(), i.filter((e) => !e.deleted).length;
725
+ }), G(), i.filter((e) => !e.deleted).length;
725
726
  }
726
- async function Be({ email: e, password: t } = {}) {
727
- if (!V) throw Error("no library api");
728
- return ze(await K("/api/auth/signin", {
727
+ async function ze({ email: e, password: t } = {}) {
728
+ if (!H) throw Error("no library api");
729
+ return Re(await q("/api/auth/signin", {
729
730
  method: "POST",
730
731
  body: JSON.stringify({
731
732
  email: e,
@@ -733,48 +734,48 @@ async function Be({ email: e, password: t } = {}) {
733
734
  })
734
735
  }));
735
736
  }
736
- async function Ve(e) {
737
- if (!V) throw Error("no library api");
738
- return ze(await K("/api/auth/signup", {
737
+ async function Be(e) {
738
+ if (!H) throw Error("no library api");
739
+ return Re(await q("/api/auth/signup", {
739
740
  method: "POST",
740
741
  body: JSON.stringify(e)
741
742
  }));
742
743
  }
743
- function q() {
744
- let e = U?.token ?? Ie()?.token;
745
- G(null), e && V && K("/api/auth/signout", {
744
+ function J() {
745
+ let e = W?.token ?? Fe()?.token;
746
+ K(null), e && H && q("/api/auth/signout", {
746
747
  method: "POST",
747
748
  body: "{}"
748
- }, e).catch(() => {}), U && (U = null, W());
749
+ }, e).catch(() => {}), W && (W = null, G());
749
750
  }
750
- async function He(e) {
751
- if (!U) throw new H();
752
- let { user: t } = await K("/api/me", {
751
+ async function Ve(e) {
752
+ if (!W) throw new U();
753
+ let { user: t } = await q("/api/me", {
753
754
  method: "PATCH",
754
755
  body: JSON.stringify(e)
755
- }, U.token);
756
- return U = {
757
- ...U,
756
+ }, W.token);
757
+ return W = {
758
+ ...W,
758
759
  user: t
759
- }, G({
760
- ...Ie(),
760
+ }, K({
761
+ ...Fe(),
761
762
  user: t
762
- }), W(), t;
763
+ }), G(), t;
763
764
  }
764
- async function Ue() {
765
- if (!U) throw new H();
766
- let { token: e, expiresAt: t } = await K("/api/invites", {
765
+ async function He() {
766
+ if (!W) throw new U();
767
+ let { token: e, expiresAt: t } = await q("/api/invites", {
767
768
  method: "POST",
768
769
  body: "{}"
769
- }, U.token);
770
+ }, W.token);
770
771
  return {
771
772
  url: `${window.location.origin}/join?invite=${encodeURIComponent(e)}`,
772
773
  expiresAt: t
773
774
  };
774
775
  }
775
- async function We({ name: e, email: t }) {
776
- if (!V) throw Error("no library api");
777
- return K("/api/invite-requests", {
776
+ async function Ue({ name: e, email: t }) {
777
+ if (!H) throw Error("no library api");
778
+ return q("/api/invite-requests", {
778
779
  method: "POST",
779
780
  body: JSON.stringify({
780
781
  name: e,
@@ -782,16 +783,16 @@ async function We({ name: e, email: t }) {
782
783
  })
783
784
  });
784
785
  }
785
- async function Ge() {
786
- if (!U) throw new H();
787
- return (await K("/api/invite-requests", {}, U.token)).requests;
786
+ async function We() {
787
+ if (!W) throw new U();
788
+ return (await q("/api/invite-requests", {}, W.token)).requests;
788
789
  }
789
- async function Ke(e) {
790
- if (!U) throw new H();
791
- let { token: t, expiresAt: n, email: r, name: i } = await K(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
790
+ async function Ge(e) {
791
+ if (!W) throw new U();
792
+ let { token: t, expiresAt: n, email: r, name: i } = await q(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
792
793
  method: "POST",
793
794
  body: "{}"
794
- }, U.token);
795
+ }, W.token);
795
796
  return {
796
797
  url: `${window.location.origin}/join?invite=${encodeURIComponent(t)}`,
797
798
  expiresAt: n,
@@ -801,17 +802,17 @@ async function Ke(e) {
801
802
  }
802
803
  //#endregion
803
804
  //#region src/editor/library/LibraryProvider.jsx
804
- var qe = "kol.editor.library.v3", J = [
805
+ var Ke = "kol.editor.library.v3", Y = [
805
806
  "palette",
806
807
  "pattern",
807
808
  "type",
808
809
  "preset"
809
- ], Y = J.reduce((e, t) => (e[t] = [], e), {}), Je = 1, Ye = () => `i${Date.now().toString(36)}-${Je++}`, Xe = (e) => ({
810
+ ], X = Y.reduce((e, t) => (e[t] = [], e), {}), qe = 1, Je = () => `i${Date.now().toString(36)}-${qe++}`, Ye = (e) => ({
810
811
  ...e,
811
- id: e.id ?? Ye(),
812
+ id: e.id ?? Je(),
812
813
  savedAt: e.savedAt ?? Date.now()
813
- }), X = (e) => typeof e == "number" && Number.isFinite(e);
814
- function Ze(e) {
814
+ }), Z = (e) => typeof e == "number" && Number.isFinite(e);
815
+ function Xe(e) {
815
816
  return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
816
817
  colors: e.colors,
817
818
  bgEnabled: !!e.bgEnabled,
@@ -819,39 +820,39 @@ function Ze(e) {
819
820
  modeId: e.modeId ?? "random"
820
821
  };
821
822
  }
822
- function Qe(e) {
823
+ function Ze(e) {
823
824
  return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
824
825
  shapeId: e.shapeId,
825
826
  customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
826
- cols: X(e.cols) ? e.cols : 4,
827
- rows: X(e.rows) ? e.rows : 4,
828
- gap: X(e.gap) ? e.gap : 0,
829
- padding: X(e.padding) ? e.padding : 0,
827
+ cols: Z(e.cols) ? e.cols : 4,
828
+ rows: Z(e.rows) ? e.rows : 4,
829
+ gap: Z(e.gap) ? e.gap : 0,
830
+ padding: Z(e.padding) ? e.padding : 0,
830
831
  stretch: !!e.stretch,
831
832
  overflow: !!e.overflow,
832
833
  bg: e.bg ?? null,
833
834
  color: e.color ?? "palette:secondary",
834
835
  rules: Array.isArray(e.rules) ? e.rules : [],
835
- scale: X(e.scale) ? e.scale : 256
836
+ scale: Z(e.scale) ? e.scale : 256
836
837
  };
837
838
  }
838
- function $e(e) {
839
+ function Qe(e) {
839
840
  if (!e || typeof e.text != "string") return null;
840
841
  let t = {
841
842
  text: e.text,
842
843
  width: e.width ?? "Tight",
843
- weight: X(e.weight) ? e.weight : 600,
844
+ weight: Z(e.weight) ? e.weight : 600,
844
845
  italic: !!e.italic,
845
- size: X(e.size) ? e.size : 96,
846
- tracking: X(e.tracking) ? e.tracking : -.01,
847
- lineHeight: X(e.lineHeight) ? e.lineHeight : 1.05,
846
+ size: Z(e.size) ? e.size : 96,
847
+ tracking: Z(e.tracking) ? e.tracking : -.01,
848
+ lineHeight: Z(e.lineHeight) ? e.lineHeight : 1.05,
848
849
  case: e.case ?? "original",
849
850
  color: e.color ?? "palette:dark",
850
851
  textAlign: e.textAlign ?? "center"
851
852
  };
852
853
  return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
853
854
  }
854
- function et(e) {
855
+ function $e(e) {
855
856
  return !e || !Array.isArray(e.layers) ? null : {
856
857
  intent: e.intent ?? "whole",
857
858
  aspect: e.aspect ?? "1:1",
@@ -863,44 +864,52 @@ function et(e) {
863
864
  } : {},
864
865
  ...typeof e.mode == "string" ? { mode: e.mode } : {},
865
866
  ...e.morph && typeof e.morph == "object" ? { morph: e.morph } : {},
867
+ ...typeof e.canvasX == "number" && typeof e.canvasY == "number" ? {
868
+ canvasX: e.canvasX,
869
+ canvasY: e.canvasY
870
+ } : {},
871
+ ...e.canvas && typeof e.canvas == "object" ? { canvas: e.canvas } : {},
872
+ ...Array.isArray(e.pages) ? { pages: e.pages } : {},
873
+ ...typeof e.frameModel == "number" ? { frameModel: e.frameModel } : {},
874
+ ...typeof e.layerModel == "number" ? { layerModel: e.layerModel } : {},
866
875
  ...typeof e.thumb == "string" ? { thumb: e.thumb } : {},
867
876
  ...e.shipped === !0 ? { shipped: !0 } : {},
868
877
  ...typeof e.group == "string" ? { group: e.group } : {},
869
878
  ...typeof e.sub == "string" ? { sub: e.sub } : {}
870
879
  };
871
880
  }
872
- var tt = {
873
- palette: Ze,
874
- pattern: Qe,
875
- type: $e,
876
- preset: et
877
- }, nt = [
881
+ var et = {
882
+ palette: Xe,
883
+ pattern: Ze,
884
+ type: Qe,
885
+ preset: $e
886
+ }, tt = [
878
887
  "id",
879
888
  "savedAt",
880
889
  "updatedAt",
881
890
  "name"
882
891
  ];
883
- function rt(e) {
892
+ function nt(e) {
884
893
  let t = {};
885
- for (let n of nt) e?.[n] !== void 0 && (t[n] = e[n]);
894
+ for (let n of tt) e?.[n] !== void 0 && (t[n] = e[n]);
886
895
  return t;
887
896
  }
888
- function it(e) {
889
- let t = J.reduce((e, t) => (e[t] = [], e), {});
890
- for (let n of J) {
891
- let r = tt[n];
897
+ function rt(e) {
898
+ let t = Y.reduce((e, t) => (e[t] = [], e), {});
899
+ for (let n of Y) {
900
+ let r = et[n];
892
901
  t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
893
902
  let t = r ? r(e) : e;
894
903
  return t ? {
895
904
  v: 1,
896
- ...rt(e),
905
+ ...nt(e),
897
906
  ...t
898
907
  } : null;
899
908
  }).filter(Boolean);
900
909
  }
901
910
  return t;
902
911
  }
903
- function at(e) {
912
+ function it(e) {
904
913
  return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
905
914
  ...e,
906
915
  type: "background"
@@ -913,7 +922,7 @@ function at(e) {
913
922
  kind: "logo"
914
923
  } : e : e) : e;
915
924
  }
916
- function ot(e) {
925
+ function at(e) {
917
926
  let t = {};
918
927
  for (let n of [
919
928
  "palette",
@@ -924,37 +933,37 @@ function ot(e) {
924
933
  "composition"
925
934
  ]) {
926
935
  let r = e?.[n];
927
- Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Xe(r)] : t[n] = [];
936
+ Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Ye(r)] : t[n] = [];
928
937
  }
929
938
  return t;
930
939
  }
931
- function st(e) {
932
- let t = J.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Xe(e)] : [];
940
+ function ot(e) {
941
+ let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Ye(e)] : [];
933
942
  t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
934
943
  let r = n(e?.layout), i = n(e?.composition).map((e) => ({
935
944
  ...e,
936
- layers: at(e.layers)
945
+ layers: it(e.layers)
937
946
  }));
938
947
  return t.preset = [...r, ...i], t;
939
948
  }
940
- function Z() {
941
- if (typeof window > "u") return Y;
949
+ function Q() {
950
+ if (typeof window > "u") return X;
942
951
  try {
943
- let e = window.localStorage.getItem(qe);
944
- if (e) return it(JSON.parse(e));
952
+ let e = window.localStorage.getItem(Ke);
953
+ if (e) return rt(JSON.parse(e));
945
954
  let t = window.localStorage.getItem("kol.generator.library.v2");
946
- if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), it(st(JSON.parse(t)));
955
+ if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), rt(ot(JSON.parse(t)));
947
956
  let n = window.localStorage.getItem("kol.generator.library.v1");
948
- return n ? it(st(ot(JSON.parse(n)))) : Y;
957
+ return n ? rt(ot(at(JSON.parse(n)))) : X;
949
958
  } catch {
950
- return Y;
959
+ return X;
951
960
  }
952
961
  }
953
- var ct = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
954
- function lt(e) {
962
+ var st = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
963
+ function ct(e) {
955
964
  if (!(typeof window > "u")) {
956
965
  try {
957
- window.localStorage.setItem(qe, JSON.stringify(e));
966
+ window.localStorage.setItem(Ke, JSON.stringify(e));
958
967
  } catch (e) {
959
968
  console.warn("library: could not save to this browser —", e?.message || e);
960
969
  return;
@@ -962,23 +971,23 @@ function lt(e) {
962
971
  window.dispatchEvent(new CustomEvent("kol:library"));
963
972
  }
964
973
  }
965
- var ut = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
974
+ var lt = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
966
975
  window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
967
- }), dt = () => {
976
+ }), ut = () => {
968
977
  try {
969
- return window.localStorage.getItem(qe);
978
+ return window.localStorage.getItem(Ke);
970
979
  } catch {
971
980
  return null;
972
981
  }
973
- }, ft = oe(null);
974
- function pt(e, t, n) {
982
+ }, dt = oe(null);
983
+ function ft(e, t, n) {
975
984
  return e.map((e) => e.id === t ? {
976
985
  ...e,
977
986
  name: String(n ?? "").trim() || null,
978
987
  updatedAt: Date.now()
979
988
  } : e);
980
989
  }
981
- function mt(e, t, n) {
990
+ function pt(e, t, n) {
982
991
  let r = e.findIndex((e) => e.id === t);
983
992
  if (r === -1) return e;
984
993
  let i = e[r], a = {
@@ -993,19 +1002,19 @@ function mt(e, t, n) {
993
1002
  ...e.slice(r + 1)
994
1003
  ];
995
1004
  }
996
- function ht({ children: e }) {
997
- let [t, n] = M(Z);
1005
+ function mt({ children: e }) {
1006
+ let [t, n] = M(Q);
998
1007
  j(() => {
999
- lt(t);
1008
+ ct(t);
1000
1009
  }, [t]);
1001
1010
  let r = le(t);
1002
1011
  r.current = t;
1003
1012
  let i = le(null), [a, o] = M("off"), s = A((e) => {
1004
1013
  let t = i.current;
1005
- !t || ct(e) || t.push(e).catch((e) => {
1006
- e instanceof H && q(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
1014
+ !t || st(e) || t.push(e).catch((e) => {
1015
+ e instanceof U && J(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
1007
1016
  });
1008
- }, []), c = Pe();
1017
+ }, []), c = Ne();
1009
1018
  j(() => {
1010
1019
  if (!c) {
1011
1020
  i.current = null, o("off");
@@ -1014,23 +1023,23 @@ function ht({ children: e }) {
1014
1023
  let e = !0;
1015
1024
  return c.backend.hydrate().then((t) => {
1016
1025
  if (!e) return;
1017
- let { next: a, pushes: l } = De(r.current, t);
1026
+ let { next: a, pushes: l } = Ee(r.current, t);
1018
1027
  i.current = c.backend, n({
1019
- ...Y,
1028
+ ...X,
1020
1029
  ...a
1021
1030
  }), o("on");
1022
1031
  for (let e of l) s(e);
1023
1032
  }).catch((e) => {
1024
- e instanceof H && q(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
1033
+ e instanceof U && J(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
1025
1034
  }), () => {
1026
1035
  e = !1;
1027
1036
  };
1028
1037
  }, [c, s]);
1029
1038
  let l = A((e, t) => {
1030
- if (!J.includes(e) || !t) return null;
1031
- let r = tt[e], i = r ? r(t) : t;
1039
+ if (!Y.includes(e) || !t) return null;
1040
+ let r = et[e], i = r ? r(t) : t;
1032
1041
  if (!i) return null;
1033
- let a = Ye(), o = {
1042
+ let a = Je(), o = {
1034
1043
  v: 1,
1035
1044
  id: a,
1036
1045
  savedAt: Date.now(),
@@ -1055,8 +1064,8 @@ function ht({ children: e }) {
1055
1064
  id: t
1056
1065
  });
1057
1066
  }, [s]), ee = A((e, t, i) => {
1058
- if (!J.includes(e) || !t || !i) return;
1059
- let a = tt[e], o = a ? a(i) : i;
1067
+ if (!Y.includes(e) || !t || !i) return;
1068
+ let a = et[e], o = a ? a(i) : i;
1060
1069
  if (!o) return;
1061
1070
  let c = Date.now(), l = (e) => ({
1062
1071
  ...e,
@@ -1077,19 +1086,19 @@ function ht({ children: e }) {
1077
1086
  item: l(u)
1078
1087
  });
1079
1088
  }, [s]), d = A((e, t, i) => {
1080
- if (!J.includes(e) || !t) return;
1089
+ if (!Y.includes(e) || !t) return;
1081
1090
  n((n) => ({
1082
1091
  ...n,
1083
- [e]: pt(n[e] ?? [], t, i)
1092
+ [e]: ft(n[e] ?? [], t, i)
1084
1093
  }));
1085
- let a = pt(r.current[e] ?? [], t, i).find((e) => e.id === t);
1094
+ let a = ft(r.current[e] ?? [], t, i).find((e) => e.id === t);
1086
1095
  a && s({
1087
1096
  op: "put",
1088
1097
  kind: e,
1089
1098
  item: a
1090
1099
  });
1091
- }, [s]), f = A((e, t, i) => {
1092
- if (!J.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
1100
+ }, [s]), te = A((e, t, i) => {
1101
+ if (!Y.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
1093
1102
  let a = (e) => e.map((e) => e.id === t ? {
1094
1103
  ...e,
1095
1104
  thumb: i
@@ -1104,30 +1113,30 @@ function ht({ children: e }) {
1104
1113
  kind: e,
1105
1114
  item: o
1106
1115
  });
1107
- }, [s]), p = A((e, t) => {
1108
- if (!J.includes(e) || !t) return null;
1109
- let i = Ye();
1116
+ }, [s]), f = A((e, t) => {
1117
+ if (!Y.includes(e) || !t) return null;
1118
+ let i = Je();
1110
1119
  n((n) => ({
1111
1120
  ...n,
1112
- [e]: mt(n[e] ?? [], t, i)
1121
+ [e]: pt(n[e] ?? [], t, i)
1113
1122
  }));
1114
- let a = mt(r.current[e] ?? [], t, i).find((e) => e.id === i);
1123
+ let a = pt(r.current[e] ?? [], t, i).find((e) => e.id === i);
1115
1124
  return a && s({
1116
1125
  op: "put",
1117
1126
  kind: e,
1118
1127
  item: a
1119
1128
  }), i;
1120
- }, [s]), te = A((e) => {
1129
+ }, [s]), p = A((e) => {
1121
1130
  n((t) => ({
1122
1131
  ...t,
1123
1132
  [e]: []
1124
1133
  }));
1125
- }, []), m = A(() => n(Y), []), h = A((e) => n({
1126
- ...Y,
1134
+ }, []), m = A(() => n(X), []), h = A((e) => n({
1135
+ ...X,
1127
1136
  ...e
1128
1137
  }), []), g = {
1129
1138
  library: t,
1130
- selected: ce(() => J.reduce((e, n) => {
1139
+ selected: ce(() => Y.reduce((e, n) => {
1131
1140
  let r = t[n] ?? [];
1132
1141
  return e[n] = r.length ? r[r.length - 1] : null, e;
1133
1142
  }, {}), [t]),
@@ -1135,9 +1144,9 @@ function ht({ children: e }) {
1135
1144
  removeItem: u,
1136
1145
  updateItem: ee,
1137
1146
  renameItem: d,
1138
- setThumb: f,
1139
- duplicateItem: p,
1140
- clearSlot: te,
1147
+ setThumb: te,
1148
+ duplicateItem: f,
1149
+ clearSlot: p,
1141
1150
  clearAll: m,
1142
1151
  replaceAll: h,
1143
1152
  syncState: a,
@@ -1146,15 +1155,15 @@ function ht({ children: e }) {
1146
1155
  saveType: (e) => l("type", e),
1147
1156
  savePreset: (e) => l("preset", e)
1148
1157
  };
1149
- return /* @__PURE__ */ P(ft.Provider, {
1158
+ return /* @__PURE__ */ P(dt.Provider, {
1150
1159
  value: g,
1151
1160
  children: e
1152
1161
  });
1153
1162
  }
1154
- function gt() {
1155
- return se(ft) || {
1156
- library: Y,
1157
- selected: J.reduce((e, t) => (e[t] = null, e), {}),
1163
+ function ht() {
1164
+ return se(dt) || {
1165
+ library: X,
1166
+ selected: Y.reduce((e, t) => (e[t] = null, e), {}),
1158
1167
  addItem: () => null,
1159
1168
  removeItem: () => {},
1160
1169
  updateItem: () => {},
@@ -1168,29 +1177,29 @@ function gt() {
1168
1177
  savePreset: () => null
1169
1178
  };
1170
1179
  }
1171
- var _t = J, vt = (e) => d("generators")?.loopById(e) ?? null, yt = {
1180
+ var gt = Y, _t = (e) => s("generators")?.loopById(e) ?? null, vt = {
1172
1181
  bg: "Background",
1173
1182
  fg: "Ink",
1174
1183
  accent: "Accent",
1175
1184
  dim: "Dim",
1176
1185
  warm: "Warm"
1177
- }, bt = {
1186
+ }, yt = {
1178
1187
  0: "fg",
1179
1188
  1: "warm",
1180
1189
  3: "dim",
1181
1190
  4: "accent",
1182
1191
  5: "bg"
1183
- }, Q = (e) => e.slice(0, 7).toLowerCase();
1192
+ }, bt = (e) => e.slice(0, 7).toLowerCase();
1184
1193
  function xt() {
1185
- let e = i(), { layers: t, selectedId: n, updateLayer: a, setColorAt: o } = r(), { library: s, addItem: c } = gt(), [d, ie] = M("analogous"), [v, b] = M(h), [x, S] = M(() => ee(.62, .14, Math.random() * 360)), [C, w] = M(() => re(f(v), {
1194
+ let e = l(), { layers: t, selectedId: n, updateLayer: r, setColorAt: i } = c(), { library: a, addItem: o } = ht(), [s, ie] = M("analogous"), [v, b] = M(m), [x, S] = M(() => ee(.62, .14, Math.random() * 360)), [C, w] = M(() => re(d(v), {
1186
1195
  base: x,
1187
- relation: d,
1196
+ relation: s,
1188
1197
  count: 5
1189
1198
  }).map((e) => ({
1190
1199
  hex: e,
1191
1200
  locked: !1
1192
- }))), [T, E] = M(null), D = ce(() => p(s), [s]), k = ({ b: e = x, rel: t = d, n = C.length, s: r = v } = {}) => {
1193
- let i = re(f(r), {
1201
+ }))), [T, E] = M(null), D = ce(() => te(a), [a]), k = ({ b: e = x, rel: t = s, n = C.length, s: r = v } = {}) => {
1202
+ let i = re(d(r), {
1194
1203
  base: e,
1195
1204
  relation: t,
1196
1205
  count: n
@@ -1200,10 +1209,10 @@ function xt() {
1200
1209
  locked: !1
1201
1210
  })), E(null);
1202
1211
  }, oe = () => {
1203
- let e = h();
1212
+ let e = m();
1204
1213
  b(e), k({ s: e });
1205
1214
  }, A = (e) => {
1206
- let t = Q(e);
1215
+ let t = bt(e);
1207
1216
  S(t), k({ b: t });
1208
1217
  }, se = (e) => {
1209
1218
  ie(e), k({ rel: e });
@@ -1213,7 +1222,7 @@ function xt() {
1213
1222
  }, le = (e, t) => {
1214
1223
  w((n) => n.map((n, r) => r === e ? {
1215
1224
  ...n,
1216
- hex: Q(t)
1225
+ hex: bt(t)
1217
1226
  } : n)), E(null);
1218
1227
  }, N = (e) => w((t) => t.map((t, n) => n === e ? {
1219
1228
  ...t,
@@ -1225,22 +1234,22 @@ function xt() {
1225
1234
  if (!t) return;
1226
1235
  let n = t.colors.slice(0, 8);
1227
1236
  w((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
1228
- hex: Q(e),
1237
+ hex: bt(e),
1229
1238
  locked: !1
1230
1239
  }))), E({
1231
1240
  name: t.name,
1232
1241
  roles: t.colors.length <= 8 ? t.roles : null
1233
1242
  });
1234
- }, I = C.map((e) => e.hex), L = T?.roles ?? u(I), pe = m.find((e) => e.id === d)?.label ?? "Palette", me = {
1243
+ }, I = C.map((e) => e.hex), L = T?.roles ?? u(I), pe = p.find((e) => e.id === s)?.label ?? "Palette", R = {
1235
1244
  name: T?.name ?? pe,
1236
- relation: d,
1245
+ relation: s,
1237
1246
  colors: I,
1238
1247
  roles: L
1239
- }, he = (e) => te.filter((t) => L[t]?.toLowerCase() === e).map((e) => yt[e]).join(", "), R = n && n !== "canvas" ? l(t, n) : null, z = R?.type === "loop" ? vt(R.loopId)?.params : null, ge = () => {
1240
- if (!R || !z) return;
1241
- let e = ne(R, z, me, { rotate: !0 }), t = Object.fromEntries(z.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
1242
- a(R.id, t);
1243
- }, _e = () => Object.entries(bt).forEach(([e, t]) => o(Number(e), L[t]));
1248
+ }, me = (e) => f.filter((t) => L[t]?.toLowerCase() === e).map((e) => vt[e]).join(", "), z = n && n !== "canvas" ? ne(t, n) : null, B = z?.type === "loop" ? _t(z.loopId)?.params : null, he = () => {
1249
+ if (!z || !B) return;
1250
+ let e = g(z, B, R, { rotate: !0 }), t = Object.fromEntries(B.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
1251
+ r(z.id, t);
1252
+ }, ge = () => Object.entries(yt).forEach(([e, t]) => i(Number(e), L[t]));
1244
1253
  return /* @__PURE__ */ F("div", {
1245
1254
  className: "p-4 flex flex-col gap-4",
1246
1255
  children: [
@@ -1282,11 +1291,11 @@ function xt() {
1282
1291
  className: "flex-1 min-w-0",
1283
1292
  size: e,
1284
1293
  "aria-label": "Relationship",
1285
- options: m.map((e) => ({
1294
+ options: p.map((e) => ({
1286
1295
  value: e.id,
1287
1296
  label: e.label
1288
1297
  })),
1289
- value: d,
1298
+ value: s,
1290
1299
  onChange: se
1291
1300
  }), /* @__PURE__ */ P(_, {
1292
1301
  tone: "grey",
@@ -1308,7 +1317,7 @@ function xt() {
1308
1317
  }),
1309
1318
  /* @__PURE__ */ P("span", {
1310
1319
  className: "kol-helper-10 uppercase text-meta flex-1 truncate",
1311
- children: he(e.hex)
1320
+ children: me(e.hex)
1312
1321
  }),
1313
1322
  /* @__PURE__ */ P("span", {
1314
1323
  className: "kol-mono-10 text-meta",
@@ -1339,7 +1348,7 @@ function xt() {
1339
1348
  ]
1340
1349
  }, t))
1341
1350
  }),
1342
- g(L.bg, L.fg) < 4.5 && /* @__PURE__ */ F("span", {
1351
+ h(L.bg, L.fg) < 4.5 && /* @__PURE__ */ F("span", {
1343
1352
  className: "kol-helper-10 text-meta inline-flex items-center gap-1",
1344
1353
  children: [/* @__PURE__ */ P(de, {
1345
1354
  name: "info",
@@ -1362,25 +1371,25 @@ function xt() {
1362
1371
  /* @__PURE__ */ P(_, {
1363
1372
  tone: "grey",
1364
1373
  size: e,
1365
- onClick: () => c("palette", {
1366
- name: me.name,
1374
+ onClick: () => o("palette", {
1375
+ name: R.name,
1367
1376
  colors: I
1368
1377
  }),
1369
1378
  children: "Save"
1370
1379
  }),
1371
1380
  /* @__PURE__ */ F("div", {
1372
1381
  className: "flex gap-2",
1373
- children: [z && /* @__PURE__ */ P(_, {
1382
+ children: [B && /* @__PURE__ */ P(_, {
1374
1383
  tone: "grey",
1375
1384
  size: e,
1376
1385
  className: "flex-1",
1377
- onClick: ge,
1386
+ onClick: he,
1378
1387
  children: "Apply to layer"
1379
1388
  }), /* @__PURE__ */ P(_, {
1380
1389
  tone: "grey",
1381
1390
  size: e,
1382
1391
  className: "flex-1",
1383
- onClick: _e,
1392
+ onClick: ge,
1384
1393
  children: "Apply to document"
1385
1394
  })]
1386
1395
  })
@@ -1424,7 +1433,10 @@ function wt() {
1424
1433
  //#endregion
1425
1434
  //#region src/editor/generate/store.js
1426
1435
  var $ = {}, Tt = /* @__PURE__ */ new Set(), Et = () => Tt.forEach((e) => e());
1427
- function Dt(e, t) {
1436
+ function Dt(e) {
1437
+ return $[e];
1438
+ }
1439
+ function Ot(e, t) {
1428
1440
  $[e] = {
1429
1441
  live: !0,
1430
1442
  layerId: null,
@@ -1432,7 +1444,7 @@ function Dt(e, t) {
1432
1444
  ...typeof t == "function" ? t($[e]) : t
1433
1445
  }, Et();
1434
1446
  }
1435
- function Ot(e, t) {
1447
+ function kt(e, t) {
1436
1448
  return $[e]?.params || ($[e] = {
1437
1449
  live: !0,
1438
1450
  layerId: null,
@@ -1440,24 +1452,32 @@ function Ot(e, t) {
1440
1452
  params: t()
1441
1453
  }), N((e) => (Tt.add(e), () => Tt.delete(e)), () => $[e]);
1442
1454
  }
1443
- var kt = (e, t = "rail") => Nt(t === "dialog" ? { dialog: e } : { rail: e });
1444
- function At(e, t, n = "rail") {
1455
+ var At = (e, t = "rail") => Ft(t === "dialog" ? { dialog: e } : { rail: e });
1456
+ function jt(e, t, n = "rail") {
1445
1457
  let { id: r, type: i, children: a, ...o } = t;
1446
- Dt(e, {
1458
+ Ot(e, {
1447
1459
  params: o,
1448
- layerId: r
1449
- }), kt(e, n);
1460
+ layerId: r,
1461
+ contentKey: null
1462
+ }), At(e, n);
1463
+ }
1464
+ function Mt(e, t, n, r = "rail") {
1465
+ Ot(e, {
1466
+ params: n.params,
1467
+ layerId: t.id,
1468
+ contentKey: n.key
1469
+ }), At(e, r);
1450
1470
  }
1451
- var jt = {
1471
+ var Nt = {
1452
1472
  rail: null,
1453
1473
  dialog: null
1454
- }, Mt = /* @__PURE__ */ new Set();
1455
- function Nt(e) {
1456
- jt = {
1457
- ...jt,
1474
+ }, Pt = /* @__PURE__ */ new Set();
1475
+ function Ft(e) {
1476
+ Nt = {
1477
+ ...Nt,
1458
1478
  ...e
1459
- }, Mt.forEach((e) => e());
1479
+ }, Pt.forEach((e) => e());
1460
1480
  }
1461
- var Pt = () => N((e) => (Mt.add(e), () => Mt.delete(e)), () => jt);
1481
+ var It = () => N((e) => (Pt.add(e), () => Pt.delete(e)), () => Nt);
1462
1482
  //#endregion
1463
- export { He as A, Ge as C, Be as D, Oe as E, Se as F, he as I, Pe as M, we as N, q as O, be as P, Ke as S, We as T, ut as _, Ot as a, ke as b, Ct as c, mt as d, pt as f, lt as g, dt as h, Nt as i, Fe as j, Ve as k, ht as l, Z as m, kt as n, Pt as o, ct as p, Dt as r, wt as s, At as t, _t as u, gt as v, Ue as w, Ne as x, H as y };
1483
+ export { J as A, me as B, Me as C, Ue as D, He as E, B as F, Ce as I, z as L, Ve as M, Pe as N, De as O, Ne as P, ye as R, Oe as S, We as T, ut as _, Ot as a, ht as b, It as c, mt as d, gt as f, Q as g, st as h, At as i, Be as j, ze as k, wt as l, ft as m, jt as n, Ft as o, pt as p, Dt as r, kt as s, Mt as t, Ct as u, ct as v, Ge as w, U as x, lt as y, xe as z };