@kolkrabbi/design-editor 0.47.0 → 0.49.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 +18 -0
- package/dist/{BindDot-B85UV79g.js → BindDot-BAAc-KSs.js} +1 -1
- package/dist/{KolboxView-n6kEPJtV.js → KolboxView-DxcGz6MC.js} +3310 -5355
- package/dist/{Timeline-EbecYeGh.js → Timeline-BH3BF2m4.js} +3 -9
- package/dist/{TreePicker-2RUSyGl4.js → TreePicker-RImJ6I_0.js} +19 -19
- package/dist/{core-9UlJPBwX.js → core-DyfKZlBI.js} +3550 -5884
- package/dist/core.js +5 -5
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +6 -6
- package/dist/{effectCategories-CCpYmxS0.js → effectCategories-B5jhXEyy.js} +32 -32
- package/dist/effects-BAwNQ8Kj.js +447 -0
- package/dist/effects.js +1 -1
- package/dist/{generators-DY4_ymWh.js → generators-OCg5XjTX.js} +986 -1021
- package/dist/generators.js +1 -1
- package/dist/{host-Bo6itV50.js → host-DS-pAjP0.js} +2 -2
- package/dist/kolbox-pages.js +2218 -0
- package/dist/kolbox-sheet.js +0 -0
- package/dist/kolbox.css +3 -0
- package/dist/{morphStore-Bm30Ekce.js → morphStore-D6xiYiR_.js} +1 -1
- package/dist/{motion-BOWE4m3Q.js → motion-p5pHH9_J.js} +103 -103
- package/dist/motion.js +1 -1
- package/dist/portable-Bs8ieXiu.js +2128 -0
- package/dist/{rolls-DugKaHUw.js → rolls-ZToBSscx.js} +2897 -3068
- package/dist/{src-BlvCHYVY.js → src-DEx6Oh0D.js} +754 -996
- package/dist/{store-BMGP1qou.js → store-BDAxvWTE.js} +15 -15
- package/dist/{useLayerEdit-B5nF5I9b.js → useLayerEdit-D6vwfIoB.js} +141 -141
- package/package.json +17 -14
- package/dist/effects-DspYFJAM.js +0 -447
|
@@ -0,0 +1,2218 @@
|
|
|
1
|
+
import { C as e } from "./__vite-browser-external-y2xWjzgx.js";
|
|
2
|
+
import { B as t, Bn as n, In as r, Nr as i, z as a } from "./rolls-ZToBSscx.js";
|
|
3
|
+
import { C as o, h as s, m as c, v as l, w as u } from "./effectCategories-B5jhXEyy.js";
|
|
4
|
+
import { b as d, d as f } from "./store-BDAxvWTE.js";
|
|
5
|
+
import { c as p, d as m } from "./motion-p5pHH9_J.js";
|
|
6
|
+
import { $ as h, $t as g, At as _, E as v, It as y, Jt as b, Qt as x, Xt as ee, Yt as S, Zt as C } from "./core-DyfKZlBI.js";
|
|
7
|
+
import { A as te, C as w, D as ne, E as re, F as ie, M as ae, N as T, O as oe, P as se, T as E, X as ce, Y as le, Z as ue, b as de, ct as fe, g as pe, i as me, j as he, lt as D, n as ge, r as _e, st as ve, v as ye, w as be, x as xe, y as Se } from "./portable-Bs8ieXiu.js";
|
|
8
|
+
import { AccountMenu as Ce, Button as O, ButtonGroup as we, ContentCard as Te, Dropdown as Ee, Input as k, LabeledControl as A, LabeledControlSection as De, Menu as j, PopoverLayer as M, Rail as N, RailHeader as Oe, SectionText as ke, Table as Ae, TabsRow as je, Tooltip as Me, TreeRow as Ne, downloadBlob as Pe, formatSize as Fe, pickImage as Ie } from "@kolkrabbi/kol-component";
|
|
9
|
+
import { Fragment as P, useEffect as F, useLayoutEffect as Le, useMemo as Re, useReducer as ze, useRef as I, useState as L } from "react";
|
|
10
|
+
import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
|
|
11
|
+
import { CatalogGrid as Be, CatalogPage as Ve } from "@kolkrabbi/kol-shell";
|
|
12
|
+
import { createPortal as He } from "react-dom";
|
|
13
|
+
//#region src/editor/kolbox/ui/HomeRail.jsx
|
|
14
|
+
var V = ({ label: e, children: t }) => /* @__PURE__ */ z("div", {
|
|
15
|
+
className: "flex *:flex-1",
|
|
16
|
+
children: /* @__PURE__ */ z(Me, {
|
|
17
|
+
variant: "kolbox",
|
|
18
|
+
label: e,
|
|
19
|
+
children: t
|
|
20
|
+
})
|
|
21
|
+
}), Ue = "application/x-kolbox-files";
|
|
22
|
+
function We({ i: e }) {
|
|
23
|
+
let [t, n] = L(!1), r = /* @__PURE__ */ z(Ne, {
|
|
24
|
+
variant: "kolbox",
|
|
25
|
+
size: "sm",
|
|
26
|
+
icon: e.icon,
|
|
27
|
+
label: e.label,
|
|
28
|
+
active: e.selected || t,
|
|
29
|
+
disabled: e.disabled,
|
|
30
|
+
onClick: e.onClick
|
|
31
|
+
});
|
|
32
|
+
if (!e.onDrop) return r;
|
|
33
|
+
let i = (e) => e.dataTransfer.types.includes(Ue);
|
|
34
|
+
return /* @__PURE__ */ z("div", {
|
|
35
|
+
"data-drop-target": e.id,
|
|
36
|
+
"data-drop-over": t || void 0,
|
|
37
|
+
onDragOver: (e) => {
|
|
38
|
+
i(e) && (e.preventDefault(), e.dataTransfer.dropEffect = "move", n(!0));
|
|
39
|
+
},
|
|
40
|
+
onDragLeave: (e) => {
|
|
41
|
+
e.currentTarget.contains(e.relatedTarget) || n(!1);
|
|
42
|
+
},
|
|
43
|
+
onDrop: (t) => {
|
|
44
|
+
i(t) && (t.preventDefault(), n(!1), e.onDrop(JSON.parse(t.dataTransfer.getData(Ue))));
|
|
45
|
+
},
|
|
46
|
+
children: r
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
var H = (e) => /* @__PURE__ */ z(We, { i: e }, e.id);
|
|
50
|
+
function Ge({ label: e, open: t, onToggle: n, end: r, children: i }) {
|
|
51
|
+
return /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ B("div", {
|
|
52
|
+
className: "flex h-8 items-center justify-between",
|
|
53
|
+
children: [/* @__PURE__ */ B("button", {
|
|
54
|
+
type: "button",
|
|
55
|
+
"aria-expanded": t,
|
|
56
|
+
onClick: n,
|
|
57
|
+
className: "kol-kolbox-section flex h-8 items-center gap-1 rounded-control text-left text-text outline-none focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent",
|
|
58
|
+
children: [/* @__PURE__ */ z(D, {
|
|
59
|
+
name: "chevron-down",
|
|
60
|
+
size: 12,
|
|
61
|
+
className: t ? "" : "-rotate-90"
|
|
62
|
+
}), e]
|
|
63
|
+
}), r]
|
|
64
|
+
}), t && i] });
|
|
65
|
+
}
|
|
66
|
+
var Ke = "kol.editor.home.searches", qe = () => {
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(localStorage.getItem(Ke)) ?? [];
|
|
69
|
+
} catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}, Je = (e) => {
|
|
73
|
+
let t = [e, ...qe().filter((t) => t !== e)].slice(0, 5);
|
|
74
|
+
try {
|
|
75
|
+
localStorage.setItem(Ke, JSON.stringify(t));
|
|
76
|
+
} catch {}
|
|
77
|
+
}, Ye = new Intl.RelativeTimeFormat(void 0, { numeric: "auto" }), U = [
|
|
78
|
+
[60, "second"],
|
|
79
|
+
[60, "minute"],
|
|
80
|
+
[24, "hour"],
|
|
81
|
+
[7, "day"],
|
|
82
|
+
[4.35, "week"],
|
|
83
|
+
[12, "month"],
|
|
84
|
+
[Infinity, "year"]
|
|
85
|
+
], Xe = (e) => {
|
|
86
|
+
let t = (e - Date.now()) / 1e3;
|
|
87
|
+
for (let [e, n] of U) {
|
|
88
|
+
if (Math.abs(t) < e) return Ye.format(Math.round(t), n);
|
|
89
|
+
t /= e;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function Ze({ anchor: e, open: t, onClose: n, search: r, onSearch: i, files: a = [], filters: o = [] }) {
|
|
93
|
+
let [s, c] = L(null), l = I({}), u = "flex h-10 w-full items-center gap-4 rounded-control px-[13px] text-left text-[11px] leading-4 font-normal text-text outline-none hover:bg-hover focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent", d = I(null), f = t ? qe() : [], p = (e) => {
|
|
94
|
+
e.trim() && Je(e.trim());
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ B(M, {
|
|
97
|
+
anchor: e,
|
|
98
|
+
open: t,
|
|
99
|
+
onClose: n,
|
|
100
|
+
placement: "over",
|
|
101
|
+
kind: "search",
|
|
102
|
+
children: [/* @__PURE__ */ B("section", {
|
|
103
|
+
role: "dialog",
|
|
104
|
+
"aria-label": "Search",
|
|
105
|
+
"data-home-search": !0,
|
|
106
|
+
className: "kol-kolbox-surface flex w-[380px] max-w-[calc(100vw-var(--kol-spacing-2))] flex-col rounded-menu bg-panel p-2",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ z(k, {
|
|
109
|
+
variant: "kolbox",
|
|
110
|
+
ref: d,
|
|
111
|
+
size: "md",
|
|
112
|
+
iconLeft: "search",
|
|
113
|
+
className: "gap-2.5! pl-2!",
|
|
114
|
+
placeholder: "Search",
|
|
115
|
+
"aria-label": "Search",
|
|
116
|
+
autoFocus: !0,
|
|
117
|
+
value: r,
|
|
118
|
+
onChange: (e) => i?.(e.target.value),
|
|
119
|
+
onKeyDown: (e) => {
|
|
120
|
+
e.key === "Enter" && (p(r), n());
|
|
121
|
+
}
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ z("div", {
|
|
124
|
+
className: "flex flex-col pt-2",
|
|
125
|
+
children: o.map((e) => /* @__PURE__ */ B("button", {
|
|
126
|
+
type: "button",
|
|
127
|
+
"data-search-filter": e.id,
|
|
128
|
+
onClick: () => c(e.id),
|
|
129
|
+
className: "flex h-10 items-center justify-between gap-3 rounded-control px-2 text-left outline-none hover:bg-hover focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent",
|
|
130
|
+
children: [/* @__PURE__ */ B("span", {
|
|
131
|
+
ref: (t) => {
|
|
132
|
+
l.current[e.id] = t;
|
|
133
|
+
},
|
|
134
|
+
className: "flex h-6 items-center gap-1 rounded-control bg-field px-2 text-[11px] leading-4 font-normal text-text",
|
|
135
|
+
children: [e.label, e.value && /* @__PURE__ */ z("span", {
|
|
136
|
+
className: "text-muted",
|
|
137
|
+
children: e.value
|
|
138
|
+
})]
|
|
139
|
+
}), /* @__PURE__ */ z("span", {
|
|
140
|
+
className: "truncate text-[11px] leading-4 font-normal text-muted",
|
|
141
|
+
children: e.hint
|
|
142
|
+
})]
|
|
143
|
+
}, e.id))
|
|
144
|
+
}),
|
|
145
|
+
(f.length > 0 || a.length > 0) && /* @__PURE__ */ z("div", {
|
|
146
|
+
className: "px-3 pt-3 pb-2 text-help text-muted",
|
|
147
|
+
children: "Recent"
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ B("div", {
|
|
150
|
+
className: "flex flex-col",
|
|
151
|
+
children: [f.map((e) => /* @__PURE__ */ B("button", {
|
|
152
|
+
type: "button",
|
|
153
|
+
onClick: () => {
|
|
154
|
+
i?.(e), Je(e);
|
|
155
|
+
},
|
|
156
|
+
className: u,
|
|
157
|
+
children: [/* @__PURE__ */ z("span", {
|
|
158
|
+
className: "flex size-4 shrink-0 items-center justify-center",
|
|
159
|
+
children: /* @__PURE__ */ z(D, {
|
|
160
|
+
name: "clock",
|
|
161
|
+
size: 18
|
|
162
|
+
})
|
|
163
|
+
}), /* @__PURE__ */ z("span", {
|
|
164
|
+
className: "truncate",
|
|
165
|
+
children: e
|
|
166
|
+
})]
|
|
167
|
+
}, `q:${e}`)), a.map((e) => /* @__PURE__ */ B("button", {
|
|
168
|
+
type: "button",
|
|
169
|
+
onClick: () => {
|
|
170
|
+
p(r), n(), e.onOpen?.();
|
|
171
|
+
},
|
|
172
|
+
className: `${u} h-12`,
|
|
173
|
+
children: [/* @__PURE__ */ z("span", {
|
|
174
|
+
className: "flex size-4 shrink-0 items-center justify-center rounded-xs bg-accent text-on-accent",
|
|
175
|
+
children: /* @__PURE__ */ z(D, {
|
|
176
|
+
name: e.icon,
|
|
177
|
+
size: 14
|
|
178
|
+
})
|
|
179
|
+
}), /* @__PURE__ */ B("span", {
|
|
180
|
+
className: "flex min-w-0 flex-col",
|
|
181
|
+
children: [/* @__PURE__ */ z("span", {
|
|
182
|
+
className: "truncate",
|
|
183
|
+
children: e.name
|
|
184
|
+
}), /* @__PURE__ */ B("span", {
|
|
185
|
+
className: "flex gap-1.5 truncate text-[11px] leading-4 text-muted",
|
|
186
|
+
children: [/* @__PURE__ */ z("span", { children: e.folder }), /* @__PURE__ */ B("span", { children: ["Edited ", Xe(e.modified)] })]
|
|
187
|
+
})]
|
|
188
|
+
})]
|
|
189
|
+
}, e.id))]
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}), o.map((e) => /* @__PURE__ */ z(j, {
|
|
193
|
+
variant: "kolbox",
|
|
194
|
+
"aria-label": e.hint,
|
|
195
|
+
anchor: l.current[e.id],
|
|
196
|
+
open: s === e.id,
|
|
197
|
+
onClose: () => {
|
|
198
|
+
c(null), d.current?.focus();
|
|
199
|
+
},
|
|
200
|
+
onSelect: (e) => e.run?.(),
|
|
201
|
+
groups: e.groups
|
|
202
|
+
}, e.id))]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
function Qe({ account: e, accountMenu: t = [], search: n = "", onSearch: r, items: i = [], starred: a = [], recent: o }) {
|
|
206
|
+
let [s, c] = L(!0), [l, u] = L(!1), d = I(null), f = Re(() => ({
|
|
207
|
+
getBoundingClientRect: () => {
|
|
208
|
+
let e = d.current.getBoundingClientRect();
|
|
209
|
+
return new DOMRect(e.left - 8, e.top - 8, e.width, e.height);
|
|
210
|
+
},
|
|
211
|
+
contains: (e) => !!d.current?.contains(e)
|
|
212
|
+
}), []), [p, m] = L(!1), h = I(null);
|
|
213
|
+
return /* @__PURE__ */ z(N, {
|
|
214
|
+
variant: "kolbox",
|
|
215
|
+
side: "left",
|
|
216
|
+
"aria-label": "Home",
|
|
217
|
+
header: /* @__PURE__ */ z(Oe, {
|
|
218
|
+
variant: "kolbox",
|
|
219
|
+
title: "Home"
|
|
220
|
+
}),
|
|
221
|
+
footer: /* @__PURE__ */ B("div", {
|
|
222
|
+
className: "relative flex h-12 items-center gap-2 px-3 before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-border",
|
|
223
|
+
"data-rail-account": !0,
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ z(Me, {
|
|
226
|
+
variant: "kolbox",
|
|
227
|
+
asChild: !0,
|
|
228
|
+
label: "Account",
|
|
229
|
+
children: /* @__PURE__ */ z("span", {
|
|
230
|
+
ref: h,
|
|
231
|
+
className: "flex",
|
|
232
|
+
children: /* @__PURE__ */ z(Ce, {
|
|
233
|
+
variant: "kolbox",
|
|
234
|
+
initial: e?.initial,
|
|
235
|
+
name: "Account",
|
|
236
|
+
"aria-expanded": p,
|
|
237
|
+
onClick: () => m((e) => !e)
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
}),
|
|
241
|
+
/* @__PURE__ */ z("button", {
|
|
242
|
+
type: "button",
|
|
243
|
+
onClick: () => m((e) => !e),
|
|
244
|
+
"data-account": !0,
|
|
245
|
+
className: "min-w-0 flex-1 truncate rounded-control text-left text-row text-text outline-none hover:text-accent focus-visible:outline-solid focus-visible:outline-1 focus-visible:outline-accent",
|
|
246
|
+
children: e?.name
|
|
247
|
+
}),
|
|
248
|
+
/* @__PURE__ */ z(j, {
|
|
249
|
+
variant: "kolbox",
|
|
250
|
+
"aria-label": "Account",
|
|
251
|
+
anchor: h,
|
|
252
|
+
open: p,
|
|
253
|
+
onClose: () => m(!1),
|
|
254
|
+
onSelect: (e) => e.run?.(),
|
|
255
|
+
groups: t
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}),
|
|
259
|
+
children: /* @__PURE__ */ B("div", {
|
|
260
|
+
className: "flex flex-col gap-1 px-2 pb-3",
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ z("div", {
|
|
263
|
+
ref: d,
|
|
264
|
+
onFocus: () => o && u(!0),
|
|
265
|
+
children: /* @__PURE__ */ z(k, {
|
|
266
|
+
variant: "kolbox",
|
|
267
|
+
size: "md",
|
|
268
|
+
iconLeft: "search",
|
|
269
|
+
placeholder: "Search",
|
|
270
|
+
"aria-label": "Search",
|
|
271
|
+
type: "search",
|
|
272
|
+
value: n,
|
|
273
|
+
onChange: (e) => r?.(e.target.value),
|
|
274
|
+
className: "mb-1.5 gap-2.5! pl-2!"
|
|
275
|
+
})
|
|
276
|
+
}),
|
|
277
|
+
o && /* @__PURE__ */ z(Ze, {
|
|
278
|
+
anchor: f,
|
|
279
|
+
open: l,
|
|
280
|
+
onClose: () => u(!1),
|
|
281
|
+
search: n,
|
|
282
|
+
onSearch: r,
|
|
283
|
+
files: o.files,
|
|
284
|
+
filters: o.filters
|
|
285
|
+
}),
|
|
286
|
+
i.map((e) => e.disabled ? /* @__PURE__ */ z(V, {
|
|
287
|
+
label: e.hint,
|
|
288
|
+
children: H(e)
|
|
289
|
+
}, e.id) : H(e)),
|
|
290
|
+
/* @__PURE__ */ z(Ge, {
|
|
291
|
+
label: "Starred",
|
|
292
|
+
open: s,
|
|
293
|
+
onToggle: () => c((e) => !e),
|
|
294
|
+
children: a.map(H)
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/editor/kolbox/home/BrowserTopBar.jsx
|
|
302
|
+
function $e({ crumbs: e = [], lead: t, actions: n }) {
|
|
303
|
+
return /* @__PURE__ */ B("header", {
|
|
304
|
+
className: "flex h-[49px] shrink-0 items-center gap-4 px-8 max-md:order-first max-md:gap-2 max-md:px-4",
|
|
305
|
+
"data-browser-top-bar": !0,
|
|
306
|
+
children: [
|
|
307
|
+
t,
|
|
308
|
+
/* @__PURE__ */ z("nav", {
|
|
309
|
+
"aria-label": "Breadcrumb",
|
|
310
|
+
className: "flex min-w-0 flex-1 items-center gap-4 text-[13px] leading-[22px] font-[450] text-muted",
|
|
311
|
+
children: e.map((e, t) => /* @__PURE__ */ B(P, { children: [t > 0 && /* @__PURE__ */ z("span", {
|
|
312
|
+
"aria-hidden": !0,
|
|
313
|
+
children: "/"
|
|
314
|
+
}), /* @__PURE__ */ z("span", {
|
|
315
|
+
className: "truncate",
|
|
316
|
+
children: e
|
|
317
|
+
})] }, t))
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ z("div", {
|
|
320
|
+
className: "flex shrink-0 items-center gap-2",
|
|
321
|
+
children: n
|
|
322
|
+
})
|
|
323
|
+
]
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
//#region src/editor/kolbox/home/RailFile.jsx
|
|
328
|
+
var W = ({ children: e }) => /* @__PURE__ */ z("span", {
|
|
329
|
+
className: "min-w-0 flex-1 truncate text-right font-mono text-value text-text",
|
|
330
|
+
children: e
|
|
331
|
+
}), G = ({ children: e, onRemove: t }) => /* @__PURE__ */ B("span", {
|
|
332
|
+
className: "inline-flex h-6 items-center gap-1 rounded-control bg-field px-2 font-mono text-meta text-text",
|
|
333
|
+
"data-file-tag": !0,
|
|
334
|
+
children: [e, t && /* @__PURE__ */ z("button", {
|
|
335
|
+
type: "button",
|
|
336
|
+
"aria-label": `Remove ${e}`,
|
|
337
|
+
onClick: t,
|
|
338
|
+
className: "-mr-1 inline-flex text-muted outline-none hover:text-text focus-visible:text-accent",
|
|
339
|
+
children: /* @__PURE__ */ z(D, {
|
|
340
|
+
name: "x",
|
|
341
|
+
size: 12
|
|
342
|
+
})
|
|
343
|
+
})]
|
|
344
|
+
});
|
|
345
|
+
function et({ file: e, onClose: t, onRename: n, onTags: r, onNote: i, onCover: a, onDownload: o, onDuplicate: s, onRemove: c }) {
|
|
346
|
+
let [l, u] = L(!1), [d, f] = L(e.name), [p, m] = L(e.tags ?? []), [h, g] = L(""), [_, v] = L(e.note ?? ""), y = I(null);
|
|
347
|
+
F(() => {
|
|
348
|
+
let e = (e) => {
|
|
349
|
+
let n = document.querySelectorAll("[data-kolbox-overlay]");
|
|
350
|
+
e.key === "Escape" && n[n.length - 1] === y.current && t();
|
|
351
|
+
};
|
|
352
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
353
|
+
}, [t]);
|
|
354
|
+
let b = () => {
|
|
355
|
+
let t = d.trim();
|
|
356
|
+
t && t !== e.name ? n(t) : f(e.name);
|
|
357
|
+
}, x = (e) => {
|
|
358
|
+
m(e), r(e);
|
|
359
|
+
}, ee = () => {
|
|
360
|
+
let e = h.trim();
|
|
361
|
+
e && !p.includes(e) && x([...p, e]), g("");
|
|
362
|
+
}, S = () => {
|
|
363
|
+
_.trim() !== (e.note ?? "").trim() && i(_.trim());
|
|
364
|
+
}, C = (e, t, n) => /* @__PURE__ */ z(Me, {
|
|
365
|
+
variant: "kolbox",
|
|
366
|
+
label: t,
|
|
367
|
+
children: /* @__PURE__ */ z(O, {
|
|
368
|
+
variant: "kolbox",
|
|
369
|
+
iconOnly: e,
|
|
370
|
+
"aria-label": t,
|
|
371
|
+
onClick: n
|
|
372
|
+
})
|
|
373
|
+
});
|
|
374
|
+
return He(/* @__PURE__ */ z("div", {
|
|
375
|
+
ref: y,
|
|
376
|
+
"data-kolbox-overlay": "rail",
|
|
377
|
+
className: "fixed inset-0 z-40 flex justify-end bg-dim",
|
|
378
|
+
onClick: (e) => e.target === e.currentTarget && t(),
|
|
379
|
+
children: /* @__PURE__ */ z(N, {
|
|
380
|
+
variant: "kolbox",
|
|
381
|
+
side: "right",
|
|
382
|
+
"aria-label": "File",
|
|
383
|
+
header: /* @__PURE__ */ z(Oe, {
|
|
384
|
+
variant: "kolbox",
|
|
385
|
+
title: "File",
|
|
386
|
+
actions: /* @__PURE__ */ z(O, {
|
|
387
|
+
variant: "kolbox",
|
|
388
|
+
iconOnly: "x",
|
|
389
|
+
"aria-label": "Close",
|
|
390
|
+
onClick: t
|
|
391
|
+
})
|
|
392
|
+
}),
|
|
393
|
+
footer: /* @__PURE__ */ B("div", {
|
|
394
|
+
className: "relative flex h-12 items-center justify-end gap-1 px-4 before:absolute before:inset-x-0 before:top-0 before:h-px before:bg-border",
|
|
395
|
+
"data-rail-file-foot": !0,
|
|
396
|
+
children: [
|
|
397
|
+
C("edit", l ? "Done editing" : "Edit", () => u((e) => !e)),
|
|
398
|
+
C("download", "Download", o),
|
|
399
|
+
C("copy", "Duplicate", s),
|
|
400
|
+
C("trash", "Delete", async () => {
|
|
401
|
+
await c() && t();
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
}),
|
|
405
|
+
children: /* @__PURE__ */ B("div", {
|
|
406
|
+
"data-rail-file": e.id,
|
|
407
|
+
children: [/* @__PURE__ */ B(De, {
|
|
408
|
+
variant: "kolbox",
|
|
409
|
+
children: [
|
|
410
|
+
/* @__PURE__ */ z(A, {
|
|
411
|
+
variant: "kolbox",
|
|
412
|
+
horizontal: !0,
|
|
413
|
+
label: "Name",
|
|
414
|
+
children: l ? /* @__PURE__ */ z(k, {
|
|
415
|
+
variant: "kolbox",
|
|
416
|
+
"aria-label": "Name",
|
|
417
|
+
value: d,
|
|
418
|
+
onChange: (e) => f(e.target.value),
|
|
419
|
+
onBlur: b,
|
|
420
|
+
onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
|
|
421
|
+
className: "flex-1"
|
|
422
|
+
}) : /* @__PURE__ */ z(W, { children: d })
|
|
423
|
+
}),
|
|
424
|
+
(l || p.length > 0) && /* @__PURE__ */ z(A, {
|
|
425
|
+
variant: "kolbox",
|
|
426
|
+
horizontal: !l,
|
|
427
|
+
label: "Tags",
|
|
428
|
+
children: l ? /* @__PURE__ */ B("div", {
|
|
429
|
+
className: "flex w-full flex-col gap-2",
|
|
430
|
+
children: [p.length > 0 && /* @__PURE__ */ z("div", {
|
|
431
|
+
className: "flex flex-wrap gap-1",
|
|
432
|
+
children: p.map((e) => /* @__PURE__ */ z(G, {
|
|
433
|
+
onRemove: () => x(p.filter((t) => t !== e)),
|
|
434
|
+
children: e
|
|
435
|
+
}, e))
|
|
436
|
+
}), /* @__PURE__ */ z(k, {
|
|
437
|
+
variant: "kolbox",
|
|
438
|
+
"aria-label": "Add a tag",
|
|
439
|
+
placeholder: "Add a tag",
|
|
440
|
+
value: h,
|
|
441
|
+
onChange: (e) => g(e.target.value),
|
|
442
|
+
onBlur: ee,
|
|
443
|
+
onKeyDown: (e) => e.key === "Enter" && ee()
|
|
444
|
+
})]
|
|
445
|
+
}) : /* @__PURE__ */ z("span", {
|
|
446
|
+
className: "flex min-w-0 flex-1 flex-wrap justify-end gap-1",
|
|
447
|
+
children: p.map((e) => /* @__PURE__ */ z(G, { children: e }, e))
|
|
448
|
+
})
|
|
449
|
+
}),
|
|
450
|
+
(l || _.trim()) && /* @__PURE__ */ z(A, {
|
|
451
|
+
variant: "kolbox",
|
|
452
|
+
horizontal: !l,
|
|
453
|
+
label: "Note",
|
|
454
|
+
children: l ? /* @__PURE__ */ z("textarea", {
|
|
455
|
+
"aria-label": "Note",
|
|
456
|
+
rows: 3,
|
|
457
|
+
placeholder: "Add a note",
|
|
458
|
+
value: _,
|
|
459
|
+
onChange: (e) => v(e.target.value),
|
|
460
|
+
onBlur: S,
|
|
461
|
+
className: "w-full resize-y rounded-control border border-border bg-field px-2 py-1 font-mono text-value text-text outline-none placeholder:text-muted focus:border-accent"
|
|
462
|
+
}) : /* @__PURE__ */ z("span", {
|
|
463
|
+
className: "min-w-0 flex-1 text-right font-mono text-value whitespace-pre-wrap text-text",
|
|
464
|
+
children: _.trim()
|
|
465
|
+
})
|
|
466
|
+
}),
|
|
467
|
+
l && /* @__PURE__ */ z(A, {
|
|
468
|
+
variant: "kolbox",
|
|
469
|
+
horizontal: !0,
|
|
470
|
+
label: "Cover",
|
|
471
|
+
children: /* @__PURE__ */ z(O, {
|
|
472
|
+
variant: "kolbox",
|
|
473
|
+
onClick: a,
|
|
474
|
+
children: "Upload image"
|
|
475
|
+
})
|
|
476
|
+
})
|
|
477
|
+
]
|
|
478
|
+
}), /* @__PURE__ */ z(De, {
|
|
479
|
+
variant: "kolbox",
|
|
480
|
+
label: "Details",
|
|
481
|
+
children: (e.details ?? []).map((e) => /* @__PURE__ */ z(A, {
|
|
482
|
+
variant: "kolbox",
|
|
483
|
+
horizontal: !0,
|
|
484
|
+
label: e.label,
|
|
485
|
+
children: /* @__PURE__ */ z(W, { children: e.value })
|
|
486
|
+
}, e.label))
|
|
487
|
+
})]
|
|
488
|
+
})
|
|
489
|
+
})
|
|
490
|
+
}), document.body);
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/editor/kolbox/home/samples.js
|
|
494
|
+
var K = "kol.editor.library.samples.v1", tt = 240, q = 36e5, nt = 864e5, rt = () => {
|
|
495
|
+
try {
|
|
496
|
+
return localStorage.getItem(K) != null;
|
|
497
|
+
} catch {
|
|
498
|
+
return !0;
|
|
499
|
+
}
|
|
500
|
+
}, it = () => {
|
|
501
|
+
try {
|
|
502
|
+
localStorage.setItem(K, String(Date.now()));
|
|
503
|
+
} catch {}
|
|
504
|
+
};
|
|
505
|
+
function at() {
|
|
506
|
+
return {
|
|
507
|
+
poolId: "brand",
|
|
508
|
+
modeId: "random",
|
|
509
|
+
colors: n.find((e) => e.id === "brand")?.defaults ?? []
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
var ot = ({ colors: e }) => ({
|
|
513
|
+
primary: e[0],
|
|
514
|
+
secondary: e[1],
|
|
515
|
+
light: e[2],
|
|
516
|
+
dark: e[3],
|
|
517
|
+
accent: e[4],
|
|
518
|
+
bg: e[5]
|
|
519
|
+
});
|
|
520
|
+
async function J(e) {
|
|
521
|
+
try {
|
|
522
|
+
let t = r[e.aspect] ?? r["1:1"], n = {
|
|
523
|
+
layers: e.layers,
|
|
524
|
+
palette: ot(e.palette),
|
|
525
|
+
aspect: e.aspect,
|
|
526
|
+
canvasW: t.w,
|
|
527
|
+
canvasH: t.h
|
|
528
|
+
};
|
|
529
|
+
await y(n.layers);
|
|
530
|
+
let i = tt / Math.max(t.w, t.h), a = document.createElement("canvas");
|
|
531
|
+
a.width = Math.round(t.w * i), a.height = Math.round(t.h * i);
|
|
532
|
+
let o = URL.createObjectURL(new Blob([_(n)], { type: "image/svg+xml" }));
|
|
533
|
+
try {
|
|
534
|
+
let e = new Image();
|
|
535
|
+
await new Promise((t, n) => {
|
|
536
|
+
e.onload = t, e.onerror = n, e.src = o;
|
|
537
|
+
}), a.getContext("2d").drawImage(e, 0, 0, a.width, a.height);
|
|
538
|
+
} finally {
|
|
539
|
+
URL.revokeObjectURL(o);
|
|
540
|
+
}
|
|
541
|
+
return a.toDataURL("image/webp", .8);
|
|
542
|
+
} catch {
|
|
543
|
+
return null;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
var st = (e, t) => ({
|
|
547
|
+
visible: !0,
|
|
548
|
+
opacity: 1,
|
|
549
|
+
blend: "normal",
|
|
550
|
+
type: e,
|
|
551
|
+
...t
|
|
552
|
+
}), ct = (e) => e.layers.every((e) => e.type !== "loop" || i("generators")?.loopById(e.loopId)?.kind !== "engine"), lt = (e) => JSON.parse(JSON.stringify(e.layers));
|
|
553
|
+
function ut() {
|
|
554
|
+
let e = x(), t = (e) => h.find((t) => t.id === e)?.preset, n = (t) => e.find((e) => t(e) && ct(e)), r = (e) => n((t) => t.mode === "labs" && t.sub === e), i = e.filter((e) => e.mode === "morph" && ct(e));
|
|
555
|
+
return [
|
|
556
|
+
[
|
|
557
|
+
"Poster draft",
|
|
558
|
+
"editor",
|
|
559
|
+
t("social-portrait"),
|
|
560
|
+
34,
|
|
561
|
+
2
|
|
562
|
+
],
|
|
563
|
+
[
|
|
564
|
+
"Flow study",
|
|
565
|
+
"labs",
|
|
566
|
+
r("Flow"),
|
|
567
|
+
12,
|
|
568
|
+
5
|
|
569
|
+
],
|
|
570
|
+
[
|
|
571
|
+
"Type specimen",
|
|
572
|
+
"editor",
|
|
573
|
+
e.find((e) => e.id === "ship:editor:type-statement"),
|
|
574
|
+
27,
|
|
575
|
+
26
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
"Pattern tile",
|
|
579
|
+
"editor",
|
|
580
|
+
t("compositor"),
|
|
581
|
+
40,
|
|
582
|
+
50
|
|
583
|
+
],
|
|
584
|
+
[
|
|
585
|
+
"Morph study",
|
|
586
|
+
"morph",
|
|
587
|
+
i[0],
|
|
588
|
+
9,
|
|
589
|
+
72
|
|
590
|
+
],
|
|
591
|
+
[
|
|
592
|
+
"Launch card",
|
|
593
|
+
"editor",
|
|
594
|
+
t("social-square"),
|
|
595
|
+
21,
|
|
596
|
+
96
|
|
597
|
+
],
|
|
598
|
+
[
|
|
599
|
+
"Penrose tiling",
|
|
600
|
+
"labs",
|
|
601
|
+
r("Penrose"),
|
|
602
|
+
30,
|
|
603
|
+
130
|
|
604
|
+
],
|
|
605
|
+
[
|
|
606
|
+
"Shape study",
|
|
607
|
+
"editor",
|
|
608
|
+
"shapes",
|
|
609
|
+
8,
|
|
610
|
+
150
|
|
611
|
+
],
|
|
612
|
+
[
|
|
613
|
+
"Story frame",
|
|
614
|
+
"editor",
|
|
615
|
+
t("social-story"),
|
|
616
|
+
18,
|
|
617
|
+
200
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
"Curve study",
|
|
621
|
+
"labs",
|
|
622
|
+
r("Math"),
|
|
623
|
+
25,
|
|
624
|
+
260
|
|
625
|
+
],
|
|
626
|
+
[
|
|
627
|
+
"Leaf form",
|
|
628
|
+
"editor",
|
|
629
|
+
e.find((e) => e.id === "ship:editor:vector-leaf"),
|
|
630
|
+
15,
|
|
631
|
+
330
|
|
632
|
+
],
|
|
633
|
+
[
|
|
634
|
+
"Scanline study",
|
|
635
|
+
"labs",
|
|
636
|
+
r("Scanline"),
|
|
637
|
+
38,
|
|
638
|
+
410
|
|
639
|
+
],
|
|
640
|
+
[
|
|
641
|
+
"Morph loop",
|
|
642
|
+
"morph",
|
|
643
|
+
i[Math.floor(i.length / 2)],
|
|
644
|
+
33,
|
|
645
|
+
520
|
|
646
|
+
],
|
|
647
|
+
[
|
|
648
|
+
"Header lockup",
|
|
649
|
+
"editor",
|
|
650
|
+
t("hero-lockup"),
|
|
651
|
+
42,
|
|
652
|
+
700
|
|
653
|
+
]
|
|
654
|
+
].filter(([, , e]) => e);
|
|
655
|
+
}
|
|
656
|
+
var dt = [
|
|
657
|
+
st("background", { color: "palette:light" }),
|
|
658
|
+
st("shape", {
|
|
659
|
+
kind: "rect",
|
|
660
|
+
x: 140,
|
|
661
|
+
y: 140,
|
|
662
|
+
w: 420,
|
|
663
|
+
h: 420,
|
|
664
|
+
radius: 24,
|
|
665
|
+
color: "palette:primary"
|
|
666
|
+
}),
|
|
667
|
+
st("shape", {
|
|
668
|
+
kind: "ellipse",
|
|
669
|
+
x: 480,
|
|
670
|
+
y: 360,
|
|
671
|
+
w: 460,
|
|
672
|
+
h: 460,
|
|
673
|
+
color: "palette:secondary"
|
|
674
|
+
}),
|
|
675
|
+
st("shape", {
|
|
676
|
+
kind: "triangle",
|
|
677
|
+
x: 200,
|
|
678
|
+
y: 600,
|
|
679
|
+
w: 320,
|
|
680
|
+
h: 300,
|
|
681
|
+
color: "palette:dark"
|
|
682
|
+
})
|
|
683
|
+
];
|
|
684
|
+
async function ft() {
|
|
685
|
+
let e = at(), t = Date.now(), n = [];
|
|
686
|
+
for (let [r, i, a, o, s] of ut()) {
|
|
687
|
+
let c = {
|
|
688
|
+
...a === "shapes" ? {
|
|
689
|
+
intent: "whole",
|
|
690
|
+
aspect: "1:1",
|
|
691
|
+
layers: dt
|
|
692
|
+
} : {
|
|
693
|
+
intent: a.intent ?? "whole",
|
|
694
|
+
aspect: a.aspect ?? "1:1",
|
|
695
|
+
layers: lt(a),
|
|
696
|
+
...a.morph ? { morph: JSON.parse(JSON.stringify(a.morph)) } : {}
|
|
697
|
+
},
|
|
698
|
+
mode: i,
|
|
699
|
+
name: r,
|
|
700
|
+
palette: e
|
|
701
|
+
}, l = await J(c);
|
|
702
|
+
n.push({
|
|
703
|
+
spec: {
|
|
704
|
+
...c,
|
|
705
|
+
...l ? { thumb: l } : {}
|
|
706
|
+
},
|
|
707
|
+
dates: {
|
|
708
|
+
savedAt: t - o * nt,
|
|
709
|
+
updatedAt: t - s * q
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
return n;
|
|
714
|
+
}
|
|
715
|
+
function pt() {
|
|
716
|
+
let { library: e, addItem: t, replaceAll: n } = d(), r = I(null), i = I(e);
|
|
717
|
+
i.current = e, F(() => {
|
|
718
|
+
if (rt()) return;
|
|
719
|
+
if ((i.current.preset ?? []).some((e) => !e.shipped)) {
|
|
720
|
+
it();
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
let e = !0;
|
|
724
|
+
return ft().then((n) => {
|
|
725
|
+
if (!e || rt() || (i.current.preset ?? []).some((e) => !e.shipped)) return;
|
|
726
|
+
it();
|
|
727
|
+
let a = /* @__PURE__ */ new Map();
|
|
728
|
+
for (let e of n) {
|
|
729
|
+
let n = t("preset", e.spec);
|
|
730
|
+
n && a.set(n, e.dates);
|
|
731
|
+
}
|
|
732
|
+
r.current = a;
|
|
733
|
+
}), () => {
|
|
734
|
+
e = !1;
|
|
735
|
+
};
|
|
736
|
+
}, [t]), F(() => {
|
|
737
|
+
let t = r.current, i = e.preset ?? [];
|
|
738
|
+
!t || ![...t.keys()].every((e) => i.some((t) => t.id === e)) || (r.current = null, n({
|
|
739
|
+
...e,
|
|
740
|
+
preset: i.map((e) => t.has(e.id) ? {
|
|
741
|
+
...e,
|
|
742
|
+
...t.get(e.id)
|
|
743
|
+
} : e)
|
|
744
|
+
}));
|
|
745
|
+
}, [e, n]);
|
|
746
|
+
}
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/editor/kolbox/pages/Home.jsx
|
|
749
|
+
var mt = [
|
|
750
|
+
{
|
|
751
|
+
value: "modified",
|
|
752
|
+
label: "Last modified"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
value: "created",
|
|
756
|
+
label: "Created"
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
value: "name",
|
|
760
|
+
label: "Name"
|
|
761
|
+
}
|
|
762
|
+
], ht = {
|
|
763
|
+
modified: (e, t) => t.modified - e.modified,
|
|
764
|
+
created: (e, t) => t.created - e.created,
|
|
765
|
+
name: (e, t) => e.name.localeCompare(t.name)
|
|
766
|
+
}, gt = {
|
|
767
|
+
editor: "Editor",
|
|
768
|
+
labs: "Labs",
|
|
769
|
+
morph: "Morph",
|
|
770
|
+
randomiser: "Randomiser"
|
|
771
|
+
}, _t = {
|
|
772
|
+
editor: "desktop",
|
|
773
|
+
labs: "globe",
|
|
774
|
+
randomiser: "refresh",
|
|
775
|
+
morph: "swap"
|
|
776
|
+
}, Y = /* @__PURE__ */ new Map(), vt = (e) => new Promise((t) => {
|
|
777
|
+
let n = Date.now(), r = () => {
|
|
778
|
+
let i = !1;
|
|
779
|
+
try {
|
|
780
|
+
i = (JSON.parse(localStorage.getItem("kol.editor.library.v3") || "{}").preset ?? []).some((t) => t.id === e);
|
|
781
|
+
} catch {}
|
|
782
|
+
i || Date.now() - n > 1e3 ? t() : requestAnimationFrame(r);
|
|
783
|
+
};
|
|
784
|
+
r();
|
|
785
|
+
}), yt = (e, t) => {
|
|
786
|
+
let n = new URL(window.location.href);
|
|
787
|
+
n.searchParams.set("open", e), n.hash = t === "morph" ? "#/morph" : "#/editor", window.history.pushState(null, "", n.pathname + n.search + n.hash), window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
788
|
+
};
|
|
789
|
+
function bt() {
|
|
790
|
+
let { library: t, addItem: n, renameItem: r, duplicateItem: i, removeItem: a, setThumb: o } = d();
|
|
791
|
+
pt(), se();
|
|
792
|
+
let [s, c] = L(!1), [l, u] = L(!1), f = I(null), p = I(null), [, m] = L(0), [h, g] = L("recents"), [_, v] = L("grid"), [y, b] = L("modified"), [x, ee] = L("all"), [S, C] = L("all"), [Ce, k] = L(""), [A, De] = L(null), [M, N] = L(null), [Oe, je] = L(!1);
|
|
793
|
+
F(() => {
|
|
794
|
+
let e = (e) => {
|
|
795
|
+
!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== "k" || e.target.closest?.("input, textarea, [contenteditable]") || (e.preventDefault(), window.dispatchEvent(new CustomEvent("kolbox:search")));
|
|
796
|
+
};
|
|
797
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
798
|
+
}, []), F(() => {
|
|
799
|
+
let e = (e) => {
|
|
800
|
+
e.code !== "Backslash" || !e.shiftKey || e.metaKey || e.ctrlKey || e.altKey || e.target.closest?.("input, textarea, [contenteditable]") || (e.preventDefault(), je((e) => !e));
|
|
801
|
+
};
|
|
802
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
803
|
+
}, []), F(() => {
|
|
804
|
+
let e = () => m((e) => e + 1);
|
|
805
|
+
return window.addEventListener("kolbox:account", e), () => window.removeEventListener("kolbox:account", e);
|
|
806
|
+
}, []);
|
|
807
|
+
let Ne = Re(() => (t.preset ?? []).filter((e) => !e.shipped), [t]), P = Ne.map((e) => {
|
|
808
|
+
let t = e.mode ?? "editor", n = Y.get(e.id) ?? {};
|
|
809
|
+
return {
|
|
810
|
+
id: e.id,
|
|
811
|
+
name: e.name || "Untitled",
|
|
812
|
+
type: t,
|
|
813
|
+
thumb: e.thumb,
|
|
814
|
+
modified: e.updatedAt ?? e.savedAt,
|
|
815
|
+
created: e.savedAt,
|
|
816
|
+
size: Fe(new Blob([JSON.stringify(e)]).size),
|
|
817
|
+
mark: {
|
|
818
|
+
icon: _t[t] ?? "desktop",
|
|
819
|
+
label: gt[t] ?? t
|
|
820
|
+
},
|
|
821
|
+
tags: n.tags ?? [],
|
|
822
|
+
note: n.note ?? "",
|
|
823
|
+
starred: xe(e.id),
|
|
824
|
+
trashed: T(e.id)
|
|
825
|
+
};
|
|
826
|
+
}), Le = P.filter((e) => !e.trashed), ze = [...new Set(P.map((e) => e.type))], He = [...new Set(P.flatMap((e) => e.tags))], V = Ce.trim().toLowerCase(), We = h === "folders" ? w().filter((e) => !e.builtIn).map((e) => {
|
|
827
|
+
let t = Le.filter((t) => E(t.id) === e.id);
|
|
828
|
+
return {
|
|
829
|
+
id: e.id,
|
|
830
|
+
name: e.name,
|
|
831
|
+
icon: "folder",
|
|
832
|
+
folder: !0,
|
|
833
|
+
starred: xe(e.id),
|
|
834
|
+
created: e.created,
|
|
835
|
+
modified: Math.max(e.created ?? 0, ...t.map((e) => e.modified ?? 0))
|
|
836
|
+
};
|
|
837
|
+
}) : h === "trash" ? P.filter((e) => e.trashed) : Le.filter((e) => h === "recents" || E(e.id) === h), H = We.filter((e) => (e.folder || (x === "all" || e.type === x) && (S === "all" || e.tags.includes(S))) && (!V || e.name.toLowerCase().includes(V))).sort(ht[y]), Ge = () => {
|
|
838
|
+
let t = e().defaultAspect, r = n("preset", {
|
|
839
|
+
mode: "editor",
|
|
840
|
+
layers: [],
|
|
841
|
+
frameModel: 3,
|
|
842
|
+
layerModel: 2,
|
|
843
|
+
...t && t !== "custom" ? { aspect: t } : {}
|
|
844
|
+
});
|
|
845
|
+
r && (be(r, Ke), vt(r).then(() => yt(r)));
|
|
846
|
+
}, Ke = h === "recents" ? pe.id : h, qe = async () => {
|
|
847
|
+
let e = await ge();
|
|
848
|
+
if (e) try {
|
|
849
|
+
let t = await me(e), r = n("preset", t);
|
|
850
|
+
r && (be(r, Ke), await vt(r), yt(r, t.mode));
|
|
851
|
+
} catch (e) {
|
|
852
|
+
ve({
|
|
853
|
+
title: e.message,
|
|
854
|
+
action: "OK",
|
|
855
|
+
cancel: null
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
}, Je = async () => {
|
|
859
|
+
let e = (await fe({
|
|
860
|
+
title: "New folder",
|
|
861
|
+
value: "",
|
|
862
|
+
placeholder: "Folder name",
|
|
863
|
+
action: "Create"
|
|
864
|
+
}))?.trim(), t = e && ye(e);
|
|
865
|
+
return t && g(t), t;
|
|
866
|
+
}, Ye = (e, t) => {
|
|
867
|
+
Y.set(e, {
|
|
868
|
+
...Y.get(e),
|
|
869
|
+
...t
|
|
870
|
+
}), m((e) => e + 1);
|
|
871
|
+
}, U = {
|
|
872
|
+
rename: (e, t) => r("preset", e.id, t),
|
|
873
|
+
duplicate: (e) => {
|
|
874
|
+
let t = i("preset", e.id);
|
|
875
|
+
t && be(t, E(e.id)), t && Y.has(e.id) && Y.set(t, { ...Y.get(e.id) });
|
|
876
|
+
},
|
|
877
|
+
remove: async (e) => (ae(e.id), !0),
|
|
878
|
+
restore: (e) => oe(e.id),
|
|
879
|
+
purge: async (e) => {
|
|
880
|
+
let t = await ve({
|
|
881
|
+
title: `Permanently delete “${e.name || "Untitled"}”?`,
|
|
882
|
+
action: "Delete"
|
|
883
|
+
});
|
|
884
|
+
return t && (a("preset", e.id), de(e.id)), t;
|
|
885
|
+
},
|
|
886
|
+
star: (e) => he(e.id),
|
|
887
|
+
download: async (e) => {
|
|
888
|
+
let t = Ne.find((t) => t.id === e.id);
|
|
889
|
+
if (t) {
|
|
890
|
+
let n = await _e(t, e.name);
|
|
891
|
+
Pe(n.blob, n.name);
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
cover: async (e) => {
|
|
895
|
+
let t = await Ie();
|
|
896
|
+
t && o("preset", e.id, t);
|
|
897
|
+
}
|
|
898
|
+
}, Xe = async (e) => {
|
|
899
|
+
let t = await fe({
|
|
900
|
+
title: "Rename:",
|
|
901
|
+
value: e.name
|
|
902
|
+
});
|
|
903
|
+
t != null && t.trim() && t.trim() !== e.name && U.rename(e, t.trim());
|
|
904
|
+
}, Ze = (e, t) => ({
|
|
905
|
+
getBoundingClientRect: () => new DOMRect(e, t, 0, 0),
|
|
906
|
+
contains: () => !1
|
|
907
|
+
}), [W, G] = L(() => /* @__PURE__ */ new Set()), K = I(null), tt = I(null), [q, nt] = L(null), [rt, it] = L(null);
|
|
908
|
+
F(() => {
|
|
909
|
+
G(/* @__PURE__ */ new Set()), K.current = null;
|
|
910
|
+
}, [h]);
|
|
911
|
+
let at = H.map((e) => e.id), ot = (e) => e?.closest?.("[data-file-card], [data-file-row]"), J = (e) => e.getAttribute("data-file-card") ?? e.getAttribute("data-file-row"), st = (e, t) => {
|
|
912
|
+
if (t.shiftKey && K.current && at.includes(K.current)) {
|
|
913
|
+
let t = at.indexOf(K.current), n = at.indexOf(e);
|
|
914
|
+
G(new Set(at.slice(Math.min(t, n), Math.max(t, n) + 1)));
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
K.current = e, t.metaKey || t.ctrlKey ? G((t) => {
|
|
918
|
+
let n = new Set(t);
|
|
919
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
920
|
+
}) : G(new Set([e]));
|
|
921
|
+
}, ct = (e) => W.has(e.id) ? H.filter((e) => W.has(e.id)) : [e], lt = (e, t) => {
|
|
922
|
+
e.forEach((e) => be(e, t)), G(/* @__PURE__ */ new Set());
|
|
923
|
+
}, ut = (e) => {
|
|
924
|
+
e.forEach((e) => ae(e)), G(/* @__PURE__ */ new Set());
|
|
925
|
+
}, dt = async (e) => {
|
|
926
|
+
await ve({
|
|
927
|
+
title: e.length === 1 ? `Permanently delete “${e[0].name || "Untitled"}”?` : `Permanently delete ${e.length} files?`,
|
|
928
|
+
action: "Delete"
|
|
929
|
+
}) && (e.forEach((e) => {
|
|
930
|
+
a("preset", e.id), de(e.id);
|
|
931
|
+
}), G(/* @__PURE__ */ new Set()));
|
|
932
|
+
}, ft = (e, t) => {
|
|
933
|
+
W.has(e.id) || (G(new Set([e.id])), K.current = e.id), N({
|
|
934
|
+
file: e,
|
|
935
|
+
files: ct(e),
|
|
936
|
+
anchor: Ze(t.clientX, t.clientY)
|
|
937
|
+
});
|
|
938
|
+
}, bt = (e) => {
|
|
939
|
+
if (e.target.closest("button, input")) return;
|
|
940
|
+
let t = ot(e.target);
|
|
941
|
+
t ? st(J(t), e) : q?.moved || G(/* @__PURE__ */ new Set());
|
|
942
|
+
}, xt = (e) => {
|
|
943
|
+
if (e.button !== 0 || ot(e.target) || e.target.closest("button, input")) return;
|
|
944
|
+
let t = e.clientX, n = e.clientY, r = e.metaKey || e.ctrlKey || e.shiftKey ? new Set(W) : /* @__PURE__ */ new Set(), i = [...tt.current?.querySelectorAll("[data-file-card], [data-file-row]") ?? []], a = (e) => {
|
|
945
|
+
let a = {
|
|
946
|
+
left: Math.min(t, e.clientX),
|
|
947
|
+
top: Math.min(n, e.clientY),
|
|
948
|
+
right: Math.max(t, e.clientX),
|
|
949
|
+
bottom: Math.max(n, e.clientY)
|
|
950
|
+
};
|
|
951
|
+
if (a.right - a.left < 3 && a.bottom - a.top < 3) return;
|
|
952
|
+
nt({
|
|
953
|
+
...a,
|
|
954
|
+
moved: !0
|
|
955
|
+
});
|
|
956
|
+
let o = new Set(r);
|
|
957
|
+
i.forEach((e) => {
|
|
958
|
+
let t = e.getBoundingClientRect();
|
|
959
|
+
t.left < a.right && t.right > a.left && t.top < a.bottom && t.bottom > a.top && o.add(J(e));
|
|
960
|
+
}), G(o);
|
|
961
|
+
}, o = () => {
|
|
962
|
+
window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", o), setTimeout(() => nt(null));
|
|
963
|
+
};
|
|
964
|
+
window.addEventListener("pointermove", a), window.addEventListener("pointerup", o);
|
|
965
|
+
}, St = (e) => {
|
|
966
|
+
let t = ot(e.target);
|
|
967
|
+
if (!t) return;
|
|
968
|
+
let n = J(t), r = W.has(n) ? [...W] : [n];
|
|
969
|
+
W.has(n) || G(new Set([n])), e.dataTransfer.setData(Ue, JSON.stringify(r)), e.dataTransfer.effectAllowed = "move";
|
|
970
|
+
}, Ct = (e) => {
|
|
971
|
+
let t = h === "folders" && e.dataTransfer.types.includes("application/x-kolbox-files") && ot(e.target);
|
|
972
|
+
return t ? J(t) : null;
|
|
973
|
+
}, wt = (e) => {
|
|
974
|
+
let t = Ct(e);
|
|
975
|
+
t && (e.preventDefault(), e.dataTransfer.dropEffect = "move", it(t));
|
|
976
|
+
}, Tt = (e) => {
|
|
977
|
+
let t = Ct(e);
|
|
978
|
+
it(null), t && (e.preventDefault(), lt(JSON.parse(e.dataTransfer.getData(Ue)), t));
|
|
979
|
+
};
|
|
980
|
+
F(() => {
|
|
981
|
+
tt.current?.querySelectorAll("[data-file-card], [data-file-row]").forEach((e) => {
|
|
982
|
+
let t = J(e);
|
|
983
|
+
e.toggleAttribute("data-selected", W.has(t)), e.toggleAttribute("data-drop-over", rt === t), e.draggable = h !== "folders" && h !== "trash";
|
|
984
|
+
});
|
|
985
|
+
}), F(() => {
|
|
986
|
+
let e = (e) => {
|
|
987
|
+
!["Delete", "Backspace"].includes(e.key) || !W.size || h === "trash" || h === "folders" || e.target.closest?.("input, textarea, [contenteditable]") || (e.preventDefault(), ut([...W]));
|
|
988
|
+
};
|
|
989
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
990
|
+
});
|
|
991
|
+
let X = P.find((e) => e.id === A), Et = (e) => {
|
|
992
|
+
let t = Ne.find((t) => t.id === e.id) ?? {};
|
|
993
|
+
return [
|
|
994
|
+
{
|
|
995
|
+
label: "Date",
|
|
996
|
+
value: new Date(e.modified).toISOString().slice(0, 10)
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
label: "Size",
|
|
1000
|
+
value: e.size
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
label: "Chrome",
|
|
1004
|
+
value: e.mark.label
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
label: "Layers",
|
|
1008
|
+
value: t.layers?.length ?? 0
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
label: "Aspect",
|
|
1012
|
+
value: t.aspect ?? "1:1"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
label: "Location",
|
|
1016
|
+
value: Se(E(e.id)).name
|
|
1017
|
+
}
|
|
1018
|
+
];
|
|
1019
|
+
}, Dt = [
|
|
1020
|
+
{
|
|
1021
|
+
id: "recents",
|
|
1022
|
+
icon: "clock",
|
|
1023
|
+
label: "Recents"
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
id: "drafts",
|
|
1027
|
+
icon: "file",
|
|
1028
|
+
label: "Drafts"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
id: "folders",
|
|
1032
|
+
icon: "grid-2x2",
|
|
1033
|
+
label: "All folders"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
id: "trash",
|
|
1037
|
+
icon: "trash",
|
|
1038
|
+
label: "Trash"
|
|
1039
|
+
}
|
|
1040
|
+
], Ot = w().filter((e) => !e.builtIn), kt = Dt.find((e) => e.id === h)?.label ?? Se(h).name, Z = Ot.find((e) => e.id === h), At = async (e) => {
|
|
1041
|
+
let t = (await fe({
|
|
1042
|
+
title: "Rename:",
|
|
1043
|
+
value: e.name
|
|
1044
|
+
}))?.trim();
|
|
1045
|
+
t && t !== e.name && ne(e.id, t);
|
|
1046
|
+
}, jt = async (e) => {
|
|
1047
|
+
await ve({
|
|
1048
|
+
title: `Delete “${e.name}”?`,
|
|
1049
|
+
action: "Delete"
|
|
1050
|
+
}) && (re(e.id), h === e.id && g("folders"));
|
|
1051
|
+
}, Mt = (e) => [[{
|
|
1052
|
+
label: "Rename",
|
|
1053
|
+
icon: "edit",
|
|
1054
|
+
run: () => At(e)
|
|
1055
|
+
}, {
|
|
1056
|
+
label: "Delete",
|
|
1057
|
+
icon: "trash",
|
|
1058
|
+
run: () => jt(e)
|
|
1059
|
+
}]], Nt = te().map((e) => {
|
|
1060
|
+
let t = Ot.find((t) => t.id === e);
|
|
1061
|
+
if (t) return {
|
|
1062
|
+
id: e,
|
|
1063
|
+
icon: "folder",
|
|
1064
|
+
label: t.name,
|
|
1065
|
+
selected: h === e,
|
|
1066
|
+
onClick: () => g(e)
|
|
1067
|
+
};
|
|
1068
|
+
let n = Le.find((t) => t.id === e);
|
|
1069
|
+
return n && {
|
|
1070
|
+
id: e,
|
|
1071
|
+
icon: "file",
|
|
1072
|
+
label: n.name,
|
|
1073
|
+
onClick: () => yt(n.id, n.type)
|
|
1074
|
+
};
|
|
1075
|
+
}).filter(Boolean), Pt = h === "trash" ? {
|
|
1076
|
+
onRemove: U.purge,
|
|
1077
|
+
onMenu: ft
|
|
1078
|
+
} : h === "folders" ? {
|
|
1079
|
+
onOpen: (e) => g(e.id),
|
|
1080
|
+
onStar: U.star,
|
|
1081
|
+
onMenu: ft
|
|
1082
|
+
} : {
|
|
1083
|
+
onOpen: (e) => yt(e.id, e.type),
|
|
1084
|
+
onDownload: U.download,
|
|
1085
|
+
onStar: U.star,
|
|
1086
|
+
onSettings: (e) => De(e.id),
|
|
1087
|
+
onRemove: U.remove,
|
|
1088
|
+
onMenu: ft
|
|
1089
|
+
}, Q = ce(), Ft = Q ? [[{
|
|
1090
|
+
label: Q.name || Q.email || "Profile",
|
|
1091
|
+
icon: "user",
|
|
1092
|
+
disabled: !0
|
|
1093
|
+
}, {
|
|
1094
|
+
label: `Plan: ${Q.plan ?? "Free"}`,
|
|
1095
|
+
icon: "star",
|
|
1096
|
+
disabled: !0
|
|
1097
|
+
}], [{
|
|
1098
|
+
label: "Sign out",
|
|
1099
|
+
run: () => {
|
|
1100
|
+
ue(), m((e) => e + 1);
|
|
1101
|
+
}
|
|
1102
|
+
}]] : [{
|
|
1103
|
+
title: "Not signed in",
|
|
1104
|
+
rows: [{
|
|
1105
|
+
label: "Sign in…",
|
|
1106
|
+
icon: "user",
|
|
1107
|
+
run: le
|
|
1108
|
+
}]
|
|
1109
|
+
}], It = {
|
|
1110
|
+
files: Le.filter((e) => (x === "all" || e.type === x) && ([
|
|
1111
|
+
"recents",
|
|
1112
|
+
"folders",
|
|
1113
|
+
"trash"
|
|
1114
|
+
].includes(h) || E(e.id) === h) && (!V || e.name.toLowerCase().includes(V))).sort(ht.modified).slice(0, 5).map((e) => ({
|
|
1115
|
+
id: e.id,
|
|
1116
|
+
name: e.name,
|
|
1117
|
+
icon: e.mark.icon,
|
|
1118
|
+
folder: Se(E(e.id)).name,
|
|
1119
|
+
modified: e.modified,
|
|
1120
|
+
onOpen: () => yt(e.id, e.type)
|
|
1121
|
+
})),
|
|
1122
|
+
filters: [
|
|
1123
|
+
{
|
|
1124
|
+
id: "type",
|
|
1125
|
+
label: "Type:",
|
|
1126
|
+
hint: "Filter by resource type",
|
|
1127
|
+
value: x !== "all" && (gt[x] ?? x),
|
|
1128
|
+
groups: [[{
|
|
1129
|
+
value: "all",
|
|
1130
|
+
label: "All types"
|
|
1131
|
+
}, ...ze.map((e) => ({
|
|
1132
|
+
value: e,
|
|
1133
|
+
label: gt[e] ?? e
|
|
1134
|
+
}))].map((e) => ({
|
|
1135
|
+
label: e.label,
|
|
1136
|
+
check: x === e.value,
|
|
1137
|
+
run: () => ee(e.value)
|
|
1138
|
+
}))]
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
id: "by",
|
|
1142
|
+
label: "By:",
|
|
1143
|
+
hint: "Filter by file creator",
|
|
1144
|
+
groups: [[Q ? {
|
|
1145
|
+
label: Q.name || Q.email,
|
|
1146
|
+
icon: "user",
|
|
1147
|
+
check: !0
|
|
1148
|
+
} : {
|
|
1149
|
+
label: "Not signed in",
|
|
1150
|
+
icon: "user",
|
|
1151
|
+
disabled: !0
|
|
1152
|
+
}]]
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
id: "in",
|
|
1156
|
+
label: "In:",
|
|
1157
|
+
hint: "Filter by folder",
|
|
1158
|
+
value: ![
|
|
1159
|
+
"recents",
|
|
1160
|
+
"folders",
|
|
1161
|
+
"trash"
|
|
1162
|
+
].includes(h) && Se(h).name,
|
|
1163
|
+
groups: [[{
|
|
1164
|
+
id: "recents",
|
|
1165
|
+
name: "Recents"
|
|
1166
|
+
}, ...w()].map((e) => ({
|
|
1167
|
+
label: e.name,
|
|
1168
|
+
check: h === e.id,
|
|
1169
|
+
run: () => g(e.id)
|
|
1170
|
+
}))]
|
|
1171
|
+
}
|
|
1172
|
+
]
|
|
1173
|
+
}, Lt = {
|
|
1174
|
+
drafts: (e) => lt(e, pe.id),
|
|
1175
|
+
trash: ut
|
|
1176
|
+
};
|
|
1177
|
+
return /* @__PURE__ */ B(Ve, {
|
|
1178
|
+
variant: "kolbox",
|
|
1179
|
+
sidebar: !Oe && /* @__PURE__ */ z(Qe, {
|
|
1180
|
+
account: {
|
|
1181
|
+
name: Q?.name || Q?.email || "Not signed in",
|
|
1182
|
+
initial: (Q?.name || Q?.email)?.[0]
|
|
1183
|
+
},
|
|
1184
|
+
accountMenu: Ft,
|
|
1185
|
+
starred: Nt,
|
|
1186
|
+
search: Ce,
|
|
1187
|
+
onSearch: k,
|
|
1188
|
+
recent: It,
|
|
1189
|
+
items: Dt.map((e) => ({
|
|
1190
|
+
...e,
|
|
1191
|
+
selected: e.id === h,
|
|
1192
|
+
onClick: () => g(e.id),
|
|
1193
|
+
onDrop: Lt[e.id]
|
|
1194
|
+
}))
|
|
1195
|
+
}),
|
|
1196
|
+
children: [
|
|
1197
|
+
/* @__PURE__ */ z($e, {
|
|
1198
|
+
crumbs: [kt],
|
|
1199
|
+
actions: /* @__PURE__ */ B(R, { children: [
|
|
1200
|
+
/* @__PURE__ */ z("span", {
|
|
1201
|
+
ref: p,
|
|
1202
|
+
className: "flex",
|
|
1203
|
+
children: /* @__PURE__ */ B(O, {
|
|
1204
|
+
variant: "kolbox",
|
|
1205
|
+
tone: "primary",
|
|
1206
|
+
iconLeft: "plus",
|
|
1207
|
+
"aria-haspopup": "menu",
|
|
1208
|
+
"aria-expanded": s,
|
|
1209
|
+
onClick: () => c((e) => !e),
|
|
1210
|
+
className: "h-8!",
|
|
1211
|
+
children: ["Create", /* @__PURE__ */ z(D, {
|
|
1212
|
+
name: "chevron-down",
|
|
1213
|
+
size: 12
|
|
1214
|
+
})]
|
|
1215
|
+
})
|
|
1216
|
+
}),
|
|
1217
|
+
/* @__PURE__ */ z(j, {
|
|
1218
|
+
variant: "kolbox",
|
|
1219
|
+
"aria-label": "Create",
|
|
1220
|
+
anchor: p,
|
|
1221
|
+
open: s,
|
|
1222
|
+
onClose: () => c(!1),
|
|
1223
|
+
onSelect: (e) => e.run?.(),
|
|
1224
|
+
groups: [[{
|
|
1225
|
+
label: "New file",
|
|
1226
|
+
icon: "plus",
|
|
1227
|
+
run: Ge
|
|
1228
|
+
}, {
|
|
1229
|
+
label: "Open file…",
|
|
1230
|
+
icon: "upload",
|
|
1231
|
+
run: qe
|
|
1232
|
+
}]]
|
|
1233
|
+
}),
|
|
1234
|
+
/* @__PURE__ */ z(O, {
|
|
1235
|
+
variant: "kolbox",
|
|
1236
|
+
tone: "outline",
|
|
1237
|
+
className: "h-8!",
|
|
1238
|
+
onClick: () => navigator.clipboard?.writeText(location.href),
|
|
1239
|
+
children: "Share"
|
|
1240
|
+
}),
|
|
1241
|
+
/* @__PURE__ */ z("span", {
|
|
1242
|
+
ref: f,
|
|
1243
|
+
className: "flex",
|
|
1244
|
+
children: /* @__PURE__ */ z(Me, {
|
|
1245
|
+
variant: "kolbox",
|
|
1246
|
+
label: "View options",
|
|
1247
|
+
children: /* @__PURE__ */ z(O, {
|
|
1248
|
+
variant: "kolbox",
|
|
1249
|
+
tone: "outline",
|
|
1250
|
+
"aria-label": "View options",
|
|
1251
|
+
"aria-haspopup": "menu",
|
|
1252
|
+
"aria-expanded": l,
|
|
1253
|
+
onClick: () => u((e) => !e),
|
|
1254
|
+
className: "size-8! px-0!",
|
|
1255
|
+
children: /* @__PURE__ */ z(D, {
|
|
1256
|
+
name: "nav-settings-vertical",
|
|
1257
|
+
size: 20
|
|
1258
|
+
})
|
|
1259
|
+
})
|
|
1260
|
+
})
|
|
1261
|
+
}),
|
|
1262
|
+
/* @__PURE__ */ z(j, {
|
|
1263
|
+
variant: "kolbox",
|
|
1264
|
+
"aria-label": "View options",
|
|
1265
|
+
anchor: f,
|
|
1266
|
+
open: l,
|
|
1267
|
+
onClose: () => u(!1),
|
|
1268
|
+
onSelect: (e) => e.run?.(),
|
|
1269
|
+
groups: [[{
|
|
1270
|
+
label: "Grid view",
|
|
1271
|
+
icon: "grid",
|
|
1272
|
+
run: () => v("grid")
|
|
1273
|
+
}, {
|
|
1274
|
+
label: "List view",
|
|
1275
|
+
icon: "list-bullet",
|
|
1276
|
+
run: () => v("list")
|
|
1277
|
+
}], mt.map((e) => ({
|
|
1278
|
+
label: e.label,
|
|
1279
|
+
run: () => b(e.value)
|
|
1280
|
+
}))]
|
|
1281
|
+
}),
|
|
1282
|
+
/* @__PURE__ */ z(Me, {
|
|
1283
|
+
variant: "kolbox",
|
|
1284
|
+
label: Z && xe(Z.id) ? "Unstar" : "Star",
|
|
1285
|
+
children: /* @__PURE__ */ z(O, {
|
|
1286
|
+
variant: "kolbox",
|
|
1287
|
+
tone: "outline",
|
|
1288
|
+
"aria-label": "Star",
|
|
1289
|
+
disabled: !Z,
|
|
1290
|
+
onClick: () => Z && he(Z.id),
|
|
1291
|
+
className: "size-8! px-0!",
|
|
1292
|
+
children: /* @__PURE__ */ z(D, {
|
|
1293
|
+
name: "star-solid",
|
|
1294
|
+
size: 20,
|
|
1295
|
+
className: "text-accent"
|
|
1296
|
+
})
|
|
1297
|
+
})
|
|
1298
|
+
})
|
|
1299
|
+
] })
|
|
1300
|
+
}),
|
|
1301
|
+
/* @__PURE__ */ z(ke, {
|
|
1302
|
+
variant: "kolbox",
|
|
1303
|
+
headline: kt,
|
|
1304
|
+
menu: Z && /* @__PURE__ */ z(O, {
|
|
1305
|
+
variant: "kolbox",
|
|
1306
|
+
iconOnly: "chevron-down",
|
|
1307
|
+
"aria-label": `${kt} menu`,
|
|
1308
|
+
onClick: (e) => {
|
|
1309
|
+
let t = e.currentTarget.getBoundingClientRect();
|
|
1310
|
+
N({
|
|
1311
|
+
folder: Z,
|
|
1312
|
+
anchor: Ze(t.left, t.bottom)
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
}),
|
|
1316
|
+
actions: /* @__PURE__ */ B(R, { children: [
|
|
1317
|
+
/* @__PURE__ */ B("span", {
|
|
1318
|
+
className: "mr-1 font-mono text-meta text-muted",
|
|
1319
|
+
"data-file-count": !0,
|
|
1320
|
+
children: [
|
|
1321
|
+
H.length,
|
|
1322
|
+
" of ",
|
|
1323
|
+
We.length
|
|
1324
|
+
]
|
|
1325
|
+
}),
|
|
1326
|
+
h !== "folders" && He.length > 0 && /* @__PURE__ */ z(Ee, {
|
|
1327
|
+
variant: "kolbox",
|
|
1328
|
+
size: "xs",
|
|
1329
|
+
ariaLabel: "Tags",
|
|
1330
|
+
value: S,
|
|
1331
|
+
onChange: C,
|
|
1332
|
+
options: [{
|
|
1333
|
+
value: "all",
|
|
1334
|
+
label: "All tags"
|
|
1335
|
+
}, ...He.map((e) => ({
|
|
1336
|
+
value: e,
|
|
1337
|
+
label: e
|
|
1338
|
+
}))]
|
|
1339
|
+
}),
|
|
1340
|
+
h !== "folders" && /* @__PURE__ */ z(Ee, {
|
|
1341
|
+
variant: "kolbox",
|
|
1342
|
+
size: "xs",
|
|
1343
|
+
ariaLabel: "Type",
|
|
1344
|
+
value: x,
|
|
1345
|
+
onChange: ee,
|
|
1346
|
+
options: [{
|
|
1347
|
+
value: "all",
|
|
1348
|
+
label: "All types"
|
|
1349
|
+
}, ...ze.map((e) => ({
|
|
1350
|
+
value: e,
|
|
1351
|
+
label: gt[e] ?? e
|
|
1352
|
+
}))]
|
|
1353
|
+
}),
|
|
1354
|
+
/* @__PURE__ */ z(Ee, {
|
|
1355
|
+
variant: "kolbox",
|
|
1356
|
+
size: "xs",
|
|
1357
|
+
ariaLabel: "Sort",
|
|
1358
|
+
value: y,
|
|
1359
|
+
onChange: b,
|
|
1360
|
+
options: mt
|
|
1361
|
+
}),
|
|
1362
|
+
/* @__PURE__ */ z(we, {
|
|
1363
|
+
layout: "joined",
|
|
1364
|
+
variant: "kolbox",
|
|
1365
|
+
tone: "sunken",
|
|
1366
|
+
options: [{
|
|
1367
|
+
icon: "grid",
|
|
1368
|
+
ariaLabel: "Grid view",
|
|
1369
|
+
pressed: _ === "grid",
|
|
1370
|
+
onPress: () => v("grid")
|
|
1371
|
+
}, {
|
|
1372
|
+
icon: "list-bullet",
|
|
1373
|
+
ariaLabel: "List view",
|
|
1374
|
+
pressed: _ === "list",
|
|
1375
|
+
onPress: () => v("list")
|
|
1376
|
+
}]
|
|
1377
|
+
})
|
|
1378
|
+
] })
|
|
1379
|
+
}),
|
|
1380
|
+
/* @__PURE__ */ B("div", {
|
|
1381
|
+
ref: tt,
|
|
1382
|
+
className: "relative flex min-h-0 flex-1 flex-col [&_[data-file-card][data-selected]]:border-accent [&_[data-file-card][data-selected]]:outline-1 [&_[data-file-card][data-selected]]:outline-accent [&_[data-file-card][data-selected]]:outline-solid [&_[data-file-card][data-drop-over]]:border-accent [&_[data-file-card][data-drop-over]]:bg-accent-tint [&_[data-file-row][data-selected]]:bg-accent-tint",
|
|
1383
|
+
onClick: bt,
|
|
1384
|
+
onPointerDown: xt,
|
|
1385
|
+
onDragStart: St,
|
|
1386
|
+
onDragOver: wt,
|
|
1387
|
+
onDragLeave: () => it(null),
|
|
1388
|
+
onDrop: Tt,
|
|
1389
|
+
"data-file-box": !0,
|
|
1390
|
+
children: [_ === "grid" ? /* @__PURE__ */ z(Be, {
|
|
1391
|
+
variant: "kolbox",
|
|
1392
|
+
children: H.map((e) => /* @__PURE__ */ z(Te, {
|
|
1393
|
+
variant: "kolbox",
|
|
1394
|
+
file: e,
|
|
1395
|
+
...Pt
|
|
1396
|
+
}, e.id))
|
|
1397
|
+
}) : /* @__PURE__ */ z(Ae, {
|
|
1398
|
+
variant: "kolbox",
|
|
1399
|
+
rows: H,
|
|
1400
|
+
sort: y,
|
|
1401
|
+
...Pt
|
|
1402
|
+
}), q?.moved && /* @__PURE__ */ z("div", {
|
|
1403
|
+
"aria-hidden": !0,
|
|
1404
|
+
className: "pointer-events-none fixed z-30 border border-accent bg-accent-tint",
|
|
1405
|
+
style: {
|
|
1406
|
+
left: q.left,
|
|
1407
|
+
top: q.top,
|
|
1408
|
+
width: q.right - q.left,
|
|
1409
|
+
height: q.bottom - q.top
|
|
1410
|
+
},
|
|
1411
|
+
"data-select-band": !0
|
|
1412
|
+
})]
|
|
1413
|
+
}),
|
|
1414
|
+
X && /* @__PURE__ */ z(et, {
|
|
1415
|
+
file: {
|
|
1416
|
+
...X,
|
|
1417
|
+
details: Et(X)
|
|
1418
|
+
},
|
|
1419
|
+
onClose: () => De(null),
|
|
1420
|
+
onRename: (e) => U.rename(X, e),
|
|
1421
|
+
onTags: (e) => Ye(X.id, { tags: e }),
|
|
1422
|
+
onNote: (e) => Ye(X.id, { note: e }),
|
|
1423
|
+
onCover: () => U.cover(X),
|
|
1424
|
+
onDownload: () => U.download(X),
|
|
1425
|
+
onDuplicate: () => U.duplicate(X),
|
|
1426
|
+
onRemove: () => U.remove(X)
|
|
1427
|
+
}, X.id),
|
|
1428
|
+
/* @__PURE__ */ z(j, {
|
|
1429
|
+
variant: "kolbox",
|
|
1430
|
+
"aria-label": "File",
|
|
1431
|
+
anchor: M?.anchor,
|
|
1432
|
+
open: !!M,
|
|
1433
|
+
onClose: () => N(null),
|
|
1434
|
+
onSelect: (e) => e.run?.(),
|
|
1435
|
+
groups: M?.folder ? Mt(M.folder) : M?.file?.folder ? Mt(M.file) : M?.file?.trashed ? [[{
|
|
1436
|
+
label: "Restore",
|
|
1437
|
+
icon: "undo",
|
|
1438
|
+
run: () => {
|
|
1439
|
+
M.files.forEach(U.restore), G(/* @__PURE__ */ new Set());
|
|
1440
|
+
}
|
|
1441
|
+
}, {
|
|
1442
|
+
label: "Permanently delete",
|
|
1443
|
+
icon: "trash",
|
|
1444
|
+
run: () => dt(M.files)
|
|
1445
|
+
}]] : M ? [[
|
|
1446
|
+
...M.files.length === 1 ? [{
|
|
1447
|
+
label: "Rename",
|
|
1448
|
+
icon: "edit",
|
|
1449
|
+
run: () => Xe(M.file)
|
|
1450
|
+
}] : [],
|
|
1451
|
+
{
|
|
1452
|
+
label: "Duplicate",
|
|
1453
|
+
icon: "copy",
|
|
1454
|
+
run: () => M.files.forEach(U.duplicate)
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
label: "Move to",
|
|
1458
|
+
icon: "folder",
|
|
1459
|
+
submenu: [w().map((e) => ({
|
|
1460
|
+
label: e.name,
|
|
1461
|
+
check: M.files.every((t) => E(t.id) === e.id),
|
|
1462
|
+
run: () => lt(M.files.map((e) => e.id), e.id)
|
|
1463
|
+
})), [{
|
|
1464
|
+
label: "New folder…",
|
|
1465
|
+
run: async () => {
|
|
1466
|
+
let e = M.files.map((e) => e.id), t = await Je();
|
|
1467
|
+
t && lt(e, t);
|
|
1468
|
+
}
|
|
1469
|
+
}]]
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
label: M.files.every((e) => e.starred) ? "Unstar" : "Star",
|
|
1473
|
+
icon: "star",
|
|
1474
|
+
run: () => {
|
|
1475
|
+
let e = M.files.every((e) => e.starred);
|
|
1476
|
+
M.files.filter((t) => e || !t.starred).forEach((e) => he(e.id));
|
|
1477
|
+
}
|
|
1478
|
+
},
|
|
1479
|
+
{
|
|
1480
|
+
label: "Delete",
|
|
1481
|
+
icon: "trash",
|
|
1482
|
+
run: () => ut(M.files.map((e) => e.id))
|
|
1483
|
+
}
|
|
1484
|
+
]] : []
|
|
1485
|
+
}),
|
|
1486
|
+
/* @__PURE__ */ z(ie, { mode: "home" })
|
|
1487
|
+
]
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
function xt() {
|
|
1491
|
+
return /* @__PURE__ */ z(f, { children: /* @__PURE__ */ z(bt, {}) });
|
|
1492
|
+
}
|
|
1493
|
+
//#endregion
|
|
1494
|
+
//#region src/editor/kolbox/library/covers.js
|
|
1495
|
+
var St = (e) => {
|
|
1496
|
+
let t = e * 9301 + 49297;
|
|
1497
|
+
return () => (t = (t * 9301 + 49297) % 233280) / 233280;
|
|
1498
|
+
};
|
|
1499
|
+
function Ct(e) {
|
|
1500
|
+
let t = St(e + 1), n = Math.floor(t() * 360), r = (e, t = 60, r = 1) => `hsla(${(n + e) % 360},80%,${t}%,${r})`, i = "";
|
|
1501
|
+
switch (e % 5) {
|
|
1502
|
+
case 0:
|
|
1503
|
+
i = `<defs><radialGradient id="g" cx="${20 + t() * 60}%" cy="${20 + t() * 60}%" r="80%"><stop offset="0" stop-color="${r(0, 62)}"/><stop offset=".55" stop-color="${r(40, 30, .6)}"/><stop offset="1" stop-color="${r(80, 8, 0)}"/></radialGradient></defs><rect width="400" height="400" fill="url(#g)"/>`;
|
|
1504
|
+
break;
|
|
1505
|
+
case 1:
|
|
1506
|
+
for (let e = 0; e < 9; e++) {
|
|
1507
|
+
let n = t() * 400, a = t() * 400, o = 60 + t() * 140;
|
|
1508
|
+
i += `<polygon points="${n},${a - o} ${n + o},${a + o * .7} ${n - o},${a + o * .7}" fill="${r(e * 18, 30 + t() * 35, .55)}"/>`;
|
|
1509
|
+
}
|
|
1510
|
+
break;
|
|
1511
|
+
case 2: {
|
|
1512
|
+
let e = 10 + Math.floor(t() * 10), n = 20 + t() * 60;
|
|
1513
|
+
for (let t = 0; t <= e; t++) {
|
|
1514
|
+
let a = t / e * 400;
|
|
1515
|
+
i += `<path d="M0 ${a} Q200 ${a + (t % 2 ? n : -n)} 400 ${a}" stroke="${r(t * 6, 55)}" stroke-width="1.2" fill="none" opacity="${.3 + t / e * .7}"/>`;
|
|
1516
|
+
}
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
case 3:
|
|
1520
|
+
for (let e = 0; e < 6; e++) i += `<path d="M${t() * 400} ${t() * 400} C${t() * 400} ${t() * 400} ${t() * 400} ${t() * 400} ${t() * 400} ${t() * 400}" stroke="${r(e * 50, 62)}" stroke-width="${2 + t() * 6}" fill="none" stroke-linecap="round" filter="url(#b)"/>`;
|
|
1521
|
+
i = `<defs><filter id="b"><feGaussianBlur stdDeviation="2"/></filter></defs>${i}`;
|
|
1522
|
+
break;
|
|
1523
|
+
default: {
|
|
1524
|
+
let e = 100 + t() * 200, n = 100 + t() * 200;
|
|
1525
|
+
for (let t = 14; t > 0; t--) i += `<circle cx="${e}" cy="${n}" r="${t * 22}" fill="none" stroke="${r(t * 9, 25 + t * 3)}" stroke-width="${t % 3 ? 2 : 6}"/>`;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
return `data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" preserveAspectRatio="xMidYMid slice"><rect width="400" height="400" fill="#0b0b0d"/>${i}</svg>`)}`;
|
|
1529
|
+
}
|
|
1530
|
+
//#endregion
|
|
1531
|
+
//#region src/editor/kolbox/library/files.js
|
|
1532
|
+
var wt = Date.parse("2026-10-19T12:00:00Z"), Tt = 864e5, X = {
|
|
1533
|
+
editor: {
|
|
1534
|
+
icon: "desktop",
|
|
1535
|
+
label: "Editor"
|
|
1536
|
+
},
|
|
1537
|
+
labs: {
|
|
1538
|
+
icon: "globe",
|
|
1539
|
+
label: "Labs"
|
|
1540
|
+
},
|
|
1541
|
+
randomiser: {
|
|
1542
|
+
icon: "refresh",
|
|
1543
|
+
label: "Randomiser"
|
|
1544
|
+
},
|
|
1545
|
+
morph: {
|
|
1546
|
+
icon: "swap",
|
|
1547
|
+
label: "Morph"
|
|
1548
|
+
}
|
|
1549
|
+
}, Et = [
|
|
1550
|
+
{
|
|
1551
|
+
value: "editor",
|
|
1552
|
+
label: "EDITOR"
|
|
1553
|
+
},
|
|
1554
|
+
{
|
|
1555
|
+
value: "labs",
|
|
1556
|
+
label: "LABS"
|
|
1557
|
+
},
|
|
1558
|
+
{
|
|
1559
|
+
value: "randomiser",
|
|
1560
|
+
label: "RANDOMISER"
|
|
1561
|
+
},
|
|
1562
|
+
{
|
|
1563
|
+
value: "morph",
|
|
1564
|
+
label: "MORPH"
|
|
1565
|
+
}
|
|
1566
|
+
], Dt = [
|
|
1567
|
+
"1:1",
|
|
1568
|
+
"4:5",
|
|
1569
|
+
"16:9"
|
|
1570
|
+
], Ot = (e) => {
|
|
1571
|
+
let t = l(e.id);
|
|
1572
|
+
return c.find((e) => e.id === t)?.label ?? t ?? c[0].label;
|
|
1573
|
+
}, kt = {
|
|
1574
|
+
x: 0,
|
|
1575
|
+
y: 0,
|
|
1576
|
+
w: t,
|
|
1577
|
+
h: a
|
|
1578
|
+
}, Z = (e, t) => ({
|
|
1579
|
+
id: `ship-${e}`,
|
|
1580
|
+
type: e,
|
|
1581
|
+
visible: !0,
|
|
1582
|
+
opacity: 1,
|
|
1583
|
+
blend: "normal",
|
|
1584
|
+
...t
|
|
1585
|
+
});
|
|
1586
|
+
function At(e, t) {
|
|
1587
|
+
let n = new URL(window.location.href);
|
|
1588
|
+
for (let e of [
|
|
1589
|
+
"open",
|
|
1590
|
+
"new",
|
|
1591
|
+
"preset",
|
|
1592
|
+
"cat"
|
|
1593
|
+
]) n.searchParams.delete(e);
|
|
1594
|
+
for (let [t, r] of Object.entries(e)) r != null && n.searchParams.set(t, r);
|
|
1595
|
+
n.hash = t, window.history.pushState(null, "", n.pathname + n.search + n.hash), window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
1596
|
+
}
|
|
1597
|
+
var jt = {
|
|
1598
|
+
editor: "#/editor",
|
|
1599
|
+
labs: "#/labs",
|
|
1600
|
+
randomiser: "#/randomiser",
|
|
1601
|
+
morph: "#/morph"
|
|
1602
|
+
}, Mt = (e, t, n) => ({
|
|
1603
|
+
chrome: e,
|
|
1604
|
+
date: wt - t % 60 * Tt,
|
|
1605
|
+
bytes: 640 + t * 97 % 2400,
|
|
1606
|
+
cover: Ct(t % 40),
|
|
1607
|
+
tags: [n.group, ...n.sub ? [n.sub] : []].map((e) => e.toLowerCase()),
|
|
1608
|
+
...n
|
|
1609
|
+
});
|
|
1610
|
+
function Nt(t, n) {
|
|
1611
|
+
let r = s.map((e) => ({
|
|
1612
|
+
p: e,
|
|
1613
|
+
name: e.label ?? e.name ?? e.id,
|
|
1614
|
+
group: Ot(e),
|
|
1615
|
+
sub: e.sub ?? null,
|
|
1616
|
+
kind: "loop"
|
|
1617
|
+
})), i = p.map((e) => ({
|
|
1618
|
+
p: e,
|
|
1619
|
+
name: e.label,
|
|
1620
|
+
group: "Kinetic type",
|
|
1621
|
+
sub: e.sub ?? null,
|
|
1622
|
+
kind: "kinetic"
|
|
1623
|
+
}));
|
|
1624
|
+
return [...r, ...i].map(({ p: r, name: i, group: a, sub: s, kind: c }, d) => {
|
|
1625
|
+
let f = Dt[(d + n) % 3], p = c === "loop" ? l(r.id) : null;
|
|
1626
|
+
return Mt(t, d + n, {
|
|
1627
|
+
id: `ship:${t}:${c === "kinetic" ? "type-" : ""}${r.id}`,
|
|
1628
|
+
slug: r.id,
|
|
1629
|
+
name: i,
|
|
1630
|
+
group: a,
|
|
1631
|
+
sub: s,
|
|
1632
|
+
details: [
|
|
1633
|
+
{
|
|
1634
|
+
label: "Group",
|
|
1635
|
+
value: a
|
|
1636
|
+
},
|
|
1637
|
+
...s ? [{
|
|
1638
|
+
label: "Category",
|
|
1639
|
+
value: s
|
|
1640
|
+
}] : [],
|
|
1641
|
+
{
|
|
1642
|
+
label: "Aspect",
|
|
1643
|
+
value: f
|
|
1644
|
+
}
|
|
1645
|
+
],
|
|
1646
|
+
open: () => At({
|
|
1647
|
+
preset: r.id,
|
|
1648
|
+
cat: p
|
|
1649
|
+
}, jt[t]),
|
|
1650
|
+
spec: () => ({
|
|
1651
|
+
mode: t,
|
|
1652
|
+
aspect: f,
|
|
1653
|
+
group: a,
|
|
1654
|
+
...s ? { sub: s } : {},
|
|
1655
|
+
intent: "whole",
|
|
1656
|
+
palette: null,
|
|
1657
|
+
layers: [c === "loop" ? Z("loop", {
|
|
1658
|
+
...kt,
|
|
1659
|
+
...u(o(r.id), p),
|
|
1660
|
+
themeId: e().defaultTheme
|
|
1661
|
+
}) : Z("kinetic", {
|
|
1662
|
+
...kt,
|
|
1663
|
+
presetId: r.id,
|
|
1664
|
+
presetLabel: r.label,
|
|
1665
|
+
comp: m(r)
|
|
1666
|
+
})]
|
|
1667
|
+
})
|
|
1668
|
+
});
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
var Pt = (e) => {
|
|
1672
|
+
let { v: t, id: n, savedAt: r, updatedAt: i, shipped: a, name: o, thumb: s, ...c } = e;
|
|
1673
|
+
return c;
|
|
1674
|
+
};
|
|
1675
|
+
function Q(e, t) {
|
|
1676
|
+
return b().filter((t) => t.mode === e).map((n, r) => {
|
|
1677
|
+
let i = e === "morph" ? [
|
|
1678
|
+
{
|
|
1679
|
+
label: "Steps",
|
|
1680
|
+
value: n.morph?.steps?.length ?? 0
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
label: "From",
|
|
1684
|
+
value: n.name.split(" → ")[0]
|
|
1685
|
+
},
|
|
1686
|
+
{
|
|
1687
|
+
label: "To",
|
|
1688
|
+
value: n.name.split(" → ")[1] ?? ""
|
|
1689
|
+
}
|
|
1690
|
+
] : [
|
|
1691
|
+
{
|
|
1692
|
+
label: "Kind",
|
|
1693
|
+
value: n.group
|
|
1694
|
+
},
|
|
1695
|
+
{
|
|
1696
|
+
label: "Layers",
|
|
1697
|
+
value: n.layers.length
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
label: "Aspect",
|
|
1701
|
+
value: n.aspect
|
|
1702
|
+
}
|
|
1703
|
+
];
|
|
1704
|
+
return Mt(e, r + t, {
|
|
1705
|
+
id: n.id,
|
|
1706
|
+
slug: n.id.replace(`ship:${e}:`, ""),
|
|
1707
|
+
name: n.name,
|
|
1708
|
+
group: n.group,
|
|
1709
|
+
sub: n.sub ?? null,
|
|
1710
|
+
details: i,
|
|
1711
|
+
...n.morph ? { steps: n.name.split(" → ") } : {},
|
|
1712
|
+
open: () => At({ open: n.id }, jt[e]),
|
|
1713
|
+
spec: () => Pt(n)
|
|
1714
|
+
});
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
var Ft = null, It = () => Ft ??= {
|
|
1718
|
+
labs: Nt("labs", 0),
|
|
1719
|
+
randomiser: Nt("randomiser", 7),
|
|
1720
|
+
editor: Q("editor", 11),
|
|
1721
|
+
morph: Q("morph", 3)
|
|
1722
|
+
}, Lt = () => {
|
|
1723
|
+
try {
|
|
1724
|
+
return JSON.parse(S() || "{}");
|
|
1725
|
+
} catch {
|
|
1726
|
+
return {};
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
function Rt(e) {
|
|
1730
|
+
let { removed: t = [], names: n = {} } = Lt(), r = new Set(t);
|
|
1731
|
+
return It()[e].filter((e) => !r.has(e.id)).map((e) => n[e.id] ? {
|
|
1732
|
+
...e,
|
|
1733
|
+
name: n[e.id]
|
|
1734
|
+
} : e);
|
|
1735
|
+
}
|
|
1736
|
+
//#endregion
|
|
1737
|
+
//#region src/editor/kolbox/library/LibraryFile.jsx
|
|
1738
|
+
var zt = ({ title: e, children: t }) => /* @__PURE__ */ B("section", {
|
|
1739
|
+
className: "flex flex-col gap-2",
|
|
1740
|
+
children: [/* @__PURE__ */ z("h2", {
|
|
1741
|
+
className: "text-section text-text",
|
|
1742
|
+
children: e
|
|
1743
|
+
}), t]
|
|
1744
|
+
});
|
|
1745
|
+
function Bt({ file: e, slug: t, onBack: n, onOpen: r, onDuplicate: i }) {
|
|
1746
|
+
let a = (e, t) => /* @__PURE__ */ B(R, { children: [
|
|
1747
|
+
/* @__PURE__ */ z(O, {
|
|
1748
|
+
variant: "kolbox",
|
|
1749
|
+
tone: "ghost",
|
|
1750
|
+
iconLeft: "chevron-left",
|
|
1751
|
+
onClick: n,
|
|
1752
|
+
className: "-ml-3 self-start",
|
|
1753
|
+
children: "Back"
|
|
1754
|
+
}),
|
|
1755
|
+
/* @__PURE__ */ z("h1", {
|
|
1756
|
+
className: "mt-2 text-[22px]/[28px] font-normal text-text",
|
|
1757
|
+
children: e
|
|
1758
|
+
}),
|
|
1759
|
+
/* @__PURE__ */ z("p", {
|
|
1760
|
+
className: "mt-1 text-value text-muted",
|
|
1761
|
+
children: t
|
|
1762
|
+
})
|
|
1763
|
+
] });
|
|
1764
|
+
if (!e) return /* @__PURE__ */ z("div", {
|
|
1765
|
+
className: "flex min-h-0 flex-1 flex-col overflow-y-auto px-8 pt-3 pb-8",
|
|
1766
|
+
"data-library-file": !0,
|
|
1767
|
+
children: a("File not found", t)
|
|
1768
|
+
});
|
|
1769
|
+
let o = X[e.chrome].label;
|
|
1770
|
+
return /* @__PURE__ */ B("div", {
|
|
1771
|
+
className: "flex min-h-0 flex-1 flex-col overflow-y-auto px-8 pt-3 pb-8",
|
|
1772
|
+
"data-library-file": e.id,
|
|
1773
|
+
children: [
|
|
1774
|
+
a(e.name, `${o}${e.group ? ` — ${e.group}` : ""}${e.sub ? ` › ${e.sub}` : ""}`),
|
|
1775
|
+
/* @__PURE__ */ z("div", { className: "mt-6 h-px shrink-0 bg-border" }),
|
|
1776
|
+
/* @__PURE__ */ B("div", {
|
|
1777
|
+
className: "mt-6 grid min-h-0 flex-1 grid-cols-2 gap-12",
|
|
1778
|
+
children: [/* @__PURE__ */ B("div", {
|
|
1779
|
+
className: "flex flex-col gap-6",
|
|
1780
|
+
children: [
|
|
1781
|
+
/* @__PURE__ */ z(zt, {
|
|
1782
|
+
title: "Description",
|
|
1783
|
+
children: /* @__PURE__ */ z("p", {
|
|
1784
|
+
className: "text-help text-muted",
|
|
1785
|
+
children: `A shipped ${o} file. Open loads it in its chrome; Duplicate makes it yours.`
|
|
1786
|
+
})
|
|
1787
|
+
}),
|
|
1788
|
+
/* @__PURE__ */ z(zt, {
|
|
1789
|
+
title: "Specifications",
|
|
1790
|
+
children: e.details.map((e) => /* @__PURE__ */ z("p", {
|
|
1791
|
+
className: "font-mono text-value text-muted",
|
|
1792
|
+
children: `${e.label}: ${e.value}`
|
|
1793
|
+
}, e.label))
|
|
1794
|
+
}),
|
|
1795
|
+
e.steps && /* @__PURE__ */ z(zt, {
|
|
1796
|
+
title: "Steps",
|
|
1797
|
+
children: e.steps.map((e, t) => /* @__PURE__ */ B("p", {
|
|
1798
|
+
className: "flex gap-3 font-mono text-value text-muted",
|
|
1799
|
+
children: [/* @__PURE__ */ z("span", { children: t + 1 }), e]
|
|
1800
|
+
}, t))
|
|
1801
|
+
}),
|
|
1802
|
+
e.tags.length > 0 && /* @__PURE__ */ z(zt, {
|
|
1803
|
+
title: "Tags",
|
|
1804
|
+
children: /* @__PURE__ */ z("p", {
|
|
1805
|
+
className: "font-mono text-value text-muted",
|
|
1806
|
+
children: e.tags.join(", ")
|
|
1807
|
+
})
|
|
1808
|
+
}),
|
|
1809
|
+
/* @__PURE__ */ B("div", {
|
|
1810
|
+
className: "mt-auto flex flex-col gap-4 pt-6",
|
|
1811
|
+
children: [/* @__PURE__ */ z("div", { className: "h-px bg-border" }), /* @__PURE__ */ B("div", {
|
|
1812
|
+
className: "flex gap-2",
|
|
1813
|
+
children: [/* @__PURE__ */ z(O, {
|
|
1814
|
+
variant: "kolbox",
|
|
1815
|
+
tone: "primary",
|
|
1816
|
+
onClick: r,
|
|
1817
|
+
children: "Open"
|
|
1818
|
+
}), /* @__PURE__ */ z(O, {
|
|
1819
|
+
variant: "kolbox",
|
|
1820
|
+
onClick: i,
|
|
1821
|
+
children: "Duplicate"
|
|
1822
|
+
})]
|
|
1823
|
+
})]
|
|
1824
|
+
})
|
|
1825
|
+
]
|
|
1826
|
+
}), /* @__PURE__ */ z("div", {
|
|
1827
|
+
className: "flex items-start",
|
|
1828
|
+
children: /* @__PURE__ */ z("div", {
|
|
1829
|
+
className: "w-full rounded-well bg-canvas p-6",
|
|
1830
|
+
"data-library-preview": !0,
|
|
1831
|
+
children: e.cover && /* @__PURE__ */ z("img", {
|
|
1832
|
+
src: e.cover,
|
|
1833
|
+
alt: e.name,
|
|
1834
|
+
className: "aspect-square w-full object-contain"
|
|
1835
|
+
})
|
|
1836
|
+
})
|
|
1837
|
+
})]
|
|
1838
|
+
})
|
|
1839
|
+
]
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
//#endregion
|
|
1843
|
+
//#region src/editor/kolbox/pages/Library.jsx
|
|
1844
|
+
var $ = {
|
|
1845
|
+
tab: "labs",
|
|
1846
|
+
groups: [],
|
|
1847
|
+
query: "",
|
|
1848
|
+
filters: !1,
|
|
1849
|
+
view: "grid",
|
|
1850
|
+
scroll: 0,
|
|
1851
|
+
fromList: !1
|
|
1852
|
+
}, Vt = /* @__PURE__ */ new Map(), Ht = (e) => e?.closest?.("input, textarea, [contenteditable]"), Ut = {
|
|
1853
|
+
value: "media",
|
|
1854
|
+
label: "MEDIA"
|
|
1855
|
+
};
|
|
1856
|
+
function Wt({ view: e }) {
|
|
1857
|
+
let t = v(), n = t.buckets?.() ?? [], [r, i] = L(n[0]?.id), [a, o] = L([]);
|
|
1858
|
+
F(() => {
|
|
1859
|
+
let e = !0;
|
|
1860
|
+
return Promise.resolve(t.listMedia("", { bucket: r })).then((t) => e && o((t ?? []).filter((e) => !e.key.endsWith("/")))), () => {
|
|
1861
|
+
e = !1;
|
|
1862
|
+
};
|
|
1863
|
+
}, [t, r]);
|
|
1864
|
+
let s = a.map((e) => ({
|
|
1865
|
+
id: e.key,
|
|
1866
|
+
name: e.key.split("/").pop(),
|
|
1867
|
+
icon: (e.contentType ?? "").startsWith("video") ? "video" : "image",
|
|
1868
|
+
thumb: (e.contentType ?? "").startsWith("image") ? t.mediaUrl(e.key, r) : void 0,
|
|
1869
|
+
modified: Date.parse(e.lastModified ?? "") || void 0,
|
|
1870
|
+
created: Date.parse(e.lastModified ?? "") || void 0,
|
|
1871
|
+
size: Fe(e.size ?? 0)
|
|
1872
|
+
}));
|
|
1873
|
+
return /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ B("div", {
|
|
1874
|
+
className: "flex h-12 shrink-0 items-center gap-2 px-8 max-md:px-4",
|
|
1875
|
+
"data-library-media": !0,
|
|
1876
|
+
children: [
|
|
1877
|
+
/* @__PURE__ */ z(Ee, {
|
|
1878
|
+
variant: "kolbox",
|
|
1879
|
+
ariaLabel: "Bucket",
|
|
1880
|
+
value: r,
|
|
1881
|
+
options: n.map((e) => ({
|
|
1882
|
+
value: e.id,
|
|
1883
|
+
label: e.label ?? e.id
|
|
1884
|
+
})),
|
|
1885
|
+
onChange: i,
|
|
1886
|
+
className: "w-44"
|
|
1887
|
+
}),
|
|
1888
|
+
t.sample && /* @__PURE__ */ z("span", {
|
|
1889
|
+
className: "truncate text-help text-muted",
|
|
1890
|
+
"data-media-sample": !0,
|
|
1891
|
+
children: "Sample library: the app hosting the editor has connected no media."
|
|
1892
|
+
}),
|
|
1893
|
+
/* @__PURE__ */ B("span", {
|
|
1894
|
+
className: "ml-auto font-mono text-meta text-muted",
|
|
1895
|
+
"data-file-count": !0,
|
|
1896
|
+
children: [s.length, " files"]
|
|
1897
|
+
})
|
|
1898
|
+
]
|
|
1899
|
+
}), /* @__PURE__ */ z("div", {
|
|
1900
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
1901
|
+
children: e === "grid" ? /* @__PURE__ */ z(Be, {
|
|
1902
|
+
variant: "kolbox",
|
|
1903
|
+
children: s.map((e) => /* @__PURE__ */ z(Te, {
|
|
1904
|
+
variant: "kolbox",
|
|
1905
|
+
file: e
|
|
1906
|
+
}, e.id))
|
|
1907
|
+
}) : /* @__PURE__ */ z(Ae, {
|
|
1908
|
+
variant: "kolbox",
|
|
1909
|
+
rows: s,
|
|
1910
|
+
sort: "modified"
|
|
1911
|
+
})
|
|
1912
|
+
})] });
|
|
1913
|
+
}
|
|
1914
|
+
function Gt() {
|
|
1915
|
+
let { addItem: e } = d(), [, t] = ze((e) => e + 1, 0);
|
|
1916
|
+
F(() => g(t), []);
|
|
1917
|
+
let [, , n, r] = window.location.hash.replace(/^#/, "").split("/"), i = X[n] || n === Ut.value ? n : $.tab;
|
|
1918
|
+
$.tab = i;
|
|
1919
|
+
let a = r == null ? null : decodeURIComponent(r), [o, s] = L(() => ({
|
|
1920
|
+
groups: $.groups,
|
|
1921
|
+
query: $.query,
|
|
1922
|
+
filters: $.filters,
|
|
1923
|
+
view: $.view,
|
|
1924
|
+
searching: !!$.query
|
|
1925
|
+
})), c = (e) => s((t) => ({
|
|
1926
|
+
...t,
|
|
1927
|
+
...e
|
|
1928
|
+
}));
|
|
1929
|
+
F(() => {
|
|
1930
|
+
Object.assign($, {
|
|
1931
|
+
groups: o.groups,
|
|
1932
|
+
query: o.query,
|
|
1933
|
+
filters: o.filters,
|
|
1934
|
+
view: o.view
|
|
1935
|
+
});
|
|
1936
|
+
}, [o]);
|
|
1937
|
+
let [l, u] = L(null), [f, p] = L(null), m = I(null);
|
|
1938
|
+
F(() => {
|
|
1939
|
+
let e = (e) => {
|
|
1940
|
+
!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== "k" || Ht(e.target) || (e.preventDefault(), window.dispatchEvent(new CustomEvent("kolbox:search")));
|
|
1941
|
+
};
|
|
1942
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
1943
|
+
}, []);
|
|
1944
|
+
let h = (e) => {
|
|
1945
|
+
$.tab = e, c({
|
|
1946
|
+
groups: [],
|
|
1947
|
+
query: "",
|
|
1948
|
+
searching: !1
|
|
1949
|
+
}), $.scroll = 0, u(null), window.history.replaceState(window.history.state, "", `#/library/${e}`), t();
|
|
1950
|
+
}, _ = (i === Ut.value ? [] : Rt(i)).map((e) => {
|
|
1951
|
+
let t = Vt.get(e.id) ?? {};
|
|
1952
|
+
return {
|
|
1953
|
+
...e,
|
|
1954
|
+
...t,
|
|
1955
|
+
thumb: t.cover ?? e.cover,
|
|
1956
|
+
modified: e.date,
|
|
1957
|
+
created: e.date,
|
|
1958
|
+
size: Fe(e.bytes),
|
|
1959
|
+
mark: {
|
|
1960
|
+
icon: X[e.chrome].icon,
|
|
1961
|
+
label: X[e.chrome].label
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
}), v = [...new Set(_.map((e) => e.group).filter(Boolean))], y = o.query.trim().toLowerCase(), b = _.filter((e) => (!o.groups.length || o.groups.includes(e.group)) && (!y || [
|
|
1965
|
+
e.name,
|
|
1966
|
+
e.group,
|
|
1967
|
+
e.sub
|
|
1968
|
+
].some((e) => e?.toLowerCase().includes(y))));
|
|
1969
|
+
Le(() => {
|
|
1970
|
+
if (a != null) return;
|
|
1971
|
+
let e = m.current?.querySelector("[data-file-grid], [data-file-list]");
|
|
1972
|
+
e && (e.scrollTop = $.scroll);
|
|
1973
|
+
}, [a, o.view]);
|
|
1974
|
+
let x = (e) => {
|
|
1975
|
+
$.fromList = !0, window.location.hash = `#/library/${e.chrome}/${encodeURIComponent(e.slug)}`;
|
|
1976
|
+
}, S = () => {
|
|
1977
|
+
$.fromList ? ($.fromList = !1, window.history.back()) : window.location.hash = `#/library/${i}`;
|
|
1978
|
+
}, te = (e, n) => {
|
|
1979
|
+
Vt.set(e, {
|
|
1980
|
+
...Vt.get(e),
|
|
1981
|
+
...n
|
|
1982
|
+
}), t();
|
|
1983
|
+
}, w = {
|
|
1984
|
+
rename: (e, t) => C(e.id, t),
|
|
1985
|
+
duplicate: (t) => e("preset", {
|
|
1986
|
+
...t.spec(),
|
|
1987
|
+
name: `${t.name} copy`,
|
|
1988
|
+
thumb: t.thumb
|
|
1989
|
+
}),
|
|
1990
|
+
remove: async (e) => {
|
|
1991
|
+
let t = await ve({
|
|
1992
|
+
title: `Delete “${e.name || "Untitled"}”?`,
|
|
1993
|
+
action: "Delete"
|
|
1994
|
+
});
|
|
1995
|
+
return t && ee(e.id), t;
|
|
1996
|
+
},
|
|
1997
|
+
download: (e) => Pe(new Blob([JSON.stringify({
|
|
1998
|
+
name: e.name,
|
|
1999
|
+
...e.spec()
|
|
2000
|
+
}, null, 2)], { type: "application/json" }), `${e.name}.json`),
|
|
2001
|
+
cover: async (e) => {
|
|
2002
|
+
let t = await Ie();
|
|
2003
|
+
t && te(e.id, { cover: t });
|
|
2004
|
+
}
|
|
2005
|
+
}, ne = async (e) => {
|
|
2006
|
+
let t = await fe({
|
|
2007
|
+
title: "Rename:",
|
|
2008
|
+
value: e.name
|
|
2009
|
+
});
|
|
2010
|
+
t != null && t.trim() && t.trim() !== e.name && w.rename(e, t.trim());
|
|
2011
|
+
}, re = (e, t) => ({
|
|
2012
|
+
getBoundingClientRect: () => new DOMRect(e, t, 0, 0),
|
|
2013
|
+
contains: () => !1
|
|
2014
|
+
}), ae = (e, t) => p({
|
|
2015
|
+
file: e,
|
|
2016
|
+
anchor: re(t.clientX, t.clientY)
|
|
2017
|
+
}), T = _.find((e) => e.id === l), oe = (e) => [
|
|
2018
|
+
{
|
|
2019
|
+
label: "Date",
|
|
2020
|
+
value: new Date(e.date).toISOString().slice(0, 10)
|
|
2021
|
+
},
|
|
2022
|
+
{
|
|
2023
|
+
label: "Size",
|
|
2024
|
+
value: e.size
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
label: "Chrome",
|
|
2028
|
+
value: e.mark.label
|
|
2029
|
+
},
|
|
2030
|
+
...e.details
|
|
2031
|
+
], se = a == null ? null : _.find((e) => e.slug === a), E = (e) => c({ groups: o.groups.includes(e) ? o.groups.filter((t) => t !== e) : [...o.groups, e] });
|
|
2032
|
+
return /* @__PURE__ */ B(Ve, {
|
|
2033
|
+
variant: "kolbox",
|
|
2034
|
+
children: [
|
|
2035
|
+
/* @__PURE__ */ z($e, { crumbs: ["Library", ...a == null ? [] : [se?.name ?? "File not found"]] }),
|
|
2036
|
+
a == null ? /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z(ke, {
|
|
2037
|
+
variant: "kolbox",
|
|
2038
|
+
headline: "Library",
|
|
2039
|
+
menu: /* @__PURE__ */ z("span", {
|
|
2040
|
+
className: "ml-3 truncate text-value text-muted max-md:ml-0 max-md:basis-full max-md:whitespace-normal",
|
|
2041
|
+
children: "Everything the app ships with, by chrome."
|
|
2042
|
+
}),
|
|
2043
|
+
actions: /* @__PURE__ */ z(je, {
|
|
2044
|
+
variant: "kolbox",
|
|
2045
|
+
tabs: [Ut, ...Et],
|
|
2046
|
+
value: i,
|
|
2047
|
+
onChange: h,
|
|
2048
|
+
className: "w-136 max-md:w-full"
|
|
2049
|
+
})
|
|
2050
|
+
}), i === Ut.value ? /* @__PURE__ */ z(Wt, { view: o.view }) : /* @__PURE__ */ B(R, { children: [
|
|
2051
|
+
/* @__PURE__ */ B("div", {
|
|
2052
|
+
className: "flex h-12 shrink-0 items-center gap-2 px-8 max-md:px-4",
|
|
2053
|
+
"data-library-filters": !0,
|
|
2054
|
+
children: [
|
|
2055
|
+
/* @__PURE__ */ z("span", {
|
|
2056
|
+
className: "text-label text-text",
|
|
2057
|
+
children: `All ${X[i].label}`
|
|
2058
|
+
}),
|
|
2059
|
+
/* @__PURE__ */ z("span", {
|
|
2060
|
+
"aria-hidden": !0,
|
|
2061
|
+
className: "mx-2 h-4 w-px bg-border"
|
|
2062
|
+
}),
|
|
2063
|
+
/* @__PURE__ */ z(O, {
|
|
2064
|
+
variant: "kolbox",
|
|
2065
|
+
iconOnly: "filter",
|
|
2066
|
+
"aria-label": "Toggle filters",
|
|
2067
|
+
pressed: o.filters,
|
|
2068
|
+
onClick: () => c({ filters: !o.filters })
|
|
2069
|
+
}),
|
|
2070
|
+
o.searching || o.query ? /* @__PURE__ */ z(k, {
|
|
2071
|
+
variant: "kolbox",
|
|
2072
|
+
size: "md",
|
|
2073
|
+
iconLeft: "search",
|
|
2074
|
+
"aria-label": "Search",
|
|
2075
|
+
autoFocus: !o.query,
|
|
2076
|
+
value: o.query,
|
|
2077
|
+
onChange: (e) => c({ query: e.target.value }),
|
|
2078
|
+
onBlur: () => !o.query && c({ searching: !1 }),
|
|
2079
|
+
onKeyDown: (e) => e.key === "Escape" && c({
|
|
2080
|
+
query: "",
|
|
2081
|
+
searching: !1
|
|
2082
|
+
}),
|
|
2083
|
+
className: "w-56 max-md:w-auto max-md:min-w-0 max-md:flex-1"
|
|
2084
|
+
}) : /* @__PURE__ */ z(O, {
|
|
2085
|
+
variant: "kolbox",
|
|
2086
|
+
iconOnly: "search",
|
|
2087
|
+
"aria-label": "Search",
|
|
2088
|
+
onClick: () => c({ searching: !0 })
|
|
2089
|
+
}),
|
|
2090
|
+
/* @__PURE__ */ z("span", {
|
|
2091
|
+
className: "ml-auto font-mono text-meta text-muted",
|
|
2092
|
+
"data-file-count": !0,
|
|
2093
|
+
children: o.filters && `${b.length} of ${_.length}`
|
|
2094
|
+
}),
|
|
2095
|
+
/* @__PURE__ */ z(we, {
|
|
2096
|
+
layout: "joined",
|
|
2097
|
+
variant: "kolbox",
|
|
2098
|
+
tone: "sunken",
|
|
2099
|
+
options: [{
|
|
2100
|
+
icon: "grid",
|
|
2101
|
+
ariaLabel: "Grid view",
|
|
2102
|
+
pressed: o.view === "grid",
|
|
2103
|
+
onPress: () => {
|
|
2104
|
+
$.scroll = 0, c({ view: "grid" });
|
|
2105
|
+
}
|
|
2106
|
+
}, {
|
|
2107
|
+
icon: "list-bullet",
|
|
2108
|
+
ariaLabel: "List view",
|
|
2109
|
+
pressed: o.view === "list",
|
|
2110
|
+
onPress: () => {
|
|
2111
|
+
$.scroll = 0, c({ view: "list" });
|
|
2112
|
+
}
|
|
2113
|
+
}]
|
|
2114
|
+
})
|
|
2115
|
+
]
|
|
2116
|
+
}),
|
|
2117
|
+
o.filters && /* @__PURE__ */ B("div", {
|
|
2118
|
+
className: "flex shrink-0 items-start gap-3 px-8 pb-3 max-md:px-4",
|
|
2119
|
+
"data-library-groups": !0,
|
|
2120
|
+
children: [/* @__PURE__ */ z("span", {
|
|
2121
|
+
className: "flex h-control shrink-0 items-center text-help text-muted",
|
|
2122
|
+
children: "Group"
|
|
2123
|
+
}), /* @__PURE__ */ z("div", {
|
|
2124
|
+
className: "flex flex-wrap gap-1",
|
|
2125
|
+
children: v.map((e) => {
|
|
2126
|
+
let t = o.groups.includes(e);
|
|
2127
|
+
return /* @__PURE__ */ z(O, {
|
|
2128
|
+
variant: "kolbox",
|
|
2129
|
+
pressed: t,
|
|
2130
|
+
"aria-pressed": t,
|
|
2131
|
+
onClick: () => E(e),
|
|
2132
|
+
children: e
|
|
2133
|
+
}, e);
|
|
2134
|
+
})
|
|
2135
|
+
})]
|
|
2136
|
+
}),
|
|
2137
|
+
/* @__PURE__ */ z("div", {
|
|
2138
|
+
ref: m,
|
|
2139
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
2140
|
+
onScrollCapture: (e) => {
|
|
2141
|
+
e.target.matches?.("[data-file-grid], [data-file-list]") && ($.scroll = e.target.scrollTop);
|
|
2142
|
+
},
|
|
2143
|
+
children: o.view === "grid" ? /* @__PURE__ */ z(Be, {
|
|
2144
|
+
variant: "kolbox",
|
|
2145
|
+
children: b.map((e) => /* @__PURE__ */ z(Te, {
|
|
2146
|
+
variant: "kolbox",
|
|
2147
|
+
file: e,
|
|
2148
|
+
onOpen: x,
|
|
2149
|
+
onDownload: w.download,
|
|
2150
|
+
onSettings: (e) => u(e.id),
|
|
2151
|
+
onRemove: w.remove,
|
|
2152
|
+
onMenu: ae
|
|
2153
|
+
}, e.id))
|
|
2154
|
+
}) : /* @__PURE__ */ z(Ae, {
|
|
2155
|
+
variant: "kolbox",
|
|
2156
|
+
rows: b,
|
|
2157
|
+
sort: "modified",
|
|
2158
|
+
onOpen: x,
|
|
2159
|
+
onSettings: (e) => u(e.id),
|
|
2160
|
+
onRemove: w.remove,
|
|
2161
|
+
onMenu: ae
|
|
2162
|
+
})
|
|
2163
|
+
})
|
|
2164
|
+
] })] }) : /* @__PURE__ */ z(Bt, {
|
|
2165
|
+
file: se,
|
|
2166
|
+
slug: a,
|
|
2167
|
+
onBack: S,
|
|
2168
|
+
onOpen: () => se.open(),
|
|
2169
|
+
onDuplicate: () => w.duplicate(se)
|
|
2170
|
+
}),
|
|
2171
|
+
T && a == null && /* @__PURE__ */ z(et, {
|
|
2172
|
+
file: {
|
|
2173
|
+
...T,
|
|
2174
|
+
details: oe(T)
|
|
2175
|
+
},
|
|
2176
|
+
onClose: () => u(null),
|
|
2177
|
+
onRename: (e) => w.rename(T, e),
|
|
2178
|
+
onTags: (e) => te(T.id, { tags: e }),
|
|
2179
|
+
onNote: (e) => te(T.id, { note: e }),
|
|
2180
|
+
onCover: () => w.cover(T),
|
|
2181
|
+
onDownload: () => w.download(T),
|
|
2182
|
+
onDuplicate: () => w.duplicate(T),
|
|
2183
|
+
onRemove: () => w.remove(T)
|
|
2184
|
+
}, T.id),
|
|
2185
|
+
/* @__PURE__ */ z(j, {
|
|
2186
|
+
variant: "kolbox",
|
|
2187
|
+
"aria-label": "File",
|
|
2188
|
+
anchor: f?.anchor,
|
|
2189
|
+
open: !!f,
|
|
2190
|
+
onClose: () => p(null),
|
|
2191
|
+
onSelect: (e) => e.run?.(),
|
|
2192
|
+
groups: f ? [[
|
|
2193
|
+
{
|
|
2194
|
+
label: "Rename",
|
|
2195
|
+
icon: "edit",
|
|
2196
|
+
run: () => ne(f.file)
|
|
2197
|
+
},
|
|
2198
|
+
{
|
|
2199
|
+
label: "Duplicate",
|
|
2200
|
+
icon: "copy",
|
|
2201
|
+
run: () => w.duplicate(f.file)
|
|
2202
|
+
},
|
|
2203
|
+
{
|
|
2204
|
+
label: "Delete",
|
|
2205
|
+
icon: "trash",
|
|
2206
|
+
run: () => w.remove(f.file)
|
|
2207
|
+
}
|
|
2208
|
+
]] : []
|
|
2209
|
+
}),
|
|
2210
|
+
/* @__PURE__ */ z(ie, { mode: "library" })
|
|
2211
|
+
]
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
function Kt() {
|
|
2215
|
+
return /* @__PURE__ */ z(f, { children: /* @__PURE__ */ z(Gt, {}) });
|
|
2216
|
+
}
|
|
2217
|
+
//#endregion
|
|
2218
|
+
export { xt as Home, Kt as Library };
|