@rpcbase/ui 0.263.0 → 0.264.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index299.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { cn as e } from "./index12.js";
2
- import { Image as t } from "./index297.js";
3
- import n from "./index298.js";
4
- import { c as r } from "react/compiler-runtime";
5
- import { useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
6
- import { Loader2 as c, Maximize2 as ee, Plus as l, X as te } from "lucide-react";
7
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
8
- import { createPortal as ne } from "react-dom";
9
- import { DndContext as p, DragOverlay as m, KeyboardSensor as re, PointerSensor as h, closestCenter as g, defaultDropAnimationSideEffects as _, useSensor as ie, useSensors as ae } from "@dnd-kit/core";
10
- import { SortableContext as v, arrayMove as y, rectSortingStrategy as oe, sortableKeyboardCoordinates as b, useSortable as x } from "@dnd-kit/sortable";
11
- import { CSS as S } from "@dnd-kit/utilities";
2
+ import { Image as t, getImageSrcSet as n, isRpcbaseFileImageSrc as r, withImageWidth as i } from "./index297.js";
3
+ import a from "./index298.js";
4
+ import { c as o } from "react/compiler-runtime";
5
+ import { useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
6
+ import { Loader2 as d, Maximize2 as f, Plus as p, X as ee } from "lucide-react";
7
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
8
+ import { createPortal as te } from "react-dom";
9
+ import { DndContext as _, DragOverlay as v, KeyboardSensor as ne, PointerSensor as re, closestCenter as ie, defaultDropAnimationSideEffects as y, useSensor as b, useSensors as ae } from "@dnd-kit/core";
10
+ import { SortableContext as x, arrayMove as oe, rectSortingStrategy as se, sortableKeyboardCoordinates as ce, useSortable as S } from "@dnd-kit/sortable";
11
+ import { CSS as le } from "@dnd-kit/utilities";
12
12
  //#region src/components/FilesUploadField/index.tsx
13
- var se = async (e) => {
13
+ var C = async (e) => {
14
14
  if (typeof crypto > "u" || crypto.subtle === void 0) return null;
15
15
  try {
16
16
  let t = await crypto.subtle.digest("SHA-256", e);
@@ -18,31 +18,31 @@ var se = async (e) => {
18
18
  } catch {
19
19
  return null;
20
20
  }
21
- }, C = async (e, t) => {
21
+ }, w = async (e, t) => {
22
22
  if (typeof Worker > "u") throw Error("File hashing is not supported in this browser");
23
- return new Promise((r, i) => {
24
- let a = new n(), o = () => {
25
- t?.removeEventListener("abort", s), a.terminate();
23
+ return new Promise((n, r) => {
24
+ let i = new a(), o = () => {
25
+ t?.removeEventListener("abort", s), i.terminate();
26
26
  }, s = () => {
27
27
  o();
28
28
  let e = /* @__PURE__ */ Error("Upload aborted");
29
- e.name = "AbortError", i(e);
29
+ e.name = "AbortError", r(e);
30
30
  };
31
31
  if (t?.aborted) {
32
32
  s();
33
33
  return;
34
34
  }
35
- t?.addEventListener("abort", s, { once: !0 }), a.onerror = () => {
36
- o(), i(/* @__PURE__ */ Error("Unable to hash file"));
37
- }, a.onmessage = (e) => {
35
+ t?.addEventListener("abort", s, { once: !0 }), i.onerror = () => {
36
+ o(), r(/* @__PURE__ */ Error("Unable to hash file"));
37
+ }, i.onmessage = (e) => {
38
38
  if (o(), e.data.ok) {
39
- r(e.data.hash);
39
+ n(e.data.hash);
40
40
  return;
41
41
  }
42
- i(/* @__PURE__ */ Error(e.data.error === "hash_unavailable" ? "File hashing is not supported in this browser" : "Unable to hash file"));
43
- }, a.postMessage(e);
42
+ r(/* @__PURE__ */ Error(e.data.error === "hash_unavailable" ? "File hashing is not supported in this browser" : "Unable to hash file"));
43
+ }, i.postMessage(e);
44
44
  });
45
- }, w = async (e, t, n) => {
45
+ }, T = async (e, t, n) => {
46
46
  let r = await fetch(e, {
47
47
  method: "POST",
48
48
  headers: {
@@ -58,7 +58,7 @@ var se = async (e) => {
58
58
  status: r.status,
59
59
  data: i
60
60
  };
61
- }, T = async (e, t) => {
61
+ }, E = async (e, t) => {
62
62
  let n = await fetch(e, {
63
63
  credentials: "include",
64
64
  headers: t?.headers,
@@ -69,7 +69,7 @@ var se = async (e) => {
69
69
  status: n.status,
70
70
  data: r
71
71
  };
72
- }, E = async ({ url: e, body: t, sha256: n, uploadKey: r, signal: i }) => {
72
+ }, D = async ({ url: e, body: t, sha256: n, uploadKey: r, signal: i }) => {
73
73
  let a = { "Content-Type": "application/octet-stream" };
74
74
  n && (a["X-Chunk-SHA256"] = n), r && (a["X-Upload-Key"] = r);
75
75
  let o = await fetch(e, {
@@ -83,8 +83,8 @@ var se = async (e) => {
83
83
  ok: o.ok,
84
84
  status: o.status
85
85
  };
86
- }, ce = async (e, t, n) => {
87
- let r = n?.deduplicationNamespace?.trim(), i = r ? await C(e, n?.signal) : null, a = await w("/api/rb/file-uploads", {
86
+ }, ue = async (e, t, n) => {
87
+ let r = n?.deduplicationNamespace?.trim(), i = r ? await w(e, n?.signal) : null, a = await T("/api/rb/file-uploads", {
88
88
  filename: e.name,
89
89
  mimeType: e.type || "application/octet-stream",
90
90
  ...n?.accessScope ? { accessScope: n.accessScope } : typeof n?.isPublic == "boolean" ? { isPublic: n.isPublic } : {},
@@ -106,24 +106,24 @@ var se = async (e) => {
106
106
  ...n ? { uploadKey: n } : {}
107
107
  };
108
108
  }
109
- let s = String(a.data?.uploadId ?? ""), c = typeof a.data?.uploadKey == "string" ? String(a.data.uploadKey) : null, ee = Number(a.data?.chunkSize ?? 0), l = Number(a.data?.chunksTotal ?? 0);
110
- if (!s || !ee || !l) throw Error("Upload init missing required fields");
111
- let te = async (t) => {
112
- let r = t * ee, i = Math.min(e.size, r + ee), a = await e.slice(r, i).arrayBuffer(), o = await se(a), l = await E({
109
+ let s = String(a.data?.uploadId ?? ""), c = typeof a.data?.uploadKey == "string" ? String(a.data.uploadKey) : null, l = Number(a.data?.chunkSize ?? 0), u = Number(a.data?.chunksTotal ?? 0);
110
+ if (!s || !l || !u) throw Error("Upload init missing required fields");
111
+ let d = async (t) => {
112
+ let r = t * l, i = Math.min(e.size, r + l), a = await e.slice(r, i).arrayBuffer(), o = await C(a), u = await D({
113
113
  url: `/api/rb/file-uploads/${encodeURIComponent(s)}/chunks/${t}`,
114
114
  body: a,
115
115
  sha256: o ?? void 0,
116
116
  uploadKey: c ?? void 0,
117
117
  signal: n?.signal
118
118
  });
119
- if (l.status !== 204) throw Error(`Chunk ${t} failed (${l.status})`);
120
- }, u = async (e, n = 0) => {
119
+ if (u.status !== 204) throw Error(`Chunk ${t} failed (${u.status})`);
120
+ }, f = async (e, n = 0) => {
121
121
  let r = n;
122
- for (let n of e) await te(n), r += 1, t(Math.min(99, Math.floor(r / l * 99)));
122
+ for (let n of e) await d(n), r += 1, t(Math.min(99, Math.floor(r / u * 99)));
123
123
  };
124
- await u(Array.from({ length: l }, (e, t) => t), 0);
125
- let d = async () => {
126
- let e = await w(`/api/rb/file-uploads/${encodeURIComponent(s)}/complete`, {}, {
124
+ await f(Array.from({ length: u }, (e, t) => t), 0);
125
+ let p = async () => {
126
+ let e = await T(`/api/rb/file-uploads/${encodeURIComponent(s)}/complete`, {}, {
127
127
  headers: c ? { "X-Upload-Key": c } : void 0,
128
128
  signal: n?.signal
129
129
  });
@@ -134,275 +134,287 @@ var se = async (e) => {
134
134
  }
135
135
  let t = String(e.data?.error ?? "");
136
136
  if (e.status !== 409 || t !== "missing_chunks") throw Error(t || `Complete failed (${e.status})`);
137
- let r = await T(`/api/rb/file-uploads/${encodeURIComponent(s)}/status`, {
137
+ let r = await E(`/api/rb/file-uploads/${encodeURIComponent(s)}/status`, {
138
138
  headers: c ? { "X-Upload-Key": c } : void 0,
139
139
  signal: n?.signal
140
140
  });
141
141
  if (!r.ok || !r.data?.ok) throw Error(r.data?.error ?? `Status failed (${r.status})`);
142
142
  let i = Array.isArray(r.data?.received) ? r.data.received : [], a = new Set(i), o = [];
143
- for (let e = 0; e < l; e += 1) a.has(e) || o.push(e);
143
+ for (let e = 0; e < u; e += 1) a.has(e) || o.push(e);
144
144
  if (!o.length) throw Error("missing_chunks");
145
- return await u(o, a.size), d();
146
- }, f = await d();
145
+ return await f(o, a.size), p();
146
+ }, ee = await p();
147
147
  return t(100), {
148
- id: f,
149
- url: `/api/rb/files/${encodeURIComponent(f)}`,
148
+ id: ee,
149
+ url: `/api/rb/files/${encodeURIComponent(ee)}`,
150
150
  alt: e.name,
151
151
  ...c ? { uploadKey: c } : {}
152
152
  };
153
153
  };
154
- function le(n) {
155
- let a = r(82), { item: l, isHovered: p, enableImagePreview: m, renderItem: re, onHoverEnter: h, onHoverLeave: g, onRemove: _, onRetry: ie, startFullscreen: ae, isUploading: v, isError: y, tileClasses: oe, disabled: b, isDraggingExternal: se, removeButtonAriaLabel: C } = n, w;
156
- a[0] !== b || a[1] !== l.id ? (w = {
157
- id: l.id,
158
- disabled: b
159
- }, a[0] = b, a[1] = l.id, a[2] = w) : w = a[2];
160
- let { setNodeRef: T, attributes: E, listeners: ce, transform: le, transition: ue, isDragging: de } = x(w), pe = o(null), me = o(null), [D, he] = s(null), O;
161
- a[3] === Symbol.for("react.memo_cache_sentinel") ? (O = () => {
162
- let e = pe.current;
154
+ function de(n) {
155
+ let r = o(82), { item: i, isHovered: a, enableImagePreview: c, renderItem: p, onHoverEnter: _, onHoverLeave: v, onRemove: ne, onRetry: re, startFullscreen: ie, isUploading: y, isError: b, tileClasses: ae, disabled: x, isDraggingExternal: oe, removeButtonAriaLabel: se } = n, ce;
156
+ r[0] !== x || r[1] !== i.id ? (ce = {
157
+ id: i.id,
158
+ disabled: x
159
+ }, r[0] = x, r[1] = i.id, r[2] = ce) : ce = r[2];
160
+ let { setNodeRef: C, attributes: w, listeners: T, transform: E, transition: D, isDragging: ue } = S(ce), de = l(null), fe = l(null), [O, pe] = u(null), k;
161
+ r[3] === Symbol.for("react.memo_cache_sentinel") ? (k = () => {
162
+ let e = de.current;
163
163
  if (!e) return;
164
164
  let t = e.getBoundingClientRect();
165
- he({
165
+ pe({
166
166
  left: t.left + t.width / 2,
167
167
  top: t.top - 10
168
168
  });
169
- }, a[3] = O) : O = a[3];
170
- let ge = O, k, A;
171
- a[4] !== m || a[5] !== p ? (k = () => {
172
- if (!m || !p) {
173
- he(null);
169
+ }, r[3] = k) : k = r[3];
170
+ let A = k, j, he;
171
+ r[4] !== c || r[5] !== a ? (j = () => {
172
+ if (!c || !a) {
173
+ pe(null);
174
174
  return;
175
175
  }
176
- ge();
176
+ A();
177
177
  let e = 0, t = () => {
178
178
  e && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
179
- e = 0, ge();
179
+ e = 0, A();
180
180
  });
181
181
  };
182
182
  return window.addEventListener("resize", t), window.addEventListener("scroll", t, !0), () => {
183
183
  e && cancelAnimationFrame(e), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0);
184
184
  };
185
- }, A = [m, p], a[4] = m, a[5] = p, a[6] = k, a[7] = A) : (k = a[6], A = a[7]), i(k, A);
186
- let j;
187
- a[8] === le ? j = a[9] : (j = S.Transform.toString(le), a[8] = le, a[9] = j);
185
+ }, he = [c, a], r[4] = c, r[5] = a, r[6] = j, r[7] = he) : (j = r[6], he = r[7]), s(j, he);
188
186
  let M;
189
- a[10] !== j || a[11] !== ue ? (M = {
190
- transform: j,
191
- transition: ue
192
- }, a[10] = j, a[11] = ue, a[12] = M) : M = a[12];
193
- let N = M, P;
194
- a[13] !== m || a[14] !== y || a[15] !== v || a[16] !== l.alt || a[17] !== l.fileName || a[18] !== l.id || a[19] !== l.previewUrl || a[20] !== l.progress || a[21] !== l.status || a[22] !== l.uploadKey || a[23] !== l.url || a[24] !== re ? (P = re ? re({
187
+ r[8] === E ? M = r[9] : (M = le.Transform.toString(E), r[8] = E, r[9] = M);
188
+ let ge;
189
+ r[10] !== M || r[11] !== D ? (ge = {
190
+ transform: M,
191
+ transition: D
192
+ }, r[10] = M, r[11] = D, r[12] = ge) : ge = r[12];
193
+ let N = ge, P;
194
+ r[13] !== c || r[14] !== b || r[15] !== y || r[16] !== i.alt || r[17] !== i.fileName || r[18] !== i.id || r[19] !== i.previewUrl || r[20] !== i.progress || r[21] !== i.status || r[22] !== i.uploadKey || r[23] !== i.url || r[24] !== p ? (P = p ? p({
195
195
  file: {
196
- id: l.id,
197
- url: l.url,
198
- alt: l.alt,
199
- uploadKey: l.uploadKey
196
+ id: i.id,
197
+ url: i.url,
198
+ alt: i.alt,
199
+ uploadKey: i.uploadKey
200
200
  },
201
- previewUrl: l.previewUrl,
202
- status: l.status,
203
- progress: l.progress,
204
- fileName: l.fileName
205
- }) : m ? /* @__PURE__ */ d(t, {
206
- src: l.previewUrl,
207
- alt: l.alt ?? "Uploaded file",
201
+ previewUrl: i.previewUrl,
202
+ status: i.status,
203
+ progress: i.progress,
204
+ fileName: i.fileName
205
+ }) : c ? /* @__PURE__ */ h(t, {
206
+ src: i.previewUrl,
207
+ alt: i.alt ?? "Uploaded file",
208
208
  sizes: "96px",
209
- className: e("size-full rounded-md object-cover", v && "opacity-75", y && "grayscale")
210
- }) : /* @__PURE__ */ d("div", {
209
+ className: e("size-full rounded-md object-cover", y && "opacity-75", b && "grayscale")
210
+ }) : /* @__PURE__ */ h("div", {
211
211
  className: "flex size-full items-center justify-center rounded-md bg-slate-100 px-2 text-center text-[10px] font-medium text-slate-700 dark:bg-slate-800 dark:text-slate-200",
212
- children: /* @__PURE__ */ d("span", {
212
+ children: /* @__PURE__ */ h("span", {
213
213
  className: "w-full truncate",
214
- children: l.fileName ?? l.alt ?? "Fichier"
214
+ children: i.fileName ?? i.alt ?? "Fichier"
215
215
  })
216
- }), a[13] = m, a[14] = y, a[15] = v, a[16] = l.alt, a[17] = l.fileName, a[18] = l.id, a[19] = l.previewUrl, a[20] = l.progress, a[21] = l.status, a[22] = l.uploadKey, a[23] = l.url, a[24] = re, a[25] = P) : P = a[25];
217
- let _e = P, F;
218
- a[26] === T ? F = a[27] : (F = (e) => {
219
- pe.current = e, T(e);
220
- }, a[26] = T, a[27] = F);
221
- let I = de && "z-20 ring-2 ring-primary shadow-xl", L = se && "opacity-0", ve = !b && "cursor-grab active:cursor-grabbing", R = de && "cursor-grabbing", z = b && "cursor-default", B;
222
- a[28] !== L || a[29] !== ve || a[30] !== R || a[31] !== z || a[32] !== I || a[33] !== oe ? (B = e(oe, I, L, ve, R, z), a[28] = L, a[29] = ve, a[30] = R, a[31] = z, a[32] = I, a[33] = oe, a[34] = B) : B = a[34];
216
+ }), r[13] = c, r[14] = b, r[15] = y, r[16] = i.alt, r[17] = i.fileName, r[18] = i.id, r[19] = i.previewUrl, r[20] = i.progress, r[21] = i.status, r[22] = i.uploadKey, r[23] = i.url, r[24] = p, r[25] = P) : P = r[25];
217
+ let F = P, I;
218
+ r[26] === C ? I = r[27] : (I = (e) => {
219
+ de.current = e, C(e);
220
+ }, r[26] = C, r[27] = I);
221
+ let _e = ue && "z-20 ring-2 ring-primary shadow-xl", L = oe && "opacity-0", R = !x && "cursor-grab active:cursor-grabbing", ve = ue && "cursor-grabbing", z = x && "cursor-default", B;
222
+ r[28] !== L || r[29] !== R || r[30] !== ve || r[31] !== z || r[32] !== _e || r[33] !== ae ? (B = e(ae, _e, L, R, ve, z), r[28] = L, r[29] = R, r[30] = ve, r[31] = z, r[32] = _e, r[33] = ae, r[34] = B) : B = r[34];
223
223
  let V;
224
- a[35] === h ? V = a[36] : (V = () => {
225
- ge(), h();
226
- }, a[35] = h, a[36] = V);
224
+ r[35] === _ ? V = r[36] : (V = () => {
225
+ A(), _();
226
+ }, r[35] = _, r[36] = V);
227
227
  let H;
228
- a[37] === g ? H = a[38] : (H = (e) => {
228
+ r[37] === v ? H = r[38] : (H = (e) => {
229
229
  let t = e.relatedTarget;
230
- t instanceof Node && me.current?.contains(t) || g();
231
- }, a[37] = g, a[38] = H);
230
+ t instanceof Node && fe.current?.contains(t) || v();
231
+ }, r[37] = v, r[38] = H);
232
232
  let U;
233
- a[39] !== b || a[40] !== l.id || a[41] !== _ ? (U = () => {
234
- b || _(l.id);
235
- }, a[39] = b, a[40] = l.id, a[41] = _, a[42] = U) : U = a[42];
233
+ r[39] !== x || r[40] !== i.id || r[41] !== ne ? (U = () => {
234
+ x || ne(i.id);
235
+ }, r[39] = x, r[40] = i.id, r[41] = ne, r[42] = U) : U = r[42];
236
+ let ye;
237
+ r[43] === Symbol.for("react.memo_cache_sentinel") ? (ye = /* @__PURE__ */ h(ee, { className: "h-4 w-4" }), r[43] = ye) : ye = r[43];
236
238
  let W;
237
- a[43] === Symbol.for("react.memo_cache_sentinel") ? (W = /* @__PURE__ */ d(te, { className: "h-4 w-4" }), a[43] = W) : W = a[43];
238
- let G;
239
- a[44] !== b || a[45] !== C || a[46] !== U ? (G = /* @__PURE__ */ d("button", {
239
+ r[44] !== x || r[45] !== se || r[46] !== U ? (W = /* @__PURE__ */ h("button", {
240
240
  type: "button",
241
241
  onClick: U,
242
- disabled: b,
242
+ disabled: x,
243
243
  className: "absolute right-1 top-1 inline-flex size-6 items-center justify-center rounded-full bg-white text-slate-700 shadow-sm transition hover:scale-105 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:bg-slate-900 dark:text-slate-200",
244
- "aria-label": C,
245
- children: W
246
- }), a[44] = b, a[45] = C, a[46] = U, a[47] = G) : G = a[47];
247
- let K;
248
- a[48] !== m || a[49] !== p || a[50] !== l.alt || a[51] !== l.id || a[52] !== l.url || a[53] !== h || a[54] !== g || a[55] !== D || a[56] !== ae ? (K = m && p && D && (() => {
249
- let e = /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d("div", {
250
- ref: me,
244
+ "aria-label": se,
245
+ children: ye
246
+ }), r[44] = x, r[45] = se, r[46] = U, r[47] = W) : W = r[47];
247
+ let G;
248
+ r[48] !== c || r[49] !== a || r[50] !== i.alt || r[51] !== i.id || r[52] !== i.url || r[53] !== _ || r[54] !== v || r[55] !== O || r[56] !== ie ? (G = c && a && O && (() => {
249
+ let e = /* @__PURE__ */ h(m, { children: /* @__PURE__ */ h("div", {
250
+ ref: fe,
251
251
  className: "pointer-events-auto fixed z-[60] w-52 -translate-x-1/2 -translate-y-full rounded-xl border border-slate-200 bg-white/95 p-3 shadow-2xl backdrop-blur dark:border-slate-700 dark:bg-slate-900/95",
252
252
  style: {
253
- left: D.left,
254
- top: D.top
253
+ left: O.left,
254
+ top: O.top
255
255
  },
256
256
  onMouseEnter: () => {
257
- ge(), h();
257
+ A(), _();
258
258
  },
259
259
  onMouseLeave: (e) => {
260
260
  let t = e.relatedTarget;
261
- t instanceof Node && pe.current?.contains(t) || g();
261
+ t instanceof Node && de.current?.contains(t) || v();
262
262
  },
263
- children: /* @__PURE__ */ f("div", {
263
+ children: /* @__PURE__ */ g("div", {
264
264
  className: "relative overflow-hidden rounded-lg",
265
- children: [/* @__PURE__ */ d(t, {
266
- src: l.url,
267
- alt: l.alt ?? "Preview",
265
+ children: [/* @__PURE__ */ h(t, {
266
+ src: i.url,
267
+ alt: i.alt ?? "Preview",
268
268
  sizes: "208px",
269
269
  className: "h-40 w-full object-cover"
270
- }), /* @__PURE__ */ d("button", {
270
+ }), /* @__PURE__ */ h("button", {
271
271
  type: "button",
272
- onClick: () => ae(l.id),
272
+ onClick: () => ie(i.id),
273
273
  className: "absolute right-2 top-2 inline-flex items-center justify-center rounded-full bg-black/70 p-2 text-white transition hover:bg-black",
274
274
  "aria-label": "Plein écran",
275
- children: /* @__PURE__ */ d(ee, { className: "h-3.5 w-3.5" })
275
+ children: /* @__PURE__ */ h(f, { className: "h-3.5 w-3.5" })
276
276
  })]
277
277
  })
278
278
  }) });
279
- return typeof document > "u" ? e : ne(e, document.body);
280
- })(), a[48] = m, a[49] = p, a[50] = l.alt, a[51] = l.id, a[52] = l.url, a[53] = h, a[54] = g, a[55] = D, a[56] = ae, a[57] = K) : K = a[57];
281
- let q;
282
- a[58] !== v || a[59] !== l.alt || a[60] !== l.fileName || a[61] !== l.progress ? (q = v && /* @__PURE__ */ f("div", {
279
+ return typeof document > "u" ? e : te(e, document.body);
280
+ })(), r[48] = c, r[49] = a, r[50] = i.alt, r[51] = i.id, r[52] = i.url, r[53] = _, r[54] = v, r[55] = O, r[56] = ie, r[57] = G) : G = r[57];
281
+ let K;
282
+ r[58] !== y || r[59] !== i.alt || r[60] !== i.fileName || r[61] !== i.progress ? (K = y && /* @__PURE__ */ g("div", {
283
283
  className: "absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-black/40 text-white",
284
284
  role: "progressbar",
285
- "aria-label": l.fileName ?? l.alt ?? "File",
285
+ "aria-label": i.fileName ?? i.alt ?? "File",
286
286
  "aria-valuemin": 0,
287
287
  "aria-valuemax": 100,
288
- "aria-valuenow": l.progress,
288
+ "aria-valuenow": i.progress,
289
289
  children: [
290
- /* @__PURE__ */ d(c, {
290
+ /* @__PURE__ */ h(d, {
291
291
  className: "h-5 w-5 animate-spin",
292
292
  "aria-hidden": "true"
293
293
  }),
294
- /* @__PURE__ */ d("div", {
294
+ /* @__PURE__ */ h("div", {
295
295
  className: "h-1.5 w-5/6 rounded-full bg-white/20",
296
- children: /* @__PURE__ */ d("div", {
296
+ children: /* @__PURE__ */ h("div", {
297
297
  className: "h-full rounded-full bg-primary",
298
- style: { width: `${l.progress}%` }
298
+ style: { width: `${i.progress}%` }
299
299
  })
300
300
  }),
301
- /* @__PURE__ */ f("div", {
301
+ /* @__PURE__ */ g("div", {
302
302
  className: "text-xs font-semibold",
303
- children: [l.progress, "%"]
303
+ children: [i.progress, "%"]
304
304
  })
305
305
  ]
306
- }), a[58] = v, a[59] = l.alt, a[60] = l.fileName, a[61] = l.progress, a[62] = q) : q = a[62];
307
- let J;
308
- a[63] !== b || a[64] !== y || a[65] !== l.errorMessage || a[66] !== l.id || a[67] !== ie ? (J = y && /* @__PURE__ */ f("div", {
306
+ }), r[58] = y, r[59] = i.alt, r[60] = i.fileName, r[61] = i.progress, r[62] = K) : K = r[62];
307
+ let q;
308
+ r[63] !== x || r[64] !== b || r[65] !== i.errorMessage || r[66] !== i.id || r[67] !== re ? (q = b && /* @__PURE__ */ g("div", {
309
309
  className: "absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 rounded-lg bg-red-600/70 text-white",
310
310
  role: "alert",
311
- children: [/* @__PURE__ */ d("div", {
311
+ children: [/* @__PURE__ */ h("div", {
312
312
  className: "max-w-[92%] break-words text-center text-[10px] font-semibold leading-tight",
313
- title: l.errorMessage,
314
- children: fe(l.errorMessage)
315
- }), /* @__PURE__ */ d("button", {
313
+ title: i.errorMessage,
314
+ children: me(i.errorMessage)
315
+ }), /* @__PURE__ */ h("button", {
316
316
  type: "button",
317
- onClick: () => ie(l.id),
318
- disabled: b,
317
+ onClick: () => re(i.id),
318
+ disabled: x,
319
319
  className: "rounded-full bg-white/90 px-3 py-1 text-xs font-semibold text-red-700 shadow-sm transition hover:bg-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
320
320
  children: "Réessayer"
321
321
  })]
322
- }), a[63] = b, a[64] = y, a[65] = l.errorMessage, a[66] = l.id, a[67] = ie, a[68] = J) : J = a[68];
323
- let Y;
324
- return a[69] !== E || a[70] !== ce || a[71] !== N || a[72] !== B || a[73] !== V || a[74] !== H || a[75] !== G || a[76] !== K || a[77] !== q || a[78] !== J || a[79] !== F || a[80] !== _e ? (Y = /* @__PURE__ */ f("div", {
325
- ref: F,
322
+ }), r[63] = x, r[64] = b, r[65] = i.errorMessage, r[66] = i.id, r[67] = re, r[68] = q) : q = r[68];
323
+ let J;
324
+ return r[69] !== w || r[70] !== T || r[71] !== N || r[72] !== B || r[73] !== V || r[74] !== H || r[75] !== W || r[76] !== G || r[77] !== K || r[78] !== q || r[79] !== I || r[80] !== F ? (J = /* @__PURE__ */ g("div", {
325
+ ref: I,
326
326
  style: N,
327
327
  className: B,
328
328
  onMouseEnter: V,
329
329
  onMouseLeave: H,
330
- ...E,
331
- ...ce,
330
+ ...w,
331
+ ...T,
332
332
  children: [
333
- _e,
333
+ F,
334
+ W,
334
335
  G,
335
336
  K,
336
- q,
337
- J
337
+ q
338
338
  ]
339
- }), a[69] = E, a[70] = ce, a[71] = N, a[72] = B, a[73] = V, a[74] = H, a[75] = G, a[76] = K, a[77] = q, a[78] = J, a[79] = F, a[80] = _e, a[81] = Y) : Y = a[81], Y;
339
+ }), r[69] = w, r[70] = T, r[71] = N, r[72] = B, r[73] = V, r[74] = H, r[75] = W, r[76] = G, r[77] = K, r[78] = q, r[79] = I, r[80] = F, r[81] = J) : J = r[81], J;
340
340
  }
341
- function ue(e) {
341
+ function fe(e) {
342
342
  return URL.createObjectURL(e);
343
343
  }
344
- var de = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Upload failed", fe = (e) => e ? e.startsWith("heif_decode_unsupported") ? "HEIC/HEVC non supporté" : e : "Échec", pe = /\.(png|jpe?g|gif|webp|avif|heic|heif|svg|bmp)$/i, me = 350, D = _({ styles: { active: { opacity: "0" } } }), he = (e) => e.mimeType ? e.mimeType.startsWith("image/") : pe.test(e.fileName ?? e.alt ?? "");
345
- function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic: ee, uploadAccessScope: u, uploadDeduplicationNamespace: _, maxFiles: x, disabled: S = !1, onUploadingChange: se, accept: C, renderHeader: w, renderItem: T, addButtonAriaLabel: E = "Ajouter un fichier", removeButtonAriaLabel: pe = "Supprimer le fichier", variant: O = "card" }) {
346
- let ge = o(null), [k, A] = s(() => n.map((e) => ({
344
+ async function O(e) {
345
+ let t = document.createElement("img"), a = n(e);
346
+ if (a && (t.srcset = a, t.sizes = "96px"), t.src = r(e) ? i(e, 960) : e, typeof t.decode == "function") {
347
+ await t.decode().catch(() => void 0);
348
+ return;
349
+ }
350
+ t.complete || await new Promise((e) => {
351
+ t.onload = () => e(), t.onerror = () => e();
352
+ });
353
+ }
354
+ var pe = (e) => e instanceof Error ? e.message : typeof e == "string" ? e : "Upload failed", me = (e) => e ? e.startsWith("heif_decode_unsupported") ? "HEIC/HEVC non supporté" : e : "Échec", k = /\.(png|jpe?g|gif|webp|avif|heic|heif|svg|bmp)$/i, A = 350, j = y({ styles: { active: { opacity: "0" } } }), he = (e) => e.mimeType ? e.mimeType.startsWith("image/") : k.test(e.fileName ?? e.alt ?? "");
355
+ function M({ initialFiles: n = [], onChange: r, upload: i = ue, uploadIsPublic: a, uploadAccessScope: o, uploadDeduplicationNamespace: d, maxFiles: f, disabled: m = !1, onUploadingChange: y, accept: S, renderHeader: le, renderItem: C, addButtonAriaLabel: w = "Ajouter un fichier", removeButtonAriaLabel: T = "Supprimer le fichier", variant: E = "card" }) {
356
+ let D = l(null), [k, M] = u(() => n.map((e) => ({
347
357
  ...e,
358
+ renderKey: e.id,
348
359
  previewUrl: e.url,
349
360
  status: "uploaded",
350
361
  progress: 100
351
- }))), [j, M] = s(!1), [N, P] = s(null), [_e, F] = s(null), [I, L] = s(null), [ve, R] = s(null), z = o(null), B = o(null), V = o(!1), H = o(() => {}), U = o({ sideEffects(e) {
352
- let t = String(e.active.id), n = B.current;
353
- n?.id === t && (window.clearTimeout(n.timeout), B.current = null);
354
- let r = D(e);
362
+ }))), [ge, N] = u(!1), [P, F] = u(null), [I, _e] = u(null), [L, R] = u(null), [ve, z] = u(null), B = l(null), V = l(null), H = l(!1), U = l(() => {}), ye = l({ sideEffects(e) {
363
+ let t = String(e.active.id), n = V.current;
364
+ n?.id === t && (window.clearTimeout(n.timeout), V.current = null);
365
+ let r = j(e);
355
366
  return () => {
356
- r?.(), H.current(t);
367
+ r?.(), U.current(t);
357
368
  };
358
- } }), W = o(!0), G = o([]), K = o(n), q = o(r), J = o(se), Y = o(/* @__PURE__ */ new Map()), X = o(/* @__PURE__ */ new Map()), Z = o(/* @__PURE__ */ new Map()), Q = o(/* @__PURE__ */ new Map()), ye = ae(ie(h, { activationConstraint: { distance: 6 } }), ie(re, { coordinateGetter: b }));
359
- i(() => () => {
369
+ } }), W = l(!0), G = l([]), K = l(n), q = l(r), J = l(y), Y = l(/* @__PURE__ */ new Map()), X = l(/* @__PURE__ */ new Map()), Z = l(/* @__PURE__ */ new Map()), Q = l(/* @__PURE__ */ new Map()), be = ae(b(re, { activationConstraint: { distance: 6 } }), b(ne, { coordinateGetter: ce }));
370
+ s(() => () => {
360
371
  for (let e of Z.current.values()) try {
361
372
  e.abort();
362
373
  } catch {}
363
- Z.current.clear(), B.current !== null && (window.clearTimeout(B.current.timeout), B.current = null), X.current.clear(), Y.current.clear();
374
+ Z.current.clear(), V.current !== null && (window.clearTimeout(V.current.timeout), V.current = null), X.current.clear(), Y.current.clear();
364
375
  for (let e of Q.current.values()) if (typeof URL < "u") try {
365
376
  URL.revokeObjectURL(e);
366
377
  } catch {}
367
378
  Q.current.clear();
368
- }, []), H.current = (e) => {
369
- let t = B.current;
370
- t?.id === e && (window.clearTimeout(t.timeout), B.current = null), R((t) => t === e ? null : t);
371
- }, i(() => {
379
+ }, []), U.current = (e) => {
380
+ let t = V.current;
381
+ t?.id === e && (window.clearTimeout(t.timeout), V.current = null), z((t) => t === e ? null : t);
382
+ }, s(() => {
372
383
  if (!(typeof document > "u")) {
373
- if (I) return document.body.style.cursor = "grabbing", () => {
384
+ if (L) return document.body.style.cursor = "grabbing", () => {
374
385
  document.body.style.cursor = "";
375
386
  };
376
387
  document.body.style.cursor = "";
377
388
  }
378
- }, [I]), i(() => {
389
+ }, [L]), s(() => {
379
390
  G.current = k;
380
- }, [k]), i(() => {
391
+ }, [k]), s(() => {
381
392
  q.current = r;
382
- }, [r]), i(() => {
383
- J.current = se;
384
- }, [se]), i(() => {
393
+ }, [r]), s(() => {
394
+ J.current = y;
395
+ }, [y]), s(() => {
385
396
  let e = K.current;
386
397
  if (e.length === n.length && e.every((e, t) => {
387
398
  let r = n[t];
388
399
  return r && e.id === r.id && e.url === r.url && e.alt === r.alt;
389
400
  })) return;
390
401
  K.current = n;
391
- let t = n.map((e) => ({
402
+ let t = new Map(G.current.map((e) => [e.id, e.renderKey])), r = n.map((e) => ({
392
403
  ...e,
404
+ renderKey: t.get(e.id) ?? e.id,
393
405
  previewUrl: e.url,
394
406
  status: "uploaded",
395
407
  progress: 100
396
- })), r = new Set(t.map((e) => e.id));
397
- for (let [e, t] of Y.current.entries()) r.has(t) && Y.current.delete(e);
398
- let i = new Set(G.current.map((e) => e.id));
399
- if (t.some((e) => {
408
+ })), i = new Set(r.map((e) => e.id));
409
+ for (let [e, t] of Y.current.entries()) i.has(t) && Y.current.delete(e);
410
+ let a = new Set(G.current.map((e) => e.id));
411
+ if (r.some((e) => {
400
412
  let t = Y.current.get(e.id);
401
- return t ? i.has(t) : !1;
413
+ return t ? a.has(t) : !1;
402
414
  })) return;
403
- let a = new Set(t.map((e) => e.id));
415
+ let o = new Set(r.map((e) => e.id));
404
416
  for (let e of G.current) {
405
- if (a.has(e.id)) continue;
417
+ if (o.has(e.id)) continue;
406
418
  let t = Z.current.get(e.id);
407
419
  if (t) {
408
420
  Z.current.delete(e.id);
@@ -419,11 +431,11 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
419
431
  } catch {}
420
432
  }
421
433
  }
422
- A((e) => e.length === t.length && e.every((e, n) => {
423
- let r = t[n];
424
- return r && e.id === r.id && e.url === r.url && e.alt === r.alt && e.uploadKey === r.uploadKey;
425
- }) ? e : (W.current = !0, t));
426
- }, [n]), i(() => {
434
+ M((e) => e.length === r.length && e.every((e, t) => {
435
+ let n = r[t];
436
+ return n && e.id === n.id && e.url === n.url && e.alt === n.alt && e.uploadKey === n.uploadKey;
437
+ }) ? e : (W.current = !0, r));
438
+ }, [n]), s(() => {
427
439
  if (W.current) {
428
440
  W.current = !1;
429
441
  return;
@@ -434,33 +446,34 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
434
446
  alt: n,
435
447
  uploadKey: r
436
448
  })));
437
- }, [k]), i(() => {
449
+ }, [k]), s(() => {
438
450
  J.current?.(k.some((e) => e.status === "uploading"));
439
- }, [k]), i(() => {
440
- if (N === null) return;
451
+ }, [k]), s(() => {
452
+ if (P === null) return;
441
453
  let e = (e) => {
442
454
  if (e.key === "Escape") {
443
- P(null);
455
+ F(null);
444
456
  return;
445
457
  }
446
458
  if (e.key === "ArrowRight") {
447
- P((e) => e === null ? e : (e + 1) % k.length);
459
+ F((e) => e === null ? e : (e + 1) % k.length);
448
460
  return;
449
461
  }
450
- e.key === "ArrowLeft" && P((e) => e === null ? e : (e - 1 + k.length) % k.length);
462
+ e.key === "ArrowLeft" && F((e) => e === null ? e : (e - 1 + k.length) % k.length);
451
463
  };
452
464
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
453
- }, [N, k.length]);
454
- let be = async (e) => {
455
- if (S) return;
456
- let t = typeof x == "number" && Number.isFinite(x) && x > 0 ? Math.floor(x) : null, n = t === null ? Infinity : Math.max(0, t - G.current.length), r = Array.from(e).slice(0, n);
465
+ }, [P, k.length]);
466
+ let xe = async (e) => {
467
+ if (m) return;
468
+ let t = typeof f == "number" && Number.isFinite(f) && f > 0 ? Math.floor(f) : null, n = t === null ? Infinity : Math.max(0, t - G.current.length), r = Array.from(e).slice(0, n);
457
469
  if (!r.length) return;
458
- let i = r.map((e) => {
459
- let t = ue(e), n = crypto.randomUUID();
470
+ let s = r.map((e) => {
471
+ let t = fe(e), n = crypto.randomUUID();
460
472
  Q.current.set(n, t), X.current.set(n, e);
461
473
  let r = {
462
474
  id: n,
463
475
  url: t,
476
+ renderKey: n,
464
477
  previewUrl: t,
465
478
  alt: e.name,
466
479
  status: "uploading",
@@ -468,10 +481,10 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
468
481
  fileName: e.name,
469
482
  mimeType: e.type
470
483
  };
471
- A((e) => [...e, r]);
472
- let i = (e) => {
484
+ M((e) => [...e, r]);
485
+ let s = (e) => {
473
486
  let t = Math.max(0, Math.min(99, e));
474
- A((e) => e.map((e) => e.id === n ? {
487
+ M((e) => e.map((e) => e.id === n ? {
475
488
  ...e,
476
489
  progress: t,
477
490
  status: "uploading"
@@ -481,20 +494,14 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
481
494
  let t = new AbortController();
482
495
  Z.current.set(n, t);
483
496
  try {
484
- let r = await c(e, i, {
497
+ let r = await i(e, s, {
485
498
  signal: t.signal,
486
- ...u ? { accessScope: u } : { isPublic: ee ?? !1 },
487
- ..._ ? { deduplicationNamespace: _ } : {}
499
+ ...o ? { accessScope: o } : { isPublic: a ?? !1 },
500
+ ...d ? { deduplicationNamespace: d } : {}
488
501
  });
489
502
  Y.current.set(n, r.id);
490
- let a = Q.current.get(n);
491
- if (a) {
492
- Q.current.delete(n);
493
- try {
494
- URL.revokeObjectURL(a);
495
- } catch {}
496
- }
497
- Z.current.delete(n), X.current.delete(n), A((e) => e.map((e) => e.id === n ? {
503
+ let c = Q.current.get(n);
504
+ e.type.startsWith("image/") && await O(r.url), Z.current.delete(n), X.current.delete(n), M((e) => e.map((e) => e.id === n ? {
498
505
  ...e,
499
506
  ...r,
500
507
  previewUrl: r.url,
@@ -502,7 +509,7 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
502
509
  status: "uploaded",
503
510
  progress: 100,
504
511
  errorMessage: void 0
505
- } : e));
512
+ } : e)), c && (Q.current.delete(n), window.requestAnimationFrame(() => URL.revokeObjectURL(c)));
506
513
  } catch (e) {
507
514
  if (Z.current.delete(n), t.signal.aborted) {
508
515
  X.current.delete(n);
@@ -516,8 +523,8 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
516
523
  return;
517
524
  }
518
525
  console.error("Upload failed", e);
519
- let r = de(e);
520
- A((e) => e.map((e) => e.id === n ? {
526
+ let r = pe(e);
527
+ M((e) => e.map((e) => e.id === n ? {
521
528
  ...e,
522
529
  status: "error",
523
530
  progress: Math.max(0, Math.min(99, e.progress)),
@@ -526,12 +533,12 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
526
533
  }
527
534
  })();
528
535
  });
529
- await Promise.allSettled(i);
530
- }, xe = (e) => {
531
- e.target.files && (be(e.target.files), e.target.value = "");
532
- }, Se = () => {
533
- S || ge.current?.click();
534
- }, Ce = (e) => {
536
+ await Promise.allSettled(s);
537
+ }, Se = (e) => {
538
+ e.target.files && (xe(e.target.files), e.target.value = "");
539
+ }, Ce = () => {
540
+ m || D.current?.click();
541
+ }, we = (e) => {
535
542
  let t = Z.current.get(e);
536
543
  if (t) {
537
544
  Z.current.delete(e);
@@ -547,9 +554,9 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
547
554
  URL.revokeObjectURL(n);
548
555
  } catch {}
549
556
  }
550
- A((t) => t.filter((t) => t.id !== e));
551
- }, we = (e) => {
552
- if (S) return;
557
+ M((t) => t.filter((t) => t.id !== e));
558
+ }, Te = (e) => {
559
+ if (m) return;
553
560
  let t = X.current.get(e);
554
561
  if (!t) return;
555
562
  let n = Z.current.get(e);
@@ -559,7 +566,7 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
559
566
  } catch {}
560
567
  Z.current.delete(e);
561
568
  }
562
- A((t) => t.map((t) => t.id === e ? {
569
+ M((t) => t.map((t) => t.id === e ? {
563
570
  ...t,
564
571
  status: "uploading",
565
572
  progress: 0,
@@ -567,28 +574,22 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
567
574
  } : t));
568
575
  let r = (t) => {
569
576
  let n = Math.max(0, Math.min(99, t));
570
- A((t) => t.map((t) => t.id === e ? {
577
+ M((t) => t.map((t) => t.id === e ? {
571
578
  ...t,
572
579
  progress: n,
573
580
  status: "uploading"
574
581
  } : t));
575
- }, i = new AbortController();
576
- Z.current.set(e, i), (async () => {
582
+ }, s = new AbortController();
583
+ Z.current.set(e, s), (async () => {
577
584
  try {
578
- let n = await c(t, r, {
579
- signal: i.signal,
580
- ...u ? { accessScope: u } : { isPublic: ee ?? !1 },
581
- ..._ ? { deduplicationNamespace: _ } : {}
585
+ let n = await i(t, r, {
586
+ signal: s.signal,
587
+ ...o ? { accessScope: o } : { isPublic: a ?? !1 },
588
+ ...d ? { deduplicationNamespace: d } : {}
582
589
  });
583
590
  Y.current.set(e, n.id);
584
- let a = Q.current.get(e);
585
- if (a) {
586
- Q.current.delete(e);
587
- try {
588
- URL.revokeObjectURL(a);
589
- } catch {}
590
- }
591
- Z.current.delete(e), X.current.delete(e), A((t) => t.map((t) => t.id === e ? {
591
+ let c = Q.current.get(e);
592
+ t.type.startsWith("image/") && await O(n.url), Z.current.delete(e), X.current.delete(e), M((t) => t.map((t) => t.id === e ? {
592
593
  ...t,
593
594
  ...n,
594
595
  previewUrl: n.url,
@@ -596,60 +597,60 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
596
597
  status: "uploaded",
597
598
  progress: 100,
598
599
  errorMessage: void 0
599
- } : t));
600
+ } : t)), c && (Q.current.delete(e), window.requestAnimationFrame(() => URL.revokeObjectURL(c)));
600
601
  } catch (t) {
601
- if (Z.current.delete(e), i.signal.aborted) return;
602
+ if (Z.current.delete(e), s.signal.aborted) return;
602
603
  console.error("Retry failed", t);
603
- let n = de(t);
604
- A((t) => t.map((t) => t.id === e ? {
604
+ let n = pe(t);
605
+ M((t) => t.map((t) => t.id === e ? {
605
606
  ...t,
606
607
  status: "error",
607
608
  errorMessage: n
608
609
  } : t));
609
610
  }
610
611
  })();
611
- }, Te = (e) => {
612
+ }, Ee = (e) => {
612
613
  let t = k.findIndex((t) => t.id === e);
613
- t !== -1 && P(t);
614
- }, Ee = () => {
615
- B.current !== null && (window.clearTimeout(B.current.timeout), B.current = null), R(null);
616
- }, De = (e) => {
617
- B.current !== null && window.clearTimeout(B.current.timeout), B.current = {
614
+ t !== -1 && F(t);
615
+ }, De = () => {
616
+ V.current !== null && (window.clearTimeout(V.current.timeout), V.current = null), z(null);
617
+ }, Oe = (e) => {
618
+ V.current !== null && window.clearTimeout(V.current.timeout), V.current = {
618
619
  id: e,
619
620
  timeout: window.setTimeout(() => {
620
- B.current = null, R((t) => t === e ? null : t);
621
- }, me)
621
+ V.current = null, z((t) => t === e ? null : t);
622
+ }, A)
622
623
  };
623
- }, Oe = (e) => {
624
- V.current && (R(e), De(e)), L(null);
625
624
  }, ke = (e) => {
626
- Ee(), L(String(e.active.id));
625
+ H.current && (z(e), Oe(e)), R(null);
627
626
  }, Ae = (e) => {
627
+ De(), R(String(e.active.id));
628
+ }, je = (e) => {
628
629
  let { active: t, over: n } = e, r = String(t.id);
629
630
  if (!n) {
630
- Oe(r);
631
+ ke(r);
631
632
  return;
632
633
  }
633
634
  let i = String(n.id);
634
- r !== i && A((e) => {
635
+ r !== i && M((e) => {
635
636
  let t = e.findIndex((e) => e.id === r), n = e.findIndex((e) => e.id === i);
636
- return t === -1 || n === -1 ? e : y(e, t, n);
637
- }), Oe(r);
638
- }, je = () => {
639
- if (I) {
640
- Oe(I);
637
+ return t === -1 || n === -1 ? e : oe(e, t, n);
638
+ }), ke(r);
639
+ }, Me = () => {
640
+ if (L) {
641
+ ke(L);
641
642
  return;
642
643
  }
643
- L(null);
644
- }, Me = () => {
645
- z.current !== null && (window.clearTimeout(z.current), z.current = null);
646
- }, Ne = a(() => N === null ? null : k[N] ?? null, [N, k]), Pe = e(O === "bare" ? "rounded-lg transition-colors" : "rounded-xl border border-dashed border-slate-300 bg-white/70 p-4 shadow-sm transition-colors dark:border-slate-700 dark:bg-slate-900/60", j && (O === "bare" ? "bg-primary/5 ring-2 ring-primary/50" : "border-primary ring-2 ring-primary/50"), S && "opacity-70"), Fe = "group relative size-20 overflow-visible rounded-lg border border-slate-200 bg-slate-50 shadow-inner transition hover:shadow md:size-24 dark:border-slate-700 dark:bg-slate-800", Ie = a(() => {
647
- if (C) return Array.isArray(C) ? C.join(",") : C;
648
- }, [C]), Le = a(() => {
649
- if (T || !Ie) return !1;
650
- let e = Ie.split(",").map((e) => e.trim()).filter(Boolean);
644
+ R(null);
645
+ }, Ne = () => {
646
+ B.current !== null && (window.clearTimeout(B.current), B.current = null);
647
+ }, Pe = c(() => P === null ? null : k[P] ?? null, [P, k]), Fe = e(E === "bare" ? "rounded-lg transition-colors" : "rounded-xl border border-dashed border-slate-300 bg-white/70 p-4 shadow-sm transition-colors dark:border-slate-700 dark:bg-slate-900/60", ge && (E === "bare" ? "bg-primary/5 ring-2 ring-primary/50" : "border-primary ring-2 ring-primary/50"), m && "opacity-70"), Ie = "group relative size-20 overflow-visible rounded-lg border border-slate-200 bg-slate-50 shadow-inner transition hover:shadow md:size-24 dark:border-slate-700 dark:bg-slate-800", Le = c(() => {
648
+ if (S) return Array.isArray(S) ? S.join(",") : S;
649
+ }, [S]), Re = c(() => {
650
+ if (C || !Le) return !1;
651
+ let e = Le.split(",").map((e) => e.trim()).filter(Boolean);
651
652
  return e.length ? e.every((e) => e === "image/*" || e.startsWith("image/") || e === ".heic" || e === ".heif" || e === ".heics" || e === ".heifs") : !1;
652
- }, [Ie, T]), Re = (e) => Le || !T && he(e), ze = typeof x == "number" && Number.isFinite(x) && x > 0 ? Math.floor(x) : null, Be = !S && (ze === null || k.length < ze), $ = k.find((e) => e.status === "error") ?? k.find((e) => e.status === "uploading"), Ve = $ ? $.status === "error" ? fe($.errorMessage) : `${$.fileName ?? $.alt ?? "File"}: ${$.progress}%` : "", He = (e) => ({
653
+ }, [Le, C]), ze = (e) => Re || !C && he(e), Be = typeof f == "number" && Number.isFinite(f) && f > 0 ? Math.floor(f) : null, Ve = !m && (Be === null || k.length < Be), $ = k.find((e) => e.status === "error") ?? k.find((e) => e.status === "uploading"), He = $ ? $.status === "error" ? me($.errorMessage) : `${$.fileName ?? $.alt ?? "File"}: ${$.progress}%` : "", Ue = (e) => ({
653
654
  file: {
654
655
  id: e.id,
655
656
  url: e.url,
@@ -660,126 +661,126 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
660
661
  status: e.status,
661
662
  progress: e.progress,
662
663
  fileName: e.fileName
663
- }), Ue = I ? (() => {
664
- let e = k.find((e) => e.id === I);
664
+ }), We = L ? (() => {
665
+ let e = k.find((e) => e.id === L);
665
666
  if (!e) return null;
666
- if (T) {
667
- let t = T(He(e));
668
- return t == null || t === !1 ? null : /* @__PURE__ */ d("div", {
667
+ if (C) {
668
+ let t = C(Ue(e));
669
+ return t == null || t === !1 ? null : /* @__PURE__ */ h("div", {
669
670
  className: "pointer-events-none",
670
- children: /* @__PURE__ */ d("div", {
671
+ children: /* @__PURE__ */ h("div", {
671
672
  className: "h-24 w-24 overflow-hidden rounded-lg shadow-2xl",
672
673
  children: t
673
674
  })
674
675
  });
675
676
  }
676
- return Re(e) ? /* @__PURE__ */ d("div", {
677
+ return ze(e) ? /* @__PURE__ */ h("div", {
677
678
  className: "pointer-events-none",
678
- children: /* @__PURE__ */ d(t, {
679
+ children: /* @__PURE__ */ h(t, {
679
680
  src: e.previewUrl,
680
681
  alt: e.alt ?? "Dragged image",
681
682
  sizes: "96px",
682
683
  className: "h-24 w-24 rounded-lg object-cover shadow-2xl"
683
684
  })
684
685
  }) : null;
685
- })() : null, We = Ue != null, Ge = We ? I : ve;
686
- return V.current = We, /* @__PURE__ */ f("div", {
686
+ })() : null, Ge = We != null, Ke = Ge ? L : ve;
687
+ return H.current = Ge, /* @__PURE__ */ g("div", {
687
688
  onDragOver: (e) => {
688
- e.preventDefault(), Be && M(!0);
689
+ e.preventDefault(), Ve && N(!0);
689
690
  },
690
- onDragLeave: () => M(!1),
691
+ onDragLeave: () => N(!1),
691
692
  onDrop: (e) => {
692
- e.preventDefault(), M(!1), Be && e.dataTransfer.files?.length && be(e.dataTransfer.files);
693
+ e.preventDefault(), N(!1), Ve && e.dataTransfer.files?.length && xe(e.dataTransfer.files);
693
694
  },
694
- className: Pe,
695
+ className: Fe,
695
696
  children: [
696
- w ? /* @__PURE__ */ d("div", {
697
+ le ? /* @__PURE__ */ h("div", {
697
698
  className: "mb-3",
698
- children: w()
699
+ children: le()
699
700
  }) : null,
700
- /* @__PURE__ */ d("div", {
701
+ /* @__PURE__ */ h("div", {
701
702
  role: "status",
702
703
  className: "sr-only",
703
- children: Ve
704
+ children: He
704
705
  }),
705
- /* @__PURE__ */ f(p, {
706
- sensors: S ? void 0 : ye,
707
- collisionDetection: g,
708
- onDragStart: ke,
709
- onDragEnd: Ae,
710
- onDragCancel: je,
711
- children: [/* @__PURE__ */ d(v, {
706
+ /* @__PURE__ */ g(_, {
707
+ sensors: m ? void 0 : be,
708
+ collisionDetection: ie,
709
+ onDragStart: Ae,
710
+ onDragEnd: je,
711
+ onDragCancel: Me,
712
+ children: [/* @__PURE__ */ h(x, {
712
713
  items: k.map((e) => e.id),
713
- strategy: oe,
714
- children: /* @__PURE__ */ f("div", {
714
+ strategy: se,
715
+ children: /* @__PURE__ */ g("div", {
715
716
  className: "flex flex-wrap gap-3",
716
717
  children: [k.map((e) => {
717
718
  let t = e.status === "uploading", n = e.status === "error";
718
- return /* @__PURE__ */ d(le, {
719
+ return /* @__PURE__ */ h(de, {
719
720
  item: e,
720
- isHovered: _e === e.id,
721
- enableImagePreview: Re(e),
722
- renderItem: T,
721
+ isHovered: I === e.id,
722
+ enableImagePreview: ze(e),
723
+ renderItem: C,
723
724
  onHoverEnter: () => {
724
- Me(), F(e.id);
725
+ Ne(), _e(e.id);
725
726
  },
726
727
  onHoverLeave: () => {
727
- Me(), z.current = window.setTimeout(() => {
728
- F((t) => t === e.id ? null : t), z.current = null;
728
+ Ne(), B.current = window.setTimeout(() => {
729
+ _e((t) => t === e.id ? null : t), B.current = null;
729
730
  }, 120);
730
731
  },
731
- onRemove: Ce,
732
- onRetry: we,
733
- startFullscreen: Te,
732
+ onRemove: we,
733
+ onRetry: Te,
734
+ startFullscreen: Ee,
734
735
  isUploading: t,
735
736
  isError: n,
736
- tileClasses: Fe,
737
- disabled: S,
738
- isDraggingExternal: Ge === e.id,
739
- removeButtonAriaLabel: pe
740
- }, e.id);
741
- }), Be && (O === "bare" && k.length === 0 ? /* @__PURE__ */ f("button", {
737
+ tileClasses: Ie,
738
+ disabled: m,
739
+ isDraggingExternal: Ke === e.id,
740
+ removeButtonAriaLabel: T
741
+ }, e.renderKey);
742
+ }), Ve && (E === "bare" && k.length === 0 ? /* @__PURE__ */ g("button", {
742
743
  type: "button",
743
- onClick: Se,
744
- disabled: S,
744
+ onClick: Ce,
745
+ disabled: m,
745
746
  className: "flex w-full flex-col items-center justify-center gap-1 rounded-lg border border-dashed border-slate-300 px-4 py-6 text-slate-500 transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-600 dark:border-slate-700 dark:hover:bg-slate-800/50",
746
- "aria-label": E,
747
+ "aria-label": w,
747
748
  children: [
748
- /* @__PURE__ */ d(l, { className: "h-5 w-5" }),
749
- /* @__PURE__ */ d("span", {
749
+ /* @__PURE__ */ h(p, { className: "h-5 w-5" }),
750
+ /* @__PURE__ */ h("span", {
750
751
  className: "text-xs font-medium",
751
- children: E
752
+ children: w
752
753
  }),
753
- /* @__PURE__ */ d("span", {
754
+ /* @__PURE__ */ h("span", {
754
755
  className: "text-[11px] text-slate-400 dark:text-slate-500",
755
756
  children: "ou glissez-déposez ici"
756
757
  })
757
758
  ]
758
- }) : O === "bare" ? /* @__PURE__ */ d("button", {
759
+ }) : E === "bare" ? /* @__PURE__ */ h("button", {
759
760
  type: "button",
760
- onClick: Se,
761
- disabled: S,
761
+ onClick: Ce,
762
+ disabled: m,
762
763
  className: "flex size-20 items-center justify-center rounded-lg border border-dashed border-slate-300 text-slate-400 transition-colors hover:border-slate-400 hover:bg-slate-50 hover:text-slate-600 md:size-24 dark:border-slate-700 dark:hover:bg-slate-800/50 dark:hover:text-slate-300",
763
- "aria-label": E,
764
- children: /* @__PURE__ */ f("div", {
764
+ "aria-label": w,
765
+ children: /* @__PURE__ */ g("div", {
765
766
  className: "flex flex-col items-center gap-1",
766
- children: [/* @__PURE__ */ d(l, { className: "h-4 w-4" }), /* @__PURE__ */ d("span", {
767
+ children: [/* @__PURE__ */ h(p, { className: "h-4 w-4" }), /* @__PURE__ */ h("span", {
767
768
  className: "text-[11px] font-medium",
768
769
  children: "Ajouter"
769
770
  })]
770
771
  })
771
- }) : /* @__PURE__ */ d("button", {
772
+ }) : /* @__PURE__ */ h("button", {
772
773
  type: "button",
773
- onClick: Se,
774
- disabled: S,
775
- className: e(Fe, "flex items-center justify-center border-dashed bg-white text-slate-500 hover:border-slate-300 dark:bg-slate-900"),
776
- "aria-label": E,
777
- children: /* @__PURE__ */ f("div", {
774
+ onClick: Ce,
775
+ disabled: m,
776
+ className: e(Ie, "flex items-center justify-center border-dashed bg-white text-slate-500 hover:border-slate-300 dark:bg-slate-900"),
777
+ "aria-label": w,
778
+ children: /* @__PURE__ */ g("div", {
778
779
  className: "flex flex-col items-center gap-1",
779
- children: [/* @__PURE__ */ d("div", {
780
+ children: [/* @__PURE__ */ h("div", {
780
781
  className: "flex size-9 items-center justify-center rounded-full border border-slate-300 bg-slate-100 text-slate-600 shadow-inner dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200",
781
- children: /* @__PURE__ */ d(l, { className: "h-5 w-5" })
782
- }), /* @__PURE__ */ d("span", {
782
+ children: /* @__PURE__ */ h(p, { className: "h-5 w-5" })
783
+ }), /* @__PURE__ */ h("span", {
783
784
  className: "text-xs font-medium",
784
785
  children: "Ajouter"
785
786
  })]
@@ -787,71 +788,71 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
787
788
  }))]
788
789
  })
789
790
  }), (() => {
790
- let e = /* @__PURE__ */ d(m, {
791
- dropAnimation: U.current,
792
- children: Ue
791
+ let e = /* @__PURE__ */ h(v, {
792
+ dropAnimation: ye.current,
793
+ children: We
793
794
  });
794
- return typeof document > "u" ? e : ne(e, document.body);
795
+ return typeof document > "u" ? e : te(e, document.body);
795
796
  })()]
796
797
  }),
797
- /* @__PURE__ */ d("input", {
798
- ref: ge,
798
+ /* @__PURE__ */ h("input", {
799
+ ref: D,
799
800
  type: "file",
800
- accept: Ie,
801
- multiple: ze !== 1,
802
- disabled: !Be,
801
+ accept: Le,
802
+ multiple: Be !== 1,
803
+ disabled: !Ve,
803
804
  className: "hidden",
804
- onChange: xe,
805
+ onChange: Se,
805
806
  "aria-hidden": !0
806
807
  }),
807
- Ne && Re(Ne) && /* @__PURE__ */ f("div", {
808
+ Pe && ze(Pe) && /* @__PURE__ */ g("div", {
808
809
  className: "fixed inset-0 z-50 flex items-center justify-center bg-black/90",
809
810
  children: [
810
- /* @__PURE__ */ d("button", {
811
+ /* @__PURE__ */ h("button", {
811
812
  type: "button",
812
813
  className: "absolute left-6 top-1/2 -translate-y-1/2 rounded-full bg-white/10 p-3 text-white shadow-lg transition hover:bg-white/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
813
- onClick: () => P((e) => e === null ? e : (e - 1 + k.length) % k.length),
814
+ onClick: () => F((e) => e === null ? e : (e - 1 + k.length) % k.length),
814
815
  "aria-label": "Précédent",
815
- children: /* @__PURE__ */ d("svg", {
816
+ children: /* @__PURE__ */ h("svg", {
816
817
  viewBox: "0 0 24 24",
817
818
  className: "h-6 w-6",
818
819
  stroke: "currentColor",
819
820
  strokeWidth: 2,
820
821
  fill: "none",
821
- children: /* @__PURE__ */ d("path", {
822
+ children: /* @__PURE__ */ h("path", {
822
823
  d: "M15 18l-6-6 6-6",
823
824
  strokeLinecap: "round",
824
825
  strokeLinejoin: "round"
825
826
  })
826
827
  })
827
828
  }),
828
- /* @__PURE__ */ f("div", {
829
+ /* @__PURE__ */ g("div", {
829
830
  className: "relative max-h-[80vh] max-w-4xl",
830
- children: [/* @__PURE__ */ d(t, {
831
- src: Ne.url,
832
- alt: Ne.alt ?? "Fullscreen",
831
+ children: [/* @__PURE__ */ h(t, {
832
+ src: Pe.url,
833
+ alt: Pe.alt ?? "Fullscreen",
833
834
  sizes: "(max-width: 1024px) 100vw, 1024px",
834
835
  className: "max-h-[80vh] max-w-full rounded-lg object-contain shadow-2xl"
835
- }), /* @__PURE__ */ d("button", {
836
+ }), /* @__PURE__ */ h("button", {
836
837
  type: "button",
837
838
  className: "absolute right-3 top-3 inline-flex size-9 items-center justify-center rounded-full bg-black/70 text-white transition hover:bg-black focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
838
- onClick: () => P(null),
839
+ onClick: () => F(null),
839
840
  "aria-label": "Fermer",
840
- children: /* @__PURE__ */ d(te, { className: "h-5 w-5" })
841
+ children: /* @__PURE__ */ h(ee, { className: "h-5 w-5" })
841
842
  })]
842
843
  }),
843
- /* @__PURE__ */ d("button", {
844
+ /* @__PURE__ */ h("button", {
844
845
  type: "button",
845
846
  className: "absolute right-6 top-1/2 -translate-y-1/2 rounded-full bg-white/10 p-3 text-white shadow-lg transition hover:bg-white/20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",
846
- onClick: () => P((e) => e === null ? e : (e + 1) % k.length),
847
+ onClick: () => F((e) => e === null ? e : (e + 1) % k.length),
847
848
  "aria-label": "Suivant",
848
- children: /* @__PURE__ */ d("svg", {
849
+ children: /* @__PURE__ */ h("svg", {
849
850
  viewBox: "0 0 24 24",
850
851
  className: "h-6 w-6",
851
852
  stroke: "currentColor",
852
853
  strokeWidth: 2,
853
854
  fill: "none",
854
- children: /* @__PURE__ */ d("path", {
855
+ children: /* @__PURE__ */ h("path", {
855
856
  d: "M9 6l6 6-6 6",
856
857
  strokeLinecap: "round",
857
858
  strokeLinejoin: "round"
@@ -864,6 +865,6 @@ function O({ initialFiles: n = [], onChange: r, upload: c = ce, uploadIsPublic:
864
865
  });
865
866
  }
866
867
  //#endregion
867
- export { O as FilesUploadField };
868
+ export { M as FilesUploadField };
868
869
 
869
870
  //# sourceMappingURL=index299.js.map