@kolkrabbi/design-editor 0.35.0 → 0.36.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/dist/{BindDot-Don6fG00.js → BindDot-dBz2NUVr.js} +5 -5
- package/dist/{Timeline-Cz-W72D0.js → Timeline-BDMxiVYe.js} +31 -31
- package/dist/{TreePicker-1_NZG8GB.js → TreePicker-BawzFyzV.js} +4 -4
- package/dist/{core-DJet1D7E.js → core-d8m3o_mg.js} +4382 -4379
- package/dist/core.js +5 -5
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +1202 -1236
- package/dist/{effectCategories-DV7i_AgK.js → effectCategories-D1t5Vdqf.js} +696 -696
- package/dist/{effects-Dn4_OzYx.js → effects-BFAtGRPu.js} +126 -126
- package/dist/effects.js +1 -1
- package/dist/{generators-Bf08F0NV.js → generators-JkPVwcTT.js} +1439 -1439
- package/dist/generators.js +1 -1
- package/dist/{host-BUVR9I4S.js → host-C3_Oy1ck.js} +1 -1
- package/dist/{host-CRRiwlrB.js → host-CsF4CKfw.js} +22 -22
- package/dist/{morphStore-B5081ohW.js → morphStore-CidzL7wV.js} +1 -1
- package/dist/{motion-Cuwxm2ic.js → motion-KvPCj1EZ.js} +534 -533
- package/dist/motion.js +1 -1
- package/dist/{previewScale-CA0ComGv.js → previewScale-BAmIBoWY.js} +1 -1
- package/dist/{rolls-CEQmdcp3.js → rolls-5hhrWX96.js} +1501 -1312
- package/dist/{src-CzKMsyZO.js → src-8EvSuuNG.js} +1 -1
- package/dist/{store-DZUWPE2s.js → store-QnsWv-26.js} +448 -448
- package/dist/{useLayerEdit-Cmtx3V3O.js → useLayerEdit-BikuFIoi.js} +118 -119
- package/package.json +9 -9
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Button as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { IconLoader as
|
|
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-5hhrWX96.js";
|
|
2
|
+
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
|
+
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
|
+
import { Fragment as ue, jsx as P, jsxs as F } from "react/jsx-runtime";
|
|
5
|
+
import { IconLoader as de } from "@kolkrabbi/kol-icons";
|
|
6
6
|
//#region src/editor/params/ModulationEditor.jsx
|
|
7
|
-
var
|
|
7
|
+
var fe = [
|
|
8
8
|
{
|
|
9
9
|
code: "wave(t*2)",
|
|
10
10
|
desc: "Fast sine"
|
|
@@ -37,97 +37,97 @@ var de = [
|
|
|
37
37
|
code: "rand()",
|
|
38
38
|
desc: "Noise"
|
|
39
39
|
}
|
|
40
|
-
],
|
|
41
|
-
function
|
|
42
|
-
let [
|
|
43
|
-
|
|
44
|
-
let e = 0,
|
|
45
|
-
|
|
40
|
+
], I = 196, L = 64;
|
|
41
|
+
function pe({ expr: e }) {
|
|
42
|
+
let [n, r] = M(0);
|
|
43
|
+
j(() => {
|
|
44
|
+
let e = 0, n = () => {
|
|
45
|
+
r(t.getCtx().t ?? 0), e = requestAnimationFrame(n);
|
|
46
46
|
};
|
|
47
|
-
return e = requestAnimationFrame(
|
|
47
|
+
return e = requestAnimationFrame(n), () => cancelAnimationFrame(e);
|
|
48
48
|
}, []);
|
|
49
|
-
let
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
samples:
|
|
52
|
-
min: Math.min(0, ...
|
|
53
|
-
max: Math.max(1, ...
|
|
54
|
-
cursor:
|
|
55
|
-
height:
|
|
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
|
+
return /* @__PURE__ */ P(x, {
|
|
51
|
+
samples: c,
|
|
52
|
+
min: Math.min(0, ...c),
|
|
53
|
+
max: Math.max(1, ...c),
|
|
54
|
+
cursor: n,
|
|
55
|
+
height: L,
|
|
56
56
|
ariaLabel: "Expression plot over one loop"
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
let
|
|
61
|
-
if (!
|
|
62
|
-
let
|
|
63
|
-
...
|
|
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, {
|
|
63
|
+
...u,
|
|
64
64
|
transform: {
|
|
65
|
-
...
|
|
65
|
+
...g,
|
|
66
66
|
...e
|
|
67
67
|
}
|
|
68
|
-
}),
|
|
69
|
-
|
|
68
|
+
}), x = (e) => {
|
|
69
|
+
d(null);
|
|
70
70
|
let t = String(e).trim();
|
|
71
|
-
t && t !==
|
|
72
|
-
},
|
|
73
|
-
d(!0);
|
|
74
|
-
let e = await _();
|
|
75
|
-
d(!1), e != null && x({ cc: e });
|
|
76
|
-
}, D = async () => {
|
|
71
|
+
t && t !== y && b({ expr: t });
|
|
72
|
+
}, T = async () => {
|
|
77
73
|
p(!0);
|
|
78
|
-
let e = await
|
|
79
|
-
p(!1), e &&
|
|
80
|
-
|
|
74
|
+
let e = await c();
|
|
75
|
+
p(!1), e != null && b({ cc: e });
|
|
76
|
+
}, E = async () => {
|
|
77
|
+
m(!0);
|
|
78
|
+
let e = await a();
|
|
79
|
+
m(!1), e && s(r.key, {
|
|
80
|
+
...u,
|
|
81
81
|
source: e
|
|
82
82
|
});
|
|
83
|
-
},
|
|
83
|
+
}, O = g.range ?? (r.min != null && r.max != null ? [r.min, r.max] : [0, 1]), k = (e, t) => {
|
|
84
84
|
let n = Number(e);
|
|
85
85
|
return Number.isFinite(n) ? n : t;
|
|
86
86
|
};
|
|
87
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ F("div", {
|
|
88
88
|
className: "flex flex-col gap-3",
|
|
89
89
|
children: [
|
|
90
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ P(C, {
|
|
91
91
|
label: "Range",
|
|
92
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ F("div", {
|
|
93
93
|
className: "flex items-center gap-2 min-w-0",
|
|
94
94
|
children: [
|
|
95
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ P("div", {
|
|
96
96
|
className: "flex-1 min-w-0",
|
|
97
|
-
children: /* @__PURE__ */
|
|
97
|
+
children: /* @__PURE__ */ P(S, {
|
|
98
98
|
variant: "filled",
|
|
99
|
-
size:
|
|
99
|
+
size: l,
|
|
100
100
|
type: "number",
|
|
101
101
|
width: "100%",
|
|
102
|
-
value:
|
|
103
|
-
onChange: (e) =>
|
|
102
|
+
value: O[0],
|
|
103
|
+
onChange: (e) => b({ range: [k(e.target.value, O[0]), O[1]] })
|
|
104
104
|
})
|
|
105
105
|
}),
|
|
106
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ P("span", {
|
|
107
107
|
className: "kol-helper-10 text-meta shrink-0",
|
|
108
108
|
children: "to"
|
|
109
109
|
}),
|
|
110
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ P("div", {
|
|
111
111
|
className: "flex-1 min-w-0",
|
|
112
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ P(S, {
|
|
113
113
|
variant: "filled",
|
|
114
|
-
size:
|
|
114
|
+
size: l,
|
|
115
115
|
type: "number",
|
|
116
116
|
width: "100%",
|
|
117
|
-
value:
|
|
118
|
-
onChange: (e) =>
|
|
117
|
+
value: O[1],
|
|
118
|
+
onChange: (e) => b({ range: [O[0], k(e.target.value, O[1])] })
|
|
119
119
|
})
|
|
120
120
|
})
|
|
121
121
|
]
|
|
122
122
|
})
|
|
123
123
|
}),
|
|
124
|
-
/* @__PURE__ */
|
|
124
|
+
/* @__PURE__ */ F("div", {
|
|
125
125
|
className: "grid grid-cols-2 gap-2",
|
|
126
|
-
children: [/* @__PURE__ */
|
|
126
|
+
children: [/* @__PURE__ */ P(C, {
|
|
127
127
|
label: "Invert",
|
|
128
|
-
children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ P(ie, {
|
|
129
129
|
layout: "joined",
|
|
130
|
-
size:
|
|
130
|
+
size: l,
|
|
131
131
|
className: "w-full",
|
|
132
132
|
options: [{
|
|
133
133
|
value: "off",
|
|
@@ -136,73 +136,73 @@ function pe({ layer: e, param: r, setProp: a }) {
|
|
|
136
136
|
value: "on",
|
|
137
137
|
label: "On"
|
|
138
138
|
}],
|
|
139
|
-
value:
|
|
140
|
-
onChange: (e) =>
|
|
139
|
+
value: g?.invert ? "on" : "off",
|
|
140
|
+
onChange: (e) => b({ invert: e === "on" })
|
|
141
141
|
})
|
|
142
|
-
}), /* @__PURE__ */
|
|
142
|
+
}), /* @__PURE__ */ P(C, {
|
|
143
143
|
label: "Smooth",
|
|
144
|
-
children: /* @__PURE__ */
|
|
144
|
+
children: /* @__PURE__ */ P(D, {
|
|
145
145
|
min: 0,
|
|
146
146
|
max: .95,
|
|
147
147
|
step: .05,
|
|
148
|
-
value:
|
|
149
|
-
onChange: (e) =>
|
|
148
|
+
value: g?.smooth ?? 0,
|
|
149
|
+
onChange: (e) => b({ smooth: e })
|
|
150
150
|
})
|
|
151
151
|
})]
|
|
152
152
|
}),
|
|
153
|
-
/* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ P(C, {
|
|
154
154
|
label: "Curve",
|
|
155
|
-
children: /* @__PURE__ */
|
|
155
|
+
children: /* @__PURE__ */ P(D, {
|
|
156
156
|
min: .25,
|
|
157
157
|
max: 4,
|
|
158
158
|
step: .05,
|
|
159
|
-
value:
|
|
160
|
-
onChange: (e) =>
|
|
159
|
+
value: g?.curve ?? 1,
|
|
160
|
+
onChange: (e) => b({ curve: e })
|
|
161
161
|
})
|
|
162
162
|
}),
|
|
163
|
-
|
|
163
|
+
ne && /* @__PURE__ */ F("div", {
|
|
164
164
|
className: "grid grid-cols-2 gap-2",
|
|
165
|
-
children: [/* @__PURE__ */
|
|
165
|
+
children: [/* @__PURE__ */ P(C, {
|
|
166
166
|
label: "Rate",
|
|
167
|
-
children: /* @__PURE__ */
|
|
167
|
+
children: /* @__PURE__ */ P(D, {
|
|
168
168
|
min: .25,
|
|
169
169
|
max: 16,
|
|
170
170
|
step: .25,
|
|
171
|
-
value:
|
|
172
|
-
onChange: (e) =>
|
|
171
|
+
value: g?.rate ?? 1,
|
|
172
|
+
onChange: (e) => b({ rate: e })
|
|
173
173
|
})
|
|
174
|
-
}), /* @__PURE__ */
|
|
174
|
+
}), /* @__PURE__ */ P(C, {
|
|
175
175
|
label: "Phase",
|
|
176
|
-
children: /* @__PURE__ */
|
|
176
|
+
children: /* @__PURE__ */ P(D, {
|
|
177
177
|
min: 0,
|
|
178
178
|
max: 1,
|
|
179
179
|
step: .01,
|
|
180
|
-
value:
|
|
181
|
-
onChange: (e) =>
|
|
180
|
+
value: g?.phase ?? 0,
|
|
181
|
+
onChange: (e) => b({ phase: e })
|
|
182
182
|
})
|
|
183
183
|
})]
|
|
184
184
|
}),
|
|
185
|
-
|
|
186
|
-
/* @__PURE__ */
|
|
185
|
+
ae && /* @__PURE__ */ F(ue, { children: [
|
|
186
|
+
/* @__PURE__ */ P(C, {
|
|
187
187
|
label: "Expression",
|
|
188
|
-
children: /* @__PURE__ */
|
|
188
|
+
children: /* @__PURE__ */ P(S, {
|
|
189
189
|
variant: "ghost",
|
|
190
|
-
size:
|
|
191
|
-
value:
|
|
192
|
-
onChange: (e) =>
|
|
193
|
-
onBlur: (e) =>
|
|
190
|
+
size: l,
|
|
191
|
+
value: ee ?? y,
|
|
192
|
+
onChange: (e) => d(e.target.value),
|
|
193
|
+
onBlur: (e) => x(e.target.value),
|
|
194
194
|
onKeyDown: (e) => {
|
|
195
195
|
e.key === "Enter" && e.currentTarget.blur();
|
|
196
196
|
}
|
|
197
197
|
})
|
|
198
198
|
}),
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ P(pe, { expr: y }),
|
|
200
|
+
/* @__PURE__ */ P("div", {
|
|
201
201
|
className: "flex flex-col",
|
|
202
|
-
children:
|
|
203
|
-
onClick: () =>
|
|
202
|
+
children: fe.map((e) => /* @__PURE__ */ P(w, {
|
|
203
|
+
onClick: () => b({ expr: e.code }),
|
|
204
204
|
rowClass: "kol-mono-10 h-6",
|
|
205
|
-
shortcut: /* @__PURE__ */
|
|
205
|
+
shortcut: /* @__PURE__ */ P("span", {
|
|
206
206
|
className: "kol-helper-10 text-meta",
|
|
207
207
|
children: e.desc
|
|
208
208
|
}),
|
|
@@ -210,62 +210,62 @@ function pe({ layer: e, param: r, setProp: a }) {
|
|
|
210
210
|
}, e.code))
|
|
211
211
|
})
|
|
212
212
|
] }),
|
|
213
|
-
|
|
214
|
-
label:
|
|
215
|
-
children: /* @__PURE__ */
|
|
213
|
+
re && /* @__PURE__ */ P(C, {
|
|
214
|
+
label: g?.cc == null ? "MIDI · no CC yet" : `MIDI · CC ${g.cc}`,
|
|
215
|
+
children: /* @__PURE__ */ P(_, {
|
|
216
216
|
tone: "outline",
|
|
217
|
-
size:
|
|
218
|
-
onClick:
|
|
219
|
-
children:
|
|
217
|
+
size: l,
|
|
218
|
+
onClick: T,
|
|
219
|
+
children: f ? "Move a knob…" : "Learn"
|
|
220
220
|
})
|
|
221
221
|
}),
|
|
222
|
-
|
|
223
|
-
label:
|
|
224
|
-
children: /* @__PURE__ */
|
|
222
|
+
v && /* @__PURE__ */ P(C, {
|
|
223
|
+
label: o(h)?.label ?? "Gamepad",
|
|
224
|
+
children: /* @__PURE__ */ P(_, {
|
|
225
225
|
tone: "outline",
|
|
226
|
-
size:
|
|
227
|
-
onClick:
|
|
228
|
-
children:
|
|
226
|
+
size: l,
|
|
227
|
+
onClick: E,
|
|
228
|
+
children: te ? "Move a control…" : "Learn"
|
|
229
229
|
})
|
|
230
230
|
})
|
|
231
231
|
]
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
let i = (
|
|
236
|
-
let r =
|
|
237
|
-
return
|
|
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";
|
|
238
238
|
});
|
|
239
|
-
return i.length === 0 ? null : /* @__PURE__ */
|
|
239
|
+
return i.length === 0 ? null : /* @__PURE__ */ F("div", {
|
|
240
240
|
className: "flex flex-col gap-4",
|
|
241
|
-
children: [/* @__PURE__ */
|
|
241
|
+
children: [/* @__PURE__ */ P("span", {
|
|
242
242
|
className: "kol-eyebrow text-fg-80",
|
|
243
243
|
children: "Modulation"
|
|
244
|
-
}), i.map((
|
|
245
|
-
let n =
|
|
246
|
-
return /* @__PURE__ */
|
|
244
|
+
}), i.map((e) => {
|
|
245
|
+
let n = o(t[e.key].source);
|
|
246
|
+
return /* @__PURE__ */ F("div", {
|
|
247
247
|
className: "flex flex-col gap-2 pt-3 border-t border-oq-08",
|
|
248
|
-
children: [/* @__PURE__ */
|
|
248
|
+
children: [/* @__PURE__ */ F("div", {
|
|
249
249
|
className: "flex items-center justify-between",
|
|
250
|
-
children: [/* @__PURE__ */
|
|
250
|
+
children: [/* @__PURE__ */ P("span", {
|
|
251
251
|
className: "kol-helper-12 text-emphasis",
|
|
252
|
-
children:
|
|
253
|
-
}), /* @__PURE__ */
|
|
252
|
+
children: e.label ?? e.key
|
|
253
|
+
}), /* @__PURE__ */ P("span", {
|
|
254
254
|
className: "kol-helper-10 text-meta",
|
|
255
|
-
children: n?.label ?? e
|
|
255
|
+
children: n?.label ?? t[e.key].source
|
|
256
256
|
})]
|
|
257
|
-
}), /* @__PURE__ */
|
|
258
|
-
layer:
|
|
259
|
-
param:
|
|
257
|
+
}), /* @__PURE__ */ P(me, {
|
|
258
|
+
layer: t,
|
|
259
|
+
param: e,
|
|
260
260
|
setProp: r
|
|
261
261
|
})]
|
|
262
|
-
},
|
|
262
|
+
}, e.key);
|
|
263
263
|
})]
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/editor/modes/pattern/RuleRow.jsx
|
|
268
|
-
var
|
|
268
|
+
var R = [
|
|
269
269
|
{
|
|
270
270
|
value: "all",
|
|
271
271
|
label: "All cells"
|
|
@@ -294,7 +294,7 @@ var z = [
|
|
|
294
294
|
value: "expression",
|
|
295
295
|
label: "Expression…"
|
|
296
296
|
}
|
|
297
|
-
],
|
|
297
|
+
], z = [
|
|
298
298
|
{
|
|
299
299
|
value: 0,
|
|
300
300
|
label: "0°"
|
|
@@ -311,19 +311,19 @@ var z = [
|
|
|
311
311
|
value: 270,
|
|
312
312
|
label: "270°"
|
|
313
313
|
}
|
|
314
|
-
],
|
|
314
|
+
], ge = [
|
|
315
315
|
"every-col",
|
|
316
316
|
"every-row",
|
|
317
317
|
"both",
|
|
318
318
|
"every-nth",
|
|
319
319
|
"checker"
|
|
320
|
-
],
|
|
320
|
+
], _e = [
|
|
321
321
|
0,
|
|
322
322
|
90,
|
|
323
323
|
180,
|
|
324
324
|
270
|
|
325
|
-
],
|
|
326
|
-
id:
|
|
325
|
+
], ve = 1, ye = () => `r${ve++}`, be = () => ({
|
|
326
|
+
id: ye(),
|
|
327
327
|
selectKind: "every-col",
|
|
328
328
|
n: 2,
|
|
329
329
|
offset: 0,
|
|
@@ -337,9 +337,9 @@ var z = [
|
|
|
337
337
|
flipV: !1,
|
|
338
338
|
hide: !1,
|
|
339
339
|
opacity: 1
|
|
340
|
-
}),
|
|
341
|
-
id:
|
|
342
|
-
selectKind:
|
|
340
|
+
}), xe = (e) => e[Math.floor(Math.random() * e.length)], Se = () => ({
|
|
341
|
+
id: ye(),
|
|
342
|
+
selectKind: xe(ge),
|
|
343
343
|
n: Math.floor(Math.random() * 5) + 2,
|
|
344
344
|
offset: Math.floor(Math.random() * 3),
|
|
345
345
|
n2: Math.floor(Math.random() * 5) + 2,
|
|
@@ -347,14 +347,14 @@ var z = [
|
|
|
347
347
|
expression: "sin(col * 0.6) + cos(row * 0.6)",
|
|
348
348
|
groupW: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
349
349
|
groupH: Math.random() > .6 ? Math.floor(Math.random() * 3) + 1 : 1,
|
|
350
|
-
rotate:
|
|
350
|
+
rotate: xe(_e),
|
|
351
351
|
flipH: Math.random() > .6,
|
|
352
352
|
flipV: Math.random() > .6,
|
|
353
353
|
hide: Math.random() > .85,
|
|
354
354
|
opacity: Math.random() > .7 ? .4 + Math.random() * .6 : 1
|
|
355
355
|
});
|
|
356
|
-
function
|
|
357
|
-
return /* @__PURE__ */
|
|
356
|
+
function B({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
357
|
+
return /* @__PURE__ */ P(O, {
|
|
358
358
|
size: "sm",
|
|
359
359
|
value: e,
|
|
360
360
|
min: n,
|
|
@@ -363,10 +363,10 @@ function V({ value: e, onChange: t, min: n = 0, max: r = 99 }) {
|
|
|
363
363
|
className: "w-full"
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
return /* @__PURE__ */
|
|
366
|
+
function Ce({ active: e, onClick: t, children: n, title: r }) {
|
|
367
|
+
return /* @__PURE__ */ P(k, {
|
|
368
368
|
label: r,
|
|
369
|
-
children: /* @__PURE__ */
|
|
369
|
+
children: /* @__PURE__ */ P(_, {
|
|
370
370
|
"aria-label": r,
|
|
371
371
|
tone: e ? "primary" : "outline",
|
|
372
372
|
size: "sm",
|
|
@@ -376,31 +376,31 @@ function Se({ active: e, onClick: t, children: n, title: r }) {
|
|
|
376
376
|
})
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function we({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
380
380
|
let i = (n) => t({
|
|
381
381
|
...e,
|
|
382
382
|
...n
|
|
383
383
|
}), a = e.selectKind === "every-col" || e.selectKind === "every-row" || e.selectKind === "every-nth" || e.selectKind === "both", o = e.selectKind === "both", s = e.selectKind === "expression";
|
|
384
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ F("div", {
|
|
385
385
|
className: "flex flex-col gap-2 p-2 border border-oq-08 rounded",
|
|
386
386
|
children: [
|
|
387
|
-
/* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ F("div", {
|
|
388
388
|
className: "flex items-center gap-2",
|
|
389
389
|
children: [
|
|
390
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ P("div", {
|
|
391
391
|
className: "flex-1 min-w-0",
|
|
392
|
-
children: /* @__PURE__ */
|
|
392
|
+
children: /* @__PURE__ */ P(y, {
|
|
393
393
|
variant: "subtle",
|
|
394
394
|
size: "sm",
|
|
395
395
|
className: "w-full",
|
|
396
|
-
options:
|
|
396
|
+
options: R,
|
|
397
397
|
value: e.selectKind,
|
|
398
398
|
onChange: (e) => i({ selectKind: e })
|
|
399
399
|
})
|
|
400
400
|
}),
|
|
401
|
-
/* @__PURE__ */
|
|
401
|
+
/* @__PURE__ */ P(k, {
|
|
402
402
|
label: "Re-randomize this rule",
|
|
403
|
-
children: /* @__PURE__ */
|
|
403
|
+
children: /* @__PURE__ */ P(_, {
|
|
404
404
|
tone: "ghost",
|
|
405
405
|
size: "sm",
|
|
406
406
|
iconOnly: "refresh",
|
|
@@ -411,9 +411,9 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
411
411
|
style: { padding: 6 }
|
|
412
412
|
})
|
|
413
413
|
}),
|
|
414
|
-
/* @__PURE__ */
|
|
414
|
+
/* @__PURE__ */ P(k, {
|
|
415
415
|
label: "Delete rule",
|
|
416
|
-
children: /* @__PURE__ */
|
|
416
|
+
children: /* @__PURE__ */ P(_, {
|
|
417
417
|
tone: "ghost",
|
|
418
418
|
size: "sm",
|
|
419
419
|
iconOnly: "x",
|
|
@@ -426,95 +426,95 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
426
426
|
})
|
|
427
427
|
]
|
|
428
428
|
}),
|
|
429
|
-
a && /* @__PURE__ */
|
|
429
|
+
a && /* @__PURE__ */ F("div", {
|
|
430
430
|
className: "grid grid-cols-2 gap-2",
|
|
431
|
-
children: [/* @__PURE__ */
|
|
431
|
+
children: [/* @__PURE__ */ P(E, {
|
|
432
432
|
label: "N",
|
|
433
|
-
children: /* @__PURE__ */
|
|
433
|
+
children: /* @__PURE__ */ P(B, {
|
|
434
434
|
value: e.n,
|
|
435
435
|
onChange: (e) => i({ n: e }),
|
|
436
436
|
min: 1
|
|
437
437
|
})
|
|
438
|
-
}), /* @__PURE__ */
|
|
438
|
+
}), /* @__PURE__ */ P(E, {
|
|
439
439
|
label: "Offset",
|
|
440
|
-
children: /* @__PURE__ */
|
|
440
|
+
children: /* @__PURE__ */ P(B, {
|
|
441
441
|
value: e.offset,
|
|
442
442
|
onChange: (e) => i({ offset: e })
|
|
443
443
|
})
|
|
444
444
|
})]
|
|
445
445
|
}),
|
|
446
|
-
o && /* @__PURE__ */
|
|
446
|
+
o && /* @__PURE__ */ F("div", {
|
|
447
447
|
className: "grid grid-cols-2 gap-2",
|
|
448
|
-
children: [/* @__PURE__ */
|
|
448
|
+
children: [/* @__PURE__ */ P(E, {
|
|
449
449
|
label: "Row N",
|
|
450
|
-
children: /* @__PURE__ */
|
|
450
|
+
children: /* @__PURE__ */ P(B, {
|
|
451
451
|
value: e.n2,
|
|
452
452
|
onChange: (e) => i({ n2: e }),
|
|
453
453
|
min: 1
|
|
454
454
|
})
|
|
455
|
-
}), /* @__PURE__ */
|
|
455
|
+
}), /* @__PURE__ */ P(E, {
|
|
456
456
|
label: "Row offset",
|
|
457
|
-
children: /* @__PURE__ */
|
|
457
|
+
children: /* @__PURE__ */ P(B, {
|
|
458
458
|
value: e.offset2,
|
|
459
459
|
onChange: (e) => i({ offset2: e })
|
|
460
460
|
})
|
|
461
461
|
})]
|
|
462
462
|
}),
|
|
463
|
-
s && /* @__PURE__ */
|
|
463
|
+
s && /* @__PURE__ */ F(E, {
|
|
464
464
|
label: "Expression",
|
|
465
465
|
hint: "matches when > 0",
|
|
466
|
-
children: [/* @__PURE__ */
|
|
466
|
+
children: [/* @__PURE__ */ P(S, {
|
|
467
467
|
variant: "filled",
|
|
468
468
|
size: "sm",
|
|
469
469
|
value: e.expression,
|
|
470
470
|
onChange: (e) => i({ expression: e.target.value }),
|
|
471
471
|
placeholder: "sin(col * 0.6) + cos(row * 0.6)"
|
|
472
|
-
}), /* @__PURE__ */
|
|
472
|
+
}), /* @__PURE__ */ P("span", {
|
|
473
473
|
className: "kol-mono-10 text-subtle mt-1",
|
|
474
474
|
children: "vars: i, col, row, cols, rows · Math.* in scope"
|
|
475
475
|
})]
|
|
476
476
|
}),
|
|
477
|
-
/* @__PURE__ */
|
|
477
|
+
/* @__PURE__ */ F("div", {
|
|
478
478
|
className: "grid grid-cols-2 gap-2",
|
|
479
|
-
children: [/* @__PURE__ */
|
|
479
|
+
children: [/* @__PURE__ */ P(E, {
|
|
480
480
|
label: "Group W",
|
|
481
|
-
children: /* @__PURE__ */
|
|
481
|
+
children: /* @__PURE__ */ P(B, {
|
|
482
482
|
value: e.groupW,
|
|
483
483
|
onChange: (e) => i({ groupW: Math.max(1, e) }),
|
|
484
484
|
min: 1
|
|
485
485
|
})
|
|
486
|
-
}), /* @__PURE__ */
|
|
486
|
+
}), /* @__PURE__ */ P(E, {
|
|
487
487
|
label: "Group H",
|
|
488
|
-
children: /* @__PURE__ */
|
|
488
|
+
children: /* @__PURE__ */ P(B, {
|
|
489
489
|
value: e.groupH,
|
|
490
490
|
onChange: (e) => i({ groupH: Math.max(1, e) }),
|
|
491
491
|
min: 1
|
|
492
492
|
})
|
|
493
493
|
})]
|
|
494
494
|
}),
|
|
495
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ F("div", {
|
|
496
496
|
className: "flex flex-wrap gap-1",
|
|
497
497
|
children: [
|
|
498
|
-
/* @__PURE__ */
|
|
498
|
+
/* @__PURE__ */ P(y, {
|
|
499
499
|
variant: "subtle",
|
|
500
500
|
size: "sm",
|
|
501
|
-
options:
|
|
501
|
+
options: z,
|
|
502
502
|
value: e.rotate,
|
|
503
503
|
onChange: (e) => i({ rotate: Number(e) })
|
|
504
504
|
}),
|
|
505
|
-
/* @__PURE__ */
|
|
505
|
+
/* @__PURE__ */ P(Ce, {
|
|
506
506
|
active: e.flipH,
|
|
507
507
|
onClick: () => i({ flipH: !e.flipH }),
|
|
508
508
|
title: "Flip horizontal",
|
|
509
509
|
children: "⇋"
|
|
510
510
|
}),
|
|
511
|
-
/* @__PURE__ */
|
|
511
|
+
/* @__PURE__ */ P(Ce, {
|
|
512
512
|
active: e.flipV,
|
|
513
513
|
onClick: () => i({ flipV: !e.flipV }),
|
|
514
514
|
title: "Flip vertical",
|
|
515
515
|
children: "⇵"
|
|
516
516
|
}),
|
|
517
|
-
/* @__PURE__ */
|
|
517
|
+
/* @__PURE__ */ P(Ce, {
|
|
518
518
|
active: e.hide,
|
|
519
519
|
onClick: () => i({ hide: !e.hide }),
|
|
520
520
|
title: "Hide cell",
|
|
@@ -522,10 +522,10 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
522
522
|
})
|
|
523
523
|
]
|
|
524
524
|
}),
|
|
525
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ P(E, {
|
|
526
526
|
label: "Opacity",
|
|
527
527
|
hint: `${Math.round(e.opacity * 100)}%`,
|
|
528
|
-
children: /* @__PURE__ */
|
|
528
|
+
children: /* @__PURE__ */ P(D, {
|
|
529
529
|
min: 0,
|
|
530
530
|
max: 100,
|
|
531
531
|
value: Math.round(e.opacity * 100),
|
|
@@ -537,8 +537,8 @@ function Ce({ rule: e, onChange: t, onRemove: n, onReroll: r }) {
|
|
|
537
537
|
}
|
|
538
538
|
//#endregion
|
|
539
539
|
//#region src/editor/library/mergeRemote.js
|
|
540
|
-
var
|
|
541
|
-
function
|
|
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) {
|
|
542
542
|
let n = {}, r = [], i = /* @__PURE__ */ new Map();
|
|
543
543
|
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
544
|
let a = new Set([...Object.keys(e || {}), ...i.keys()]);
|
|
@@ -550,7 +550,7 @@ function Ee(e, t) {
|
|
|
550
550
|
o.push(n);
|
|
551
551
|
continue;
|
|
552
552
|
}
|
|
553
|
-
if (
|
|
553
|
+
if (Ee(n)) {
|
|
554
554
|
s.add(n.id), e && !e.deleted && r.push({
|
|
555
555
|
op: "remove",
|
|
556
556
|
kind: t,
|
|
@@ -567,7 +567,7 @@ function Ee(e, t) {
|
|
|
567
567
|
continue;
|
|
568
568
|
}
|
|
569
569
|
if (e.deleted) {
|
|
570
|
-
if (e.updatedAt >
|
|
570
|
+
if (e.updatedAt > Te(n)) continue;
|
|
571
571
|
o.push(n), r.push({
|
|
572
572
|
op: "put",
|
|
573
573
|
kind: t,
|
|
@@ -575,7 +575,7 @@ function Ee(e, t) {
|
|
|
575
575
|
});
|
|
576
576
|
continue;
|
|
577
577
|
}
|
|
578
|
-
e.updatedAt >
|
|
578
|
+
e.updatedAt > Te(n) ? o.push(e.spec) : (o.push(n), e.updatedAt < Te(n) && r.push({
|
|
579
579
|
op: "put",
|
|
580
580
|
kind: t,
|
|
581
581
|
item: n
|
|
@@ -583,7 +583,7 @@ function Ee(e, t) {
|
|
|
583
583
|
}
|
|
584
584
|
let c = new Set(o.map((e) => e.id));
|
|
585
585
|
for (let e of a.values()) if (!(e.deleted || c.has(e.id) || s.has(e.id))) {
|
|
586
|
-
if (
|
|
586
|
+
if (Ee(e.spec)) {
|
|
587
587
|
r.push({
|
|
588
588
|
op: "remove",
|
|
589
589
|
kind: t,
|
|
@@ -602,19 +602,19 @@ function Ee(e, t) {
|
|
|
602
602
|
}
|
|
603
603
|
//#endregion
|
|
604
604
|
//#region src/editor/library/libraryApi.js
|
|
605
|
-
var
|
|
606
|
-
function
|
|
607
|
-
|
|
605
|
+
var V = null;
|
|
606
|
+
function Oe(e) {
|
|
607
|
+
V = typeof e == "string" && e.trim() ? e.trim().replace(/\/+$/, "") : null, Re();
|
|
608
608
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
609
|
+
function ke() {
|
|
610
|
+
return V;
|
|
611
611
|
}
|
|
612
|
-
var
|
|
612
|
+
var H = class extends Error {
|
|
613
613
|
constructor() {
|
|
614
614
|
super("unauthorized"), this.name = "UnauthorizedError";
|
|
615
615
|
}
|
|
616
616
|
};
|
|
617
|
-
function
|
|
617
|
+
function Ae(e, t) {
|
|
618
618
|
let n = `Bearer ${t}`, r = async (t, r = {}) => {
|
|
619
619
|
let i = await fetch(`${e}${t}`, {
|
|
620
620
|
...r,
|
|
@@ -624,7 +624,7 @@ function ke(e, t) {
|
|
|
624
624
|
...r.headers || {}
|
|
625
625
|
}
|
|
626
626
|
});
|
|
627
|
-
if (i.status === 401) throw new
|
|
627
|
+
if (i.status === 401) throw new H();
|
|
628
628
|
if (!i.ok) throw Error(`library api ${i.status}`);
|
|
629
629
|
return i.json();
|
|
630
630
|
};
|
|
@@ -648,33 +648,33 @@ function ke(e, t) {
|
|
|
648
648
|
}
|
|
649
649
|
};
|
|
650
650
|
}
|
|
651
|
-
var
|
|
652
|
-
function
|
|
653
|
-
return
|
|
651
|
+
var je = "kol.fxr.library-session", U = null, Me = /* @__PURE__ */ new Set(), W = () => Me.forEach((e) => e());
|
|
652
|
+
function Ne() {
|
|
653
|
+
return U;
|
|
654
654
|
}
|
|
655
|
-
var
|
|
656
|
-
function
|
|
655
|
+
var Pe = () => N((e) => (Me.add(e), () => Me.delete(e)), Ne, Ne), Fe = () => Pe()?.user ?? null;
|
|
656
|
+
function G(e) {
|
|
657
657
|
try {
|
|
658
|
-
e ? localStorage.setItem(
|
|
658
|
+
e ? localStorage.setItem(je, JSON.stringify(e)) : localStorage.removeItem(je);
|
|
659
659
|
} catch {}
|
|
660
660
|
}
|
|
661
|
-
var
|
|
661
|
+
var Ie = () => {
|
|
662
662
|
try {
|
|
663
|
-
return JSON.parse(localStorage.getItem(
|
|
663
|
+
return JSON.parse(localStorage.getItem(je) || "null");
|
|
664
664
|
} catch {
|
|
665
665
|
return null;
|
|
666
666
|
}
|
|
667
667
|
};
|
|
668
|
-
function
|
|
669
|
-
let { next: n, pushes: r } =
|
|
670
|
-
|
|
671
|
-
...
|
|
668
|
+
function Le(e, t) {
|
|
669
|
+
let { next: n, pushes: r } = De(Z(), t);
|
|
670
|
+
lt({
|
|
671
|
+
...Z(),
|
|
672
672
|
...n
|
|
673
673
|
});
|
|
674
674
|
for (let t of r) e.push(t).catch(() => {});
|
|
675
675
|
}
|
|
676
|
-
async function
|
|
677
|
-
let r = await fetch(`${
|
|
676
|
+
async function K(e, t = {}, n) {
|
|
677
|
+
let r = await fetch(`${V}${e}`, {
|
|
678
678
|
...t,
|
|
679
679
|
headers: {
|
|
680
680
|
"content-type": "application/json",
|
|
@@ -682,50 +682,50 @@ async function q(e, t = {}, n) {
|
|
|
682
682
|
...t.headers || {}
|
|
683
683
|
}
|
|
684
684
|
});
|
|
685
|
-
if (r.status === 401) throw new
|
|
685
|
+
if (r.status === 401) throw new H();
|
|
686
686
|
let i = await r.json().catch(() => ({}));
|
|
687
687
|
if (!r.ok) throw Error(i.error || `library api ${r.status}`);
|
|
688
688
|
return i;
|
|
689
689
|
}
|
|
690
|
-
function
|
|
691
|
-
if (
|
|
692
|
-
let e =
|
|
693
|
-
if (!e?.token || e.base !==
|
|
694
|
-
let t =
|
|
695
|
-
|
|
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 = {
|
|
696
696
|
backend: t,
|
|
697
697
|
user: e.user,
|
|
698
698
|
token: e.token
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
...
|
|
699
|
+
}, W(), K("/api/me", {}, e.token).then(({ user: t }) => {
|
|
700
|
+
U?.token === e.token && (U = {
|
|
701
|
+
...U,
|
|
702
702
|
user: t
|
|
703
|
-
},
|
|
703
|
+
}, G({
|
|
704
704
|
...e,
|
|
705
705
|
user: t
|
|
706
|
-
}),
|
|
706
|
+
}), W());
|
|
707
707
|
}).catch((e) => {
|
|
708
|
-
e instanceof
|
|
709
|
-
}), t.hydrate().then((e) =>
|
|
710
|
-
e instanceof
|
|
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);
|
|
711
711
|
});
|
|
712
712
|
}
|
|
713
|
-
async function
|
|
714
|
-
let r =
|
|
715
|
-
return
|
|
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 = {
|
|
716
716
|
backend: r,
|
|
717
717
|
user: n,
|
|
718
718
|
token: e
|
|
719
|
-
},
|
|
720
|
-
base:
|
|
719
|
+
}, G({
|
|
720
|
+
base: V,
|
|
721
721
|
token: e,
|
|
722
722
|
expiresAt: t,
|
|
723
723
|
user: n
|
|
724
|
-
}),
|
|
724
|
+
}), W(), i.filter((e) => !e.deleted).length;
|
|
725
725
|
}
|
|
726
|
-
async function
|
|
727
|
-
if (!
|
|
728
|
-
return
|
|
726
|
+
async function Be({ email: e, password: t } = {}) {
|
|
727
|
+
if (!V) throw Error("no library api");
|
|
728
|
+
return ze(await K("/api/auth/signin", {
|
|
729
729
|
method: "POST",
|
|
730
730
|
body: JSON.stringify({
|
|
731
731
|
email: e,
|
|
@@ -733,48 +733,48 @@ async function ze({ email: e, password: t } = {}) {
|
|
|
733
733
|
})
|
|
734
734
|
}));
|
|
735
735
|
}
|
|
736
|
-
async function
|
|
737
|
-
if (!
|
|
738
|
-
return
|
|
736
|
+
async function Ve(e) {
|
|
737
|
+
if (!V) throw Error("no library api");
|
|
738
|
+
return ze(await K("/api/auth/signup", {
|
|
739
739
|
method: "POST",
|
|
740
740
|
body: JSON.stringify(e)
|
|
741
741
|
}));
|
|
742
742
|
}
|
|
743
|
-
function
|
|
744
|
-
let e =
|
|
745
|
-
|
|
743
|
+
function q() {
|
|
744
|
+
let e = U?.token ?? Ie()?.token;
|
|
745
|
+
G(null), e && V && K("/api/auth/signout", {
|
|
746
746
|
method: "POST",
|
|
747
747
|
body: "{}"
|
|
748
|
-
}, e).catch(() => {}),
|
|
748
|
+
}, e).catch(() => {}), U && (U = null, W());
|
|
749
749
|
}
|
|
750
|
-
async function
|
|
751
|
-
if (!
|
|
752
|
-
let { user: t } = await
|
|
750
|
+
async function He(e) {
|
|
751
|
+
if (!U) throw new H();
|
|
752
|
+
let { user: t } = await K("/api/me", {
|
|
753
753
|
method: "PATCH",
|
|
754
754
|
body: JSON.stringify(e)
|
|
755
|
-
},
|
|
756
|
-
return
|
|
757
|
-
...
|
|
755
|
+
}, U.token);
|
|
756
|
+
return U = {
|
|
757
|
+
...U,
|
|
758
758
|
user: t
|
|
759
|
-
},
|
|
760
|
-
...
|
|
759
|
+
}, G({
|
|
760
|
+
...Ie(),
|
|
761
761
|
user: t
|
|
762
|
-
}),
|
|
762
|
+
}), W(), t;
|
|
763
763
|
}
|
|
764
|
-
async function
|
|
765
|
-
if (!
|
|
766
|
-
let { token: e, expiresAt: t } = await
|
|
764
|
+
async function Ue() {
|
|
765
|
+
if (!U) throw new H();
|
|
766
|
+
let { token: e, expiresAt: t } = await K("/api/invites", {
|
|
767
767
|
method: "POST",
|
|
768
768
|
body: "{}"
|
|
769
|
-
},
|
|
769
|
+
}, U.token);
|
|
770
770
|
return {
|
|
771
771
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(e)}`,
|
|
772
772
|
expiresAt: t
|
|
773
773
|
};
|
|
774
774
|
}
|
|
775
|
-
async function
|
|
776
|
-
if (!
|
|
777
|
-
return
|
|
775
|
+
async function We({ name: e, email: t }) {
|
|
776
|
+
if (!V) throw Error("no library api");
|
|
777
|
+
return K("/api/invite-requests", {
|
|
778
778
|
method: "POST",
|
|
779
779
|
body: JSON.stringify({
|
|
780
780
|
name: e,
|
|
@@ -782,16 +782,16 @@ async function Ue({ name: e, email: t }) {
|
|
|
782
782
|
})
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
|
-
async function
|
|
786
|
-
if (!
|
|
787
|
-
return (await
|
|
785
|
+
async function Ge() {
|
|
786
|
+
if (!U) throw new H();
|
|
787
|
+
return (await K("/api/invite-requests", {}, U.token)).requests;
|
|
788
788
|
}
|
|
789
|
-
async function
|
|
790
|
-
if (!
|
|
791
|
-
let { token: t, expiresAt: n, email: r, name: i } = await
|
|
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`, {
|
|
792
792
|
method: "POST",
|
|
793
793
|
body: "{}"
|
|
794
|
-
},
|
|
794
|
+
}, U.token);
|
|
795
795
|
return {
|
|
796
796
|
url: `${window.location.origin}/join?invite=${encodeURIComponent(t)}`,
|
|
797
797
|
expiresAt: n,
|
|
@@ -801,17 +801,17 @@ async function Ge(e) {
|
|
|
801
801
|
}
|
|
802
802
|
//#endregion
|
|
803
803
|
//#region src/editor/library/LibraryProvider.jsx
|
|
804
|
-
var
|
|
804
|
+
var qe = "kol.editor.library.v3", J = [
|
|
805
805
|
"palette",
|
|
806
806
|
"pattern",
|
|
807
807
|
"type",
|
|
808
808
|
"preset"
|
|
809
|
-
],
|
|
809
|
+
], Y = J.reduce((e, t) => (e[t] = [], e), {}), Je = 1, Ye = () => `i${Date.now().toString(36)}-${Je++}`, Xe = (e) => ({
|
|
810
810
|
...e,
|
|
811
|
-
id: e.id ??
|
|
811
|
+
id: e.id ?? Ye(),
|
|
812
812
|
savedAt: e.savedAt ?? Date.now()
|
|
813
|
-
}),
|
|
814
|
-
function
|
|
813
|
+
}), X = (e) => typeof e == "number" && Number.isFinite(e);
|
|
814
|
+
function Ze(e) {
|
|
815
815
|
return !e || !Array.isArray(e.colors) || e.colors.length === 0 ? null : {
|
|
816
816
|
colors: e.colors,
|
|
817
817
|
bgEnabled: !!e.bgEnabled,
|
|
@@ -819,39 +819,39 @@ function Xe(e) {
|
|
|
819
819
|
modeId: e.modeId ?? "random"
|
|
820
820
|
};
|
|
821
821
|
}
|
|
822
|
-
function
|
|
822
|
+
function Qe(e) {
|
|
823
823
|
return !e || typeof e.shapeId != "string" || e.shapeId === "type-composition" ? null : {
|
|
824
824
|
shapeId: e.shapeId,
|
|
825
825
|
customSvg: typeof e.customSvg == "string" ? e.customSvg : "",
|
|
826
|
-
cols:
|
|
827
|
-
rows:
|
|
828
|
-
gap:
|
|
829
|
-
padding:
|
|
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,
|
|
830
830
|
stretch: !!e.stretch,
|
|
831
831
|
overflow: !!e.overflow,
|
|
832
832
|
bg: e.bg ?? null,
|
|
833
833
|
color: e.color ?? "palette:secondary",
|
|
834
834
|
rules: Array.isArray(e.rules) ? e.rules : [],
|
|
835
|
-
scale:
|
|
835
|
+
scale: X(e.scale) ? e.scale : 256
|
|
836
836
|
};
|
|
837
837
|
}
|
|
838
|
-
function
|
|
838
|
+
function $e(e) {
|
|
839
839
|
if (!e || typeof e.text != "string") return null;
|
|
840
840
|
let t = {
|
|
841
841
|
text: e.text,
|
|
842
842
|
width: e.width ?? "Tight",
|
|
843
|
-
weight:
|
|
843
|
+
weight: X(e.weight) ? e.weight : 600,
|
|
844
844
|
italic: !!e.italic,
|
|
845
|
-
size:
|
|
846
|
-
tracking:
|
|
847
|
-
lineHeight:
|
|
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,
|
|
848
848
|
case: e.case ?? "original",
|
|
849
849
|
color: e.color ?? "palette:dark",
|
|
850
850
|
textAlign: e.textAlign ?? "center"
|
|
851
851
|
};
|
|
852
852
|
return e.axisOn !== void 0 && (t.axisOn = e.axisOn, t.width2 = e.width2, t.weight2 = e.weight2, t.blend = e.blend), t;
|
|
853
853
|
}
|
|
854
|
-
function
|
|
854
|
+
function et(e) {
|
|
855
855
|
return !e || !Array.isArray(e.layers) ? null : {
|
|
856
856
|
intent: e.intent ?? "whole",
|
|
857
857
|
aspect: e.aspect ?? "1:1",
|
|
@@ -869,38 +869,38 @@ function $e(e) {
|
|
|
869
869
|
...typeof e.sub == "string" ? { sub: e.sub } : {}
|
|
870
870
|
};
|
|
871
871
|
}
|
|
872
|
-
var
|
|
873
|
-
palette:
|
|
874
|
-
pattern:
|
|
875
|
-
type:
|
|
876
|
-
preset:
|
|
877
|
-
},
|
|
872
|
+
var tt = {
|
|
873
|
+
palette: Ze,
|
|
874
|
+
pattern: Qe,
|
|
875
|
+
type: $e,
|
|
876
|
+
preset: et
|
|
877
|
+
}, nt = [
|
|
878
878
|
"id",
|
|
879
879
|
"savedAt",
|
|
880
880
|
"updatedAt",
|
|
881
881
|
"name"
|
|
882
882
|
];
|
|
883
|
-
function
|
|
883
|
+
function rt(e) {
|
|
884
884
|
let t = {};
|
|
885
|
-
for (let n of
|
|
885
|
+
for (let n of nt) e?.[n] !== void 0 && (t[n] = e[n]);
|
|
886
886
|
return t;
|
|
887
887
|
}
|
|
888
|
-
function
|
|
889
|
-
let t =
|
|
890
|
-
for (let n of
|
|
891
|
-
let r =
|
|
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];
|
|
892
892
|
t[n] = (Array.isArray(e?.[n]) ? e[n] : []).map((e) => {
|
|
893
893
|
let t = r ? r(e) : e;
|
|
894
894
|
return t ? {
|
|
895
895
|
v: 1,
|
|
896
|
-
...
|
|
896
|
+
...rt(e),
|
|
897
897
|
...t
|
|
898
898
|
} : null;
|
|
899
899
|
}).filter(Boolean);
|
|
900
900
|
}
|
|
901
901
|
return t;
|
|
902
902
|
}
|
|
903
|
-
function
|
|
903
|
+
function at(e) {
|
|
904
904
|
return Array.isArray(e) ? e.map((e) => e?.type ? e.type === "bg" ? {
|
|
905
905
|
...e,
|
|
906
906
|
type: "background"
|
|
@@ -913,7 +913,7 @@ function it(e) {
|
|
|
913
913
|
kind: "logo"
|
|
914
914
|
} : e : e) : e;
|
|
915
915
|
}
|
|
916
|
-
function
|
|
916
|
+
function ot(e) {
|
|
917
917
|
let t = {};
|
|
918
918
|
for (let n of [
|
|
919
919
|
"palette",
|
|
@@ -924,37 +924,37 @@ function at(e) {
|
|
|
924
924
|
"composition"
|
|
925
925
|
]) {
|
|
926
926
|
let r = e?.[n];
|
|
927
|
-
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [
|
|
927
|
+
Array.isArray(r) ? t[n] = r : r && typeof r == "object" ? t[n] = [Xe(r)] : t[n] = [];
|
|
928
928
|
}
|
|
929
929
|
return t;
|
|
930
930
|
}
|
|
931
|
-
function
|
|
932
|
-
let t =
|
|
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)] : [];
|
|
933
933
|
t.palette = n(e?.palette), t.pattern = n(e?.pattern), t.type = n(e?.type);
|
|
934
934
|
let r = n(e?.layout), i = n(e?.composition).map((e) => ({
|
|
935
935
|
...e,
|
|
936
|
-
layers:
|
|
936
|
+
layers: at(e.layers)
|
|
937
937
|
}));
|
|
938
938
|
return t.preset = [...r, ...i], t;
|
|
939
939
|
}
|
|
940
|
-
function
|
|
941
|
-
if (typeof window > "u") return
|
|
940
|
+
function Z() {
|
|
941
|
+
if (typeof window > "u") return Y;
|
|
942
942
|
try {
|
|
943
|
-
let e = window.localStorage.getItem(
|
|
944
|
-
if (e) return
|
|
943
|
+
let e = window.localStorage.getItem(qe);
|
|
944
|
+
if (e) return it(JSON.parse(e));
|
|
945
945
|
let t = window.localStorage.getItem("kol.generator.library.v2");
|
|
946
|
-
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t),
|
|
946
|
+
if (t) return window.localStorage.setItem("kol.generator.library.v2._backup", t), it(st(JSON.parse(t)));
|
|
947
947
|
let n = window.localStorage.getItem("kol.generator.library.v1");
|
|
948
|
-
return n ?
|
|
948
|
+
return n ? it(st(ot(JSON.parse(n)))) : Y;
|
|
949
949
|
} catch {
|
|
950
|
-
return
|
|
950
|
+
return Y;
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
-
var
|
|
954
|
-
function
|
|
953
|
+
var ct = (e) => e?.item?.shipped === !0 || String(e?.id ?? e?.item?.id ?? "").startsWith("ship:");
|
|
954
|
+
function lt(e) {
|
|
955
955
|
if (!(typeof window > "u")) {
|
|
956
956
|
try {
|
|
957
|
-
window.localStorage.setItem(
|
|
957
|
+
window.localStorage.setItem(qe, JSON.stringify(e));
|
|
958
958
|
} catch (e) {
|
|
959
959
|
console.warn("library: could not save to this browser —", e?.message || e);
|
|
960
960
|
return;
|
|
@@ -962,23 +962,23 @@ function ct(e) {
|
|
|
962
962
|
window.dispatchEvent(new CustomEvent("kol:library"));
|
|
963
963
|
}
|
|
964
964
|
}
|
|
965
|
-
var
|
|
965
|
+
var ut = (e) => (window.addEventListener("kol:library", e), window.addEventListener("storage", e), () => {
|
|
966
966
|
window.removeEventListener("kol:library", e), window.removeEventListener("storage", e);
|
|
967
|
-
}),
|
|
967
|
+
}), dt = () => {
|
|
968
968
|
try {
|
|
969
|
-
return window.localStorage.getItem(
|
|
969
|
+
return window.localStorage.getItem(qe);
|
|
970
970
|
} catch {
|
|
971
971
|
return null;
|
|
972
972
|
}
|
|
973
|
-
},
|
|
974
|
-
function
|
|
973
|
+
}, ft = oe(null);
|
|
974
|
+
function pt(e, t, n) {
|
|
975
975
|
return e.map((e) => e.id === t ? {
|
|
976
976
|
...e,
|
|
977
977
|
name: String(n ?? "").trim() || null,
|
|
978
978
|
updatedAt: Date.now()
|
|
979
979
|
} : e);
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function mt(e, t, n) {
|
|
982
982
|
let r = e.findIndex((e) => e.id === t);
|
|
983
983
|
if (r === -1) return e;
|
|
984
984
|
let i = e[r], a = {
|
|
@@ -993,20 +993,20 @@ function pt(e, t, n) {
|
|
|
993
993
|
...e.slice(r + 1)
|
|
994
994
|
];
|
|
995
995
|
}
|
|
996
|
-
function
|
|
997
|
-
let [t, n] =
|
|
998
|
-
|
|
999
|
-
|
|
996
|
+
function ht({ children: e }) {
|
|
997
|
+
let [t, n] = M(Z);
|
|
998
|
+
j(() => {
|
|
999
|
+
lt(t);
|
|
1000
1000
|
}, [t]);
|
|
1001
|
-
let r =
|
|
1001
|
+
let r = le(t);
|
|
1002
1002
|
r.current = t;
|
|
1003
|
-
let i =
|
|
1003
|
+
let i = le(null), [a, o] = M("off"), s = A((e) => {
|
|
1004
1004
|
let t = i.current;
|
|
1005
|
-
!t ||
|
|
1006
|
-
e instanceof
|
|
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);
|
|
1007
1007
|
});
|
|
1008
|
-
}, []), c =
|
|
1009
|
-
|
|
1008
|
+
}, []), c = Pe();
|
|
1009
|
+
j(() => {
|
|
1010
1010
|
if (!c) {
|
|
1011
1011
|
i.current = null, o("off");
|
|
1012
1012
|
return;
|
|
@@ -1014,23 +1014,23 @@ function mt({ children: e }) {
|
|
|
1014
1014
|
let e = !0;
|
|
1015
1015
|
return c.backend.hydrate().then((t) => {
|
|
1016
1016
|
if (!e) return;
|
|
1017
|
-
let { next: a, pushes: l } =
|
|
1017
|
+
let { next: a, pushes: l } = De(r.current, t);
|
|
1018
1018
|
i.current = c.backend, n({
|
|
1019
|
-
...
|
|
1019
|
+
...Y,
|
|
1020
1020
|
...a
|
|
1021
1021
|
}), o("on");
|
|
1022
1022
|
for (let e of l) s(e);
|
|
1023
1023
|
}).catch((e) => {
|
|
1024
|
-
e instanceof
|
|
1024
|
+
e instanceof H && q(), typeof console < "u" && console.warn("library sync: hydrate failed —", e?.message || e);
|
|
1025
1025
|
}), () => {
|
|
1026
1026
|
e = !1;
|
|
1027
1027
|
};
|
|
1028
1028
|
}, [c, s]);
|
|
1029
|
-
let l =
|
|
1030
|
-
if (!
|
|
1031
|
-
let r =
|
|
1029
|
+
let l = A((e, t) => {
|
|
1030
|
+
if (!J.includes(e) || !t) return null;
|
|
1031
|
+
let r = tt[e], i = r ? r(t) : t;
|
|
1032
1032
|
if (!i) return null;
|
|
1033
|
-
let a =
|
|
1033
|
+
let a = Ye(), o = {
|
|
1034
1034
|
v: 1,
|
|
1035
1035
|
id: a,
|
|
1036
1036
|
savedAt: Date.now(),
|
|
@@ -1045,7 +1045,7 @@ function mt({ children: e }) {
|
|
|
1045
1045
|
kind: e,
|
|
1046
1046
|
item: o
|
|
1047
1047
|
}), a;
|
|
1048
|
-
}, [s]), u =
|
|
1048
|
+
}, [s]), u = A((e, t) => {
|
|
1049
1049
|
n((n) => ({
|
|
1050
1050
|
...n,
|
|
1051
1051
|
[e]: (n[e] ?? []).filter((e) => e.id !== t)
|
|
@@ -1054,9 +1054,9 @@ function mt({ children: e }) {
|
|
|
1054
1054
|
kind: e,
|
|
1055
1055
|
id: t
|
|
1056
1056
|
});
|
|
1057
|
-
}, [s]), ee =
|
|
1058
|
-
if (!
|
|
1059
|
-
let a =
|
|
1057
|
+
}, [s]), ee = A((e, t, i) => {
|
|
1058
|
+
if (!J.includes(e) || !t || !i) return;
|
|
1059
|
+
let a = tt[e], o = a ? a(i) : i;
|
|
1060
1060
|
if (!o) return;
|
|
1061
1061
|
let c = Date.now(), l = (e) => ({
|
|
1062
1062
|
...e,
|
|
@@ -1076,20 +1076,20 @@ function mt({ children: e }) {
|
|
|
1076
1076
|
kind: e,
|
|
1077
1077
|
item: l(u)
|
|
1078
1078
|
});
|
|
1079
|
-
}, [s]), d =
|
|
1080
|
-
if (!
|
|
1079
|
+
}, [s]), d = A((e, t, i) => {
|
|
1080
|
+
if (!J.includes(e) || !t) return;
|
|
1081
1081
|
n((n) => ({
|
|
1082
1082
|
...n,
|
|
1083
|
-
[e]:
|
|
1083
|
+
[e]: pt(n[e] ?? [], t, i)
|
|
1084
1084
|
}));
|
|
1085
|
-
let a =
|
|
1085
|
+
let a = pt(r.current[e] ?? [], t, i).find((e) => e.id === t);
|
|
1086
1086
|
a && s({
|
|
1087
1087
|
op: "put",
|
|
1088
1088
|
kind: e,
|
|
1089
1089
|
item: a
|
|
1090
1090
|
});
|
|
1091
|
-
}, [s]), f =
|
|
1092
|
-
if (!
|
|
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;
|
|
1093
1093
|
let a = (e) => e.map((e) => e.id === t ? {
|
|
1094
1094
|
...e,
|
|
1095
1095
|
thumb: i
|
|
@@ -1104,30 +1104,30 @@ function mt({ children: e }) {
|
|
|
1104
1104
|
kind: e,
|
|
1105
1105
|
item: o
|
|
1106
1106
|
});
|
|
1107
|
-
}, [s]), p =
|
|
1108
|
-
if (!
|
|
1109
|
-
let i =
|
|
1107
|
+
}, [s]), p = A((e, t) => {
|
|
1108
|
+
if (!J.includes(e) || !t) return null;
|
|
1109
|
+
let i = Ye();
|
|
1110
1110
|
n((n) => ({
|
|
1111
1111
|
...n,
|
|
1112
|
-
[e]:
|
|
1112
|
+
[e]: mt(n[e] ?? [], t, i)
|
|
1113
1113
|
}));
|
|
1114
|
-
let a =
|
|
1114
|
+
let a = mt(r.current[e] ?? [], t, i).find((e) => e.id === i);
|
|
1115
1115
|
return a && s({
|
|
1116
1116
|
op: "put",
|
|
1117
1117
|
kind: e,
|
|
1118
1118
|
item: a
|
|
1119
1119
|
}), i;
|
|
1120
|
-
}, [s]),
|
|
1120
|
+
}, [s]), te = A((e) => {
|
|
1121
1121
|
n((t) => ({
|
|
1122
1122
|
...t,
|
|
1123
1123
|
[e]: []
|
|
1124
1124
|
}));
|
|
1125
|
-
}, []),
|
|
1126
|
-
...
|
|
1125
|
+
}, []), m = A(() => n(Y), []), h = A((e) => n({
|
|
1126
|
+
...Y,
|
|
1127
1127
|
...e
|
|
1128
|
-
}), []),
|
|
1128
|
+
}), []), g = {
|
|
1129
1129
|
library: t,
|
|
1130
|
-
selected:
|
|
1130
|
+
selected: ce(() => J.reduce((e, n) => {
|
|
1131
1131
|
let r = t[n] ?? [];
|
|
1132
1132
|
return e[n] = r.length ? r[r.length - 1] : null, e;
|
|
1133
1133
|
}, {}), [t]),
|
|
@@ -1137,24 +1137,24 @@ function mt({ children: e }) {
|
|
|
1137
1137
|
renameItem: d,
|
|
1138
1138
|
setThumb: f,
|
|
1139
1139
|
duplicateItem: p,
|
|
1140
|
-
clearSlot:
|
|
1141
|
-
clearAll:
|
|
1142
|
-
replaceAll:
|
|
1140
|
+
clearSlot: te,
|
|
1141
|
+
clearAll: m,
|
|
1142
|
+
replaceAll: h,
|
|
1143
1143
|
syncState: a,
|
|
1144
1144
|
savePalette: (e) => l("palette", e),
|
|
1145
1145
|
savePattern: (e) => l("pattern", e),
|
|
1146
1146
|
saveType: (e) => l("type", e),
|
|
1147
1147
|
savePreset: (e) => l("preset", e)
|
|
1148
1148
|
};
|
|
1149
|
-
return /* @__PURE__ */
|
|
1150
|
-
value:
|
|
1149
|
+
return /* @__PURE__ */ P(ft.Provider, {
|
|
1150
|
+
value: g,
|
|
1151
1151
|
children: e
|
|
1152
1152
|
});
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1156
|
-
library:
|
|
1157
|
-
selected:
|
|
1154
|
+
function gt() {
|
|
1155
|
+
return se(ft) || {
|
|
1156
|
+
library: Y,
|
|
1157
|
+
selected: J.reduce((e, t) => (e[t] = null, e), {}),
|
|
1158
1158
|
addItem: () => null,
|
|
1159
1159
|
removeItem: () => {},
|
|
1160
1160
|
updateItem: () => {},
|
|
@@ -1168,219 +1168,219 @@ function ht() {
|
|
|
1168
1168
|
savePreset: () => null
|
|
1169
1169
|
};
|
|
1170
1170
|
}
|
|
1171
|
-
var
|
|
1171
|
+
var _t = J, vt = (e) => d("generators")?.loopById(e) ?? null, yt = {
|
|
1172
1172
|
bg: "Background",
|
|
1173
1173
|
fg: "Ink",
|
|
1174
1174
|
accent: "Accent",
|
|
1175
1175
|
dim: "Dim",
|
|
1176
1176
|
warm: "Warm"
|
|
1177
|
-
},
|
|
1177
|
+
}, bt = {
|
|
1178
1178
|
0: "fg",
|
|
1179
1179
|
1: "warm",
|
|
1180
1180
|
3: "dim",
|
|
1181
1181
|
4: "accent",
|
|
1182
1182
|
5: "bg"
|
|
1183
|
-
},
|
|
1183
|
+
}, Q = (e) => e.slice(0, 7).toLowerCase();
|
|
1184
1184
|
function xt() {
|
|
1185
|
-
let e = i(), { layers: t, selectedId: n, updateLayer:
|
|
1186
|
-
base:
|
|
1187
|
-
relation:
|
|
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), {
|
|
1186
|
+
base: x,
|
|
1187
|
+
relation: d,
|
|
1188
1188
|
count: 5
|
|
1189
1189
|
}).map((e) => ({
|
|
1190
1190
|
hex: e,
|
|
1191
1191
|
locked: !1
|
|
1192
|
-
}))), [
|
|
1193
|
-
let i =
|
|
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), {
|
|
1194
1194
|
base: e,
|
|
1195
1195
|
relation: t,
|
|
1196
1196
|
count: n
|
|
1197
1197
|
});
|
|
1198
|
-
|
|
1198
|
+
w((e) => i.map((t, n) => e[n]?.locked ? e[n] : {
|
|
1199
1199
|
hex: t,
|
|
1200
1200
|
locked: !1
|
|
1201
|
-
})),
|
|
1202
|
-
},
|
|
1203
|
-
let e =
|
|
1204
|
-
|
|
1201
|
+
})), E(null);
|
|
1202
|
+
}, oe = () => {
|
|
1203
|
+
let e = h();
|
|
1204
|
+
b(e), k({ s: e });
|
|
1205
|
+
}, A = (e) => {
|
|
1206
|
+
let t = Q(e);
|
|
1207
|
+
S(t), k({ b: t });
|
|
1208
|
+
}, se = (e) => {
|
|
1209
|
+
ie(e), k({ rel: e });
|
|
1205
1210
|
}, j = (e) => {
|
|
1206
|
-
let t = bt(e);
|
|
1207
|
-
C(t), A({ b: t });
|
|
1208
|
-
}, oe = (e) => {
|
|
1209
|
-
re(e), A({ rel: e });
|
|
1210
|
-
}, M = (e) => {
|
|
1211
1211
|
let t = Number(e);
|
|
1212
|
-
Number.isInteger(t) && t >= 2 && t <= 8 &&
|
|
1213
|
-
},
|
|
1214
|
-
|
|
1212
|
+
Number.isInteger(t) && t >= 2 && t <= 8 && k({ n: t });
|
|
1213
|
+
}, le = (e, t) => {
|
|
1214
|
+
w((n) => n.map((n, r) => r === e ? {
|
|
1215
1215
|
...n,
|
|
1216
|
-
hex:
|
|
1217
|
-
} : n)),
|
|
1218
|
-
},
|
|
1216
|
+
hex: Q(t)
|
|
1217
|
+
} : n)), E(null);
|
|
1218
|
+
}, N = (e) => w((t) => t.map((t, n) => n === e ? {
|
|
1219
1219
|
...t,
|
|
1220
1220
|
locked: !t.locked
|
|
1221
|
-
} : t)),
|
|
1222
|
-
|
|
1223
|
-
},
|
|
1224
|
-
let t =
|
|
1221
|
+
} : t)), ue = (e) => {
|
|
1222
|
+
w((t) => t.filter((t, n) => n !== e)), E(null);
|
|
1223
|
+
}, fe = (e) => {
|
|
1224
|
+
let t = D.find((t) => t.id === e);
|
|
1225
1225
|
if (!t) return;
|
|
1226
1226
|
let n = t.colors.slice(0, 8);
|
|
1227
|
-
|
|
1228
|
-
hex:
|
|
1227
|
+
w((n.length >= 2 ? n : [...n, ...n]).map((e) => ({
|
|
1228
|
+
hex: Q(e),
|
|
1229
1229
|
locked: !1
|
|
1230
|
-
}))),
|
|
1230
|
+
}))), E({
|
|
1231
1231
|
name: t.name,
|
|
1232
1232
|
roles: t.colors.length <= 8 ? t.roles : null
|
|
1233
1233
|
});
|
|
1234
|
-
},
|
|
1235
|
-
name:
|
|
1236
|
-
relation:
|
|
1237
|
-
colors:
|
|
1238
|
-
roles:
|
|
1239
|
-
},
|
|
1240
|
-
if (!
|
|
1241
|
-
let e =
|
|
1242
|
-
|
|
1243
|
-
},
|
|
1244
|
-
return /* @__PURE__ */
|
|
1234
|
+
}, I = C.map((e) => e.hex), L = T?.roles ?? u(I), pe = m.find((e) => e.id === d)?.label ?? "Palette", me = {
|
|
1235
|
+
name: T?.name ?? pe,
|
|
1236
|
+
relation: d,
|
|
1237
|
+
colors: I,
|
|
1238
|
+
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]));
|
|
1244
|
+
return /* @__PURE__ */ F("div", {
|
|
1245
1245
|
className: "p-4 flex flex-col gap-4",
|
|
1246
1246
|
children: [
|
|
1247
|
-
/* @__PURE__ */
|
|
1247
|
+
/* @__PURE__ */ F("div", {
|
|
1248
1248
|
className: "flex items-center gap-2",
|
|
1249
1249
|
children: [
|
|
1250
|
-
/* @__PURE__ */
|
|
1251
|
-
color:
|
|
1252
|
-
onChange:
|
|
1250
|
+
/* @__PURE__ */ P(ae, {
|
|
1251
|
+
color: x.toUpperCase(),
|
|
1252
|
+
onChange: A,
|
|
1253
1253
|
size: "sm",
|
|
1254
1254
|
label: "Base"
|
|
1255
1255
|
}),
|
|
1256
|
-
/* @__PURE__ */
|
|
1256
|
+
/* @__PURE__ */ P("span", {
|
|
1257
1257
|
className: "kol-helper-10 uppercase text-meta",
|
|
1258
1258
|
children: "Base"
|
|
1259
1259
|
}),
|
|
1260
|
-
/* @__PURE__ */
|
|
1260
|
+
/* @__PURE__ */ P("span", {
|
|
1261
1261
|
className: "kol-mono-10 text-meta flex-1",
|
|
1262
|
-
children:
|
|
1262
|
+
children: x.toUpperCase()
|
|
1263
1263
|
}),
|
|
1264
|
-
/* @__PURE__ */
|
|
1264
|
+
/* @__PURE__ */ P("span", {
|
|
1265
1265
|
className: "kol-helper-10 uppercase text-meta",
|
|
1266
1266
|
children: "Colors"
|
|
1267
1267
|
}),
|
|
1268
|
-
/* @__PURE__ */
|
|
1268
|
+
/* @__PURE__ */ P(O, {
|
|
1269
1269
|
size: e,
|
|
1270
1270
|
min: 2,
|
|
1271
1271
|
max: 8,
|
|
1272
|
-
value:
|
|
1273
|
-
onChange: (e) =>
|
|
1272
|
+
value: C.length,
|
|
1273
|
+
onChange: (e) => j(e.target.value),
|
|
1274
1274
|
className: "w-16",
|
|
1275
1275
|
"aria-label": "Colors"
|
|
1276
1276
|
})
|
|
1277
1277
|
]
|
|
1278
1278
|
}),
|
|
1279
|
-
/* @__PURE__ */
|
|
1279
|
+
/* @__PURE__ */ F("div", {
|
|
1280
1280
|
className: "flex items-center gap-2",
|
|
1281
|
-
children: [/* @__PURE__ */
|
|
1281
|
+
children: [/* @__PURE__ */ P(y, {
|
|
1282
1282
|
className: "flex-1 min-w-0",
|
|
1283
1283
|
size: e,
|
|
1284
1284
|
"aria-label": "Relationship",
|
|
1285
|
-
options:
|
|
1285
|
+
options: m.map((e) => ({
|
|
1286
1286
|
value: e.id,
|
|
1287
1287
|
label: e.label
|
|
1288
1288
|
})),
|
|
1289
|
-
value:
|
|
1290
|
-
onChange:
|
|
1291
|
-
}), /* @__PURE__ */
|
|
1289
|
+
value: d,
|
|
1290
|
+
onChange: se
|
|
1291
|
+
}), /* @__PURE__ */ P(_, {
|
|
1292
1292
|
tone: "grey",
|
|
1293
1293
|
size: e,
|
|
1294
|
-
onClick:
|
|
1294
|
+
onClick: oe,
|
|
1295
1295
|
children: "Roll"
|
|
1296
1296
|
})]
|
|
1297
1297
|
}),
|
|
1298
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ P("div", {
|
|
1299
1299
|
className: "flex flex-col gap-1",
|
|
1300
|
-
children:
|
|
1300
|
+
children: C.map((e, t) => /* @__PURE__ */ F("div", {
|
|
1301
1301
|
className: "flex items-center gap-2",
|
|
1302
1302
|
children: [
|
|
1303
|
-
/* @__PURE__ */
|
|
1303
|
+
/* @__PURE__ */ P(ae, {
|
|
1304
1304
|
color: e.hex.toUpperCase(),
|
|
1305
|
-
onChange: (e) =>
|
|
1305
|
+
onChange: (e) => le(t, e),
|
|
1306
1306
|
size: "sm",
|
|
1307
1307
|
label: `Color ${t + 1}`
|
|
1308
1308
|
}),
|
|
1309
|
-
/* @__PURE__ */
|
|
1309
|
+
/* @__PURE__ */ P("span", {
|
|
1310
1310
|
className: "kol-helper-10 uppercase text-meta flex-1 truncate",
|
|
1311
|
-
children:
|
|
1311
|
+
children: he(e.hex)
|
|
1312
1312
|
}),
|
|
1313
|
-
/* @__PURE__ */
|
|
1313
|
+
/* @__PURE__ */ P("span", {
|
|
1314
1314
|
className: "kol-mono-10 text-meta",
|
|
1315
1315
|
children: e.hex.toUpperCase()
|
|
1316
1316
|
}),
|
|
1317
|
-
/* @__PURE__ */
|
|
1317
|
+
/* @__PURE__ */ P(_, {
|
|
1318
1318
|
tone: "ghost",
|
|
1319
1319
|
quiet: !0,
|
|
1320
1320
|
size: "sm",
|
|
1321
1321
|
iconOnly: e.locked ? "lock" : "unlock",
|
|
1322
1322
|
"aria-label": `${e.locked ? "Unlock" : "Lock"} color ${t + 1}`,
|
|
1323
1323
|
pressed: e.locked,
|
|
1324
|
-
onClick: () =>
|
|
1324
|
+
onClick: () => N(t)
|
|
1325
1325
|
}),
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
className:
|
|
1328
|
-
"aria-hidden":
|
|
1329
|
-
children: /* @__PURE__ */
|
|
1326
|
+
/* @__PURE__ */ P("span", {
|
|
1327
|
+
className: C.length <= 2 ? "invisible pointer-events-none" : "contents",
|
|
1328
|
+
"aria-hidden": C.length <= 2 || void 0,
|
|
1329
|
+
children: /* @__PURE__ */ P(_, {
|
|
1330
1330
|
tone: "ghost",
|
|
1331
1331
|
quiet: !0,
|
|
1332
1332
|
size: "sm",
|
|
1333
1333
|
iconOnly: "trash",
|
|
1334
1334
|
"aria-label": `Delete color ${t + 1}`,
|
|
1335
|
-
tabIndex:
|
|
1336
|
-
onClick: () =>
|
|
1335
|
+
tabIndex: C.length <= 2 ? -1 : void 0,
|
|
1336
|
+
onClick: () => ue(t)
|
|
1337
1337
|
})
|
|
1338
1338
|
})
|
|
1339
1339
|
]
|
|
1340
1340
|
}, t))
|
|
1341
1341
|
}),
|
|
1342
|
-
|
|
1342
|
+
g(L.bg, L.fg) < 4.5 && /* @__PURE__ */ F("span", {
|
|
1343
1343
|
className: "kol-helper-10 text-meta inline-flex items-center gap-1",
|
|
1344
|
-
children: [/* @__PURE__ */
|
|
1344
|
+
children: [/* @__PURE__ */ P(de, {
|
|
1345
1345
|
name: "info",
|
|
1346
1346
|
size: 12
|
|
1347
1347
|
}), "Ink on background is under 4.5:1"]
|
|
1348
1348
|
}),
|
|
1349
|
-
/* @__PURE__ */
|
|
1349
|
+
/* @__PURE__ */ P(y, {
|
|
1350
1350
|
size: e,
|
|
1351
1351
|
"aria-label": "Load palette",
|
|
1352
1352
|
value: "",
|
|
1353
1353
|
options: [{
|
|
1354
1354
|
value: "",
|
|
1355
1355
|
label: "Load palette…"
|
|
1356
|
-
}, ...
|
|
1356
|
+
}, ...D.map((e) => ({
|
|
1357
1357
|
value: e.id,
|
|
1358
1358
|
label: e.name
|
|
1359
1359
|
}))],
|
|
1360
|
-
onChange: (e) => e &&
|
|
1360
|
+
onChange: (e) => e && fe(e)
|
|
1361
1361
|
}),
|
|
1362
|
-
/* @__PURE__ */
|
|
1362
|
+
/* @__PURE__ */ P(_, {
|
|
1363
1363
|
tone: "grey",
|
|
1364
1364
|
size: e,
|
|
1365
|
-
onClick: () =>
|
|
1366
|
-
name:
|
|
1367
|
-
colors:
|
|
1365
|
+
onClick: () => c("palette", {
|
|
1366
|
+
name: me.name,
|
|
1367
|
+
colors: I
|
|
1368
1368
|
}),
|
|
1369
1369
|
children: "Save"
|
|
1370
1370
|
}),
|
|
1371
|
-
/* @__PURE__ */
|
|
1371
|
+
/* @__PURE__ */ F("div", {
|
|
1372
1372
|
className: "flex gap-2",
|
|
1373
|
-
children: [
|
|
1373
|
+
children: [z && /* @__PURE__ */ P(_, {
|
|
1374
1374
|
tone: "grey",
|
|
1375
1375
|
size: e,
|
|
1376
1376
|
className: "flex-1",
|
|
1377
|
-
onClick:
|
|
1377
|
+
onClick: ge,
|
|
1378
1378
|
children: "Apply to layer"
|
|
1379
|
-
}), /* @__PURE__ */
|
|
1379
|
+
}), /* @__PURE__ */ P(_, {
|
|
1380
1380
|
tone: "grey",
|
|
1381
1381
|
size: e,
|
|
1382
1382
|
className: "flex-1",
|
|
1383
|
-
onClick:
|
|
1383
|
+
onClick: _e,
|
|
1384
1384
|
children: "Apply to document"
|
|
1385
1385
|
})]
|
|
1386
1386
|
})
|
|
@@ -1391,33 +1391,33 @@ function xt() {
|
|
|
1391
1391
|
//#region src/editor/color/ColorModesWindow.jsx
|
|
1392
1392
|
var St = "kol:open-color-modes", Ct = () => window.dispatchEvent(new CustomEvent(St));
|
|
1393
1393
|
function wt() {
|
|
1394
|
-
let [e, t] =
|
|
1395
|
-
if (
|
|
1394
|
+
let [e, t] = M(!1);
|
|
1395
|
+
if (j(() => {
|
|
1396
1396
|
let e = () => t(!0);
|
|
1397
1397
|
return window.addEventListener(St, e), () => window.removeEventListener(St, e);
|
|
1398
1398
|
}, []), !e) return null;
|
|
1399
1399
|
let n = () => t(!1);
|
|
1400
|
-
return /* @__PURE__ */
|
|
1400
|
+
return /* @__PURE__ */ P(b, {
|
|
1401
1401
|
open: !0,
|
|
1402
1402
|
onClose: n,
|
|
1403
1403
|
closeButton: !1,
|
|
1404
1404
|
scrim: !0,
|
|
1405
|
-
children: /* @__PURE__ */
|
|
1405
|
+
children: /* @__PURE__ */ F(T, {
|
|
1406
1406
|
variant: "bordered",
|
|
1407
1407
|
"aria-label": "Color Modes",
|
|
1408
1408
|
"data-editor-keep-selection": !0,
|
|
1409
1409
|
className: "kol-design-editor w-[360px] max-w-full shadow-[0_8px_24px_-8px_rgba(0,0,0,0.4),0_2px_6px_-2px_rgba(0,0,0,0.3)]",
|
|
1410
|
-
children: [/* @__PURE__ */
|
|
1410
|
+
children: [/* @__PURE__ */ F("div", {
|
|
1411
1411
|
className: "relative flex h-10 items-center justify-center border-b border-oq-08 px-4",
|
|
1412
|
-
children: [/* @__PURE__ */
|
|
1412
|
+
children: [/* @__PURE__ */ P("span", {
|
|
1413
1413
|
className: "font-sans text-[13px] text-emphasis",
|
|
1414
1414
|
children: "Color Modes"
|
|
1415
|
-
}), /* @__PURE__ */
|
|
1415
|
+
}), /* @__PURE__ */ P(v, {
|
|
1416
1416
|
onClick: n,
|
|
1417
1417
|
size: "sm",
|
|
1418
1418
|
className: "!absolute right-3"
|
|
1419
1419
|
})]
|
|
1420
|
-
}), /* @__PURE__ */
|
|
1420
|
+
}), /* @__PURE__ */ P(xt, {})]
|
|
1421
1421
|
})
|
|
1422
1422
|
});
|
|
1423
1423
|
}
|
|
@@ -1438,7 +1438,7 @@ function Ot(e, t) {
|
|
|
1438
1438
|
layerId: null,
|
|
1439
1439
|
...$[e],
|
|
1440
1440
|
params: t()
|
|
1441
|
-
}),
|
|
1441
|
+
}), N((e) => (Tt.add(e), () => Tt.delete(e)), () => $[e]);
|
|
1442
1442
|
}
|
|
1443
1443
|
var kt = (e, t = "rail") => Nt(t === "dialog" ? { dialog: e } : { rail: e });
|
|
1444
1444
|
function At(e, t, n = "rail") {
|
|
@@ -1458,6 +1458,6 @@ function Nt(e) {
|
|
|
1458
1458
|
...e
|
|
1459
1459
|
}, Mt.forEach((e) => e());
|
|
1460
1460
|
}
|
|
1461
|
-
var Pt = () =>
|
|
1461
|
+
var Pt = () => N((e) => (Mt.add(e), () => Mt.delete(e)), () => jt);
|
|
1462
1462
|
//#endregion
|
|
1463
|
-
export {
|
|
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 };
|