@nivaro/react 0.3.50 → 0.3.52

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.
Files changed (29) hide show
  1. package/dist/hooks/useSessionRecorder.js +1 -1
  2. package/dist/index.d.ts +13 -3
  3. package/dist/shared/components/ItemEditForm.js +4801 -4666
  4. package/dist/shared/components/QueryTable.js +337 -324
  5. package/dist/shared/components/ReportView.js +105 -99
  6. package/dist/shared/components/alerts/AlertManagerView.js +327 -301
  7. package/dist/shared/components/item-edit/CatalogPickerField.js +1149 -1111
  8. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
  9. package/dist/shared/components/item-edit/FieldRenderer.js +227 -223
  10. package/dist/shared/components/item-edit/FieldRow.js +287 -265
  11. package/dist/shared/components/item-edit/FilePickerField.js +315 -307
  12. package/dist/shared/components/item-edit/InlineTableField.js +491 -466
  13. package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
  14. package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
  15. package/dist/shared/components/item-edit/RelationCombobox.js +62 -60
  16. package/dist/shared/components/item-edit/SummaryPanel.js +287 -277
  17. package/dist/shared/components/item-edit/UserChip.js +233 -200
  18. package/dist/shared/components/item-edit/header-midair.js +51 -0
  19. package/dist/shared/components/item-edit/line-midair.js +76 -70
  20. package/dist/shared/components/panels/CommentPanel.js +290 -284
  21. package/dist/shared/components/panels/ItemLockBanner.js +30 -30
  22. package/dist/shared/components/panels/PipelinePanel.js +956 -901
  23. package/dist/shared/components/panels/TaskPanel.js +71 -61
  24. package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
  25. package/dist/shared/components/panels/requirement-side-effects.js +40 -0
  26. package/dist/shared/components/queue/QueueWorklist.js +141 -130
  27. package/dist/shared/lib/draft-store.js +48 -34
  28. package/dist/shared/lib/query-stats.js +60 -60
  29. package/package.json +1 -1
@@ -1,65 +1,72 @@
1
- import { jsxs as i, jsx as t, Fragment as A } from "react/jsx-runtime";
2
- import { useQueryClient as fe, useQuery as Z } from "@tanstack/react-query";
3
- import { Clock as xe, Download as ge, Loader2 as I, Upload as re, X as ee, Plus as je, File as me, FileVideo as Pe, FileAudio as We, FileText as ie, FileSpreadsheet as $e, FileCode as Ke } from "lucide-react";
4
- import { useId as oe, useState as v, useRef as be, useEffect as B } from "react";
5
- import { useNivaroClient as de, useGridFlush as ye, useParentDraft as we } from "../../context.js";
6
- import { useFileHealth as ve } from "../../hooks/useFileHealth.js";
7
- import { get as te, post as he, del as pe } from "../../lib/commands.js";
8
- import { cn as ce } from "../../lib/utils.js";
9
- import { FilePreviewLightbox as Ne } from "../FilePreviewLightbox.js";
10
- import { useOnceVisible as ke, useFileUsage as _e, FileUsageChip as Fe } from "./FileUsage.js";
1
+ import { jsxs as i, jsx as e, Fragment as B } from "react/jsx-runtime";
2
+ import { useQueryClient as xe, useQuery as I } from "@tanstack/react-query";
3
+ import { Clock as ge, Download as be, Loader2 as ee, Upload as oe, X as te, Plus as je, File as he, FileVideo as Pe, FileAudio as We, FileText as re, FileSpreadsheet as Ke, FileCode as Oe } from "lucide-react";
4
+ import { useId as ce, useState as N, useRef as ye, useEffect as V } from "react";
5
+ import { useNivaroClient as ue, useGridFlush as we, useParentDraft as ve } from "../../context.js";
6
+ import { useFileHealth as Ne } from "../../hooks/useFileHealth.js";
7
+ import { get as le, post as pe, del as fe } from "../../lib/commands.js";
8
+ import { cn as de } from "../../lib/utils.js";
9
+ import { FilePreviewLightbox as ke } from "../FilePreviewLightbox.js";
10
+ import { useOnceVisible as _e, useFileUsage as Fe, FileUsageChip as Re } from "./FileUsage.js";
11
11
  import { useFileDownload as Ce } from "./file-download.js";
12
- import { useM2MStaging as Oe } from "./M2MStagingContext.js";
13
- function le(n) {
14
- return n ? n < 1024 ? `${n} B` : n < 1024 * 1024 ? `${(n / 1024).toFixed(1)} KB` : `${(n / (1024 * 1024)).toFixed(1)} MB` : null;
12
+ import { useM2MStaging as Qe } from "./M2MStagingContext.js";
13
+ function E(s) {
14
+ var w;
15
+ const a = ((s == null ? void 0 : s.title) ?? "").trim(), k = ((s == null ? void 0 : s.filename_download) ?? "").trim();
16
+ if (!a) return k;
17
+ const h = (w = /\.([A-Za-z0-9]{1,8})$/.exec(k)) == null ? void 0 : w[1];
18
+ return h ? new RegExp(`\\.${h}$`, "i").test(a) ? a : `${a}.${h}` : a;
15
19
  }
16
- function Le(n) {
17
- if (!n) return null;
18
- const a = new Date(n);
20
+ function se(s) {
21
+ return s ? s < 1024 ? `${s} B` : s < 1024 * 1024 ? `${(s / 1024).toFixed(1)} KB` : `${(s / (1024 * 1024)).toFixed(1)} MB` : null;
22
+ }
23
+ function Le(s) {
24
+ if (!s) return null;
25
+ const a = new Date(s);
19
26
  return a.toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" }) + " " + a.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" });
20
27
  }
21
- function Qe(n) {
22
- return !!n && n.startsWith("image/");
28
+ function Ee(s) {
29
+ return !!s && s.startsWith("image/");
23
30
  }
24
- function Te(n, a) {
25
- return n ? n.startsWith("video/") ? /* @__PURE__ */ t(Pe, { className: a, strokeWidth: 1.5 }) : n.startsWith("audio/") ? /* @__PURE__ */ t(We, { className: a, strokeWidth: 1.5 }) : n === "application/pdf" ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.startsWith("text/") ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.includes("spreadsheet") || n.includes("excel") || n === "text/csv" ? /* @__PURE__ */ t($e, { className: a, strokeWidth: 1.5 }) : n.includes("wordprocessing") || n.includes("msword") ? /* @__PURE__ */ t(ie, { className: a, strokeWidth: 1.5 }) : n.includes("json") || n.includes("javascript") || n.includes("typescript") || n.includes("xml") ? /* @__PURE__ */ t(Ke, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ t(me, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ t(me, { className: a, strokeWidth: 1.5 });
31
+ function Te(s, a) {
32
+ return s ? s.startsWith("video/") ? /* @__PURE__ */ e(Pe, { className: a, strokeWidth: 1.5 }) : s.startsWith("audio/") ? /* @__PURE__ */ e(We, { className: a, strokeWidth: 1.5 }) : s === "application/pdf" ? /* @__PURE__ */ e(re, { className: a, strokeWidth: 1.5 }) : s.startsWith("text/") ? /* @__PURE__ */ e(re, { className: a, strokeWidth: 1.5 }) : s.includes("spreadsheet") || s.includes("excel") || s === "text/csv" ? /* @__PURE__ */ e(Ke, { className: a, strokeWidth: 1.5 }) : s.includes("wordprocessing") || s.includes("msword") ? /* @__PURE__ */ e(re, { className: a, strokeWidth: 1.5 }) : s.includes("json") || s.includes("javascript") || s.includes("typescript") || s.includes("xml") ? /* @__PURE__ */ e(Oe, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(he, { className: a, strokeWidth: 1.5 }) : /* @__PURE__ */ e(he, { className: a, strokeWidth: 1.5 });
26
33
  }
27
- function V({
28
- url: n,
34
+ function H({
35
+ url: s,
29
36
  type: a,
30
- filename: z,
31
- size: y = "md"
37
+ filename: k,
38
+ size: h = "md"
32
39
  }) {
33
- const L = y === "sm" ? "h-10 w-10" : y === "lg" ? "h-20 w-20" : "h-14 w-14";
34
- return Qe(a) ? /* @__PURE__ */ t(
40
+ const w = h === "sm" ? "h-10 w-10" : h === "lg" ? "h-20 w-20" : "h-14 w-14";
41
+ return Ee(a) ? /* @__PURE__ */ e(
35
42
  "img",
36
43
  {
37
- src: n,
38
- alt: z,
44
+ src: s,
45
+ alt: k,
39
46
  "data-file-thumb": !0,
40
- className: ce(L, "object-cover rounded shrink-0"),
47
+ className: de(w, "object-cover rounded shrink-0"),
41
48
  loading: "lazy",
42
- onError: (N) => {
43
- N.target.style.display = "none";
49
+ onError: (_) => {
50
+ _.target.style.display = "none";
44
51
  }
45
52
  }
46
- ) : /* @__PURE__ */ t("div", { className: ce(L, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: Te(a, y === "sm" ? "h-4 w-4" : "h-6 w-6") });
53
+ ) : /* @__PURE__ */ e("div", { className: de(w, "flex items-center justify-center rounded bg-slate-100 shrink-0"), children: Te(a, h === "sm" ? "h-4 w-4" : "h-6 w-6") });
47
54
  }
48
- function Re({
49
- selected: n,
55
+ function Ue({
56
+ selected: s,
50
57
  multi: a,
51
- onSelect: z,
52
- onClose: y,
53
- getUrl: L
58
+ onSelect: k,
59
+ onClose: h,
60
+ getUrl: w
54
61
  }) {
55
- const N = de(), [h, u] = v(""), { data: x = [], isLoading: p } = Z({
56
- queryKey: ["file-browser", h],
57
- queryFn: () => N.request(
58
- te("/files", {
62
+ const _ = ue(), [p, u] = N(""), { data: g = [], isLoading: f } = I({
63
+ queryKey: ["file-browser", p],
64
+ queryFn: () => _.request(
65
+ le("/files", {
59
66
  limit: "60",
60
67
  sort: "-uploaded_on",
61
68
  fields: "id,filename_download,title,type,filesize,width,height,missing_at",
62
- ...h ? { search: h } : {}
69
+ ...p ? { search: p } : {}
63
70
  })
64
71
  ).then((c) => c.data ?? []),
65
72
  staleTime: 3e4
@@ -70,61 +77,61 @@ function Re({
70
77
  "Select file",
71
78
  a ? "s" : ""
72
79
  ] }),
73
- /* @__PURE__ */ t(
80
+ /* @__PURE__ */ e(
74
81
  "button",
75
82
  {
76
83
  type: "button",
77
84
  "aria-label": "Close",
78
- onClick: y,
85
+ onClick: h,
79
86
  className: "text-slate-400 hover:text-slate-600",
80
- children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
87
+ children: /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5" })
81
88
  }
82
89
  )
83
90
  ] }),
84
- /* @__PURE__ */ t("div", { className: "px-3 pt-2 pb-1 shrink-0", children: /* @__PURE__ */ t(
91
+ /* @__PURE__ */ e("div", { className: "px-3 pt-2 pb-1 shrink-0", children: /* @__PURE__ */ e(
85
92
  "input",
86
93
  {
87
94
  type: "text",
88
95
  placeholder: "Search files…",
89
- value: h,
96
+ value: p,
90
97
  onChange: (c) => u(c.target.value),
91
98
  className: "w-full h-7 rounded border border-slate-200 px-2 text-[12px] focus:outline-none focus:ring-1 focus:ring-nvr-cyan",
92
99
  autoFocus: !0
93
100
  }
94
101
  ) }),
95
102
  /* @__PURE__ */ i("div", { className: "overflow-y-auto flex-1 p-3", children: [
96
- p && /* @__PURE__ */ t("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ t(I, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
97
- !p && x.length === 0 && /* @__PURE__ */ t("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
98
- !p && x.length > 0 && /* @__PURE__ */ t("div", { className: "grid grid-cols-5 gap-2", children: x.map((c) => {
99
- const w = n.includes(c.id);
103
+ f && /* @__PURE__ */ e("div", { className: "flex justify-center py-6", children: /* @__PURE__ */ e(ee, { className: "h-5 w-5 animate-spin text-slate-300" }) }),
104
+ !f && g.length === 0 && /* @__PURE__ */ e("p", { className: "text-center text-[12px] text-slate-400 py-6", children: "No files found" }),
105
+ !f && g.length > 0 && /* @__PURE__ */ e("div", { className: "grid grid-cols-5 gap-2", children: g.map((c) => {
106
+ const v = s.includes(c.id);
100
107
  return /* @__PURE__ */ i(
101
108
  "button",
102
109
  {
103
110
  type: "button",
104
- onClick: () => z(c.id),
105
- className: ce(
111
+ onClick: () => k(c.id),
112
+ className: de(
106
113
  "nvr-rise-in group flex flex-col items-center gap-1 rounded-lg p-1.5 text-left transition-colors border",
107
- w ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
114
+ v ? "border-nvr-cyan bg-nvr-cyan/5" : "border-transparent hover:border-slate-200 hover:bg-slate-50"
108
115
  ),
109
116
  children: [
110
117
  /* @__PURE__ */ i("div", { className: "relative", children: [
111
- /* @__PURE__ */ t(
112
- V,
118
+ /* @__PURE__ */ e(
119
+ H,
113
120
  {
114
- url: L(c.id),
121
+ url: w(c.id),
115
122
  type: c.type,
116
123
  filename: c.filename_download,
117
124
  size: "md"
118
125
  }
119
126
  ),
120
- w && /* @__PURE__ */ t("div", { className: "absolute inset-0 flex items-center justify-center rounded bg-nvr-cyan/20", children: /* @__PURE__ */ t("div", { className: "h-4 w-4 rounded-full bg-nvr-cyan flex items-center justify-center", children: /* @__PURE__ */ t(
127
+ v && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center rounded bg-nvr-cyan/20", children: /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-full bg-nvr-cyan flex items-center justify-center", children: /* @__PURE__ */ e(
121
128
  "svg",
122
129
  {
123
130
  className: "h-2.5 w-2.5 text-white",
124
131
  fill: "none",
125
132
  stroke: "currentColor",
126
133
  viewBox: "0 0 24 24",
127
- children: /* @__PURE__ */ t(
134
+ children: /* @__PURE__ */ e(
128
135
  "path",
129
136
  {
130
137
  strokeLinecap: "round",
@@ -136,12 +143,12 @@ function Re({
136
143
  }
137
144
  ) }) })
138
145
  ] }),
139
- /* @__PURE__ */ t(
146
+ /* @__PURE__ */ e(
140
147
  "span",
141
148
  {
142
149
  "data-file-name": !0,
143
150
  className: "text-[10px] text-slate-500 truncate w-full text-center leading-tight",
144
- children: c.title || c.filename_download
151
+ children: E(c)
145
152
  }
146
153
  )
147
154
  ]
@@ -152,103 +159,103 @@ function Re({
152
159
  ] })
153
160
  ] });
154
161
  }
155
- function Ie({
156
- value: n,
162
+ function et({
163
+ value: s,
157
164
  onChange: a,
158
- disabled: z,
159
- allowUpload: y = !0,
160
- allowPick: L = !0
165
+ disabled: k,
166
+ allowUpload: h = !0,
167
+ allowPick: w = !0
161
168
  }) {
162
- var q, D;
163
- const N = de(), h = fe(), u = ye(), x = oe(), [p, c] = v(!1), [w, R] = v(!1), [H, T] = v(null), [m, P] = v(null), [J, K] = v(null), f = be(null), r = !m && n ? String(n) : null, _ = (d) => N.fileUrl(d), W = Ce(), g = we(), $ = ((q = g == null ? void 0 : g.draft) == null ? void 0 : q.id) != null ? String(g.draft.id) : null, [G, U] = ke(!!r), F = _e(
164
- g == null ? void 0 : g.collection,
165
- $,
169
+ var z, Z;
170
+ const _ = ue(), p = xe(), u = we(), g = ce(), [f, c] = N(!1), [v, U] = N(!1), [J, T] = N(null), [m, j] = N(null), [D, K] = N(null), x = ye(null), r = !m && s ? String(s) : null, R = (d) => _.fileUrl(d), P = Ce(), b = ve(), W = ((z = b == null ? void 0 : b.draft) == null ? void 0 : z.id) != null ? String(b.draft.id) : null, [G, q] = _e(!!r), C = Fe(
171
+ b == null ? void 0 : b.collection,
172
+ W,
166
173
  r ? [r] : [],
167
- U
174
+ q
168
175
  );
169
- B(() => {
176
+ V(() => {
170
177
  if (!m) {
171
178
  K(null);
172
179
  return;
173
180
  }
174
181
  const d = URL.createObjectURL(m);
175
182
  return K(d), () => URL.revokeObjectURL(d);
176
- }, [m]), B(() => {
183
+ }, [m]), V(() => {
177
184
  if (!(!u || !m))
178
- return u.register(x, async () => {
179
- const d = await N.upload(m);
180
- a(d.id), P(null), h.invalidateQueries({ queryKey: ["file-browser"] });
181
- }), () => u.unregister(x);
182
- }, [u, m, x, N, a, h]);
183
- const E = ve([r]), { data: s, isLoading: S } = Z({
185
+ return u.register(g, async () => {
186
+ const d = await _.upload(m);
187
+ a(d.id), j(null), p.invalidateQueries({ queryKey: ["file-browser"] });
188
+ }), () => u.unregister(g);
189
+ }, [u, m, g, _, a, p]);
190
+ const A = Ne([r]), { data: n, isLoading: $ } = I({
184
191
  queryKey: ["file-meta", r],
185
- queryFn: () => N.request(te(`/files/${r}/meta`)).then((d) => d.data ?? null),
192
+ queryFn: () => _.request(le(`/files/${r}/meta`)).then((d) => d.data ?? null),
186
193
  enabled: !!r,
187
194
  staleTime: 6e4
188
195
  });
189
196
  async function X(d) {
190
197
  var Y;
191
- const j = (Y = d.target.files) == null ? void 0 : Y[0];
192
- if (j)
193
- if (f.current && (f.current.value = ""), u)
194
- P(j);
198
+ const S = (Y = d.target.files) == null ? void 0 : Y[0];
199
+ if (S)
200
+ if (x.current && (x.current.value = ""), u)
201
+ j(S);
195
202
  else {
196
- R(!0), window.dispatchEvent(
197
- new CustomEvent("nvr:upload-state", { detail: { name: j.name, state: "start" } })
203
+ U(!0), window.dispatchEvent(
204
+ new CustomEvent("nvr:upload-state", { detail: { name: S.name, state: "start" } })
198
205
  );
199
206
  try {
200
- const ne = await N.upload(j);
201
- a(ne.id), h.invalidateQueries({ queryKey: ["file-browser"] });
207
+ const ae = await _.upload(S);
208
+ a(ae.id), p.invalidateQueries({ queryKey: ["file-browser"] });
202
209
  } catch {
203
210
  } finally {
204
- R(!1), window.dispatchEvent(
205
- new CustomEvent("nvr:upload-state", { detail: { name: j.name, state: "done" } })
211
+ U(!1), window.dispatchEvent(
212
+ new CustomEvent("nvr:upload-state", { detail: { name: S.name, state: "done" } })
206
213
  );
207
214
  }
208
215
  }
209
216
  }
210
217
  function M(d) {
211
- P(null), a(d), c(!1);
218
+ j(null), a(d), c(!1);
212
219
  }
213
- function se() {
214
- P(null), a(null);
220
+ function ne() {
221
+ j(null), a(null);
215
222
  }
216
- const b = !!m;
223
+ const y = !!m;
217
224
  return /* @__PURE__ */ i("div", { className: "relative", children: [
218
- H && /* @__PURE__ */ t(Ne, { file: H, onClose: () => T(null) }),
219
- b || !!r ? /* @__PURE__ */ i(
225
+ J && /* @__PURE__ */ e(ke, { file: J, onClose: () => T(null) }),
226
+ y || !!r ? /* @__PURE__ */ i(
220
227
  "div",
221
228
  {
222
229
  ref: G,
223
230
  className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
224
231
  children: [
225
- b ? /* @__PURE__ */ t(
226
- V,
232
+ y ? /* @__PURE__ */ e(
233
+ H,
227
234
  {
228
- url: J ?? "",
235
+ url: D ?? "",
229
236
  type: m.type || null,
230
237
  filename: m.name,
231
238
  size: "sm"
232
239
  }
233
- ) : S ? /* @__PURE__ */ t("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : /* @__PURE__ */ t(
240
+ ) : $ ? /* @__PURE__ */ e("div", { className: "h-10 w-10 rounded bg-slate-200 dark:bg-[hsl(var(--nvr-skeleton))] animate-pulse" }) : /* @__PURE__ */ e(
234
241
  "button",
235
242
  {
236
243
  type: "button",
237
244
  title: "Preview",
238
245
  onClick: () => T({
239
246
  id: r,
240
- url: _(r),
241
- name: (s == null ? void 0 : s.title) || (s == null ? void 0 : s.filename_download) || r,
242
- type: (s == null ? void 0 : s.type) ?? null,
243
- size: (s == null ? void 0 : s.filesize) ?? null
247
+ url: R(r),
248
+ name: E(n) || r,
249
+ type: (n == null ? void 0 : n.type) ?? null,
250
+ size: (n == null ? void 0 : n.filesize) ?? null
244
251
  }),
245
252
  className: "shrink-0 cursor-zoom-in",
246
- children: /* @__PURE__ */ t(
247
- V,
253
+ children: /* @__PURE__ */ e(
254
+ H,
248
255
  {
249
- url: _(r),
250
- type: (s == null ? void 0 : s.type) ?? null,
251
- filename: (s == null ? void 0 : s.filename_download) ?? "",
256
+ url: R(r),
257
+ type: (n == null ? void 0 : n.type) ?? null,
258
+ filename: (n == null ? void 0 : n.filename_download) ?? "",
252
259
  size: "sm"
253
260
  }
254
261
  )
@@ -256,9 +263,9 @@ function Ie({
256
263
  ),
257
264
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
258
265
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
259
- b && /* @__PURE__ */ t(xe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
260
- /* @__PURE__ */ t("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: b ? m.name : (s == null ? void 0 : s.title) || (s == null ? void 0 : s.filename_download) || r }),
261
- !b && (E.verdict(r) ?? !!(s != null && s.missing_at)) && /* @__PURE__ */ t(
266
+ y && /* @__PURE__ */ e(ge, { className: "h-3 w-3 text-amber-400 shrink-0" }),
267
+ /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: y ? m.name : E(n) || r }),
268
+ !y && (A.verdict(r) ?? !!(n != null && n.missing_at)) && /* @__PURE__ */ e(
262
269
  "span",
263
270
  {
264
271
  className: "shrink-0 rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
@@ -267,42 +274,42 @@ function Ie({
267
274
  }
268
275
  )
269
276
  ] }),
270
- /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: b ? /* @__PURE__ */ i(A, { children: [
271
- m.type && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: m.type }),
272
- /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(m.size) }),
273
- /* @__PURE__ */ t("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
274
- ] }) : /* @__PURE__ */ i(A, { children: [
275
- (s == null ? void 0 : s.type) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: s.type }),
276
- (s == null ? void 0 : s.filesize) != null && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(s.filesize) }),
277
- (s == null ? void 0 : s.uploaded_on) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: Le(s.uploaded_on) }),
278
- (s == null ? void 0 : s.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
277
+ /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: y ? /* @__PURE__ */ i(B, { children: [
278
+ m.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: m.type }),
279
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: se(m.size) }),
280
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
281
+ ] }) : /* @__PURE__ */ i(B, { children: [
282
+ (n == null ? void 0 : n.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: n.type }),
283
+ (n == null ? void 0 : n.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: se(n.filesize) }),
284
+ (n == null ? void 0 : n.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Le(n.uploaded_on) }),
285
+ (n == null ? void 0 : n.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
279
286
  "by ",
280
- s.uploaded_by_name
287
+ n.uploaded_by_name
281
288
  ] })
282
289
  ] }) })
283
290
  ] }),
284
- !b && r && /* @__PURE__ */ t(
285
- Fe,
291
+ !y && r && /* @__PURE__ */ e(
292
+ Re,
286
293
  {
287
294
  fileId: r,
288
- uses: (D = F.data) == null ? void 0 : D[r],
289
- loading: F.isLoading,
290
- collection: g == null ? void 0 : g.collection,
291
- itemId: $
295
+ uses: (Z = C.data) == null ? void 0 : Z[r],
296
+ loading: C.isLoading,
297
+ collection: b == null ? void 0 : b.collection,
298
+ itemId: W
292
299
  }
293
300
  ),
294
- !b && r && /* @__PURE__ */ t(
301
+ !y && r && /* @__PURE__ */ e(
295
302
  "a",
296
303
  {
297
- href: `${_(r)}?download=1`,
298
- onClick: W(`${_(r)}?download=1`, s == null ? void 0 : s.filename_download),
304
+ href: `${R(r)}?download=1`,
305
+ onClick: P(`${R(r)}?download=1`, n == null ? void 0 : n.filename_download),
299
306
  title: "Download",
300
307
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
301
- children: /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5" })
308
+ children: /* @__PURE__ */ e(be, { className: "h-3.5 w-3.5" })
302
309
  }
303
310
  ),
304
- !z && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
305
- L && /* @__PURE__ */ t(
311
+ !k && /* @__PURE__ */ i("div", { className: "flex items-center gap-1 shrink-0", children: [
312
+ w && /* @__PURE__ */ e(
306
313
  "button",
307
314
  {
308
315
  type: "button",
@@ -311,285 +318,285 @@ function Ie({
311
318
  children: "Replace"
312
319
  }
313
320
  ),
314
- y && /* @__PURE__ */ i(A, { children: [
321
+ h && /* @__PURE__ */ i(B, { children: [
315
322
  /* @__PURE__ */ i(
316
323
  "button",
317
324
  {
318
325
  type: "button",
319
326
  onClick: () => {
320
327
  var d;
321
- return (d = f.current) == null ? void 0 : d.click();
328
+ return (d = x.current) == null ? void 0 : d.click();
322
329
  },
323
- disabled: w,
330
+ disabled: v,
324
331
  className: "h-6 px-2 rounded border border-slate-200 text-[11px] text-slate-600 hover:border-slate-400 disabled:opacity-40 flex items-center gap-1",
325
332
  children: [
326
- w ? /* @__PURE__ */ t(I, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
333
+ v ? /* @__PURE__ */ e(ee, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(oe, { className: "h-3 w-3" }),
327
334
  "Upload"
328
335
  ]
329
336
  }
330
337
  ),
331
- /* @__PURE__ */ t("input", { ref: f, type: "file", className: "hidden", onChange: X })
338
+ /* @__PURE__ */ e("input", { ref: x, type: "file", className: "hidden", onChange: X })
332
339
  ] }),
333
- /* @__PURE__ */ t(
340
+ /* @__PURE__ */ e(
334
341
  "button",
335
342
  {
336
343
  type: "button",
337
344
  "aria-label": "Remove file",
338
- onClick: se,
345
+ onClick: ne,
339
346
  className: "text-slate-300 hover:text-red-400 p-0.5",
340
- children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
347
+ children: /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5" })
341
348
  }
342
349
  )
343
350
  ] })
344
351
  ]
345
352
  }
346
353
  ) : /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
347
- L && /* @__PURE__ */ t(
354
+ w && /* @__PURE__ */ e(
348
355
  "button",
349
356
  {
350
357
  type: "button",
351
- disabled: z,
358
+ disabled: k,
352
359
  onClick: () => c(!0),
353
360
  className: "flex h-9 flex-1 items-center gap-2 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
354
361
  children: "Select file…"
355
362
  }
356
363
  ),
357
- y && !z && /* @__PURE__ */ i(A, { children: [
364
+ h && !k && /* @__PURE__ */ i(B, { children: [
358
365
  /* @__PURE__ */ i(
359
366
  "button",
360
367
  {
361
368
  type: "button",
362
369
  onClick: () => {
363
370
  var d;
364
- return (d = f.current) == null ? void 0 : d.click();
371
+ return (d = x.current) == null ? void 0 : d.click();
365
372
  },
366
- disabled: w,
373
+ disabled: v,
367
374
  className: "flex h-9 items-center gap-1.5 rounded-md border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
368
375
  children: [
369
- w ? /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
376
+ v ? /* @__PURE__ */ e(ee, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
370
377
  "Upload"
371
378
  ]
372
379
  }
373
380
  ),
374
- /* @__PURE__ */ t("input", { ref: f, type: "file", className: "hidden", onChange: X })
381
+ /* @__PURE__ */ e("input", { ref: x, type: "file", className: "hidden", onChange: X })
375
382
  ] })
376
383
  ] }),
377
- p && /* @__PURE__ */ t(
384
+ f && /* @__PURE__ */ e(
378
385
  "div",
379
386
  {
380
387
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
381
388
  style: { minWidth: 480 },
382
- children: /* @__PURE__ */ t(
383
- Re,
389
+ children: /* @__PURE__ */ e(
390
+ Ue,
384
391
  {
385
392
  selected: r ? [r] : [],
386
393
  multi: !1,
387
394
  onSelect: M,
388
395
  onClose: () => c(!1),
389
- getUrl: _
396
+ getUrl: R
390
397
  }
391
398
  )
392
399
  }
393
400
  )
394
401
  ] });
395
402
  }
396
- function et({
397
- relation: n,
403
+ function tt({
404
+ relation: s,
398
405
  parentId: a,
399
- allRelations: z,
400
- disabled: y,
401
- allowUpload: L = !0,
402
- allowPick: N = !0,
403
- pendingSave: h = !1
406
+ allRelations: k,
407
+ disabled: h,
408
+ allowUpload: w = !0,
409
+ allowPick: _ = !0,
410
+ pendingSave: p = !1
404
411
  }) {
405
- const u = de(), x = fe(), p = ye(), c = oe(), w = oe(), R = Oe(), [H, T] = v(!1), [m, P] = v(!1), [J, K] = v(null), [f, r] = v([]), _ = be(null), [W, g] = v([]), [$, G] = v(/* @__PURE__ */ new Set()), U = n.junction_field ?? "", F = n.many_field ?? "", E = n.one_field ?? `${n.many_collection}.${U}`, s = a === "new", S = (l) => u.fileUrl(l), X = Ce();
406
- B(() => () => {
407
- r((l) => (l.forEach((e) => URL.revokeObjectURL(e.url)), []));
408
- }, []), B(() => {
409
- if (!p || !f.length || h) return;
410
- const l = f;
411
- return p.register(c, async () => {
412
- for (const e of l) {
413
- const o = await u.upload(e.file);
414
- URL.revokeObjectURL(e.url), await ae(o.id);
412
+ const u = ue(), g = xe(), f = we(), c = ce(), v = ce(), U = Qe(), [J, T] = N(!1), [m, j] = N(!1), [D, K] = N(null), [x, r] = N([]), R = ye(null), [P, b] = N([]), [W, G] = N(/* @__PURE__ */ new Set()), q = s.junction_field ?? "", C = s.many_field ?? "", A = s.one_field ?? `${s.many_collection}.${q}`, n = a === "new", $ = (l) => u.fileUrl(l), X = Ce();
413
+ V(() => () => {
414
+ r((l) => (l.forEach((t) => URL.revokeObjectURL(t.url)), []));
415
+ }, []), V(() => {
416
+ if (!f || !x.length || p) return;
417
+ const l = x;
418
+ return f.register(c, async () => {
419
+ for (const t of l) {
420
+ const o = await u.upload(t.file);
421
+ URL.revokeObjectURL(t.url), await ie(o.id);
415
422
  }
416
- r([]), x.invalidateQueries({ queryKey: ["file-browser"] });
417
- }), () => p.unregister(c);
418
- }, [p, f, c, h]), B(() => {
419
- if (!p || !h) return;
420
- if (!(W.length > 0 || $.size > 0 || f.length > 0)) {
421
- p.unregister(w);
423
+ r([]), g.invalidateQueries({ queryKey: ["file-browser"] });
424
+ }), () => f.unregister(c);
425
+ }, [f, x, c, p]), V(() => {
426
+ if (!f || !p) return;
427
+ if (!(P.length > 0 || W.size > 0 || x.length > 0)) {
428
+ f.unregister(v);
422
429
  return;
423
430
  }
424
- const e = W, o = new Set($), C = f;
425
- return p.register(w, async () => {
426
- const ue = [];
427
- for (const O of C) {
431
+ const t = P, o = new Set(W), L = x;
432
+ return f.register(v, async () => {
433
+ const me = [];
434
+ for (const O of L) {
428
435
  const Q = await u.upload(O.file);
429
- URL.revokeObjectURL(O.url), ue.push(Q.id);
436
+ URL.revokeObjectURL(O.url), me.push(Q.id);
430
437
  }
431
- for (const O of [...e, ...ue])
438
+ for (const O of [...t, ...me])
432
439
  await u.request(
433
- he(`/items/${n.many_collection}`, {
434
- [F]: a,
435
- [U]: O
440
+ pe(`/items/${s.many_collection}`, {
441
+ [C]: a,
442
+ [q]: O
436
443
  })
437
444
  );
438
445
  for (const O of o) {
439
- const Q = M.find((Se) => String(Se[U]) === O);
440
- Q != null && Q.id && await u.request(pe(`/items/${n.many_collection}/${Q.id}`));
446
+ const Q = M.find((Se) => String(Se[q]) === O);
447
+ Q != null && Q.id && await u.request(fe(`/items/${s.many_collection}/${Q.id}`));
441
448
  }
442
- g([]), G(/* @__PURE__ */ new Set()), r([]), x.invalidateQueries({
443
- queryKey: ["m2m-items", n.many_collection, F, a]
444
- }), x.invalidateQueries({ queryKey: ["file-browser"] });
445
- }), () => p.unregister(w);
446
- }, [p, h, W, $, f, w]);
447
- const { data: M = [] } = Z({
448
- queryKey: ["m2m-items", n.many_collection, F, a],
449
+ b([]), G(/* @__PURE__ */ new Set()), r([]), g.invalidateQueries({
450
+ queryKey: ["m2m-items", s.many_collection, C, a]
451
+ }), g.invalidateQueries({ queryKey: ["file-browser"] });
452
+ }), () => f.unregister(v);
453
+ }, [f, p, P, W, x, v]);
454
+ const { data: M = [] } = I({
455
+ queryKey: ["m2m-items", s.many_collection, C, a],
449
456
  queryFn: () => u.request(
450
- te(`/items/${n.many_collection}`, {
451
- filter: JSON.stringify({ [F]: { _eq: a } }),
457
+ le(`/items/${s.many_collection}`, {
458
+ filter: JSON.stringify({ [C]: { _eq: a } }),
452
459
  limit: "200",
453
- fields: `id,${U}`
460
+ fields: `id,${q}`
454
461
  })
455
462
  ).then((l) => l.data ?? []),
456
- enabled: !!a && !s,
463
+ enabled: !!a && !n,
457
464
  staleTime: 3e4
458
- }), se = s && R ? R.getStagedLinks(E) : [], b = M.map((l) => String(l[U])), k = s ? se : h ? [...b.filter((l) => !$.has(l)), ...W] : b, q = we(), [D, d] = ke(b.length > 0), j = _e(
459
- q == null ? void 0 : q.collection,
460
- s ? null : a,
461
- b,
465
+ }), ne = n && U ? U.getStagedLinks(A) : [], y = M.map((l) => String(l[q])), F = n ? ne : p ? [...y.filter((l) => !W.has(l)), ...P] : y, z = ve(), [Z, d] = _e(y.length > 0), S = Fe(
466
+ z == null ? void 0 : z.collection,
467
+ n ? null : a,
468
+ y,
462
469
  d
463
- ), Y = ve(k), { data: ne = {} } = Z({
464
- queryKey: ["files-meta", ...k.sort()],
470
+ ), Y = Ne(F), { data: ae = {} } = I({
471
+ queryKey: ["files-meta", ...F.sort()],
465
472
  queryFn: async () => {
466
- if (!k.length) return {};
473
+ if (!F.length) return {};
467
474
  const l = await u.request(
468
- te("/files", {
469
- filter: JSON.stringify({ id: { _in: k } }),
470
- limit: String(k.length),
475
+ le("/files", {
476
+ filter: JSON.stringify({ id: { _in: F } }),
477
+ limit: String(F.length),
471
478
  fields: "id,filename_download,title,type,filesize,uploaded_on,uploaded_by_name,missing_at"
472
479
  })
473
- ).then((o) => o.data ?? []), e = {};
474
- for (const o of l) e[o.id] = o;
475
- return e;
480
+ ).then((o) => o.data ?? []), t = {};
481
+ for (const o of l) t[o.id] = o;
482
+ return t;
476
483
  },
477
- enabled: k.length > 0,
484
+ enabled: F.length > 0,
478
485
  staleTime: 6e4
479
486
  });
480
- async function Ue(l) {
481
- if (s && R) {
482
- R.unstageLink(E, l);
487
+ async function qe(l) {
488
+ if (n && U) {
489
+ U.unstageLink(A, l);
483
490
  return;
484
491
  }
485
- if (h) {
486
- W.includes(l) ? g((o) => o.filter((C) => C !== l)) : G((o) => /* @__PURE__ */ new Set([...o, l]));
492
+ if (p) {
493
+ P.includes(l) ? b((o) => o.filter((L) => L !== l)) : G((o) => /* @__PURE__ */ new Set([...o, l]));
487
494
  return;
488
495
  }
489
- const e = M.find((o) => String(o[U]) === l);
490
- e != null && e.id && (await u.request(pe(`/items/${n.many_collection}/${e.id}`)), x.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, F, a] }));
496
+ const t = M.find((o) => String(o[q]) === l);
497
+ t != null && t.id && (await u.request(fe(`/items/${s.many_collection}/${t.id}`)), g.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, C, a] }));
491
498
  }
492
- async function ae(l) {
493
- if (!k.includes(l)) {
494
- if (s && R) {
495
- R.stageLink(E, l);
499
+ async function ie(l) {
500
+ if (!F.includes(l)) {
501
+ if (n && U) {
502
+ U.stageLink(A, l);
496
503
  return;
497
504
  }
498
- if (h) {
499
- g((e) => e.includes(l) ? e : [...e, l]);
505
+ if (p) {
506
+ b((t) => t.includes(l) ? t : [...t, l]);
500
507
  return;
501
508
  }
502
509
  await u.request(
503
- he(`/items/${n.many_collection}`, { [F]: a, [U]: l })
504
- ), x.invalidateQueries({ queryKey: ["m2m-items", n.many_collection, F, a] });
510
+ pe(`/items/${s.many_collection}`, { [C]: a, [q]: l })
511
+ ), g.invalidateQueries({ queryKey: ["m2m-items", s.many_collection, C, a] });
505
512
  }
506
513
  }
507
- function qe(l) {
508
- URL.revokeObjectURL(l), r((e) => e.filter((o) => o.url !== l));
514
+ function ze(l) {
515
+ URL.revokeObjectURL(l), r((t) => t.filter((o) => o.url !== l));
509
516
  }
510
- async function ze(l) {
511
- const e = Array.from(l.target.files ?? []);
512
- if (e.length)
513
- if (_.current && (_.current.value = ""), p) {
514
- const o = e.map((C) => ({ file: C, url: URL.createObjectURL(C) }));
515
- r((C) => [...C, ...o]);
517
+ async function $e(l) {
518
+ const t = Array.from(l.target.files ?? []);
519
+ if (t.length)
520
+ if (R.current && (R.current.value = ""), f) {
521
+ const o = t.map((L) => ({ file: L, url: URL.createObjectURL(L) }));
522
+ r((L) => [...L, ...o]);
516
523
  } else {
517
- P(!0);
524
+ j(!0);
518
525
  try {
519
- for (const o of e) {
520
- const C = await u.upload(o);
521
- await ae(C.id);
526
+ for (const o of t) {
527
+ const L = await u.upload(o);
528
+ await ie(L.id);
522
529
  }
523
- x.invalidateQueries({ queryKey: ["file-browser"] });
530
+ g.invalidateQueries({ queryKey: ["file-browser"] });
524
531
  } catch {
525
532
  } finally {
526
- P(!1);
533
+ j(!1);
527
534
  }
528
535
  }
529
536
  }
530
537
  return /* @__PURE__ */ i("div", { className: "space-y-2", children: [
531
- J && /* @__PURE__ */ t(Ne, { file: J, onClose: () => K(null) }),
532
- (k.length > 0 || f.length > 0) && /* @__PURE__ */ i("div", { ref: D, className: "flex flex-col gap-1.5", children: [
533
- k.map((l) => {
538
+ D && /* @__PURE__ */ e(ke, { file: D, onClose: () => K(null) }),
539
+ (F.length > 0 || x.length > 0) && /* @__PURE__ */ i("div", { ref: Z, className: "flex flex-col gap-1.5", children: [
540
+ F.map((l) => {
534
541
  var o;
535
- const e = ne[l];
542
+ const t = ae[l];
536
543
  return /* @__PURE__ */ i(
537
544
  "div",
538
545
  {
539
546
  className: "flex items-center gap-2 rounded-lg border border-slate-200 p-2 bg-slate-50",
540
547
  children: [
541
- /* @__PURE__ */ t(
548
+ /* @__PURE__ */ e(
542
549
  "button",
543
550
  {
544
551
  type: "button",
545
552
  title: "Preview",
546
553
  onClick: () => K({
547
554
  id: l,
548
- url: S(l),
549
- name: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l,
550
- type: (e == null ? void 0 : e.type) ?? null,
551
- size: (e == null ? void 0 : e.filesize) ?? null
555
+ url: $(l),
556
+ name: E(t) || l,
557
+ type: (t == null ? void 0 : t.type) ?? null,
558
+ size: (t == null ? void 0 : t.filesize) ?? null
552
559
  }),
553
560
  className: "shrink-0 cursor-zoom-in",
554
- children: /* @__PURE__ */ t(
555
- V,
561
+ children: /* @__PURE__ */ e(
562
+ H,
556
563
  {
557
- url: S(l),
558
- type: (e == null ? void 0 : e.type) ?? null,
559
- filename: (e == null ? void 0 : e.filename_download) ?? l,
564
+ url: $(l),
565
+ type: (t == null ? void 0 : t.type) ?? null,
566
+ filename: (t == null ? void 0 : t.filename_download) ?? l,
560
567
  size: "sm"
561
568
  }
562
569
  )
563
570
  }
564
571
  ),
565
572
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
566
- /* @__PURE__ */ t(
573
+ /* @__PURE__ */ e(
567
574
  "button",
568
575
  {
569
576
  type: "button",
570
577
  onClick: () => K({
571
578
  id: l,
572
- url: S(l),
573
- name: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l,
574
- type: (e == null ? void 0 : e.type) ?? null,
575
- size: (e == null ? void 0 : e.filesize) ?? null
579
+ url: $(l),
580
+ name: E(t) || l,
581
+ type: (t == null ? void 0 : t.type) ?? null,
582
+ size: (t == null ? void 0 : t.filesize) ?? null
576
583
  }),
577
584
  "data-file-name": !0,
578
585
  className: "block w-full truncate text-left text-[12px] font-medium text-slate-700 hover:underline",
579
- children: (e == null ? void 0 : e.title) || (e == null ? void 0 : e.filename_download) || l
586
+ children: E(t) || l
580
587
  }
581
588
  ),
582
589
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
583
- (e == null ? void 0 : e.type) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: e.type }),
584
- (e == null ? void 0 : e.filesize) != null && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(e.filesize) }),
585
- (e == null ? void 0 : e.uploaded_on) && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: Le(e.uploaded_on) }),
586
- (e == null ? void 0 : e.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
590
+ (t == null ? void 0 : t.type) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: t.type }),
591
+ (t == null ? void 0 : t.filesize) != null && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: se(t.filesize) }),
592
+ (t == null ? void 0 : t.uploaded_on) && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: Le(t.uploaded_on) }),
593
+ (t == null ? void 0 : t.uploaded_by_name) && /* @__PURE__ */ i("span", { className: "text-[10px] text-slate-500", children: [
587
594
  "by ",
588
- e.uploaded_by_name
595
+ t.uploaded_by_name
589
596
  ] })
590
597
  ] })
591
598
  ] }),
592
- (Y.verdict(l) ?? !!(e != null && e.missing_at)) && /* @__PURE__ */ t(
599
+ (Y.verdict(l) ?? !!(t != null && t.missing_at)) && /* @__PURE__ */ e(
593
600
  "span",
594
601
  {
595
602
  className: "shrink-0 self-center rounded bg-red-500/10 px-1.5 py-0.5 text-[9.5px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
@@ -597,34 +604,34 @@ function et({
597
604
  children: "file missing"
598
605
  }
599
606
  ),
600
- !s && b.includes(l) && /* @__PURE__ */ t(
601
- Fe,
607
+ !n && y.includes(l) && /* @__PURE__ */ e(
608
+ Re,
602
609
  {
603
610
  fileId: l,
604
- uses: (o = j.data) == null ? void 0 : o[l],
605
- loading: j.isLoading,
606
- collection: q == null ? void 0 : q.collection,
611
+ uses: (o = S.data) == null ? void 0 : o[l],
612
+ loading: S.isLoading,
613
+ collection: z == null ? void 0 : z.collection,
607
614
  itemId: a
608
615
  }
609
616
  ),
610
- /* @__PURE__ */ t(
617
+ /* @__PURE__ */ e(
611
618
  "a",
612
619
  {
613
- href: `${S(l)}?download=1`,
614
- onClick: X(`${S(l)}?download=1`, e == null ? void 0 : e.filename_download),
620
+ href: `${$(l)}?download=1`,
621
+ onClick: X(`${$(l)}?download=1`, t == null ? void 0 : t.filename_download),
615
622
  title: "Download",
616
623
  className: "shrink-0 text-slate-400 hover:text-nvr-cyan p-0.5",
617
- children: /* @__PURE__ */ t(ge, { className: "h-3.5 w-3.5" })
624
+ children: /* @__PURE__ */ e(be, { className: "h-3.5 w-3.5" })
618
625
  }
619
626
  ),
620
- !y && /* @__PURE__ */ t(
627
+ !h && /* @__PURE__ */ e(
621
628
  "button",
622
629
  {
623
630
  type: "button",
624
631
  "aria-label": "Remove file",
625
- onClick: () => Ue(l),
632
+ onClick: () => qe(l),
626
633
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
627
- children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
634
+ children: /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5" })
628
635
  }
629
636
  )
630
637
  ]
@@ -632,13 +639,13 @@ function et({
632
639
  l
633
640
  );
634
641
  }),
635
- f.map((l) => /* @__PURE__ */ i(
642
+ x.map((l) => /* @__PURE__ */ i(
636
643
  "div",
637
644
  {
638
645
  className: "flex items-center gap-2 rounded-lg border border-amber-200 p-2 bg-amber-50/50",
639
646
  children: [
640
- /* @__PURE__ */ t(
641
- V,
647
+ /* @__PURE__ */ e(
648
+ H,
642
649
  {
643
650
  url: l.url,
644
651
  type: l.file.type || null,
@@ -648,23 +655,23 @@ function et({
648
655
  ),
649
656
  /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
650
657
  /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
651
- /* @__PURE__ */ t(xe, { className: "h-3 w-3 text-amber-400 shrink-0" }),
652
- /* @__PURE__ */ t("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: l.file.name })
658
+ /* @__PURE__ */ e(ge, { className: "h-3 w-3 text-amber-400 shrink-0" }),
659
+ /* @__PURE__ */ e("p", { "data-file-name": !0, className: "text-[12px] font-medium text-slate-700 truncate", children: l.file.name })
653
660
  ] }),
654
661
  /* @__PURE__ */ i("div", { className: "flex flex-wrap items-center gap-x-2 mt-0.5", children: [
655
- l.file.type && /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: l.file.type }),
656
- /* @__PURE__ */ t("span", { className: "text-[10px] text-slate-400", children: le(l.file.size) }),
657
- /* @__PURE__ */ t("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
662
+ l.file.type && /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: l.file.type }),
663
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-slate-400", children: se(l.file.size) }),
664
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-amber-500", children: "Pending upload" })
658
665
  ] })
659
666
  ] }),
660
- !y && /* @__PURE__ */ t(
667
+ !h && /* @__PURE__ */ e(
661
668
  "button",
662
669
  {
663
670
  type: "button",
664
671
  "aria-label": "Remove file",
665
- onClick: () => qe(l.url),
672
+ onClick: () => ze(l.url),
666
673
  className: "text-slate-300 hover:text-red-400 p-0.5 shrink-0",
667
- children: /* @__PURE__ */ t(ee, { className: "h-3.5 w-3.5" })
674
+ children: /* @__PURE__ */ e(te, { className: "h-3.5 w-3.5" })
668
675
  }
669
676
  )
670
677
  ]
@@ -672,8 +679,8 @@ function et({
672
679
  l.url
673
680
  ))
674
681
  ] }),
675
- !y && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
676
- N && /* @__PURE__ */ i("div", { className: "relative", children: [
682
+ !h && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
683
+ _ && /* @__PURE__ */ i("div", { className: "relative", children: [
677
684
  /* @__PURE__ */ i(
678
685
  "button",
679
686
  {
@@ -681,54 +688,54 @@ function et({
681
688
  onClick: () => T((l) => !l),
682
689
  className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 transition-colors",
683
690
  children: [
684
- /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5" }),
691
+ /* @__PURE__ */ e(je, { className: "h-3.5 w-3.5" }),
685
692
  "Add existing…"
686
693
  ]
687
694
  }
688
695
  ),
689
- H && /* @__PURE__ */ t(
696
+ J && /* @__PURE__ */ e(
690
697
  "div",
691
698
  {
692
699
  className: "absolute z-50 mt-1 rounded-lg border border-slate-200 bg-white shadow-lg dark:border-border dark:bg-card",
693
700
  style: { minWidth: 480 },
694
- children: /* @__PURE__ */ t(
695
- Re,
701
+ children: /* @__PURE__ */ e(
702
+ Ue,
696
703
  {
697
- selected: k,
704
+ selected: F,
698
705
  multi: !0,
699
- onSelect: (l) => ae(l),
706
+ onSelect: (l) => ie(l),
700
707
  onClose: () => T(!1),
701
- getUrl: S
708
+ getUrl: $
702
709
  }
703
710
  )
704
711
  }
705
712
  )
706
713
  ] }),
707
- L && /* @__PURE__ */ i(A, { children: [
714
+ w && /* @__PURE__ */ i(B, { children: [
708
715
  /* @__PURE__ */ i(
709
716
  "button",
710
717
  {
711
718
  type: "button",
712
719
  onClick: () => {
713
720
  var l;
714
- return (l = _.current) == null ? void 0 : l.click();
721
+ return (l = R.current) == null ? void 0 : l.click();
715
722
  },
716
723
  disabled: m,
717
724
  className: "flex h-8 items-center gap-1.5 rounded border border-dashed border-slate-300 px-3 text-[12px] text-slate-400 hover:border-slate-400 hover:text-slate-600 disabled:opacity-40 transition-colors",
718
725
  children: [
719
- m ? /* @__PURE__ */ t(I, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
726
+ m ? /* @__PURE__ */ e(ee, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" }),
720
727
  "Upload…"
721
728
  ]
722
729
  }
723
730
  ),
724
- /* @__PURE__ */ t(
731
+ /* @__PURE__ */ e(
725
732
  "input",
726
733
  {
727
- ref: _,
734
+ ref: R,
728
735
  type: "file",
729
736
  multiple: !0,
730
737
  className: "hidden",
731
- onChange: ze
738
+ onChange: $e
732
739
  }
733
740
  )
734
741
  ] })
@@ -736,6 +743,7 @@ function et({
736
743
  ] });
737
744
  }
738
745
  export {
739
- et as FileM2MField,
740
- Ie as FilePickerField
746
+ tt as FileM2MField,
747
+ et as FilePickerField,
748
+ E as fileDisplayName
741
749
  };