@nivaro/react 0.3.108 → 0.3.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,24 @@
1
- import { jsx as e, jsxs as r, Fragment as Ve } from "react/jsx-runtime";
2
- import { useQueryClient as je, useQuery as U, useMutation as K } from "@tanstack/react-query";
3
- import { Upload as We, Plus as $e, ArrowLeft as Re, FileUp as He, Link2 as Ge, Loader2 as me, Sparkles as Ze, ArrowRight as Ee, MoreHorizontal as Xe, Trash2 as Ye, ChevronsUpDown as et, Check as tt } from "lucide-react";
4
- import { useState as f, useMemo as V, useEffect as Ie, useRef as Te } from "react";
5
- import { useNivaroClient as ae, useNavigation as rt } from "../../context.js";
6
- import { get as W, del as at, post as L } from "../../lib/commands.js";
7
- import { errorSentence as st, rowErrorSentence as De } from "../../lib/error-message.js";
8
- import { formatNumber as C, toLocalDateString as lt, cn as k, formatRelative as ot, formatDateTime as te } from "../../lib/utils.js";
9
- import { DataTable as nt } from "../DataTable.js";
1
+ import { jsx as e, jsxs as a, Fragment as Ze } from "react/jsx-runtime";
2
+ import { useQueryClient as Xe, useQuery as L, useMutation as K } from "@tanstack/react-query";
3
+ import { Upload as Ye, Plus as Me, ArrowLeft as Te, FileUp as et, Link2 as tt, Loader2 as pe, Sparkles as at, ArrowRight as Ee, MoreHorizontal as rt, Trash2 as st, ChevronsUpDown as lt, Check as nt } from "lucide-react";
4
+ import { useState as g, useMemo as W, useEffect as Ie, useRef as Ae } from "react";
5
+ import { useNivaroClient as se, useNavigation as ot } from "../../context.js";
6
+ import { get as Q, del as dt, post as I } from "../../lib/commands.js";
7
+ import { errorSentence as it, rowErrorSentence as De } from "../../lib/error-message.js";
8
+ import { formatNumber as P, toLocalDateString as ct, cn as v, formatRelative as mt, formatDateTime as ae } from "../../lib/utils.js";
9
+ import { DataTable as pt } from "../DataTable.js";
10
10
  import { Button as F } from "../ui/button.js";
11
- import { Command as dt, CommandInput as it, CommandList as ct, CommandEmpty as mt, CommandItem as pt } from "../ui/command.js";
12
- import { DropdownMenu as ut, DropdownMenuTrigger as xt, DropdownMenuContent as ht, DropdownMenuItem as xe } from "../ui/dropdown-menu.js";
13
- import { Input as Ae } from "../ui/input.js";
14
- import { Label as J } from "../ui/label.js";
15
- import { Popover as bt, PopoverTrigger as ft, PopoverContent as gt } from "../ui/popover.js";
16
- import { SimpleSelect as vt } from "../ui/SimpleSelect.js";
17
- import { Sheet as kt, SheetContent as wt } from "../ui/sheet.js";
18
- import { Switch as Nt } from "../ui/switch.js";
19
- import { Textarea as yt } from "../ui/textarea.js";
20
- const pe = 25, ue = ["Source", "Map columns", "Options", "Confirm"], j = {
11
+ import { Command as ut, CommandInput as ht, CommandList as xt, CommandEmpty as bt, CommandGroup as ft, CommandItem as gt } from "../ui/command.js";
12
+ import { DropdownMenu as vt, DropdownMenuTrigger as kt, DropdownMenuContent as wt, DropdownMenuItem as xe } from "../ui/dropdown-menu.js";
13
+ import { Input as Re } from "../ui/input.js";
14
+ import { Label as V } from "../ui/label.js";
15
+ import { Popover as Nt, PopoverTrigger as yt, PopoverContent as _t } from "../ui/popover.js";
16
+ import { SimpleSelect as Ct } from "../ui/SimpleSelect.js";
17
+ import { Sheet as St, SheetContent as Pt } from "../ui/sheet.js";
18
+ import { Switch as $t } from "../ui/switch.js";
19
+ import { Textarea as qt } from "../ui/textarea.js";
20
+ import { collectionPickerOptions as Mt, fieldPickerOptions as Fe } from "./import-picker-options.js";
21
+ const ue = 25, he = ["Source", "Map columns", "Options", "Confirm"], H = {
21
22
  pending: { dot: "bg-slate-400", text: "text-slate-600 dark:text-slate-300", label: "Pending" },
22
23
  processing: {
23
24
  dot: "bg-nvr-cyan",
@@ -30,238 +31,247 @@ const pe = 25, ue = ["Source", "Map columns", "Options", "Confirm"], j = {
30
31
  label: "Complete"
31
32
  },
32
33
  failed: { dot: "bg-red-500", text: "text-red-700 dark:text-red-400", label: "Failed" }
33
- }, _t = "Roll back this import? Created rows are deleted (to trash) and overwritten rows restored to their prior values. One-shot.";
34
- function Ct({
35
- disabled: d,
36
- rolledBack: n,
37
- onConfirm: l
34
+ }, Tt = "Roll back this import? Created rows are deleted (to trash) and overwritten rows restored to their prior values. One-shot.";
35
+ function At({
36
+ disabled: c,
37
+ rolledBack: o,
38
+ onConfirm: n
38
39
  }) {
39
- const [m, i] = f(!1);
40
+ const [p, m] = g(!1);
40
41
  return /* @__PURE__ */ e(
41
42
  xe,
42
43
  {
43
- disabled: d,
44
- "data-armed": m ? "" : void 0,
45
- className: k(
46
- m && "max-w-[300px] whitespace-normal bg-red-50 font-medium text-red-700 focus:bg-red-100 focus:text-red-800 dark:bg-red-500/10 dark:text-red-400 dark:focus:bg-red-500/20 dark:focus:text-red-300"
44
+ disabled: c,
45
+ "data-armed": p ? "" : void 0,
46
+ className: v(
47
+ p && "max-w-[300px] whitespace-normal bg-red-50 font-medium text-red-700 focus:bg-red-100 focus:text-red-800 dark:bg-red-500/10 dark:text-red-400 dark:focus:bg-red-500/20 dark:focus:text-red-300"
47
48
  ),
48
49
  onSelect: (s) => {
49
- if (!m) {
50
- s.preventDefault(), i(!0);
50
+ if (!p) {
51
+ s.preventDefault(), m(!0);
51
52
  return;
52
53
  }
53
- i(!1), l();
54
+ m(!1), n();
54
55
  },
55
- children: m ? /* @__PURE__ */ r("span", { className: "block", children: [
56
- _t,
56
+ children: p ? /* @__PURE__ */ a("span", { className: "block", children: [
57
+ Tt,
57
58
  /* @__PURE__ */ e("span", { className: "mt-1 block text-[11px] font-semibold", children: "Choose again to roll back" })
58
- ] }) : n ? "Rolled back" : "Roll back this import"
59
+ ] }) : o ? "Rolled back" : "Roll back this import"
59
60
  }
60
61
  );
61
62
  }
62
- function Le({ status: d }) {
63
- const n = j[d] ?? j.pending;
64
- return /* @__PURE__ */ r("span", { className: k("flex items-center gap-1.5 text-[12px] font-medium", n.text), children: [
65
- /* @__PURE__ */ r("span", { className: "relative flex h-1.5 w-1.5 shrink-0", children: [
66
- d === "processing" && /* @__PURE__ */ e(
63
+ function Le({ status: c }) {
64
+ const o = H[c] ?? H.pending;
65
+ return /* @__PURE__ */ a("span", { className: v("flex items-center gap-1.5 text-[12px] font-medium", o.text), children: [
66
+ /* @__PURE__ */ a("span", { className: "relative flex h-1.5 w-1.5 shrink-0", children: [
67
+ c === "processing" && /* @__PURE__ */ e(
67
68
  "span",
68
69
  {
69
- className: k(
70
+ className: v(
70
71
  "absolute inline-flex h-full w-full rounded-full opacity-75 motion-safe:animate-ping",
71
- n.dot
72
+ o.dot
72
73
  )
73
74
  }
74
75
  ),
75
- /* @__PURE__ */ e("span", { className: k("relative inline-flex h-1.5 w-1.5 rounded-full", n.dot) })
76
+ /* @__PURE__ */ e("span", { className: v("relative inline-flex h-1.5 w-1.5 rounded-full", o.dot) })
76
77
  ] }),
77
- n.label
78
+ o.label
78
79
  ] });
79
80
  }
80
- function St({
81
- processed: d,
82
- total: n,
83
- failed: l
81
+ function Dt({
82
+ processed: c,
83
+ total: o,
84
+ failed: n
84
85
  }) {
85
- if (!n) return /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" });
86
- const m = Math.min(100, Math.round((d ?? 0) / n * 100));
87
- return /* @__PURE__ */ r("div", { className: "flex min-w-[92px] items-center gap-2", children: [
86
+ if (!o) return /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" });
87
+ const p = Math.min(100, Math.round((c ?? 0) / o * 100));
88
+ return /* @__PURE__ */ a("div", { className: "flex min-w-[92px] items-center gap-2", children: [
88
89
  /* @__PURE__ */ e("div", { className: "h-1.5 flex-1 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ e(
89
90
  "div",
90
91
  {
91
- className: k(
92
+ className: v(
92
93
  "h-full rounded-full transition-[width] duration-500",
93
- l ? "bg-red-500" : "bg-nvr-cyan"
94
+ n ? "bg-red-500" : "bg-nvr-cyan"
94
95
  ),
95
- style: { width: `${m}%` }
96
+ style: { width: `${p}%` }
96
97
  }
97
98
  ) }),
98
- /* @__PURE__ */ r("span", { className: "w-8 text-right text-[11px] tabular-nums text-slate-400", children: [
99
- m,
99
+ /* @__PURE__ */ a("span", { className: "w-8 text-right text-[11px] tabular-nums text-slate-400", children: [
100
+ p,
100
101
  "%"
101
102
  ] })
102
103
  ] });
103
104
  }
104
- function re(d) {
105
- const n = [];
106
- let l = "", m = !1;
107
- for (let i = 0; i < d.length; i++) {
108
- const s = d[i];
109
- m ? s === '"' && d[i + 1] === '"' ? (l += '"', i++) : s === '"' ? m = !1 : l += s : s === '"' ? m = !0 : s === "," ? (n.push(l), l = "") : l += s;
105
+ function re(c) {
106
+ const o = [];
107
+ let n = "", p = !1;
108
+ for (let m = 0; m < c.length; m++) {
109
+ const s = c[m];
110
+ p ? s === '"' && c[m + 1] === '"' ? (n += '"', m++) : s === '"' ? p = !1 : n += s : s === '"' ? p = !0 : s === "," ? (o.push(n), n = "") : n += s;
110
111
  }
111
- return n.push(l), n.map((i) => i.trim());
112
+ return o.push(n), o.map((m) => m.trim());
112
113
  }
113
- function Pt(d) {
114
- const n = d.split(/\r?\n/).filter((i) => i.trim());
115
- if (n.length === 0) return { headers: [], rows: [], rowCount: 0 };
116
- const l = re(n[0]), m = n.slice(1, 6).map(re);
117
- return { headers: l, rows: m, rowCount: Math.max(0, n.length - 1) };
114
+ function Rt(c) {
115
+ const o = c.split(/\r?\n/).filter((m) => m.trim());
116
+ if (o.length === 0) return { headers: [], rows: [], rowCount: 0 };
117
+ const n = re(o[0]), p = o.slice(1, 6).map(re);
118
+ return { headers: n, rows: p, rowCount: Math.max(0, o.length - 1) };
118
119
  }
119
- function X({
120
- value: d,
121
- onChange: n,
122
- options: l,
123
- placeholder: m = "Select…",
124
- className: i
120
+ function Y({
121
+ value: c,
122
+ onChange: o,
123
+ options: n,
124
+ placeholder: p = "Select…",
125
+ className: m,
126
+ wide: s = !1
125
127
  }) {
126
- const [s, g] = f(!1), S = l.find((x) => x.value === d);
127
- return /* @__PURE__ */ r(bt, { open: s, onOpenChange: g, children: [
128
- /* @__PURE__ */ e(ft, { asChild: !0, children: /* @__PURE__ */ r(
128
+ const [k, q] = g(!1), x = n.find((d) => d.value === c), $ = [];
129
+ for (const d of n) {
130
+ const i = $[$.length - 1];
131
+ i && i.name === d.group ? i.items.push(d) : $.push({ name: d.group, items: [d] });
132
+ }
133
+ return /* @__PURE__ */ a(Nt, { open: k, onOpenChange: q, children: [
134
+ /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ a(
129
135
  "button",
130
136
  {
131
137
  type: "button",
132
- className: k(
133
- "flex h-8 w-full items-center justify-between gap-2 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[12px] transition-colors hover:border-slate-300 dark:border-border dark:bg-card",
134
- i
138
+ className: v(
139
+ "flex h-8 w-full items-center justify-between gap-2 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[12.5px] transition-colors hover:border-slate-300 dark:border-border dark:bg-card",
140
+ m
135
141
  ),
136
142
  children: [
137
143
  /* @__PURE__ */ e(
138
144
  "span",
139
145
  {
140
- className: k(
141
- "truncate font-mono",
142
- S ? "text-slate-800 dark:text-foreground" : "text-slate-400"
146
+ className: v(
147
+ "truncate",
148
+ x != null && x.value ? "text-slate-800 dark:text-foreground" : "text-slate-400"
143
149
  ),
144
- children: (S == null ? void 0 : S.label) ?? m
150
+ title: x == null ? void 0 : x.hint,
151
+ children: (x == null ? void 0 : x.label) ?? p
145
152
  }
146
153
  ),
147
- /* @__PURE__ */ e(et, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
154
+ /* @__PURE__ */ e(lt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
148
155
  ]
149
156
  }
150
157
  ) }),
151
- /* @__PURE__ */ e(gt, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ r(dt, { children: [
152
- /* @__PURE__ */ e(it, { placeholder: "Search…", className: "h-8 text-[12px]" }),
153
- /* @__PURE__ */ r(ct, { children: [
154
- /* @__PURE__ */ e(mt, { children: "Nothing matches." }),
155
- l.map((x) => /* @__PURE__ */ r(
156
- pt,
158
+ /* @__PURE__ */ e(_t, { className: v("p-0", s ? "w-[320px]" : "w-[260px]"), align: "start", children: /* @__PURE__ */ a(ut, { children: [
159
+ /* @__PURE__ */ e(ht, { placeholder: "Search by name…", className: "h-8 text-[12px]" }),
160
+ /* @__PURE__ */ a(xt, { className: "max-h-[340px]", children: [
161
+ /* @__PURE__ */ e(bt, { children: "Nothing matches." }),
162
+ $.map((d, i) => /* @__PURE__ */ e(ft, { heading: d.name, children: d.items.map((u) => /* @__PURE__ */ a(
163
+ gt,
157
164
  {
158
- value: x.label,
165
+ value: `${u.label} ${u.hint ?? ""} ${u.value}`,
159
166
  onSelect: () => {
160
- n(x.value), g(!1);
167
+ o(u.value), q(!1);
161
168
  },
162
- className: "text-[12px]",
169
+ className: "items-start text-[12.5px]",
163
170
  children: [
164
171
  /* @__PURE__ */ e(
165
- tt,
172
+ nt,
166
173
  {
167
- className: k(
168
- "h-3.5 w-3.5",
169
- x.value === d ? "text-nvr-cyan opacity-100" : "opacity-0"
174
+ className: v(
175
+ "mt-0.5 h-3.5 w-3.5 shrink-0",
176
+ u.value === c ? "text-nvr-cyan opacity-100" : "opacity-0"
170
177
  )
171
178
  }
172
179
  ),
173
- /* @__PURE__ */ e("span", { className: "font-mono", children: x.label })
180
+ /* @__PURE__ */ a("span", { className: "min-w-0", children: [
181
+ /* @__PURE__ */ e("span", { className: "block truncate", children: u.label }),
182
+ u.hint && /* @__PURE__ */ e("span", { className: "block truncate font-mono text-[10.5px] text-slate-400 dark:text-slate-500", children: u.hint })
183
+ ] })
174
184
  ]
175
185
  },
176
- x.value || "__skip__"
177
- ))
186
+ u.value || "__skip__"
187
+ )) }, `${d.name ?? ""}-${i}`))
178
188
  ] })
179
189
  ] }) })
180
190
  ] });
181
191
  }
182
- function Mt({ confidence: d }) {
183
- const n = Math.round(d * 100), l = n >= 80 ? "text-emerald-700 dark:text-emerald-400" : n >= 50 ? "text-amber-700 dark:text-amber-400" : "text-slate-500";
184
- return /* @__PURE__ */ r(
192
+ function Ft({ confidence: c }) {
193
+ const o = Math.round(c * 100), n = o >= 80 ? "text-emerald-700 dark:text-emerald-400" : o >= 50 ? "text-amber-700 dark:text-amber-400" : "text-slate-500";
194
+ return /* @__PURE__ */ a(
185
195
  "span",
186
196
  {
187
- className: k("shrink-0 text-[10.5px] font-medium tabular-nums", l),
197
+ className: v("shrink-0 text-[10.5px] font-medium tabular-nums", n),
188
198
  title: "AI mapping confidence",
189
199
  children: [
190
200
  "AI ",
191
- n,
201
+ o,
192
202
  "%"
193
203
  ]
194
204
  }
195
205
  );
196
206
  }
197
- function Yt({
198
- initialJobId: d,
199
- onJobOpen: n
207
+ function na({
208
+ initialJobId: c,
209
+ onJobOpen: o
200
210
  }) {
201
- var Q;
202
- const l = ae(), m = je(), [i, s] = f("list"), [g, S] = f(d ?? null), [x, T] = f("all"), [p, c] = f(1), [v, w] = f(null), u = U({
211
+ var B;
212
+ const n = se(), p = Xe(), [m, s] = g("list"), [k, q] = g(c ?? null), [x, $] = g("all"), [d, i] = g(1), [u, N] = g(null), h = L({
203
213
  queryKey: ["collection-import-jobs"],
204
214
  // The endpoint returns every job the caller may see, so the counters below
205
215
  // are exact rather than page-scoped.
206
- queryFn: () => l.request(W("/imports")),
207
- refetchInterval: (a) => {
208
- var N;
209
- return (((N = a.state.data) == null ? void 0 : N.data) ?? []).some((A) => A.status === "pending" || A.status === "processing") ? 3e3 : !1;
216
+ queryFn: () => n.request(Q("/imports")),
217
+ refetchInterval: (r) => {
218
+ var y;
219
+ return (((y = r.state.data) == null ? void 0 : y.data) ?? []).some((R) => R.status === "pending" || R.status === "processing") ? 3e3 : !1;
210
220
  },
211
- placeholderData: (a) => a
212
- }), $ = V(() => {
213
- var a;
214
- return ((a = u.data) == null ? void 0 : a.data) ?? [];
215
- }, [(Q = u.data) == null ? void 0 : Q.data]), P = V(() => {
216
- const a = {};
217
- for (const N of $) a[N.status] = (a[N.status] ?? 0) + 1;
218
- return a;
219
- }, [$]), D = V(
220
- () => $.reduce(
221
- (a, N) => ({
222
- created: a.created + (N.created_rows ?? 0),
223
- updated: a.updated + (N.updated_rows ?? 0),
224
- skipped: a.skipped + (N.skipped_rows ?? 0),
225
- errors: a.errors + (N.error_rows ?? 0)
221
+ placeholderData: (r) => r
222
+ }), T = W(() => {
223
+ var r;
224
+ return ((r = h.data) == null ? void 0 : r.data) ?? [];
225
+ }, [(B = h.data) == null ? void 0 : B.data]), _ = W(() => {
226
+ const r = {};
227
+ for (const y of T) r[y.status] = (r[y.status] ?? 0) + 1;
228
+ return r;
229
+ }, [T]), D = W(
230
+ () => T.reduce(
231
+ (r, y) => ({
232
+ created: r.created + (y.created_rows ?? 0),
233
+ updated: r.updated + (y.updated_rows ?? 0),
234
+ skipped: r.skipped + (y.skipped_rows ?? 0),
235
+ errors: r.errors + (y.error_rows ?? 0)
226
236
  }),
227
237
  { created: 0, updated: 0, skipped: 0, errors: 0 }
228
238
  ),
229
- [$]
230
- ), O = x === "all" ? $ : $.filter((a) => a.status === x), H = O.slice((p - 1) * pe, p * pe);
231
- Ie(() => c(1), [x]);
232
- const E = K({
233
- mutationFn: (a) => l.request(at(`/imports/${a}`)),
239
+ [T]
240
+ ), z = x === "all" ? T : T.filter((r) => r.status === x), G = z.slice((d - 1) * ue, d * ue);
241
+ Ie(() => i(1), [x]);
242
+ const O = K({
243
+ mutationFn: (r) => n.request(dt(`/imports/${r}`)),
234
244
  onSuccess: () => {
235
- w(null), m.invalidateQueries({ queryKey: ["collection-import-jobs"] });
245
+ N(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
236
246
  },
237
- onError: (a) => w(a.message)
238
- }), G = K({
239
- mutationFn: (a) => l.request(L(`/imports/${a}/rollback`, {})),
247
+ onError: (r) => N(r.message)
248
+ }), Z = K({
249
+ mutationFn: (r) => n.request(I(`/imports/${r}/rollback`, {})),
240
250
  onSuccess: () => {
241
- w(null), m.invalidateQueries({ queryKey: ["collection-import-jobs"] });
251
+ N(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
242
252
  },
243
- onError: (a) => w(a.message)
253
+ onError: (r) => N(r.message)
244
254
  });
245
- function R(a) {
246
- S(a), n == null || n(a);
255
+ function A(r) {
256
+ q(r), o == null || o(r);
247
257
  }
248
- const Z = [
258
+ const X = [
249
259
  {
250
260
  key: "status",
251
261
  header: "Status",
252
262
  className: "w-[110px]",
253
- render: (a) => /* @__PURE__ */ e(Le, { status: a.status })
263
+ render: (r) => /* @__PURE__ */ e(Le, { status: r.status })
254
264
  },
255
265
  {
256
266
  key: "file_name",
257
267
  header: "File",
258
268
  className: "max-w-[220px]",
259
- render: (a) => /* @__PURE__ */ e(
269
+ render: (r) => /* @__PURE__ */ e(
260
270
  "span",
261
271
  {
262
272
  className: "block truncate font-mono text-[11.5px] text-slate-800 dark:text-foreground",
263
- title: a.file_name,
264
- children: a.file_name
273
+ title: r.file_name,
274
+ children: r.file_name
265
275
  }
266
276
  )
267
277
  },
@@ -269,18 +279,18 @@ function Yt({
269
279
  key: "collection",
270
280
  header: "Collection",
271
281
  className: "w-[170px]",
272
- render: (a) => /* @__PURE__ */ e("span", { className: "truncate font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: a.collection })
282
+ render: (r) => /* @__PURE__ */ e("span", { className: "truncate font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: r.collection })
273
283
  },
274
284
  {
275
285
  key: "progress",
276
286
  header: "Progress",
277
287
  className: "w-[130px]",
278
- render: (a) => /* @__PURE__ */ e(
279
- St,
288
+ render: (r) => /* @__PURE__ */ e(
289
+ Dt,
280
290
  {
281
- processed: a.processed_rows,
282
- total: a.total_rows,
283
- failed: a.status === "failed"
291
+ processed: r.processed_rows,
292
+ total: r.total_rows,
293
+ failed: r.status === "failed"
284
294
  }
285
295
  )
286
296
  },
@@ -289,39 +299,39 @@ function Yt({
289
299
  header: "Created",
290
300
  className: "w-[76px] text-right",
291
301
  headerClassName: "text-right",
292
- render: (a) => /* @__PURE__ */ e(Y, { n: a.created_rows })
302
+ render: (r) => /* @__PURE__ */ e(ee, { n: r.created_rows })
293
303
  },
294
304
  {
295
305
  key: "updated_rows",
296
306
  header: "Updated",
297
307
  className: "w-[76px] text-right",
298
308
  headerClassName: "text-right",
299
- render: (a) => /* @__PURE__ */ e(Y, { n: a.updated_rows })
309
+ render: (r) => /* @__PURE__ */ e(ee, { n: r.updated_rows })
300
310
  },
301
311
  {
302
312
  key: "skipped_rows",
303
313
  header: "Skipped",
304
314
  className: "w-[76px] text-right",
305
315
  headerClassName: "text-right",
306
- render: (a) => /* @__PURE__ */ e(Y, { n: a.skipped_rows })
316
+ render: (r) => /* @__PURE__ */ e(ee, { n: r.skipped_rows })
307
317
  },
308
318
  {
309
319
  key: "error_rows",
310
320
  header: "Errors",
311
321
  className: "w-[70px] text-right",
312
322
  headerClassName: "text-right",
313
- render: (a) => (a.error_rows ?? 0) > 0 ? /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] font-medium tabular-nums text-red-600 dark:text-red-400", children: C(a.error_rows ?? 0) }) : /* @__PURE__ */ e(Y, { n: 0 })
323
+ render: (r) => (r.error_rows ?? 0) > 0 ? /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] font-medium tabular-nums text-red-600 dark:text-red-400", children: P(r.error_rows ?? 0) }) : /* @__PURE__ */ e(ee, { n: 0 })
314
324
  },
315
325
  {
316
326
  key: "created_at",
317
327
  header: "Queued",
318
328
  className: "w-[110px]",
319
- render: (a) => /* @__PURE__ */ e(
329
+ render: (r) => /* @__PURE__ */ e(
320
330
  "span",
321
331
  {
322
332
  className: "text-[12px] text-slate-500 dark:text-muted-foreground",
323
- title: te(a.created_at),
324
- children: ot(a.created_at)
333
+ title: ae(r.created_at),
334
+ children: mt(r.created_at)
325
335
  }
326
336
  )
327
337
  },
@@ -329,33 +339,33 @@ function Yt({
329
339
  key: "__actions__",
330
340
  header: "",
331
341
  className: "w-[44px]",
332
- render: (a) => /* @__PURE__ */ e("div", { onClick: (N) => N.stopPropagation(), onKeyDown: (N) => N.stopPropagation(), children: /* @__PURE__ */ r(ut, { children: [
333
- /* @__PURE__ */ e(xt, { asChild: !0, children: /* @__PURE__ */ e(
342
+ render: (r) => /* @__PURE__ */ e("div", { onClick: (y) => y.stopPropagation(), onKeyDown: (y) => y.stopPropagation(), children: /* @__PURE__ */ a(vt, { children: [
343
+ /* @__PURE__ */ e(kt, { asChild: !0, children: /* @__PURE__ */ e(
334
344
  "button",
335
345
  {
336
346
  type: "button",
337
347
  className: "rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
338
- "aria-label": `Actions for ${a.file_name}`,
339
- children: /* @__PURE__ */ e(Xe, { className: "h-4 w-4" })
348
+ "aria-label": `Actions for ${r.file_name}`,
349
+ children: /* @__PURE__ */ e(rt, { className: "h-4 w-4" })
340
350
  }
341
351
  ) }),
342
- /* @__PURE__ */ r(ht, { align: "end", className: "text-[12.5px]", children: [
343
- /* @__PURE__ */ e(xe, { onSelect: () => R(a.id), children: "View details" }),
352
+ /* @__PURE__ */ a(wt, { align: "end", className: "text-[12.5px]", children: [
353
+ /* @__PURE__ */ e(xe, { onSelect: () => A(r.id), children: "View details" }),
344
354
  /* @__PURE__ */ e(
345
- Ct,
355
+ At,
346
356
  {
347
- disabled: a.status !== "complete" || !!a.rolled_back_at,
348
- rolledBack: !!a.rolled_back_at,
349
- onConfirm: () => G.mutate(a.id)
357
+ disabled: r.status !== "complete" || !!r.rolled_back_at,
358
+ rolledBack: !!r.rolled_back_at,
359
+ onConfirm: () => Z.mutate(r.id)
350
360
  }
351
361
  ),
352
- /* @__PURE__ */ r(
362
+ /* @__PURE__ */ a(
353
363
  xe,
354
364
  {
355
- disabled: a.status !== "complete" && a.status !== "failed",
356
- onSelect: () => E.mutate(a.id),
365
+ disabled: r.status !== "complete" && r.status !== "failed",
366
+ onSelect: () => O.mutate(r.id),
357
367
  children: [
358
- /* @__PURE__ */ e(Ye, { className: "h-3.5 w-3.5" }),
368
+ /* @__PURE__ */ e(st, { className: "h-3.5 w-3.5" }),
359
369
  " Delete job"
360
370
  ]
361
371
  }
@@ -364,344 +374,365 @@ function Yt({
364
374
  ] }) })
365
375
  }
366
376
  ];
367
- return i === "wizard" ? /* @__PURE__ */ e(
368
- qt,
377
+ return m === "wizard" ? /* @__PURE__ */ e(
378
+ Ot,
369
379
  {
370
380
  onCancel: () => s("list"),
371
- onCreated: (a) => {
372
- s("list"), m.invalidateQueries({ queryKey: ["collection-import-jobs"] }), R(a);
381
+ onCreated: (r) => {
382
+ s("list"), p.invalidateQueries({ queryKey: ["collection-import-jobs"] }), A(r);
373
383
  }
374
384
  }
375
- ) : /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
376
- v && /* @__PURE__ */ e("p", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-400", children: v }),
377
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-stretch divide-x divide-slate-200 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card", children: [
385
+ ) : /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
386
+ u && /* @__PURE__ */ e("p", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-400", children: u }),
387
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap items-stretch divide-x divide-slate-200 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card", children: [
378
388
  /* @__PURE__ */ e(
379
- Fe,
389
+ Oe,
380
390
  {
381
391
  label: "All",
382
- count: $.length,
392
+ count: T.length,
383
393
  active: x === "all",
384
- onClick: () => T("all")
394
+ onClick: () => $("all")
385
395
  }
386
396
  ),
387
- Object.keys(j).map((a) => /* @__PURE__ */ e(
388
- Fe,
397
+ Object.keys(H).map((r) => /* @__PURE__ */ e(
398
+ Oe,
389
399
  {
390
- label: j[a].label,
391
- dot: j[a].dot,
392
- count: P[a] ?? 0,
393
- active: x === a,
394
- onClick: () => T(x === a ? "all" : a)
400
+ label: H[r].label,
401
+ dot: H[r].dot,
402
+ count: _[r] ?? 0,
403
+ active: x === r,
404
+ onClick: () => $(x === r ? "all" : r)
395
405
  },
396
- a
406
+ r
397
407
  )),
398
- /* @__PURE__ */ r("div", { className: "ml-auto flex items-stretch divide-x divide-slate-200 dark:divide-border", children: [
399
- /* @__PURE__ */ e(ee, { label: "Records created", value: C(D.created) }),
400
- /* @__PURE__ */ e(ee, { label: "Records updated", value: C(D.updated) }),
401
- /* @__PURE__ */ e(ee, { label: "Skipped", value: C(D.skipped) }),
408
+ /* @__PURE__ */ a("div", { className: "ml-auto flex items-stretch divide-x divide-slate-200 dark:divide-border", children: [
409
+ /* @__PURE__ */ e(te, { label: "Records created", value: P(D.created) }),
410
+ /* @__PURE__ */ e(te, { label: "Records updated", value: P(D.updated) }),
411
+ /* @__PURE__ */ e(te, { label: "Skipped", value: P(D.skipped) }),
402
412
  /* @__PURE__ */ e(
403
- ee,
413
+ te,
404
414
  {
405
415
  label: "Row errors",
406
- value: C(D.errors),
416
+ value: P(D.errors),
407
417
  tone: D.errors > 0 ? "red" : void 0
408
418
  }
409
419
  )
410
420
  ] })
411
421
  ] }),
412
- $.length === 0 && !u.isLoading ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-dashed border-slate-300 bg-white px-6 py-12 dark:border-border dark:bg-card", children: /* @__PURE__ */ r("div", { className: "max-w-[58ch]", children: [
413
- /* @__PURE__ */ e(We, { className: "h-5 w-5 text-slate-300" }),
422
+ T.length === 0 && !h.isLoading ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-dashed border-slate-300 bg-white px-6 py-12 dark:border-border dark:bg-card", children: /* @__PURE__ */ a("div", { className: "max-w-[58ch]", children: [
423
+ /* @__PURE__ */ e(Ye, { className: "h-5 w-5 text-slate-300" }),
414
424
  /* @__PURE__ */ e("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No collection imports yet" }),
415
425
  /* @__PURE__ */ e("p", { className: "mt-1.5 text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: "This is the row-by-row importer: a CSV's columns are mapped onto a collection's fields, and each row is created or updated through the normal item API — so validation, hooks and permissions all apply. Use it when you want records, not a staging table." }),
416
- /* @__PURE__ */ r(F, { size: "sm", className: "mt-4", onClick: () => s("wizard"), children: [
417
- /* @__PURE__ */ e($e, { className: "h-3.5 w-3.5" }),
426
+ /* @__PURE__ */ a(F, { size: "sm", className: "mt-4", onClick: () => s("wizard"), children: [
427
+ /* @__PURE__ */ e(Me, { className: "h-3.5 w-3.5" }),
418
428
  " Start an import"
419
429
  ] })
420
430
  ] }) }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(
421
- nt,
431
+ pt,
422
432
  {
423
- columns: Z,
424
- rows: H,
425
- rowKey: (a) => a.id,
426
- total: O.length,
427
- page: p,
428
- limit: pe,
429
- onPageChange: c,
430
- isLoading: u.isLoading,
431
- onRowClick: (a) => R(a.id),
433
+ columns: X,
434
+ rows: G,
435
+ rowKey: (r) => r.id,
436
+ total: z.length,
437
+ page: d,
438
+ limit: ue,
439
+ onPageChange: i,
440
+ isLoading: h.isLoading,
441
+ onRowClick: (r) => A(r.id),
432
442
  nowrapCells: !0,
433
443
  minBodyHeight: 280,
434
444
  emptyMessage: "No import jobs match this filter.",
435
- rowClassName: (a) => a.status === "processing" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
436
- toolbarRight: /* @__PURE__ */ r(F, { size: "sm", className: "h-7", onClick: () => s("wizard"), children: [
437
- /* @__PURE__ */ e($e, { className: "h-3.5 w-3.5" }),
445
+ rowClassName: (r) => r.status === "processing" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
446
+ toolbarRight: /* @__PURE__ */ a(F, { size: "sm", className: "h-7", onClick: () => s("wizard"), children: [
447
+ /* @__PURE__ */ e(Me, { className: "h-3.5 w-3.5" }),
438
448
  " New collection import"
439
449
  ] })
440
450
  }
441
451
  ) }),
442
- /* @__PURE__ */ e(Rt, { jobId: g, onClose: () => R(null) })
452
+ /* @__PURE__ */ e(It, { jobId: k, onClose: () => A(null) })
443
453
  ] });
444
454
  }
445
- function Y({ n: d }) {
446
- return /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-600 dark:text-muted-foreground", children: C(d ?? 0) });
455
+ function ee({ n: c }) {
456
+ return /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-600 dark:text-muted-foreground", children: P(c ?? 0) });
447
457
  }
448
- function ee({ label: d, value: n, tone: l }) {
449
- return /* @__PURE__ */ r("div", { className: "px-3.5 py-2", children: [
450
- /* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children: d }),
458
+ function te({ label: c, value: o, tone: n }) {
459
+ return /* @__PURE__ */ a("div", { className: "px-3.5 py-2", children: [
460
+ /* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children: c }),
451
461
  /* @__PURE__ */ e(
452
462
  "p",
453
463
  {
454
- className: k(
464
+ className: v(
455
465
  "mt-0.5 text-[15px] font-semibold leading-none tabular-nums",
456
- l === "red" ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
466
+ n === "red" ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
457
467
  ),
458
- children: n
468
+ children: o
459
469
  }
460
470
  )
461
471
  ] });
462
472
  }
463
- function Fe({
464
- label: d,
465
- count: n,
466
- dot: l,
467
- active: m,
468
- onClick: i
473
+ function Oe({
474
+ label: c,
475
+ count: o,
476
+ dot: n,
477
+ active: p,
478
+ onClick: m
469
479
  }) {
470
- return /* @__PURE__ */ r(
480
+ return /* @__PURE__ */ a(
471
481
  "button",
472
482
  {
473
483
  type: "button",
474
- onClick: i,
475
- "aria-pressed": m,
476
- className: k(
484
+ onClick: m,
485
+ "aria-pressed": p,
486
+ className: v(
477
487
  "flex items-center gap-1.5 px-3 py-2 transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
478
- m && "bg-nvr-cyan/10 ring-1 ring-inset ring-nvr-cyan dark:bg-nvr-cyan/15",
479
- !m && n === 0 && "opacity-45"
488
+ p && "bg-nvr-cyan/10 ring-1 ring-inset ring-nvr-cyan dark:bg-nvr-cyan/15",
489
+ !p && o === 0 && "opacity-45"
480
490
  ),
481
491
  children: [
482
- l && /* @__PURE__ */ e("span", { className: k("h-1.5 w-1.5 shrink-0 rounded-full", l) }),
483
- /* @__PURE__ */ e("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: C(n) }),
484
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: d })
492
+ n && /* @__PURE__ */ e("span", { className: v("h-1.5 w-1.5 shrink-0 rounded-full", n) }),
493
+ /* @__PURE__ */ e("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: P(o) }),
494
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: c })
485
495
  ]
486
496
  }
487
497
  );
488
498
  }
489
- function qt({
490
- onCancel: d,
491
- onCreated: n
499
+ function Ot({
500
+ onCancel: c,
501
+ onCreated: o
492
502
  }) {
493
503
  var ye, _e, Ce, Se;
494
- const l = ae(), m = Te(null), [i, s] = f(0), [g, S] = f(""), [x, T] = f({}), [p, c] = f(""), [v, w] = f(""), [u, $] = f(""), [P, D] = f({}), [O, H] = f({}), [E, G] = f("skip"), [R, Z] = f(""), [Q, a] = f(!1), [N, A] = f(null), [Oe, se] = f(!1), [ze, Ue] = f(null), he = Te(null), { headers: y, rows: be, rowCount: le } = V(() => Pt(g), [g]);
504
+ const n = se(), p = Ae(null), [m, s] = g(0), [k, q] = g(""), [x, $] = g({}), [d, i] = g(""), [u, N] = g(""), [h, T] = g(""), [_, D] = g({}), [z, G] = g({}), [O, Z] = g("skip"), [A, X] = g(""), [B, r] = g(!1), [y, R] = g(null), [ze, le] = g(!1), [Ue, Ke] = g(null), be = Ae(null), { headers: C, rows: fe, rowCount: ne } = W(() => Rt(k), [k]);
495
505
  Ie(() => {
496
- if (!u || y.length === 0) return;
497
- const t = `${u}|${y.join("")}`;
498
- he.current !== t && (he.current = t, l.request(L("/imports/mappings/lookup", { collection: u, headers: y })).then((o) => {
499
- const b = o.data;
500
- b && D((M) => {
501
- if (Object.values(M).some((h) => h == null ? void 0 : h.trim())) return M;
502
- const q = {};
503
- for (const h of y) b.column_map[h] && (q[h] = b.column_map[h]);
504
- return Object.keys(q).length === 0 ? M : (Ue(
505
- b.updated_at ? `Applied your saved mapping from ${lt(b.updated_at)}` : "Applied your saved mapping"
506
- ), b.id_field && Z((h) => h || b.id_field || ""), b.duplicate_strategy && G((h) => h === "skip" && b.duplicate_strategy || h), q);
506
+ if (!h || C.length === 0) return;
507
+ const t = `${h}|${C.join("")}`;
508
+ be.current !== t && (be.current = t, n.request(I("/imports/mappings/lookup", { collection: h, headers: C })).then((l) => {
509
+ const b = l.data;
510
+ b && D((w) => {
511
+ if (Object.values(w).some((f) => f == null ? void 0 : f.trim())) return w;
512
+ const M = {};
513
+ for (const f of C) b.column_map[f] && (M[f] = b.column_map[f]);
514
+ return Object.keys(M).length === 0 ? w : (Ke(
515
+ b.updated_at ? `Applied your saved mapping from ${ct(b.updated_at)}` : "Applied your saved mapping"
516
+ ), b.id_field && X((f) => f || b.id_field || ""), b.duplicate_strategy && Z((f) => f === "skip" && b.duplicate_strategy || f), M);
507
517
  });
508
518
  }).catch(() => {
509
519
  }));
510
- }, [u, y, l]);
511
- const fe = U({
520
+ }, [h, C, n]);
521
+ const ge = L({
512
522
  queryKey: [
513
523
  "import-diff-preview",
514
- u,
515
- R,
516
- E,
517
- g.length,
518
- JSON.stringify(P)
524
+ h,
525
+ A,
526
+ O,
527
+ k.length,
528
+ JSON.stringify(_)
519
529
  ],
520
- queryFn: () => l.request(
521
- L("/imports/preview", {
522
- collection: u,
523
- csv_data: g,
524
- column_map: P,
525
- id_field: R || null,
526
- duplicate_strategy: E
530
+ queryFn: () => n.request(
531
+ I("/imports/preview", {
532
+ collection: h,
533
+ csv_data: k,
534
+ column_map: _,
535
+ id_field: A || null,
536
+ duplicate_strategy: O
527
537
  })
528
538
  ),
529
- enabled: i === 3 && !!u && !!g,
539
+ enabled: m === 3 && !!h && !!k,
530
540
  staleTime: 3e4,
531
541
  retry: !1
532
- }), _ = (ye = fe.data) == null ? void 0 : ye.data, Ke = (((_e = U({
542
+ }), S = (ye = ge.data) == null ? void 0 : ye.data, Qe = L({
533
543
  queryKey: ["import-collections"],
534
- queryFn: () => l.request(W("/collections")),
544
+ queryFn: () => n.request(Q("/collections")),
535
545
  staleTime: 6e4
536
- }).data) == null ? void 0 : _e.data) ?? []).filter((t) => !t.collection.toLowerCase().startsWith("nivaro_")).map((t) => ({ value: t.collection, label: t.collection })), ge = U({
537
- queryKey: ["import-collection-meta", u],
538
- queryFn: () => l.request(
539
- W(`/collections/${u}`)
546
+ }), Be = L({
547
+ queryKey: ["import-collections-links"],
548
+ queryFn: () => n.request(Q("/collections/overview-stats")).then(
549
+ (t) => new Set(
550
+ Object.entries(t.data ?? {}).filter(([, l]) => l == null ? void 0 : l.link).map(([l]) => l)
551
+ )
552
+ ).catch(() => /* @__PURE__ */ new Set()),
553
+ staleTime: 5 * 6e4,
554
+ retry: !1
555
+ }), je = Mt(
556
+ ((_e = Qe.data) == null ? void 0 : _e.data) ?? [],
557
+ Be.data,
558
+ h
559
+ ), oe = L({
560
+ queryKey: ["import-collection-meta", h],
561
+ queryFn: () => n.request(
562
+ Q(`/collections/${h}`)
540
563
  ),
541
- enabled: !!u,
564
+ enabled: !!h,
542
565
  staleTime: 6e4
543
- }), oe = (((Se = (Ce = ge.data) == null ? void 0 : Ce.data) == null ? void 0 : Se.fields) ?? []).filter((t) => !t.hidden).map((t) => t.field), ve = (t) => {
544
- var M, q, h;
545
- const o = t ? (h = (q = (M = ge.data) == null ? void 0 : M.data) == null ? void 0 : q.fields) == null ? void 0 : h.find((I) => I.field === t) : void 0, b = `${(o == null ? void 0 : o.special) ?? ""} ${(o == null ? void 0 : o.interface) ?? ""}`.toLowerCase();
566
+ }), j = Fe(((Se = (Ce = oe.data) == null ? void 0 : Ce.data) == null ? void 0 : Se.fields) ?? []), Je = j.map((t) => t.value), Ve = (t) => {
567
+ var l, b;
568
+ return t && !j.some((w) => w.value === t) ? [
569
+ ...j,
570
+ ...Fe(((b = (l = oe.data) == null ? void 0 : l.data) == null ? void 0 : b.fields) ?? [], t).filter(
571
+ (w) => w.value === t
572
+ )
573
+ ] : j;
574
+ }, ve = (t) => {
575
+ var w, M, f;
576
+ const l = t ? (f = (M = (w = oe.data) == null ? void 0 : w.data) == null ? void 0 : M.fields) == null ? void 0 : f.find((E) => E.field === t) : void 0, b = `${[(l == null ? void 0 : l.special) ?? ""].flat().join(" ")} ${(l == null ? void 0 : l.interface) ?? ""}`.toLowerCase();
546
577
  return /m2m|many-to-many/.test(b) ? "Links several: separate names (or ids) with commas" : /m2o|many-to-one/.test(b) ? "Matched by name or id" : null;
547
- }, ne = K({
548
- mutationFn: (t) => l.request(
549
- L("/imports/from-url", {
578
+ }, de = K({
579
+ mutationFn: (t) => n.request(
580
+ I("/imports/from-url", {
550
581
  url: t,
551
582
  preview: !0
552
583
  })
553
584
  ),
554
585
  onSuccess: (t) => {
555
- A(null), S(t.data.csv_data), c(t.data.file_name);
586
+ R(null), q(t.data.csv_data), i(t.data.file_name);
556
587
  },
557
- onError: (t) => A(t.message)
558
- }), de = K({
559
- mutationFn: () => l.request(
560
- L("/ai/map-columns", {
561
- collection: u,
562
- columns: y,
563
- sample_rows: be.slice(0, 5)
588
+ onError: (t) => R(t.message)
589
+ }), ie = K({
590
+ mutationFn: () => n.request(
591
+ I("/ai/map-columns", {
592
+ collection: h,
593
+ columns: C,
594
+ sample_rows: fe.slice(0, 5)
564
595
  })
565
596
  ),
566
597
  onSuccess: (t) => {
567
- var q;
568
- const o = ((q = t.data) == null ? void 0 : q.mappings) ?? t.mappings ?? [], b = { ...P }, M = {};
569
- for (const h of o)
570
- y.includes(h.column) && (b[h.column] = h.field ?? "", h.field && (M[h.column] = h.confidence ?? 0));
571
- D(b), H(M), A(null);
598
+ var M;
599
+ const l = ((M = t.data) == null ? void 0 : M.mappings) ?? t.mappings ?? [], b = { ..._ }, w = {};
600
+ for (const f of l)
601
+ C.includes(f.column) && (b[f.column] = f.field ?? "", f.field && (w[f.column] = f.confidence ?? 0));
602
+ D(b), G(w), R(null);
572
603
  },
573
- onError: (t) => A(
604
+ onError: (t) => R(
574
605
  t.status === 503 ? "AI mapping needs an Anthropic API key — add one in Settings, or map the columns by hand." : t.message
575
606
  )
576
- }), ie = K({
577
- mutationFn: () => l.request(
578
- L("/imports", {
579
- collection: u,
580
- csv_data: g,
581
- column_map: P,
607
+ }), ce = K({
608
+ mutationFn: () => n.request(
609
+ I("/imports", {
610
+ collection: h,
611
+ csv_data: k,
612
+ column_map: _,
582
613
  transforms: Object.fromEntries(Object.entries(x).filter(([, t]) => t)),
583
- duplicate_strategy: E,
584
- id_field: R || void 0,
585
- file_name: p || "import.csv",
586
- through_items: Q
614
+ duplicate_strategy: O,
615
+ id_field: A || void 0,
616
+ file_name: d || "import.csv",
617
+ through_items: B
587
618
  })
588
619
  ),
589
- onSuccess: (t) => n(t.data.id),
590
- onError: (t) => A(t.message)
620
+ onSuccess: (t) => o(t.data.id),
621
+ onError: (t) => R(t.message)
591
622
  });
592
- function ke(t, o) {
593
- D((b) => ({ ...b, [t]: o })), O[t] !== void 0 && H((b) => {
594
- const M = { ...b };
595
- return delete M[t], M;
623
+ function ke(t, l) {
624
+ D((b) => ({ ...b, [t]: l })), z[t] !== void 0 && G((b) => {
625
+ const w = { ...b };
626
+ return delete w[t], w;
596
627
  });
597
628
  }
598
629
  async function we(t) {
599
- t && (A(null), S(await t.text()), c(t.name));
630
+ t && (R(null), q(await t.text()), i(t.name));
600
631
  }
601
- const z = V(() => {
602
- const t = g.split(/\r?\n/).filter((q) => q.trim());
632
+ const U = W(() => {
633
+ const t = k.split(/\r?\n/).filter((M) => M.trim());
603
634
  if (t.length < 2) return {};
604
- const o = re(t[0]), b = t.slice(1, 2001).map(re), M = {};
605
- return o.forEach((q, h) => {
606
- let I = 0, Pe = 0, Me = 0, qe = 0;
607
- for (const Je of b) {
608
- const B = (Je[h] ?? "").trim();
609
- B && (I++, /^-?\$?[\d,]+(\.\d+)?$/.test(B) ? Pe++ : /^\d{4}-\d{2}-\d{2}/.test(B) || /^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(B) ? Me++ : /^(true|false|yes|no|y|n)$/i.test(B) && qe++);
635
+ const l = re(t[0]), b = t.slice(1, 2001).map(re), w = {};
636
+ return l.forEach((M, f) => {
637
+ let E = 0, Pe = 0, $e = 0, qe = 0;
638
+ for (const Ge of b) {
639
+ const J = (Ge[f] ?? "").trim();
640
+ J && (E++, /^-?\$?[\d,]+(\.\d+)?$/.test(J) ? Pe++ : /^\d{4}-\d{2}-\d{2}/.test(J) || /^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(J) ? $e++ : /^(true|false|yes|no|y|n)$/i.test(J) && qe++);
610
641
  }
611
- const Be = I === 0 ? "empty" : Pe / I > 0.9 ? "number" : Me / I > 0.9 ? "date" : qe / I > 0.9 ? "boolean" : "text";
612
- M[q] = { fill: Math.round(I / b.length * 100), guess: Be };
613
- }), M;
614
- }, [g]), ce = y.filter((t) => {
615
- var o;
616
- return (o = P[t]) == null ? void 0 : o.trim();
617
- }).length, Ne = ze, Qe = i === 0 ? y.length > 0 : i === 1 ? !!u && ce > 0 : !0;
618
- return /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-4", children: [
619
- /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
620
- /* @__PURE__ */ r(F, { variant: "ghost", size: "sm", className: "h-7 px-2", onClick: d, children: [
621
- /* @__PURE__ */ e(Re, { className: "h-3.5 w-3.5" }),
642
+ const He = E === 0 ? "empty" : Pe / E > 0.9 ? "number" : $e / E > 0.9 ? "date" : qe / E > 0.9 ? "boolean" : "text";
643
+ w[M] = { fill: Math.round(E / b.length * 100), guess: He };
644
+ }), w;
645
+ }, [k]), me = C.filter((t) => {
646
+ var l;
647
+ return (l = _[t]) == null ? void 0 : l.trim();
648
+ }).length, Ne = Ue, We = m === 0 ? C.length > 0 : m === 1 ? !!h && me > 0 : !0;
649
+ return /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-4", children: [
650
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-3", children: [
651
+ /* @__PURE__ */ a(F, { variant: "ghost", size: "sm", className: "h-7 px-2", onClick: c, children: [
652
+ /* @__PURE__ */ e(Te, { className: "h-3.5 w-3.5" }),
622
653
  " Back to jobs"
623
654
  ] }),
624
- /* @__PURE__ */ e("ol", { className: "flex items-center gap-1.5", children: ue.map((t, o) => /* @__PURE__ */ r("li", { className: "flex items-center gap-1.5", children: [
625
- /* @__PURE__ */ r(
655
+ /* @__PURE__ */ e("ol", { className: "flex items-center gap-1.5", children: he.map((t, l) => /* @__PURE__ */ a("li", { className: "flex items-center gap-1.5", children: [
656
+ /* @__PURE__ */ a(
626
657
  "button",
627
658
  {
628
659
  type: "button",
629
- onClick: () => o < i && s(o),
630
- disabled: o > i,
631
- className: k(
660
+ onClick: () => l < m && s(l),
661
+ disabled: l > m,
662
+ className: v(
632
663
  "flex items-center gap-1.5 rounded-md px-2 py-1 text-[12px] font-medium transition-colors",
633
- o === i ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : o < i ? "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted" : "text-slate-300 dark:text-slate-600"
664
+ l === m ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : l < m ? "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted" : "text-slate-300 dark:text-slate-600"
634
665
  ),
635
666
  children: [
636
- /* @__PURE__ */ e("span", { className: "tabular-nums", children: o + 1 }),
667
+ /* @__PURE__ */ e("span", { className: "tabular-nums", children: l + 1 }),
637
668
  t
638
669
  ]
639
670
  }
640
671
  ),
641
- o < ue.length - 1 && /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" })
672
+ l < he.length - 1 && /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" })
642
673
  ] }, t)) })
643
674
  ] }),
644
- /* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-y-auto rounded-lg border border-slate-200 bg-white p-5 dark:border-border dark:bg-card", children: [
645
- i === 0 && /* @__PURE__ */ r("div", { className: "max-w-[980px] space-y-5", children: [
675
+ /* @__PURE__ */ a("div", { className: "min-h-0 flex-1 overflow-y-auto rounded-lg border border-slate-200 bg-white p-5 dark:border-border dark:bg-card", children: [
676
+ m === 0 && /* @__PURE__ */ a("div", { className: "max-w-[980px] space-y-5", children: [
646
677
  /* @__PURE__ */ e(
647
678
  "input",
648
679
  {
649
- ref: m,
680
+ ref: p,
650
681
  type: "file",
651
682
  accept: ".csv,text/csv",
652
683
  className: "hidden",
653
684
  onChange: (t) => {
654
- var o;
655
- we(((o = t.target.files) == null ? void 0 : o[0]) ?? null), t.target.value = "";
685
+ var l;
686
+ we(((l = t.target.files) == null ? void 0 : l[0]) ?? null), t.target.value = "";
656
687
  }
657
688
  }
658
689
  ),
659
- /* @__PURE__ */ r("div", { className: "grid gap-4 lg:grid-cols-2", children: [
660
- /* @__PURE__ */ r(
690
+ /* @__PURE__ */ a("div", { className: "grid gap-4 lg:grid-cols-2", children: [
691
+ /* @__PURE__ */ a(
661
692
  "button",
662
693
  {
663
694
  type: "button",
664
695
  onClick: () => {
665
696
  var t;
666
- return (t = m.current) == null ? void 0 : t.click();
697
+ return (t = p.current) == null ? void 0 : t.click();
667
698
  },
668
699
  onDragOver: (t) => {
669
- t.preventDefault(), se(!0);
700
+ t.preventDefault(), le(!0);
670
701
  },
671
- onDragLeave: () => se(!1),
702
+ onDragLeave: () => le(!1),
672
703
  onDrop: (t) => {
673
- var o;
674
- t.preventDefault(), se(!1), we(((o = t.dataTransfer.files) == null ? void 0 : o[0]) ?? null);
704
+ var l;
705
+ t.preventDefault(), le(!1), we(((l = t.dataTransfer.files) == null ? void 0 : l[0]) ?? null);
675
706
  },
676
- className: k(
707
+ className: v(
677
708
  "flex flex-col items-center justify-center gap-1.5 rounded-md border border-dashed px-4 py-8 transition-colors",
678
- Oe ? "border-nvr-cyan bg-nvr-cyan/10" : "border-slate-300 hover:border-slate-400 hover:bg-slate-50 dark:border-border dark:hover:bg-muted/30"
709
+ ze ? "border-nvr-cyan bg-nvr-cyan/10" : "border-slate-300 hover:border-slate-400 hover:bg-slate-50 dark:border-border dark:hover:bg-muted/30"
679
710
  ),
680
711
  children: [
681
- /* @__PURE__ */ e(He, { className: "h-4 w-4 text-slate-400" }),
712
+ /* @__PURE__ */ e(et, { className: "h-4 w-4 text-slate-400" }),
682
713
  /* @__PURE__ */ e("span", { className: "text-[12.5px] font-medium text-slate-700 dark:text-foreground", children: "Drop a CSV, or click to choose" }),
683
- p && /* @__PURE__ */ e("span", { className: "font-mono text-[11px] text-slate-500", children: p })
714
+ d && /* @__PURE__ */ e("span", { className: "font-mono text-[11px] text-slate-500", children: d })
684
715
  ]
685
716
  }
686
717
  ),
687
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
688
- /* @__PURE__ */ r(J, { className: "flex items-center gap-1.5 text-[11.5px]", children: [
689
- /* @__PURE__ */ e(Ge, { className: "h-3.5 w-3.5 text-slate-400" }),
718
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
719
+ /* @__PURE__ */ a(V, { className: "flex items-center gap-1.5 text-[11.5px]", children: [
720
+ /* @__PURE__ */ e(tt, { className: "h-3.5 w-3.5 text-slate-400" }),
690
721
  " Or fetch from a URL"
691
722
  ] }),
692
- /* @__PURE__ */ r(
723
+ /* @__PURE__ */ a(
693
724
  "form",
694
725
  {
695
726
  className: "flex items-center gap-2",
696
727
  onSubmit: (t) => {
697
- t.preventDefault(), v.trim() && ne.mutate(v.trim());
728
+ t.preventDefault(), u.trim() && de.mutate(u.trim());
698
729
  },
699
730
  children: [
700
731
  /* @__PURE__ */ e(
701
- Ae,
732
+ Re,
702
733
  {
703
- value: v,
704
- onChange: (t) => w(t.target.value),
734
+ value: u,
735
+ onChange: (t) => N(t.target.value),
705
736
  placeholder: "https://example.com/data.csv",
706
737
  className: "h-8 font-mono text-[12px]"
707
738
  }
@@ -713,8 +744,8 @@ function qt({
713
744
  variant: "outline",
714
745
  size: "sm",
715
746
  className: "h-8 shrink-0",
716
- disabled: !v.trim() || ne.isPending,
717
- children: ne.isPending ? /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 animate-spin" }) : "Fetch"
747
+ disabled: !u.trim() || de.isPending,
748
+ children: de.isPending ? /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }) : "Fetch"
718
749
  }
719
750
  )
720
751
  ]
@@ -723,14 +754,14 @@ function qt({
723
754
  /* @__PURE__ */ e("p", { className: "text-[11px] leading-snug text-slate-400", children: "The server fetches it (25MB max, CSV or plain text) so the file never has to round-trip through your machine." })
724
755
  ] })
725
756
  ] }),
726
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
727
- /* @__PURE__ */ e(J, { className: "text-[11.5px]", children: "Or paste the rows" }),
757
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
758
+ /* @__PURE__ */ e(V, { className: "text-[11.5px]", children: "Or paste the rows" }),
728
759
  /* @__PURE__ */ e(
729
- yt,
760
+ qt,
730
761
  {
731
- value: g,
762
+ value: k,
732
763
  onChange: (t) => {
733
- S(t.target.value), p || c("pasted.csv");
764
+ q(t.target.value), d || i("pasted.csv");
734
765
  },
735
766
  rows: 5,
736
767
  spellCheck: !1,
@@ -740,109 +771,110 @@ val1,val2,val3`,
740
771
  }
741
772
  )
742
773
  ] }),
743
- y.length > 0 && /* @__PURE__ */ r("div", { className: "space-y-2", children: [
744
- /* @__PURE__ */ r("p", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: [
745
- /* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: C(le) }),
774
+ C.length > 0 && /* @__PURE__ */ a("div", { className: "space-y-2", children: [
775
+ /* @__PURE__ */ a("p", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: [
776
+ /* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: P(ne) }),
746
777
  " ",
747
778
  "data rows ×",
748
779
  " ",
749
- /* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: y.length }),
780
+ /* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: C.length }),
750
781
  " ",
751
782
  "columns"
752
783
  ] }),
753
- /* @__PURE__ */ e($t, { headers: y, rows: be })
784
+ /* @__PURE__ */ e(Et, { headers: C, rows: fe })
754
785
  ] })
755
786
  ] }),
756
- i === 1 && // Bounded width: a mapping row is a form field, and stretching the
787
+ m === 1 && // Bounded width: a mapping row is a form field, and stretching the
757
788
  // pickers to a 1600px viewport puts the CSV column and the field it
758
789
  // maps to half a screen apart.
759
- /* @__PURE__ */ r("div", { className: "max-w-[860px] space-y-4", children: [
760
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [
761
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
762
- /* @__PURE__ */ e(J, { className: "text-[11.5px]", children: "Target collection" }),
790
+ /* @__PURE__ */ a("div", { className: "max-w-[860px] space-y-4", children: [
791
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [
792
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
793
+ /* @__PURE__ */ e(V, { className: "text-[11.5px]", children: "Target collection" }),
763
794
  /* @__PURE__ */ e("div", { className: "w-[260px]", children: /* @__PURE__ */ e(
764
- X,
795
+ Y,
765
796
  {
766
- value: u,
767
- onChange: $,
768
- options: Ke,
769
- placeholder: "Choose a collection…"
797
+ value: h,
798
+ onChange: T,
799
+ options: je,
800
+ placeholder: "Choose a collection…",
801
+ wide: !0
770
802
  }
771
803
  ) }),
772
804
  /* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "Rows are written through the item API, so this collection's validation, hooks and permissions all apply." })
773
805
  ] }),
774
- /* @__PURE__ */ r(
806
+ /* @__PURE__ */ a(
775
807
  F,
776
808
  {
777
809
  variant: "outline",
778
810
  size: "sm",
779
811
  className: "h-8",
780
- disabled: !u || y.length === 0 || de.isPending,
781
- onClick: () => de.mutate(),
812
+ disabled: !h || C.length === 0 || ie.isPending,
813
+ onClick: () => ie.mutate(),
782
814
  children: [
783
- de.isPending ? /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Ze, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
815
+ ie.isPending ? /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(at, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
784
816
  "Match columns with AI"
785
817
  ]
786
818
  }
787
819
  )
788
820
  ] }),
789
- /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ r("table", { className: "w-full border-collapse", children: [
790
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { className: "bg-slate-50 dark:bg-muted/40", children: [
821
+ /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ a("table", { className: "w-full border-collapse", children: [
822
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { className: "bg-slate-50 dark:bg-muted/40", children: [
791
823
  /* @__PURE__ */ e("th", { className: "w-[45%] border-b border-slate-200 px-3 py-1.5 text-left text-[10.5px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: "CSV column" }),
792
824
  /* @__PURE__ */ e("th", { className: "border-b border-slate-200 px-3 py-1.5 text-left text-[10.5px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: "Collection field" })
793
825
  ] }) }),
794
- /* @__PURE__ */ e("tbody", { children: y.map((t) => /* @__PURE__ */ r(
826
+ /* @__PURE__ */ e("tbody", { children: C.map((t) => /* @__PURE__ */ a(
795
827
  "tr",
796
828
  {
797
829
  className: "border-b border-slate-100 last:border-b-0 dark:border-border/60",
798
830
  children: [
799
- /* @__PURE__ */ r("td", { className: "px-3 py-1.5 font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: [
831
+ /* @__PURE__ */ a("td", { className: "px-3 py-1.5 font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: [
800
832
  t,
801
- z[t] && /* @__PURE__ */ r(
833
+ U[t] && /* @__PURE__ */ a(
802
834
  "span",
803
835
  {
804
- className: k(
836
+ className: v(
805
837
  "ml-2 rounded px-1 py-0.5 font-sans text-[9.5px] font-medium",
806
- z[t].fill < 50 ? "bg-amber-100 text-amber-700 dark:bg-amber-400/15 dark:text-amber-400" : "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
838
+ U[t].fill < 50 ? "bg-amber-100 text-amber-700 dark:bg-amber-400/15 dark:text-amber-400" : "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
807
839
  ),
808
- "data-tip": `${z[t].fill}% of rows have a value · looks like ${z[t].guess}`,
840
+ "data-tip": `${U[t].fill}% of rows have a value · looks like ${U[t].guess}`,
809
841
  children: [
810
- z[t].guess,
842
+ U[t].guess,
811
843
  " · ",
812
- z[t].fill,
844
+ U[t].fill,
813
845
  "%"
814
846
  ]
815
847
  }
816
848
  )
817
849
  ] }),
818
- /* @__PURE__ */ r("td", { className: "px-3 py-1.5", children: [
819
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
820
- /* @__PURE__ */ e("div", { className: "w-[220px]", children: oe.length > 0 ? /* @__PURE__ */ e(
821
- X,
850
+ /* @__PURE__ */ a("td", { className: "px-3 py-1.5", children: [
851
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
852
+ /* @__PURE__ */ e("div", { className: "w-[220px]", children: Je.length > 0 ? /* @__PURE__ */ e(
853
+ Y,
822
854
  {
823
- value: P[t] ?? "",
824
- onChange: (o) => ke(t, o),
855
+ value: _[t] ?? "",
856
+ onChange: (l) => ke(t, l),
825
857
  options: [
826
- { value: "", label: "— skip this column —" },
827
- ...oe.map((o) => ({ value: o, label: o }))
858
+ { value: "", label: "Skip this column" },
859
+ ...Ve(_[t])
828
860
  ],
829
- placeholder: "— skip this column —"
861
+ placeholder: "Skip this column"
830
862
  }
831
863
  ) : /* @__PURE__ */ e(
832
- Ae,
864
+ Re,
833
865
  {
834
- value: P[t] ?? "",
835
- onChange: (o) => ke(t, o.target.value),
866
+ value: _[t] ?? "",
867
+ onChange: (l) => ke(t, l.target.value),
836
868
  placeholder: "field_name",
837
869
  className: "h-8 font-mono text-[12px]"
838
870
  }
839
871
  ) }),
840
- O[t] !== void 0 && P[t] && /* @__PURE__ */ e(Mt, { confidence: O[t] }),
841
- P[t] && /* @__PURE__ */ e("div", { className: "w-[120px]", children: /* @__PURE__ */ e(
842
- X,
872
+ z[t] !== void 0 && _[t] && /* @__PURE__ */ e(Ft, { confidence: z[t] }),
873
+ _[t] && /* @__PURE__ */ e("div", { className: "w-[120px]", children: /* @__PURE__ */ e(
874
+ Y,
843
875
  {
844
876
  value: x[t] ?? "",
845
- onChange: (o) => T((b) => ({ ...b, [t]: o })),
877
+ onChange: (l) => $((b) => ({ ...b, [t]: l })),
846
878
  options: [
847
879
  { value: "", label: "As-is" },
848
880
  { value: "trim", label: "Trim" },
@@ -855,29 +887,29 @@ val1,val2,val3`,
855
887
  }
856
888
  ) })
857
889
  ] }),
858
- ve(P[t]) && /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] text-slate-500 dark:text-muted-foreground", children: ve(P[t]) })
890
+ ve(_[t]) && /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] text-slate-500 dark:text-muted-foreground", children: ve(_[t]) })
859
891
  ] })
860
892
  ]
861
893
  },
862
894
  t
863
895
  )) })
864
896
  ] }) }),
865
- /* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
866
- ce,
897
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
898
+ me,
867
899
  " of ",
868
- y.length,
900
+ C.length,
869
901
  " columns mapped — unmapped columns are ignored.",
870
902
  Ne && /* @__PURE__ */ e("span", { className: "ml-1.5 rounded bg-sky-500/10 px-1.5 py-0.5 text-[10.5px] font-medium text-sky-700 dark:text-sky-400", children: Ne })
871
903
  ] })
872
904
  ] }),
873
- i === 2 && /* @__PURE__ */ r("div", { className: "max-w-[520px] space-y-4", children: [
874
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
875
- /* @__PURE__ */ e(J, { className: "text-[11.5px]", children: "When a record already exists" }),
905
+ m === 2 && /* @__PURE__ */ a("div", { className: "max-w-[520px] space-y-4", children: [
906
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
907
+ /* @__PURE__ */ e(V, { className: "text-[11.5px]", children: "When a record already exists" }),
876
908
  /* @__PURE__ */ e(
877
- vt,
909
+ Ct,
878
910
  {
879
- value: E,
880
- onChange: G,
911
+ value: O,
912
+ onChange: Z,
881
913
  options: [
882
914
  { value: "skip", label: "Skip — leave the existing record alone" },
883
915
  { value: "overwrite", label: "Overwrite — replace every mapped field" },
@@ -887,96 +919,100 @@ val1,val2,val3`,
887
919
  }
888
920
  )
889
921
  ] }),
890
- /* @__PURE__ */ r("div", { className: "flex items-start gap-2.5 rounded-md border border-slate-200 bg-white px-3 py-2 dark:border-border dark:bg-card", children: [
922
+ /* @__PURE__ */ a("div", { className: "flex items-start gap-2.5 rounded-md border border-slate-200 bg-white px-3 py-2 dark:border-border dark:bg-card", children: [
891
923
  /* @__PURE__ */ e(
892
- Nt,
924
+ $t,
893
925
  {
894
926
  id: "csv-through-items",
895
- checked: Q,
896
- onCheckedChange: a,
927
+ checked: B,
928
+ onCheckedChange: r,
897
929
  className: "mt-0.5",
898
930
  "data-csv-through-items": !0
899
931
  }
900
932
  ),
901
- /* @__PURE__ */ r("label", { htmlFor: "csv-through-items", className: "cursor-pointer", children: [
933
+ /* @__PURE__ */ a("label", { htmlFor: "csv-through-items", className: "cursor-pointer", children: [
902
934
  /* @__PURE__ */ e("span", { className: "block text-[12px] font-medium text-slate-800 dark:text-foreground", children: "Apply rules and keep history" }),
903
935
  /* @__PURE__ */ e("span", { className: "block text-[11px] leading-snug text-slate-500 dark:text-muted-foreground", children: "Each row is saved the way the form saves it: field rules, validation, automations, and a revision on every record, credited to you. Rows that break a rule are reported instead of written. Unchanged fields are left alone. Slower on large files." })
904
936
  ] })
905
937
  ] }),
906
- /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
907
- /* @__PURE__ */ e(J, { className: "text-[11.5px]", children: "Match records on" }),
938
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
939
+ /* @__PURE__ */ e(V, { className: "text-[11.5px]", children: "Match records on" }),
908
940
  /* @__PURE__ */ e(
909
- X,
941
+ Y,
910
942
  {
911
- value: R,
912
- onChange: Z,
943
+ value: A,
944
+ onChange: X,
913
945
  options: [
914
- { value: "", label: "— always create new records —" },
915
- ...oe.map((t) => ({ value: t, label: t }))
946
+ { value: "", label: "Always create new records" },
947
+ // Match on a plain value: the record's id or any field a link list is not.
948
+ { value: "id", label: "ID", hint: "id" },
949
+ ...j.filter(
950
+ (t) => t.value !== "id" && !/links several/.test(t.hint ?? "")
951
+ )
916
952
  ],
917
- placeholder: "— always create new records —",
953
+ placeholder: "Always create new records",
918
954
  className: "w-[260px]"
919
955
  }
920
956
  ),
921
957
  /* @__PURE__ */ e("p", { className: "text-[11px] leading-snug text-slate-400", children: "The field used to decide whether a row is a duplicate. Leave it empty and every row becomes a new record." })
922
958
  ] })
923
959
  ] }),
924
- i === 3 && /* @__PURE__ */ r("div", { className: "max-w-[620px] space-y-4", children: [
925
- fe.isLoading && /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "Comparing against the live data…" }),
926
- _ && /* @__PURE__ */ r("div", { className: "space-y-2", children: [
927
- /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-2", children: [
960
+ m === 3 && /* @__PURE__ */ a("div", { className: "max-w-[620px] space-y-4", children: [
961
+ ge.isLoading && /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "Comparing against the live data…" }),
962
+ S && /* @__PURE__ */ a("div", { className: "space-y-2", children: [
963
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-2", children: [
928
964
  [
929
965
  {
930
966
  label: "new",
931
- n: _.new,
967
+ n: S.new,
932
968
  cls: "border-emerald-300 text-emerald-700 dark:border-emerald-500/40 dark:text-emerald-400"
933
969
  },
934
970
  {
935
971
  label: "changed",
936
- n: _.changed,
972
+ n: S.changed,
937
973
  cls: "border-amber-300 text-amber-700 dark:border-amber-500/40 dark:text-amber-400"
938
974
  },
939
975
  {
940
- label: _.conflicts === 1 ? "conflict" : "conflicts",
941
- n: _.conflicts,
976
+ label: S.conflicts === 1 ? "conflict" : "conflicts",
977
+ n: S.conflicts,
942
978
  cls: "border-red-300 text-red-700 dark:border-red-500/40 dark:text-red-400"
943
979
  },
944
980
  {
945
981
  label: "unchanged",
946
- n: _.unchanged,
982
+ n: S.unchanged,
947
983
  cls: "border-slate-200 text-slate-500 dark:border-border dark:text-slate-400"
948
984
  }
949
- ].map((t) => /* @__PURE__ */ r(
985
+ ].map((t) => /* @__PURE__ */ a(
950
986
  "span",
951
987
  {
952
- className: k(
988
+ className: v(
953
989
  "inline-flex items-center gap-1.5 rounded-full border bg-white px-2.5 py-1 text-[12px] font-medium dark:bg-card",
954
990
  t.cls
955
991
  ),
956
992
  children: [
957
- /* @__PURE__ */ e("span", { className: "tabular-nums", children: C(t.n) }),
993
+ /* @__PURE__ */ e("span", { className: "tabular-nums", children: P(t.n) }),
958
994
  " ",
959
995
  t.label
960
996
  ]
961
997
  },
962
998
  t.label
963
999
  )),
964
- _.truncated && /* @__PURE__ */ r("span", { className: "self-center text-[11px] text-slate-400", children: [
1000
+ S.truncated && /* @__PURE__ */ a("span", { className: "self-center text-[11px] text-slate-400", children: [
965
1001
  "(first ",
966
- C(_.total),
1002
+ P(S.total),
967
1003
  " rows scanned)"
968
1004
  ] })
969
1005
  ] }),
970
- _.diffs.length > 0 && /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: _.diffs.map((t) => /* @__PURE__ */ r(
1006
+ S.diffs.length > 0 && /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: S.diffs.map((t) => /* @__PURE__ */ a(
971
1007
  "div",
972
1008
  {
973
1009
  className: "border-b border-slate-100 px-3 py-2 text-[12px] last:border-b-0 dark:border-border/60",
974
1010
  children: [
975
- /* @__PURE__ */ r("p", { className: "flex items-center gap-2", children: [
1011
+ /* @__PURE__ */ a("p", { className: "flex items-center gap-2", children: [
976
1012
  /* @__PURE__ */ e(
977
1013
  "span",
978
1014
  {
979
- className: k(
1015
+ className: v(
980
1016
  "rounded px-1.5 py-0.5 text-[10.5px] font-semibold uppercase tracking-wide",
981
1017
  t.kind === "conflict" ? "bg-red-500/10 text-red-600 dark:text-red-400" : "bg-amber-400/10 text-amber-600 dark:text-amber-400"
982
1018
  ),
@@ -984,38 +1020,38 @@ val1,val2,val3`,
984
1020
  }
985
1021
  ),
986
1022
  /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px]", children: t.id }),
987
- /* @__PURE__ */ r("span", { className: "text-[11px] text-slate-400", children: [
1023
+ /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400", children: [
988
1024
  "row ",
989
1025
  t.row
990
1026
  ] })
991
1027
  ] }),
992
1028
  t.reason && /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-muted-foreground", children: t.reason }),
993
- t.fields.map((o) => /* @__PURE__ */ r("p", { className: "mt-0.5 font-mono text-[11px]", children: [
994
- /* @__PURE__ */ r("span", { className: "text-slate-400", children: [
995
- o.field,
1029
+ t.fields.map((l) => /* @__PURE__ */ a("p", { className: "mt-0.5 font-mono text-[11px]", children: [
1030
+ /* @__PURE__ */ a("span", { className: "text-slate-400", children: [
1031
+ l.field,
996
1032
  ":"
997
1033
  ] }),
998
1034
  " ",
999
- /* @__PURE__ */ e("span", { className: "text-red-600 line-through dark:text-red-400", children: String(o.old ?? "—") }),
1035
+ /* @__PURE__ */ e("span", { className: "text-red-600 line-through dark:text-red-400", children: String(l.old ?? "—") }),
1000
1036
  " ",
1001
- /* @__PURE__ */ e("span", { className: "text-emerald-600 dark:text-emerald-400", children: String(o.new ?? "—") })
1002
- ] }, o.field))
1037
+ /* @__PURE__ */ e("span", { className: "text-emerald-600 dark:text-emerald-400", children: String(l.new ?? "—") })
1038
+ ] }, l.field))
1003
1039
  ]
1004
1040
  },
1005
1041
  `${t.row}-${t.id}`
1006
1042
  )) }),
1007
- _.conflicts > 0 && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: "Conflicts need a look before you start — they are rows the import will silently drop or resolve by last-write-wins." }),
1008
- (_.link_error_rows ?? 0) > 0 && /* @__PURE__ */ r("div", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-500/30 dark:bg-red-500/10", children: [
1009
- /* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-red-700 dark:text-red-300", children: [
1010
- C(_.link_error_rows ?? 0),
1043
+ S.conflicts > 0 && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: "Conflicts need a look before you start — they are rows the import will silently drop or resolve by last-write-wins." }),
1044
+ (S.link_error_rows ?? 0) > 0 && /* @__PURE__ */ a("div", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-500/30 dark:bg-red-500/10", children: [
1045
+ /* @__PURE__ */ a("p", { className: "text-[12px] font-medium text-red-700 dark:text-red-300", children: [
1046
+ P(S.link_error_rows ?? 0),
1011
1047
  " ",
1012
- _.link_error_rows === 1 ? "row names" : "rows name",
1048
+ S.link_error_rows === 1 ? "row names" : "rows name",
1013
1049
  " a record that does not exist — ",
1014
- _.link_error_rows === 1 ? "it" : "they",
1050
+ S.link_error_rows === 1 ? "it" : "they",
1015
1051
  " will not be imported"
1016
1052
  ] }),
1017
- /* @__PURE__ */ e("ul", { className: "mt-1 max-h-32 space-y-0.5 overflow-y-auto text-[11.5px] text-red-700 dark:text-red-300", children: (_.link_problems ?? []).map((t) => /* @__PURE__ */ r("li", { children: [
1018
- /* @__PURE__ */ r("span", { className: "text-red-500/80 dark:text-red-400/70", children: [
1053
+ /* @__PURE__ */ e("ul", { className: "mt-1 max-h-32 space-y-0.5 overflow-y-auto text-[11.5px] text-red-700 dark:text-red-300", children: (S.link_problems ?? []).map((t) => /* @__PURE__ */ a("li", { children: [
1054
+ /* @__PURE__ */ a("span", { className: "text-red-500/80 dark:text-red-400/70", children: [
1019
1055
  "Row ",
1020
1056
  t.row,
1021
1057
  ":"
@@ -1026,20 +1062,20 @@ val1,val2,val3`,
1026
1062
  ] })
1027
1063
  ] }),
1028
1064
  /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: [
1029
- { label: "File", value: p || "pasted.csv", mono: !0 },
1030
- { label: "Collection", value: u, mono: !0 },
1031
- { label: "Data rows", value: C(le) },
1032
- { label: "Mapped columns", value: `${ce} of ${y.length}` },
1065
+ { label: "File", value: d || "pasted.csv", mono: !0 },
1066
+ { label: "Collection", value: h, mono: !0 },
1067
+ { label: "Data rows", value: P(ne) },
1068
+ { label: "Mapped columns", value: `${me} of ${C.length}` },
1033
1069
  {
1034
1070
  label: "Duplicates",
1035
- value: E === "skip" ? "Skipped" : E === "overwrite" ? "Overwritten" : "Merged"
1071
+ value: O === "skip" ? "Skipped" : O === "overwrite" ? "Overwritten" : "Merged"
1036
1072
  },
1037
1073
  {
1038
1074
  label: "Matched on",
1039
- value: R || "nothing — every row is new",
1040
- mono: !!R
1075
+ value: A || "nothing — every row is new",
1076
+ mono: !!A
1041
1077
  }
1042
- ].map((t) => /* @__PURE__ */ r(
1078
+ ].map((t) => /* @__PURE__ */ a(
1043
1079
  "div",
1044
1080
  {
1045
1081
  className: "flex items-center gap-4 border-b border-slate-100 px-3.5 py-2 last:border-b-0 dark:border-border/60",
@@ -1048,7 +1084,7 @@ val1,val2,val3`,
1048
1084
  /* @__PURE__ */ e(
1049
1085
  "span",
1050
1086
  {
1051
- className: k(
1087
+ className: v(
1052
1088
  "truncate text-[12.5px] text-slate-800 dark:text-foreground",
1053
1089
  t.mono && "font-mono text-[12px]"
1054
1090
  ),
@@ -1059,107 +1095,107 @@ val1,val2,val3`,
1059
1095
  },
1060
1096
  t.label
1061
1097
  )) }),
1062
- /* @__PURE__ */ r("p", { className: "text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: [
1098
+ /* @__PURE__ */ a("p", { className: "text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: [
1063
1099
  "Starting the import writes ",
1064
- C(le),
1100
+ P(ne),
1065
1101
  " rows into",
1066
1102
  " ",
1067
- /* @__PURE__ */ e("span", { className: "font-mono text-slate-700 dark:text-foreground", children: u }),
1103
+ /* @__PURE__ */ e("span", { className: "font-mono text-slate-700 dark:text-foreground", children: h }),
1068
1104
  " ",
1069
1105
  "one at a time. Progress appears in the job list as it runs."
1070
1106
  ] })
1071
1107
  ] })
1072
1108
  ] }),
1073
- /* @__PURE__ */ r("div", { className: "flex shrink-0 items-center gap-2", children: [
1074
- i > 0 && /* @__PURE__ */ r(F, { variant: "ghost", size: "sm", onClick: () => s((t) => t - 1), children: [
1075
- /* @__PURE__ */ e(Re, { className: "h-3.5 w-3.5" }),
1109
+ /* @__PURE__ */ a("div", { className: "flex shrink-0 items-center gap-2", children: [
1110
+ m > 0 && /* @__PURE__ */ a(F, { variant: "ghost", size: "sm", onClick: () => s((t) => t - 1), children: [
1111
+ /* @__PURE__ */ e(Te, { className: "h-3.5 w-3.5" }),
1076
1112
  " Back"
1077
1113
  ] }),
1078
- N && /* @__PURE__ */ e("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: N }),
1079
- /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", children: [
1080
- /* @__PURE__ */ e(F, { variant: "ghost", size: "sm", onClick: d, children: "Cancel" }),
1081
- i < ue.length - 1 ? /* @__PURE__ */ r(F, { size: "sm", disabled: !Qe, onClick: () => s((t) => t + 1), children: [
1114
+ y && /* @__PURE__ */ e("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: y }),
1115
+ /* @__PURE__ */ a("div", { className: "ml-auto flex items-center gap-2", children: [
1116
+ /* @__PURE__ */ e(F, { variant: "ghost", size: "sm", onClick: c, children: "Cancel" }),
1117
+ m < he.length - 1 ? /* @__PURE__ */ a(F, { size: "sm", disabled: !We, onClick: () => s((t) => t + 1), children: [
1082
1118
  "Next ",
1083
1119
  /* @__PURE__ */ e(Ee, { className: "h-3.5 w-3.5" })
1084
- ] }) : /* @__PURE__ */ e(F, { size: "sm", disabled: ie.isPending, onClick: () => ie.mutate(), children: ie.isPending ? /* @__PURE__ */ r(Ve, { children: [
1085
- /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5 animate-spin" }),
1120
+ ] }) : /* @__PURE__ */ e(F, { size: "sm", disabled: ce.isPending, onClick: () => ce.mutate(), children: ce.isPending ? /* @__PURE__ */ a(Ze, { children: [
1121
+ /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5 animate-spin" }),
1086
1122
  " Starting…"
1087
1123
  ] }) : "Start import" })
1088
1124
  ] })
1089
1125
  ] })
1090
1126
  ] });
1091
1127
  }
1092
- function $t({ headers: d, rows: n }) {
1093
- return /* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ r("table", { className: "w-full border-collapse", children: [
1094
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { className: "bg-slate-50 dark:bg-muted/40", children: d.map((l) => /* @__PURE__ */ e(
1128
+ function Et({ headers: c, rows: o }) {
1129
+ return /* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ a("table", { className: "w-full border-collapse", children: [
1130
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { className: "bg-slate-50 dark:bg-muted/40", children: c.map((n) => /* @__PURE__ */ e(
1095
1131
  "th",
1096
1132
  {
1097
1133
  className: "whitespace-nowrap border-b border-slate-200 px-2.5 py-1.5 text-left font-mono text-[10.5px] font-medium text-slate-500 dark:border-border dark:text-muted-foreground",
1098
- children: l
1134
+ children: n
1099
1135
  },
1100
- l
1136
+ n
1101
1137
  )) }) }),
1102
- /* @__PURE__ */ e("tbody", { children: n.map((l, m) => (
1138
+ /* @__PURE__ */ e("tbody", { children: o.map((n, p) => (
1103
1139
  // eslint-disable-next-line react/no-array-index-key
1104
- /* @__PURE__ */ e("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/60", children: d.map((i, s) => /* @__PURE__ */ e(
1140
+ /* @__PURE__ */ e("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/60", children: c.map((m, s) => /* @__PURE__ */ e(
1105
1141
  "td",
1106
1142
  {
1107
1143
  className: "max-w-[200px] truncate whitespace-nowrap px-2.5 py-1 font-mono text-[11px] text-slate-700 dark:text-foreground",
1108
- title: l[s] ?? "",
1109
- children: l[s] || /* @__PURE__ */ e("span", { className: "text-slate-300", children: "—" })
1144
+ title: n[s] ?? "",
1145
+ children: n[s] || /* @__PURE__ */ e("span", { className: "text-slate-300", children: "—" })
1110
1146
  },
1111
1147
  s
1112
- )) }, m)
1148
+ )) }, p)
1113
1149
  )) })
1114
1150
  ] }) });
1115
1151
  }
1116
- function Rt({ jobId: d, onClose: n }) {
1117
- var x, T;
1118
- const l = rt(), m = ae(), s = (x = U({
1119
- queryKey: ["collection-import-job", d],
1120
- queryFn: () => m.request(W(`/imports/${d}`)),
1121
- enabled: !!d,
1122
- refetchInterval: (p) => {
1123
- var c, v, w, u;
1124
- return ((v = (c = p.state.data) == null ? void 0 : c.data) == null ? void 0 : v.status) === "processing" || ((u = (w = p.state.data) == null ? void 0 : w.data) == null ? void 0 : u.status) === "pending" ? 2e3 : !1;
1152
+ function It({ jobId: c, onClose: o }) {
1153
+ var x, $;
1154
+ const n = ot(), p = se(), s = (x = L({
1155
+ queryKey: ["collection-import-job", c],
1156
+ queryFn: () => p.request(Q(`/imports/${c}`)),
1157
+ enabled: !!c,
1158
+ refetchInterval: (d) => {
1159
+ var i, u, N, h;
1160
+ return ((u = (i = d.state.data) == null ? void 0 : i.data) == null ? void 0 : u.status) === "processing" || ((h = (N = d.state.data) == null ? void 0 : N.data) == null ? void 0 : h.status) === "pending" ? 2e3 : !1;
1125
1161
  }
1126
- }).data) == null ? void 0 : x.data, g = Array.isArray(s == null ? void 0 : s.errors) ? s.errors : [], S = s != null && s.total_rows ? Math.min(100, Math.round((s.processed_rows ?? 0) / s.total_rows * 100)) : (s == null ? void 0 : s.status) === "complete" ? 100 : 0;
1127
- return /* @__PURE__ */ e(kt, { open: !!d, onOpenChange: (p) => !p && n(), children: /* @__PURE__ */ e(wt, { side: "right", className: "w-[min(560px,94vw)] p-0 sm:max-w-none", children: s ? /* @__PURE__ */ r("div", { className: "flex h-full flex-col", children: [
1128
- /* @__PURE__ */ r("header", { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
1162
+ }).data) == null ? void 0 : x.data, k = Array.isArray(s == null ? void 0 : s.errors) ? s.errors : [], q = s != null && s.total_rows ? Math.min(100, Math.round((s.processed_rows ?? 0) / s.total_rows * 100)) : (s == null ? void 0 : s.status) === "complete" ? 100 : 0;
1163
+ return /* @__PURE__ */ e(St, { open: !!c, onOpenChange: (d) => !d && o(), children: /* @__PURE__ */ e(Pt, { side: "right", className: "w-[min(560px,94vw)] p-0 sm:max-w-none", children: s ? /* @__PURE__ */ a("div", { className: "flex h-full flex-col", children: [
1164
+ /* @__PURE__ */ a("header", { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
1129
1165
  /* @__PURE__ */ e(Le, { status: s.status }),
1130
1166
  /* @__PURE__ */ e("h2", { className: "mt-1.5 truncate font-mono text-[15px] font-semibold text-slate-900 dark:text-foreground", children: s.file_name }),
1131
- /* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-400", children: [
1167
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-400", children: [
1132
1168
  "into ",
1133
1169
  /* @__PURE__ */ e("span", { className: "font-mono", children: s.collection }),
1134
1170
  " ·",
1135
1171
  " ",
1136
- te(s.created_at)
1172
+ ae(s.created_at)
1137
1173
  ] })
1138
1174
  ] }),
1139
- /* @__PURE__ */ r("div", { className: "min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4", children: [
1140
- /* @__PURE__ */ r("section", { className: "space-y-2", children: [
1141
- /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
1175
+ /* @__PURE__ */ a("div", { className: "min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4", children: [
1176
+ /* @__PURE__ */ a("section", { className: "space-y-2", children: [
1177
+ /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
1142
1178
  /* @__PURE__ */ e("h3", { className: "text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Progress" }),
1143
- /* @__PURE__ */ r("span", { className: "text-[12px] font-medium tabular-nums text-slate-700 dark:text-foreground", children: [
1144
- S,
1179
+ /* @__PURE__ */ a("span", { className: "text-[12px] font-medium tabular-nums text-slate-700 dark:text-foreground", children: [
1180
+ q,
1145
1181
  "%"
1146
1182
  ] })
1147
1183
  ] }),
1148
1184
  /* @__PURE__ */ e("div", { className: "h-2 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ e(
1149
1185
  "div",
1150
1186
  {
1151
- className: k(
1187
+ className: v(
1152
1188
  "h-full rounded-full transition-[width] duration-500",
1153
1189
  s.status === "failed" ? "bg-red-500" : "bg-nvr-cyan"
1154
1190
  ),
1155
- style: { width: `${S}%` }
1191
+ style: { width: `${q}%` }
1156
1192
  }
1157
1193
  ) }),
1158
- /* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
1159
- C(s.processed_rows ?? 0),
1194
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
1195
+ P(s.processed_rows ?? 0),
1160
1196
  " of",
1161
1197
  " ",
1162
- s.total_rows == null ? "?" : C(s.total_rows),
1198
+ s.total_rows == null ? "?" : P(s.total_rows),
1163
1199
  " rows processed"
1164
1200
  ] })
1165
1201
  ] }),
@@ -1168,20 +1204,20 @@ function Rt({ jobId: d, onClose: n }) {
1168
1204
  { label: "Updated", value: s.updated_rows ?? 0 },
1169
1205
  { label: "Skipped", value: s.skipped_rows ?? 0 },
1170
1206
  { label: "Errors", value: s.error_rows ?? 0, bad: (s.error_rows ?? 0) > 0 }
1171
- ].map((p) => /* @__PURE__ */ r("div", { className: "bg-white px-3 py-2 dark:bg-card", children: [
1172
- /* @__PURE__ */ e("p", { className: "text-[10.5px] text-slate-400", children: p.label }),
1207
+ ].map((d) => /* @__PURE__ */ a("div", { className: "bg-white px-3 py-2 dark:bg-card", children: [
1208
+ /* @__PURE__ */ e("p", { className: "text-[10.5px] text-slate-400", children: d.label }),
1173
1209
  /* @__PURE__ */ e(
1174
1210
  "p",
1175
1211
  {
1176
- className: k(
1212
+ className: v(
1177
1213
  "text-[15px] font-semibold tabular-nums",
1178
- p.bad ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
1214
+ d.bad ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
1179
1215
  ),
1180
- children: C(p.value)
1216
+ children: P(d.value)
1181
1217
  }
1182
1218
  )
1183
- ] }, p.label)) }),
1184
- /* @__PURE__ */ r("section", { children: [
1219
+ ] }, d.label)) }),
1220
+ /* @__PURE__ */ a("section", { children: [
1185
1221
  /* @__PURE__ */ e("h3", { className: "mb-1 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Settings" }),
1186
1222
  [
1187
1223
  { label: "Duplicates", value: s.duplicate_strategy },
@@ -1192,47 +1228,47 @@ function Rt({ jobId: d, onClose: n }) {
1192
1228
  { label: "Matched on", value: s.id_field ?? "— always create" },
1193
1229
  {
1194
1230
  label: "Started",
1195
- value: s.started_at ? te(s.started_at) : "—"
1231
+ value: s.started_at ? ae(s.started_at) : "—"
1196
1232
  },
1197
1233
  {
1198
1234
  label: "Completed",
1199
- value: s.completed_at ? te(s.completed_at) : "—"
1235
+ value: s.completed_at ? ae(s.completed_at) : "—"
1200
1236
  }
1201
- ].map((p) => /* @__PURE__ */ r(
1237
+ ].map((d) => /* @__PURE__ */ a(
1202
1238
  "div",
1203
1239
  {
1204
1240
  className: "flex items-baseline justify-between gap-4 border-b border-slate-100 py-1.5 last:border-b-0 dark:border-border/60",
1205
1241
  children: [
1206
- /* @__PURE__ */ e("span", { className: "text-[11.5px] text-slate-400", children: p.label }),
1207
- /* @__PURE__ */ e("span", { className: "truncate text-[12px] text-slate-800 dark:text-foreground", children: p.value })
1242
+ /* @__PURE__ */ e("span", { className: "text-[11.5px] text-slate-400", children: d.label }),
1243
+ /* @__PURE__ */ e("span", { className: "truncate text-[12px] text-slate-800 dark:text-foreground", children: d.value })
1208
1244
  ]
1209
1245
  },
1210
- p.label
1246
+ d.label
1211
1247
  ))
1212
1248
  ] }),
1213
- s.column_map && Object.keys(s.column_map).length > 0 && /* @__PURE__ */ r("section", { children: [
1249
+ s.column_map && Object.keys(s.column_map).length > 0 && /* @__PURE__ */ a("section", { children: [
1214
1250
  /* @__PURE__ */ e("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Column mapping" }),
1215
- /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([p, c]) => /* @__PURE__ */ r(
1251
+ /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([d, i]) => /* @__PURE__ */ a(
1216
1252
  "div",
1217
1253
  {
1218
1254
  className: "flex items-center gap-2 border-b border-slate-100 px-3 py-1.5 font-mono text-[11.5px] last:border-b-0 dark:border-border/60",
1219
1255
  children: [
1220
- /* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-500 dark:text-muted-foreground", children: p }),
1256
+ /* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-500 dark:text-muted-foreground", children: d }),
1221
1257
  /* @__PURE__ */ e(Ee, { className: "h-3 w-3 shrink-0 text-slate-300" }),
1222
- /* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-800 dark:text-foreground", children: c || /* @__PURE__ */ e("span", { className: "font-sans text-slate-400", children: "skipped" }) })
1258
+ /* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-800 dark:text-foreground", children: i || /* @__PURE__ */ e("span", { className: "font-sans text-slate-400", children: "skipped" }) })
1223
1259
  ]
1224
1260
  },
1225
- p
1261
+ d
1226
1262
  )) })
1227
1263
  ] }),
1228
- s.created_ids && (((T = s.created_ids) == null ? void 0 : T.length) ?? 0) > 0 && /* @__PURE__ */ e("section", { children: /* @__PURE__ */ r(
1264
+ s.created_ids && ((($ = s.created_ids) == null ? void 0 : $.length) ?? 0) > 0 && /* @__PURE__ */ e("section", { children: /* @__PURE__ */ a(
1229
1265
  "button",
1230
1266
  {
1231
1267
  type: "button",
1232
1268
  onClick: () => {
1233
- const p = (s.created_ids ?? []).map(String).join(",");
1234
- l.navigate(
1235
- `/collections/${s.collection}?ids=${encodeURIComponent(p)}`
1269
+ const d = (s.created_ids ?? []).map(String).join(",");
1270
+ n.navigate(
1271
+ `/collections/${s.collection}?ids=${encodeURIComponent(d)}`
1236
1272
  );
1237
1273
  },
1238
1274
  className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-nvr-cyan/40 bg-nvr-cyan/5 px-3 text-[12px] font-medium text-[#007a99] dark:text-nvr-cyan",
@@ -1247,102 +1283,102 @@ function Rt({ jobId: d, onClose: n }) {
1247
1283
  ]
1248
1284
  }
1249
1285
  ) }),
1250
- g.length > 0 && /* @__PURE__ */ e(Tt, { jobId: String(s.id), errors: g })
1286
+ k.length > 0 && /* @__PURE__ */ e(Lt, { jobId: String(s.id), errors: k })
1251
1287
  ] })
1252
1288
  ] }) : /* @__PURE__ */ e("div", { className: "p-5 text-[12.5px] text-slate-400", children: "Loading job…" }) }) });
1253
1289
  }
1254
- function Tt({
1255
- jobId: d,
1256
- errors: n
1290
+ function Lt({
1291
+ jobId: c,
1292
+ errors: o
1257
1293
  }) {
1258
- const l = ae(), [m, i] = f({}), [s, g] = f({}), { data: S } = U({
1259
- queryKey: ["import-failed-rows", d],
1260
- queryFn: () => l.request(
1261
- W(`/imports/${d}/failed-rows`)
1262
- ).then((c) => c.data ?? []),
1294
+ const n = se(), [p, m] = g({}), [s, k] = g({}), { data: q } = L({
1295
+ queryKey: ["import-failed-rows", c],
1296
+ queryFn: () => n.request(
1297
+ Q(`/imports/${c}/failed-rows`)
1298
+ ).then((i) => i.data ?? []),
1263
1299
  staleTime: 3e4
1264
- }), x = S ?? [], T = x[0] ? Object.keys(x[0].values) : [], p = K({
1265
- mutationFn: ({ row: c, values: v }) => l.request(L(`/imports/${d}/repair-row`, { values: v })).then(() => c),
1266
- onSuccess: (c) => g((v) => ({ ...v, [c]: "ok" })),
1267
- onError: (c, v) => g((w) => ({ ...w, [v.row]: st(c, "The row was not created") }))
1300
+ }), x = q ?? [], $ = x[0] ? Object.keys(x[0].values) : [], d = K({
1301
+ mutationFn: ({ row: i, values: u }) => n.request(I(`/imports/${c}/repair-row`, { values: u })).then(() => i),
1302
+ onSuccess: (i) => k((u) => ({ ...u, [i]: "ok" })),
1303
+ onError: (i, u) => k((N) => ({ ...N, [u.row]: it(i, "The row was not created") }))
1268
1304
  });
1269
- return x.length === 0 ? /* @__PURE__ */ r("section", { children: [
1270
- /* @__PURE__ */ r("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
1305
+ return x.length === 0 ? /* @__PURE__ */ a("section", { children: [
1306
+ /* @__PURE__ */ a("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
1271
1307
  "Row errors (",
1272
- n.length,
1308
+ o.length,
1273
1309
  ")"
1274
1310
  ] }),
1275
- /* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: n.map((c) => /* @__PURE__ */ e(
1311
+ /* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: o.map((i) => /* @__PURE__ */ e(
1276
1312
  "div",
1277
1313
  {
1278
1314
  className: "flex gap-3 border-b border-red-100 px-3 py-1.5 text-[11.5px] last:border-b-0 dark:border-red-900/60",
1279
- children: /* @__PURE__ */ r("span", { className: "text-red-700 dark:text-red-400", children: [
1280
- /* @__PURE__ */ r("span", { className: "font-medium tabular-nums", children: [
1315
+ children: /* @__PURE__ */ a("span", { className: "text-red-700 dark:text-red-400", children: [
1316
+ /* @__PURE__ */ a("span", { className: "font-medium tabular-nums", children: [
1281
1317
  "Row ",
1282
- c.row,
1318
+ i.row,
1283
1319
  ":"
1284
1320
  ] }),
1285
1321
  " ",
1286
- De(c.error)
1322
+ De(i.error)
1287
1323
  ] })
1288
1324
  },
1289
- `${c.row}-${c.error}`
1325
+ `${i.row}-${i.error}`
1290
1326
  )) })
1291
- ] }) : /* @__PURE__ */ r("section", { children: [
1292
- /* @__PURE__ */ r("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
1327
+ ] }) : /* @__PURE__ */ a("section", { children: [
1328
+ /* @__PURE__ */ a("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
1293
1329
  "Failed rows (",
1294
1330
  x.length,
1295
1331
  ") — fix and resubmit"
1296
1332
  ] }),
1297
- /* @__PURE__ */ e("div", { className: "max-h-[320px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: /* @__PURE__ */ r("table", { className: "w-full text-[11.5px]", children: [
1298
- /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { className: "bg-red-50/60 text-left text-[10px] uppercase tracking-wide text-slate-400 dark:bg-red-950/30", children: [
1333
+ /* @__PURE__ */ e("div", { className: "max-h-[320px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: /* @__PURE__ */ a("table", { className: "w-full text-[11.5px]", children: [
1334
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ a("tr", { className: "bg-red-50/60 text-left text-[10px] uppercase tracking-wide text-slate-400 dark:bg-red-950/30", children: [
1299
1335
  /* @__PURE__ */ e("th", { className: "px-2 py-1", children: "Row" }),
1300
- T.map((c) => /* @__PURE__ */ e("th", { className: "px-2 py-1 font-mono normal-case", children: c }, c)),
1336
+ $.map((i) => /* @__PURE__ */ e("th", { className: "px-2 py-1 font-mono normal-case", children: i }, i)),
1301
1337
  /* @__PURE__ */ e("th", { className: "px-2 py-1" })
1302
1338
  ] }) }),
1303
- /* @__PURE__ */ e("tbody", { children: x.map((c) => {
1304
- const v = m[c.row] ?? c.values, w = s[c.row];
1305
- return /* @__PURE__ */ r(
1339
+ /* @__PURE__ */ e("tbody", { children: x.map((i) => {
1340
+ const u = p[i.row] ?? i.values, N = s[i.row];
1341
+ return /* @__PURE__ */ a(
1306
1342
  "tr",
1307
1343
  {
1308
1344
  className: "border-t border-red-100 align-top dark:border-red-900/50",
1309
1345
  children: [
1310
- /* @__PURE__ */ r("td", { className: "px-2 py-1 font-mono tabular-nums text-slate-400", children: [
1311
- c.row,
1312
- /* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children: De(c.error) })
1346
+ /* @__PURE__ */ a("td", { className: "px-2 py-1 font-mono tabular-nums text-slate-400", children: [
1347
+ i.row,
1348
+ /* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children: De(i.error) })
1313
1349
  ] }),
1314
- T.map((u) => /* @__PURE__ */ e("td", { className: "px-1 py-1", children: /* @__PURE__ */ e(
1350
+ $.map((h) => /* @__PURE__ */ e("td", { className: "px-1 py-1", children: /* @__PURE__ */ e(
1315
1351
  "input",
1316
1352
  {
1317
- value: String(v[u] ?? ""),
1318
- disabled: w === "ok",
1319
- onChange: ($) => i((P) => ({ ...P, [c.row]: { ...v, [u]: $.target.value } })),
1353
+ value: String(u[h] ?? ""),
1354
+ disabled: N === "ok",
1355
+ onChange: (T) => m((_) => ({ ..._, [i.row]: { ...u, [h]: T.target.value } })),
1320
1356
  className: "h-6 w-full min-w-[80px] rounded border border-slate-200 bg-background px-1 text-[11px] dark:border-border"
1321
1357
  }
1322
- ) }, u)),
1323
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: w === "ok" ? /* @__PURE__ */ e("span", { className: "text-[10.5px] font-medium text-emerald-600", children: "✓ Created" }) : /* @__PURE__ */ r("div", { children: [
1358
+ ) }, h)),
1359
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: N === "ok" ? /* @__PURE__ */ e("span", { className: "text-[10.5px] font-medium text-emerald-600", children: "✓ Created" }) : /* @__PURE__ */ a("div", { children: [
1324
1360
  /* @__PURE__ */ e(
1325
1361
  "button",
1326
1362
  {
1327
1363
  type: "button",
1328
- disabled: p.isPending,
1329
- onClick: () => p.mutate({ row: c.row, values: v }),
1364
+ disabled: d.isPending,
1365
+ onClick: () => d.mutate({ row: i.row, values: u }),
1330
1366
  className: "rounded border border-slate-200 px-1.5 py-0.5 text-[10.5px] hover:bg-muted disabled:opacity-50 dark:border-border",
1331
1367
  children: "Resubmit"
1332
1368
  }
1333
1369
  ),
1334
- w && w !== "ok" && /* @__PURE__ */ e("p", { className: "max-w-[140px] whitespace-normal text-[9.5px] text-red-500", children: w })
1370
+ N && N !== "ok" && /* @__PURE__ */ e("p", { className: "max-w-[140px] whitespace-normal text-[9.5px] text-red-500", children: N })
1335
1371
  ] }) })
1336
1372
  ]
1337
1373
  },
1338
- c.row
1374
+ i.row
1339
1375
  );
1340
1376
  }) })
1341
1377
  ] }) })
1342
1378
  ] });
1343
1379
  }
1344
1380
  export {
1345
- Yt as CollectionImportPanel,
1346
- _t as ROLLBACK_QUESTION,
1347
- Ct as RollbackJobItem
1381
+ na as CollectionImportPanel,
1382
+ Tt as ROLLBACK_QUESTION,
1383
+ At as RollbackJobItem
1348
1384
  };