@kolkrabbi/design-editor 0.24.0 → 0.27.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.
- package/README.md +2 -2
- package/dist/BindDot-CMUtpJPX.js +84 -0
- package/dist/BufferGeometryUtils-Cc8LNd5v.js +150 -0
- package/dist/ColorModesWindow-CWhL6nfm.js +1493 -0
- package/dist/GLTFLoader-BFir8PCc.js +1361 -0
- package/dist/OBJLoader-BgqC_-Jn.js +287 -0
- package/dist/{OrbitControls-Cql8Rn2i.js → OrbitControls-DVpLgmKv.js} +2755 -2202
- package/dist/STLLoader-C6DGLf6r.js +83 -0
- package/dist/Timeline-BObvcdXF.js +3014 -0
- package/dist/TreePicker-nMf17QGH.js +68 -0
- package/dist/core-EWu8GfXL.js +17504 -0
- package/dist/core.js +5 -3
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +2114 -916
- package/dist/effects-DZEmfY7a.js +444 -0
- package/dist/effects.js +1 -1
- package/dist/generators-D1tFSZgG.js +2961 -0
- package/dist/generators.js +1 -1
- package/dist/{host-qtFVROOD.js → host-CRsCCafL.js} +429 -370
- package/dist/{host-be1CWhN1.js → host-ZLJKCZ54.js} +137 -136
- package/dist/motion-C_u7tsis.js +2295 -0
- package/dist/motion.js +1 -1
- package/dist/previewScale-BMkeLc6w.js +26 -0
- package/dist/{rolls-Bg1XHuvJ.js → rolls-BGtqxVYq.js} +2621 -1522
- package/dist/{src-B5fQgAVE.js → src-BpTckTDZ.js} +1 -1
- package/dist/{useLayerEdit-ieOjHx6x.js → useLayerEdit-BFcZhiNX.js} +20992 -12580
- package/package.json +9 -7
- package/dist/RuleRow-DIbuUt37.js +0 -650
- package/dist/TreePicker-DLmMl0aU.js +0 -68
- package/dist/core-CNI8b_83.js +0 -12314
- package/dist/effectCategories-0PnGZvjd.js +0 -4210
- package/dist/effects-BujxwoNY.js +0 -469
- package/dist/generators-SpRHQDMq.js +0 -2517
- package/dist/labels-B5qkocWy.js +0 -2007
- package/dist/motion-Bn3FVkCS.js +0 -2260
|
@@ -0,0 +1,1493 @@
|
|
|
1
|
+
import { D as e, Et as t, J as n, L as r, _ as i, an as a, b as o, dn as s, en as c, f as l, g as u, h as ee, ln as d, m as f, p, sn as m, un as te, v as h, x as g, y as ne } from "./rolls-BGtqxVYq.js";
|
|
2
|
+
import { w as re } from "./useLayerEdit-BFcZhiNX.js";
|
|
3
|
+
import { Button as _, CloseButton as v, ColorPickerPopover as y, Dropdown as b, FullscreenOverlay as x, FunctionPlot as S, Input as C, LabeledControl as w, MenuDropdownItem as ie, Section as T, SegmentedToggle as E, Slider as D, Stepper as ae, Tooltip as O } from "@kolkrabbi/kol-component";
|
|
4
|
+
import { createContext as k, useCallback as A, useContext as oe, useEffect as j, useMemo as se, useRef as ce, useState as M, useSyncExternalStore as le } from "react";
|
|
5
|
+
import { Fragment as ue, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
6
|
+
import { Icon as de } from "@kolkrabbi/kol-icons";
|
|
7
|
+
//#region src/loops/taxonomy.js
|
|
8
|
+
var fe = [
|
|
9
|
+
{
|
|
10
|
+
label: "Scanline",
|
|
11
|
+
groups: ["scanline"]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: "Pattern",
|
|
15
|
+
groups: [
|
|
16
|
+
"pattern",
|
|
17
|
+
"patternloop",
|
|
18
|
+
"field"
|
|
19
|
+
],
|
|
20
|
+
labels: { pattern: "Rules" }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Loops",
|
|
24
|
+
groups: ["shape"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Math",
|
|
28
|
+
groups: ["math"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Penrose",
|
|
32
|
+
groups: ["penrose"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: "Flow",
|
|
36
|
+
groups: ["flow"]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Letter Gap",
|
|
40
|
+
groups: ["lettergap"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "Drift",
|
|
44
|
+
groups: ["drift"]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "Gradients",
|
|
48
|
+
groups: ["gradients"]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "Soft Forms",
|
|
52
|
+
groups: ["softforms"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "3D Scene",
|
|
56
|
+
groups: [
|
|
57
|
+
"scene",
|
|
58
|
+
"ribbon",
|
|
59
|
+
"forms",
|
|
60
|
+
"environment",
|
|
61
|
+
"abstract",
|
|
62
|
+
"softforms3d"
|
|
63
|
+
],
|
|
64
|
+
labels: {
|
|
65
|
+
scene: "Primitive",
|
|
66
|
+
softforms3d: "Soft forms"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
], pe = [{
|
|
70
|
+
label: "Para Type",
|
|
71
|
+
groups: ["paratype"]
|
|
72
|
+
}], me = fe, F = {
|
|
73
|
+
optic: "Pattern · Effects",
|
|
74
|
+
paratype: "Para Type · Misc",
|
|
75
|
+
distress: "Distressor · Vector",
|
|
76
|
+
modulator: "Modulator · Vector"
|
|
77
|
+
}, I = [
|
|
78
|
+
{
|
|
79
|
+
code: "wave(t*2)",
|
|
80
|
+
desc: "Fast sine"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
code: "saw(t)*0.8",
|
|
84
|
+
desc: "Ramp to 80"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
code: "tri(t*0.5)",
|
|
88
|
+
desc: "Slow bounce"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
code: "pulse(t, 0.3)",
|
|
92
|
+
desc: "PWM 30%"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: "ease(t*2, 4)",
|
|
96
|
+
desc: "Fast + punchy"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
code: "bell(t)",
|
|
100
|
+
desc: "Bell curve"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
code: "step(t, 4)",
|
|
104
|
+
desc: "4 steps"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
code: "rand()",
|
|
108
|
+
desc: "Noise"
|
|
109
|
+
}
|
|
110
|
+
], he = 196, L = 64;
|
|
111
|
+
function ge({ expr: e }) {
|
|
112
|
+
let [t, n] = M(0);
|
|
113
|
+
j(() => {
|
|
114
|
+
let e = 0, t = () => {
|
|
115
|
+
n(c.getCtx().t ?? 0), e = requestAnimationFrame(t);
|
|
116
|
+
};
|
|
117
|
+
return e = requestAnimationFrame(t), () => cancelAnimationFrame(e);
|
|
118
|
+
}, []);
|
|
119
|
+
let r = m(e), i = c.getLoopSeconds(), a = he, o = Array.from({ length: 197 }, (e, t) => r.ok ? r.fn(t / a * i) : 0);
|
|
120
|
+
return /* @__PURE__ */ N(S, {
|
|
121
|
+
samples: o,
|
|
122
|
+
min: Math.min(0, ...o),
|
|
123
|
+
max: Math.max(1, ...o),
|
|
124
|
+
cursor: t,
|
|
125
|
+
height: L,
|
|
126
|
+
ariaLabel: "Expression plot over one loop"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function R({ layer: t, param: n, setProp: i }) {
|
|
130
|
+
let o = r(), c = t[n.key], [l, u] = M(null), [ee, f] = M(!1), [p, m] = M(!1);
|
|
131
|
+
if (!e(c) || c.bind !== "mod") return null;
|
|
132
|
+
let h = c.source, g = c.transform ?? {}, ne = h.startsWith("lfo-"), re = h === "midi", v = d(h), y = h === "expr", b = g.expr ?? "wave(t)", x = (e) => i(n.key, {
|
|
133
|
+
...c,
|
|
134
|
+
transform: {
|
|
135
|
+
...g,
|
|
136
|
+
...e
|
|
137
|
+
}
|
|
138
|
+
}), S = (e) => {
|
|
139
|
+
u(null);
|
|
140
|
+
let t = String(e).trim();
|
|
141
|
+
t && t !== b && x({ expr: t });
|
|
142
|
+
}, T = async () => {
|
|
143
|
+
f(!0);
|
|
144
|
+
let e = await s();
|
|
145
|
+
f(!1), e != null && x({ cc: e });
|
|
146
|
+
}, ae = async () => {
|
|
147
|
+
m(!0);
|
|
148
|
+
let e = await te();
|
|
149
|
+
m(!1), e && i(n.key, {
|
|
150
|
+
...c,
|
|
151
|
+
source: e
|
|
152
|
+
});
|
|
153
|
+
}, O = g.range ?? (n.min != null && n.max != null ? [n.min, n.max] : [0, 1]), k = (e, t) => {
|
|
154
|
+
let n = Number(e);
|
|
155
|
+
return Number.isFinite(n) ? n : t;
|
|
156
|
+
};
|
|
157
|
+
return /* @__PURE__ */ P("div", {
|
|
158
|
+
className: "flex flex-col gap-3",
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ N(w, {
|
|
161
|
+
label: "Range",
|
|
162
|
+
children: /* @__PURE__ */ P("div", {
|
|
163
|
+
className: "flex items-center gap-2 min-w-0",
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ N("div", {
|
|
166
|
+
className: "flex-1 min-w-0",
|
|
167
|
+
children: /* @__PURE__ */ N(C, {
|
|
168
|
+
variant: "filled",
|
|
169
|
+
size: o,
|
|
170
|
+
type: "number",
|
|
171
|
+
width: "100%",
|
|
172
|
+
value: O[0],
|
|
173
|
+
onChange: (e) => x({ range: [k(e.target.value, O[0]), O[1]] })
|
|
174
|
+
})
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ N("span", {
|
|
177
|
+
className: "kol-helper-10 text-meta shrink-0",
|
|
178
|
+
children: "to"
|
|
179
|
+
}),
|
|
180
|
+
/* @__PURE__ */ N("div", {
|
|
181
|
+
className: "flex-1 min-w-0",
|
|
182
|
+
children: /* @__PURE__ */ N(C, {
|
|
183
|
+
variant: "filled",
|
|
184
|
+
size: o,
|
|
185
|
+
type: "number",
|
|
186
|
+
width: "100%",
|
|
187
|
+
value: O[1],
|
|
188
|
+
onChange: (e) => x({ range: [O[0], k(e.target.value, O[1])] })
|
|
189
|
+
})
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
})
|
|
193
|
+
}),
|
|
194
|
+
/* @__PURE__ */ P("div", {
|
|
195
|
+
className: "grid grid-cols-2 gap-2",
|
|
196
|
+
children: [/* @__PURE__ */ N(w, {
|
|
197
|
+
label: "Invert",
|
|
198
|
+
children: /* @__PURE__ */ N(E, {
|
|
199
|
+
size: o,
|
|
200
|
+
className: "w-full",
|
|
201
|
+
options: [{
|
|
202
|
+
value: "off",
|
|
203
|
+
label: "Off"
|
|
204
|
+
}, {
|
|
205
|
+
value: "on",
|
|
206
|
+
label: "On"
|
|
207
|
+
}],
|
|
208
|
+
value: g?.invert ? "on" : "off",
|
|
209
|
+
onChange: (e) => x({ invert: e === "on" })
|
|
210
|
+
})
|
|
211
|
+
}), /* @__PURE__ */ N(w, {
|
|
212
|
+
label: "Smooth",
|
|
213
|
+
children: /* @__PURE__ */ N(D, {
|
|
214
|
+
min: 0,
|
|
215
|
+
max: .95,
|
|
216
|
+
step: .05,
|
|
217
|
+
value: g?.smooth ?? 0,
|
|
218
|
+
onChange: (e) => x({ smooth: e })
|
|
219
|
+
})
|
|
220
|
+
})]
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ N(w, {
|
|
223
|
+
label: "Curve",
|
|
224
|
+
children: /* @__PURE__ */ N(D, {
|
|
225
|
+
min: .25,
|
|
226
|
+
max: 4,
|
|
227
|
+
step: .05,
|
|
228
|
+
value: g?.curve ?? 1,
|
|
229
|
+
onChange: (e) => x({ curve: e })
|
|
230
|
+
})
|
|
231
|
+
}),
|
|
232
|
+
ne && /* @__PURE__ */ P("div", {
|
|
233
|
+
className: "grid grid-cols-2 gap-2",
|
|
234
|
+
children: [/* @__PURE__ */ N(w, {
|
|
235
|
+
label: "Rate",
|
|
236
|
+
children: /* @__PURE__ */ N(D, {
|
|
237
|
+
min: .25,
|
|
238
|
+
max: 16,
|
|
239
|
+
step: .25,
|
|
240
|
+
value: g?.rate ?? 1,
|
|
241
|
+
onChange: (e) => x({ rate: e })
|
|
242
|
+
})
|
|
243
|
+
}), /* @__PURE__ */ N(w, {
|
|
244
|
+
label: "Phase",
|
|
245
|
+
children: /* @__PURE__ */ N(D, {
|
|
246
|
+
min: 0,
|
|
247
|
+
max: 1,
|
|
248
|
+
step: .01,
|
|
249
|
+
value: g?.phase ?? 0,
|
|
250
|
+
onChange: (e) => x({ phase: e })
|
|
251
|
+
})
|
|
252
|
+
})]
|
|
253
|
+
}),
|
|
254
|
+
y && /* @__PURE__ */ P(ue, { children: [
|
|
255
|
+
/* @__PURE__ */ N(w, {
|
|
256
|
+
label: "Expression",
|
|
257
|
+
children: /* @__PURE__ */ N(C, {
|
|
258
|
+
variant: "ghost",
|
|
259
|
+
size: o,
|
|
260
|
+
value: l ?? b,
|
|
261
|
+
onChange: (e) => u(e.target.value),
|
|
262
|
+
onBlur: (e) => S(e.target.value),
|
|
263
|
+
onKeyDown: (e) => {
|
|
264
|
+
e.key === "Enter" && e.currentTarget.blur();
|
|
265
|
+
}
|
|
266
|
+
})
|
|
267
|
+
}),
|
|
268
|
+
/* @__PURE__ */ N(ge, { expr: b }),
|
|
269
|
+
/* @__PURE__ */ N("div", {
|
|
270
|
+
className: "flex flex-col",
|
|
271
|
+
children: I.map((e) => /* @__PURE__ */ N(ie, {
|
|
272
|
+
onClick: () => x({ expr: e.code }),
|
|
273
|
+
rowClass: "kol-mono-10 h-6",
|
|
274
|
+
shortcut: /* @__PURE__ */ N("span", {
|
|
275
|
+
className: "kol-helper-10 text-meta",
|
|
276
|
+
children: e.desc
|
|
277
|
+
}),
|
|
278
|
+
children: e.code
|
|
279
|
+
}, e.code))
|
|
280
|
+
})
|
|
281
|
+
] }),
|
|
282
|
+
re && /* @__PURE__ */ N(w, {
|
|
283
|
+
label: g?.cc == null ? "MIDI · no CC yet" : `MIDI · CC ${g.cc}`,
|
|
284
|
+
children: /* @__PURE__ */ N(_, {
|
|
285
|
+
tone: "outline",
|
|
286
|
+
size: o,
|
|
287
|
+
onClick: T,
|
|
288
|
+
children: ee ? "Move a knob…" : "Learn"
|
|
289
|
+
})
|
|
290
|
+
}),
|
|
291
|
+
v && /* @__PURE__ */ N(w, {
|
|
292
|
+
label: a(h)?.label ?? "Gamepad",
|
|
293
|
+
children: /* @__PURE__ */ N(_, {
|
|
294
|
+
tone: "outline",
|
|
295
|
+
size: o,
|
|
296
|
+
onClick: ae,
|
|
297
|
+
children: p ? "Move a control…" : "Learn"
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
function z({ layer: t, schema: n, setProp: r }) {
|
|
304
|
+
let i = (n ?? []).filter((n) => {
|
|
305
|
+
let r = t[n.key];
|
|
306
|
+
return e(r) && r.bind === "mod";
|
|
307
|
+
});
|
|
308
|
+
return i.length === 0 ? null : /* @__PURE__ */ P("div", {
|
|
309
|
+
className: "flex flex-col gap-4",
|
|
310
|
+
children: [/* @__PURE__ */ N("span", {
|
|
311
|
+
className: "kol-eyebrow text-fg-80",
|
|
312
|
+
children: "Modulation"
|
|
313
|
+
}), i.map((e) => {
|
|
314
|
+
let n = a(t[e.key].source);
|
|
315
|
+
return /* @__PURE__ */ P("div", {
|
|
316
|
+
className: "flex flex-col gap-2 pt-3 border-t border-oq-08",
|
|
317
|
+
children: [/* @__PURE__ */ P("div", {
|
|
318
|
+
className: "flex items-center justify-between",
|
|
319
|
+
children: [/* @__PURE__ */ N("span", {
|
|
320
|
+
className: "kol-helper-12 text-emphasis",
|
|
321
|
+
children: e.label ?? e.key
|
|
322
|
+
}), /* @__PURE__ */ N("span", {
|
|
323
|
+
className: "kol-helper-10 text-meta",
|
|
324
|
+
children: n?.label ?? t[e.key].source
|
|
325
|
+
})]
|
|
326
|
+
}), /* @__PURE__ */ N(R, {
|
|
327
|
+
layer: t,
|
|
328
|
+
param: e,
|
|
329
|
+
setProp: r
|
|
330
|
+
})]
|
|
331
|
+
}, e.key);
|
|
332
|
+
})]
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/editor/modes/pattern/RuleRow.jsx
|
|
337
|
+
var _e = [
|
|
338
|
+
{
|
|
339
|
+
value: "all",
|
|
340
|
+
label: "All cells"
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
value: "every-col",
|
|
344
|
+
label: "Every Nth col"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
value: "every-row",
|
|
348
|
+
label: "Every Nth row"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
value: "both",
|
|
352
|
+
label: "Nth col × Nth row"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
value: "every-nth",
|
|
356
|
+
label: "Every Nth (flat)"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
value: "checker",
|
|
360
|
+
label: "Checker"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
value: "expression",
|
|
364
|
+
label: "Expression…"
|
|
365
|
+
}
|
|
366
|
+
], ve = [
|
|
367
|
+
{
|
|
368
|
+
value: 0,
|
|
369
|
+
label: "0°"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
value: 90,
|
|
373
|
+
label: "90°"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
value: 180,
|
|
377
|
+
label: "180°"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
value: 270,
|
|
381
|
+
label: "270°"
|
|
382
|
+
}
|
|
383
|
+
], ye = [
|
|
384
|
+
"every-col",
|
|
385
|
+
"every-row",
|
|
386
|
+
"both",
|
|
387
|
+
"every-nth",
|
|
388
|
+
"checker"
|
|
389
|
+
], be = [
|
|
390
|
+
0,
|
|
391
|
+
90,
|
|
392
|
+
180,
|
|
393
|
+
270
|
|
394
|
+
], xe = 1, Se = () => `r${xe++}`, Ce = () => ({
|
|
395
|
+
id: Se(),
|
|
396
|
+
selectKind: "every-col",
|
|
397
|
+
n: 2,
|
|
398
|
+
offset: 0,
|
|
399
|
+
n2: 2,
|
|
400
|
+
offset2: 0,
|
|
401
|
+
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
402
|
+
groupW: 1,
|
|
403
|
+
groupH: 1,
|
|
404
|
+
rotate: 90,
|
|
405
|
+
flipH: !1,
|
|
406
|
+
flipV: !1,
|
|
407
|
+
hide: !1,
|
|
408
|
+
opacity: 1
|
|
409
|
+
}), we = (e) => e[Math.floor(Math.random() * e.length)], Te = () => ({
|
|
410
|
+
id: Se(),
|
|
411
|
+
selectKind: we(ye),
|
|
412
|
+
n: Math.floor(Math.random() * 5) + 2,
|
|
413
|
+
offset: Math.floor(Math.random() * 3),
|
|
414
|
+
n2: Math.floor(Math.random() * 5) + 2,
|
|
415
|
+
offset2: Math.floor(Math.random() * 3),
|
|
416
|
+
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
417
|
+
groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
418
|
+
groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
419
|
+
rotate: we(be),
|
|
420
|
+
flipH: Math.random() > .6,
|
|
421
|
+
flipV: Math.random() > .6,
|
|
422
|
+
hide: Math.random() > .85,
|
|
423
|
+
opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
|
|
424
|
+
});
|
|
425
|
+
function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
426
|
+
return /* @__PURE__ */ N(ae, {
|
|
427
|
+
size: "sm",
|
|
428
|
+
value: e,
|
|
429
|
+
min: n,
|
|
430
|
+
max: r,
|
|
431
|
+
onChange: (e) => t(Number(e.target.value)),
|
|
432
|
+
className: "w-full"
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
function Ee({ active: e, onClick: t, children: n, title: r }) {
|
|
436
|
+
return /* @__PURE__ */ N(O, {
|
|
437
|
+
label: r,
|
|
438
|
+
children: /* @__PURE__ */ N(_, {
|
|
439
|
+
"aria-label": r,
|
|
440
|
+
tone: e ? "primary" : "outline",
|
|
441
|
+
size: "sm",
|
|
442
|
+
onClick: t,
|
|
443
|
+
"aria-pressed": e,
|
|
444
|
+
children: n
|
|
445
|
+
})
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function De({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
449
|
+
let i = (n) => t({
|
|
450
|
+
...e,
|
|
451
|
+
...n
|
|
452
|
+
}), a = e.selectKind === "every-col" || e.selectKind === "every-row" || e.selectKind === "every-nth" || e.selectKind === "both", o = e.selectKind === "both", s = e.selectKind === "expression";
|
|
453
|
+
return /* @__PURE__ */ P("div", {
|
|
454
|
+
className: "flex flex-col gap-2 p-2 border border-oq-08 rounded",
|
|
455
|
+
children: [
|
|
456
|
+
/* @__PURE__ */ P("div", {
|
|
457
|
+
className: "flex items-center gap-2",
|
|
458
|
+
children: [
|
|
459
|
+
/* @__PURE__ */ N("div", {
|
|
460
|
+
className: "flex-1 min-w-0",
|
|
461
|
+
children: /* @__PURE__ */ N(b, {
|
|
462
|
+
variant: "subtle",
|
|
463
|
+
size: "sm",
|
|
464
|
+
className: "w-full",
|
|
465
|
+
options: _e,
|
|
466
|
+
value: e.selectKind,
|
|
467
|
+
onChange: (e) => i({ selectKind: e })
|
|
468
|
+
})
|
|
469
|
+
}),
|
|
470
|
+
/* @__PURE__ */ N(O, {
|
|
471
|
+
label: "Re-randomize this rule",
|
|
472
|
+
children: /* @__PURE__ */ N(_, {
|
|
473
|
+
tone: "ghost",
|
|
474
|
+
size: "sm",
|
|
475
|
+
iconOnly: "refresh",
|
|
476
|
+
iconSize: 12,
|
|
477
|
+
onClick: r,
|
|
478
|
+
"aria-label": "Re-randomize rule",
|
|
479
|
+
className: "shrink-0",
|
|
480
|
+
style: { padding: 6 }
|
|
481
|
+
})
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ N(O, {
|
|
484
|
+
label: "Delete rule",
|
|
485
|
+
children: /* @__PURE__ */ N(_, {
|
|
486
|
+
tone: "ghost",
|
|
487
|
+
size: "sm",
|
|
488
|
+
iconOnly: "x",
|
|
489
|
+
iconSize: 12,
|
|
490
|
+
onClick: n,
|
|
491
|
+
"aria-label": "Delete rule",
|
|
492
|
+
className: "shrink-0",
|
|
493
|
+
style: { padding: 6 }
|
|
494
|
+
})
|
|
495
|
+
})
|
|
496
|
+
]
|
|
497
|
+
}),
|
|
498
|
+
a && /* @__PURE__ */ P("div", {
|
|
499
|
+
className: "grid grid-cols-2 gap-2",
|
|
500
|
+
children: [/* @__PURE__ */ N(T, {
|
|
501
|
+
label: "N",
|
|
502
|
+
children: /* @__PURE__ */ N(B, {
|
|
503
|
+
value: e.n,
|
|
504
|
+
onChange: (e) => i({ n: e }),
|
|
505
|
+
min: 1
|
|
506
|
+
})
|
|
507
|
+
}), /* @__PURE__ */ N(T, {
|
|
508
|
+
label: "Offset",
|
|
509
|
+
children: /* @__PURE__ */ N(B, {
|
|
510
|
+
value: e.offset,
|
|
511
|
+
onChange: (e) => i({ offset: e })
|
|
512
|
+
})
|
|
513
|
+
})]
|
|
514
|
+
}),
|
|
515
|
+
o && /* @__PURE__ */ P("div", {
|
|
516
|
+
className: "grid grid-cols-2 gap-2",
|
|
517
|
+
children: [/* @__PURE__ */ N(T, {
|
|
518
|
+
label: "Row N",
|
|
519
|
+
children: /* @__PURE__ */ N(B, {
|
|
520
|
+
value: e.n2,
|
|
521
|
+
onChange: (e) => i({ n2: e }),
|
|
522
|
+
min: 1
|
|
523
|
+
})
|
|
524
|
+
}), /* @__PURE__ */ N(T, {
|
|
525
|
+
label: "Row offset",
|
|
526
|
+
children: /* @__PURE__ */ N(B, {
|
|
527
|
+
value: e.offset2,
|
|
528
|
+
onChange: (e) => i({ offset2: e })
|
|
529
|
+
})
|
|
530
|
+
})]
|
|
531
|
+
}),
|
|
532
|
+
s && /* @__PURE__ */ P(T, {
|
|
533
|
+
label: "Expression",
|
|
534
|
+
hint: "matches when > 0",
|
|
535
|
+
children: [/* @__PURE__ */ N(C, {
|
|
536
|
+
variant: "filled",
|
|
537
|
+
size: "sm",
|
|
538
|
+
value: e.expression,
|
|
539
|
+
onChange: (e) => i({ expression: e.target.value }),
|
|
540
|
+
placeholder: "sin(col * 0.6) + cos(row * 0.6)"
|
|
541
|
+
}), /* @__PURE__ */ N("span", {
|
|
542
|
+
className: "kol-mono-10 text-subtle mt-1",
|
|
543
|
+
children: "vars: i, col, row, cols, rows · Math.* in scope"
|
|
544
|
+
})]
|
|
545
|
+
}),
|
|
546
|
+
/* @__PURE__ */ P("div", {
|
|
547
|
+
className: "grid grid-cols-2 gap-2",
|
|
548
|
+
children: [/* @__PURE__ */ N(T, {
|
|
549
|
+
label: "Group W",
|
|
550
|
+
children: /* @__PURE__ */ N(B, {
|
|
551
|
+
value: e.groupW,
|
|
552
|
+
onChange: (e) => i({ groupW: Math.max(1, e) }),
|
|
553
|
+
min: 1
|
|
554
|
+
})
|
|
555
|
+
}), /* @__PURE__ */ N(T, {
|
|
556
|
+
label: "Group H",
|
|
557
|
+
children: /* @__PURE__ */ N(B, {
|
|
558
|
+
value: e.groupH,
|
|
559
|
+
onChange: (e) => i({ groupH: Math.max(1, e) }),
|
|
560
|
+
min: 1
|
|
561
|
+
})
|
|
562
|
+
})]
|
|
563
|
+
}),
|
|
564
|
+
/* @__PURE__ */ P("div", {
|
|
565
|
+
className: "flex flex-wrap gap-1",
|
|
566
|
+
children: [
|
|
567
|
+
/* @__PURE__ */ N(b, {
|
|
568
|
+
variant: "subtle",
|
|
569
|
+
size: "sm",
|
|
570
|
+
options: ve,
|
|
571
|
+
value: e.rotate,
|
|
572
|
+
onChange: (e) => i({ rotate: Number(e) })
|
|
573
|
+
}),
|
|
574
|
+
/* @__PURE__ */ N(Ee, {
|
|
575
|
+
active: e.flipH,
|
|
576
|
+
onClick: () => i({ flipH: !e.flipH }),
|
|
577
|
+
title: "Flip horizontal",
|
|
578
|
+
children: "⇋"
|
|
579
|
+
}),
|
|
580
|
+
/* @__PURE__ */ N(Ee, {
|
|
581
|
+
active: e.flipV,
|
|
582
|
+
onClick: () => i({ flipV: !e.flipV }),
|
|
583
|
+
title: "Flip vertical",
|
|
584
|
+
children: "⇵"
|
|
585
|
+
}),
|
|
586
|
+
/* @__PURE__ */ N(Ee, {
|
|
587
|
+
active: e.hide,
|
|
588
|
+
onClick: () => i({ hide: !e.hide }),
|
|
589
|
+
title: "Hide cell",
|
|
590
|
+
children: "hide"
|
|
591
|
+
})
|
|
592
|
+
]
|
|
593
|
+
}),
|
|
594
|
+
/* @__PURE__ */ N(T, {
|
|
595
|
+
label: "Opacity",
|
|
596
|
+
hint: `${Math.round(e.opacity * 100)}%`,
|
|
597
|
+
children: /* @__PURE__ */ N(D, {
|
|
598
|
+
min: 0,
|
|
599
|
+
max: 100,
|
|
600
|
+
value: Math.round(e.opacity * 100),
|
|
601
|
+
onChange: (e) => i({ opacity: e / 100 })
|
|
602
|
+
})
|
|
603
|
+
})
|
|
604
|
+
]
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region src/editor/library/mergeRemote.js
|
|
609
|
+
var Oe = (e) => e?.updatedAt ?? e?.savedAt ?? 0, ke = (e) => /^(Plan08 |Sync [A-Z] \d{13}|Morph [A-Z] \d{13})/.test(e?.name ?? "");
|
|
610
|
+
function Ae(e, t) {
|
|
611
|
+
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
612
|
+
for (let e of t || []) i.has(e.kind) || i.set(e.kind, /* @__PURE__ */ new Map()), i.get(e.kind).set(e.id, e);
|
|
613
|
+
let a = new Set([...Object.keys(e || {}), ...i.keys()]);
|
|
614
|
+
for (let t of a) {
|
|
615
|
+
let a = i.get(t) ?? /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set();
|
|
616
|
+
for (let n of e?.[t] ?? []) {
|
|
617
|
+
let e = a.get(n.id);
|
|
618
|
+
if (n?.shipped) {
|
|
619
|
+
o.push(n);
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
if (ke(n)) {
|
|
623
|
+
s.add(n.id), e && !e.deleted && r.push({
|
|
624
|
+
op: "remove",
|
|
625
|
+
kind: t,
|
|
626
|
+
id: n.id
|
|
627
|
+
});
|
|
628
|
+
continue;
|
|
629
|
+
}
|
|
630
|
+
if (!e) {
|
|
631
|
+
o.push(n), r.push({
|
|
632
|
+
op: "put",
|
|
633
|
+
kind: t,
|
|
634
|
+
item: n
|
|
635
|
+
});
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
if (e.deleted) {
|
|
639
|
+
if (e.updatedAt > Oe(n)) continue;
|
|
640
|
+
o.push(n), r.push({
|
|
641
|
+
op: "put",
|
|
642
|
+
kind: t,
|
|
643
|
+
item: n
|
|
644
|
+
});
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
e.updatedAt > Oe(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < Oe(n) && r.push({
|
|
648
|
+
op: "put",
|
|
649
|
+
kind: t,
|
|
650
|
+
item: n
|
|
651
|
+
}));
|
|
652
|
+
}
|
|
653
|
+
let c = new Set(o.map((e) => e.id));
|
|
654
|
+
for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
|
|
655
|
+
if (ke(e.spec)) {
|
|
656
|
+
r.push({
|
|
657
|
+
op: "remove",
|
|
658
|
+
kind: t,
|
|
659
|
+
id: e.id
|
|
660
|
+
});
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
o.push(e.spec);
|
|
664
|
+
}
|
|
665
|
+
n[t] = o;
|
|
666
|
+
}
|
|
667
|
+
return {
|
|
668
|
+
next: n,
|
|
669
|
+
pushes: r
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/editor/library/libraryApi.js
|
|
674
|
+
var V = null;
|
|
675
|
+
function je(e) {
|
|
676
|
+
V = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Be();
|
|
677
|
+
}
|
|
678
|
+
function Me() {
|
|
679
|
+
return V;
|
|
680
|
+
}
|
|
681
|
+
var H = class extends Error {
|
|
682
|
+
constructor() {
|
|
683
|
+
super("unauthorized"), this.name = "UnauthorizedError";
|
|
684
|
+
}
|
|
685
|
+
};
|
|
686
|
+
function Ne(e, t) {
|
|
687
|
+
let n = `Bearer ${t}`, r = async (t, r = {}) => {
|
|
688
|
+
let i = await fetch(`${e}${t}`, {
|
|
689
|
+
...r,
|
|
690
|
+
headers: {
|
|
691
|
+
authorization: n,
|
|
692
|
+
"content-type": "application/json",
|
|
693
|
+
...r.headers || {}
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
if (i.status === 401) throw new H();
|
|
697
|
+
if (!i.ok) throw Error(`library api ${i.status}`);
|
|
698
|
+
return i.json();
|
|
699
|
+
};
|
|
700
|
+
return {
|
|
701
|
+
async hydrate() {
|
|
702
|
+
let { documents: e } = await r("/api/documents");
|
|
703
|
+
return e;
|
|
704
|
+
},
|
|
705
|
+
async push(e) {
|
|
706
|
+
if (e.op === "remove") return r(`/api/documents/${encodeURIComponent(e.id)}`, { method: "DELETE" });
|
|
707
|
+
let t = e.item;
|
|
708
|
+
return r(`/api/documents/${encodeURIComponent(t.id)}`, {
|
|
709
|
+
method: "PUT",
|
|
710
|
+
body: JSON.stringify({
|
|
711
|
+
kind: e.kind,
|
|
712
|
+
name: t.name ?? null,
|
|
713
|
+
spec: t,
|
|
714
|
+
updatedAt: t.updatedAt ?? t.savedAt ?? Date.now()
|
|
715
|
+
})
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
var U = "kol.fxr.library-session", W = null, Pe = /* @__PURE__ */ new Set(), G = () => Pe.forEach((e) => e());
|
|
721
|
+
function Fe() {
|
|
722
|
+
return W;
|
|
723
|
+
}
|
|
724
|
+
var Ie = () => le((e) => (Pe.add(e), () => Pe.delete(e)), Fe, Fe), Le = () => Ie()?.user ?? null;
|
|
725
|
+
function K(e) {
|
|
726
|
+
try {
|
|
727
|
+
e ? localStorage.setItem(U, JSON.stringify(e)) : localStorage.removeItem(U);
|
|
728
|
+
} catch {}
|
|
729
|
+
}
|
|
730
|
+
var Re = () => {
|
|
731
|
+
try {
|
|
732
|
+
return JSON.parse(localStorage.getItem(U) || "null");
|
|
733
|
+
} catch {
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
function ze(e, t) {
|
|
738
|
+
let { next: n, pushes: r } = Ae(Q(), t);
|
|
739
|
+
dt({
|
|
740
|
+
...Q(),
|
|
741
|
+
...n
|
|
742
|
+
});
|
|
743
|
+
for (let t of r) e.push(t).catch(() => {});
|
|
744
|
+
}
|
|
745
|
+
async function q(e, t = {}, n) {
|
|
746
|
+
let r = await fetch(`${V}${e}`, {
|
|
747
|
+
...t,
|
|
748
|
+
headers: {
|
|
749
|
+
"content-type": "application/json",
|
|
750
|
+
...n ? { authorization: `Bearer ${n}` } : {},
|
|
751
|
+
...t.headers || {}
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
if (r.status === 401) throw new H();
|
|
755
|
+
let i = await r.json().catch(() => ({}));
|
|
756
|
+
if (!r.ok) throw Error(i.error || `library api ${r.status}`);
|
|
757
|
+
return i;
|
|
758
|
+
}
|
|
759
|
+
function Be() {
|
|
760
|
+
if (W || !V) return;
|
|
761
|
+
let e = Re();
|
|
762
|
+
if (!e?.token || e.base !== V || !(e.expiresAt > Date.now()) || !e.user) return;
|
|
763
|
+
let t = Ne(V, e.token);
|
|
764
|
+
W = {
|
|
765
|
+
backend: t,
|
|
766
|
+
user: e.user,
|
|
767
|
+
token: e.token
|
|
768
|
+
}, G(), q("/api/me", {}, e.token).then(({ user: t }) => {
|
|
769
|
+
W?.token === e.token && (W = {
|
|
770
|
+
...W,
|
|
771
|
+
user: t
|
|
772
|
+
}, K({
|
|
773
|
+
...e,
|
|
774
|
+
user: t
|
|
775
|
+
}), G());
|
|
776
|
+
}).catch((e) => {
|
|
777
|
+
e instanceof H && J();
|
|
778
|
+
}), t.hydrate().then((e) => ze(t, e)).catch((e) => {
|
|
779
|
+
e instanceof H ? J() : console.warn("library sync: hydrate failed —", e?.message || e);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
async function Ve({ token: e, expiresAt: t, user: n }) {
|
|
783
|
+
let r = Ne(V, e), i = await r.hydrate();
|
|
784
|
+
return ze(r, i), W = {
|
|
785
|
+
backend: r,
|
|
786
|
+
user: n,
|
|
787
|
+
token: e
|
|
788
|
+
}, K({
|
|
789
|
+
base: V,
|
|
790
|
+
token: e,
|
|
791
|
+
expiresAt: t,
|
|
792
|
+
user: n
|
|
793
|
+
}), G(), i.filter((e) => !e.deleted).length;
|
|
794
|
+
}
|
|
795
|
+
async function He({ email: e, password: t } = {}) {
|
|
796
|
+
if (!V) throw Error("no library api");
|
|
797
|
+
return Ve(await q("/api/auth/signin", {
|
|
798
|
+
method: "POST",
|
|
799
|
+
body: JSON.stringify({
|
|
800
|
+
email: e,
|
|
801
|
+
password: t
|
|
802
|
+
})
|
|
803
|
+
}));
|
|
804
|
+
}
|
|
805
|
+
async function Ue(e) {
|
|
806
|
+
if (!V) throw Error("no library api");
|
|
807
|
+
return Ve(await q("/api/auth/signup", {
|
|
808
|
+
method: "POST",
|
|
809
|
+
body: JSON.stringify(e)
|
|
810
|
+
}));
|
|
811
|
+
}
|
|
812
|
+
function J() {
|
|
813
|
+
let e = W?.token ?? Re()?.token;
|
|
814
|
+
K(null), e && V && q("/api/auth/signout", {
|
|
815
|
+
method: "POST",
|
|
816
|
+
body: "{}"
|
|
817
|
+
}, e).catch(() => {}), W && (W = null, G());
|
|
818
|
+
}
|
|
819
|
+
async function We(e) {
|
|
820
|
+
if (!W) throw new H();
|
|
821
|
+
let { user: t } = await q("/api/me", {
|
|
822
|
+
method: "PATCH",
|
|
823
|
+
body: JSON.stringify(e)
|
|
824
|
+
}, W.token);
|
|
825
|
+
return W = {
|
|
826
|
+
...W,
|
|
827
|
+
user: t
|
|
828
|
+
}, K({
|
|
829
|
+
...Re(),
|
|
830
|
+
user: t
|
|
831
|
+
}), G(), t;
|
|
832
|
+
}
|
|
833
|
+
async function Ge() {
|
|
834
|
+
if (!W) throw new H();
|
|
835
|
+
let { token: e, expiresAt: t } = await q("/api/invites", {
|
|
836
|
+
method: "POST",
|
|
837
|
+
body: "{}"
|
|
838
|
+
}, W.token);
|
|
839
|
+
return {
|
|
840
|
+
url: `${window.location.origin}/join?invite=${encodeURIComponent(e)}`,
|
|
841
|
+
expiresAt: t
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
async function Ke({ name: e, email: t }) {
|
|
845
|
+
if (!V) throw Error("no library api");
|
|
846
|
+
return q("/api/invite-requests", {
|
|
847
|
+
method: "POST",
|
|
848
|
+
body: JSON.stringify({
|
|
849
|
+
name: e,
|
|
850
|
+
email: t
|
|
851
|
+
})
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
async function qe() {
|
|
855
|
+
if (!W) throw new H();
|
|
856
|
+
return (await q("/api/invite-requests", {}, W.token)).requests;
|
|
857
|
+
}
|
|
858
|
+
async function Je(e) {
|
|
859
|
+
if (!W) throw new H();
|
|
860
|
+
let { token: t, expiresAt: n, email: r, name: i } = await q(`/api/invite-requests/${encodeURIComponent(e)}/invite`, {
|
|
861
|
+
method: "POST",
|
|
862
|
+
body: "{}"
|
|
863
|
+
}, W.token);
|
|
864
|
+
return {
|
|
865
|
+
url: `${window.location.origin}/join?invite=${encodeURIComponent(t)}`,
|
|
866
|
+
expiresAt: n,
|
|
867
|
+
email: r,
|
|
868
|
+
name: i
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/editor/library/LibraryProvider.jsx
|
|
873
|
+
var Ye = "kol.editor.library.v3", Y = [
|
|
874
|
+
"palette",
|
|
875
|
+
"pattern",
|
|
876
|
+
"type",
|
|
877
|
+
"preset"
|
|
878
|
+
], X = Y.reduce((e, t) => (e[t] = [], e), {}), Xe = 1, Ze = () => `i${Date.now().toString(36)}-${Xe++}`, Qe = (e) => ({
|
|
879
|
+
...e,
|
|
880
|
+
id: e.id ?? Ze(),
|
|
881
|
+
savedAt: e.savedAt ?? Date.now()
|
|
882
|
+
}), Z = (e) => typeof e == "number" && Number.isFinite(e);
|
|
883
|
+
function $e(e) {
|
|
884
|
+
return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
|
|
885
|
+
colors: e.colors,
|
|
886
|
+
bgEnabled: !!e.bgEnabled,
|
|
887
|
+
poolId: e.poolId ?? "brand",
|
|
888
|
+
modeId: e.modeId ?? "random"
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
function et(e) {
|
|
892
|
+
return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
|
|
893
|
+
shapeId: e.shapeId,
|
|
894
|
+
customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
|
|
895
|
+
cols: Z(e.cols) ? e.cols : 4,
|
|
896
|
+
rows: Z(e.rows) ? e.rows : 4,
|
|
897
|
+
gap: Z(e.gap) ? e.gap : 0,
|
|
898
|
+
padding: Z(e.padding) ? e.padding : 0,
|
|
899
|
+
stretch: !!e.stretch,
|
|
900
|
+
overflow: !!e.overflow,
|
|
901
|
+
bg: e.bg ?? null,
|
|
902
|
+
color: e.color ?? "palette:secondary",
|
|
903
|
+
rules: Array.isArray(e.rules) ? e.rules : [],
|
|
904
|
+
scale: Z(e.scale) ? e.scale : 256
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function tt(e) {
|
|
908
|
+
if (!e || typeof e.text != "string") return null;
|
|
909
|
+
let t = {
|
|
910
|
+
text: e.text,
|
|
911
|
+
width: e.width ?? "Tight",
|
|
912
|
+
weight: Z(e.weight) ? e.weight : 600,
|
|
913
|
+
italic: !!e.italic,
|
|
914
|
+
size: Z(e.size) ? e.size : 96,
|
|
915
|
+
tracking: Z(e.tracking) ? e.tracking : -.01,
|
|
916
|
+
lineHeight: Z(e.lineHeight) ? e.lineHeight : 1.05,
|
|
917
|
+
case: e.case ?? "original",
|
|
918
|
+
color: e.color ?? "palette:dark",
|
|
919
|
+
textAlign: e.textAlign ?? "center"
|
|
920
|
+
};
|
|
921
|
+
return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
|
|
922
|
+
}
|
|
923
|
+
function nt(e) {
|
|
924
|
+
return !e || !Array.isArray(e.layers) ? null : {
|
|
925
|
+
intent: e.intent ?? "whole",
|
|
926
|
+
aspect: e.aspect ?? "1:1",
|
|
927
|
+
layers: e.layers,
|
|
928
|
+
palette: e.palette ?? null,
|
|
929
|
+
...typeof e.canvasW == "number" && typeof e.canvasH == "number" ? {
|
|
930
|
+
canvasW: e.canvasW,
|
|
931
|
+
canvasH: e.canvasH
|
|
932
|
+
} : {},
|
|
933
|
+
...typeof e.mode == "string" ? { mode: e.mode } : {},
|
|
934
|
+
...e.morph && typeof e.morph == "object" ? { morph: e.morph } : {},
|
|
935
|
+
...typeof e.thumb == "string" ? { thumb: e.thumb } : {},
|
|
936
|
+
...e.shipped === !0 ? { shipped: !0 } : {},
|
|
937
|
+
...typeof e.group == "string" ? { group: e.group } : {},
|
|
938
|
+
...typeof e.sub == "string" ? { sub: e.sub } : {}
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
var rt = {
|
|
942
|
+
palette: $e,
|
|
943
|
+
pattern: et,
|
|
944
|
+
type: tt,
|
|
945
|
+
preset: nt
|
|
946
|
+
}, it = [
|
|
947
|
+
"id",
|
|
948
|
+
"savedAt",
|
|
949
|
+
"updatedAt",
|
|
950
|
+
"name"
|
|
951
|
+
];
|
|
952
|
+
function at(e) {
|
|
953
|
+
let t = {};
|
|
954
|
+
for (let n of it) e?.[n] !== void 0 && (t[n] = e[n]);
|
|
955
|
+
return t;
|
|
956
|
+
}
|
|
957
|
+
function ot(e) {
|
|
958
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {});
|
|
959
|
+
for (let n of Y) {
|
|
960
|
+
let r = rt[n];
|
|
961
|
+
t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
|
|
962
|
+
let t = r ? r(e) : e;
|
|
963
|
+
return t ? {
|
|
964
|
+
v: 1,
|
|
965
|
+
...at(e),
|
|
966
|
+
...t
|
|
967
|
+
} : null;
|
|
968
|
+
}).filter(Boolean);
|
|
969
|
+
}
|
|
970
|
+
return t;
|
|
971
|
+
}
|
|
972
|
+
function st(e) {
|
|
973
|
+
return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
|
|
974
|
+
...e,
|
|
975
|
+
type: "background"
|
|
976
|
+
} : e.type === "image" ? {
|
|
977
|
+
...e,
|
|
978
|
+
type: "photo"
|
|
979
|
+
} : e.type === "mark" ? {
|
|
980
|
+
...e,
|
|
981
|
+
type: "shape",
|
|
982
|
+
kind: "logo"
|
|
983
|
+
} : e : e) : e;
|
|
984
|
+
}
|
|
985
|
+
function ct(e) {
|
|
986
|
+
let t = {};
|
|
987
|
+
for (let n of [
|
|
988
|
+
"palette",
|
|
989
|
+
"pattern",
|
|
990
|
+
"type",
|
|
991
|
+
"mark",
|
|
992
|
+
"layout",
|
|
993
|
+
"composition"
|
|
994
|
+
]) {
|
|
995
|
+
let r = e?.[n];
|
|
996
|
+
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Qe(r)] : t[n] = [];
|
|
997
|
+
}
|
|
998
|
+
return t;
|
|
999
|
+
}
|
|
1000
|
+
function lt(e) {
|
|
1001
|
+
let t = Y.reduce((e, t) => (e[t] = [], e), {}), n = (e) => Array.isArray(e) ? e : e && typeof e == "object" ? [Qe(e)] : [];
|
|
1002
|
+
t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
|
|
1003
|
+
let r = n(e?.layout), i = n(e?.composition).map((e) => ({
|
|
1004
|
+
...e,
|
|
1005
|
+
layers: st(e.layers)
|
|
1006
|
+
}));
|
|
1007
|
+
return t.preset = [...r, ...i], t;
|
|
1008
|
+
}
|
|
1009
|
+
function Q() {
|
|
1010
|
+
if (typeof window > "u") return X;
|
|
1011
|
+
try {
|
|
1012
|
+
let e = window.localStorage.getItem(Ye);
|
|
1013
|
+
if (e) return ot(JSON.parse(e));
|
|
1014
|
+
let t = window.localStorage.getItem("kol.generator.library.v2");
|
|
1015
|
+
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), ot(lt(JSON.parse(t)));
|
|
1016
|
+
let n = window.localStorage.getItem("kol.generator.library.v1");
|
|
1017
|
+
return n ? ot(lt(ct(JSON.parse(n)))) : X;
|
|
1018
|
+
} catch {
|
|
1019
|
+
return X;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
var ut = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
|
|
1023
|
+
function dt(e) {
|
|
1024
|
+
if (!(typeof window > "u")) {
|
|
1025
|
+
try {
|
|
1026
|
+
window.localStorage.setItem(Ye, JSON.stringify(e));
|
|
1027
|
+
} catch (e) {
|
|
1028
|
+
console.warn("library: could not save to this browser —", e?.message || e);
|
|
1029
|
+
return;
|
|
1030
|
+
}
|
|
1031
|
+
window.dispatchEvent(new CustomEvent("kol:library"));
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
var ft = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
|
|
1035
|
+
window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
|
|
1036
|
+
}), pt = () => {
|
|
1037
|
+
try {
|
|
1038
|
+
return window.localStorage.getItem(Ye);
|
|
1039
|
+
} catch {
|
|
1040
|
+
return null;
|
|
1041
|
+
}
|
|
1042
|
+
}, mt = k(null);
|
|
1043
|
+
function ht(e, t, n) {
|
|
1044
|
+
return e.map((e) => e.id === t ? {
|
|
1045
|
+
...e,
|
|
1046
|
+
name: String(n ?? "").trim() || null,
|
|
1047
|
+
updatedAt: Date.now()
|
|
1048
|
+
} : e);
|
|
1049
|
+
}
|
|
1050
|
+
function gt(e, t, n) {
|
|
1051
|
+
let r = e.findIndex((e) => e.id === t);
|
|
1052
|
+
if (r === -1) return e;
|
|
1053
|
+
let i = e[r], a = {
|
|
1054
|
+
...i,
|
|
1055
|
+
id: n,
|
|
1056
|
+
name: `${i.name || "Untitled"} copy`,
|
|
1057
|
+
savedAt: Date.now()
|
|
1058
|
+
};
|
|
1059
|
+
return delete a.updatedAt, delete a.shipped, [
|
|
1060
|
+
...e.slice(0, r + 1),
|
|
1061
|
+
a,
|
|
1062
|
+
...e.slice(r + 1)
|
|
1063
|
+
];
|
|
1064
|
+
}
|
|
1065
|
+
function _t({ children: e }) {
|
|
1066
|
+
let [t, n] = M(Q);
|
|
1067
|
+
j(() => {
|
|
1068
|
+
dt(t);
|
|
1069
|
+
}, [t]);
|
|
1070
|
+
let r = ce(t);
|
|
1071
|
+
r.current = t;
|
|
1072
|
+
let i = ce(null), [a, o] = M("off"), s = A((e) => {
|
|
1073
|
+
let t = i.current;
|
|
1074
|
+
!t || ut(e) || t.push(e).catch((e) => {
|
|
1075
|
+
e instanceof H && J(), typeof console < "u" && console.warn("library sync: push failed —", e?.message || e);
|
|
1076
|
+
});
|
|
1077
|
+
}, []), c = Ie();
|
|
1078
|
+
j(() => {
|
|
1079
|
+
if (!c) {
|
|
1080
|
+
i.current = null, o("off");
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
let e = !0;
|
|
1084
|
+
return c.backend.hydrate().then((t) => {
|
|
1085
|
+
if (!e) return;
|
|
1086
|
+
let { next: a, pushes: l } = Ae(r.current, t);
|
|
1087
|
+
i.current = c.backend, n({
|
|
1088
|
+
...X,
|
|
1089
|
+
...a
|
|
1090
|
+
}), o("on");
|
|
1091
|
+
for (let e of l) s(e);
|
|
1092
|
+
}).catch((e) => {
|
|
1093
|
+
e instanceof H && J(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
|
|
1094
|
+
}), () => {
|
|
1095
|
+
e = !1;
|
|
1096
|
+
};
|
|
1097
|
+
}, [c, s]);
|
|
1098
|
+
let l = A((e, t) => {
|
|
1099
|
+
if (!Y.includes(e) || !t) return null;
|
|
1100
|
+
let r = rt[e], i = r ? r(t) : t;
|
|
1101
|
+
if (!i) return null;
|
|
1102
|
+
let a = Ze(), o = {
|
|
1103
|
+
v: 1,
|
|
1104
|
+
id: a,
|
|
1105
|
+
savedAt: Date.now(),
|
|
1106
|
+
...typeof t.name == "string" ? { name: t.name } : {},
|
|
1107
|
+
...i
|
|
1108
|
+
};
|
|
1109
|
+
return n((t) => ({
|
|
1110
|
+
...t,
|
|
1111
|
+
[e]: [...t[e] ?? [], o]
|
|
1112
|
+
})), s({
|
|
1113
|
+
op: "put",
|
|
1114
|
+
kind: e,
|
|
1115
|
+
item: o
|
|
1116
|
+
}), a;
|
|
1117
|
+
}, [s]), u = A((e, t) => {
|
|
1118
|
+
n((n) => ({
|
|
1119
|
+
...n,
|
|
1120
|
+
[e]: (n[e] ?? []).filter((e) => e.id !== t)
|
|
1121
|
+
})), s({
|
|
1122
|
+
op: "remove",
|
|
1123
|
+
kind: e,
|
|
1124
|
+
id: t
|
|
1125
|
+
});
|
|
1126
|
+
}, [s]), ee = A((e, t, i) => {
|
|
1127
|
+
if (!Y.includes(e) || !t || !i) return;
|
|
1128
|
+
let a = rt[e], o = a ? a(i) : i;
|
|
1129
|
+
if (!o) return;
|
|
1130
|
+
let c = Date.now(), l = (e) => ({
|
|
1131
|
+
...e,
|
|
1132
|
+
...typeof i.name == "string" ? { name: i.name } : {},
|
|
1133
|
+
...o,
|
|
1134
|
+
id: e.id,
|
|
1135
|
+
savedAt: e.savedAt,
|
|
1136
|
+
updatedAt: c
|
|
1137
|
+
});
|
|
1138
|
+
n((n) => ({
|
|
1139
|
+
...n,
|
|
1140
|
+
[e]: (n[e] ?? []).map((e) => e.id === t ? l(e) : e)
|
|
1141
|
+
}));
|
|
1142
|
+
let u = (r.current[e] ?? []).find((e) => e.id === t);
|
|
1143
|
+
u && s({
|
|
1144
|
+
op: "put",
|
|
1145
|
+
kind: e,
|
|
1146
|
+
item: l(u)
|
|
1147
|
+
});
|
|
1148
|
+
}, [s]), d = A((e, t, i) => {
|
|
1149
|
+
if (!Y.includes(e) || !t) return;
|
|
1150
|
+
n((n) => ({
|
|
1151
|
+
...n,
|
|
1152
|
+
[e]: ht(n[e] ?? [], t, i)
|
|
1153
|
+
}));
|
|
1154
|
+
let a = ht(r.current[e] ?? [], t, i).find((e) => e.id === t);
|
|
1155
|
+
a && s({
|
|
1156
|
+
op: "put",
|
|
1157
|
+
kind: e,
|
|
1158
|
+
item: a
|
|
1159
|
+
});
|
|
1160
|
+
}, [s]), f = A((e, t, i) => {
|
|
1161
|
+
if (!Y.includes(e) || !t || typeof i != "string" || (r.current[e] ?? []).find((e) => e.id === t)?.shipped) return;
|
|
1162
|
+
let a = (e) => e.map((e) => e.id === t ? {
|
|
1163
|
+
...e,
|
|
1164
|
+
thumb: i
|
|
1165
|
+
} : e);
|
|
1166
|
+
n((t) => ({
|
|
1167
|
+
...t,
|
|
1168
|
+
[e]: a(t[e] ?? [])
|
|
1169
|
+
}));
|
|
1170
|
+
let o = a(r.current[e] ?? []).find((e) => e.id === t);
|
|
1171
|
+
o && s({
|
|
1172
|
+
op: "put",
|
|
1173
|
+
kind: e,
|
|
1174
|
+
item: o
|
|
1175
|
+
});
|
|
1176
|
+
}, [s]), p = A((e, t) => {
|
|
1177
|
+
if (!Y.includes(e) || !t) return null;
|
|
1178
|
+
let i = Ze();
|
|
1179
|
+
n((n) => ({
|
|
1180
|
+
...n,
|
|
1181
|
+
[e]: gt(n[e] ?? [], t, i)
|
|
1182
|
+
}));
|
|
1183
|
+
let a = gt(r.current[e] ?? [], t, i).find((e) => e.id === i);
|
|
1184
|
+
return a && s({
|
|
1185
|
+
op: "put",
|
|
1186
|
+
kind: e,
|
|
1187
|
+
item: a
|
|
1188
|
+
}), i;
|
|
1189
|
+
}, [s]), m = A((e) => {
|
|
1190
|
+
n((t) => ({
|
|
1191
|
+
...t,
|
|
1192
|
+
[e]: []
|
|
1193
|
+
}));
|
|
1194
|
+
}, []), te = A(() => n(X), []), h = A((e) => n({
|
|
1195
|
+
...X,
|
|
1196
|
+
...e
|
|
1197
|
+
}), []), g = {
|
|
1198
|
+
library: t,
|
|
1199
|
+
selected: se(() => Y.reduce((e, n) => {
|
|
1200
|
+
let r = t[n] ?? [];
|
|
1201
|
+
return e[n] = r.length ? r[r.length - 1] : null, e;
|
|
1202
|
+
}, {}), [t]),
|
|
1203
|
+
addItem: l,
|
|
1204
|
+
removeItem: u,
|
|
1205
|
+
updateItem: ee,
|
|
1206
|
+
renameItem: d,
|
|
1207
|
+
setThumb: f,
|
|
1208
|
+
duplicateItem: p,
|
|
1209
|
+
clearSlot: m,
|
|
1210
|
+
clearAll: te,
|
|
1211
|
+
replaceAll: h,
|
|
1212
|
+
syncState: a,
|
|
1213
|
+
savePalette: (e) => l("palette", e),
|
|
1214
|
+
savePattern: (e) => l("pattern", e),
|
|
1215
|
+
saveType: (e) => l("type", e),
|
|
1216
|
+
savePreset: (e) => l("preset", e)
|
|
1217
|
+
};
|
|
1218
|
+
return /* @__PURE__ */ N(mt.Provider, {
|
|
1219
|
+
value: g,
|
|
1220
|
+
children: e
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
function vt() {
|
|
1224
|
+
return oe(mt) || {
|
|
1225
|
+
library: X,
|
|
1226
|
+
selected: Y.reduce((e, t) => (e[t] = null, e), {}),
|
|
1227
|
+
addItem: () => null,
|
|
1228
|
+
removeItem: () => {},
|
|
1229
|
+
updateItem: () => {},
|
|
1230
|
+
clearSlot: () => {},
|
|
1231
|
+
clearAll: () => {},
|
|
1232
|
+
replaceAll: () => {},
|
|
1233
|
+
syncState: "off",
|
|
1234
|
+
savePalette: () => null,
|
|
1235
|
+
savePattern: () => null,
|
|
1236
|
+
saveType: () => null,
|
|
1237
|
+
savePreset: () => null
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
var yt = Y, bt = {
|
|
1241
|
+
bg: "Background",
|
|
1242
|
+
fg: "Ink",
|
|
1243
|
+
accent: "Accent",
|
|
1244
|
+
dim: "Dim",
|
|
1245
|
+
warm: "Warm"
|
|
1246
|
+
}, xt = {
|
|
1247
|
+
0: "fg",
|
|
1248
|
+
1: "warm",
|
|
1249
|
+
3: "dim",
|
|
1250
|
+
4: "accent",
|
|
1251
|
+
5: "bg"
|
|
1252
|
+
}, St = (e) => e.slice(0, 7).toLowerCase();
|
|
1253
|
+
function Ct() {
|
|
1254
|
+
let e = r(), { layers: a, selectedId: s, updateLayer: c, setColorAt: d } = n(), { library: m, addItem: te } = vt(), [v, x] = M("analogous"), [S, C] = M(p), [w, ie] = M(() => o(.62, .14, Math.random() * 360)), [T, E] = M(() => ne(l(S), {
|
|
1255
|
+
base: w,
|
|
1256
|
+
relation: v,
|
|
1257
|
+
count: 5
|
|
1258
|
+
}).map((e) => ({
|
|
1259
|
+
hex: e,
|
|
1260
|
+
locked: !1
|
|
1261
|
+
}))), [D, O] = M(null), k = se(() => u(m), [m]), A = ({ b: e = w, rel: t = v, n = T.length, s: r = S } = {}) => {
|
|
1262
|
+
let i = ne(l(r), {
|
|
1263
|
+
base: e,
|
|
1264
|
+
relation: t,
|
|
1265
|
+
count: n
|
|
1266
|
+
});
|
|
1267
|
+
E((e) => i.map((t, n) => e[n]?.locked ? e[n] : {
|
|
1268
|
+
hex: t,
|
|
1269
|
+
locked: !1
|
|
1270
|
+
})), O(null);
|
|
1271
|
+
}, oe = () => {
|
|
1272
|
+
let e = p();
|
|
1273
|
+
C(e), A({ s: e });
|
|
1274
|
+
}, j = (e) => {
|
|
1275
|
+
let t = St(e);
|
|
1276
|
+
ie(t), A({ b: t });
|
|
1277
|
+
}, ce = (e) => {
|
|
1278
|
+
x(e), A({ rel: e });
|
|
1279
|
+
}, le = (e) => {
|
|
1280
|
+
let t = Number(e);
|
|
1281
|
+
Number.isInteger(t) && t >= 2 && t <= 8 && A({ n: t });
|
|
1282
|
+
}, ue = (e, t) => {
|
|
1283
|
+
E((n) => n.map((n, r) => r === e ? {
|
|
1284
|
+
...n,
|
|
1285
|
+
hex: St(t)
|
|
1286
|
+
} : n)), O(null);
|
|
1287
|
+
}, fe = (e) => E((t) => t.map((t, n) => n === e ? {
|
|
1288
|
+
...t,
|
|
1289
|
+
locked: !t.locked
|
|
1290
|
+
} : t)), pe = (e) => {
|
|
1291
|
+
E((t) => t.filter((t, n) => n !== e)), O(null);
|
|
1292
|
+
}, me = (e) => {
|
|
1293
|
+
let t = k.find((t) => t.id === e);
|
|
1294
|
+
if (!t) return;
|
|
1295
|
+
let n = t.colors.slice(0, 8);
|
|
1296
|
+
E((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
|
|
1297
|
+
hex: St(e),
|
|
1298
|
+
locked: !1
|
|
1299
|
+
}))), O({
|
|
1300
|
+
name: t.name,
|
|
1301
|
+
roles: t.colors.length <= 8 ? t.roles : null
|
|
1302
|
+
});
|
|
1303
|
+
}, F = T.map((e) => e.hex), I = D?.roles ?? i(F), he = f.find((e) => e.id === v)?.label ?? "Palette", L = {
|
|
1304
|
+
name: D?.name ?? he,
|
|
1305
|
+
relation: v,
|
|
1306
|
+
colors: F,
|
|
1307
|
+
roles: I
|
|
1308
|
+
}, ge = (e) => ee.filter((t) => I[t]?.toLowerCase() === e).map((e) => bt[e]).join(", "), R = s && s !== "canvas" ? t(a, s) : null, z = R?.type === "loop" ? re(R.loopId)?.params : null, _e = () => {
|
|
1309
|
+
if (!R || !z) return;
|
|
1310
|
+
let e = g(R, z, L, { rotate: !0 }), t = Object.fromEntries(z.filter((e) => e.type === "color").map((t) => [t.key, e[t.key]]));
|
|
1311
|
+
c(R.id, t);
|
|
1312
|
+
}, ve = () => Object.entries(xt).forEach(([e, t]) => d(Number(e), I[t]));
|
|
1313
|
+
return /* @__PURE__ */ P("div", {
|
|
1314
|
+
className: "p-4 flex flex-col gap-4",
|
|
1315
|
+
children: [
|
|
1316
|
+
/* @__PURE__ */ P("div", {
|
|
1317
|
+
className: "flex items-center gap-2",
|
|
1318
|
+
children: [
|
|
1319
|
+
/* @__PURE__ */ N(y, {
|
|
1320
|
+
color: w.toUpperCase(),
|
|
1321
|
+
onChange: j,
|
|
1322
|
+
size: "sm",
|
|
1323
|
+
label: "Base"
|
|
1324
|
+
}),
|
|
1325
|
+
/* @__PURE__ */ N("span", {
|
|
1326
|
+
className: "kol-helper-10 uppercase text-meta",
|
|
1327
|
+
children: "Base"
|
|
1328
|
+
}),
|
|
1329
|
+
/* @__PURE__ */ N("span", {
|
|
1330
|
+
className: "kol-mono-10 text-meta flex-1",
|
|
1331
|
+
children: w.toUpperCase()
|
|
1332
|
+
}),
|
|
1333
|
+
/* @__PURE__ */ N("span", {
|
|
1334
|
+
className: "kol-helper-10 uppercase text-meta",
|
|
1335
|
+
children: "Colors"
|
|
1336
|
+
}),
|
|
1337
|
+
/* @__PURE__ */ N(ae, {
|
|
1338
|
+
size: e,
|
|
1339
|
+
min: 2,
|
|
1340
|
+
max: 8,
|
|
1341
|
+
value: T.length,
|
|
1342
|
+
onChange: (e) => le(e.target.value),
|
|
1343
|
+
className: "w-16",
|
|
1344
|
+
"aria-label": "Colors"
|
|
1345
|
+
})
|
|
1346
|
+
]
|
|
1347
|
+
}),
|
|
1348
|
+
/* @__PURE__ */ P("div", {
|
|
1349
|
+
className: "flex items-center gap-2",
|
|
1350
|
+
children: [/* @__PURE__ */ N(b, {
|
|
1351
|
+
className: "flex-1 min-w-0",
|
|
1352
|
+
size: e,
|
|
1353
|
+
"aria-label": "Relationship",
|
|
1354
|
+
options: f.map((e) => ({
|
|
1355
|
+
value: e.id,
|
|
1356
|
+
label: e.label
|
|
1357
|
+
})),
|
|
1358
|
+
value: v,
|
|
1359
|
+
onChange: ce
|
|
1360
|
+
}), /* @__PURE__ */ N(_, {
|
|
1361
|
+
tone: "grey",
|
|
1362
|
+
size: e,
|
|
1363
|
+
onClick: oe,
|
|
1364
|
+
children: "Roll"
|
|
1365
|
+
})]
|
|
1366
|
+
}),
|
|
1367
|
+
/* @__PURE__ */ N("div", {
|
|
1368
|
+
className: "flex flex-col gap-1",
|
|
1369
|
+
children: T.map((e, t) => /* @__PURE__ */ P("div", {
|
|
1370
|
+
className: "flex items-center gap-2",
|
|
1371
|
+
children: [
|
|
1372
|
+
/* @__PURE__ */ N(y, {
|
|
1373
|
+
color: e.hex.toUpperCase(),
|
|
1374
|
+
onChange: (e) => ue(t, e),
|
|
1375
|
+
size: "sm",
|
|
1376
|
+
label: `Color ${t + 1}`
|
|
1377
|
+
}),
|
|
1378
|
+
/* @__PURE__ */ N("span", {
|
|
1379
|
+
className: "kol-helper-10 uppercase text-meta flex-1 truncate",
|
|
1380
|
+
children: ge(e.hex)
|
|
1381
|
+
}),
|
|
1382
|
+
/* @__PURE__ */ N("span", {
|
|
1383
|
+
className: "kol-mono-10 text-meta",
|
|
1384
|
+
children: e.hex.toUpperCase()
|
|
1385
|
+
}),
|
|
1386
|
+
/* @__PURE__ */ N(_, {
|
|
1387
|
+
tone: "ghost",
|
|
1388
|
+
quiet: !0,
|
|
1389
|
+
size: "sm",
|
|
1390
|
+
iconOnly: e.locked ? "lock" : "unlock",
|
|
1391
|
+
"aria-label": `${e.locked ? "Unlock" : "Lock"} color ${t + 1}`,
|
|
1392
|
+
pressed: e.locked,
|
|
1393
|
+
onClick: () => fe(t)
|
|
1394
|
+
}),
|
|
1395
|
+
/* @__PURE__ */ N("span", {
|
|
1396
|
+
className: T.length <= 2 ? "invisible pointer-events-none" : "contents",
|
|
1397
|
+
"aria-hidden": T.length <= 2 || void 0,
|
|
1398
|
+
children: /* @__PURE__ */ N(_, {
|
|
1399
|
+
tone: "ghost",
|
|
1400
|
+
quiet: !0,
|
|
1401
|
+
size: "sm",
|
|
1402
|
+
iconOnly: "trash",
|
|
1403
|
+
"aria-label": `Delete color ${t + 1}`,
|
|
1404
|
+
tabIndex: T.length <= 2 ? -1 : void 0,
|
|
1405
|
+
onClick: () => pe(t)
|
|
1406
|
+
})
|
|
1407
|
+
})
|
|
1408
|
+
]
|
|
1409
|
+
}, t))
|
|
1410
|
+
}),
|
|
1411
|
+
h(I.bg, I.fg) < 4.5 && /* @__PURE__ */ P("span", {
|
|
1412
|
+
className: "kol-helper-10 text-meta inline-flex items-center gap-1",
|
|
1413
|
+
children: [/* @__PURE__ */ N(de, {
|
|
1414
|
+
name: "info",
|
|
1415
|
+
size: 12
|
|
1416
|
+
}), "Ink on background is under 4.5:1"]
|
|
1417
|
+
}),
|
|
1418
|
+
/* @__PURE__ */ N(b, {
|
|
1419
|
+
size: e,
|
|
1420
|
+
"aria-label": "Load palette",
|
|
1421
|
+
value: "",
|
|
1422
|
+
options: [{
|
|
1423
|
+
value: "",
|
|
1424
|
+
label: "Load palette…"
|
|
1425
|
+
}, ...k.map((e) => ({
|
|
1426
|
+
value: e.id,
|
|
1427
|
+
label: e.name
|
|
1428
|
+
}))],
|
|
1429
|
+
onChange: (e) => e && me(e)
|
|
1430
|
+
}),
|
|
1431
|
+
/* @__PURE__ */ N(_, {
|
|
1432
|
+
tone: "grey",
|
|
1433
|
+
size: e,
|
|
1434
|
+
onClick: () => te("palette", {
|
|
1435
|
+
name: L.name,
|
|
1436
|
+
colors: F
|
|
1437
|
+
}),
|
|
1438
|
+
children: "Save"
|
|
1439
|
+
}),
|
|
1440
|
+
/* @__PURE__ */ P("div", {
|
|
1441
|
+
className: "flex gap-2",
|
|
1442
|
+
children: [z && /* @__PURE__ */ N(_, {
|
|
1443
|
+
tone: "grey",
|
|
1444
|
+
size: e,
|
|
1445
|
+
className: "flex-1",
|
|
1446
|
+
onClick: _e,
|
|
1447
|
+
children: "Apply to layer"
|
|
1448
|
+
}), /* @__PURE__ */ N(_, {
|
|
1449
|
+
tone: "grey",
|
|
1450
|
+
size: e,
|
|
1451
|
+
className: "flex-1",
|
|
1452
|
+
onClick: ve,
|
|
1453
|
+
children: "Apply to document"
|
|
1454
|
+
})]
|
|
1455
|
+
})
|
|
1456
|
+
]
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
//#endregion
|
|
1460
|
+
//#region src/editor/color/ColorModesWindow.jsx
|
|
1461
|
+
var $ = "kol:open-color-modes", wt = () => window.dispatchEvent(new CustomEvent($));
|
|
1462
|
+
function Tt() {
|
|
1463
|
+
let [e, t] = M(!1);
|
|
1464
|
+
if (j(() => {
|
|
1465
|
+
let e = () => t(!0);
|
|
1466
|
+
return window.addEventListener($, e), () => window.removeEventListener($, e);
|
|
1467
|
+
}, []), !e) return null;
|
|
1468
|
+
let n = () => t(!1);
|
|
1469
|
+
return /* @__PURE__ */ N(x, {
|
|
1470
|
+
open: !0,
|
|
1471
|
+
onClose: n,
|
|
1472
|
+
closeButton: !1,
|
|
1473
|
+
scrim: !0,
|
|
1474
|
+
children: /* @__PURE__ */ P("div", {
|
|
1475
|
+
"aria-label": "Color Modes",
|
|
1476
|
+
"data-editor-keep-selection": !0,
|
|
1477
|
+
className: "kol-design-editor kol-popover w-[360px] max-w-full flex flex-col",
|
|
1478
|
+
children: [/* @__PURE__ */ P("div", {
|
|
1479
|
+
className: "relative flex h-10 items-center justify-center border-b border-oq-08 px-4",
|
|
1480
|
+
children: [/* @__PURE__ */ N("span", {
|
|
1481
|
+
className: "font-sans text-[13px] text-emphasis",
|
|
1482
|
+
children: "Color Modes"
|
|
1483
|
+
}), /* @__PURE__ */ N(v, {
|
|
1484
|
+
onClick: n,
|
|
1485
|
+
size: "sm",
|
|
1486
|
+
className: "!absolute right-3"
|
|
1487
|
+
})]
|
|
1488
|
+
}), /* @__PURE__ */ N(Ct, {})]
|
|
1489
|
+
})
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
//#endregion
|
|
1493
|
+
export { z as A, Ue as C, De as D, Ie as E, F as M, pe as N, Ce as O, me as P, J as S, Le as T, qe as _, gt as a, je as b, Q as c, ft as d, vt as f, Je as g, Fe as h, yt as i, fe as j, Te as k, pt as l, Me as m, wt as n, ht as o, H as p, _t as r, ut as s, Tt as t, dt as u, Ge as v, We as w, He as x, Ke as y };
|