@floegence/floe-webapp-core 0.35.47 → 0.35.48

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.
@@ -1,428 +1,490 @@
1
- import { createComponent as yt } from "solid-js/web";
2
- import { createSignal as h, createEffect as S, createMemo as q, useContext as wt, createContext as xt, untrack as Ct } from "solid-js";
3
- import { createStore as fe, produce as me } from "solid-js/store";
4
- import { useResolvedFloeConfig as Pt } from "../../context/FloeConfigContext.js";
5
- import { deferAfterPaint as Rt, deferNonBlocking as w } from "../../utils/defer.js";
6
- const Pe = xt(), A = {
1
+ import { createComponent as Lt } from "solid-js/web";
2
+ import { createSignal as h, createEffect as S, createMemo as U, useContext as _t, createContext as Ot, untrack as Tt } from "solid-js";
3
+ import { createStore as pe, produce as Se } from "solid-js/store";
4
+ import { useResolvedFloeConfig as zt } from "../../context/FloeConfigContext.js";
5
+ import { deferAfterPaint as Dt, deferNonBlocking as E } from "../../utils/defer.js";
6
+ const Ee = Ot(), M = {
7
7
  name: 0.65,
8
8
  modifiedAt: 0.2,
9
9
  size: 0.15
10
- }, he = "fileBrowser:listColumnRatios", pe = 220, At = "fileBrowser:sidebarWidth", vt = 160, bt = 520, Se = "fileBrowser:viewMode", ge = "fileBrowser:sortConfig", Ie = "fileBrowser:expandedFolders", ye = "fileBrowser:sidebarCollapsed";
11
- function k(n, r) {
12
- const o = typeof n == "number" && Number.isFinite(n) ? n : r;
13
- return Math.max(vt, Math.min(bt, Math.round(o)));
10
+ }, ge = "fileBrowser:listColumnRatios", xe = 220, Nt = "fileBrowser:sidebarWidth", Wt = 160, qt = 520, ye = "fileBrowser:viewMode", we = "fileBrowser:sortConfig", Ce = "fileBrowser:expandedFolders", ve = "fileBrowser:sidebarCollapsed";
11
+ function G(o, c) {
12
+ const i = typeof o == "number" && Number.isFinite(o) ? o : c;
13
+ return Math.max(Wt, Math.min(qt, Math.round(i)));
14
14
  }
15
- function Et(n, r) {
16
- return n === "list" || n === "grid" ? n : r;
15
+ function Vt(o, c) {
16
+ return o === "list" || o === "grid" ? o : c;
17
17
  }
18
- function Ft(n, r) {
19
- if (!n || typeof n != "object") return r;
20
- const o = n, d = o.field, a = o.direction;
21
- return !(d === "name" || d === "size" || d === "modifiedAt" || d === "type") || !(a === "asc" || a === "desc") ? r : {
22
- field: d,
23
- direction: a
18
+ function kt(o, c) {
19
+ if (!o || typeof o != "object") return c;
20
+ const i = o, f = i.field, l = i.direction;
21
+ return !(f === "name" || f === "size" || f === "modifiedAt" || f === "type") || !(l === "asc" || l === "desc") ? c : {
22
+ field: f,
23
+ direction: l
24
24
  };
25
25
  }
26
- function Mt(n) {
27
- if (!Array.isArray(n)) return ["/"];
28
- const r = [], o = /* @__PURE__ */ new Set();
29
- for (const d of n) {
30
- if (typeof d != "string") continue;
31
- const a = d.trim();
32
- !a || o.has(a) || (o.add(a), r.push(a));
26
+ function Kt(o) {
27
+ if (!Array.isArray(o)) return ["/"];
28
+ const c = [], i = /* @__PURE__ */ new Set();
29
+ for (const f of o) {
30
+ if (typeof f != "string") continue;
31
+ const l = f.trim();
32
+ !l || i.has(l) || (i.add(l), c.push(l));
33
33
  }
34
- return o.has("/") || r.unshift("/"), r;
34
+ return i.has("/") || c.unshift("/"), c;
35
35
  }
36
- function Bt(n) {
37
- const r = [], o = /* @__PURE__ */ new Set();
38
- for (const d of n) {
39
- if (typeof d != "string") continue;
40
- const a = d.trim();
41
- !a || o.has(a) || (o.add(a), r.push(a));
36
+ function Ae(o) {
37
+ const c = [], i = /* @__PURE__ */ new Set();
38
+ for (const f of o) {
39
+ if (typeof f != "string") continue;
40
+ const l = f.trim();
41
+ !l || i.has(l) || (i.add(l), c.push(l));
42
42
  }
43
- return r;
43
+ return c;
44
44
  }
45
- function we(n) {
46
- const r = {};
47
- for (const o of n)
48
- r[o] = !0;
49
- return r;
45
+ function Re(o) {
46
+ const c = {};
47
+ for (const i of o)
48
+ c[i] = !0;
49
+ return c;
50
50
  }
51
- function Lt(n, r) {
52
- if (n.length !== r.length) return !1;
53
- for (let o = 0; o < n.length; o += 1)
54
- if (n[o] !== r[o]) return !1;
51
+ function X(o, c) {
52
+ if (o.length !== c.length) return !1;
53
+ for (let i = 0; i < o.length; i += 1)
54
+ if (o[i] !== c[i]) return !1;
55
55
  return !0;
56
56
  }
57
- function xe(n) {
58
- const r = Number.isFinite(n.name) ? n.name : A.name, o = Number.isFinite(n.modifiedAt) ? n.modifiedAt : A.modifiedAt, d = Number.isFinite(n.size) ? n.size : A.size, a = Math.max(0, r), f = Math.max(0, o), x = Math.max(0, d), I = a + f + x;
59
- return I <= 0 ? A : {
60
- name: a / I,
61
- modifiedAt: f / I,
62
- size: x / I
57
+ function Pe(o) {
58
+ const c = Number.isFinite(o.name) ? o.name : M.name, i = Number.isFinite(o.modifiedAt) ? o.modifiedAt : M.modifiedAt, f = Number.isFinite(o.size) ? o.size : M.size, l = Math.max(0, c), m = Math.max(0, i), v = Math.max(0, f), x = l + m + v;
59
+ return x <= 0 ? M : {
60
+ name: l / x,
61
+ modifiedAt: m / x,
62
+ size: v / x
63
63
  };
64
64
  }
65
- function Ce(n, r) {
66
- if (!r) return [];
67
- const o = [];
68
- let d = 0;
69
- for (const a of r) {
70
- const f = n.indexOf(a, d);
71
- if (f === -1) return null;
72
- o.push(f), d = f + 1;
65
+ function be(o, c) {
66
+ if (!c) return [];
67
+ const i = [];
68
+ let f = 0;
69
+ for (const l of c) {
70
+ const m = o.indexOf(l, f);
71
+ if (m === -1) return null;
72
+ i.push(m), f = m + 1;
73
73
  }
74
- return o;
74
+ return i;
75
75
  }
76
- function qt(n) {
77
- const r = Pt(), o = (e) => {
76
+ function $t(o) {
77
+ const c = zt(), i = (e) => {
78
78
  const t = (e ?? "").trim();
79
79
  return t === "" ? "/" : t;
80
- }, d = (n.persistenceKey ?? "").trim(), a = !!d, f = (e) => d ? `${d}:${e}` : e, x = a ? Et(r.persist.load(f(Se), n.initialViewMode ?? "list"), n.initialViewMode ?? "list") : n.initialViewMode ?? "list", I = {
80
+ }, f = (o.persistenceKey ?? "").trim(), l = !!f, m = (e) => f ? `${f}:${e}` : e, v = l ? Vt(c.persist.load(m(ye), o.initialViewMode ?? "list"), o.initialViewMode ?? "list") : o.initialViewMode ?? "list", x = {
81
81
  field: "name",
82
82
  direction: "asc"
83
- }, Re = a ? Ft(r.persist.load(f(ge), I), I) : I, K = a ? Mt(r.persist.load(f(Ie), ["/"])) : ["/"], Ae = a ? r.persist.load(f(ye), !1) === !0 : !1, ve = () => typeof n.path == "string" ? o(n.path) : o(n.initialPath ?? "/"), [C, U] = h(ve()), [V, be] = fe({}), [v, Ee] = h([]), [G, Fe] = h(x), [M, Me] = h(Re), Be = xe(r.persist.load(he, n.initialListColumnRatios ?? A)), [X, Le] = h(Be), Y = (n.sidebarWidthStorageKey ?? "").trim() || At, _e = k(r.persist.load(Y, n.initialSidebarWidth ?? pe), n.initialSidebarWidth ?? pe), [B, Oe] = h(_e), [L, j] = fe(we(K)), [Q, H] = h(K), [$, Te] = h(Ae), [ze, J] = h(null), [Z, _] = h(""), [O, b] = h(""), [De, T] = h(!1), [z, ee] = h(null);
84
- let D = 0;
83
+ }, Me = l ? kt(c.persist.load(m(we), x), x) : x, Y = l ? Kt(c.persist.load(m(Ce), ["/"])) : ["/"], Be = l ? c.persist.load(m(ve), !1) === !0 : !1, Fe = () => typeof o.path == "string" ? i(o.path) : i(o.initialPath ?? "/"), [A, j] = h(Fe()), [F, Le] = pe({}), [y, _e] = h([]), [R, Oe] = h(null), [L, Q] = h(null), [H, Te] = h(v), [_, ze] = h(Me), De = Pe(c.persist.load(ge, o.initialListColumnRatios ?? M)), [$, Ne] = h(De), J = (o.sidebarWidthStorageKey ?? "").trim() || Nt, We = G(c.persist.load(J, o.initialSidebarWidth ?? xe), o.initialSidebarWidth ?? xe), [O, qe] = h(We), [T, Z] = pe(Re(Y)), [ee, te] = h(Y), [ne, Ve] = h(Be), [ke, oe] = h(null), [se, z] = h(""), [D, B] = h(""), [Ke, N] = h(!1), [W, re] = h(null);
84
+ let q = 0;
85
85
  S(() => {
86
- const e = Z().trim();
87
- D += 1;
88
- const t = D;
86
+ const e = se().trim();
87
+ q += 1;
88
+ const t = q;
89
89
  if (!e) {
90
- b("");
90
+ B("");
91
91
  return;
92
92
  }
93
- Rt(() => {
94
- t === D && b(e);
93
+ Dt(() => {
94
+ t === q && B(e);
95
95
  });
96
96
  }), S(() => {
97
- r.persist.debouncedSave(he, X());
97
+ c.persist.debouncedSave(ge, $());
98
98
  }), S(() => {
99
- r.persist.debouncedSave(Y, B());
99
+ c.persist.debouncedSave(J, O());
100
100
  }), S(() => {
101
- a && r.persist.debouncedSave(f(Se), G());
101
+ l && c.persist.debouncedSave(m(ye), H());
102
102
  }), S(() => {
103
- a && r.persist.debouncedSave(f(ge), M());
103
+ l && c.persist.debouncedSave(m(we), _());
104
104
  }), S(() => {
105
- if (!a) return;
106
- const e = [...Q()].sort((t, i) => t.localeCompare(i));
107
- r.persist.debouncedSave(f(Ie), e);
105
+ if (!l) return;
106
+ const e = [...ee()].sort((t, n) => t.localeCompare(n));
107
+ c.persist.debouncedSave(m(Ce), e);
108
108
  }), S(() => {
109
- a && r.persist.debouncedSave(f(ye), $());
109
+ l && c.persist.debouncedSave(m(ve), ne());
110
110
  }), S(() => {
111
- const e = n.revealRequest ?? null;
112
- ee(e);
111
+ const e = o.revealRequest ?? null;
112
+ re(e);
113
113
  });
114
- const Ne = (e) => Fe(e), We = (e) => Me(e), qe = (e) => k(e, B()), ke = () => n.homeLabel ?? "Root", Ke = () => new Set(v()), Ue = () => new Set(Q()), E = (e) => {
115
- const t = Bt(e), i = we(t);
116
- be(me((s) => {
117
- for (const c of Object.keys(s))
118
- c in i || delete s[c];
119
- for (const c of t)
120
- s[c] = !0;
121
- })), Ee((s) => Lt(s, t) ? s : t);
122
- }, te = (e) => {
123
- L[e] !== !0 && (j(e, !0), H((t) => t.includes(e) ? t : [...t, e]));
124
- }, Ve = (e) => {
125
- if (L[e] === !0) {
126
- j(me((t) => {
114
+ const Ue = (e) => Te(e), Ge = (e) => ze(e), Xe = (e) => G(e, O()), Ye = () => o.homeLabel ?? "Root", je = () => new Set(y()), Qe = () => new Set(ee()), He = (e) => {
115
+ const t = Ae(e), n = Re(t);
116
+ Le(Se((s) => {
117
+ for (const r of Object.keys(s))
118
+ r in n || delete s[r];
119
+ for (const r of t)
120
+ s[r] = !0;
121
+ })), _e((s) => X(s, t) ? s : t);
122
+ }, ie = (e) => {
123
+ T[e] !== !0 && (Z(e, !0), te((t) => t.includes(e) ? t : [...t, e]));
124
+ }, $e = (e) => {
125
+ if (T[e] === !0) {
126
+ Z(Se((t) => {
127
127
  delete t[e];
128
- })), H((t) => t.filter((i) => i !== e));
128
+ })), te((t) => t.filter((n) => n !== e));
129
129
  return;
130
130
  }
131
- te(e);
132
- }, [ne, P] = h([]);
133
- let y = null, N = {
131
+ ie(e);
132
+ }, [ce, P] = h([]);
133
+ let w = null, V = {
134
134
  top: 0,
135
135
  left: 0
136
136
  };
137
- const oe = () => n.files, ie = (e) => {
138
- const t = o(e);
137
+ const ae = () => o.files, le = (e) => {
138
+ const t = i(e);
139
139
  if (t === "/") return "/";
140
- const i = t.split("/").filter(Boolean);
141
- return i.pop(), i.length ? "/" + i.join("/") : "/";
142
- }, Ge = (e, t) => {
143
- const i = ne();
144
- if (i.length === 0) return e;
140
+ const n = t.split("/").filter(Boolean);
141
+ return n.pop(), n.length ? "/" + n.join("/") : "/";
142
+ }, Je = (e, t) => {
143
+ const n = ce();
144
+ if (n.length === 0) return e;
145
145
  let s = [...e];
146
- const c = o(t);
147
- for (const l of i)
148
- switch (l.type) {
146
+ const r = i(t);
147
+ for (const a of n)
148
+ switch (a.type) {
149
149
  case "remove": {
150
- const m = new Set(l.paths.map(o));
151
- s = s.filter((u) => !m.has(o(u.path)));
150
+ const u = new Set(a.paths.map(i));
151
+ s = s.filter((d) => !u.has(i(d.path)));
152
152
  break;
153
153
  }
154
154
  case "update": {
155
- const m = o(l.oldPath), u = s.findIndex((g) => o(g.path) === m);
156
- if (u !== -1) {
157
- const g = l.updates.path ?? s[u].path;
158
- ie(g) === c ? s[u] = {
159
- ...s[u],
160
- ...l.updates
161
- } : s.splice(u, 1);
155
+ const u = i(a.oldPath), d = s.findIndex((p) => i(p.path) === u);
156
+ if (d !== -1) {
157
+ const p = a.updates.path ?? s[d].path;
158
+ le(p) === r ? s[d] = {
159
+ ...s[d],
160
+ ...a.updates
161
+ } : s.splice(d, 1);
162
162
  } else {
163
- const g = l.updates.path;
164
- g && ie(g);
163
+ const p = a.updates.path;
164
+ p && le(p);
165
165
  }
166
166
  break;
167
167
  }
168
168
  case "insert": {
169
- o(l.parentPath) === c && (s.some((u) => o(u.path) === o(l.item.path)) || s.push(l.item));
169
+ i(a.parentPath) === r && (s.some((d) => i(d.path) === i(a.item.path)) || s.push(a.item));
170
170
  break;
171
171
  }
172
172
  }
173
173
  return s;
174
- }, Xe = q(() => {
174
+ }, Ze = U(() => {
175
175
  const e = /* @__PURE__ */ new Map(), t = (s) => {
176
- for (const c of s)
177
- c.type === "folder" && (e.set(o(c.path), c.children ?? []), c.children?.length && t(c.children));
178
- }, i = oe();
179
- return e.set("/", i), t(i), e;
180
- }), se = q(() => {
181
- const e = o(C());
182
- let t = Xe().get(e) ?? [];
183
- t = Ge(t, e);
184
- const i = M(), s = [...t].sort((l, m) => {
185
- if (l.type !== m.type) return l.type === "folder" ? -1 : 1;
186
- let u = 0;
187
- switch (i.field) {
176
+ for (const r of s)
177
+ r.type === "folder" && (e.set(i(r.path), r.children ?? []), r.children?.length && t(r.children));
178
+ }, n = ae();
179
+ return e.set("/", n), t(n), e;
180
+ }), k = U(() => {
181
+ const e = i(A());
182
+ let t = Ze().get(e) ?? [];
183
+ t = Je(t, e);
184
+ const n = _(), s = [...t].sort((a, u) => {
185
+ if (a.type !== u.type) return a.type === "folder" ? -1 : 1;
186
+ let d = 0;
187
+ switch (n.field) {
188
188
  case "name":
189
- u = l.name.localeCompare(m.name);
189
+ d = a.name.localeCompare(u.name);
190
190
  break;
191
191
  case "size":
192
- u = (l.size ?? 0) - (m.size ?? 0);
192
+ d = (a.size ?? 0) - (u.size ?? 0);
193
193
  break;
194
194
  case "modifiedAt":
195
- u = (l.modifiedAt?.getTime() ?? 0) - (m.modifiedAt?.getTime() ?? 0);
195
+ d = (a.modifiedAt?.getTime() ?? 0) - (u.modifiedAt?.getTime() ?? 0);
196
196
  break;
197
197
  case "type":
198
- u = (l.extension ?? "").localeCompare(m.extension ?? "");
198
+ d = (a.extension ?? "").localeCompare(u.extension ?? "");
199
199
  break;
200
200
  }
201
- return i.direction === "asc" ? u : -u;
202
- }), c = /* @__PURE__ */ new Map();
203
- for (const l of s)
204
- c.set(l.id, l.name.toLowerCase());
201
+ return n.direction === "asc" ? d : -d;
202
+ }), r = /* @__PURE__ */ new Map();
203
+ for (const a of s)
204
+ r.set(a.id, a.name.toLowerCase());
205
205
  return {
206
206
  items: s,
207
- nameLowerById: c
207
+ nameLowerById: r
208
208
  };
209
- }), F = q(() => {
209
+ }), C = U(() => {
210
210
  const {
211
211
  items: e,
212
212
  nameLowerById: t
213
- } = se(), s = O().trim().toLowerCase(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
213
+ } = k(), s = D().trim().toLowerCase(), r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
214
214
  if (!s) {
215
- for (let p = 0; p < e.length; p++) {
216
- const R = e[p];
217
- l.set(R.id, R), m.set(R.id, p);
215
+ for (let I = 0; I < e.length; I++) {
216
+ const b = e[I];
217
+ a.set(b.id, b), u.set(b.id, I);
218
218
  }
219
219
  return {
220
220
  items: e,
221
- matchById: c,
222
- fileById: l,
223
- indexById: m
221
+ matchById: r,
222
+ fileById: a,
223
+ indexById: u
224
224
  };
225
225
  }
226
- const u = [];
227
- let g = 0;
228
- for (const p of e) {
229
- const R = t.get(p.id) ?? p.name.toLowerCase(), ue = Ce(R, s);
230
- ue && (u.push(p), c.set(p.id, {
231
- matchedIndices: ue
232
- }), l.set(p.id, p), m.set(p.id, g), g += 1);
226
+ const d = [];
227
+ let p = 0;
228
+ for (const I of e) {
229
+ const b = t.get(I.id) ?? I.name.toLowerCase(), Ie = be(b, s);
230
+ Ie && (d.push(I), r.set(I.id, {
231
+ matchedIndices: Ie
232
+ }), a.set(I.id, I), u.set(I.id, p), p += 1);
233
233
  }
234
234
  return {
235
- items: u,
236
- matchById: c,
237
- fileById: l,
238
- indexById: m
235
+ items: d,
236
+ matchById: r,
237
+ fileById: a,
238
+ indexById: u
239
239
  };
240
- }), Ye = () => F().items;
240
+ }), et = () => C().items;
241
241
  S(() => {
242
- const e = z();
243
- !e || e.clearFilter !== "if-needed" || F().fileById.has(e.targetId) || !se().items.some((s) => s.id === e.targetId) || (_(""), b(""), T(!1));
242
+ const e = W();
243
+ !e || e.clearFilter !== "if-needed" || C().fileById.has(e.targetId) || !k().items.some((s) => s.id === e.targetId) || (z(""), B(""), N(!1));
244
244
  });
245
- const re = (e) => {
246
- const t = F(), i = [];
245
+ const de = (e) => {
246
+ const t = C(), n = [];
247
247
  for (const s of e) {
248
- const c = t.fileById.get(s);
249
- if (!c) continue;
250
- const l = t.indexById.get(s);
251
- i.push({
252
- index: l ?? Number.MAX_SAFE_INTEGER,
253
- item: c
248
+ const r = t.fileById.get(s);
249
+ if (!r) continue;
250
+ const a = t.indexById.get(s);
251
+ n.push({
252
+ index: a ?? Number.MAX_SAFE_INTEGER,
253
+ item: r
254
254
  });
255
255
  }
256
- return i.sort((s, c) => s.index - c.index), i.map((s) => s.item);
257
- }, ce = () => {
258
- E([]), _(""), b(""), T(!1);
259
- const e = n.onSelect;
260
- w(() => e?.([]));
256
+ return n.sort((s, r) => s.index - r.index), n.map((s) => s.item);
257
+ }, tt = (e) => {
258
+ const t = o.onSelect;
259
+ if (!t) return;
260
+ const n = [...e];
261
+ E(() => {
262
+ const s = Tt(() => de(n));
263
+ t(s);
264
+ });
265
+ }, g = (e, t = {}) => {
266
+ const n = Ae(e), r = (t.preserveAnchor === !0 ? R() : void 0) ?? (t.anchorId !== void 0 ? t.anchorId : n[0] ?? null), a = t.lastInteractedId !== void 0 ? t.lastInteractedId : n[n.length - 1] ?? null, u = !X(y(), n), d = R() !== r, p = L() !== a;
267
+ !u && !d && !p || (He(n), Oe(r), Q(a), u && tt(n));
268
+ }, nt = (e, t) => {
269
+ const n = C(), s = n.indexById.get(e), r = n.indexById.get(t);
270
+ if (s === void 0 || r === void 0) return [];
271
+ const a = Math.min(s, r), u = Math.max(s, r);
272
+ return n.items.slice(a, u + 1).map((d) => d.id);
273
+ }, ot = () => {
274
+ const e = R();
275
+ return e && C().indexById.has(e) ? e : null;
276
+ }, ue = () => {
277
+ g([], {
278
+ anchorId: null,
279
+ lastInteractedId: null
280
+ }), z(""), B(""), N(!1);
261
281
  };
262
282
  S(() => {
263
- if (typeof n.path != "string") return;
264
- const e = o(n.path);
265
- e !== C() && (U(e), ce());
283
+ if (typeof o.path != "string") return;
284
+ const e = i(o.path);
285
+ e !== A() && (j(e), ue());
266
286
  });
267
- const W = (e) => {
268
- const t = o(e);
269
- if (t === C()) return;
270
- U(t), ce();
271
- const i = n.onNavigate;
272
- w(() => i?.(t));
273
- const s = n.onPathChange;
274
- w(() => s?.(t, "user"));
275
- }, je = (e) => {
276
- Le(xe(e));
277
- }, Qe = () => {
278
- const e = C();
287
+ const K = (e) => {
288
+ const t = i(e);
289
+ if (t === A()) return;
290
+ j(t), ue();
291
+ const n = o.onNavigate;
292
+ E(() => n?.(t));
293
+ const s = o.onPathChange;
294
+ E(() => s?.(t, "user"));
295
+ }, st = (e) => {
296
+ Ne(Pe(e));
297
+ }, rt = () => {
298
+ const e = A();
279
299
  if (e === "/" || e === "") return;
280
300
  const t = e.split("/").filter(Boolean);
281
- t.pop(), W(t.length ? "/" + t.join("/") : "/");
282
- }, le = (e) => {
283
- e.type === "folder" && (W(e.path), te(e.path));
284
- }, He = (e, t = !1) => {
285
- const i = t ? V[e] === !0 ? v().filter((c) => c !== e) : [...v(), e] : [e];
286
- E(i);
287
- const s = n.onSelect;
288
- if (s) {
289
- const c = [...i];
290
- w(() => {
291
- const l = Ct(() => re(c));
292
- s(l);
301
+ t.pop(), K(t.length ? "/" + t.join("/") : "/");
302
+ }, fe = (e) => {
303
+ e.type === "folder" && (K(e.path), ie(e.path));
304
+ }, it = (e, t = !1) => {
305
+ const n = t ? F[e] === !0 ? y().filter((s) => s !== e) : [...y(), e] : [e];
306
+ g(n, {
307
+ anchorId: e,
308
+ lastInteractedId: e
309
+ });
310
+ }, ct = (e, t = !1) => {
311
+ const n = ot();
312
+ if (!n) {
313
+ g([e], {
314
+ anchorId: e,
315
+ lastInteractedId: e
316
+ });
317
+ return;
318
+ }
319
+ const s = nt(n, e);
320
+ if (s.length === 0) {
321
+ g([e], {
322
+ anchorId: e,
323
+ lastInteractedId: e
293
324
  });
325
+ return;
326
+ }
327
+ const r = t ? [...y(), ...s] : s;
328
+ g(r, {
329
+ anchorId: n,
330
+ lastInteractedId: e
331
+ });
332
+ }, at = (e, t = {}) => {
333
+ g(e, t);
334
+ }, lt = (e) => {
335
+ if (F[e] === !0) {
336
+ Q(e);
337
+ return;
294
338
  }
295
- }, $e = () => {
296
- E([]);
297
- const e = n.onSelect;
298
- w(() => e?.([]));
299
- }, Je = (e) => V[e] === !0, Ze = (e) => Ve(e), et = (e) => L[e] === !0, tt = () => Te((e) => !e), nt = (e) => {
300
- Oe((t) => k(e, t));
301
- }, ot = (e) => J(e), it = () => J(null), st = (e) => {
302
- _(e);
303
- }, rt = (e) => {
304
- const t = O().trim();
339
+ g([e], {
340
+ anchorId: e,
341
+ lastInteractedId: e
342
+ });
343
+ }, dt = () => {
344
+ g([], {
345
+ anchorId: null,
346
+ lastInteractedId: null
347
+ });
348
+ }, ut = (e) => F[e] === !0, ft = (e) => $e(e), mt = (e) => T[e] === !0, ht = () => Ve((e) => !e), It = (e) => {
349
+ qe((t) => G(e, t));
350
+ }, pt = (e) => oe(e), St = () => oe(null), gt = (e) => {
351
+ z(e);
352
+ }, xt = (e) => {
353
+ const t = D().trim();
305
354
  if (!t) return null;
306
- const i = Ce(e.toLowerCase(), t.toLowerCase());
307
- return i ? {
308
- matchedIndices: i
355
+ const n = be(e.toLowerCase(), t.toLowerCase());
356
+ return n ? {
357
+ matchedIndices: n
309
358
  } : null;
310
- }, ct = (e) => F().matchById.get(e) ?? null, lt = () => re(v()), at = (e) => {
311
- const t = z();
359
+ }, yt = (e) => C().matchById.get(e) ?? null, wt = () => de(y());
360
+ S(() => {
361
+ const e = new Set(k().items.map((d) => d.id)), t = y(), n = t.filter((d) => e.has(d)), s = R(), r = L(), a = s && e.has(s) ? s : n[0] ?? null, u = r && e.has(r) ? r : n[n.length - 1] ?? null;
362
+ X(t, n) && s === a && r === u || g(n, {
363
+ anchorId: a,
364
+ lastInteractedId: u
365
+ });
366
+ });
367
+ const Ct = (e) => {
368
+ const t = W();
312
369
  if (!t || t.requestId !== e) return;
313
- ee(null);
314
- const i = n.onRevealRequestConsumed;
315
- w(() => i?.(e));
316
- }, dt = (e) => {
370
+ re(null);
371
+ const n = o.onRevealRequestConsumed;
372
+ E(() => n?.(e));
373
+ }, vt = (e) => {
317
374
  if (e.type === "folder")
318
- le(e);
375
+ fe(e);
319
376
  else {
320
- const t = n.onOpen;
321
- w(() => t?.(e));
377
+ const t = o.onOpen;
378
+ E(() => t?.(e));
322
379
  }
323
- }, ut = (e) => {
380
+ }, At = (e) => {
324
381
  e.length !== 0 && P((t) => [...t, {
325
382
  type: "remove",
326
383
  paths: e
327
384
  }]);
328
- }, ft = (e, t) => {
329
- P((i) => [...i, {
385
+ }, Rt = (e, t) => {
386
+ P((n) => [...n, {
330
387
  type: "update",
331
388
  oldPath: e,
332
389
  updates: t
333
390
  }]);
334
- }, mt = (e, t) => {
335
- P((i) => [...i, {
391
+ }, Pt = (e, t) => {
392
+ P((n) => [...n, {
336
393
  type: "insert",
337
394
  parentPath: e,
338
395
  item: t
339
396
  }]);
340
- }, ht = () => {
397
+ }, bt = () => {
341
398
  P([]);
342
- }, pt = () => {
399
+ }, Et = () => {
343
400
  P([]);
344
- }, St = () => ne().length > 0, gt = (e) => {
345
- y = e;
346
- }, ae = () => y ? {
347
- top: y.scrollTop,
348
- left: y.scrollLeft
401
+ }, Mt = () => ce().length > 0, Bt = (e) => {
402
+ w = e;
403
+ }, me = () => w ? {
404
+ top: w.scrollTop,
405
+ left: w.scrollLeft
349
406
  } : {
350
407
  top: 0,
351
408
  left: 0
352
- }, de = (e) => {
353
- y && (y.scrollTop = e.top, y.scrollLeft = e.left);
354
- }, It = {
355
- currentPath: C,
356
- setCurrentPath: W,
357
- navigateUp: Qe,
358
- navigateTo: le,
359
- homeLabel: ke,
360
- selectedItems: Ke,
361
- selectItem: He,
362
- clearSelection: $e,
363
- isSelected: Je,
364
- getSelectedItemsList: lt,
365
- viewMode: G,
366
- setViewMode: Ne,
367
- sortConfig: M,
368
- setSortConfig: We,
369
- listColumnRatios: X,
370
- setListColumnRatios: je,
371
- expandedFolders: Ue,
372
- toggleFolder: Ze,
373
- isExpanded: et,
374
- files: oe,
375
- currentFiles: Ye,
376
- filterQuery: Z,
377
- setFilterQuery: st,
378
- filterQueryApplied: O,
379
- isFilterActive: De,
380
- setFilterActive: T,
381
- getFilterMatch: rt,
382
- getFilterMatchForId: ct,
383
- sidebarCollapsed: $,
384
- toggleSidebar: tt,
385
- sidebarWidth: B,
386
- clampSidebarWidth: qe,
387
- setSidebarWidth: nt,
388
- contextMenu: ze,
389
- showContextMenu: ot,
390
- hideContextMenu: it,
391
- openItem: dt,
392
- revealRequest: z,
393
- consumeRevealRequest: at,
409
+ }, he = (e) => {
410
+ w && (w.scrollTop = e.top, w.scrollLeft = e.left);
411
+ }, Ft = {
412
+ currentPath: A,
413
+ setCurrentPath: K,
414
+ navigateUp: rt,
415
+ navigateTo: fe,
416
+ homeLabel: Ye,
417
+ selectedItems: je,
418
+ selectionAnchorId: R,
419
+ lastInteractedId: L,
420
+ selectItem: it,
421
+ selectRangeTo: ct,
422
+ replaceSelection: at,
423
+ ensureContextMenuSelection: lt,
424
+ clearSelection: dt,
425
+ isSelected: ut,
426
+ getSelectedItemsList: wt,
427
+ viewMode: H,
428
+ setViewMode: Ue,
429
+ sortConfig: _,
430
+ setSortConfig: Ge,
431
+ listColumnRatios: $,
432
+ setListColumnRatios: st,
433
+ expandedFolders: Qe,
434
+ toggleFolder: ft,
435
+ isExpanded: mt,
436
+ files: ae,
437
+ currentFiles: et,
438
+ filterQuery: se,
439
+ setFilterQuery: gt,
440
+ filterQueryApplied: D,
441
+ isFilterActive: Ke,
442
+ setFilterActive: N,
443
+ getFilterMatch: xt,
444
+ getFilterMatchForId: yt,
445
+ sidebarCollapsed: ne,
446
+ toggleSidebar: ht,
447
+ sidebarWidth: O,
448
+ clampSidebarWidth: Xe,
449
+ setSidebarWidth: It,
450
+ contextMenu: ke,
451
+ showContextMenu: pt,
452
+ hideContextMenu: St,
453
+ openItem: vt,
454
+ revealRequest: W,
455
+ consumeRevealRequest: Ct,
394
456
  // Optimistic updates
395
- optimisticRemove: ut,
396
- optimisticUpdate: ft,
397
- optimisticInsert: mt,
398
- clearOptimisticUpdates: ht,
399
- rollbackOptimisticUpdates: pt,
400
- hasOptimisticUpdates: St,
457
+ optimisticRemove: At,
458
+ optimisticUpdate: Rt,
459
+ optimisticInsert: Pt,
460
+ clearOptimisticUpdates: bt,
461
+ rollbackOptimisticUpdates: Et,
462
+ hasOptimisticUpdates: Mt,
401
463
  // Scroll position management
402
- setScrollContainer: gt,
403
- getScrollPosition: ae,
404
- setScrollPosition: de,
405
- saveScrollPosition: () => (N = ae(), N),
464
+ setScrollContainer: Bt,
465
+ getScrollPosition: me,
466
+ setScrollPosition: he,
467
+ saveScrollPosition: () => (V = me(), V),
406
468
  restoreScrollPosition: () => {
407
469
  requestAnimationFrame(() => {
408
- de(N);
470
+ he(V);
409
471
  });
410
472
  }
411
473
  };
412
- return yt(Pe.Provider, {
413
- value: It,
474
+ return Lt(Ee.Provider, {
475
+ value: Ft,
414
476
  get children() {
415
- return n.children;
477
+ return o.children;
416
478
  }
417
479
  });
418
480
  }
419
- function kt() {
420
- const n = wt(Pe);
421
- if (!n)
481
+ function Jt() {
482
+ const o = _t(Ee);
483
+ if (!o)
422
484
  throw new Error("useFileBrowser must be used within a FileBrowserProvider");
423
- return n;
485
+ return o;
424
486
  }
425
487
  export {
426
- qt as FileBrowserProvider,
427
- kt as useFileBrowser
488
+ $t as FileBrowserProvider,
489
+ Jt as useFileBrowser
428
490
  };