@harryy/react-file-browser 0.0.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/LICENSE +21 -0
- package/README.md +247 -0
- package/dist/adapters/cloud-adapter-base.d.ts +27 -0
- package/dist/adapters/cloud-adapter-base.d.ts.map +1 -0
- package/dist/adapters/in-memory/in-memory-file-browser-adapter.d.ts +53 -0
- package/dist/adapters/in-memory/in-memory-file-browser-adapter.d.ts.map +1 -0
- package/dist/adapters/in-memory/index.d.ts +2 -0
- package/dist/adapters/in-memory/index.d.ts.map +1 -0
- package/dist/adapters/in-memory/index.js +270 -0
- package/dist/adapters/in-memory/index.js.map +1 -0
- package/dist/adapters/r2/index.d.ts +7 -0
- package/dist/adapters/r2/index.d.ts.map +1 -0
- package/dist/adapters/r2/index.js +11 -0
- package/dist/adapters/r2/index.js.map +1 -0
- package/dist/adapters/s3/index.d.ts +7 -0
- package/dist/adapters/s3/index.d.ts.map +1 -0
- package/dist/adapters/s3/index.js +11 -0
- package/dist/adapters/s3/index.js.map +1 -0
- package/dist/adapters/s3-compatible-adapter.d.ts +50 -0
- package/dist/adapters/s3-compatible-adapter.d.ts.map +1 -0
- package/dist/adapters/supabase/index.d.ts +7 -0
- package/dist/adapters/supabase/index.d.ts.map +1 -0
- package/dist/adapters/supabase/index.js +216 -0
- package/dist/adapters/supabase/index.js.map +1 -0
- package/dist/adapters/supabase/supabase-file-browser-adapter.d.ts +88 -0
- package/dist/adapters/supabase/supabase-file-browser-adapter.d.ts.map +1 -0
- package/dist/chunks/browser-4lIkMGbo.js +436 -0
- package/dist/chunks/browser-4lIkMGbo.js.map +1 -0
- package/dist/chunks/cloud-adapter-base-CBUoZYLS.js +39 -0
- package/dist/chunks/cloud-adapter-base-CBUoZYLS.js.map +1 -0
- package/dist/chunks/path-CPm7s9NF.js +52 -0
- package/dist/chunks/path-CPm7s9NF.js.map +1 -0
- package/dist/chunks/s3-compatible-adapter-D9agsn9e.js +317 -0
- package/dist/chunks/s3-compatible-adapter-D9agsn9e.js.map +1 -0
- package/dist/components/file-browser.d.ts +28 -0
- package/dist/components/file-browser.d.ts.map +1 -0
- package/dist/core/path.d.ts +9 -0
- package/dist/core/path.d.ts.map +1 -0
- package/dist/core/types.d.ts +84 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/upload-drop.d.ts +7 -0
- package/dist/core/upload-drop.d.ts.map +1 -0
- package/dist/core/use-file-browser.d.ts +78 -0
- package/dist/core/use-file-browser.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3212 -0
- package/dist/index.js.map +1 -0
- package/dist/theme/index.d.ts +25 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +28 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/transfers/file-browser-provider.d.ts +13 -0
- package/dist/transfers/file-browser-provider.d.ts.map +1 -0
- package/dist/transfers/transfer-manager.d.ts +118 -0
- package/dist/transfers/transfer-manager.d.ts.map +1 -0
- package/package.json +137 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3212 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c } from "./chunks/path-CPm7s9NF.js";
|
|
2
|
+
import { FILE_BROWSER_THEME_CONTRACT as l, getFileBrowserDensityAttributes as u } from "./theme/index.js";
|
|
3
|
+
import { t as d } from "./chunks/browser-4lIkMGbo.js";
|
|
4
|
+
import { createContext as f, createElement as p, forwardRef as m, useCallback as h, useContext as g, useEffect as _, useMemo as v, useRef as y, useState as b, useSyncExternalStore as x } from "react";
|
|
5
|
+
import S from "react-selecto";
|
|
6
|
+
import { createPortal as C } from "react-dom";
|
|
7
|
+
import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
|
|
8
|
+
//#region src/core/use-file-browser.ts
|
|
9
|
+
function D({ adapter: n, initialPath: i = "/" }) {
|
|
10
|
+
let [o, s] = b(() => a(i)), [c, l] = b("loading"), [u, d] = b([]), [f, p] = b(), [m, g] = b(null), [x, S] = b(() => /* @__PURE__ */ new Set()), [C, w] = b(null), [T, E] = b(null), [D, j] = b(null), [M, ne] = b("grid"), [N, re] = b(""), [P, ie] = b("all"), [F, ae] = b("name"), [I, oe] = b("asc"), se = y(0), ce = y(o), L = v(() => ({
|
|
11
|
+
createFolder: typeof n.createFolder == "function",
|
|
12
|
+
rename: typeof n.rename == "function",
|
|
13
|
+
move: typeof n.move == "function",
|
|
14
|
+
copy: typeof n.copy == "function",
|
|
15
|
+
stat: typeof n.stat == "function",
|
|
16
|
+
exists: typeof n.exists == "function",
|
|
17
|
+
multipart: typeof n.createMultipartUpload == "function" && typeof n.uploadPart == "function" && typeof n.completeMultipartUpload == "function",
|
|
18
|
+
bulkDownload: typeof n.bulkDownloadUrl == "function"
|
|
19
|
+
}), [n]), R = v(() => te(Array.from(x)), [x]), le = v(() => u.filter((e) => x.has(e.path)), [u, x]), z = v(() => {
|
|
20
|
+
let e = N.trim().toLowerCase();
|
|
21
|
+
return [...u].filter((t) => e ? t.name.toLowerCase().includes(e) : !0).filter((e) => P === "all" ? !0 : e.kind === (P === "files" ? "file" : "folder")).sort((e, t) => ee(e, t, F, I));
|
|
22
|
+
}, [
|
|
23
|
+
P,
|
|
24
|
+
u,
|
|
25
|
+
N,
|
|
26
|
+
F,
|
|
27
|
+
I
|
|
28
|
+
]), ue = h(async (e, t) => {
|
|
29
|
+
let r = a(e), i = ++se.current;
|
|
30
|
+
l((e) => t === "replace" || e === "idle" ? "loading" : e), g(null);
|
|
31
|
+
try {
|
|
32
|
+
let e = await n.list(r, { cursor: t === "append" ? f : void 0 });
|
|
33
|
+
if (i !== se.current) return;
|
|
34
|
+
d((n) => t === "append" ? O(n, e.items) : e.items), p(e.cursor), l("ready");
|
|
35
|
+
} catch (e) {
|
|
36
|
+
if (i !== se.current) return;
|
|
37
|
+
g(A(e)), l("error");
|
|
38
|
+
}
|
|
39
|
+
}, [n, f]), de = h(async () => {
|
|
40
|
+
await ue(o, "replace");
|
|
41
|
+
}, [o, ue]), fe = h(async (e) => {
|
|
42
|
+
let t = a(e);
|
|
43
|
+
ce.current = t, s(t), S(/* @__PURE__ */ new Set()), w(null), E(null), p(void 0), await ue(t, "replace");
|
|
44
|
+
}, [ue]), pe = h(async () => {
|
|
45
|
+
!f || c === "loading" || await ue(o, "append");
|
|
46
|
+
}, [
|
|
47
|
+
o,
|
|
48
|
+
f,
|
|
49
|
+
ue,
|
|
50
|
+
c
|
|
51
|
+
]);
|
|
52
|
+
_(() => {
|
|
53
|
+
Promise.resolve().then(() => ue(o, "replace"));
|
|
54
|
+
}, [n]);
|
|
55
|
+
let B = h((e) => {
|
|
56
|
+
let t = a(e);
|
|
57
|
+
S(/* @__PURE__ */ new Set([t])), w(t), E(t);
|
|
58
|
+
}, []), me = h((e) => {
|
|
59
|
+
let t = a(e);
|
|
60
|
+
S((e) => {
|
|
61
|
+
let n = new Set(e);
|
|
62
|
+
return n.has(t) ? n.delete(t) : n.add(t), n;
|
|
63
|
+
}), w(t);
|
|
64
|
+
}, []), he = h((e) => {
|
|
65
|
+
let t = a(e), n = T ?? C ?? t, r = z.map((e) => e.path), i = r.indexOf(n), o = r.indexOf(t);
|
|
66
|
+
if (i === -1 || o === -1) {
|
|
67
|
+
B(t);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let s = Math.min(i, o), c = Math.max(i, o);
|
|
71
|
+
S(new Set(r.slice(s, c + 1))), w(t);
|
|
72
|
+
}, [
|
|
73
|
+
z,
|
|
74
|
+
C,
|
|
75
|
+
T,
|
|
76
|
+
B
|
|
77
|
+
]), ge = h((e, t = {}) => {
|
|
78
|
+
let n = e.map(a);
|
|
79
|
+
S((e) => {
|
|
80
|
+
let r = t.additive ? new Set(e) : /* @__PURE__ */ new Set();
|
|
81
|
+
for (let e of n) r.add(e);
|
|
82
|
+
return r;
|
|
83
|
+
}), w(n.at(-1) ?? null), E(n.at(0) ?? null);
|
|
84
|
+
}, []), _e = h(() => {
|
|
85
|
+
S(new Set(u.map((e) => e.path))), w(u.at(0)?.path ?? null), E(u.at(0)?.path ?? null);
|
|
86
|
+
}, [u]), ve = h(() => {
|
|
87
|
+
S(/* @__PURE__ */ new Set()), w(null), E(null);
|
|
88
|
+
}, []), ye = h(async (e) => {
|
|
89
|
+
e.kind === "folder" ? await fe(e.path) : B(e.path);
|
|
90
|
+
}, [fe, B]), V = h(async (r) => {
|
|
91
|
+
if (!n.createFolder) throw new t("not_supported", "Folder creation is not supported by this adapter");
|
|
92
|
+
let i = e(o, r.trim()), a = {
|
|
93
|
+
path: i,
|
|
94
|
+
name: r.trim(),
|
|
95
|
+
kind: "folder",
|
|
96
|
+
modifiedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
97
|
+
};
|
|
98
|
+
d((e) => O(e, [a]));
|
|
99
|
+
try {
|
|
100
|
+
let e = await n.createFolder(i);
|
|
101
|
+
return d((t) => O(k(t, [i]), [e])), e;
|
|
102
|
+
} catch (e) {
|
|
103
|
+
throw d((e) => k(e, [i])), e;
|
|
104
|
+
}
|
|
105
|
+
}, [n, o]), be = h(async (e, r) => {
|
|
106
|
+
if (!n.rename) throw new t("not_supported", "Rename is not supported by this adapter");
|
|
107
|
+
let i = a(e), o = u;
|
|
108
|
+
d((e) => e.map((e) => e.path === i ? {
|
|
109
|
+
...e,
|
|
110
|
+
name: r.trim()
|
|
111
|
+
} : e));
|
|
112
|
+
try {
|
|
113
|
+
let e = await n.rename(i, r.trim());
|
|
114
|
+
return d((t) => t.map((t) => t.path === i ? e : t)), e;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
throw d(o), e;
|
|
117
|
+
}
|
|
118
|
+
}, [n, u]), xe = h(async (e) => {
|
|
119
|
+
let t = e.map(a), i = u, o = x;
|
|
120
|
+
d((e) => k(e, t)), S((e) => {
|
|
121
|
+
let n = new Set(e);
|
|
122
|
+
for (let e of t) n.delete(e);
|
|
123
|
+
return n;
|
|
124
|
+
});
|
|
125
|
+
try {
|
|
126
|
+
await n.delete(t);
|
|
127
|
+
} catch (e) {
|
|
128
|
+
if (e instanceof r) {
|
|
129
|
+
let t = e.succeededPaths.map(a), n = e.failures.map((e) => a(e.path));
|
|
130
|
+
throw d(k(i, t)), S(new Set(n)), w(n.at(0) ?? null), E(n.at(0) ?? null), e;
|
|
131
|
+
}
|
|
132
|
+
throw d(i), S(o), e;
|
|
133
|
+
}
|
|
134
|
+
}, [
|
|
135
|
+
n,
|
|
136
|
+
u,
|
|
137
|
+
x
|
|
138
|
+
]), H = h(async () => {
|
|
139
|
+
await xe(R);
|
|
140
|
+
}, [xe, R]), U = h(async (e, i) => {
|
|
141
|
+
if (!n.move) throw new t("not_supported", "Move is not supported by this adapter");
|
|
142
|
+
let s = e.map(a);
|
|
143
|
+
if (s.length === 0) return;
|
|
144
|
+
let c = a(i);
|
|
145
|
+
try {
|
|
146
|
+
await n.move(s, c);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
if (e instanceof r) {
|
|
149
|
+
let t = e.succeededPaths.map(a), n = e.failures.map((e) => a(e.path));
|
|
150
|
+
throw c === o ? await de() : d((e) => k(e, t)), S(new Set(n)), w(n.at(0) ?? null), E(n.at(0) ?? null), e;
|
|
151
|
+
}
|
|
152
|
+
throw e;
|
|
153
|
+
}
|
|
154
|
+
S((e) => {
|
|
155
|
+
let t = new Set(e);
|
|
156
|
+
for (let e of s) t.delete(e);
|
|
157
|
+
return t;
|
|
158
|
+
}), w(null), E(null), c === o ? await de() : d((e) => k(e, s));
|
|
159
|
+
}, [
|
|
160
|
+
n,
|
|
161
|
+
o,
|
|
162
|
+
de
|
|
163
|
+
]), Se = h(async (e) => {
|
|
164
|
+
await U(R, e), j((e) => e?.type === "cut" ? null : e);
|
|
165
|
+
}, [U, R]), Ce = h((e = R) => {
|
|
166
|
+
j({
|
|
167
|
+
type: "copy",
|
|
168
|
+
paths: e.map(a)
|
|
169
|
+
});
|
|
170
|
+
}, [R]), we = h((e = R) => {
|
|
171
|
+
j({
|
|
172
|
+
type: "cut",
|
|
173
|
+
paths: e.map(a)
|
|
174
|
+
});
|
|
175
|
+
}, [R]), Te = h(async (e) => {
|
|
176
|
+
if (!D || D.paths.length === 0) return;
|
|
177
|
+
let r = a(e);
|
|
178
|
+
if (D.type === "copy") {
|
|
179
|
+
if (!n.copy) throw new t("not_supported", "Copy is not supported by this adapter");
|
|
180
|
+
await n.copy(D.paths, r);
|
|
181
|
+
} else {
|
|
182
|
+
if (!n.move) throw new t("not_supported", "Move is not supported by this adapter");
|
|
183
|
+
await U(D.paths, r), j(null);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
r === o && await de();
|
|
187
|
+
}, [
|
|
188
|
+
n,
|
|
189
|
+
D,
|
|
190
|
+
o,
|
|
191
|
+
U,
|
|
192
|
+
de
|
|
193
|
+
]), Ee = h(async (t, r = {}) => {
|
|
194
|
+
if (r.onConflict === "skip") return [];
|
|
195
|
+
let i = Array.from(t), a = [];
|
|
196
|
+
for (let t of i) {
|
|
197
|
+
let i = e(ce.current, t.name), o = await n.upload(i, t, { onConflict: r.onConflict ?? "keep-both" });
|
|
198
|
+
a.push(o), d((e) => O(e, [o]));
|
|
199
|
+
}
|
|
200
|
+
return a;
|
|
201
|
+
}, [n]);
|
|
202
|
+
return {
|
|
203
|
+
adapter: n,
|
|
204
|
+
capabilities: L,
|
|
205
|
+
currentPath: o,
|
|
206
|
+
status: c,
|
|
207
|
+
items: u,
|
|
208
|
+
error: m,
|
|
209
|
+
hasMore: !!f,
|
|
210
|
+
selectedPaths: R,
|
|
211
|
+
selectedItems: le,
|
|
212
|
+
focusedPath: C,
|
|
213
|
+
clipboard: D,
|
|
214
|
+
view: M,
|
|
215
|
+
searchQuery: N,
|
|
216
|
+
filterKind: P,
|
|
217
|
+
sortBy: F,
|
|
218
|
+
sortDirection: I,
|
|
219
|
+
filteredItems: z,
|
|
220
|
+
setView: ne,
|
|
221
|
+
setSearchQuery: re,
|
|
222
|
+
setFilterKind: ie,
|
|
223
|
+
setSortBy: ae,
|
|
224
|
+
setSortDirection: oe,
|
|
225
|
+
refresh: de,
|
|
226
|
+
loadMore: pe,
|
|
227
|
+
navigate: fe,
|
|
228
|
+
open: ye,
|
|
229
|
+
selectOnly: B,
|
|
230
|
+
toggleSelection: me,
|
|
231
|
+
selectRange: he,
|
|
232
|
+
setSelection: ge,
|
|
233
|
+
selectAllLoaded: _e,
|
|
234
|
+
clearSelection: ve,
|
|
235
|
+
createFolder: V,
|
|
236
|
+
rename: be,
|
|
237
|
+
deleteSelected: H,
|
|
238
|
+
deletePaths: xe,
|
|
239
|
+
movePathsTo: U,
|
|
240
|
+
moveSelectedTo: Se,
|
|
241
|
+
copySelection: Ce,
|
|
242
|
+
cutSelection: we,
|
|
243
|
+
pasteInto: Te,
|
|
244
|
+
uploadFiles: Ee
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function O(e, t) {
|
|
248
|
+
let n = new Map(e.map((e) => [e.path, e]));
|
|
249
|
+
for (let e of t) n.set(e.path, e);
|
|
250
|
+
return Array.from(n.values()).sort((e, t) => ee(e, t, "name", "asc"));
|
|
251
|
+
}
|
|
252
|
+
function k(e, t) {
|
|
253
|
+
let n = new Set(t);
|
|
254
|
+
return e.filter((e) => !n.has(e.path));
|
|
255
|
+
}
|
|
256
|
+
function ee(e, t, n, r) {
|
|
257
|
+
let i = r === "asc" ? 1 : -1;
|
|
258
|
+
return e.kind === t.kind ? n === "size" ? ((e.size ?? 0) - (t.size ?? 0)) * i : n === "modifiedAt" ? String(e.modifiedAt ?? "").localeCompare(String(t.modifiedAt ?? "")) * i : e.name.localeCompare(t.name, void 0, {
|
|
259
|
+
numeric: !0,
|
|
260
|
+
sensitivity: "base"
|
|
261
|
+
}) * i : e.kind === "folder" ? -1 : 1;
|
|
262
|
+
}
|
|
263
|
+
function te(e) {
|
|
264
|
+
return [...e].sort((e, t) => e.localeCompare(t));
|
|
265
|
+
}
|
|
266
|
+
function A(e) {
|
|
267
|
+
return e instanceof Error ? e : Error(String(e));
|
|
268
|
+
}
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
271
|
+
var j = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), M = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ne = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), N = (e) => {
|
|
272
|
+
let t = ne(e);
|
|
273
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
274
|
+
}, re = {
|
|
275
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
276
|
+
width: 24,
|
|
277
|
+
height: 24,
|
|
278
|
+
viewBox: "0 0 24 24",
|
|
279
|
+
fill: "none",
|
|
280
|
+
stroke: "currentColor",
|
|
281
|
+
strokeWidth: 2,
|
|
282
|
+
strokeLinecap: "round",
|
|
283
|
+
strokeLinejoin: "round"
|
|
284
|
+
}, P = (e) => {
|
|
285
|
+
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
286
|
+
return !1;
|
|
287
|
+
}, ie = f({}), F = () => g(ie), ae = m(({ color: e, size: t, strokeWidth: n, absoluteStrokeWidth: r, className: i = "", children: a, iconNode: o, ...s }, c) => {
|
|
288
|
+
let { size: l = 24, strokeWidth: u = 2, absoluteStrokeWidth: d = !1, color: f = "currentColor", className: m = "" } = F() ?? {}, h = r ?? d ? Number(n ?? u) * 24 / Number(t ?? l) : n ?? u;
|
|
289
|
+
return p("svg", {
|
|
290
|
+
ref: c,
|
|
291
|
+
...re,
|
|
292
|
+
width: t ?? l ?? re.width,
|
|
293
|
+
height: t ?? l ?? re.height,
|
|
294
|
+
stroke: e ?? f,
|
|
295
|
+
strokeWidth: h,
|
|
296
|
+
className: j("lucide", m, i),
|
|
297
|
+
...!a && !P(s) && { "aria-hidden": "true" },
|
|
298
|
+
...s
|
|
299
|
+
}, [...o.map(([e, t]) => p(e, t)), ...Array.isArray(a) ? a : [a]]);
|
|
300
|
+
}), I = (e, t) => {
|
|
301
|
+
let n = m(({ className: n, ...r }, i) => p(ae, {
|
|
302
|
+
ref: i,
|
|
303
|
+
iconNode: t,
|
|
304
|
+
className: j(`lucide-${M(N(e))}`, `lucide-${e}`, n),
|
|
305
|
+
...r
|
|
306
|
+
}));
|
|
307
|
+
return n.displayName = N(e), n;
|
|
308
|
+
}, oe = I("chevron-left", [["path", {
|
|
309
|
+
d: "m15 18-6-6 6-6",
|
|
310
|
+
key: "1wnfg3"
|
|
311
|
+
}]]), se = I("chevron-right", [["path", {
|
|
312
|
+
d: "m9 18 6-6-6-6",
|
|
313
|
+
key: "mthhwq"
|
|
314
|
+
}]]), ce = I("copy", [["rect", {
|
|
315
|
+
width: "14",
|
|
316
|
+
height: "14",
|
|
317
|
+
x: "8",
|
|
318
|
+
y: "8",
|
|
319
|
+
rx: "2",
|
|
320
|
+
ry: "2",
|
|
321
|
+
key: "17jyea"
|
|
322
|
+
}], ["path", {
|
|
323
|
+
d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
|
|
324
|
+
key: "zix9uf"
|
|
325
|
+
}]]), L = I("download", [
|
|
326
|
+
["path", {
|
|
327
|
+
d: "M12 15V3",
|
|
328
|
+
key: "m9g1x1"
|
|
329
|
+
}],
|
|
330
|
+
["path", {
|
|
331
|
+
d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
|
|
332
|
+
key: "ih7n3h"
|
|
333
|
+
}],
|
|
334
|
+
["path", {
|
|
335
|
+
d: "m7 10 5 5 5-5",
|
|
336
|
+
key: "brsn70"
|
|
337
|
+
}]
|
|
338
|
+
]), R = I("file", [["path", {
|
|
339
|
+
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
340
|
+
key: "1oefj6"
|
|
341
|
+
}], ["path", {
|
|
342
|
+
d: "M14 2v5a1 1 0 0 0 1 1h5",
|
|
343
|
+
key: "wfsgrz"
|
|
344
|
+
}]]), le = I("folder-input", [
|
|
345
|
+
["path", {
|
|
346
|
+
d: "M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",
|
|
347
|
+
key: "fm4g5t"
|
|
348
|
+
}],
|
|
349
|
+
["path", {
|
|
350
|
+
d: "M2 13h10",
|
|
351
|
+
key: "pgb2dq"
|
|
352
|
+
}],
|
|
353
|
+
["path", {
|
|
354
|
+
d: "m9 16 3-3-3-3",
|
|
355
|
+
key: "6m91ic"
|
|
356
|
+
}]
|
|
357
|
+
]), z = I("folder", [["path", {
|
|
358
|
+
d: "M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",
|
|
359
|
+
key: "1kt360"
|
|
360
|
+
}]]), ue = I("grid-2x2", [
|
|
361
|
+
["path", {
|
|
362
|
+
d: "M12 3v18",
|
|
363
|
+
key: "108xh3"
|
|
364
|
+
}],
|
|
365
|
+
["path", {
|
|
366
|
+
d: "M3 12h18",
|
|
367
|
+
key: "1i2n21"
|
|
368
|
+
}],
|
|
369
|
+
["rect", {
|
|
370
|
+
x: "3",
|
|
371
|
+
y: "3",
|
|
372
|
+
width: "18",
|
|
373
|
+
height: "18",
|
|
374
|
+
rx: "2",
|
|
375
|
+
key: "h1oib"
|
|
376
|
+
}]
|
|
377
|
+
]), de = I("list", [
|
|
378
|
+
["path", {
|
|
379
|
+
d: "M3 5h.01",
|
|
380
|
+
key: "18ugdj"
|
|
381
|
+
}],
|
|
382
|
+
["path", {
|
|
383
|
+
d: "M3 12h.01",
|
|
384
|
+
key: "nlz23k"
|
|
385
|
+
}],
|
|
386
|
+
["path", {
|
|
387
|
+
d: "M3 19h.01",
|
|
388
|
+
key: "noohij"
|
|
389
|
+
}],
|
|
390
|
+
["path", {
|
|
391
|
+
d: "M8 5h13",
|
|
392
|
+
key: "1pao27"
|
|
393
|
+
}],
|
|
394
|
+
["path", {
|
|
395
|
+
d: "M8 12h13",
|
|
396
|
+
key: "1za7za"
|
|
397
|
+
}],
|
|
398
|
+
["path", {
|
|
399
|
+
d: "M8 19h13",
|
|
400
|
+
key: "m83p4d"
|
|
401
|
+
}]
|
|
402
|
+
]), fe = I("pause", [["rect", {
|
|
403
|
+
x: "14",
|
|
404
|
+
y: "3",
|
|
405
|
+
width: "5",
|
|
406
|
+
height: "18",
|
|
407
|
+
rx: "1",
|
|
408
|
+
key: "kaeet6"
|
|
409
|
+
}], ["rect", {
|
|
410
|
+
x: "5",
|
|
411
|
+
y: "3",
|
|
412
|
+
width: "5",
|
|
413
|
+
height: "18",
|
|
414
|
+
rx: "1",
|
|
415
|
+
key: "1wsw3u"
|
|
416
|
+
}]]), pe = I("pencil", [["path", {
|
|
417
|
+
d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
|
|
418
|
+
key: "1a8usu"
|
|
419
|
+
}], ["path", {
|
|
420
|
+
d: "m15 5 4 4",
|
|
421
|
+
key: "1mk7zo"
|
|
422
|
+
}]]), B = I("play", [["path", {
|
|
423
|
+
d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
|
|
424
|
+
key: "10ikf1"
|
|
425
|
+
}]]), me = I("scissors", [
|
|
426
|
+
["circle", {
|
|
427
|
+
cx: "6",
|
|
428
|
+
cy: "6",
|
|
429
|
+
r: "3",
|
|
430
|
+
key: "1lh9wr"
|
|
431
|
+
}],
|
|
432
|
+
["path", {
|
|
433
|
+
d: "M8.12 8.12 12 12",
|
|
434
|
+
key: "1alkpv"
|
|
435
|
+
}],
|
|
436
|
+
["path", {
|
|
437
|
+
d: "M20 4 8.12 15.88",
|
|
438
|
+
key: "xgtan2"
|
|
439
|
+
}],
|
|
440
|
+
["circle", {
|
|
441
|
+
cx: "6",
|
|
442
|
+
cy: "18",
|
|
443
|
+
r: "3",
|
|
444
|
+
key: "fqmcym"
|
|
445
|
+
}],
|
|
446
|
+
["path", {
|
|
447
|
+
d: "M14.8 14.8 20 20",
|
|
448
|
+
key: "ptml3r"
|
|
449
|
+
}]
|
|
450
|
+
]), he = I("search", [["path", {
|
|
451
|
+
d: "m21 21-4.34-4.34",
|
|
452
|
+
key: "14j7rj"
|
|
453
|
+
}], ["circle", {
|
|
454
|
+
cx: "11",
|
|
455
|
+
cy: "11",
|
|
456
|
+
r: "8",
|
|
457
|
+
key: "4ej97u"
|
|
458
|
+
}]]), ge = I("square-check-big", [["path", {
|
|
459
|
+
d: "M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",
|
|
460
|
+
key: "2acyp4"
|
|
461
|
+
}], ["path", {
|
|
462
|
+
d: "m9 11 3 3L22 4",
|
|
463
|
+
key: "1pflzl"
|
|
464
|
+
}]]), _e = I("square", [["rect", {
|
|
465
|
+
width: "18",
|
|
466
|
+
height: "18",
|
|
467
|
+
x: "3",
|
|
468
|
+
y: "3",
|
|
469
|
+
rx: "2",
|
|
470
|
+
key: "afitv7"
|
|
471
|
+
}]]), ve = I("trash-2", [
|
|
472
|
+
["path", {
|
|
473
|
+
d: "M10 11v6",
|
|
474
|
+
key: "nco0om"
|
|
475
|
+
}],
|
|
476
|
+
["path", {
|
|
477
|
+
d: "M14 11v6",
|
|
478
|
+
key: "outv1u"
|
|
479
|
+
}],
|
|
480
|
+
["path", {
|
|
481
|
+
d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",
|
|
482
|
+
key: "miytrc"
|
|
483
|
+
}],
|
|
484
|
+
["path", {
|
|
485
|
+
d: "M3 6h18",
|
|
486
|
+
key: "d0wm0j"
|
|
487
|
+
}],
|
|
488
|
+
["path", {
|
|
489
|
+
d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",
|
|
490
|
+
key: "e791ji"
|
|
491
|
+
}]
|
|
492
|
+
]), ye = I("upload", [
|
|
493
|
+
["path", {
|
|
494
|
+
d: "M12 3v12",
|
|
495
|
+
key: "1x0j5s"
|
|
496
|
+
}],
|
|
497
|
+
["path", {
|
|
498
|
+
d: "m17 8-5-5-5 5",
|
|
499
|
+
key: "7q97r8"
|
|
500
|
+
}],
|
|
501
|
+
["path", {
|
|
502
|
+
d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
|
|
503
|
+
key: "ih7n3h"
|
|
504
|
+
}]
|
|
505
|
+
]), V = I("x", [["path", {
|
|
506
|
+
d: "M18 6 6 18",
|
|
507
|
+
key: "1bl5f8"
|
|
508
|
+
}], ["path", {
|
|
509
|
+
d: "m6 6 12 12",
|
|
510
|
+
key: "d8bk6v"
|
|
511
|
+
}]]);
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/core/upload-drop.ts
|
|
514
|
+
async function be(e) {
|
|
515
|
+
let t = Array.from(e.items).map((e) => e.webkitGetAsEntry?.()).filter((e) => !!e);
|
|
516
|
+
if (t.length === 0) return xe(e.files);
|
|
517
|
+
let n = [];
|
|
518
|
+
for (let e of t) n.push(...await H(e));
|
|
519
|
+
return n;
|
|
520
|
+
}
|
|
521
|
+
function xe(e) {
|
|
522
|
+
return Array.from(e).map((e) => ({
|
|
523
|
+
file: e,
|
|
524
|
+
relativePath: Te(Ce(e))
|
|
525
|
+
}));
|
|
526
|
+
}
|
|
527
|
+
async function H(e, t = "") {
|
|
528
|
+
if (e.isFile) {
|
|
529
|
+
let n = await U(e);
|
|
530
|
+
return [{
|
|
531
|
+
file: n,
|
|
532
|
+
relativePath: Te(we(t, n.name))
|
|
533
|
+
}];
|
|
534
|
+
}
|
|
535
|
+
let n = we(t, e.name), r = await Se(e), i = [];
|
|
536
|
+
for (let e of r) i.push(...await H(e, n));
|
|
537
|
+
return i;
|
|
538
|
+
}
|
|
539
|
+
function U(e) {
|
|
540
|
+
return new Promise((t, n) => {
|
|
541
|
+
e.file(t, n);
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
async function Se(e) {
|
|
545
|
+
let t = e.createReader(), n = [];
|
|
546
|
+
for (;;) {
|
|
547
|
+
let e = await new Promise((e, n) => {
|
|
548
|
+
t.readEntries(e, n);
|
|
549
|
+
});
|
|
550
|
+
if (e.length === 0) break;
|
|
551
|
+
n.push(...e);
|
|
552
|
+
}
|
|
553
|
+
return n;
|
|
554
|
+
}
|
|
555
|
+
function Ce(e) {
|
|
556
|
+
return e.webkitRelativePath || e.name;
|
|
557
|
+
}
|
|
558
|
+
function we(...e) {
|
|
559
|
+
return e.filter(Boolean).join("/");
|
|
560
|
+
}
|
|
561
|
+
function Te(e) {
|
|
562
|
+
return e.replaceAll("\\", "/").split("/").filter((e) => e && e !== "." && e !== "..").join("/");
|
|
563
|
+
}
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/transfers/transfer-manager.ts
|
|
566
|
+
var Ee = "react-file-browser-transfers", De = 1440 * 60 * 1e3, W = class {
|
|
567
|
+
uploads = /* @__PURE__ */ new Map();
|
|
568
|
+
downloads = /* @__PURE__ */ new Map();
|
|
569
|
+
uploadSpeedSamples = /* @__PURE__ */ new Map();
|
|
570
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
571
|
+
activeTasks = /* @__PURE__ */ new Set();
|
|
572
|
+
storage;
|
|
573
|
+
storageKey;
|
|
574
|
+
idFactory;
|
|
575
|
+
now;
|
|
576
|
+
snapshotCache;
|
|
577
|
+
constructor(e = {}) {
|
|
578
|
+
this.storage = e.storage, this.storageKey = e.storageKey ?? Ee, this.idFactory = e.idFactory ?? Pe, this.now = e.now ?? (() => /* @__PURE__ */ new Date()), this.restorePersisted(), this.downloads.size > 0 && this.pruneExpiredDownloads();
|
|
579
|
+
}
|
|
580
|
+
subscribe(e) {
|
|
581
|
+
return this.subscribers.add(e), () => {
|
|
582
|
+
this.subscribers.delete(e);
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
getSnapshot() {
|
|
586
|
+
return this.snapshotCache ??= {
|
|
587
|
+
uploads: Array.from(this.uploads.values()).map(je),
|
|
588
|
+
downloads: Array.from(this.downloads.values()).map((e) => ({ ...K(e) }))
|
|
589
|
+
}, this.snapshotCache;
|
|
590
|
+
}
|
|
591
|
+
getUpload(e) {
|
|
592
|
+
let t = this.uploads.get(e);
|
|
593
|
+
return t ? je(t) : void 0;
|
|
594
|
+
}
|
|
595
|
+
getRestorableUploads() {
|
|
596
|
+
return Array.from(this.uploads.values()).filter((e) => [
|
|
597
|
+
"queued",
|
|
598
|
+
"uploading",
|
|
599
|
+
"paused",
|
|
600
|
+
"failed"
|
|
601
|
+
].includes(e.status)).filter((e) => !e.file || !e.adapter).map(je);
|
|
602
|
+
}
|
|
603
|
+
dismissRestoredUploads(e) {
|
|
604
|
+
for (let t of e) {
|
|
605
|
+
let e = this.uploads.get(t);
|
|
606
|
+
e && (e.status = "cancelled", this.uploadSpeedSamples.delete(t), e.updatedAt = this.timestamp());
|
|
607
|
+
}
|
|
608
|
+
this.persistAndNotify();
|
|
609
|
+
}
|
|
610
|
+
dismissDownload(e) {
|
|
611
|
+
let t = this.downloads.get(e);
|
|
612
|
+
t && (Ne(t.url), this.downloads.delete(e), this.persistAndNotify());
|
|
613
|
+
}
|
|
614
|
+
hasActiveTransfers() {
|
|
615
|
+
let e = this.getSnapshot();
|
|
616
|
+
return e.uploads.some((e) => ["queued", "uploading"].includes(e.status)) || e.downloads.some((e) => e.status === "preparing");
|
|
617
|
+
}
|
|
618
|
+
enqueueUpload({ adapter: e, destinationPath: t, file: n, group: r, onConflict: i }) {
|
|
619
|
+
let a = this.idFactory(), o = this.timestamp(), s = {
|
|
620
|
+
id: a,
|
|
621
|
+
kind: "upload",
|
|
622
|
+
status: "queued",
|
|
623
|
+
path: t,
|
|
624
|
+
name: n.name,
|
|
625
|
+
loadedBytes: 0,
|
|
626
|
+
totalBytes: n.size,
|
|
627
|
+
completedParts: [],
|
|
628
|
+
createdAt: o,
|
|
629
|
+
updatedAt: o,
|
|
630
|
+
adapter: e,
|
|
631
|
+
file: n,
|
|
632
|
+
group: r,
|
|
633
|
+
onConflict: i,
|
|
634
|
+
abortController: new AbortController()
|
|
635
|
+
};
|
|
636
|
+
return this.uploads.set(a, s), this.persistAndNotify(), this.track(this.runUpload(a)), a;
|
|
637
|
+
}
|
|
638
|
+
resumeUpload(e) {
|
|
639
|
+
let t = this.uploads.get(e);
|
|
640
|
+
return !t || !t.adapter || !t.file ? Promise.resolve() : (t.status = "queued", t.error = void 0, t.bytesPerSecond = void 0, this.uploadSpeedSamples.delete(e), t.abortController = new AbortController(), t.updatedAt = this.timestamp(), this.persistAndNotify(), this.track(this.runUpload(e)), Promise.resolve());
|
|
641
|
+
}
|
|
642
|
+
resumeRestoredUpload({ adapter: e, file: t, id: n, onConflict: r }) {
|
|
643
|
+
let i = this.uploads.get(n);
|
|
644
|
+
return i ? (i.adapter = e, i.file = t, i.name = t.name, i.totalBytes = t.size, i.onConflict = r ?? i.onConflict, i.status = "queued", i.error = void 0, i.bytesPerSecond = void 0, this.uploadSpeedSamples.delete(n), i.abortController = new AbortController(), i.updatedAt = this.timestamp(), this.persistAndNotify(), this.track(this.runUpload(n)), Promise.resolve()) : Promise.resolve();
|
|
645
|
+
}
|
|
646
|
+
pauseUpload(e) {
|
|
647
|
+
let t = this.uploads.get(e);
|
|
648
|
+
t && (t.abortController?.abort(), t.status = "paused", this.uploadSpeedSamples.delete(e), t.updatedAt = this.timestamp(), this.persistAndNotify());
|
|
649
|
+
}
|
|
650
|
+
async cancelUpload(e) {
|
|
651
|
+
let t = this.uploads.get(e);
|
|
652
|
+
t && (t.abortController?.abort(), t.status = "cancelled", this.uploadSpeedSamples.delete(e), t.updatedAt = this.timestamp(), t.uploadId && t.adapter?.abortMultipartUpload && await t.adapter.abortMultipartUpload(t.uploadId), this.persistAndNotify());
|
|
653
|
+
}
|
|
654
|
+
async waitForIdle() {
|
|
655
|
+
for (; this.activeTasks.size > 0;) await Promise.allSettled(Array.from(this.activeTasks));
|
|
656
|
+
}
|
|
657
|
+
async prepareBulkDownload({ adapter: e, paths: t, selectedBytes: n, warnZipSizeBytes: r = Infinity }) {
|
|
658
|
+
let i = this.idFactory(), a = this.timestamp(), o = {
|
|
659
|
+
id: i,
|
|
660
|
+
kind: "bulk-download",
|
|
661
|
+
status: "preparing",
|
|
662
|
+
strategy: e.bulkDownloadUrl ? "server" : "client",
|
|
663
|
+
adapter: e,
|
|
664
|
+
paths: [...t],
|
|
665
|
+
selectedBytes: n,
|
|
666
|
+
createdAt: a,
|
|
667
|
+
updatedAt: a
|
|
668
|
+
};
|
|
669
|
+
this.downloads.set(i, o), this.persistAndNotify();
|
|
670
|
+
try {
|
|
671
|
+
if (e.bulkDownloadUrl) {
|
|
672
|
+
let n = await e.bulkDownloadUrl(t);
|
|
673
|
+
o.status = "ready", o.url = n.url, o.expiresAt = n.expiresAt;
|
|
674
|
+
} else n > r ? (o.status = "warning", o.warning = "client_zip_size") : (o.url = await Ie(e, t), o.status = "ready");
|
|
675
|
+
} catch (e) {
|
|
676
|
+
o.status = "failed", o.error = Fe(e);
|
|
677
|
+
}
|
|
678
|
+
return o.updatedAt = this.timestamp(), this.persistAndNotify(), K(o);
|
|
679
|
+
}
|
|
680
|
+
async prepareSingleDownload({ adapter: e, path: t, selectedBytes: n = 0 }) {
|
|
681
|
+
let r = this.idFactory(), i = this.timestamp(), a = {
|
|
682
|
+
id: r,
|
|
683
|
+
kind: "bulk-download",
|
|
684
|
+
status: "preparing",
|
|
685
|
+
strategy: "single",
|
|
686
|
+
adapter: e,
|
|
687
|
+
paths: [t],
|
|
688
|
+
selectedBytes: n,
|
|
689
|
+
createdAt: i,
|
|
690
|
+
updatedAt: i
|
|
691
|
+
};
|
|
692
|
+
this.downloads.set(r, a), this.persistAndNotify();
|
|
693
|
+
try {
|
|
694
|
+
a.url = await e.signedUrl(t), a.status = "ready";
|
|
695
|
+
} catch (e) {
|
|
696
|
+
a.status = "failed", a.error = Fe(e);
|
|
697
|
+
}
|
|
698
|
+
return a.updatedAt = this.timestamp(), this.persistAndNotify(), K(a);
|
|
699
|
+
}
|
|
700
|
+
async confirmBulkDownload(e) {
|
|
701
|
+
let t = this.downloads.get(e);
|
|
702
|
+
if (t) {
|
|
703
|
+
if (t.status !== "warning") return K(t);
|
|
704
|
+
if (!t.adapter) return t.status = "failed", t.error = "This download can no longer continue in the current session.", t.updatedAt = this.timestamp(), this.persistAndNotify(), K(t);
|
|
705
|
+
t.status = "preparing", t.warning = void 0, t.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
706
|
+
try {
|
|
707
|
+
t.url = await Ie(t.adapter, t.paths), t.status = "ready";
|
|
708
|
+
} catch (e) {
|
|
709
|
+
t.status = "failed", t.error = Fe(e);
|
|
710
|
+
}
|
|
711
|
+
return t.updatedAt = this.timestamp(), this.persistAndNotify(), K(t);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async runUpload(e) {
|
|
715
|
+
let t = this.uploads.get(e);
|
|
716
|
+
if (!(!t?.adapter || !t.file)) {
|
|
717
|
+
t.status = "uploading", t.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
718
|
+
try {
|
|
719
|
+
let e = Oe(t.adapter) ? await this.runMultipartUpload(t) : await this.runSimpleUpload(t);
|
|
720
|
+
t.status = "completed", t.loadedBytes = t.totalBytes, t.result = e, this.uploadSpeedSamples.delete(t.id), t.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
721
|
+
} catch (e) {
|
|
722
|
+
if (["paused", "cancelled"].includes(t.status)) {
|
|
723
|
+
this.uploadSpeedSamples.delete(t.id), this.persistAndNotify();
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
t.status = "failed", t.error = Fe(e), this.uploadSpeedSamples.delete(t.id), t.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
async runSimpleUpload(e) {
|
|
731
|
+
if (!e.adapter || !e.file) throw Error("Upload is missing adapter or file");
|
|
732
|
+
return e.adapter.upload(e.path, e.file, {
|
|
733
|
+
onConflict: e.onConflict,
|
|
734
|
+
signal: e.abortController?.signal,
|
|
735
|
+
onProgress: (t, n) => {
|
|
736
|
+
this.updateUploadProgress(e, t, n);
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
async runMultipartUpload(e) {
|
|
741
|
+
let t = e.adapter, n = e.file;
|
|
742
|
+
if (!t || !n || !Oe(t)) throw Error("Multipart upload is not available");
|
|
743
|
+
if (!e.uploadId || !e.partSize) {
|
|
744
|
+
await G(e);
|
|
745
|
+
let r = await t.createMultipartUpload(e.path, n.size);
|
|
746
|
+
e.uploadId = r.uploadId, e.partSize = r.partSize, e.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
747
|
+
}
|
|
748
|
+
let r = e.partSize, i = Math.ceil(n.size / r);
|
|
749
|
+
for (let a = 1; a <= i; a += 1) {
|
|
750
|
+
if (e.completedParts.some((e) => e.partNumber === a)) continue;
|
|
751
|
+
let i = (a - 1) * r, o = Math.min(i + r, n.size), s = n.slice(i, o), c = ke(e), l = await t.uploadPart({
|
|
752
|
+
uploadId: e.uploadId,
|
|
753
|
+
partNumber: a,
|
|
754
|
+
chunk: s,
|
|
755
|
+
signal: e.abortController?.signal,
|
|
756
|
+
onProgress: (t) => {
|
|
757
|
+
this.updateUploadProgress(e, c + t, e.totalBytes);
|
|
758
|
+
}
|
|
759
|
+
});
|
|
760
|
+
e.completedParts = [...e.completedParts, {
|
|
761
|
+
partNumber: a,
|
|
762
|
+
etag: l.etag
|
|
763
|
+
}].sort((e, t) => e.partNumber - t.partNumber), e.loadedBytes = ke(e), e.updatedAt = this.timestamp(), this.persistAndNotify();
|
|
764
|
+
}
|
|
765
|
+
return t.completeMultipartUpload({
|
|
766
|
+
uploadId: e.uploadId,
|
|
767
|
+
parts: e.completedParts
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
updateUploadProgress(e, t, n) {
|
|
771
|
+
let r = this.now(), i = r.getTime(), a = this.uploadSpeedSamples.get(e.id);
|
|
772
|
+
e.loadedBytes = t, e.totalBytes = n, a && t > a.loadedBytes && i > a.timeMs && (e.bytesPerSecond = (t - a.loadedBytes) / (i - a.timeMs) * 1e3), this.uploadSpeedSamples.set(e.id, {
|
|
773
|
+
loadedBytes: t,
|
|
774
|
+
timeMs: i
|
|
775
|
+
}), e.updatedAt = r.toISOString(), this.persistAndNotify();
|
|
776
|
+
}
|
|
777
|
+
track(e) {
|
|
778
|
+
this.activeTasks.add(e), e.finally(() => {
|
|
779
|
+
this.activeTasks.delete(e);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
persistAndNotify() {
|
|
783
|
+
this.snapshotCache = void 0, this.persist();
|
|
784
|
+
for (let e of this.subscribers) e();
|
|
785
|
+
}
|
|
786
|
+
persist() {
|
|
787
|
+
if (!this.storage) return;
|
|
788
|
+
let e = {
|
|
789
|
+
uploads: Array.from(this.uploads.values()).map((e) => ({
|
|
790
|
+
...je(e),
|
|
791
|
+
file: void 0,
|
|
792
|
+
adapter: void 0,
|
|
793
|
+
abortController: void 0
|
|
794
|
+
})),
|
|
795
|
+
downloads: Array.from(this.downloads.values()).map(K)
|
|
796
|
+
};
|
|
797
|
+
this.storage.setItem(this.storageKey, JSON.stringify(e));
|
|
798
|
+
}
|
|
799
|
+
restorePersisted() {
|
|
800
|
+
if (!this.storage) return;
|
|
801
|
+
let e = this.storage.getItem(this.storageKey);
|
|
802
|
+
if (e) try {
|
|
803
|
+
let t = JSON.parse(e);
|
|
804
|
+
for (let e of t.uploads ?? []) this.uploads.set(e.id, {
|
|
805
|
+
...e,
|
|
806
|
+
file: void 0,
|
|
807
|
+
adapter: void 0,
|
|
808
|
+
abortController: void 0
|
|
809
|
+
});
|
|
810
|
+
for (let e of t.downloads ?? []) this.downloads.set(e.id, { ...e });
|
|
811
|
+
} catch {
|
|
812
|
+
this.storage.removeItem(this.storageKey);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
timestamp() {
|
|
816
|
+
return this.now().toISOString();
|
|
817
|
+
}
|
|
818
|
+
pruneExpiredDownloads() {
|
|
819
|
+
let e = this.now().getTime(), t = !1;
|
|
820
|
+
for (let [n, r] of this.downloads) Me(r, e) && (Ne(r.url), this.downloads.delete(n), t = !0);
|
|
821
|
+
t && (this.snapshotCache = void 0, this.persist());
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
function Oe(e) {
|
|
825
|
+
return typeof e.createMultipartUpload == "function" && typeof e.uploadPart == "function" && typeof e.completeMultipartUpload == "function";
|
|
826
|
+
}
|
|
827
|
+
function ke(e) {
|
|
828
|
+
let t = e.partSize ?? e.totalBytes;
|
|
829
|
+
return e.completedParts.reduce((n, r) => {
|
|
830
|
+
let i = (r.partNumber - 1) * t;
|
|
831
|
+
return n + Math.min(t, e.totalBytes - i);
|
|
832
|
+
}, 0);
|
|
833
|
+
}
|
|
834
|
+
async function G(e) {
|
|
835
|
+
let n = e.adapter;
|
|
836
|
+
if (!n?.exists) return;
|
|
837
|
+
let r = (e) => n.exists?.(e) ?? Promise.resolve({});
|
|
838
|
+
if ((await r([e.path]))[e.path]) {
|
|
839
|
+
if (e.onConflict === "keep-both") {
|
|
840
|
+
e.path = await Ae(r, e.path);
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (e.onConflict !== "replace") throw new t("conflict", `A file browser entry already exists at ${e.path}`);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
async function Ae(n, r) {
|
|
847
|
+
let a = o(r), s = i(r), c = s.lastIndexOf("."), l = c > 0, u = l ? s.slice(0, c) : s, d = l ? s.slice(c) : "";
|
|
848
|
+
for (let t = 1; t < 2 ** 53 - 1; t += 1) {
|
|
849
|
+
let r = e(a, `${u} (${t})${d}`);
|
|
850
|
+
if (!(await n([r]))[r]) return r;
|
|
851
|
+
}
|
|
852
|
+
throw new t("conflict", `Could not allocate a unique file browser path for ${r}`);
|
|
853
|
+
}
|
|
854
|
+
function je(e) {
|
|
855
|
+
return {
|
|
856
|
+
...e,
|
|
857
|
+
group: e.group ? { ...e.group } : void 0,
|
|
858
|
+
completedParts: e.completedParts.map((e) => ({ ...e }))
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function K(e) {
|
|
862
|
+
let { adapter: t, ...n } = e;
|
|
863
|
+
return {
|
|
864
|
+
...n,
|
|
865
|
+
paths: [...e.paths]
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function Me(e, t) {
|
|
869
|
+
if (e.status === "preparing") return !1;
|
|
870
|
+
if (e.expiresAt) {
|
|
871
|
+
let n = Date.parse(e.expiresAt);
|
|
872
|
+
if (Number.isFinite(n) && n <= t) return !0;
|
|
873
|
+
}
|
|
874
|
+
let n = Date.parse(e.updatedAt);
|
|
875
|
+
return Number.isFinite(n) && t - n > De;
|
|
876
|
+
}
|
|
877
|
+
function Ne(e) {
|
|
878
|
+
!e?.startsWith("blob:") || typeof URL > "u" || typeof URL.revokeObjectURL != "function" || URL.revokeObjectURL(e);
|
|
879
|
+
}
|
|
880
|
+
function Pe() {
|
|
881
|
+
return `transfer-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
882
|
+
}
|
|
883
|
+
function Fe(e) {
|
|
884
|
+
return e instanceof Error ? e.message : String(e);
|
|
885
|
+
}
|
|
886
|
+
async function Ie(e, t) {
|
|
887
|
+
let n = await q(e, t), r = {};
|
|
888
|
+
for (let t of n) {
|
|
889
|
+
let n = await e.signedUrl(t.path), i = await fetch(n);
|
|
890
|
+
if (!i.ok) throw Error(`Could not fetch ${t.path} for the client zip`);
|
|
891
|
+
r[t.archivePath] = new Uint8Array(await i.arrayBuffer());
|
|
892
|
+
}
|
|
893
|
+
let i = d(r);
|
|
894
|
+
return URL.createObjectURL(new Blob([i], { type: "application/zip" }));
|
|
895
|
+
}
|
|
896
|
+
async function q(e, t) {
|
|
897
|
+
let n = [], r = /* @__PURE__ */ new Set();
|
|
898
|
+
for (let i of t) await Le(e, i, n, r);
|
|
899
|
+
return n;
|
|
900
|
+
}
|
|
901
|
+
async function Le(e, t, n, r) {
|
|
902
|
+
if (r.has(t)) return;
|
|
903
|
+
r.add(t);
|
|
904
|
+
let i = await Re(e, t);
|
|
905
|
+
if (i?.kind === "file") {
|
|
906
|
+
n.push({
|
|
907
|
+
path: t,
|
|
908
|
+
archivePath: Be(t)
|
|
909
|
+
});
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
if (i?.kind === "folder") {
|
|
913
|
+
await J(e, t, n, r);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
let a = await ze(e, t);
|
|
917
|
+
if (a) {
|
|
918
|
+
for (let t of a) await Le(e, t.path, n, r);
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
n.push({
|
|
922
|
+
path: t,
|
|
923
|
+
archivePath: Be(t)
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
async function J(e, t, n, r) {
|
|
927
|
+
let i;
|
|
928
|
+
do {
|
|
929
|
+
let a = await e.list(t, { cursor: i });
|
|
930
|
+
for (let t of a.items) await Le(e, t.path, n, r);
|
|
931
|
+
i = a.cursor;
|
|
932
|
+
} while (i);
|
|
933
|
+
}
|
|
934
|
+
async function Re(e, t) {
|
|
935
|
+
if (e.stat) try {
|
|
936
|
+
return await e.stat(t);
|
|
937
|
+
} catch {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
async function ze(e, t) {
|
|
942
|
+
try {
|
|
943
|
+
let n, r = [];
|
|
944
|
+
do {
|
|
945
|
+
let i = await e.list(t, { cursor: n });
|
|
946
|
+
r.push(...i.items), n = i.cursor;
|
|
947
|
+
} while (n);
|
|
948
|
+
return r;
|
|
949
|
+
} catch {
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function Be(e) {
|
|
954
|
+
return e.replace(/^\/+/, "") || "download";
|
|
955
|
+
}
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/transfers/file-browser-provider.tsx
|
|
958
|
+
var Ve = f(null), He = "transition-[background-color,border-color,color,box-shadow,opacity] duration-150 ease-out motion-reduce:transition-none", Y = "transition-[background-color,border-color,box-shadow,opacity] duration-200 ease-out motion-reduce:transition-none";
|
|
959
|
+
function Ue({ children: e, manager: t, options: n, resolveRestoredUpload: r, showFloatingWidget: i = !0 }) {
|
|
960
|
+
let a = v(() => t ?? new W(Je(n)), [t, n]), o = Ke(a), [s, c] = b(!1), l = a.getRestorableUploads();
|
|
961
|
+
qe(a);
|
|
962
|
+
async function u(e) {
|
|
963
|
+
for (let t of e) {
|
|
964
|
+
if (t.adapter && t.file) {
|
|
965
|
+
await a.resumeUpload(t.id);
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
let e = await r?.(t);
|
|
969
|
+
e && await a.resumeRestoredUpload({
|
|
970
|
+
id: t.id,
|
|
971
|
+
...e
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
c(!0);
|
|
975
|
+
}
|
|
976
|
+
return /* @__PURE__ */ E(Ve.Provider, {
|
|
977
|
+
value: a,
|
|
978
|
+
children: [
|
|
979
|
+
e,
|
|
980
|
+
i ? /* @__PURE__ */ T(Ye, {
|
|
981
|
+
manager: a,
|
|
982
|
+
snapshot: o
|
|
983
|
+
}) : null,
|
|
984
|
+
!s && l.length > 0 ? /* @__PURE__ */ T(Qe, {
|
|
985
|
+
count: l.length,
|
|
986
|
+
onDismiss: () => {
|
|
987
|
+
a.dismissRestoredUploads(l.map((e) => e.id)), c(!0);
|
|
988
|
+
},
|
|
989
|
+
onResume: () => {
|
|
990
|
+
u(l);
|
|
991
|
+
}
|
|
992
|
+
}) : null
|
|
993
|
+
]
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
function We() {
|
|
997
|
+
return g(Ve) ?? $e;
|
|
998
|
+
}
|
|
999
|
+
function Ge() {
|
|
1000
|
+
return Ke(We());
|
|
1001
|
+
}
|
|
1002
|
+
function Ke(e) {
|
|
1003
|
+
return x((t) => e.subscribe(t), () => e.getSnapshot(), () => ({
|
|
1004
|
+
uploads: [],
|
|
1005
|
+
downloads: []
|
|
1006
|
+
}));
|
|
1007
|
+
}
|
|
1008
|
+
function qe(e) {
|
|
1009
|
+
_(() => {
|
|
1010
|
+
let t = (t) => {
|
|
1011
|
+
e.hasActiveTransfers() && (t.preventDefault(), t.returnValue = "");
|
|
1012
|
+
};
|
|
1013
|
+
return window.addEventListener("beforeunload", t), () => window.removeEventListener("beforeunload", t);
|
|
1014
|
+
}, [e]);
|
|
1015
|
+
}
|
|
1016
|
+
function Je(e) {
|
|
1017
|
+
if (e?.storage) return e;
|
|
1018
|
+
let t = typeof window > "u" ? void 0 : window.localStorage;
|
|
1019
|
+
return t ? {
|
|
1020
|
+
...e,
|
|
1021
|
+
storage: t
|
|
1022
|
+
} : e ?? {};
|
|
1023
|
+
}
|
|
1024
|
+
function Ye({ manager: e, snapshot: t }) {
|
|
1025
|
+
let n = t.uploads.filter(rt), r = it(t.uploads), i = new Set(r.flatMap((e) => e.activeUploads.map((e) => e.id))), a = n.filter((e) => !i.has(e.id)), o = t.downloads.filter((e) => [
|
|
1026
|
+
"preparing",
|
|
1027
|
+
"warning",
|
|
1028
|
+
"ready",
|
|
1029
|
+
"failed"
|
|
1030
|
+
].includes(e.status));
|
|
1031
|
+
return n.length === 0 && o.length === 0 ? null : C(/* @__PURE__ */ E("aside", {
|
|
1032
|
+
"aria-label": "Transfers",
|
|
1033
|
+
className: `fixed bottom-4 right-4 z-50 w-[min(360px,calc(100vw-2rem))] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-3 text-[12px] text-[var(--fb-text)] shadow-[0_16px_44px_color-mix(in_oklch,var(--fb-text)_16%,transparent)] ${Y}`,
|
|
1034
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1035
|
+
className: "mb-2 flex items-center justify-between gap-2",
|
|
1036
|
+
children: [/* @__PURE__ */ T("div", {
|
|
1037
|
+
className: "font-semibold",
|
|
1038
|
+
children: "Transfers"
|
|
1039
|
+
}), /* @__PURE__ */ E("div", {
|
|
1040
|
+
className: "text-[11px] text-[var(--fb-muted)]",
|
|
1041
|
+
children: [n.length + o.length, " active"]
|
|
1042
|
+
})]
|
|
1043
|
+
}), /* @__PURE__ */ E("div", {
|
|
1044
|
+
className: "flex flex-col gap-2",
|
|
1045
|
+
children: [
|
|
1046
|
+
r.map((t) => /* @__PURE__ */ T(Xe, {
|
|
1047
|
+
group: t,
|
|
1048
|
+
manager: e
|
|
1049
|
+
}, t.group.id)),
|
|
1050
|
+
a.map((t) => /* @__PURE__ */ T(Ze, {
|
|
1051
|
+
manager: e,
|
|
1052
|
+
upload: t
|
|
1053
|
+
}, t.id)),
|
|
1054
|
+
o.map((t) => /* @__PURE__ */ E("div", {
|
|
1055
|
+
className: "text-[11px] text-[var(--fb-muted)]",
|
|
1056
|
+
children: [
|
|
1057
|
+
t.status === "ready" && t.url ? /* @__PURE__ */ E("div", {
|
|
1058
|
+
className: "flex items-center justify-between gap-2",
|
|
1059
|
+
children: [/* @__PURE__ */ E("a", {
|
|
1060
|
+
"aria-label": "Open prepared download",
|
|
1061
|
+
className: `inline-flex min-w-0 items-center gap-1 rounded-[calc(var(--fb-radius)-4px)] px-1.5 py-1 font-medium text-[var(--fb-accent)] hover:bg-[var(--fb-accent-soft)] ${He}`,
|
|
1062
|
+
download: !0,
|
|
1063
|
+
href: t.url,
|
|
1064
|
+
onClick: () => e.dismissDownload(t.id),
|
|
1065
|
+
children: [/* @__PURE__ */ T(L, {
|
|
1066
|
+
"aria-hidden": "true",
|
|
1067
|
+
className: "size-3.5 shrink-0"
|
|
1068
|
+
}), /* @__PURE__ */ T("span", {
|
|
1069
|
+
className: "truncate",
|
|
1070
|
+
children: ct(t)
|
|
1071
|
+
})]
|
|
1072
|
+
}), /* @__PURE__ */ T("button", {
|
|
1073
|
+
"aria-label": "Dismiss download",
|
|
1074
|
+
className: et(),
|
|
1075
|
+
onClick: () => e.dismissDownload(t.id),
|
|
1076
|
+
type: "button",
|
|
1077
|
+
children: /* @__PURE__ */ T(V, {
|
|
1078
|
+
"aria-hidden": "true",
|
|
1079
|
+
className: "size-3.5"
|
|
1080
|
+
})
|
|
1081
|
+
})]
|
|
1082
|
+
}) : null,
|
|
1083
|
+
t.status === "warning" ? /* @__PURE__ */ E("div", {
|
|
1084
|
+
className: "flex items-center justify-between gap-2",
|
|
1085
|
+
children: [/* @__PURE__ */ T("span", { children: "Large client zip" }), /* @__PURE__ */ T("button", {
|
|
1086
|
+
className: tt(),
|
|
1087
|
+
onClick: () => void e.confirmBulkDownload(t.id),
|
|
1088
|
+
type: "button",
|
|
1089
|
+
children: "Continue"
|
|
1090
|
+
})]
|
|
1091
|
+
}) : null,
|
|
1092
|
+
t.status === "preparing" ? /* @__PURE__ */ T("span", { children: "Preparing zip" }) : null,
|
|
1093
|
+
t.status === "failed" ? /* @__PURE__ */ T("span", {
|
|
1094
|
+
className: "text-[var(--fb-danger)]",
|
|
1095
|
+
children: t.error ?? "Download failed"
|
|
1096
|
+
}) : null
|
|
1097
|
+
]
|
|
1098
|
+
}, t.id))
|
|
1099
|
+
]
|
|
1100
|
+
})]
|
|
1101
|
+
}), document.body);
|
|
1102
|
+
}
|
|
1103
|
+
function Xe({ group: e, manager: t }) {
|
|
1104
|
+
return /* @__PURE__ */ E("div", {
|
|
1105
|
+
className: Y,
|
|
1106
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1107
|
+
className: "flex items-center justify-between gap-2",
|
|
1108
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1109
|
+
className: "min-w-0",
|
|
1110
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1111
|
+
className: "truncate font-semibold",
|
|
1112
|
+
children: ["Uploading ", e.group.name]
|
|
1113
|
+
}), /* @__PURE__ */ T("div", {
|
|
1114
|
+
className: "text-[11px] text-[var(--fb-muted)]",
|
|
1115
|
+
children: at(e)
|
|
1116
|
+
})]
|
|
1117
|
+
}), /* @__PURE__ */ T("button", {
|
|
1118
|
+
"aria-label": `Cancel upload group ${e.group.name}`,
|
|
1119
|
+
className: et(),
|
|
1120
|
+
onClick: () => {
|
|
1121
|
+
for (let n of e.activeUploads) t.cancelUpload(n.id);
|
|
1122
|
+
},
|
|
1123
|
+
title: "Cancel",
|
|
1124
|
+
type: "button",
|
|
1125
|
+
children: /* @__PURE__ */ T(V, {
|
|
1126
|
+
"aria-hidden": "true",
|
|
1127
|
+
className: "size-3.5"
|
|
1128
|
+
})
|
|
1129
|
+
})]
|
|
1130
|
+
}), /* @__PURE__ */ T("div", {
|
|
1131
|
+
className: `mt-2 flex flex-col gap-1.5 border-l border-[var(--fb-border)] pl-3 ${Y}`,
|
|
1132
|
+
children: e.activeUploads.map((e) => /* @__PURE__ */ T(Ze, {
|
|
1133
|
+
compact: !0,
|
|
1134
|
+
manager: t,
|
|
1135
|
+
upload: e
|
|
1136
|
+
}, e.id))
|
|
1137
|
+
})]
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
function Ze({ compact: e = !1, manager: t, upload: n }) {
|
|
1141
|
+
return /* @__PURE__ */ E("div", {
|
|
1142
|
+
className: Y,
|
|
1143
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1144
|
+
className: "flex items-center justify-between gap-2",
|
|
1145
|
+
children: [/* @__PURE__ */ E("div", {
|
|
1146
|
+
className: "min-w-0",
|
|
1147
|
+
children: [/* @__PURE__ */ T("span", {
|
|
1148
|
+
className: "block truncate font-medium",
|
|
1149
|
+
children: n.name
|
|
1150
|
+
}), /* @__PURE__ */ T("span", {
|
|
1151
|
+
className: "text-[11px] text-[var(--fb-muted)]",
|
|
1152
|
+
children: ot(n)
|
|
1153
|
+
})]
|
|
1154
|
+
}), /* @__PURE__ */ E("div", {
|
|
1155
|
+
className: "flex shrink-0 items-center gap-1",
|
|
1156
|
+
children: [
|
|
1157
|
+
["queued", "uploading"].includes(n.status) ? /* @__PURE__ */ T("button", {
|
|
1158
|
+
"aria-label": `Pause upload ${n.name}`,
|
|
1159
|
+
className: et(),
|
|
1160
|
+
onClick: () => t.pauseUpload(n.id),
|
|
1161
|
+
title: "Pause",
|
|
1162
|
+
type: "button",
|
|
1163
|
+
children: /* @__PURE__ */ T(fe, {
|
|
1164
|
+
"aria-hidden": "true",
|
|
1165
|
+
className: "size-3.5"
|
|
1166
|
+
})
|
|
1167
|
+
}) : null,
|
|
1168
|
+
["failed", "paused"].includes(n.status) ? /* @__PURE__ */ T("button", {
|
|
1169
|
+
"aria-label": `Resume upload ${n.name}`,
|
|
1170
|
+
className: et(),
|
|
1171
|
+
onClick: () => void t.resumeUpload(n.id),
|
|
1172
|
+
title: "Resume",
|
|
1173
|
+
type: "button",
|
|
1174
|
+
children: /* @__PURE__ */ T(B, {
|
|
1175
|
+
"aria-hidden": "true",
|
|
1176
|
+
className: "size-3.5"
|
|
1177
|
+
})
|
|
1178
|
+
}) : null,
|
|
1179
|
+
/* @__PURE__ */ T("button", {
|
|
1180
|
+
"aria-label": `Cancel upload ${n.name}`,
|
|
1181
|
+
className: et(),
|
|
1182
|
+
onClick: () => void t.cancelUpload(n.id),
|
|
1183
|
+
title: "Cancel",
|
|
1184
|
+
type: "button",
|
|
1185
|
+
children: /* @__PURE__ */ T(V, {
|
|
1186
|
+
"aria-hidden": "true",
|
|
1187
|
+
className: "size-3.5"
|
|
1188
|
+
})
|
|
1189
|
+
})
|
|
1190
|
+
]
|
|
1191
|
+
})]
|
|
1192
|
+
}), /* @__PURE__ */ T("div", {
|
|
1193
|
+
className: `h-1.5 overflow-hidden rounded-full bg-[var(--fb-surface-2)] ${Y} ${e ? "mt-1" : "mt-1.5"}`,
|
|
1194
|
+
children: /* @__PURE__ */ T("div", {
|
|
1195
|
+
className: "h-full rounded-full bg-[var(--fb-accent)] transition-[width] duration-300 ease-out motion-reduce:transition-none",
|
|
1196
|
+
style: { width: `${Math.min(100, n.totalBytes ? n.loadedBytes / n.totalBytes * 100 : 0)}%` }
|
|
1197
|
+
})
|
|
1198
|
+
})]
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
function Qe({ count: e, onDismiss: t, onResume: n }) {
|
|
1202
|
+
return C(/* @__PURE__ */ T("div", {
|
|
1203
|
+
"aria-label": "Resume uploads",
|
|
1204
|
+
"aria-modal": "true",
|
|
1205
|
+
className: `fixed inset-0 z-50 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 text-[13px] text-[var(--fb-text)] ${Y}`,
|
|
1206
|
+
role: "dialog",
|
|
1207
|
+
children: /* @__PURE__ */ E("div", {
|
|
1208
|
+
className: `w-[min(380px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Y}`,
|
|
1209
|
+
children: [
|
|
1210
|
+
/* @__PURE__ */ T("h2", {
|
|
1211
|
+
className: "m-0 text-[14px] font-semibold",
|
|
1212
|
+
children: "Resume uploads"
|
|
1213
|
+
}),
|
|
1214
|
+
/* @__PURE__ */ E("p", {
|
|
1215
|
+
className: "mt-2 text-[12px] text-[var(--fb-muted)]",
|
|
1216
|
+
children: [
|
|
1217
|
+
"Resume ",
|
|
1218
|
+
e,
|
|
1219
|
+
" upload",
|
|
1220
|
+
e === 1 ? "?" : "s?"
|
|
1221
|
+
]
|
|
1222
|
+
}),
|
|
1223
|
+
/* @__PURE__ */ E("div", {
|
|
1224
|
+
className: "mt-4 flex justify-end gap-2",
|
|
1225
|
+
children: [/* @__PURE__ */ T("button", {
|
|
1226
|
+
className: tt(),
|
|
1227
|
+
onClick: t,
|
|
1228
|
+
type: "button",
|
|
1229
|
+
children: "Dismiss"
|
|
1230
|
+
}), /* @__PURE__ */ T("button", {
|
|
1231
|
+
className: nt(),
|
|
1232
|
+
onClick: n,
|
|
1233
|
+
type: "button",
|
|
1234
|
+
children: "Resume uploads"
|
|
1235
|
+
})]
|
|
1236
|
+
})
|
|
1237
|
+
]
|
|
1238
|
+
})
|
|
1239
|
+
}), document.body);
|
|
1240
|
+
}
|
|
1241
|
+
var $e = new W();
|
|
1242
|
+
function et() {
|
|
1243
|
+
return `grid size-7 place-items-center rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] text-[var(--fb-muted)] outline-none hover:bg-[var(--fb-bg)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${He}`;
|
|
1244
|
+
}
|
|
1245
|
+
function tt() {
|
|
1246
|
+
return `inline-flex h-7 items-center rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] px-2 text-[11px] font-medium text-[var(--fb-text)] outline-none hover:bg-[var(--fb-bg)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${He}`;
|
|
1247
|
+
}
|
|
1248
|
+
function nt() {
|
|
1249
|
+
return `inline-flex h-7 items-center rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-accent)] bg-[var(--fb-accent)] px-2 text-[11px] font-semibold text-[var(--fb-surface)] outline-none hover:opacity-90 focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${He}`;
|
|
1250
|
+
}
|
|
1251
|
+
function rt(e) {
|
|
1252
|
+
return [
|
|
1253
|
+
"queued",
|
|
1254
|
+
"uploading",
|
|
1255
|
+
"failed",
|
|
1256
|
+
"paused"
|
|
1257
|
+
].includes(e.status);
|
|
1258
|
+
}
|
|
1259
|
+
function it(e) {
|
|
1260
|
+
let t = /* @__PURE__ */ new Map();
|
|
1261
|
+
for (let n of e) {
|
|
1262
|
+
if (!n.group) continue;
|
|
1263
|
+
let e = t.get(n.group.id) ?? {
|
|
1264
|
+
group: n.group,
|
|
1265
|
+
uploads: [],
|
|
1266
|
+
activeUploads: [],
|
|
1267
|
+
completedCount: 0
|
|
1268
|
+
};
|
|
1269
|
+
e.uploads.push(n), n.status === "completed" && (e.completedCount += 1), rt(n) && e.activeUploads.push(n), t.set(n.group.id, e);
|
|
1270
|
+
}
|
|
1271
|
+
return Array.from(t.values()).filter((e) => e.activeUploads.length > 0);
|
|
1272
|
+
}
|
|
1273
|
+
function at(e) {
|
|
1274
|
+
let t = e.group.createdFolders, n = `${e.completedCount} of ${e.group.totalFiles} files`;
|
|
1275
|
+
return t <= 0 ? n : `${n}, ${t} folder${t === 1 ? "" : "s"} created`;
|
|
1276
|
+
}
|
|
1277
|
+
function ot(e) {
|
|
1278
|
+
return e.status !== "uploading" || typeof e.bytesPerSecond != "number" || !Number.isFinite(e.bytesPerSecond) || e.bytesPerSecond <= 0 ? e.status : `${e.status}, ${st(e.bytesPerSecond)}/s`;
|
|
1279
|
+
}
|
|
1280
|
+
function st(e) {
|
|
1281
|
+
let t = [
|
|
1282
|
+
"B",
|
|
1283
|
+
"KB",
|
|
1284
|
+
"MB",
|
|
1285
|
+
"GB",
|
|
1286
|
+
"TB"
|
|
1287
|
+
], n = Math.max(0, e), r = 0;
|
|
1288
|
+
for (; n >= 1024 && r < t.length - 1;) n /= 1024, r += 1;
|
|
1289
|
+
return `${r === 0 || n >= 10 ? Math.round(n).toString() : n.toFixed(1)} ${t[r]}`;
|
|
1290
|
+
}
|
|
1291
|
+
function ct(e) {
|
|
1292
|
+
let t = e.expiresAt ? lt(e.expiresAt) : void 0;
|
|
1293
|
+
return t ? `Download ready, expires in ${t}` : "Download ready";
|
|
1294
|
+
}
|
|
1295
|
+
function lt(e) {
|
|
1296
|
+
let t = Date.parse(e) - Date.now();
|
|
1297
|
+
if (!(!Number.isFinite(t) || t <= 0)) return t < 3600 * 1e3 ? `${Math.ceil(t / (60 * 1e3))}m` : t < 1440 * 60 * 1e3 ? `${Math.ceil(t / (3600 * 1e3))}h` : `${Math.ceil(t / (1440 * 60 * 1e3))}d`;
|
|
1298
|
+
}
|
|
1299
|
+
//#endregion
|
|
1300
|
+
//#region src/components/file-browser.tsx
|
|
1301
|
+
var ut = "application/x.react-file-browser.paths", dt = 220, ft = 5e3, X = "transition-[background-color,border-color,color,box-shadow,opacity] duration-150 ease-out motion-reduce:transition-none", Z = "transition-[background-color,border-color,box-shadow,opacity] duration-200 ease-out motion-reduce:transition-none", pt = {
|
|
1302
|
+
comfortable: {
|
|
1303
|
+
"--fb-font": "13px",
|
|
1304
|
+
"--fb-control-h": "32px",
|
|
1305
|
+
"--fb-cell-x": "12px",
|
|
1306
|
+
"--fb-cell-y": "8px",
|
|
1307
|
+
"--fb-pad": "12px",
|
|
1308
|
+
"--fb-card-min": "150px",
|
|
1309
|
+
"--fb-card-minh": "132px",
|
|
1310
|
+
"--fb-card-pad": "8px",
|
|
1311
|
+
"--fb-thumb-h": "64px",
|
|
1312
|
+
"--fb-grid-gap": "12px",
|
|
1313
|
+
"--fb-panel-w": "18rem",
|
|
1314
|
+
"--fb-panel-pad": "16px"
|
|
1315
|
+
},
|
|
1316
|
+
compact: {
|
|
1317
|
+
"--fb-font": "12px",
|
|
1318
|
+
"--fb-control-h": "28px",
|
|
1319
|
+
"--fb-cell-x": "10px",
|
|
1320
|
+
"--fb-cell-y": "6px",
|
|
1321
|
+
"--fb-pad": "8px",
|
|
1322
|
+
"--fb-card-min": "124px",
|
|
1323
|
+
"--fb-card-minh": "108px",
|
|
1324
|
+
"--fb-card-pad": "6px",
|
|
1325
|
+
"--fb-thumb-h": "48px",
|
|
1326
|
+
"--fb-grid-gap": "8px",
|
|
1327
|
+
"--fb-panel-w": "15rem",
|
|
1328
|
+
"--fb-panel-pad": "12px"
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
function mt({ adapter: e, initialPath: n = "/", density: i = "comfortable", readOnly: a = !1, showDetailsPanel: s = !0, uploadPolicy: c, warnZipSizeBytes: l }) {
|
|
1332
|
+
let u = D({
|
|
1333
|
+
adapter: e,
|
|
1334
|
+
initialPath: n
|
|
1335
|
+
}), d = We(), f = Ge(), [p, m] = b(!1), [g, x] = b(""), [S, C] = b(null), [w, O] = b(null), [k, ee] = b(""), [te, A] = b(null), [j, M] = b(null), [ne, N] = b(""), [re, P] = b(null), [ie, F] = b(!1), [ae, I] = b(!1), [ce, L] = b(null), [le, fe] = b(n), [pe, B] = b([]), [me, ge] = b("idle"), [_e, ve] = b(null), [V, H] = b(null), [U, Se] = b(null), [Ce, we] = b([]), [Te, Ee] = b(!1), [De, W] = b(null), [Oe, ke] = b(!1), [G, Ae] = b(null), je = y(null), K = y(null), Me = y(null), Ne = y(null), Pe = y(null), Fe = y(/* @__PURE__ */ new Set()), Ie = u.selectedItems.at(0) ?? null, q = v(() => u.filteredItems.filter((e) => e.kind === "file"), [u.filteredItems]), Le = h(async (t) => {
|
|
1336
|
+
Ae({
|
|
1337
|
+
item: t,
|
|
1338
|
+
status: "loading"
|
|
1339
|
+
});
|
|
1340
|
+
try {
|
|
1341
|
+
let n = await e.signedUrl(t.path);
|
|
1342
|
+
Ae((e) => e?.item.path === t.path ? {
|
|
1343
|
+
item: t,
|
|
1344
|
+
status: "ready",
|
|
1345
|
+
url: n
|
|
1346
|
+
} : e);
|
|
1347
|
+
} catch (e) {
|
|
1348
|
+
Ae((n) => n?.item.path === t.path ? {
|
|
1349
|
+
item: t,
|
|
1350
|
+
status: "error",
|
|
1351
|
+
error: Jt(e)
|
|
1352
|
+
} : n);
|
|
1353
|
+
}
|
|
1354
|
+
}, [e]), J = h(() => {
|
|
1355
|
+
Me.current &&= (clearTimeout(Me.current.timeoutId), null);
|
|
1356
|
+
}, []), Re = h((e) => {
|
|
1357
|
+
J(), Me.current = {
|
|
1358
|
+
path: e,
|
|
1359
|
+
timeoutId: setTimeout(() => {
|
|
1360
|
+
Me.current?.path === e && (Me.current = null, u.clearSelection());
|
|
1361
|
+
}, dt)
|
|
1362
|
+
};
|
|
1363
|
+
}, [u, J]), ze = h((e, t) => {
|
|
1364
|
+
let n = Date.now(), r = Ne.current, i = r?.path === e && n - r.timeMs <= dt;
|
|
1365
|
+
if ("detail" in t && t.detail > 1) {
|
|
1366
|
+
i && (J(), Pe.current = e), Ne.current = {
|
|
1367
|
+
path: e,
|
|
1368
|
+
timeMs: n
|
|
1369
|
+
};
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
Pe.current = null, Ne.current = {
|
|
1373
|
+
path: e,
|
|
1374
|
+
timeMs: n
|
|
1375
|
+
}, Bt(u, e, t, {
|
|
1376
|
+
cancelPendingSelectedItemUnselect: J,
|
|
1377
|
+
scheduleSelectedItemUnselect: Re
|
|
1378
|
+
});
|
|
1379
|
+
}, [
|
|
1380
|
+
u,
|
|
1381
|
+
J,
|
|
1382
|
+
Re
|
|
1383
|
+
]), Be = h((e) => {
|
|
1384
|
+
Pe.current === e.path && (Pe.current = null, J(), e.kind === "folder" ? u.navigate(e.path) : Le(e));
|
|
1385
|
+
}, [
|
|
1386
|
+
u,
|
|
1387
|
+
J,
|
|
1388
|
+
Le
|
|
1389
|
+
]);
|
|
1390
|
+
_(() => () => {
|
|
1391
|
+
J();
|
|
1392
|
+
}, [J]);
|
|
1393
|
+
let Ve = v(() => u.selectedItems.reduce((e, t) => e + (t.size ?? 0), 0), [u.selectedItems]), He = h((e, t) => {
|
|
1394
|
+
let n = u.filteredItems;
|
|
1395
|
+
if (n.length === 0) return;
|
|
1396
|
+
let r = u.focusedPath ?? u.selectedPaths.at(-1), i = n.findIndex((e) => e.path === r), a = e === "ArrowUp" || e === "ArrowLeft" || e === "End" ? n.length - 1 : 0, o = n[i === -1 ? a : Ut(e, i, n.length)];
|
|
1397
|
+
t ? u.selectRange(o.path) : u.selectOnly(o.path);
|
|
1398
|
+
}, [u]), Y = h((e = u.selectedPaths) => {
|
|
1399
|
+
e.length !== 0 && (u.copySelection(e), W(`Copied ${Zt(e.length)}`));
|
|
1400
|
+
}, [u]), Ue = h((e = u.selectedPaths) => {
|
|
1401
|
+
e.length !== 0 && (u.cutSelection(e), W(`Cut ${Zt(e.length)}`));
|
|
1402
|
+
}, [u]), Ke = h(async (e) => {
|
|
1403
|
+
e.length !== 0 && (await navigator.clipboard.writeText(e.join(", ")), W(e.length === 1 ? "Copied path" : `Copied ${e.length} paths`));
|
|
1404
|
+
}, []), qe = h(async (e) => {
|
|
1405
|
+
let t = u.clipboard?.paths.length ?? 0;
|
|
1406
|
+
await u.pasteInto(e), t > 0 && W(`Pasted ${Zt(t)}`);
|
|
1407
|
+
}, [u]);
|
|
1408
|
+
_(() => {
|
|
1409
|
+
let e = (e) => {
|
|
1410
|
+
if (e.key === "Escape" && (u.clearSelection(), M(null), N(""), P(null), O(null), A(null), C(null), F(!1), I(!1), L(null), H(null), Se(null), Ae(null)), !Yt(e.target)) {
|
|
1411
|
+
if (Ht(e.key)) {
|
|
1412
|
+
e.preventDefault(), He(e.key, e.shiftKey);
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
if (!a && e.key === "F2" && u.capabilities.rename && u.selectedItems.length === 1) {
|
|
1416
|
+
e.preventDefault();
|
|
1417
|
+
let t = u.selectedItems[0];
|
|
1418
|
+
O(null), A(null), M(t), N(t.name), P(null);
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (!a && (e.key === "Delete" || e.key === "Backspace") && u.selectedPaths.length > 0) {
|
|
1422
|
+
e.preventDefault(), F(!0);
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
if ((e.metaKey || e.ctrlKey) && !a) {
|
|
1426
|
+
let t = e.key.toLowerCase();
|
|
1427
|
+
if (t === "c" && u.capabilities.copy && u.selectedPaths.length > 0) {
|
|
1428
|
+
e.preventDefault(), Y();
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (t === "x" && u.capabilities.move && u.selectedPaths.length > 0) {
|
|
1432
|
+
e.preventDefault(), Ue();
|
|
1433
|
+
return;
|
|
1434
|
+
}
|
|
1435
|
+
if (t === "v" && u.clipboard) {
|
|
1436
|
+
e.preventDefault(), qe(u.currentPath);
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
if (e.key === "Enter" && u.selectedItems.length === 1) {
|
|
1441
|
+
let e = u.selectedItems[0];
|
|
1442
|
+
e.kind === "folder" ? u.navigate(e.path) : Le(e);
|
|
1443
|
+
}
|
|
1444
|
+
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" && (e.preventDefault(), u.selectAllLoaded());
|
|
1445
|
+
}
|
|
1446
|
+
};
|
|
1447
|
+
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
1448
|
+
}, [
|
|
1449
|
+
u,
|
|
1450
|
+
Y,
|
|
1451
|
+
Ue,
|
|
1452
|
+
He,
|
|
1453
|
+
Le,
|
|
1454
|
+
qe,
|
|
1455
|
+
a
|
|
1456
|
+
]), _(() => {
|
|
1457
|
+
u.focusedPath && (je.current?.querySelector(`[data-fb-path="${Wt(u.focusedPath)}"]`))?.focus();
|
|
1458
|
+
}, [
|
|
1459
|
+
u.focusedPath,
|
|
1460
|
+
u.filteredItems,
|
|
1461
|
+
u.view
|
|
1462
|
+
]), _(() => {
|
|
1463
|
+
if (!V) return;
|
|
1464
|
+
let e = () => H(null);
|
|
1465
|
+
return document.addEventListener("click", e), () => document.removeEventListener("click", e);
|
|
1466
|
+
}, [V]), _(() => {
|
|
1467
|
+
if (!De) return;
|
|
1468
|
+
let e = setTimeout(() => W(null), ft);
|
|
1469
|
+
return () => clearTimeout(e);
|
|
1470
|
+
}, [De]), _(() => {
|
|
1471
|
+
for (let e of f.uploads) e.status !== "completed" || !e.result || Fe.current.has(e.id) || (Fe.current.add(e.id), o(e.result.path) === u.currentPath && u.refresh());
|
|
1472
|
+
}, [u, f.uploads]), _(() => {
|
|
1473
|
+
if (!ae) return;
|
|
1474
|
+
let t = !1;
|
|
1475
|
+
return Promise.resolve().then(async () => t ? [] : (ge("loading"), ve(null), yt(e, u.selectedPaths))).then((e) => {
|
|
1476
|
+
if (t || e.length === 0) {
|
|
1477
|
+
!t && e.length === 0 && (B([]), ge("ready"));
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
B(e), ge("ready");
|
|
1481
|
+
}).catch((e) => {
|
|
1482
|
+
t || (B([]), ge("error"), ve(Jt(e)));
|
|
1483
|
+
}), () => {
|
|
1484
|
+
t = !0;
|
|
1485
|
+
};
|
|
1486
|
+
}, [
|
|
1487
|
+
e,
|
|
1488
|
+
u.selectedPaths,
|
|
1489
|
+
ae
|
|
1490
|
+
]);
|
|
1491
|
+
async function Je() {
|
|
1492
|
+
if (g.trim()) {
|
|
1493
|
+
C(null);
|
|
1494
|
+
try {
|
|
1495
|
+
await u.createFolder(g), x(""), m(!1);
|
|
1496
|
+
} catch (e) {
|
|
1497
|
+
C(Jt(e));
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
function Ye(e = u.selectedItems.at(0)) {
|
|
1502
|
+
e && (M(null), N(""), P(null), O(e), ee(e.name), A(null));
|
|
1503
|
+
}
|
|
1504
|
+
async function Xe() {
|
|
1505
|
+
let e = k.trim();
|
|
1506
|
+
if (!(!w || !e)) {
|
|
1507
|
+
A(null);
|
|
1508
|
+
try {
|
|
1509
|
+
await u.rename(w.path, e), O(null), ee("");
|
|
1510
|
+
} catch (e) {
|
|
1511
|
+
A(Jt(e));
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
async function Ze() {
|
|
1516
|
+
let e = j, t = ne.trim();
|
|
1517
|
+
if (P(null), !e || !t || t === e.name) {
|
|
1518
|
+
M(null), N("");
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
await u.rename(e.path, t), M(null), N("");
|
|
1523
|
+
} catch (n) {
|
|
1524
|
+
M(e), N(t), P(Jt(n));
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
function Qe() {
|
|
1528
|
+
M(null), N(""), P(null);
|
|
1529
|
+
}
|
|
1530
|
+
async function $e() {
|
|
1531
|
+
try {
|
|
1532
|
+
await u.deleteSelected(), F(!1);
|
|
1533
|
+
} catch (e) {
|
|
1534
|
+
if (e instanceof r) {
|
|
1535
|
+
F(!1), L(e);
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
throw e;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
function et() {
|
|
1542
|
+
u.selectedPaths.length !== 0 && (fe(u.currentPath), I(!0));
|
|
1543
|
+
}
|
|
1544
|
+
async function tt() {
|
|
1545
|
+
try {
|
|
1546
|
+
await u.moveSelectedTo(le), I(!1);
|
|
1547
|
+
} catch (e) {
|
|
1548
|
+
if (e instanceof r) {
|
|
1549
|
+
I(!1), L(e);
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
throw e;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function nt(e, t) {
|
|
1556
|
+
if (a || !u.capabilities.move) return;
|
|
1557
|
+
let n = u.selectedPaths.includes(e.path) ? u.selectedPaths : [e.path];
|
|
1558
|
+
u.setSelection(n), t.dataTransfer.effectAllowed = "move", t.dataTransfer.setData(ut, JSON.stringify(n));
|
|
1559
|
+
}
|
|
1560
|
+
function rt(e, t) {
|
|
1561
|
+
a || !u.capabilities.move || e.kind !== "folder" || Gt(t.dataTransfer).length !== 0 && (t.preventDefault(), t.stopPropagation(), t.dataTransfer.dropEffect = "move");
|
|
1562
|
+
}
|
|
1563
|
+
async function it(e, t) {
|
|
1564
|
+
if (a || !u.capabilities.move || e.kind !== "folder") return;
|
|
1565
|
+
let n = Gt(t.dataTransfer);
|
|
1566
|
+
if (n.length !== 0) {
|
|
1567
|
+
t.preventDefault(), t.stopPropagation();
|
|
1568
|
+
try {
|
|
1569
|
+
await u.movePathsTo(n, e.path);
|
|
1570
|
+
} catch (e) {
|
|
1571
|
+
if (e instanceof r) {
|
|
1572
|
+
L(e);
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
throw e;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
function at(e, t) {
|
|
1580
|
+
t.preventDefault(), t.stopPropagation(), u.selectedPaths.includes(e.path) || u.selectOnly(e.path), H({
|
|
1581
|
+
target: "item",
|
|
1582
|
+
item: e,
|
|
1583
|
+
x: t.clientX,
|
|
1584
|
+
y: t.clientY,
|
|
1585
|
+
mode: "context"
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
function ot(e) {
|
|
1589
|
+
u.selectedPaths.includes(e.path) || u.selectOnly(e.path), H({
|
|
1590
|
+
target: "item",
|
|
1591
|
+
item: e,
|
|
1592
|
+
x: 0,
|
|
1593
|
+
y: 0,
|
|
1594
|
+
mode: "sheet"
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
function st(e) {
|
|
1598
|
+
e.preventDefault(), u.clearSelection(), H({
|
|
1599
|
+
target: "empty",
|
|
1600
|
+
x: e.clientX,
|
|
1601
|
+
y: e.clientY,
|
|
1602
|
+
mode: "context"
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
function ct(e) {
|
|
1606
|
+
e.target !== e.currentTarget || Vt(e) || u.clearSelection();
|
|
1607
|
+
}
|
|
1608
|
+
function lt(e) {
|
|
1609
|
+
if (!G || q.length === 0) return;
|
|
1610
|
+
let t = q.findIndex((e) => e.path === G.item.path), n = ((t >= 0 ? t : 0) + e + q.length) % q.length, r = q[n];
|
|
1611
|
+
Le(r), u.selectOnly(r.path);
|
|
1612
|
+
}
|
|
1613
|
+
async function mt() {
|
|
1614
|
+
if (u.selectedItems.length === 1 && u.selectedItems[0].kind === "file") {
|
|
1615
|
+
await bt(u.selectedItems[0]);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
await St(u.selectedPaths.length > 0 ? u.selectedPaths : u.items.map((e) => e.path), Ve);
|
|
1619
|
+
}
|
|
1620
|
+
async function bt(t) {
|
|
1621
|
+
if (t.kind === "file") {
|
|
1622
|
+
await d.prepareSingleDownload({
|
|
1623
|
+
adapter: e,
|
|
1624
|
+
path: t.path,
|
|
1625
|
+
selectedBytes: t.size ?? 0
|
|
1626
|
+
});
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
await St([t.path], t.size ?? 0);
|
|
1630
|
+
}
|
|
1631
|
+
async function St(t, n) {
|
|
1632
|
+
await d.prepareBulkDownload({
|
|
1633
|
+
adapter: e,
|
|
1634
|
+
paths: t,
|
|
1635
|
+
selectedBytes: n,
|
|
1636
|
+
warnZipSizeBytes: l
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
async function wt(e) {
|
|
1640
|
+
!e || e.length === 0 || (await Tt(e), K.current && (K.current.value = ""));
|
|
1641
|
+
}
|
|
1642
|
+
async function Tt(e) {
|
|
1643
|
+
await jt(xe(e));
|
|
1644
|
+
}
|
|
1645
|
+
async function Q(e) {
|
|
1646
|
+
await jt(await be(e));
|
|
1647
|
+
}
|
|
1648
|
+
async function jt(e) {
|
|
1649
|
+
if (e.length === 0) return;
|
|
1650
|
+
let { acceptedCandidates: t, rejectedCandidates: n } = xt(e, c, u.currentPath);
|
|
1651
|
+
if (n.length > 0 && we(n), t.length === 0) return;
|
|
1652
|
+
let r = Pt(t);
|
|
1653
|
+
if (r.length === 0) return;
|
|
1654
|
+
let i = await qt(r), a = vt(u.currentPath, r, i);
|
|
1655
|
+
an(r, await Xt(r), 0, void 0, a);
|
|
1656
|
+
}
|
|
1657
|
+
function Pt(e) {
|
|
1658
|
+
if (u.capabilities.createFolder) return e;
|
|
1659
|
+
let [t, n] = _t(e, (e) => e.relativePath.includes("/"));
|
|
1660
|
+
return t.length > 0 && we((e) => [...e, ...t.map((e) => ({
|
|
1661
|
+
fileName: e.file.name,
|
|
1662
|
+
relativePath: e.relativePath,
|
|
1663
|
+
reasons: ["Folder uploads require folder creation support"]
|
|
1664
|
+
}))]), n;
|
|
1665
|
+
}
|
|
1666
|
+
async function qt(n) {
|
|
1667
|
+
let r = gt(n), i = 0;
|
|
1668
|
+
if (!e.createFolder) {
|
|
1669
|
+
if (r.length > 0) throw new t("not_supported", "Folder uploads require folder creation support");
|
|
1670
|
+
return 0;
|
|
1671
|
+
}
|
|
1672
|
+
for (let n of r) try {
|
|
1673
|
+
await e.createFolder(ht(u.currentPath, n)), i += 1;
|
|
1674
|
+
} catch (e) {
|
|
1675
|
+
if (e instanceof t && e.code === "conflict") continue;
|
|
1676
|
+
throw e;
|
|
1677
|
+
}
|
|
1678
|
+
return i > 0 && await u.refresh(), i;
|
|
1679
|
+
}
|
|
1680
|
+
async function Xt(t) {
|
|
1681
|
+
let n = t.map((e) => ht(u.currentPath, e.relativePath));
|
|
1682
|
+
if (e.exists) try {
|
|
1683
|
+
let t = await e.exists(n);
|
|
1684
|
+
return n.filter((e) => t[e]);
|
|
1685
|
+
} catch {}
|
|
1686
|
+
let r = new Set(u.items.map((e) => e.path)), i = [];
|
|
1687
|
+
for (let e of n) (r.has(e) || await rn(e)) && i.push(e);
|
|
1688
|
+
return i;
|
|
1689
|
+
}
|
|
1690
|
+
async function rn(t) {
|
|
1691
|
+
let n = o(t), r;
|
|
1692
|
+
do {
|
|
1693
|
+
let i = await e.list(n, { cursor: r });
|
|
1694
|
+
if (i.items.some((e) => e.path === t)) return !0;
|
|
1695
|
+
r = i.cursor;
|
|
1696
|
+
} while (r);
|
|
1697
|
+
return !1;
|
|
1698
|
+
}
|
|
1699
|
+
function an(e, t, n, r, i) {
|
|
1700
|
+
let a = new Set(t);
|
|
1701
|
+
for (let o = n; o < e.length; o += 1) {
|
|
1702
|
+
let n = e[o], s = ht(u.currentPath, n.relativePath);
|
|
1703
|
+
if (a.has(s)) {
|
|
1704
|
+
if (!r) {
|
|
1705
|
+
Se({
|
|
1706
|
+
candidates: e,
|
|
1707
|
+
conflictPaths: t,
|
|
1708
|
+
group: i,
|
|
1709
|
+
index: o
|
|
1710
|
+
}), Ee(!1);
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
r !== "skip" && sn(n, r, i);
|
|
1714
|
+
} else sn(n, void 0, i);
|
|
1715
|
+
}
|
|
1716
|
+
Se(null), Ee(!1);
|
|
1717
|
+
}
|
|
1718
|
+
function on(e) {
|
|
1719
|
+
if (!U) return;
|
|
1720
|
+
let { candidates: t, conflictPaths: n, group: r, index: i } = U;
|
|
1721
|
+
if (Te) {
|
|
1722
|
+
an(t, n, i, e, r);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
let a = t[i];
|
|
1726
|
+
e !== "skip" && sn(a, e, r), an(t, n, i + 1, void 0, r);
|
|
1727
|
+
}
|
|
1728
|
+
function sn(t, n, r) {
|
|
1729
|
+
d.enqueueUpload({
|
|
1730
|
+
adapter: e,
|
|
1731
|
+
destinationPath: ht(u.currentPath, t.relativePath),
|
|
1732
|
+
file: t.file,
|
|
1733
|
+
group: r,
|
|
1734
|
+
onConflict: n === "skip" ? void 0 : n
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
return /* @__PURE__ */ E("section", {
|
|
1738
|
+
className: `flex min-h-[520px] w-full overflow-hidden rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] font-[inherit] text-[length:var(--fb-font)] text-[var(--fb-text)] ${Z}`,
|
|
1739
|
+
"data-fb-density": i,
|
|
1740
|
+
ref: je,
|
|
1741
|
+
style: pt[i],
|
|
1742
|
+
onDragEnter: (e) => {
|
|
1743
|
+
e.preventDefault(), a || ke(!0);
|
|
1744
|
+
},
|
|
1745
|
+
onDragLeave: (e) => {
|
|
1746
|
+
e.currentTarget === e.target && ke(!1);
|
|
1747
|
+
},
|
|
1748
|
+
onDragOver: (e) => {
|
|
1749
|
+
e.preventDefault();
|
|
1750
|
+
},
|
|
1751
|
+
onDrop: (e) => {
|
|
1752
|
+
e.preventDefault(), ke(!1), !a && Q(e.dataTransfer);
|
|
1753
|
+
},
|
|
1754
|
+
onPaste: (e) => {
|
|
1755
|
+
if (a) return;
|
|
1756
|
+
let t = Array.from(e.clipboardData.files).filter((e) => e.type.startsWith("image/"));
|
|
1757
|
+
t.length > 0 && Tt(t);
|
|
1758
|
+
},
|
|
1759
|
+
children: [
|
|
1760
|
+
/* @__PURE__ */ T("div", {
|
|
1761
|
+
"aria-atomic": "true",
|
|
1762
|
+
"aria-live": "polite",
|
|
1763
|
+
className: "sr-only",
|
|
1764
|
+
role: "status",
|
|
1765
|
+
children: Qt({
|
|
1766
|
+
currentPath: u.currentPath,
|
|
1767
|
+
itemCount: u.filteredItems.length,
|
|
1768
|
+
selectedCount: u.selectedPaths.length,
|
|
1769
|
+
status: u.status
|
|
1770
|
+
})
|
|
1771
|
+
}),
|
|
1772
|
+
/* @__PURE__ */ E("div", {
|
|
1773
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
1774
|
+
children: [
|
|
1775
|
+
/* @__PURE__ */ E("header", {
|
|
1776
|
+
className: `flex flex-wrap items-center gap-2 border-b border-[var(--fb-border)] bg-[var(--fb-surface)] px-[var(--fb-pad)] py-[var(--fb-cell-y)] ${Z}`,
|
|
1777
|
+
children: [
|
|
1778
|
+
/* @__PURE__ */ T(Nt, {
|
|
1779
|
+
path: u.currentPath,
|
|
1780
|
+
onNavigate: u.navigate
|
|
1781
|
+
}),
|
|
1782
|
+
De ? /* @__PURE__ */ T("span", {
|
|
1783
|
+
"aria-label": "Clipboard status",
|
|
1784
|
+
className: `rounded-[calc(var(--fb-radius)-4px)] bg-[var(--fb-accent-soft)] px-2 py-1 text-[12px] font-medium text-[var(--fb-accent)] ${X}`,
|
|
1785
|
+
role: "status",
|
|
1786
|
+
children: De
|
|
1787
|
+
}) : null,
|
|
1788
|
+
/* @__PURE__ */ E("div", {
|
|
1789
|
+
className: "ml-auto flex min-w-0 items-center gap-1.5",
|
|
1790
|
+
children: [
|
|
1791
|
+
/* @__PURE__ */ E("label", {
|
|
1792
|
+
className: "relative block min-w-[140px] max-w-[220px]",
|
|
1793
|
+
children: [/* @__PURE__ */ T(he, {
|
|
1794
|
+
"aria-hidden": "true",
|
|
1795
|
+
className: "pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-[var(--fb-muted)]"
|
|
1796
|
+
}), /* @__PURE__ */ T("input", {
|
|
1797
|
+
"aria-label": "Search files",
|
|
1798
|
+
className: `h-[var(--fb-control-h)] w-full rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] pl-7 pr-2 text-[12px] text-[var(--fb-text)] outline-none focus:border-[var(--fb-accent)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`,
|
|
1799
|
+
onChange: (e) => u.setSearchQuery(e.target.value),
|
|
1800
|
+
placeholder: "Search",
|
|
1801
|
+
type: "search",
|
|
1802
|
+
value: u.searchQuery
|
|
1803
|
+
})]
|
|
1804
|
+
}),
|
|
1805
|
+
/* @__PURE__ */ E("select", {
|
|
1806
|
+
"aria-label": "Filter files",
|
|
1807
|
+
className: nn(),
|
|
1808
|
+
onChange: (e) => u.setFilterKind(e.target.value),
|
|
1809
|
+
value: u.filterKind,
|
|
1810
|
+
children: [
|
|
1811
|
+
/* @__PURE__ */ T("option", {
|
|
1812
|
+
value: "all",
|
|
1813
|
+
children: "All"
|
|
1814
|
+
}),
|
|
1815
|
+
/* @__PURE__ */ T("option", {
|
|
1816
|
+
value: "folders",
|
|
1817
|
+
children: "Folders"
|
|
1818
|
+
}),
|
|
1819
|
+
/* @__PURE__ */ T("option", {
|
|
1820
|
+
value: "files",
|
|
1821
|
+
children: "Files"
|
|
1822
|
+
})
|
|
1823
|
+
]
|
|
1824
|
+
}),
|
|
1825
|
+
/* @__PURE__ */ E("select", {
|
|
1826
|
+
"aria-label": "Sort files",
|
|
1827
|
+
className: nn(),
|
|
1828
|
+
onChange: (e) => u.setSortBy(e.target.value),
|
|
1829
|
+
value: u.sortBy,
|
|
1830
|
+
children: [
|
|
1831
|
+
/* @__PURE__ */ T("option", {
|
|
1832
|
+
value: "name",
|
|
1833
|
+
children: "Name"
|
|
1834
|
+
}),
|
|
1835
|
+
/* @__PURE__ */ T("option", {
|
|
1836
|
+
value: "modifiedAt",
|
|
1837
|
+
children: "Modified"
|
|
1838
|
+
}),
|
|
1839
|
+
/* @__PURE__ */ T("option", {
|
|
1840
|
+
value: "size",
|
|
1841
|
+
children: "Size"
|
|
1842
|
+
})
|
|
1843
|
+
]
|
|
1844
|
+
}),
|
|
1845
|
+
/* @__PURE__ */ T("button", {
|
|
1846
|
+
"aria-label": "Toggle sort direction",
|
|
1847
|
+
className: $t(!1),
|
|
1848
|
+
onClick: () => u.setSortDirection((e) => e === "asc" ? "desc" : "asc"),
|
|
1849
|
+
type: "button",
|
|
1850
|
+
children: u.sortDirection === "asc" ? "Asc" : "Desc"
|
|
1851
|
+
}),
|
|
1852
|
+
/* @__PURE__ */ T("button", {
|
|
1853
|
+
"aria-label": "Grid view",
|
|
1854
|
+
className: $t(u.view === "grid"),
|
|
1855
|
+
onClick: () => u.setView("grid"),
|
|
1856
|
+
type: "button",
|
|
1857
|
+
children: /* @__PURE__ */ T(ue, {
|
|
1858
|
+
"aria-hidden": "true",
|
|
1859
|
+
className: "size-4"
|
|
1860
|
+
})
|
|
1861
|
+
}),
|
|
1862
|
+
/* @__PURE__ */ T("button", {
|
|
1863
|
+
"aria-label": "List view",
|
|
1864
|
+
className: $t(u.view === "list"),
|
|
1865
|
+
onClick: () => u.setView("list"),
|
|
1866
|
+
type: "button",
|
|
1867
|
+
children: /* @__PURE__ */ T(de, {
|
|
1868
|
+
"aria-hidden": "true",
|
|
1869
|
+
className: "size-4"
|
|
1870
|
+
})
|
|
1871
|
+
}),
|
|
1872
|
+
!a && u.capabilities.createFolder ? /* @__PURE__ */ E("button", {
|
|
1873
|
+
className: $(!1),
|
|
1874
|
+
onClick: () => {
|
|
1875
|
+
C(null), m(!0);
|
|
1876
|
+
},
|
|
1877
|
+
type: "button",
|
|
1878
|
+
children: [/* @__PURE__ */ T(z, {
|
|
1879
|
+
"aria-hidden": "true",
|
|
1880
|
+
className: "size-4"
|
|
1881
|
+
}), "New folder"]
|
|
1882
|
+
}) : null,
|
|
1883
|
+
/* @__PURE__ */ T("input", {
|
|
1884
|
+
"aria-label": "Upload files",
|
|
1885
|
+
multiple: !0,
|
|
1886
|
+
onChange: (e) => void wt(e.target.files),
|
|
1887
|
+
ref: K,
|
|
1888
|
+
type: "file",
|
|
1889
|
+
className: "hidden"
|
|
1890
|
+
}),
|
|
1891
|
+
a ? null : /* @__PURE__ */ E("button", {
|
|
1892
|
+
className: en(),
|
|
1893
|
+
onClick: () => K.current?.click(),
|
|
1894
|
+
type: "button",
|
|
1895
|
+
children: [/* @__PURE__ */ T(ye, {
|
|
1896
|
+
"aria-hidden": "true",
|
|
1897
|
+
className: "size-4"
|
|
1898
|
+
}), "Upload"]
|
|
1899
|
+
})
|
|
1900
|
+
]
|
|
1901
|
+
})
|
|
1902
|
+
]
|
|
1903
|
+
}),
|
|
1904
|
+
/* @__PURE__ */ T(Mt, {
|
|
1905
|
+
canCopy: !a && u.capabilities.copy,
|
|
1906
|
+
canCut: !a && u.capabilities.move,
|
|
1907
|
+
canDelete: !a,
|
|
1908
|
+
canMove: !a && u.capabilities.move,
|
|
1909
|
+
canRename: !a && u.capabilities.rename,
|
|
1910
|
+
itemCount: u.filteredItems.length,
|
|
1911
|
+
onCopy: () => Y(),
|
|
1912
|
+
onCut: () => Ue(),
|
|
1913
|
+
onDelete: () => F(!0),
|
|
1914
|
+
onDownload: () => void mt(),
|
|
1915
|
+
onMove: et,
|
|
1916
|
+
onRename: Ye,
|
|
1917
|
+
onSelectAll: u.selectAllLoaded,
|
|
1918
|
+
onSelectNone: u.clearSelection,
|
|
1919
|
+
selectedCount: u.selectedPaths.length
|
|
1920
|
+
}),
|
|
1921
|
+
Ce.length > 0 ? /* @__PURE__ */ T(zt, {
|
|
1922
|
+
onDismiss: () => we([]),
|
|
1923
|
+
rejections: Ce
|
|
1924
|
+
}) : null,
|
|
1925
|
+
/* @__PURE__ */ E("div", {
|
|
1926
|
+
className: `relative min-h-0 flex-1 overflow-auto bg-[var(--fb-bg)] p-[var(--fb-pad)] ${Z}`,
|
|
1927
|
+
onClick: ct,
|
|
1928
|
+
onContextMenu: st,
|
|
1929
|
+
children: [u.status === "loading" && u.items.length === 0 ? /* @__PURE__ */ T(Lt, {}) : u.status === "error" ? /* @__PURE__ */ T(Rt, {
|
|
1930
|
+
title: Kt(u.error).title,
|
|
1931
|
+
tone: "danger",
|
|
1932
|
+
value: Kt(u.error).value
|
|
1933
|
+
}) : u.filteredItems.length === 0 ? /* @__PURE__ */ T(Rt, {
|
|
1934
|
+
title: "This folder is empty",
|
|
1935
|
+
value: "Create a folder or upload files to start."
|
|
1936
|
+
}) : u.view === "grid" ? /* @__PURE__ */ T(Ct, {
|
|
1937
|
+
browser: u,
|
|
1938
|
+
canMove: !a && u.capabilities.move,
|
|
1939
|
+
inlineRenameError: re,
|
|
1940
|
+
inlineRenameLabel: j?.name ?? "",
|
|
1941
|
+
inlineRenameItem: j,
|
|
1942
|
+
inlineRenameValue: ne,
|
|
1943
|
+
onDragStart: nt,
|
|
1944
|
+
onFolderDragOver: rt,
|
|
1945
|
+
onFolderDrop: (e, t) => void it(e, t),
|
|
1946
|
+
onEmptyClick: () => u.clearSelection(),
|
|
1947
|
+
onInlineRenameCancel: Qe,
|
|
1948
|
+
onInlineRenameChange: (e) => {
|
|
1949
|
+
N(e), P(null);
|
|
1950
|
+
},
|
|
1951
|
+
onInlineRenameCommit: () => void Ze(),
|
|
1952
|
+
onContextMenu: at,
|
|
1953
|
+
onOpenItem: Be,
|
|
1954
|
+
onSelectItem: ze,
|
|
1955
|
+
onTouchMenu: ot,
|
|
1956
|
+
selectedPaths: u.selectedPaths
|
|
1957
|
+
}) : /* @__PURE__ */ T(Et, {
|
|
1958
|
+
browser: u,
|
|
1959
|
+
canMove: !a && u.capabilities.move,
|
|
1960
|
+
inlineRenameError: re,
|
|
1961
|
+
inlineRenameLabel: j?.name ?? "",
|
|
1962
|
+
inlineRenameItem: j,
|
|
1963
|
+
inlineRenameValue: ne,
|
|
1964
|
+
onDragStart: nt,
|
|
1965
|
+
onFolderDragOver: rt,
|
|
1966
|
+
onFolderDrop: (e, t) => void it(e, t),
|
|
1967
|
+
onInlineRenameCancel: Qe,
|
|
1968
|
+
onInlineRenameChange: (e) => {
|
|
1969
|
+
N(e), P(null);
|
|
1970
|
+
},
|
|
1971
|
+
onInlineRenameCommit: () => void Ze(),
|
|
1972
|
+
onContextMenu: at,
|
|
1973
|
+
onOpenItem: Be,
|
|
1974
|
+
onSelectItem: ze,
|
|
1975
|
+
selectedPaths: u.selectedPaths
|
|
1976
|
+
}), Oe ? /* @__PURE__ */ T("div", {
|
|
1977
|
+
className: `pointer-events-none absolute inset-3 z-10 grid place-items-center rounded-[var(--fb-radius)] border-2 border-dashed border-[var(--fb-accent)] bg-[var(--fb-accent-soft)] text-[13px] font-semibold text-[var(--fb-accent)] ${Z}`,
|
|
1978
|
+
children: "Drop files to upload"
|
|
1979
|
+
}) : null]
|
|
1980
|
+
}),
|
|
1981
|
+
/* @__PURE__ */ E("footer", {
|
|
1982
|
+
className: `flex h-9 items-center justify-between border-t border-[var(--fb-border)] px-[var(--fb-pad)] text-[11px] text-[var(--fb-muted)] ${Z}`,
|
|
1983
|
+
children: [/* @__PURE__ */ E("span", { children: [
|
|
1984
|
+
u.filteredItems.length,
|
|
1985
|
+
" items",
|
|
1986
|
+
u.selectedPaths.length ? ` · ${u.selectedPaths.length} selected` : ""
|
|
1987
|
+
] }), u.hasMore ? /* @__PURE__ */ T("button", {
|
|
1988
|
+
className: `rounded-[calc(var(--fb-radius)-4px)] px-2 py-1 font-medium text-[var(--fb-accent)] hover:bg-[var(--fb-accent-soft)] ${X}`,
|
|
1989
|
+
onClick: () => void u.loadMore(),
|
|
1990
|
+
type: "button",
|
|
1991
|
+
children: "Load more"
|
|
1992
|
+
}) : /* @__PURE__ */ T("span", {})]
|
|
1993
|
+
})
|
|
1994
|
+
]
|
|
1995
|
+
}),
|
|
1996
|
+
s ? /* @__PURE__ */ T(Ft, {
|
|
1997
|
+
item: Ie,
|
|
1998
|
+
onCopyPath: () => void Ke(u.selectedPaths),
|
|
1999
|
+
onDownload: () => void mt(),
|
|
2000
|
+
selectedCount: u.selectedItems.length,
|
|
2001
|
+
totalBytes: Ve
|
|
2002
|
+
}) : null,
|
|
2003
|
+
V ? /* @__PURE__ */ T(Dt, {
|
|
2004
|
+
browser: u,
|
|
2005
|
+
menu: V,
|
|
2006
|
+
onClose: () => H(null),
|
|
2007
|
+
onDelete: () => F(!0),
|
|
2008
|
+
onDownload: () => void mt(),
|
|
2009
|
+
onMove: et,
|
|
2010
|
+
onNewFolder: () => {
|
|
2011
|
+
C(null), m(!0);
|
|
2012
|
+
},
|
|
2013
|
+
onCopy: () => Y(),
|
|
2014
|
+
onCopyPath: (e) => void Ke(u.selectedPaths.includes(e.path) ? u.selectedPaths : [e.path]),
|
|
2015
|
+
onCut: () => Ue(),
|
|
2016
|
+
onPaste: () => void qe(u.currentPath),
|
|
2017
|
+
onRename: Ye,
|
|
2018
|
+
onUpload: () => K.current?.click(),
|
|
2019
|
+
readOnly: a
|
|
2020
|
+
}) : null,
|
|
2021
|
+
p ? /* @__PURE__ */ T("div", {
|
|
2022
|
+
"aria-label": "New folder",
|
|
2023
|
+
"aria-modal": "true",
|
|
2024
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2025
|
+
role: "dialog",
|
|
2026
|
+
children: /* @__PURE__ */ E("form", {
|
|
2027
|
+
className: `w-[min(360px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2028
|
+
onSubmit: (e) => {
|
|
2029
|
+
e.preventDefault(), Je();
|
|
2030
|
+
},
|
|
2031
|
+
children: [
|
|
2032
|
+
/* @__PURE__ */ T("h2", {
|
|
2033
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2034
|
+
children: "New folder"
|
|
2035
|
+
}),
|
|
2036
|
+
/* @__PURE__ */ E("label", {
|
|
2037
|
+
className: "mt-3 block text-[12px] font-medium text-[var(--fb-muted)]",
|
|
2038
|
+
children: ["Folder name", /* @__PURE__ */ T("input", {
|
|
2039
|
+
"aria-label": "Folder name",
|
|
2040
|
+
autoFocus: !0,
|
|
2041
|
+
className: `mt-1 h-9 w-full rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] px-2 text-[13px] text-[var(--fb-text)] outline-none focus:border-[var(--fb-accent)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`,
|
|
2042
|
+
onChange: (e) => {
|
|
2043
|
+
x(e.target.value), C(null);
|
|
2044
|
+
},
|
|
2045
|
+
value: g
|
|
2046
|
+
})]
|
|
2047
|
+
}),
|
|
2048
|
+
S ? /* @__PURE__ */ T("div", {
|
|
2049
|
+
className: `mt-3 rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-danger)] bg-[var(--fb-danger-soft)] px-2 py-1.5 text-[12px] text-[var(--fb-danger)] ${Z}`,
|
|
2050
|
+
role: "alert",
|
|
2051
|
+
children: S
|
|
2052
|
+
}) : null,
|
|
2053
|
+
/* @__PURE__ */ E("div", {
|
|
2054
|
+
className: "mt-4 flex justify-end gap-2",
|
|
2055
|
+
children: [/* @__PURE__ */ T("button", {
|
|
2056
|
+
className: $(!1),
|
|
2057
|
+
onClick: () => {
|
|
2058
|
+
C(null), m(!1);
|
|
2059
|
+
},
|
|
2060
|
+
type: "button",
|
|
2061
|
+
children: "Cancel"
|
|
2062
|
+
}), /* @__PURE__ */ T("button", {
|
|
2063
|
+
className: en(),
|
|
2064
|
+
type: "submit",
|
|
2065
|
+
children: "Create folder"
|
|
2066
|
+
})]
|
|
2067
|
+
})
|
|
2068
|
+
]
|
|
2069
|
+
})
|
|
2070
|
+
}) : null,
|
|
2071
|
+
w ? /* @__PURE__ */ T("div", {
|
|
2072
|
+
"aria-label": "Rename item",
|
|
2073
|
+
"aria-modal": "true",
|
|
2074
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2075
|
+
role: "dialog",
|
|
2076
|
+
children: /* @__PURE__ */ E("form", {
|
|
2077
|
+
className: `w-[min(360px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2078
|
+
onSubmit: (e) => {
|
|
2079
|
+
e.preventDefault(), Xe();
|
|
2080
|
+
},
|
|
2081
|
+
children: [
|
|
2082
|
+
/* @__PURE__ */ T("h2", {
|
|
2083
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2084
|
+
children: "Rename"
|
|
2085
|
+
}),
|
|
2086
|
+
/* @__PURE__ */ E("label", {
|
|
2087
|
+
className: "mt-3 block text-[12px] font-medium text-[var(--fb-muted)]",
|
|
2088
|
+
children: ["New name", /* @__PURE__ */ T("input", {
|
|
2089
|
+
"aria-label": "New name",
|
|
2090
|
+
autoFocus: !0,
|
|
2091
|
+
className: `mt-1 h-9 w-full rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] px-2 text-[13px] text-[var(--fb-text)] outline-none focus:border-[var(--fb-accent)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`,
|
|
2092
|
+
onChange: (e) => {
|
|
2093
|
+
ee(e.target.value), A(null);
|
|
2094
|
+
},
|
|
2095
|
+
value: k
|
|
2096
|
+
})]
|
|
2097
|
+
}),
|
|
2098
|
+
te ? /* @__PURE__ */ T("div", {
|
|
2099
|
+
className: `mt-3 rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-danger)] bg-[var(--fb-danger-soft)] px-2 py-1.5 text-[12px] text-[var(--fb-danger)] ${Z}`,
|
|
2100
|
+
role: "alert",
|
|
2101
|
+
children: te
|
|
2102
|
+
}) : null,
|
|
2103
|
+
/* @__PURE__ */ E("div", {
|
|
2104
|
+
className: "mt-4 flex justify-end gap-2",
|
|
2105
|
+
children: [/* @__PURE__ */ T("button", {
|
|
2106
|
+
className: $(!1),
|
|
2107
|
+
onClick: () => {
|
|
2108
|
+
O(null), ee(""), A(null);
|
|
2109
|
+
},
|
|
2110
|
+
type: "button",
|
|
2111
|
+
children: "Cancel"
|
|
2112
|
+
}), /* @__PURE__ */ T("button", {
|
|
2113
|
+
className: en(),
|
|
2114
|
+
type: "submit",
|
|
2115
|
+
children: "Rename item"
|
|
2116
|
+
})]
|
|
2117
|
+
})
|
|
2118
|
+
]
|
|
2119
|
+
})
|
|
2120
|
+
}) : null,
|
|
2121
|
+
ie ? /* @__PURE__ */ T("div", {
|
|
2122
|
+
"aria-label": "Delete selected items",
|
|
2123
|
+
"aria-modal": "true",
|
|
2124
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2125
|
+
role: "dialog",
|
|
2126
|
+
children: /* @__PURE__ */ E("form", {
|
|
2127
|
+
className: `w-[min(400px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2128
|
+
onSubmit: (e) => {
|
|
2129
|
+
e.preventDefault(), $e();
|
|
2130
|
+
},
|
|
2131
|
+
children: [
|
|
2132
|
+
/* @__PURE__ */ T("h2", {
|
|
2133
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2134
|
+
children: "Delete selected items"
|
|
2135
|
+
}),
|
|
2136
|
+
/* @__PURE__ */ T("p", {
|
|
2137
|
+
className: "mt-2 text-[12px] text-[var(--fb-muted)]",
|
|
2138
|
+
children: "This removes the selected entries from storage."
|
|
2139
|
+
}),
|
|
2140
|
+
/* @__PURE__ */ T("ul", {
|
|
2141
|
+
className: `mt-3 max-h-32 overflow-auto rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-bg)] p-2 text-[12px] ${Z}`,
|
|
2142
|
+
children: u.selectedItems.map((e) => /* @__PURE__ */ T("li", {
|
|
2143
|
+
className: "truncate py-1",
|
|
2144
|
+
children: e.name
|
|
2145
|
+
}, e.path))
|
|
2146
|
+
}),
|
|
2147
|
+
/* @__PURE__ */ E("div", {
|
|
2148
|
+
className: "mt-4 flex justify-end gap-2",
|
|
2149
|
+
children: [/* @__PURE__ */ T("button", {
|
|
2150
|
+
className: $(!1),
|
|
2151
|
+
onClick: () => F(!1),
|
|
2152
|
+
type: "button",
|
|
2153
|
+
children: "Cancel"
|
|
2154
|
+
}), /* @__PURE__ */ T("button", {
|
|
2155
|
+
className: tn(),
|
|
2156
|
+
type: "submit",
|
|
2157
|
+
children: "Delete selected"
|
|
2158
|
+
})]
|
|
2159
|
+
})
|
|
2160
|
+
]
|
|
2161
|
+
})
|
|
2162
|
+
}) : null,
|
|
2163
|
+
ae ? /* @__PURE__ */ T("div", {
|
|
2164
|
+
"aria-label": "Move selected items",
|
|
2165
|
+
"aria-modal": "true",
|
|
2166
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2167
|
+
role: "dialog",
|
|
2168
|
+
children: /* @__PURE__ */ E("form", {
|
|
2169
|
+
className: `w-[min(420px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2170
|
+
onSubmit: (e) => {
|
|
2171
|
+
e.preventDefault(), tt();
|
|
2172
|
+
},
|
|
2173
|
+
children: [
|
|
2174
|
+
/* @__PURE__ */ T("h2", {
|
|
2175
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2176
|
+
children: "Move selected items"
|
|
2177
|
+
}),
|
|
2178
|
+
/* @__PURE__ */ T("p", {
|
|
2179
|
+
className: "mt-2 text-[12px] text-[var(--fb-muted)]",
|
|
2180
|
+
children: "Choose a destination folder from the folder tree."
|
|
2181
|
+
}),
|
|
2182
|
+
/* @__PURE__ */ T(At, {
|
|
2183
|
+
currentPath: u.currentPath,
|
|
2184
|
+
destinations: pe,
|
|
2185
|
+
error: _e,
|
|
2186
|
+
onSelect: fe,
|
|
2187
|
+
selectedPath: le,
|
|
2188
|
+
status: me
|
|
2189
|
+
}),
|
|
2190
|
+
/* @__PURE__ */ E("div", {
|
|
2191
|
+
className: "mt-3 truncate text-[11px] text-[var(--fb-muted)]",
|
|
2192
|
+
children: ["Destination: ", le]
|
|
2193
|
+
}),
|
|
2194
|
+
/* @__PURE__ */ E("div", {
|
|
2195
|
+
className: "mt-4 flex justify-end gap-2",
|
|
2196
|
+
children: [/* @__PURE__ */ T("button", {
|
|
2197
|
+
className: $(!1),
|
|
2198
|
+
onClick: () => I(!1),
|
|
2199
|
+
type: "button",
|
|
2200
|
+
children: "Cancel"
|
|
2201
|
+
}), /* @__PURE__ */ T("button", {
|
|
2202
|
+
className: en(),
|
|
2203
|
+
type: "submit",
|
|
2204
|
+
children: "Move here"
|
|
2205
|
+
})]
|
|
2206
|
+
})
|
|
2207
|
+
]
|
|
2208
|
+
})
|
|
2209
|
+
}) : null,
|
|
2210
|
+
ce ? /* @__PURE__ */ T(kt, {
|
|
2211
|
+
error: ce,
|
|
2212
|
+
onClose: () => L(null)
|
|
2213
|
+
}) : null,
|
|
2214
|
+
U ? /* @__PURE__ */ T(Ot, {
|
|
2215
|
+
applyToAll: Te,
|
|
2216
|
+
currentPath: u.currentPath,
|
|
2217
|
+
onApplyToAllChange: Ee,
|
|
2218
|
+
onCancel: () => {
|
|
2219
|
+
Se(null), Ee(!1);
|
|
2220
|
+
},
|
|
2221
|
+
onResolve: (e) => on(e),
|
|
2222
|
+
queue: U
|
|
2223
|
+
}) : null,
|
|
2224
|
+
G ? /* @__PURE__ */ T("div", {
|
|
2225
|
+
"aria-label": `Preview ${G.item.name}`,
|
|
2226
|
+
"aria-modal": "true",
|
|
2227
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_35%,transparent)] p-4 ${Z}`,
|
|
2228
|
+
role: "dialog",
|
|
2229
|
+
children: /* @__PURE__ */ E("div", {
|
|
2230
|
+
className: `w-[min(720px,100%)] overflow-hidden rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] shadow-[0_22px_70px_color-mix(in_oklch,var(--fb-text)_24%,transparent)] ${Z}`,
|
|
2231
|
+
children: [/* @__PURE__ */ E("div", {
|
|
2232
|
+
className: `flex h-12 items-center justify-between border-b border-[var(--fb-border)] px-4 ${Z}`,
|
|
2233
|
+
children: [/* @__PURE__ */ E("div", {
|
|
2234
|
+
className: "min-w-0 truncate font-semibold",
|
|
2235
|
+
children: ["Preview ", G.item.name]
|
|
2236
|
+
}), /* @__PURE__ */ E("div", {
|
|
2237
|
+
className: "flex items-center gap-1",
|
|
2238
|
+
children: [
|
|
2239
|
+
/* @__PURE__ */ T("button", {
|
|
2240
|
+
"aria-label": "Previous file",
|
|
2241
|
+
className: $t(!1),
|
|
2242
|
+
disabled: q.length <= 1,
|
|
2243
|
+
onClick: () => lt(-1),
|
|
2244
|
+
type: "button",
|
|
2245
|
+
children: /* @__PURE__ */ T(oe, {
|
|
2246
|
+
"aria-hidden": "true",
|
|
2247
|
+
className: "size-4"
|
|
2248
|
+
})
|
|
2249
|
+
}),
|
|
2250
|
+
/* @__PURE__ */ T("button", {
|
|
2251
|
+
"aria-label": "Next file",
|
|
2252
|
+
className: $t(!1),
|
|
2253
|
+
disabled: q.length <= 1,
|
|
2254
|
+
onClick: () => lt(1),
|
|
2255
|
+
type: "button",
|
|
2256
|
+
children: /* @__PURE__ */ T(se, {
|
|
2257
|
+
"aria-hidden": "true",
|
|
2258
|
+
className: "size-4"
|
|
2259
|
+
})
|
|
2260
|
+
}),
|
|
2261
|
+
/* @__PURE__ */ T("button", {
|
|
2262
|
+
className: $t(!1),
|
|
2263
|
+
onClick: () => Ae(null),
|
|
2264
|
+
type: "button",
|
|
2265
|
+
children: "Close"
|
|
2266
|
+
})
|
|
2267
|
+
]
|
|
2268
|
+
})]
|
|
2269
|
+
}), /* @__PURE__ */ T("div", {
|
|
2270
|
+
className: `grid min-h-[260px] place-items-center bg-[var(--fb-bg)] p-8 ${Z}`,
|
|
2271
|
+
children: G.item.mimeType?.startsWith("image/") && G.url || G.item.thumbnailUrl ? /* @__PURE__ */ E("div", {
|
|
2272
|
+
className: "text-center",
|
|
2273
|
+
children: [/* @__PURE__ */ T("img", {
|
|
2274
|
+
alt: G.item.name,
|
|
2275
|
+
className: `max-h-[420px] max-w-full rounded-[calc(var(--fb-radius)-2px)] object-contain ${Z}`,
|
|
2276
|
+
src: G.url ?? G.item.thumbnailUrl
|
|
2277
|
+
}), /* @__PURE__ */ T(It, { preview: G })]
|
|
2278
|
+
}) : /* @__PURE__ */ E("div", {
|
|
2279
|
+
className: "text-center",
|
|
2280
|
+
children: [
|
|
2281
|
+
/* @__PURE__ */ T(R, { className: "mx-auto size-12 text-[var(--fb-muted)]" }),
|
|
2282
|
+
/* @__PURE__ */ T("div", {
|
|
2283
|
+
className: "mt-3 font-semibold",
|
|
2284
|
+
children: G.item.name
|
|
2285
|
+
}),
|
|
2286
|
+
/* @__PURE__ */ T("div", {
|
|
2287
|
+
className: "mt-1 text-[12px] text-[var(--fb-muted)]",
|
|
2288
|
+
children: G.item.mimeType ?? "File"
|
|
2289
|
+
}),
|
|
2290
|
+
G.status === "loading" ? /* @__PURE__ */ T("div", {
|
|
2291
|
+
className: "mt-3 text-[12px] text-[var(--fb-muted)]",
|
|
2292
|
+
children: "Loading preview"
|
|
2293
|
+
}) : null,
|
|
2294
|
+
G.status === "error" ? /* @__PURE__ */ T("div", {
|
|
2295
|
+
className: "mt-3 text-[12px] text-[var(--fb-danger)]",
|
|
2296
|
+
children: G.error ?? "Could not load preview"
|
|
2297
|
+
}) : null,
|
|
2298
|
+
/* @__PURE__ */ T(It, { preview: G })
|
|
2299
|
+
]
|
|
2300
|
+
})
|
|
2301
|
+
})]
|
|
2302
|
+
})
|
|
2303
|
+
}) : null
|
|
2304
|
+
]
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
function ht(t, n) {
|
|
2308
|
+
return n.split("/").filter(Boolean).reduce((t, n) => e(t, n), t);
|
|
2309
|
+
}
|
|
2310
|
+
function gt(e) {
|
|
2311
|
+
let t = /* @__PURE__ */ new Set();
|
|
2312
|
+
for (let { relativePath: n } of e) {
|
|
2313
|
+
let e = n.split("/").filter(Boolean);
|
|
2314
|
+
for (let n = 1; n < e.length; n += 1) t.add(e.slice(0, n).join("/"));
|
|
2315
|
+
}
|
|
2316
|
+
return Array.from(t).sort((e, t) => e.split("/").length - t.split("/").length || e.localeCompare(t));
|
|
2317
|
+
}
|
|
2318
|
+
function _t(e, t) {
|
|
2319
|
+
let n = [], r = [];
|
|
2320
|
+
for (let i of e) t(i) ? n.push(i) : r.push(i);
|
|
2321
|
+
return [n, r];
|
|
2322
|
+
}
|
|
2323
|
+
function vt(e, t, n = 0) {
|
|
2324
|
+
if (gt(t).length === 0) return;
|
|
2325
|
+
let r = t.map((e) => e.relativePath.split("/").filter(Boolean)[0]).filter((e) => !!e), i = Array.from(new Set(r)), o = i.length === 1 ? i[0] : "Folder upload";
|
|
2326
|
+
return {
|
|
2327
|
+
id: i.length === 1 ? ht(e, o) : `${a(e)}#folder-upload`,
|
|
2328
|
+
name: o,
|
|
2329
|
+
totalFiles: t.length,
|
|
2330
|
+
createdFolders: n
|
|
2331
|
+
};
|
|
2332
|
+
}
|
|
2333
|
+
async function yt(e, t) {
|
|
2334
|
+
let n = [], r = t.map(a);
|
|
2335
|
+
async function i(t, a) {
|
|
2336
|
+
let o;
|
|
2337
|
+
do {
|
|
2338
|
+
let s = await e.list(t, { cursor: o }), c = s.items.filter((e) => e.kind === "folder").sort((e, t) => e.name.localeCompare(t.name, void 0, {
|
|
2339
|
+
numeric: !0,
|
|
2340
|
+
sensitivity: "base"
|
|
2341
|
+
}));
|
|
2342
|
+
for (let e of c) bt(e.path, r) || (n.push({
|
|
2343
|
+
path: e.path,
|
|
2344
|
+
name: e.name,
|
|
2345
|
+
depth: a
|
|
2346
|
+
}), await i(e.path, a + 1));
|
|
2347
|
+
o = s.cursor;
|
|
2348
|
+
} while (o);
|
|
2349
|
+
}
|
|
2350
|
+
return await i("/", 0), n;
|
|
2351
|
+
}
|
|
2352
|
+
function bt(e, t) {
|
|
2353
|
+
let n = a(e);
|
|
2354
|
+
return t.some((e) => n === e || n.startsWith(`${e}/`));
|
|
2355
|
+
}
|
|
2356
|
+
function xt(e, t, n) {
|
|
2357
|
+
if (!t) return {
|
|
2358
|
+
acceptedCandidates: e,
|
|
2359
|
+
rejectedCandidates: []
|
|
2360
|
+
};
|
|
2361
|
+
let r = [], i = [], a = 0;
|
|
2362
|
+
for (let o of e) {
|
|
2363
|
+
let e = [];
|
|
2364
|
+
t.maxFileSizeBytes !== void 0 && o.file.size > t.maxFileSizeBytes && e.push(`File is larger than ${Xt(t.maxFileSizeBytes)}`), t.allowedMimeTypes?.length && !St(o.file, t.allowedMimeTypes) && e.push(`File type ${o.file.type || "unknown"} is not allowed`), t.remainingQuotaBytes !== void 0 && a + o.file.size > t.remainingQuotaBytes && e.push(`Upload exceeds remaining quota of ${Xt(t.remainingQuotaBytes)}`);
|
|
2365
|
+
let s = t.validate?.(o, {
|
|
2366
|
+
acceptedBytes: a,
|
|
2367
|
+
currentPath: n
|
|
2368
|
+
});
|
|
2369
|
+
if (Array.isArray(s) ? e.push(...s.filter(Boolean)) : s && e.push(s), e.length > 0) {
|
|
2370
|
+
i.push({
|
|
2371
|
+
fileName: o.file.name,
|
|
2372
|
+
relativePath: o.relativePath,
|
|
2373
|
+
reasons: e
|
|
2374
|
+
});
|
|
2375
|
+
continue;
|
|
2376
|
+
}
|
|
2377
|
+
a += o.file.size, r.push(o);
|
|
2378
|
+
}
|
|
2379
|
+
return {
|
|
2380
|
+
acceptedCandidates: r,
|
|
2381
|
+
rejectedCandidates: i
|
|
2382
|
+
};
|
|
2383
|
+
}
|
|
2384
|
+
function St(e, t) {
|
|
2385
|
+
return t.some((t) => t.endsWith("/*") ? e.type.startsWith(t.slice(0, -1)) : t.startsWith(".") ? e.name.toLowerCase().endsWith(t.toLowerCase()) : e.type === t);
|
|
2386
|
+
}
|
|
2387
|
+
function Ct({ browser: e, canMove: t, inlineRenameError: n, inlineRenameLabel: r, inlineRenameItem: i, inlineRenameValue: a, selectedPaths: o, onContextMenu: s, onDragStart: c, onEmptyClick: l, onFolderDragOver: u, onFolderDrop: d, onInlineRenameCancel: f, onInlineRenameChange: p, onInlineRenameCommit: m, onOpenItem: h, onSelectItem: g, onTouchMenu: _ }) {
|
|
2388
|
+
let [v, y] = b(null);
|
|
2389
|
+
function x(t) {
|
|
2390
|
+
let n = t.inputEvent, r = t.selected.map((e) => e.getAttribute("data-fb-path")).filter((e) => !!e);
|
|
2391
|
+
e.setSelection(r, { additive: !!(n?.shiftKey || n?.metaKey || n?.ctrlKey) });
|
|
2392
|
+
}
|
|
2393
|
+
return /* @__PURE__ */ E(w, { children: [v ? /* @__PURE__ */ T(S, {
|
|
2394
|
+
className: "[background:var(--fb-accent-soft)!important] [border-color:var(--fb-accent)!important]",
|
|
2395
|
+
container: v,
|
|
2396
|
+
dragContainer: v,
|
|
2397
|
+
hitRate: 10,
|
|
2398
|
+
onSelect: x,
|
|
2399
|
+
preventClickEventOnDrag: !0,
|
|
2400
|
+
selectByClick: !1,
|
|
2401
|
+
selectableTargets: [() => Array.from(v.querySelectorAll("[data-fb-selectable='true']"))],
|
|
2402
|
+
selectFromInside: !1
|
|
2403
|
+
}) : null, /* @__PURE__ */ T("div", {
|
|
2404
|
+
"aria-label": "Files",
|
|
2405
|
+
className: "relative grid min-h-full content-start grid-cols-[repeat(auto-fill,minmax(var(--fb-card-min),1fr))] gap-[var(--fb-grid-gap)]",
|
|
2406
|
+
onClick: (e) => {
|
|
2407
|
+
e.target === e.currentTarget && !Vt(e) && l();
|
|
2408
|
+
},
|
|
2409
|
+
ref: y,
|
|
2410
|
+
role: "grid",
|
|
2411
|
+
children: e.filteredItems.map((e) => /* @__PURE__ */ T(wt, {
|
|
2412
|
+
canMove: t,
|
|
2413
|
+
item: e,
|
|
2414
|
+
onOpen: () => h(e),
|
|
2415
|
+
onContextMenu: (t) => s(e, t),
|
|
2416
|
+
onDragStart: (t) => c(e, t),
|
|
2417
|
+
onFolderDragOver: (t) => u(e, t),
|
|
2418
|
+
onFolderDrop: (t) => d(e, t),
|
|
2419
|
+
inlineRenameError: n,
|
|
2420
|
+
inlineRenameLabel: r,
|
|
2421
|
+
inlineRenameValue: a,
|
|
2422
|
+
isRenaming: i?.path === e.path,
|
|
2423
|
+
onInlineRenameCancel: f,
|
|
2424
|
+
onInlineRenameChange: p,
|
|
2425
|
+
onInlineRenameCommit: m,
|
|
2426
|
+
onSelect: (t) => g(e.path, t),
|
|
2427
|
+
onTouchMenu: () => _(e),
|
|
2428
|
+
selected: o.includes(e.path)
|
|
2429
|
+
}, e.path))
|
|
2430
|
+
})] });
|
|
2431
|
+
}
|
|
2432
|
+
function wt({ canMove: e, inlineRenameError: t, inlineRenameLabel: n, inlineRenameValue: r, isRenaming: i, item: a, selected: o, onSelect: s, onOpen: c, onContextMenu: l, onDragStart: u, onFolderDragOver: d, onFolderDrop: f, onInlineRenameCancel: p, onInlineRenameChange: m, onInlineRenameCommit: h, onTouchMenu: g }) {
|
|
2433
|
+
let _ = y(null);
|
|
2434
|
+
function v() {
|
|
2435
|
+
_.current &&= (clearTimeout(_.current), null);
|
|
2436
|
+
}
|
|
2437
|
+
function b() {
|
|
2438
|
+
v(), _.current = setTimeout(() => {
|
|
2439
|
+
_.current = null, g();
|
|
2440
|
+
}, 520);
|
|
2441
|
+
}
|
|
2442
|
+
return /* @__PURE__ */ E("article", {
|
|
2443
|
+
"aria-selected": o,
|
|
2444
|
+
"data-fb-path": a.path,
|
|
2445
|
+
"data-fb-selectable": "true",
|
|
2446
|
+
draggable: e,
|
|
2447
|
+
className: `group relative flex min-h-[var(--fb-card-minh)] cursor-default flex-col rounded-[calc(var(--fb-radius)-1px)] border p-[var(--fb-card-pad)] outline-none hover:shadow-[0_8px_22px_color-mix(in_oklch,var(--fb-text)_8%,transparent)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${Z} ${o ? "border-[var(--fb-accent)] bg-[var(--fb-accent-soft)]" : "border-[var(--fb-border)] bg-[var(--fb-surface)] hover:border-[var(--fb-border-strong)]"}`,
|
|
2448
|
+
onClick: s,
|
|
2449
|
+
onContextMenu: l,
|
|
2450
|
+
onDoubleClick: c,
|
|
2451
|
+
onDragOver: a.kind === "folder" ? d : void 0,
|
|
2452
|
+
onDragStart: e ? u : void 0,
|
|
2453
|
+
onDrop: a.kind === "folder" ? f : void 0,
|
|
2454
|
+
onTouchCancel: v,
|
|
2455
|
+
onTouchEnd: v,
|
|
2456
|
+
onTouchMove: v,
|
|
2457
|
+
onTouchStart: b,
|
|
2458
|
+
role: "gridcell",
|
|
2459
|
+
tabIndex: 0,
|
|
2460
|
+
children: [
|
|
2461
|
+
/* @__PURE__ */ T("span", {
|
|
2462
|
+
"aria-hidden": "true",
|
|
2463
|
+
className: `absolute right-2 top-2 grid size-4 place-items-center rounded border text-[10px] ${X} ${o ? "border-[var(--fb-accent)] bg-[var(--fb-accent)] text-[var(--fb-surface)]" : "border-[var(--fb-border)] bg-[var(--fb-surface)] opacity-0 group-hover:opacity-100"}`,
|
|
2464
|
+
children: o ? "✓" : ""
|
|
2465
|
+
}),
|
|
2466
|
+
/* @__PURE__ */ T("div", {
|
|
2467
|
+
className: `grid h-[var(--fb-thumb-h)] place-items-center rounded-[calc(var(--fb-radius)-3px)] bg-[var(--fb-surface-2)] group-hover:bg-[var(--fb-bg)] ${X}`,
|
|
2468
|
+
children: a.kind === "folder" ? /* @__PURE__ */ T(z, {
|
|
2469
|
+
"aria-hidden": "true",
|
|
2470
|
+
className: "size-9 text-[var(--fb-folder)]"
|
|
2471
|
+
}) : /* @__PURE__ */ T(R, {
|
|
2472
|
+
"aria-hidden": "true",
|
|
2473
|
+
className: "size-9 text-[var(--fb-muted)]"
|
|
2474
|
+
})
|
|
2475
|
+
}),
|
|
2476
|
+
i ? /* @__PURE__ */ T(Tt, {
|
|
2477
|
+
item: a,
|
|
2478
|
+
error: t,
|
|
2479
|
+
label: n,
|
|
2480
|
+
onCancel: p,
|
|
2481
|
+
onChange: m,
|
|
2482
|
+
onCommit: h,
|
|
2483
|
+
value: r
|
|
2484
|
+
}) : /* @__PURE__ */ T("button", {
|
|
2485
|
+
className: `mt-2 min-w-0 truncate text-left text-[12.5px] font-semibold text-[var(--fb-text)] outline-none ${X}`,
|
|
2486
|
+
onClick: (e) => {
|
|
2487
|
+
e.stopPropagation(), s(e);
|
|
2488
|
+
},
|
|
2489
|
+
type: "button",
|
|
2490
|
+
children: a.name
|
|
2491
|
+
}),
|
|
2492
|
+
/* @__PURE__ */ T("div", {
|
|
2493
|
+
className: "mt-1 text-[11px] text-[var(--fb-muted)]",
|
|
2494
|
+
children: a.kind === "folder" ? "Folder" : Xt(a.size ?? 0)
|
|
2495
|
+
})
|
|
2496
|
+
]
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
function Tt({ error: e, item: t, label: n, onCancel: r, onChange: i, onCommit: a, value: o }) {
|
|
2500
|
+
return /* @__PURE__ */ E("div", {
|
|
2501
|
+
className: "min-w-0",
|
|
2502
|
+
children: [/* @__PURE__ */ T("input", {
|
|
2503
|
+
"aria-label": `Rename ${n || t.name}`,
|
|
2504
|
+
autoFocus: !0,
|
|
2505
|
+
className: `mt-2 min-w-0 rounded-[calc(var(--fb-radius)-4px)] border border-[var(--fb-accent)] bg-[var(--fb-surface)] px-1.5 py-1 text-[12.5px] font-semibold text-[var(--fb-text)] outline-none ring-2 ring-[var(--fb-accent-soft)] ${X}`,
|
|
2506
|
+
onBlur: a,
|
|
2507
|
+
onChange: (e) => i(e.target.value),
|
|
2508
|
+
onClick: (e) => e.stopPropagation(),
|
|
2509
|
+
onDoubleClick: (e) => e.stopPropagation(),
|
|
2510
|
+
onKeyDown: (e) => {
|
|
2511
|
+
e.key === "Enter" && (e.preventDefault(), a()), e.key === "Escape" && (e.preventDefault(), r());
|
|
2512
|
+
},
|
|
2513
|
+
value: o
|
|
2514
|
+
}), e ? /* @__PURE__ */ T("div", {
|
|
2515
|
+
className: `mt-1 rounded-[calc(var(--fb-radius)-5px)] border border-[var(--fb-danger)] bg-[var(--fb-danger-soft)] px-1.5 py-1 text-[11px] text-[var(--fb-danger)] ${Z}`,
|
|
2516
|
+
role: "alert",
|
|
2517
|
+
children: e
|
|
2518
|
+
}) : null]
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
function Et({ browser: e, canMove: t, inlineRenameError: n, inlineRenameLabel: r, inlineRenameItem: i, inlineRenameValue: a, selectedPaths: o, onContextMenu: s, onDragStart: c, onFolderDragOver: l, onFolderDrop: u, onInlineRenameCancel: d, onInlineRenameChange: f, onInlineRenameCommit: p, onOpenItem: m, onSelectItem: h }) {
|
|
2522
|
+
return /* @__PURE__ */ E("table", {
|
|
2523
|
+
"aria-label": "Files",
|
|
2524
|
+
className: `w-full border-separate border-spacing-0 overflow-hidden rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] text-left ${Z}`,
|
|
2525
|
+
children: [/* @__PURE__ */ T("thead", {
|
|
2526
|
+
className: "text-[11px] text-[var(--fb-muted)]",
|
|
2527
|
+
children: /* @__PURE__ */ E("tr", { children: [
|
|
2528
|
+
/* @__PURE__ */ T("th", {
|
|
2529
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)] font-medium",
|
|
2530
|
+
children: "Name"
|
|
2531
|
+
}),
|
|
2532
|
+
/* @__PURE__ */ T("th", {
|
|
2533
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)] font-medium",
|
|
2534
|
+
children: "Size"
|
|
2535
|
+
}),
|
|
2536
|
+
/* @__PURE__ */ T("th", {
|
|
2537
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)] font-medium",
|
|
2538
|
+
children: "Modified"
|
|
2539
|
+
})
|
|
2540
|
+
] })
|
|
2541
|
+
}), /* @__PURE__ */ T("tbody", { children: e.filteredItems.map((e) => /* @__PURE__ */ E("tr", {
|
|
2542
|
+
"aria-selected": o.includes(e.path),
|
|
2543
|
+
"data-fb-path": e.path,
|
|
2544
|
+
className: o.includes(e.path) ? `bg-[var(--fb-accent-soft)] outline-none focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}` : `outline-none hover:bg-[var(--fb-bg)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`,
|
|
2545
|
+
draggable: t,
|
|
2546
|
+
onClick: (t) => h(e.path, t),
|
|
2547
|
+
onContextMenu: (t) => s(e, t),
|
|
2548
|
+
onDragOver: (t) => l(e, t),
|
|
2549
|
+
onDragStart: (t) => c(e, t),
|
|
2550
|
+
onDrop: (t) => u(e, t),
|
|
2551
|
+
onDoubleClick: () => m(e),
|
|
2552
|
+
tabIndex: 0,
|
|
2553
|
+
children: [
|
|
2554
|
+
/* @__PURE__ */ T("td", {
|
|
2555
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)]",
|
|
2556
|
+
children: /* @__PURE__ */ E("div", {
|
|
2557
|
+
className: "flex min-w-0 items-center gap-2",
|
|
2558
|
+
children: [e.kind === "folder" ? /* @__PURE__ */ T(z, { className: "size-4 text-[var(--fb-folder)]" }) : /* @__PURE__ */ T(R, { className: "size-4 text-[var(--fb-muted)]" }), i?.path === e.path ? /* @__PURE__ */ T(Tt, {
|
|
2559
|
+
item: e,
|
|
2560
|
+
error: n,
|
|
2561
|
+
label: r,
|
|
2562
|
+
onCancel: d,
|
|
2563
|
+
onChange: f,
|
|
2564
|
+
onCommit: p,
|
|
2565
|
+
value: a
|
|
2566
|
+
}) : /* @__PURE__ */ T("button", {
|
|
2567
|
+
className: `truncate font-medium ${X}`,
|
|
2568
|
+
onClick: (t) => {
|
|
2569
|
+
t.stopPropagation(), h(e.path, t);
|
|
2570
|
+
},
|
|
2571
|
+
type: "button",
|
|
2572
|
+
children: e.name
|
|
2573
|
+
})]
|
|
2574
|
+
})
|
|
2575
|
+
}),
|
|
2576
|
+
/* @__PURE__ */ T("td", {
|
|
2577
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)] text-[12px] text-[var(--fb-muted)]",
|
|
2578
|
+
children: e.kind === "folder" ? "Folder" : Xt(e.size ?? 0)
|
|
2579
|
+
}),
|
|
2580
|
+
/* @__PURE__ */ T("td", {
|
|
2581
|
+
className: "border-b border-[var(--fb-border)] px-[var(--fb-cell-x)] py-[var(--fb-cell-y)] text-[12px] text-[var(--fb-muted)]",
|
|
2582
|
+
children: e.modifiedAt ? new Date(e.modifiedAt).toLocaleDateString() : "—"
|
|
2583
|
+
})
|
|
2584
|
+
]
|
|
2585
|
+
}, e.path)) })]
|
|
2586
|
+
});
|
|
2587
|
+
}
|
|
2588
|
+
function Dt({ browser: e, menu: t, onClose: n, onDelete: r, onDownload: i, onCopy: a, onCopyPath: o, onCut: s, onMove: c, onNewFolder: l, onPaste: u, onRename: d, onUpload: f, readOnly: p }) {
|
|
2589
|
+
let m = t.target === "item", h = t.mode === "sheet";
|
|
2590
|
+
function g(e) {
|
|
2591
|
+
e(), n();
|
|
2592
|
+
}
|
|
2593
|
+
return /* @__PURE__ */ E("div", {
|
|
2594
|
+
"aria-label": m ? "Item actions" : "Folder actions",
|
|
2595
|
+
className: `fixed z-50 rounded-[calc(var(--fb-radius)-2px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-1 text-[12px] text-[var(--fb-text)] shadow-[0_16px_44px_color-mix(in_oklch,var(--fb-text)_16%,transparent)] ${Z} ${h ? "inset-x-3 bottom-3 max-h-[80vh] overflow-auto" : "min-w-40"}`,
|
|
2596
|
+
"data-fb-menu": h ? "sheet" : "context",
|
|
2597
|
+
role: "menu",
|
|
2598
|
+
style: h ? void 0 : {
|
|
2599
|
+
left: t.x,
|
|
2600
|
+
top: t.y
|
|
2601
|
+
},
|
|
2602
|
+
children: [
|
|
2603
|
+
m && !p && e.capabilities.rename ? /* @__PURE__ */ T(Q, {
|
|
2604
|
+
onClick: () => g(() => d(t.item)),
|
|
2605
|
+
children: "Rename"
|
|
2606
|
+
}) : null,
|
|
2607
|
+
m && !p && e.capabilities.move ? /* @__PURE__ */ T(Q, {
|
|
2608
|
+
onClick: () => g(c),
|
|
2609
|
+
children: "Move"
|
|
2610
|
+
}) : null,
|
|
2611
|
+
m && !p && e.capabilities.copy ? /* @__PURE__ */ T(Q, {
|
|
2612
|
+
onClick: () => g(a),
|
|
2613
|
+
children: "Copy"
|
|
2614
|
+
}) : null,
|
|
2615
|
+
m && !p && e.capabilities.move ? /* @__PURE__ */ T(Q, {
|
|
2616
|
+
onClick: () => g(s),
|
|
2617
|
+
children: "Cut"
|
|
2618
|
+
}) : null,
|
|
2619
|
+
m ? /* @__PURE__ */ E(w, { children: [
|
|
2620
|
+
/* @__PURE__ */ T(Q, {
|
|
2621
|
+
onClick: () => g(() => o(t.item)),
|
|
2622
|
+
children: e.selectedPaths.includes(t.item.path) && e.selectedPaths.length > 1 ? "Copy paths" : "Copy path"
|
|
2623
|
+
}),
|
|
2624
|
+
/* @__PURE__ */ T(Q, {
|
|
2625
|
+
onClick: () => g(i),
|
|
2626
|
+
children: "Download"
|
|
2627
|
+
}),
|
|
2628
|
+
p ? null : /* @__PURE__ */ T(Q, {
|
|
2629
|
+
danger: !0,
|
|
2630
|
+
onClick: () => {
|
|
2631
|
+
r(), n();
|
|
2632
|
+
},
|
|
2633
|
+
children: "Delete"
|
|
2634
|
+
})
|
|
2635
|
+
] }) : /* @__PURE__ */ E(w, { children: [p ? null : /* @__PURE__ */ E(w, { children: [e.capabilities.createFolder ? /* @__PURE__ */ T(Q, {
|
|
2636
|
+
onClick: () => g(l),
|
|
2637
|
+
children: "New folder"
|
|
2638
|
+
}) : null, /* @__PURE__ */ T(Q, {
|
|
2639
|
+
onClick: () => g(f),
|
|
2640
|
+
children: "Upload"
|
|
2641
|
+
})] }), !p && e.clipboard ? /* @__PURE__ */ T(Q, {
|
|
2642
|
+
onClick: () => g(u),
|
|
2643
|
+
children: "Paste here"
|
|
2644
|
+
}) : null] })
|
|
2645
|
+
]
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
function Q({ children: e, danger: t, onClick: n }) {
|
|
2649
|
+
return /* @__PURE__ */ T("button", {
|
|
2650
|
+
className: `flex h-8 w-full items-center rounded-[calc(var(--fb-radius)-4px)] px-2 text-left font-medium outline-none hover:bg-[var(--fb-bg)] focus:bg-[var(--fb-bg)] ${X} ${t ? "text-[var(--fb-danger)]" : ""}`,
|
|
2651
|
+
onClick: n,
|
|
2652
|
+
role: "menuitem",
|
|
2653
|
+
type: "button",
|
|
2654
|
+
children: e
|
|
2655
|
+
});
|
|
2656
|
+
}
|
|
2657
|
+
function Ot({ applyToAll: e, currentPath: t, onApplyToAllChange: n, onCancel: r, onResolve: i, queue: a }) {
|
|
2658
|
+
let o = a.candidates[a.index], s = ht(t, o.relativePath), c = a.conflictPaths.indexOf(s) + 1;
|
|
2659
|
+
return /* @__PURE__ */ T("div", {
|
|
2660
|
+
"aria-label": "File conflict",
|
|
2661
|
+
"aria-modal": "true",
|
|
2662
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2663
|
+
role: "dialog",
|
|
2664
|
+
children: /* @__PURE__ */ E("div", {
|
|
2665
|
+
className: `w-[min(420px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2666
|
+
children: [
|
|
2667
|
+
/* @__PURE__ */ T("h2", {
|
|
2668
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2669
|
+
children: "File conflict"
|
|
2670
|
+
}),
|
|
2671
|
+
/* @__PURE__ */ E("p", {
|
|
2672
|
+
className: "mt-2 text-[12px] text-[var(--fb-muted)]",
|
|
2673
|
+
children: [o.relativePath, " already exists in this folder."]
|
|
2674
|
+
}),
|
|
2675
|
+
/* @__PURE__ */ E("div", {
|
|
2676
|
+
className: `mt-3 rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-bg)] p-2 text-[12px] ${Z}`,
|
|
2677
|
+
children: [
|
|
2678
|
+
"Conflict ",
|
|
2679
|
+
c,
|
|
2680
|
+
" of ",
|
|
2681
|
+
a.conflictPaths.length
|
|
2682
|
+
]
|
|
2683
|
+
}),
|
|
2684
|
+
/* @__PURE__ */ E("label", {
|
|
2685
|
+
className: "mt-3 flex items-center gap-2 text-[12px] font-medium text-[var(--fb-muted)]",
|
|
2686
|
+
children: [/* @__PURE__ */ T("input", {
|
|
2687
|
+
checked: e,
|
|
2688
|
+
onChange: (e) => n(e.target.checked),
|
|
2689
|
+
type: "checkbox"
|
|
2690
|
+
}), "Apply to all conflicts"]
|
|
2691
|
+
}),
|
|
2692
|
+
/* @__PURE__ */ E("div", {
|
|
2693
|
+
className: "mt-4 flex flex-wrap justify-end gap-2",
|
|
2694
|
+
children: [
|
|
2695
|
+
/* @__PURE__ */ T("button", {
|
|
2696
|
+
className: $(!1),
|
|
2697
|
+
onClick: r,
|
|
2698
|
+
type: "button",
|
|
2699
|
+
children: "Cancel"
|
|
2700
|
+
}),
|
|
2701
|
+
/* @__PURE__ */ T("button", {
|
|
2702
|
+
className: $(!1),
|
|
2703
|
+
onClick: () => i("skip"),
|
|
2704
|
+
type: "button",
|
|
2705
|
+
children: "Skip"
|
|
2706
|
+
}),
|
|
2707
|
+
/* @__PURE__ */ T("button", {
|
|
2708
|
+
className: $(!1),
|
|
2709
|
+
onClick: () => i("replace"),
|
|
2710
|
+
type: "button",
|
|
2711
|
+
children: "Replace"
|
|
2712
|
+
}),
|
|
2713
|
+
/* @__PURE__ */ T("button", {
|
|
2714
|
+
className: en(),
|
|
2715
|
+
onClick: () => i("keep-both"),
|
|
2716
|
+
type: "button",
|
|
2717
|
+
children: "Keep both"
|
|
2718
|
+
})
|
|
2719
|
+
]
|
|
2720
|
+
})
|
|
2721
|
+
]
|
|
2722
|
+
})
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
function kt({ error: e, onClose: t }) {
|
|
2726
|
+
let n = e.succeededPaths.length;
|
|
2727
|
+
return /* @__PURE__ */ T("div", {
|
|
2728
|
+
"aria-label": "Partial bulk failure",
|
|
2729
|
+
"aria-modal": "true",
|
|
2730
|
+
className: `fixed inset-0 z-40 grid place-items-center bg-[color-mix(in_oklch,var(--fb-text)_20%,transparent)] p-4 ${Z}`,
|
|
2731
|
+
role: "dialog",
|
|
2732
|
+
children: /* @__PURE__ */ E("div", {
|
|
2733
|
+
className: `w-[min(440px,100%)] rounded-[var(--fb-radius)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 shadow-[0_18px_50px_color-mix(in_oklch,var(--fb-text)_18%,transparent)] ${Z}`,
|
|
2734
|
+
children: [
|
|
2735
|
+
/* @__PURE__ */ T("h2", {
|
|
2736
|
+
className: "m-0 text-[14px] font-semibold",
|
|
2737
|
+
children: "Partial bulk failure"
|
|
2738
|
+
}),
|
|
2739
|
+
/* @__PURE__ */ E("p", {
|
|
2740
|
+
className: "mt-2 text-[12px] text-[var(--fb-muted)]",
|
|
2741
|
+
children: [
|
|
2742
|
+
n,
|
|
2743
|
+
" of ",
|
|
2744
|
+
e.totalCount,
|
|
2745
|
+
" completed"
|
|
2746
|
+
]
|
|
2747
|
+
}),
|
|
2748
|
+
/* @__PURE__ */ T("ul", {
|
|
2749
|
+
className: `mt-3 max-h-40 overflow-auto rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-bg)] p-2 text-[12px] ${Z}`,
|
|
2750
|
+
children: e.failures.map((e) => /* @__PURE__ */ E("li", {
|
|
2751
|
+
className: "py-1",
|
|
2752
|
+
children: [/* @__PURE__ */ T("div", {
|
|
2753
|
+
className: "truncate font-medium",
|
|
2754
|
+
children: e.path.split("/").filter(Boolean).at(-1) ?? e.path
|
|
2755
|
+
}), /* @__PURE__ */ T("div", {
|
|
2756
|
+
className: "text-[var(--fb-danger)]",
|
|
2757
|
+
children: e.message
|
|
2758
|
+
})]
|
|
2759
|
+
}, e.path))
|
|
2760
|
+
}),
|
|
2761
|
+
/* @__PURE__ */ T("div", {
|
|
2762
|
+
className: "mt-4 flex justify-end",
|
|
2763
|
+
children: /* @__PURE__ */ T("button", {
|
|
2764
|
+
className: en(),
|
|
2765
|
+
onClick: t,
|
|
2766
|
+
type: "button",
|
|
2767
|
+
children: "OK"
|
|
2768
|
+
})
|
|
2769
|
+
})
|
|
2770
|
+
]
|
|
2771
|
+
})
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
function At({ currentPath: e, destinations: t, error: n, onSelect: r, selectedPath: i, status: a }) {
|
|
2775
|
+
return /* @__PURE__ */ E("div", {
|
|
2776
|
+
className: `mt-3 max-h-64 overflow-auto rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-bg)] p-2 ${Z}`,
|
|
2777
|
+
children: [
|
|
2778
|
+
/* @__PURE__ */ T(jt, {
|
|
2779
|
+
active: i === e,
|
|
2780
|
+
label: "Current folder",
|
|
2781
|
+
onClick: () => r(e),
|
|
2782
|
+
path: e
|
|
2783
|
+
}),
|
|
2784
|
+
/* @__PURE__ */ T(jt, {
|
|
2785
|
+
active: i === "/",
|
|
2786
|
+
label: "Files",
|
|
2787
|
+
onClick: () => r("/"),
|
|
2788
|
+
path: "/"
|
|
2789
|
+
}),
|
|
2790
|
+
a === "loading" ? /* @__PURE__ */ T("div", {
|
|
2791
|
+
className: "px-2 py-3 text-[12px] text-[var(--fb-muted)]",
|
|
2792
|
+
children: "Loading folders"
|
|
2793
|
+
}) : null,
|
|
2794
|
+
a === "error" ? /* @__PURE__ */ T("div", {
|
|
2795
|
+
className: "px-2 py-3 text-[12px] text-[var(--fb-danger)]",
|
|
2796
|
+
children: n ?? "Could not load folders"
|
|
2797
|
+
}) : null,
|
|
2798
|
+
a === "ready" && t.length === 0 ? /* @__PURE__ */ T("div", {
|
|
2799
|
+
className: "px-2 py-3 text-[12px] text-[var(--fb-muted)]",
|
|
2800
|
+
children: "No folders available."
|
|
2801
|
+
}) : null,
|
|
2802
|
+
t.map((e) => /* @__PURE__ */ T(jt, {
|
|
2803
|
+
active: i === e.path,
|
|
2804
|
+
depth: e.depth,
|
|
2805
|
+
label: e.name,
|
|
2806
|
+
onClick: () => r(e.path),
|
|
2807
|
+
path: e.path
|
|
2808
|
+
}, e.path))
|
|
2809
|
+
]
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
function jt({ active: e, depth: t = 0, label: n, onClick: r, path: i }) {
|
|
2813
|
+
return /* @__PURE__ */ E("button", {
|
|
2814
|
+
"aria-label": `Move destination ${i}`,
|
|
2815
|
+
className: `mt-1 flex h-8 w-full items-center gap-2 rounded-[calc(var(--fb-radius)-4px)] px-2 text-left text-[12px] font-medium ${X} ${e ? "bg-[var(--fb-accent-soft)] text-[var(--fb-accent)]" : "hover:bg-[var(--fb-surface)]"}`,
|
|
2816
|
+
onClick: r,
|
|
2817
|
+
style: { paddingLeft: `calc((${t} * 6 + 2) * var(--fb-gap))` },
|
|
2818
|
+
type: "button",
|
|
2819
|
+
children: [/* @__PURE__ */ T(z, {
|
|
2820
|
+
"aria-hidden": "true",
|
|
2821
|
+
className: "size-4 shrink-0"
|
|
2822
|
+
}), /* @__PURE__ */ T("span", {
|
|
2823
|
+
className: "truncate",
|
|
2824
|
+
children: n
|
|
2825
|
+
})]
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
function Mt({ selectedCount: e, itemCount: t, canRename: n, canMove: r, canCopy: i, canCut: a, canDelete: o, onRename: s, onMove: c, onCopy: l, onCut: u, onDelete: d, onDownload: f, onSelectAll: p, onSelectNone: m }) {
|
|
2829
|
+
let h = e > 0;
|
|
2830
|
+
return /* @__PURE__ */ E("div", {
|
|
2831
|
+
"aria-label": "Selection actions",
|
|
2832
|
+
className: `flex min-h-11 flex-wrap items-center gap-2 border-b border-[var(--fb-border)] px-[var(--fb-pad)] py-1.5 ${Z} ${h ? "bg-[var(--fb-accent-soft)]" : "bg-[var(--fb-surface)]"}`,
|
|
2833
|
+
role: "toolbar",
|
|
2834
|
+
children: [
|
|
2835
|
+
/* @__PURE__ */ E("span", {
|
|
2836
|
+
className: "mr-auto text-[12px] font-semibold",
|
|
2837
|
+
children: [e, " selected"]
|
|
2838
|
+
}),
|
|
2839
|
+
/* @__PURE__ */ E("button", {
|
|
2840
|
+
className: $(!1),
|
|
2841
|
+
disabled: t === 0,
|
|
2842
|
+
onClick: p,
|
|
2843
|
+
type: "button",
|
|
2844
|
+
children: [/* @__PURE__ */ T(ge, { className: "size-4" }), "Select all"]
|
|
2845
|
+
}),
|
|
2846
|
+
/* @__PURE__ */ E("button", {
|
|
2847
|
+
className: $(!1),
|
|
2848
|
+
disabled: !h,
|
|
2849
|
+
onClick: m,
|
|
2850
|
+
type: "button",
|
|
2851
|
+
children: [/* @__PURE__ */ T(V, { className: "size-4" }), "Select none"]
|
|
2852
|
+
}),
|
|
2853
|
+
h && n && e === 1 ? /* @__PURE__ */ E("button", {
|
|
2854
|
+
className: $(!1),
|
|
2855
|
+
onClick: () => s(),
|
|
2856
|
+
type: "button",
|
|
2857
|
+
children: [/* @__PURE__ */ T(pe, { className: "size-4" }), "Rename"]
|
|
2858
|
+
}) : null,
|
|
2859
|
+
h && r ? /* @__PURE__ */ E("button", {
|
|
2860
|
+
className: $(!1),
|
|
2861
|
+
onClick: c,
|
|
2862
|
+
type: "button",
|
|
2863
|
+
children: [/* @__PURE__ */ T(le, { className: "size-4" }), "Move"]
|
|
2864
|
+
}) : null,
|
|
2865
|
+
h && i ? /* @__PURE__ */ E("button", {
|
|
2866
|
+
className: $(!1),
|
|
2867
|
+
onClick: l,
|
|
2868
|
+
type: "button",
|
|
2869
|
+
children: [/* @__PURE__ */ T(ce, { className: "size-4" }), "Copy"]
|
|
2870
|
+
}) : null,
|
|
2871
|
+
h && a ? /* @__PURE__ */ E("button", {
|
|
2872
|
+
className: $(!1),
|
|
2873
|
+
onClick: u,
|
|
2874
|
+
type: "button",
|
|
2875
|
+
children: [/* @__PURE__ */ T(me, { className: "size-4" }), "Cut"]
|
|
2876
|
+
}) : null,
|
|
2877
|
+
h ? /* @__PURE__ */ E("button", {
|
|
2878
|
+
className: $(!1),
|
|
2879
|
+
onClick: f,
|
|
2880
|
+
type: "button",
|
|
2881
|
+
children: [/* @__PURE__ */ T(L, { className: "size-4" }), "Download"]
|
|
2882
|
+
}) : null,
|
|
2883
|
+
h && o ? /* @__PURE__ */ E("button", {
|
|
2884
|
+
className: tn(),
|
|
2885
|
+
onClick: d,
|
|
2886
|
+
type: "button",
|
|
2887
|
+
children: [/* @__PURE__ */ T(ve, { className: "size-4" }), "Delete"]
|
|
2888
|
+
}) : null
|
|
2889
|
+
]
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
function Nt({ path: e, onNavigate: t }) {
|
|
2893
|
+
let n = e.split("/").filter(Boolean);
|
|
2894
|
+
return /* @__PURE__ */ T("nav", {
|
|
2895
|
+
"aria-label": "Breadcrumb",
|
|
2896
|
+
className: "flex min-w-0 items-center gap-1",
|
|
2897
|
+
children: Pt([{
|
|
2898
|
+
label: "Files",
|
|
2899
|
+
path: "/"
|
|
2900
|
+
}].concat(n.map((e, t) => ({
|
|
2901
|
+
label: e,
|
|
2902
|
+
path: `/${n.slice(0, t + 1).join("/")}`
|
|
2903
|
+
})))).map((e, n) => /* @__PURE__ */ E("span", {
|
|
2904
|
+
className: "flex min-w-0 items-center gap-1",
|
|
2905
|
+
children: [n > 0 ? /* @__PURE__ */ T("span", {
|
|
2906
|
+
className: "text-[var(--fb-muted)]",
|
|
2907
|
+
"aria-hidden": "true",
|
|
2908
|
+
children: "/"
|
|
2909
|
+
}) : null, e.kind === "collapsed" ? /* @__PURE__ */ T("span", {
|
|
2910
|
+
"aria-label": "Collapsed breadcrumb",
|
|
2911
|
+
className: `rounded-[calc(var(--fb-radius)-4px)] px-1.5 py-1 text-[12px] font-semibold text-[var(--fb-muted)] ${X}`,
|
|
2912
|
+
children: "..."
|
|
2913
|
+
}) : /* @__PURE__ */ T("button", {
|
|
2914
|
+
className: `max-w-[160px] truncate rounded-[calc(var(--fb-radius)-4px)] px-1.5 py-1 text-[12px] font-semibold hover:bg-[var(--fb-bg)] ${X}`,
|
|
2915
|
+
onClick: () => void t(e.path),
|
|
2916
|
+
type: "button",
|
|
2917
|
+
children: e.label
|
|
2918
|
+
})]
|
|
2919
|
+
}, e.key))
|
|
2920
|
+
});
|
|
2921
|
+
}
|
|
2922
|
+
function Pt(e) {
|
|
2923
|
+
return e.length <= 4 ? e.map((e) => ({
|
|
2924
|
+
...e,
|
|
2925
|
+
kind: "crumb",
|
|
2926
|
+
key: e.path
|
|
2927
|
+
})) : [
|
|
2928
|
+
{
|
|
2929
|
+
...e[0],
|
|
2930
|
+
kind: "crumb",
|
|
2931
|
+
key: e[0].path
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
...e[1],
|
|
2935
|
+
kind: "crumb",
|
|
2936
|
+
key: e[1].path
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
kind: "collapsed",
|
|
2940
|
+
key: "collapsed"
|
|
2941
|
+
},
|
|
2942
|
+
...e.slice(-2).map((e) => ({
|
|
2943
|
+
...e,
|
|
2944
|
+
kind: "crumb",
|
|
2945
|
+
key: e.path
|
|
2946
|
+
}))
|
|
2947
|
+
];
|
|
2948
|
+
}
|
|
2949
|
+
function Ft({ item: e, onCopyPath: t, onDownload: n, selectedCount: r, totalBytes: i }) {
|
|
2950
|
+
return e ? r > 1 ? /* @__PURE__ */ E("aside", {
|
|
2951
|
+
"aria-label": "Details",
|
|
2952
|
+
className: `hidden w-[var(--fb-panel-w)] shrink-0 border-l border-[var(--fb-border)] bg-[var(--fb-surface)] p-[var(--fb-panel-pad)] md:block ${Z}`,
|
|
2953
|
+
children: [
|
|
2954
|
+
/* @__PURE__ */ T("div", {
|
|
2955
|
+
className: `grid h-28 place-items-center rounded-[var(--fb-radius)] bg-[var(--fb-bg)] ${Z}`,
|
|
2956
|
+
children: /* @__PURE__ */ T(ce, { className: "size-12 text-[var(--fb-muted)]" })
|
|
2957
|
+
}),
|
|
2958
|
+
/* @__PURE__ */ E("h2", {
|
|
2959
|
+
className: "mt-4 text-[14px] font-semibold",
|
|
2960
|
+
children: [Zt(r), " selected"]
|
|
2961
|
+
}),
|
|
2962
|
+
/* @__PURE__ */ T("dl", {
|
|
2963
|
+
className: "mt-3 space-y-2 text-[12px]",
|
|
2964
|
+
children: /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("dt", {
|
|
2965
|
+
className: "text-[var(--fb-muted)]",
|
|
2966
|
+
children: "Total size"
|
|
2967
|
+
}), /* @__PURE__ */ T("dd", {
|
|
2968
|
+
className: "font-medium",
|
|
2969
|
+
children: Xt(i)
|
|
2970
|
+
})] })
|
|
2971
|
+
}),
|
|
2972
|
+
/* @__PURE__ */ E("button", {
|
|
2973
|
+
"aria-label": `Download ${Zt(r)}`,
|
|
2974
|
+
className: `${$(!1)} mt-4 w-full justify-center`,
|
|
2975
|
+
onClick: n,
|
|
2976
|
+
type: "button",
|
|
2977
|
+
children: [/* @__PURE__ */ T(L, { className: "size-4" }), "Download"]
|
|
2978
|
+
}),
|
|
2979
|
+
/* @__PURE__ */ E("button", {
|
|
2980
|
+
"aria-label": `Copy ${Zt(r)} paths`,
|
|
2981
|
+
className: `${$(!1)} mt-2 w-full justify-center`,
|
|
2982
|
+
onClick: t,
|
|
2983
|
+
type: "button",
|
|
2984
|
+
children: [/* @__PURE__ */ T(ce, { className: "size-4" }), "Copy paths"]
|
|
2985
|
+
})
|
|
2986
|
+
]
|
|
2987
|
+
}) : /* @__PURE__ */ E("aside", {
|
|
2988
|
+
"aria-label": "Details",
|
|
2989
|
+
className: `hidden w-72 shrink-0 border-l border-[var(--fb-border)] bg-[var(--fb-surface)] p-4 md:block ${Z}`,
|
|
2990
|
+
children: [
|
|
2991
|
+
/* @__PURE__ */ T("div", {
|
|
2992
|
+
className: `grid h-28 place-items-center rounded-[var(--fb-radius)] bg-[var(--fb-bg)] ${Z}`,
|
|
2993
|
+
children: e.kind === "folder" ? /* @__PURE__ */ T(z, { className: "size-12 text-[var(--fb-folder)]" }) : /* @__PURE__ */ T(R, { className: "size-12 text-[var(--fb-muted)]" })
|
|
2994
|
+
}),
|
|
2995
|
+
/* @__PURE__ */ T("h2", {
|
|
2996
|
+
className: "mt-4 truncate text-[14px] font-semibold",
|
|
2997
|
+
children: e.name
|
|
2998
|
+
}),
|
|
2999
|
+
/* @__PURE__ */ E("dl", {
|
|
3000
|
+
className: "mt-3 space-y-2 text-[12px]",
|
|
3001
|
+
children: [
|
|
3002
|
+
/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("dt", {
|
|
3003
|
+
className: "text-[var(--fb-muted)]",
|
|
3004
|
+
children: "Path"
|
|
3005
|
+
}), /* @__PURE__ */ T("dd", {
|
|
3006
|
+
className: "truncate font-medium",
|
|
3007
|
+
children: e.path
|
|
3008
|
+
})] }),
|
|
3009
|
+
/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("dt", {
|
|
3010
|
+
className: "text-[var(--fb-muted)]",
|
|
3011
|
+
children: "Type"
|
|
3012
|
+
}), /* @__PURE__ */ T("dd", {
|
|
3013
|
+
className: "font-medium",
|
|
3014
|
+
children: e.kind
|
|
3015
|
+
})] }),
|
|
3016
|
+
e.kind === "file" ? /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("dt", {
|
|
3017
|
+
className: "text-[var(--fb-muted)]",
|
|
3018
|
+
children: "Size"
|
|
3019
|
+
}), /* @__PURE__ */ T("dd", {
|
|
3020
|
+
className: "font-medium",
|
|
3021
|
+
children: Xt(e.size ?? 0)
|
|
3022
|
+
})] }) : null
|
|
3023
|
+
]
|
|
3024
|
+
}),
|
|
3025
|
+
/* @__PURE__ */ E("button", {
|
|
3026
|
+
"aria-label": `Download ${e.name}`,
|
|
3027
|
+
className: `${$(!1)} mt-4 w-full justify-center`,
|
|
3028
|
+
onClick: n,
|
|
3029
|
+
type: "button",
|
|
3030
|
+
children: [/* @__PURE__ */ T(L, { className: "size-4" }), "Download"]
|
|
3031
|
+
}),
|
|
3032
|
+
/* @__PURE__ */ E("button", {
|
|
3033
|
+
"aria-label": `Copy path of ${e.name}`,
|
|
3034
|
+
className: `${$(!1)} mt-2 w-full justify-center`,
|
|
3035
|
+
onClick: t,
|
|
3036
|
+
type: "button",
|
|
3037
|
+
children: [/* @__PURE__ */ T(ce, { className: "size-4" }), "Copy path"]
|
|
3038
|
+
})
|
|
3039
|
+
]
|
|
3040
|
+
}) : /* @__PURE__ */ T("aside", {
|
|
3041
|
+
"aria-label": "Details",
|
|
3042
|
+
className: `hidden w-[var(--fb-panel-w)] shrink-0 border-l border-[var(--fb-border)] bg-[var(--fb-surface)] p-[var(--fb-panel-pad)] md:flex ${Z}`,
|
|
3043
|
+
children: /* @__PURE__ */ E("div", {
|
|
3044
|
+
className: "flex min-h-full flex-1 flex-col items-center justify-center text-center",
|
|
3045
|
+
children: [/* @__PURE__ */ T("div", {
|
|
3046
|
+
className: `grid h-28 w-full place-items-center rounded-[var(--fb-radius)] bg-[var(--fb-bg)] ${Z}`,
|
|
3047
|
+
children: /* @__PURE__ */ T(_e, { className: "size-12 text-[var(--fb-muted)]" })
|
|
3048
|
+
}), /* @__PURE__ */ T("h2", {
|
|
3049
|
+
className: "mt-4 text-[14px] font-semibold",
|
|
3050
|
+
children: "No item selected"
|
|
3051
|
+
})]
|
|
3052
|
+
})
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
function It({ preview: e }) {
|
|
3056
|
+
return e.url ? /* @__PURE__ */ T("a", {
|
|
3057
|
+
"aria-label": `Open original ${e.item.name}`,
|
|
3058
|
+
className: `mt-4 inline-flex h-8 items-center rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] px-2.5 text-[12px] font-medium text-[var(--fb-accent)] outline-none hover:bg-[var(--fb-bg)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`,
|
|
3059
|
+
href: e.url,
|
|
3060
|
+
rel: "noreferrer",
|
|
3061
|
+
target: "_blank",
|
|
3062
|
+
children: "Open original"
|
|
3063
|
+
}) : null;
|
|
3064
|
+
}
|
|
3065
|
+
function Lt() {
|
|
3066
|
+
return /* @__PURE__ */ T("div", {
|
|
3067
|
+
"aria-label": "Files",
|
|
3068
|
+
className: "grid grid-cols-[repeat(auto-fill,minmax(var(--fb-card-min),1fr))] gap-[var(--fb-grid-gap)]",
|
|
3069
|
+
role: "grid",
|
|
3070
|
+
children: Array.from({ length: 8 }, (e, t) => /* @__PURE__ */ E("div", {
|
|
3071
|
+
className: `min-h-[var(--fb-card-minh)] animate-pulse rounded-[calc(var(--fb-radius)-1px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] p-[var(--fb-card-pad)] ${Z}`,
|
|
3072
|
+
children: [
|
|
3073
|
+
/* @__PURE__ */ T("div", { className: "h-[var(--fb-thumb-h)] rounded-[calc(var(--fb-radius)-3px)] bg-[var(--fb-surface-2)]" }),
|
|
3074
|
+
/* @__PURE__ */ T("div", { className: "mt-3 h-3 w-3/4 rounded bg-[var(--fb-surface-2)]" }),
|
|
3075
|
+
/* @__PURE__ */ T("div", { className: "mt-2 h-3 w-1/2 rounded bg-[var(--fb-surface-2)]" })
|
|
3076
|
+
]
|
|
3077
|
+
}, t))
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
function Rt({ title: e, value: t, tone: n }) {
|
|
3081
|
+
return /* @__PURE__ */ T("div", {
|
|
3082
|
+
className: `grid min-h-[280px] place-items-center rounded-[var(--fb-radius)] border border-dashed border-[var(--fb-border)] bg-[var(--fb-surface)] p-8 text-center ${Z}`,
|
|
3083
|
+
children: /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("div", {
|
|
3084
|
+
className: `font-semibold ${n === "danger" ? "text-[var(--fb-danger)]" : ""}`,
|
|
3085
|
+
children: e
|
|
3086
|
+
}), /* @__PURE__ */ T("div", {
|
|
3087
|
+
className: "mt-1 text-[12px] text-[var(--fb-muted)]",
|
|
3088
|
+
children: t
|
|
3089
|
+
})] })
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
function zt({ onDismiss: e, rejections: t }) {
|
|
3093
|
+
return /* @__PURE__ */ T("div", {
|
|
3094
|
+
"aria-label": "Upload rejected",
|
|
3095
|
+
className: "border-b border-[var(--fb-border)] bg-[var(--fb-danger-soft)] px-3 py-2 text-[12px] text-[var(--fb-text)]",
|
|
3096
|
+
role: "alert",
|
|
3097
|
+
children: /* @__PURE__ */ E("div", {
|
|
3098
|
+
className: "flex items-start gap-3",
|
|
3099
|
+
children: [/* @__PURE__ */ E("div", {
|
|
3100
|
+
className: "min-w-0 flex-1",
|
|
3101
|
+
children: [/* @__PURE__ */ T("div", {
|
|
3102
|
+
className: "font-semibold text-[var(--fb-danger)]",
|
|
3103
|
+
children: "Upload rejected"
|
|
3104
|
+
}), /* @__PURE__ */ T("ul", {
|
|
3105
|
+
className: "mt-1 space-y-1",
|
|
3106
|
+
children: t.map((e) => /* @__PURE__ */ E("li", {
|
|
3107
|
+
className: "min-w-0",
|
|
3108
|
+
children: [/* @__PURE__ */ T("span", {
|
|
3109
|
+
className: "font-medium",
|
|
3110
|
+
children: e.relativePath
|
|
3111
|
+
}), /* @__PURE__ */ E("span", {
|
|
3112
|
+
className: "text-[var(--fb-muted)]",
|
|
3113
|
+
children: [" ", e.reasons.join("; ")]
|
|
3114
|
+
})]
|
|
3115
|
+
}, e.relativePath))
|
|
3116
|
+
})]
|
|
3117
|
+
}), /* @__PURE__ */ T("button", {
|
|
3118
|
+
"aria-label": "Dismiss upload rejection",
|
|
3119
|
+
className: $(!1),
|
|
3120
|
+
onClick: e,
|
|
3121
|
+
type: "button",
|
|
3122
|
+
children: "Dismiss"
|
|
3123
|
+
})]
|
|
3124
|
+
})
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
function Bt(e, t, n, r) {
|
|
3128
|
+
"shiftKey" in n && n.shiftKey ? (r.cancelPendingSelectedItemUnselect(), e.selectRange(t)) : "metaKey" in n && (n.metaKey || n.ctrlKey) ? (r.cancelPendingSelectedItemUnselect(), e.toggleSelection(t)) : e.selectedPaths.length === 1 && e.selectedPaths[0] === t ? r.scheduleSelectedItemUnselect(t) : (r.cancelPendingSelectedItemUnselect(), e.selectOnly(t));
|
|
3129
|
+
}
|
|
3130
|
+
function Vt(e) {
|
|
3131
|
+
return !!("shiftKey" in e && (e.shiftKey || e.metaKey || e.ctrlKey));
|
|
3132
|
+
}
|
|
3133
|
+
function Ht(e) {
|
|
3134
|
+
return [
|
|
3135
|
+
"ArrowDown",
|
|
3136
|
+
"ArrowLeft",
|
|
3137
|
+
"ArrowRight",
|
|
3138
|
+
"ArrowUp",
|
|
3139
|
+
"End",
|
|
3140
|
+
"Home"
|
|
3141
|
+
].includes(e);
|
|
3142
|
+
}
|
|
3143
|
+
function Ut(e, t, n) {
|
|
3144
|
+
return e === "Home" ? 0 : e === "End" ? n - 1 : e === "ArrowUp" || e === "ArrowLeft" ? Math.max(0, t - 1) : Math.min(n - 1, t + 1);
|
|
3145
|
+
}
|
|
3146
|
+
function Wt(e) {
|
|
3147
|
+
return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
|
|
3148
|
+
}
|
|
3149
|
+
function Gt(e) {
|
|
3150
|
+
let t = e.getData(ut);
|
|
3151
|
+
if (!t) return [];
|
|
3152
|
+
try {
|
|
3153
|
+
let e = JSON.parse(t);
|
|
3154
|
+
return Array.isArray(e) ? e.filter((e) => typeof e == "string").map(a) : [];
|
|
3155
|
+
} catch {
|
|
3156
|
+
return [];
|
|
3157
|
+
}
|
|
3158
|
+
}
|
|
3159
|
+
function Kt(e) {
|
|
3160
|
+
return qt(e) ? {
|
|
3161
|
+
title: "Access denied",
|
|
3162
|
+
value: e?.message ?? "You do not have access to this folder."
|
|
3163
|
+
} : {
|
|
3164
|
+
title: "Could not load this folder",
|
|
3165
|
+
value: e?.message ?? "Unknown error"
|
|
3166
|
+
};
|
|
3167
|
+
}
|
|
3168
|
+
function qt(e) {
|
|
3169
|
+
if (!e) return !1;
|
|
3170
|
+
let t = e;
|
|
3171
|
+
return t.status === 403 || t.statusCode === 403 || t.code === "access_denied" || t.code === "forbidden" || t.code === "permission_denied";
|
|
3172
|
+
}
|
|
3173
|
+
function Jt(e) {
|
|
3174
|
+
return e instanceof Error ? e.message : String(e);
|
|
3175
|
+
}
|
|
3176
|
+
function Yt(e) {
|
|
3177
|
+
return e instanceof HTMLElement ? e.isContentEditable || [
|
|
3178
|
+
"INPUT",
|
|
3179
|
+
"SELECT",
|
|
3180
|
+
"TEXTAREA"
|
|
3181
|
+
].includes(e.tagName) : !1;
|
|
3182
|
+
}
|
|
3183
|
+
function Xt(e) {
|
|
3184
|
+
if (e < 1024) return `${e} B`;
|
|
3185
|
+
let t = e / 1024;
|
|
3186
|
+
return t < 1024 ? `${t.toFixed(1)} KB` : `${(t / 1024).toFixed(1)} MB`;
|
|
3187
|
+
}
|
|
3188
|
+
function Zt(e) {
|
|
3189
|
+
return `${e} ${e === 1 ? "item" : "items"}`;
|
|
3190
|
+
}
|
|
3191
|
+
function Qt({ currentPath: e, itemCount: t, selectedCount: n, status: r }) {
|
|
3192
|
+
return `${e === "/" ? "Files" : e.split("/").filter(Boolean).at(-1) ?? "Files"} ${r}. ${t} ${t === 1 ? "item" : "items"}. ${n} selected.`;
|
|
3193
|
+
}
|
|
3194
|
+
function $t(e) {
|
|
3195
|
+
return `inline-flex h-[var(--fb-control-h)] items-center justify-center gap-1 rounded-[calc(var(--fb-radius)-3px)] border px-2 text-[12px] font-medium outline-none focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X} ${e ? "border-[var(--fb-accent)] bg-[var(--fb-accent-soft)] text-[var(--fb-accent)]" : "border-[var(--fb-border)] bg-[var(--fb-surface)] text-[var(--fb-muted)] hover:bg-[var(--fb-bg)]"}`;
|
|
3196
|
+
}
|
|
3197
|
+
function $(e) {
|
|
3198
|
+
return `inline-flex h-[var(--fb-control-h)] items-center gap-1.5 rounded-[calc(var(--fb-radius)-3px)] border px-2.5 text-[12px] font-medium outline-none disabled:cursor-not-allowed disabled:opacity-45 focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X} ${e ? "border-[var(--fb-accent)] bg-[var(--fb-accent-soft)] text-[var(--fb-accent)]" : "border-[var(--fb-border)] bg-[var(--fb-surface)] text-[var(--fb-text)] hover:bg-[var(--fb-bg)]"}`;
|
|
3199
|
+
}
|
|
3200
|
+
function en() {
|
|
3201
|
+
return `inline-flex h-[var(--fb-control-h)] items-center gap-1.5 rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-accent)] bg-[var(--fb-accent)] px-2.5 text-[12px] font-semibold text-[var(--fb-surface)] outline-none hover:opacity-90 focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`;
|
|
3202
|
+
}
|
|
3203
|
+
function tn() {
|
|
3204
|
+
return `inline-flex h-[var(--fb-control-h)] items-center gap-1.5 rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-danger)] bg-[var(--fb-danger-soft)] px-2.5 text-[12px] font-medium text-[var(--fb-danger)] outline-none hover:bg-[var(--fb-danger-soft)] focus:ring-2 focus:ring-[var(--fb-danger-soft)] ${X}`;
|
|
3205
|
+
}
|
|
3206
|
+
function nn() {
|
|
3207
|
+
return `h-[var(--fb-control-h)] rounded-[calc(var(--fb-radius)-3px)] border border-[var(--fb-border)] bg-[var(--fb-surface)] px-2 text-[12px] font-medium text-[var(--fb-text)] outline-none focus:border-[var(--fb-accent)] focus:ring-2 focus:ring-[var(--fb-accent-soft)] ${X}`;
|
|
3208
|
+
}
|
|
3209
|
+
//#endregion
|
|
3210
|
+
export { l as FILE_BROWSER_THEME_CONTRACT, mt as FileBrowser, t as FileBrowserAdapterError, r as FileBrowserBulkActionError, Ue as FileBrowserProvider, c as ROOT_PATH, W as TransferManager, i as getFileBrowserBasename, u as getFileBrowserDensityAttributes, o as getFileBrowserDirname, n as isFileBrowserDescendantOrSelf, e as joinFileBrowserPath, a as normalizeFileBrowserPath, s as replaceFileBrowserPathPrefix, D as useFileBrowser, Ge as useTransferSnapshot, We as useTransfers };
|
|
3211
|
+
|
|
3212
|
+
//# sourceMappingURL=index.js.map
|