@fileflow/sdk 0.1.21 → 0.1.23

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.
@@ -0,0 +1,3384 @@
1
+ import { jsx as d, jsxs as h, Fragment as oe } from "react/jsx-runtime";
2
+ import * as Ne from "react";
3
+ import yt, { useCallback as De, useState as X, useMemo as Ue, useEffect as Xe } from "react";
4
+ import { h as q, j as St, k as Rt, X as he, m as Q, U as ot, n as Le, T as Me, q as xt, p as ze, o as Ze, t as _t, d as Ft, V as We, g as ie, S as we, L as ce } from "./index-Dn3cI9sZ.mjs";
5
+ /**
6
+ * @license lucide-react v0.563.0 - ISC
7
+ *
8
+ * This source code is licensed under the ISC license.
9
+ * See the LICENSE file in the root directory of this source tree.
10
+ */
11
+ const It = [
12
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
13
+ ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
14
+ ], $t = q("arrow-right", It);
15
+ /**
16
+ * @license lucide-react v0.563.0 - ISC
17
+ *
18
+ * This source code is licensed under the ISC license.
19
+ * See the LICENSE file in the root directory of this source tree.
20
+ */
21
+ const Nt = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Mt = q("check", Nt);
22
+ /**
23
+ * @license lucide-react v0.563.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */
28
+ const Vt = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], Pt = q("chevron-left", Vt);
29
+ /**
30
+ * @license lucide-react v0.563.0 - ISC
31
+ *
32
+ * This source code is licensed under the ISC license.
33
+ * See the LICENSE file in the root directory of this source tree.
34
+ */
35
+ const kt = [
36
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
37
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
38
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
39
+ ], bt = q("circle-question-mark", kt);
40
+ /**
41
+ * @license lucide-react v0.563.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */
46
+ const Et = [
47
+ [
48
+ "path",
49
+ {
50
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
51
+ key: "1nclc0"
52
+ }
53
+ ],
54
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
55
+ ], Dt = q("eye", Et);
56
+ /**
57
+ * @license lucide-react v0.563.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */
62
+ const Lt = [
63
+ [
64
+ "path",
65
+ {
66
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
67
+ key: "1oefj6"
68
+ }
69
+ ],
70
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
71
+ ["path", { d: "M8 13h2", key: "yr2amv" }],
72
+ ["path", { d: "M14 13h2", key: "un5t4a" }],
73
+ ["path", { d: "M8 17h2", key: "2yhykz" }],
74
+ ["path", { d: "M14 17h2", key: "10kma7" }]
75
+ ], zt = q("file-spreadsheet", Lt);
76
+ /**
77
+ * @license lucide-react v0.563.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */
82
+ const At = [
83
+ [
84
+ "path",
85
+ {
86
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
87
+ key: "1oefj6"
88
+ }
89
+ ],
90
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
91
+ ], Ht = q("file", At);
92
+ /**
93
+ * @license lucide-react v0.563.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */
98
+ const Gt = [
99
+ ["line", { x1: "6", x2: "6", y1: "3", y2: "15", key: "17qcm7" }],
100
+ ["circle", { cx: "18", cy: "6", r: "3", key: "1h7g24" }],
101
+ ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
102
+ ["path", { d: "M18 9a9 9 0 0 1-9 9", key: "n2h4wq" }]
103
+ ], Ot = q("git-branch", Gt);
104
+ /**
105
+ * @license lucide-react v0.563.0 - ISC
106
+ *
107
+ * This source code is licensed under the ISC license.
108
+ * See the LICENSE file in the root directory of this source tree.
109
+ */
110
+ const Tt = [
111
+ [
112
+ "path",
113
+ {
114
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
115
+ key: "1a8usu"
116
+ }
117
+ ]
118
+ ], Bt = q("pen", Tt);
119
+ /**
120
+ * @license lucide-react v0.563.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */
125
+ const Kt = [
126
+ [
127
+ "path",
128
+ { d: "M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344", key: "2acyp4" }
129
+ ],
130
+ ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
131
+ ], jt = q("square-check-big", Kt);
132
+ /**
133
+ * @license lucide-react v0.563.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */
138
+ const qt = [
139
+ ["path", { d: "M10 11v6", key: "nco0om" }],
140
+ ["path", { d: "M14 11v6", key: "outv1u" }],
141
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
142
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
143
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
144
+ ], Ut = q("trash-2", qt), Ye = {
145
+ sessionId: null,
146
+ status: "idle",
147
+ step: "upload",
148
+ schema: null,
149
+ file: null,
150
+ fileName: null,
151
+ fileSize: null,
152
+ headers: [],
153
+ rows: [],
154
+ totalRows: 0,
155
+ sampleRows: [],
156
+ mappings: [],
157
+ unmappedSource: [],
158
+ unmappedTarget: [],
159
+ validationResults: null,
160
+ errorsByRow: /* @__PURE__ */ new Map(),
161
+ isLoading: !1,
162
+ error: null,
163
+ editingCell: null,
164
+ editedRows: /* @__PURE__ */ new Set()
165
+ };
166
+ function Xt(e, o) {
167
+ var r;
168
+ const t = [], n = (e == null ? void 0 : e.trim()) || "";
169
+ if (o.required && !n)
170
+ return t.push({
171
+ rowIndex: 0,
172
+ // will be set by caller
173
+ columnKey: o.key,
174
+ value: n,
175
+ severity: "error",
176
+ validatorType: "required",
177
+ message: `${o.label} is required`
178
+ }), t;
179
+ if (!n) return t;
180
+ switch (o.type) {
181
+ case "email": {
182
+ if (!/^[^\s@]+@[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(n))
183
+ t.push({
184
+ rowIndex: 0,
185
+ columnKey: o.key,
186
+ value: n,
187
+ severity: "error",
188
+ validatorType: "type",
189
+ message: "Invalid email format"
190
+ });
191
+ else {
192
+ const s = (r = n.split("@")[1]) == null ? void 0 : r.toLowerCase(), i = {
193
+ "gmial.com": "gmail.com",
194
+ "gmal.com": "gmail.com",
195
+ "gmai.com": "gmail.com",
196
+ "gamil.com": "gmail.com",
197
+ "gnail.com": "gmail.com",
198
+ "gmail.co": "gmail.com",
199
+ "gmail.cm": "gmail.com",
200
+ "gmil.com": "gmail.com",
201
+ "gmaill.com": "gmail.com",
202
+ "yaho.com": "yahoo.com",
203
+ "yahooo.com": "yahoo.com",
204
+ "yahoo.co": "yahoo.com",
205
+ "hotmal.com": "hotmail.com",
206
+ "hotmial.com": "hotmail.com",
207
+ "hotmai.com": "hotmail.com",
208
+ "hotmail.co": "hotmail.com",
209
+ "outlok.com": "outlook.com",
210
+ "outloo.com": "outlook.com",
211
+ "outlook.co": "outlook.com"
212
+ };
213
+ s && i[s] && t.push({
214
+ rowIndex: 0,
215
+ columnKey: o.key,
216
+ value: n,
217
+ severity: "warning",
218
+ validatorType: "type",
219
+ message: `Possible typo: did you mean @${i[s]}?`,
220
+ suggestion: `${n.split("@")[0]}@${i[s]}`
221
+ });
222
+ }
223
+ break;
224
+ }
225
+ case "url":
226
+ /^https?:\/\/.+/.test(n) || t.push({
227
+ rowIndex: 0,
228
+ columnKey: o.key,
229
+ value: n,
230
+ severity: "error",
231
+ validatorType: "type",
232
+ message: "Invalid URL format"
233
+ });
234
+ break;
235
+ case "integer":
236
+ /^-?\d+$/.test(n) || t.push({
237
+ rowIndex: 0,
238
+ columnKey: o.key,
239
+ value: n,
240
+ severity: "error",
241
+ validatorType: "type",
242
+ message: "Must be a whole number"
243
+ });
244
+ break;
245
+ case "number":
246
+ case "float":
247
+ /^-?\d+(\.\d+)?$/.test(n) || t.push({
248
+ rowIndex: 0,
249
+ columnKey: o.key,
250
+ value: n,
251
+ severity: "error",
252
+ validatorType: "type",
253
+ message: "Must be a valid number"
254
+ });
255
+ break;
256
+ case "phone":
257
+ n.replace(/\D/g, "").length < 10 && t.push({
258
+ rowIndex: 0,
259
+ columnKey: o.key,
260
+ value: n,
261
+ severity: "warning",
262
+ validatorType: "type",
263
+ message: "Invalid phone number"
264
+ });
265
+ break;
266
+ }
267
+ if (o.validators)
268
+ for (const l of o.validators) {
269
+ const s = l.severity === "info" ? "warning" : l.severity || "error", i = l.params || {};
270
+ switch (l.type) {
271
+ case "minLength": {
272
+ const u = i.value ?? 0;
273
+ n.length < u && t.push({
274
+ rowIndex: 0,
275
+ columnKey: o.key,
276
+ value: n,
277
+ severity: s,
278
+ validatorType: l.type,
279
+ message: l.message || `Must be at least ${u} characters`
280
+ });
281
+ break;
282
+ }
283
+ case "maxLength": {
284
+ const u = i.value ?? 1 / 0;
285
+ n.length > u && t.push({
286
+ rowIndex: 0,
287
+ columnKey: o.key,
288
+ value: n,
289
+ severity: s,
290
+ validatorType: l.type,
291
+ message: l.message || `Must be at most ${u} characters`
292
+ });
293
+ break;
294
+ }
295
+ case "min": {
296
+ const u = parseFloat(n), f = i.value ?? -1 / 0;
297
+ !isNaN(u) && u < f && t.push({
298
+ rowIndex: 0,
299
+ columnKey: o.key,
300
+ value: n,
301
+ severity: s,
302
+ validatorType: l.type,
303
+ message: l.message || `Must be at least ${f}`
304
+ });
305
+ break;
306
+ }
307
+ case "max": {
308
+ const u = parseFloat(n), f = i.value ?? 1 / 0;
309
+ !isNaN(u) && u > f && t.push({
310
+ rowIndex: 0,
311
+ columnKey: o.key,
312
+ value: n,
313
+ severity: s,
314
+ validatorType: l.type,
315
+ message: l.message || `Must be at most ${f}`
316
+ });
317
+ break;
318
+ }
319
+ case "pattern": {
320
+ const u = i.regex ?? i.pattern ?? ".*";
321
+ new RegExp(u).test(n) || t.push({
322
+ rowIndex: 0,
323
+ columnKey: o.key,
324
+ value: n,
325
+ severity: s,
326
+ validatorType: l.type,
327
+ message: l.message || "Format is invalid"
328
+ });
329
+ break;
330
+ }
331
+ case "enum": {
332
+ const u = i.values || [];
333
+ u.map((p) => p.toLowerCase()).includes(n.toLowerCase()) || t.push({
334
+ rowIndex: 0,
335
+ columnKey: o.key,
336
+ value: n,
337
+ severity: s,
338
+ validatorType: l.type,
339
+ message: l.message || `Must be one of: ${u.slice(0, 5).join(", ")}${u.length > 5 ? "..." : ""}`
340
+ });
341
+ break;
342
+ }
343
+ case "custom": {
344
+ const u = i.validatorName;
345
+ if (u === "commaSeparatedEnum") {
346
+ const f = i.allowedValues || [], p = n.split(",").map((a) => a.trim().toLowerCase()).filter((a) => a), g = f.map((a) => a.toLowerCase()), c = p.filter((a) => !g.includes(a));
347
+ c.length > 0 && t.push({
348
+ rowIndex: 0,
349
+ columnKey: o.key,
350
+ value: n,
351
+ severity: s,
352
+ validatorType: l.type,
353
+ message: l.message || `Invalid values: ${c.join(", ")}. Must be comma-separated values from: ${f.slice(0, 5).join(", ")}${f.length > 5 ? "..." : ""}`
354
+ });
355
+ }
356
+ if (u === "commaSeparatedEmails") {
357
+ const p = n.split(",").map((g) => g.trim()).filter((g) => g).filter((g) => !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(g));
358
+ p.length > 0 && t.push({
359
+ rowIndex: 0,
360
+ columnKey: o.key,
361
+ value: n,
362
+ severity: s,
363
+ validatorType: l.type,
364
+ message: `Invalid email(s): ${p.join(", ")}`
365
+ });
366
+ }
367
+ break;
368
+ }
369
+ }
370
+ }
371
+ return t;
372
+ }
373
+ function Ce(e, o, t) {
374
+ var C;
375
+ const n = [];
376
+ for (const w of e)
377
+ for (const y of t) {
378
+ if (!y.targetKey) continue;
379
+ const x = o.columns.find((P) => P.key === y.targetKey);
380
+ if (!x) continue;
381
+ const N = w.data[y.targetKey] || w.data[y.sourceColumn] || "", _ = Xt(String(N), x);
382
+ for (const P of _)
383
+ n.push({ ...P, rowIndex: w.rowIndex });
384
+ }
385
+ const r = ((C = o.options) == null ? void 0 : C.uniqueKeys) || [];
386
+ for (const w of r) {
387
+ const y = t.find((N) => N.targetKey === w);
388
+ if (!y) continue;
389
+ const x = /* @__PURE__ */ new Map();
390
+ for (const N of e) {
391
+ const _ = String(N.data[w] || N.data[y.sourceColumn] || "").toLowerCase().trim();
392
+ if (!_) continue;
393
+ const P = x.get(_) || [];
394
+ P.push(N.rowIndex), x.set(_, P);
395
+ }
396
+ for (const [N, _] of x.entries())
397
+ if (_.length > 1)
398
+ for (const P of _.slice(1))
399
+ n.push({
400
+ rowIndex: P,
401
+ columnKey: w,
402
+ value: N,
403
+ severity: "warning",
404
+ validatorType: "unique",
405
+ message: `Duplicate ${w} value`
406
+ });
407
+ }
408
+ const l = /* @__PURE__ */ new Map();
409
+ for (const w of n) {
410
+ const y = l.get(w.rowIndex) || [];
411
+ y.push(w), l.set(w.rowIndex, y);
412
+ }
413
+ const s = n.filter((w) => w.severity === "error").length, i = n.filter((w) => w.severity === "warning").length, u = n.filter((w) => w.severity === "info").length, f = new Set(n.filter((w) => w.severity === "error").map((w) => w.rowIndex)), p = e.length, g = p - f.size, c = {};
414
+ for (const w of n) {
415
+ c[w.columnKey] || (c[w.columnKey] = {
416
+ columnKey: w.columnKey,
417
+ errorCount: 0,
418
+ warningCount: 0,
419
+ infoCount: 0,
420
+ mostCommonError: void 0
421
+ });
422
+ const y = c[w.columnKey];
423
+ w.severity === "error" ? y.errorCount++ : w.severity === "warning" ? y.warningCount++ : y.infoCount++, y.mostCommonError || (y.mostCommonError = w.message);
424
+ }
425
+ const a = {};
426
+ for (const w of n)
427
+ a[w.validatorType] = (a[w.validatorType] || 0) + 1;
428
+ const m = [];
429
+ for (const w of r) {
430
+ const y = t.find((N) => N.targetKey === w);
431
+ if (!y) continue;
432
+ const x = /* @__PURE__ */ new Map();
433
+ for (const N of e) {
434
+ const _ = String(N.data[w] || N.data[y.sourceColumn] || "").toLowerCase().trim();
435
+ if (!_) continue;
436
+ const P = x.get(_) || [];
437
+ P.push(N.rowIndex), x.set(_, P);
438
+ }
439
+ for (const [N, _] of x.entries())
440
+ _.length > 1 && m.push({ columnKey: w, value: N, rowIndices: _ });
441
+ }
442
+ const v = {
443
+ byColumn: c,
444
+ byType: a,
445
+ duplicates: m.length > 0 ? m : void 0
446
+ };
447
+ return {
448
+ validationResults: {
449
+ isValid: s === 0,
450
+ totalRows: p,
451
+ validRows: g,
452
+ errorCount: s,
453
+ warningCount: i,
454
+ infoCount: u,
455
+ errors: n,
456
+ summary: v
457
+ },
458
+ errorsByRow: l
459
+ };
460
+ }
461
+ const re = St((e, o) => ({
462
+ ...Ye,
463
+ setSchema: (t) => e({ schema: t }),
464
+ setSessionId: (t) => e({ sessionId: t }),
465
+ setFile: (t) => e({
466
+ file: t,
467
+ fileName: t.name,
468
+ fileSize: t.size,
469
+ error: null
470
+ }),
471
+ setParsedData: (t) => e({
472
+ headers: t.headers,
473
+ rows: t.rows,
474
+ totalRows: t.totalRows,
475
+ sampleRows: t.sampleRows
476
+ }),
477
+ setMappings: (t) => e({ mappings: t }),
478
+ updateMapping: (t, n) => e((r) => ({ mappings: r.mappings.map(
479
+ (s) => s.sourceColumn === t ? { ...s, targetKey: n, isAutoMapped: !1 } : s
480
+ ) })),
481
+ setUnmapped: (t, n) => e({
482
+ unmappedSource: t,
483
+ unmappedTarget: n
484
+ }),
485
+ setValidationResults: (t) => {
486
+ const n = /* @__PURE__ */ new Map();
487
+ for (const r of t.errors) {
488
+ const l = n.get(r.rowIndex) || [];
489
+ l.push(r), n.set(r.rowIndex, l);
490
+ }
491
+ e({ validationResults: t, errorsByRow: n });
492
+ },
493
+ revalidate: () => {
494
+ const t = o();
495
+ if (!t.schema || !t.validationResults) return;
496
+ const { validationResults: n, errorsByRow: r } = Ce(
497
+ t.rows,
498
+ t.schema,
499
+ t.mappings
500
+ );
501
+ e({ validationResults: n, errorsByRow: r });
502
+ },
503
+ setStep: (t) => e({ step: t }),
504
+ nextStep: () => {
505
+ const t = ["upload", "mapping", "validation", "review", "complete"], n = t.indexOf(o().step);
506
+ n < t.length - 1 && e({ step: t[n + 1] });
507
+ },
508
+ previousStep: () => {
509
+ const t = ["upload", "mapping", "validation", "review", "complete"], n = t.indexOf(o().step);
510
+ n > 0 && e({ step: t[n - 1] });
511
+ },
512
+ startEditing: (t, n) => e({
513
+ editingCell: { rowIndex: t, columnKey: n }
514
+ }),
515
+ stopEditing: () => e({ editingCell: null }),
516
+ updateCell: (t, n, r) => {
517
+ const l = o(), s = [...l.rows], i = s.find((f) => f.rowIndex === t);
518
+ i && (i.data = { ...i.data, [n]: String(r) });
519
+ const u = new Set(l.editedRows);
520
+ if (u.add(t), e({ rows: s, editedRows: u, editingCell: null }), l.schema && l.validationResults) {
521
+ const { validationResults: f, errorsByRow: p } = Ce(
522
+ s,
523
+ l.schema,
524
+ l.mappings
525
+ );
526
+ e({ validationResults: f, errorsByRow: p });
527
+ }
528
+ },
529
+ deleteRow: (t) => {
530
+ const n = o(), l = n.rows.filter((s) => s.rowIndex !== t).map((s, i) => ({ ...s, rowIndex: i }));
531
+ if (e({
532
+ rows: l,
533
+ totalRows: l.length
534
+ }), n.schema && n.validationResults) {
535
+ const { validationResults: s, errorsByRow: i } = Ce(
536
+ l,
537
+ n.schema,
538
+ n.mappings
539
+ );
540
+ e({ validationResults: s, errorsByRow: i });
541
+ }
542
+ },
543
+ setStatus: (t) => e({ status: t }),
544
+ setLoading: (t) => e({ isLoading: t }),
545
+ setError: (t) => e({ error: t }),
546
+ reset: () => e(Ye)
547
+ })), Zt = ({
548
+ onFileSelect: e,
549
+ maxSize: o = 50 * 1024 * 1024,
550
+ // 50MB
551
+ acceptedTypes: t = [".csv", ".xlsx", ".xls"]
552
+ }) => {
553
+ const { file: n, fileName: r, fileSize: l, setFile: s, error: i, setError: u, isLoading: f } = re(), p = De(
554
+ (C, w) => {
555
+ if (w.length > 0) {
556
+ u("Invalid file type or file too large");
557
+ return;
558
+ }
559
+ if (C.length > 0) {
560
+ const y = C[0];
561
+ s(y), e == null || e(y);
562
+ }
563
+ },
564
+ [e, s, u]
565
+ ), { getRootProps: g, getInputProps: c, isDragActive: a } = Rt({
566
+ onDrop: p,
567
+ accept: {
568
+ "text/csv": [".csv"],
569
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
570
+ "application/vnd.ms-excel": [".xls"]
571
+ },
572
+ maxSize: o,
573
+ multiple: !1,
574
+ disabled: f
575
+ }), m = (C) => C < 1024 ? `${C} B` : C < 1024 * 1024 ? `${(C / 1024).toFixed(1)} KB` : `${(C / (1024 * 1024)).toFixed(1)} MB`, v = (C) => {
576
+ C.stopPropagation(), re.getState().reset();
577
+ };
578
+ return n ? /* @__PURE__ */ d("div", { className: "ff-p-4 ff-rounded-xl ff-border", style: { backgroundColor: "var(--ff-success-light)", borderColor: "var(--ff-success)" }, children: /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
579
+ /* @__PURE__ */ d("div", { className: "ff-p-2 ff-rounded-lg", style: { backgroundColor: "rgba(41, 142, 51, 0.15)" }, children: /* @__PURE__ */ d(Ht, { className: "ff-w-6 ff-h-6", style: { color: "var(--ff-success)" } }) }),
580
+ /* @__PURE__ */ h("div", { className: "ff-flex-1 ff-min-w-0", children: [
581
+ /* @__PURE__ */ d("p", { className: "ff-font-medium ff-truncate", style: { color: "var(--ff-success-dark)" }, children: r }),
582
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: m(l || 0) })
583
+ ] }),
584
+ /* @__PURE__ */ d(
585
+ "button",
586
+ {
587
+ onClick: v,
588
+ className: "ff-p-1.5 ff-rounded-full ff-transition-colors",
589
+ style: { color: "var(--ff-success)" },
590
+ "aria-label": "Remove file",
591
+ children: /* @__PURE__ */ d(he, { className: "ff-w-5 ff-h-5" })
592
+ }
593
+ )
594
+ ] }) }) : /* @__PURE__ */ h("div", { className: "ff-space-y-6", children: [
595
+ /* @__PURE__ */ h(
596
+ "div",
597
+ {
598
+ ...g(),
599
+ className: Q(
600
+ "ff-dropzone",
601
+ a && "ff-dropzone-active",
602
+ f && "ff-opacity-50 ff-cursor-not-allowed"
603
+ ),
604
+ children: [
605
+ /* @__PURE__ */ d("input", { ...c() }),
606
+ /* @__PURE__ */ d("div", { className: "ff-dropzone-icon-wrapper", children: /* @__PURE__ */ d(ot, { className: "ff-dropzone-icon" }) }),
607
+ /* @__PURE__ */ d("h3", { className: "ff-dropzone-text", children: a ? "Drop your file here" : "Upload your file" }),
608
+ /* @__PURE__ */ d("p", { className: "ff-dropzone-hint", children: "Drag and drop or click to select" }),
609
+ /* @__PURE__ */ d("label", { className: "ff-inline-block", children: /* @__PURE__ */ d("span", { className: Q(
610
+ "ff-btn ff-btn-primary",
611
+ f && "ff-opacity-50 ff-cursor-wait"
612
+ ), children: f ? "Processing..." : "Choose file" }) }),
613
+ /* @__PURE__ */ h("p", { className: "ff-dropzone-formats", children: [
614
+ "Supports ",
615
+ t.join(", "),
616
+ " up to ",
617
+ m(o)
618
+ ] })
619
+ ]
620
+ }
621
+ ),
622
+ i && /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-2 ff-p-4 ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", color: "var(--ff-error)" }, children: [
623
+ /* @__PURE__ */ d(Le, { className: "ff-w-4 ff-h-4 ff-flex-shrink-0" }),
624
+ /* @__PURE__ */ d("p", { children: i })
625
+ ] })
626
+ ] });
627
+ }, Wt = ({ onMappingChange: e }) => {
628
+ const { mappings: o, schema: t, unmappedSource: n, updateMapping: r } = re(), l = (t == null ? void 0 : t.columns) || [], s = (g, c) => {
629
+ const a = c === "" ? null : c;
630
+ r(g, a), e == null || e(g, a);
631
+ }, i = (g) => g >= 0.85 ? "var(--ff-success)" : g >= 0.6 ? "var(--ff-warning)" : "var(--ff-error)", u = (g) => g >= 0.85 ? "High" : g >= 0.6 ? "Medium" : "Low", p = new Set(
632
+ o.filter((g) => g.targetKey !== null).map((g) => g.targetKey)
633
+ );
634
+ return /* @__PURE__ */ h("div", { className: "ff-space-y-4", children: [
635
+ /* @__PURE__ */ h("div", { className: "ff-mapping-header", children: [
636
+ /* @__PURE__ */ h("div", { children: [
637
+ /* @__PURE__ */ d("h3", { className: "ff-mapping-title", children: "Column Mapping" }),
638
+ /* @__PURE__ */ d("p", { className: "ff-mapping-subtitle", children: "Match your file columns to the expected fields" })
639
+ ] }),
640
+ /* @__PURE__ */ h("div", { className: "ff-mapping-legend", children: [
641
+ /* @__PURE__ */ h("span", { className: "ff-mapping-legend-item", children: [
642
+ /* @__PURE__ */ d("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-success)" } }),
643
+ /* @__PURE__ */ d("span", { style: { color: "var(--ff-text-secondary)" }, children: "Mapped" })
644
+ ] }),
645
+ /* @__PURE__ */ h("span", { className: "ff-mapping-legend-item", children: [
646
+ /* @__PURE__ */ d("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-warning)" } }),
647
+ /* @__PURE__ */ d("span", { style: { color: "var(--ff-text-secondary)" }, children: "Review" })
648
+ ] }),
649
+ /* @__PURE__ */ h("span", { className: "ff-mapping-legend-item", children: [
650
+ /* @__PURE__ */ d("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-gray-70)" } }),
651
+ /* @__PURE__ */ d("span", { style: { color: "var(--ff-text-secondary)" }, children: "Unmapped" })
652
+ ] })
653
+ ] })
654
+ ] }),
655
+ /* @__PURE__ */ d("div", { className: "ff-space-y-2", children: o.map((g) => {
656
+ l.find((m) => m.key === g.targetKey);
657
+ const c = g.targetKey !== null, a = g.confidence >= 0.85;
658
+ return /* @__PURE__ */ h(
659
+ "div",
660
+ {
661
+ className: Q(
662
+ "ff-mapping-row",
663
+ c && a && "ff-mapping-row-success",
664
+ c && !a && "ff-mapping-row-warning"
665
+ ),
666
+ children: [
667
+ /* @__PURE__ */ d("div", { className: "ff-flex-1", children: /* @__PURE__ */ d("div", { className: "ff-mapping-source", children: g.sourceColumn }) }),
668
+ /* @__PURE__ */ d("div", { className: "ff-mapping-arrow", children: /* @__PURE__ */ d($t, { className: "ff-w-5 ff-h-5" }) }),
669
+ /* @__PURE__ */ d("div", { className: "ff-flex-1 ff-mapping-target", children: /* @__PURE__ */ h(
670
+ "select",
671
+ {
672
+ value: g.targetKey || "",
673
+ onChange: (m) => s(g.sourceColumn, m.target.value),
674
+ className: "ff-input",
675
+ children: [
676
+ /* @__PURE__ */ d("option", { value: "", children: "-- Do not import --" }),
677
+ l.map((m) => /* @__PURE__ */ h(
678
+ "option",
679
+ {
680
+ value: m.key,
681
+ disabled: p.has(m.key) && g.targetKey !== m.key,
682
+ children: [
683
+ m.label,
684
+ " (",
685
+ m.type,
686
+ ")",
687
+ m.required ? " *" : ""
688
+ ]
689
+ },
690
+ m.key
691
+ ))
692
+ ]
693
+ }
694
+ ) }),
695
+ /* @__PURE__ */ d("div", { className: "ff-mapping-status", children: c ? a ? /* @__PURE__ */ d(Mt, { className: "ff-w-5 ff-h-5", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ d(bt, { className: "ff-w-5 ff-h-5", style: { color: "var(--ff-warning)" } }) : /* @__PURE__ */ d("span", { className: "ff-w-5 ff-h-5" }) }),
696
+ g.confidence > 0 && /* @__PURE__ */ h("div", { className: "ff-confidence", style: { color: i(g.confidence) }, children: [
697
+ /* @__PURE__ */ h("span", { children: [
698
+ Math.round(g.confidence * 100),
699
+ "%"
700
+ ] }),
701
+ /* @__PURE__ */ h("span", { style: { color: "var(--ff-text-muted)" }, children: [
702
+ "(",
703
+ u(g.confidence),
704
+ ")"
705
+ ] })
706
+ ] })
707
+ ]
708
+ },
709
+ g.sourceColumn
710
+ );
711
+ }) }),
712
+ (() => {
713
+ const g = l.filter(
714
+ (c) => c.required && !p.has(c.key)
715
+ );
716
+ return g.length > 0 ? /* @__PURE__ */ h("div", { className: "ff-flex ff-items-start ff-gap-2 ff-p-4 ff-rounded-lg", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: [
717
+ /* @__PURE__ */ d(Le, { className: "ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5", style: { color: "var(--ff-warning)" } }),
718
+ /* @__PURE__ */ h("div", { children: [
719
+ /* @__PURE__ */ d("p", { className: "ff-text-sm ff-font-medium", style: { color: "var(--ff-warning-dark)" }, children: "Required fields not mapped" }),
720
+ /* @__PURE__ */ d("p", { className: "ff-text-sm ff-mt-1", style: { color: "var(--ff-warning)" }, children: g.map((c) => c.label).join(", ") })
721
+ ] })
722
+ ] }) : null;
723
+ })()
724
+ ] });
725
+ };
726
+ /**
727
+ * table-core
728
+ *
729
+ * Copyright (c) TanStack
730
+ *
731
+ * This source code is licensed under the MIT license found in the
732
+ * LICENSE.md file in the root directory of this source tree.
733
+ *
734
+ * @license MIT
735
+ */
736
+ function Yt() {
737
+ return {
738
+ accessor: (e, o) => typeof e == "function" ? {
739
+ ...o,
740
+ accessorFn: e
741
+ } : {
742
+ ...o,
743
+ accessorKey: e
744
+ },
745
+ display: (e) => e,
746
+ group: (e) => e
747
+ };
748
+ }
749
+ function Y(e, o) {
750
+ return typeof e == "function" ? e(o) : e;
751
+ }
752
+ function G(e, o) {
753
+ return (t) => {
754
+ o.setState((n) => ({
755
+ ...n,
756
+ [e]: Y(t, n[e])
757
+ }));
758
+ };
759
+ }
760
+ function ve(e) {
761
+ return e instanceof Function;
762
+ }
763
+ function Qt(e) {
764
+ return Array.isArray(e) && e.every((o) => typeof o == "number");
765
+ }
766
+ function Jt(e, o) {
767
+ const t = [], n = (r) => {
768
+ r.forEach((l) => {
769
+ t.push(l);
770
+ const s = o(l);
771
+ s != null && s.length && n(s);
772
+ });
773
+ };
774
+ return n(e), t;
775
+ }
776
+ function S(e, o, t) {
777
+ let n = [], r;
778
+ return (l) => {
779
+ let s;
780
+ t.key && t.debug && (s = Date.now());
781
+ const i = e(l);
782
+ if (!(i.length !== n.length || i.some((p, g) => n[g] !== p)))
783
+ return r;
784
+ n = i;
785
+ let f;
786
+ if (t.key && t.debug && (f = Date.now()), r = o(...i), t == null || t.onChange == null || t.onChange(r), t.key && t.debug && t != null && t.debug()) {
787
+ const p = Math.round((Date.now() - s) * 100) / 100, g = Math.round((Date.now() - f) * 100) / 100, c = g / 16, a = (m, v) => {
788
+ for (m = String(m); m.length < v; )
789
+ m = " " + m;
790
+ return m;
791
+ };
792
+ console.info(`%c⏱ ${a(g, 5)} /${a(p, 5)} ms`, `
793
+ font-size: .6rem;
794
+ font-weight: bold;
795
+ color: hsl(${Math.max(0, Math.min(120 - 120 * c, 120))}deg 100% 31%);`, t == null ? void 0 : t.key);
796
+ }
797
+ return r;
798
+ };
799
+ }
800
+ function R(e, o, t, n) {
801
+ return {
802
+ debug: () => {
803
+ var r;
804
+ return (r = e == null ? void 0 : e.debugAll) != null ? r : e[o];
805
+ },
806
+ key: process.env.NODE_ENV === "development" && t,
807
+ onChange: n
808
+ };
809
+ }
810
+ function en(e, o, t, n) {
811
+ const r = () => {
812
+ var s;
813
+ return (s = l.getValue()) != null ? s : e.options.renderFallbackValue;
814
+ }, l = {
815
+ id: `${o.id}_${t.id}`,
816
+ row: o,
817
+ column: t,
818
+ getValue: () => o.getValue(n),
819
+ renderValue: r,
820
+ getContext: S(() => [e, t, o, l], (s, i, u, f) => ({
821
+ table: s,
822
+ column: i,
823
+ row: u,
824
+ cell: f,
825
+ getValue: f.getValue,
826
+ renderValue: f.renderValue
827
+ }), R(e.options, "debugCells", "cell.getContext"))
828
+ };
829
+ return e._features.forEach((s) => {
830
+ s.createCell == null || s.createCell(l, t, o, e);
831
+ }, {}), l;
832
+ }
833
+ function tn(e, o, t, n) {
834
+ var r, l;
835
+ const i = {
836
+ ...e._getDefaultColumnDef(),
837
+ ...o
838
+ }, u = i.accessorKey;
839
+ let f = (r = (l = i.id) != null ? l : u ? typeof String.prototype.replaceAll == "function" ? u.replaceAll(".", "_") : u.replace(/\./g, "_") : void 0) != null ? r : typeof i.header == "string" ? i.header : void 0, p;
840
+ if (i.accessorFn ? p = i.accessorFn : u && (u.includes(".") ? p = (c) => {
841
+ let a = c;
842
+ for (const v of u.split(".")) {
843
+ var m;
844
+ a = (m = a) == null ? void 0 : m[v], process.env.NODE_ENV !== "production" && a === void 0 && console.warn(`"${v}" in deeply nested key "${u}" returned undefined.`);
845
+ }
846
+ return a;
847
+ } : p = (c) => c[i.accessorKey]), !f)
848
+ throw process.env.NODE_ENV !== "production" ? new Error(i.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header") : new Error();
849
+ let g = {
850
+ id: `${String(f)}`,
851
+ accessorFn: p,
852
+ parent: n,
853
+ depth: t,
854
+ columnDef: i,
855
+ columns: [],
856
+ getFlatColumns: S(() => [!0], () => {
857
+ var c;
858
+ return [g, ...(c = g.columns) == null ? void 0 : c.flatMap((a) => a.getFlatColumns())];
859
+ }, R(e.options, "debugColumns", "column.getFlatColumns")),
860
+ getLeafColumns: S(() => [e._getOrderColumnsFn()], (c) => {
861
+ var a;
862
+ if ((a = g.columns) != null && a.length) {
863
+ let m = g.columns.flatMap((v) => v.getLeafColumns());
864
+ return c(m);
865
+ }
866
+ return [g];
867
+ }, R(e.options, "debugColumns", "column.getLeafColumns"))
868
+ };
869
+ for (const c of e._features)
870
+ c.createColumn == null || c.createColumn(g, e);
871
+ return g;
872
+ }
873
+ const z = "debugHeaders";
874
+ function Qe(e, o, t) {
875
+ var n;
876
+ let l = {
877
+ id: (n = t.id) != null ? n : o.id,
878
+ column: o,
879
+ index: t.index,
880
+ isPlaceholder: !!t.isPlaceholder,
881
+ placeholderId: t.placeholderId,
882
+ depth: t.depth,
883
+ subHeaders: [],
884
+ colSpan: 0,
885
+ rowSpan: 0,
886
+ headerGroup: null,
887
+ getLeafHeaders: () => {
888
+ const s = [], i = (u) => {
889
+ u.subHeaders && u.subHeaders.length && u.subHeaders.map(i), s.push(u);
890
+ };
891
+ return i(l), s;
892
+ },
893
+ getContext: () => ({
894
+ table: e,
895
+ header: l,
896
+ column: o
897
+ })
898
+ };
899
+ return e._features.forEach((s) => {
900
+ s.createHeader == null || s.createHeader(l, e);
901
+ }), l;
902
+ }
903
+ const nn = {
904
+ createTable: (e) => {
905
+ e.getHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n, r) => {
906
+ var l, s;
907
+ const i = (l = n == null ? void 0 : n.map((g) => t.find((c) => c.id === g)).filter(Boolean)) != null ? l : [], u = (s = r == null ? void 0 : r.map((g) => t.find((c) => c.id === g)).filter(Boolean)) != null ? s : [], f = t.filter((g) => !(n != null && n.includes(g.id)) && !(r != null && r.includes(g.id)));
908
+ return ge(o, [...i, ...f, ...u], e);
909
+ }, R(e.options, z, "getHeaderGroups")), e.getCenterHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n, r) => (t = t.filter((l) => !(n != null && n.includes(l.id)) && !(r != null && r.includes(l.id))), ge(o, t, e, "center")), R(e.options, z, "getCenterHeaderGroups")), e.getLeftHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left], (o, t, n) => {
910
+ var r;
911
+ const l = (r = n == null ? void 0 : n.map((s) => t.find((i) => i.id === s)).filter(Boolean)) != null ? r : [];
912
+ return ge(o, l, e, "left");
913
+ }, R(e.options, z, "getLeftHeaderGroups")), e.getRightHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.right], (o, t, n) => {
914
+ var r;
915
+ const l = (r = n == null ? void 0 : n.map((s) => t.find((i) => i.id === s)).filter(Boolean)) != null ? r : [];
916
+ return ge(o, l, e, "right");
917
+ }, R(e.options, z, "getRightHeaderGroups")), e.getFooterGroups = S(() => [e.getHeaderGroups()], (o) => [...o].reverse(), R(e.options, z, "getFooterGroups")), e.getLeftFooterGroups = S(() => [e.getLeftHeaderGroups()], (o) => [...o].reverse(), R(e.options, z, "getLeftFooterGroups")), e.getCenterFooterGroups = S(() => [e.getCenterHeaderGroups()], (o) => [...o].reverse(), R(e.options, z, "getCenterFooterGroups")), e.getRightFooterGroups = S(() => [e.getRightHeaderGroups()], (o) => [...o].reverse(), R(e.options, z, "getRightFooterGroups")), e.getFlatHeaders = S(() => [e.getHeaderGroups()], (o) => o.map((t) => t.headers).flat(), R(e.options, z, "getFlatHeaders")), e.getLeftFlatHeaders = S(() => [e.getLeftHeaderGroups()], (o) => o.map((t) => t.headers).flat(), R(e.options, z, "getLeftFlatHeaders")), e.getCenterFlatHeaders = S(() => [e.getCenterHeaderGroups()], (o) => o.map((t) => t.headers).flat(), R(e.options, z, "getCenterFlatHeaders")), e.getRightFlatHeaders = S(() => [e.getRightHeaderGroups()], (o) => o.map((t) => t.headers).flat(), R(e.options, z, "getRightFlatHeaders")), e.getCenterLeafHeaders = S(() => [e.getCenterFlatHeaders()], (o) => o.filter((t) => {
918
+ var n;
919
+ return !((n = t.subHeaders) != null && n.length);
920
+ }), R(e.options, z, "getCenterLeafHeaders")), e.getLeftLeafHeaders = S(() => [e.getLeftFlatHeaders()], (o) => o.filter((t) => {
921
+ var n;
922
+ return !((n = t.subHeaders) != null && n.length);
923
+ }), R(e.options, z, "getLeftLeafHeaders")), e.getRightLeafHeaders = S(() => [e.getRightFlatHeaders()], (o) => o.filter((t) => {
924
+ var n;
925
+ return !((n = t.subHeaders) != null && n.length);
926
+ }), R(e.options, z, "getRightLeafHeaders")), e.getLeafHeaders = S(() => [e.getLeftHeaderGroups(), e.getCenterHeaderGroups(), e.getRightHeaderGroups()], (o, t, n) => {
927
+ var r, l, s, i, u, f;
928
+ return [...(r = (l = o[0]) == null ? void 0 : l.headers) != null ? r : [], ...(s = (i = t[0]) == null ? void 0 : i.headers) != null ? s : [], ...(u = (f = n[0]) == null ? void 0 : f.headers) != null ? u : []].map((p) => p.getLeafHeaders()).flat();
929
+ }, R(e.options, z, "getLeafHeaders"));
930
+ }
931
+ };
932
+ function ge(e, o, t, n) {
933
+ var r, l;
934
+ let s = 0;
935
+ const i = function(c, a) {
936
+ a === void 0 && (a = 1), s = Math.max(s, a), c.filter((m) => m.getIsVisible()).forEach((m) => {
937
+ var v;
938
+ (v = m.columns) != null && v.length && i(m.columns, a + 1);
939
+ }, 0);
940
+ };
941
+ i(e);
942
+ let u = [];
943
+ const f = (c, a) => {
944
+ const m = {
945
+ depth: a,
946
+ id: [n, `${a}`].filter(Boolean).join("_"),
947
+ headers: []
948
+ }, v = [];
949
+ c.forEach((C) => {
950
+ const w = [...v].reverse()[0], y = C.column.depth === m.depth;
951
+ let x, N = !1;
952
+ if (y && C.column.parent ? x = C.column.parent : (x = C.column, N = !0), w && (w == null ? void 0 : w.column) === x)
953
+ w.subHeaders.push(C);
954
+ else {
955
+ const _ = Qe(t, x, {
956
+ id: [n, a, x.id, C == null ? void 0 : C.id].filter(Boolean).join("_"),
957
+ isPlaceholder: N,
958
+ placeholderId: N ? `${v.filter((P) => P.column === x).length}` : void 0,
959
+ depth: a,
960
+ index: v.length
961
+ });
962
+ _.subHeaders.push(C), v.push(_);
963
+ }
964
+ m.headers.push(C), C.headerGroup = m;
965
+ }), u.push(m), a > 0 && f(v, a - 1);
966
+ }, p = o.map((c, a) => Qe(t, c, {
967
+ depth: s,
968
+ index: a
969
+ }));
970
+ f(p, s - 1), u.reverse();
971
+ const g = (c) => c.filter((m) => m.column.getIsVisible()).map((m) => {
972
+ let v = 0, C = 0, w = [0];
973
+ m.subHeaders && m.subHeaders.length ? (w = [], g(m.subHeaders).forEach((x) => {
974
+ let {
975
+ colSpan: N,
976
+ rowSpan: _
977
+ } = x;
978
+ v += N, w.push(_);
979
+ })) : v = 1;
980
+ const y = Math.min(...w);
981
+ return C = C + y, m.colSpan = v, m.rowSpan = C, {
982
+ colSpan: v,
983
+ rowSpan: C
984
+ };
985
+ });
986
+ return g((r = (l = u[0]) == null ? void 0 : l.headers) != null ? r : []), u;
987
+ }
988
+ const Ae = (e, o, t, n, r, l, s) => {
989
+ let i = {
990
+ id: o,
991
+ index: n,
992
+ original: t,
993
+ depth: r,
994
+ parentId: s,
995
+ _valuesCache: {},
996
+ _uniqueValuesCache: {},
997
+ getValue: (u) => {
998
+ if (i._valuesCache.hasOwnProperty(u))
999
+ return i._valuesCache[u];
1000
+ const f = e.getColumn(u);
1001
+ if (f != null && f.accessorFn)
1002
+ return i._valuesCache[u] = f.accessorFn(i.original, n), i._valuesCache[u];
1003
+ },
1004
+ getUniqueValues: (u) => {
1005
+ if (i._uniqueValuesCache.hasOwnProperty(u))
1006
+ return i._uniqueValuesCache[u];
1007
+ const f = e.getColumn(u);
1008
+ if (f != null && f.accessorFn)
1009
+ return f.columnDef.getUniqueValues ? (i._uniqueValuesCache[u] = f.columnDef.getUniqueValues(i.original, n), i._uniqueValuesCache[u]) : (i._uniqueValuesCache[u] = [i.getValue(u)], i._uniqueValuesCache[u]);
1010
+ },
1011
+ renderValue: (u) => {
1012
+ var f;
1013
+ return (f = i.getValue(u)) != null ? f : e.options.renderFallbackValue;
1014
+ },
1015
+ subRows: [],
1016
+ getLeafRows: () => Jt(i.subRows, (u) => u.subRows),
1017
+ getParentRow: () => i.parentId ? e.getRow(i.parentId, !0) : void 0,
1018
+ getParentRows: () => {
1019
+ let u = [], f = i;
1020
+ for (; ; ) {
1021
+ const p = f.getParentRow();
1022
+ if (!p) break;
1023
+ u.push(p), f = p;
1024
+ }
1025
+ return u.reverse();
1026
+ },
1027
+ getAllCells: S(() => [e.getAllLeafColumns()], (u) => u.map((f) => en(e, i, f, f.id)), R(e.options, "debugRows", "getAllCells")),
1028
+ _getAllCellsByColumnId: S(() => [i.getAllCells()], (u) => u.reduce((f, p) => (f[p.column.id] = p, f), {}), R(e.options, "debugRows", "getAllCellsByColumnId"))
1029
+ };
1030
+ for (let u = 0; u < e._features.length; u++) {
1031
+ const f = e._features[u];
1032
+ f == null || f.createRow == null || f.createRow(i, e);
1033
+ }
1034
+ return i;
1035
+ }, on = {
1036
+ createColumn: (e, o) => {
1037
+ e._getFacetedRowModel = o.options.getFacetedRowModel && o.options.getFacetedRowModel(o, e.id), e.getFacetedRowModel = () => e._getFacetedRowModel ? e._getFacetedRowModel() : o.getPreFilteredRowModel(), e._getFacetedUniqueValues = o.options.getFacetedUniqueValues && o.options.getFacetedUniqueValues(o, e.id), e.getFacetedUniqueValues = () => e._getFacetedUniqueValues ? e._getFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getFacetedMinMaxValues = o.options.getFacetedMinMaxValues && o.options.getFacetedMinMaxValues(o, e.id), e.getFacetedMinMaxValues = () => {
1038
+ if (e._getFacetedMinMaxValues)
1039
+ return e._getFacetedMinMaxValues();
1040
+ };
1041
+ }
1042
+ }, rt = (e, o, t) => {
1043
+ var n, r;
1044
+ const l = t == null || (n = t.toString()) == null ? void 0 : n.toLowerCase();
1045
+ return !!(!((r = e.getValue(o)) == null || (r = r.toString()) == null || (r = r.toLowerCase()) == null) && r.includes(l));
1046
+ };
1047
+ rt.autoRemove = (e) => j(e);
1048
+ const lt = (e, o, t) => {
1049
+ var n;
1050
+ return !!(!((n = e.getValue(o)) == null || (n = n.toString()) == null) && n.includes(t));
1051
+ };
1052
+ lt.autoRemove = (e) => j(e);
1053
+ const st = (e, o, t) => {
1054
+ var n;
1055
+ return ((n = e.getValue(o)) == null || (n = n.toString()) == null ? void 0 : n.toLowerCase()) === (t == null ? void 0 : t.toLowerCase());
1056
+ };
1057
+ st.autoRemove = (e) => j(e);
1058
+ const it = (e, o, t) => {
1059
+ var n;
1060
+ return (n = e.getValue(o)) == null ? void 0 : n.includes(t);
1061
+ };
1062
+ it.autoRemove = (e) => j(e);
1063
+ const at = (e, o, t) => !t.some((n) => {
1064
+ var r;
1065
+ return !((r = e.getValue(o)) != null && r.includes(n));
1066
+ });
1067
+ at.autoRemove = (e) => j(e) || !(e != null && e.length);
1068
+ const ut = (e, o, t) => t.some((n) => {
1069
+ var r;
1070
+ return (r = e.getValue(o)) == null ? void 0 : r.includes(n);
1071
+ });
1072
+ ut.autoRemove = (e) => j(e) || !(e != null && e.length);
1073
+ const ft = (e, o, t) => e.getValue(o) === t;
1074
+ ft.autoRemove = (e) => j(e);
1075
+ const dt = (e, o, t) => e.getValue(o) == t;
1076
+ dt.autoRemove = (e) => j(e);
1077
+ const He = (e, o, t) => {
1078
+ let [n, r] = t;
1079
+ const l = e.getValue(o);
1080
+ return l >= n && l <= r;
1081
+ };
1082
+ He.resolveFilterValue = (e) => {
1083
+ let [o, t] = e, n = typeof o != "number" ? parseFloat(o) : o, r = typeof t != "number" ? parseFloat(t) : t, l = o === null || Number.isNaN(n) ? -1 / 0 : n, s = t === null || Number.isNaN(r) ? 1 / 0 : r;
1084
+ if (l > s) {
1085
+ const i = l;
1086
+ l = s, s = i;
1087
+ }
1088
+ return [l, s];
1089
+ };
1090
+ He.autoRemove = (e) => j(e) || j(e[0]) && j(e[1]);
1091
+ const U = {
1092
+ includesString: rt,
1093
+ includesStringSensitive: lt,
1094
+ equalsString: st,
1095
+ arrIncludes: it,
1096
+ arrIncludesAll: at,
1097
+ arrIncludesSome: ut,
1098
+ equals: ft,
1099
+ weakEquals: dt,
1100
+ inNumberRange: He
1101
+ };
1102
+ function j(e) {
1103
+ return e == null || e === "";
1104
+ }
1105
+ const rn = {
1106
+ getDefaultColumnDef: () => ({
1107
+ filterFn: "auto"
1108
+ }),
1109
+ getInitialState: (e) => ({
1110
+ columnFilters: [],
1111
+ ...e
1112
+ }),
1113
+ getDefaultOptions: (e) => ({
1114
+ onColumnFiltersChange: G("columnFilters", e),
1115
+ filterFromLeafRows: !1,
1116
+ maxLeafRowFilterDepth: 100
1117
+ }),
1118
+ createColumn: (e, o) => {
1119
+ e.getAutoFilterFn = () => {
1120
+ const t = o.getCoreRowModel().flatRows[0], n = t == null ? void 0 : t.getValue(e.id);
1121
+ return typeof n == "string" ? U.includesString : typeof n == "number" ? U.inNumberRange : typeof n == "boolean" || n !== null && typeof n == "object" ? U.equals : Array.isArray(n) ? U.arrIncludes : U.weakEquals;
1122
+ }, e.getFilterFn = () => {
1123
+ var t, n;
1124
+ return ve(e.columnDef.filterFn) ? e.columnDef.filterFn : e.columnDef.filterFn === "auto" ? e.getAutoFilterFn() : (
1125
+ // @ts-ignore
1126
+ (t = (n = o.options.filterFns) == null ? void 0 : n[e.columnDef.filterFn]) != null ? t : U[e.columnDef.filterFn]
1127
+ );
1128
+ }, e.getCanFilter = () => {
1129
+ var t, n, r;
1130
+ return ((t = e.columnDef.enableColumnFilter) != null ? t : !0) && ((n = o.options.enableColumnFilters) != null ? n : !0) && ((r = o.options.enableFilters) != null ? r : !0) && !!e.accessorFn;
1131
+ }, e.getIsFiltered = () => e.getFilterIndex() > -1, e.getFilterValue = () => {
1132
+ var t;
1133
+ return (t = o.getState().columnFilters) == null || (t = t.find((n) => n.id === e.id)) == null ? void 0 : t.value;
1134
+ }, e.getFilterIndex = () => {
1135
+ var t, n;
1136
+ return (t = (n = o.getState().columnFilters) == null ? void 0 : n.findIndex((r) => r.id === e.id)) != null ? t : -1;
1137
+ }, e.setFilterValue = (t) => {
1138
+ o.setColumnFilters((n) => {
1139
+ const r = e.getFilterFn(), l = n == null ? void 0 : n.find((p) => p.id === e.id), s = Y(t, l ? l.value : void 0);
1140
+ if (Je(r, s, e)) {
1141
+ var i;
1142
+ return (i = n == null ? void 0 : n.filter((p) => p.id !== e.id)) != null ? i : [];
1143
+ }
1144
+ const u = {
1145
+ id: e.id,
1146
+ value: s
1147
+ };
1148
+ if (l) {
1149
+ var f;
1150
+ return (f = n == null ? void 0 : n.map((p) => p.id === e.id ? u : p)) != null ? f : [];
1151
+ }
1152
+ return n != null && n.length ? [...n, u] : [u];
1153
+ });
1154
+ };
1155
+ },
1156
+ createRow: (e, o) => {
1157
+ e.columnFilters = {}, e.columnFiltersMeta = {};
1158
+ },
1159
+ createTable: (e) => {
1160
+ e.setColumnFilters = (o) => {
1161
+ const t = e.getAllLeafColumns(), n = (r) => {
1162
+ var l;
1163
+ return (l = Y(o, r)) == null ? void 0 : l.filter((s) => {
1164
+ const i = t.find((u) => u.id === s.id);
1165
+ if (i) {
1166
+ const u = i.getFilterFn();
1167
+ if (Je(u, s.value, i))
1168
+ return !1;
1169
+ }
1170
+ return !0;
1171
+ });
1172
+ };
1173
+ e.options.onColumnFiltersChange == null || e.options.onColumnFiltersChange(n);
1174
+ }, e.resetColumnFilters = (o) => {
1175
+ var t, n;
1176
+ e.setColumnFilters(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.columnFilters) != null ? t : []);
1177
+ }, e.getPreFilteredRowModel = () => e.getCoreRowModel(), e.getFilteredRowModel = () => (!e._getFilteredRowModel && e.options.getFilteredRowModel && (e._getFilteredRowModel = e.options.getFilteredRowModel(e)), e.options.manualFiltering || !e._getFilteredRowModel ? e.getPreFilteredRowModel() : e._getFilteredRowModel());
1178
+ }
1179
+ };
1180
+ function Je(e, o, t) {
1181
+ return (e && e.autoRemove ? e.autoRemove(o, t) : !1) || typeof o > "u" || typeof o == "string" && !o;
1182
+ }
1183
+ const ln = (e, o, t) => t.reduce((n, r) => {
1184
+ const l = r.getValue(e);
1185
+ return n + (typeof l == "number" ? l : 0);
1186
+ }, 0), sn = (e, o, t) => {
1187
+ let n;
1188
+ return t.forEach((r) => {
1189
+ const l = r.getValue(e);
1190
+ l != null && (n > l || n === void 0 && l >= l) && (n = l);
1191
+ }), n;
1192
+ }, an = (e, o, t) => {
1193
+ let n;
1194
+ return t.forEach((r) => {
1195
+ const l = r.getValue(e);
1196
+ l != null && (n < l || n === void 0 && l >= l) && (n = l);
1197
+ }), n;
1198
+ }, un = (e, o, t) => {
1199
+ let n, r;
1200
+ return t.forEach((l) => {
1201
+ const s = l.getValue(e);
1202
+ s != null && (n === void 0 ? s >= s && (n = r = s) : (n > s && (n = s), r < s && (r = s)));
1203
+ }), [n, r];
1204
+ }, fn = (e, o) => {
1205
+ let t = 0, n = 0;
1206
+ if (o.forEach((r) => {
1207
+ let l = r.getValue(e);
1208
+ l != null && (l = +l) >= l && (++t, n += l);
1209
+ }), t) return n / t;
1210
+ }, dn = (e, o) => {
1211
+ if (!o.length)
1212
+ return;
1213
+ const t = o.map((l) => l.getValue(e));
1214
+ if (!Qt(t))
1215
+ return;
1216
+ if (t.length === 1)
1217
+ return t[0];
1218
+ const n = Math.floor(t.length / 2), r = t.sort((l, s) => l - s);
1219
+ return t.length % 2 !== 0 ? r[n] : (r[n - 1] + r[n]) / 2;
1220
+ }, cn = (e, o) => Array.from(new Set(o.map((t) => t.getValue(e))).values()), gn = (e, o) => new Set(o.map((t) => t.getValue(e))).size, pn = (e, o) => o.length, ye = {
1221
+ sum: ln,
1222
+ min: sn,
1223
+ max: an,
1224
+ extent: un,
1225
+ mean: fn,
1226
+ median: dn,
1227
+ unique: cn,
1228
+ uniqueCount: gn,
1229
+ count: pn
1230
+ }, mn = {
1231
+ getDefaultColumnDef: () => ({
1232
+ aggregatedCell: (e) => {
1233
+ var o, t;
1234
+ return (o = (t = e.getValue()) == null || t.toString == null ? void 0 : t.toString()) != null ? o : null;
1235
+ },
1236
+ aggregationFn: "auto"
1237
+ }),
1238
+ getInitialState: (e) => ({
1239
+ grouping: [],
1240
+ ...e
1241
+ }),
1242
+ getDefaultOptions: (e) => ({
1243
+ onGroupingChange: G("grouping", e),
1244
+ groupedColumnMode: "reorder"
1245
+ }),
1246
+ createColumn: (e, o) => {
1247
+ e.toggleGrouping = () => {
1248
+ o.setGrouping((t) => t != null && t.includes(e.id) ? t.filter((n) => n !== e.id) : [...t ?? [], e.id]);
1249
+ }, e.getCanGroup = () => {
1250
+ var t, n;
1251
+ return ((t = e.columnDef.enableGrouping) != null ? t : !0) && ((n = o.options.enableGrouping) != null ? n : !0) && (!!e.accessorFn || !!e.columnDef.getGroupingValue);
1252
+ }, e.getIsGrouped = () => {
1253
+ var t;
1254
+ return (t = o.getState().grouping) == null ? void 0 : t.includes(e.id);
1255
+ }, e.getGroupedIndex = () => {
1256
+ var t;
1257
+ return (t = o.getState().grouping) == null ? void 0 : t.indexOf(e.id);
1258
+ }, e.getToggleGroupingHandler = () => {
1259
+ const t = e.getCanGroup();
1260
+ return () => {
1261
+ t && e.toggleGrouping();
1262
+ };
1263
+ }, e.getAutoAggregationFn = () => {
1264
+ const t = o.getCoreRowModel().flatRows[0], n = t == null ? void 0 : t.getValue(e.id);
1265
+ if (typeof n == "number")
1266
+ return ye.sum;
1267
+ if (Object.prototype.toString.call(n) === "[object Date]")
1268
+ return ye.extent;
1269
+ }, e.getAggregationFn = () => {
1270
+ var t, n;
1271
+ if (!e)
1272
+ throw new Error();
1273
+ return ve(e.columnDef.aggregationFn) ? e.columnDef.aggregationFn : e.columnDef.aggregationFn === "auto" ? e.getAutoAggregationFn() : (t = (n = o.options.aggregationFns) == null ? void 0 : n[e.columnDef.aggregationFn]) != null ? t : ye[e.columnDef.aggregationFn];
1274
+ };
1275
+ },
1276
+ createTable: (e) => {
1277
+ e.setGrouping = (o) => e.options.onGroupingChange == null ? void 0 : e.options.onGroupingChange(o), e.resetGrouping = (o) => {
1278
+ var t, n;
1279
+ e.setGrouping(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.grouping) != null ? t : []);
1280
+ }, e.getPreGroupedRowModel = () => e.getFilteredRowModel(), e.getGroupedRowModel = () => (!e._getGroupedRowModel && e.options.getGroupedRowModel && (e._getGroupedRowModel = e.options.getGroupedRowModel(e)), e.options.manualGrouping || !e._getGroupedRowModel ? e.getPreGroupedRowModel() : e._getGroupedRowModel());
1281
+ },
1282
+ createRow: (e, o) => {
1283
+ e.getIsGrouped = () => !!e.groupingColumnId, e.getGroupingValue = (t) => {
1284
+ if (e._groupingValuesCache.hasOwnProperty(t))
1285
+ return e._groupingValuesCache[t];
1286
+ const n = o.getColumn(t);
1287
+ return n != null && n.columnDef.getGroupingValue ? (e._groupingValuesCache[t] = n.columnDef.getGroupingValue(e.original), e._groupingValuesCache[t]) : e.getValue(t);
1288
+ }, e._groupingValuesCache = {};
1289
+ },
1290
+ createCell: (e, o, t, n) => {
1291
+ e.getIsGrouped = () => o.getIsGrouped() && o.id === t.groupingColumnId, e.getIsPlaceholder = () => !e.getIsGrouped() && o.getIsGrouped(), e.getIsAggregated = () => {
1292
+ var r;
1293
+ return !e.getIsGrouped() && !e.getIsPlaceholder() && !!((r = t.subRows) != null && r.length);
1294
+ };
1295
+ }
1296
+ };
1297
+ function hn(e, o, t) {
1298
+ if (!(o != null && o.length) || !t)
1299
+ return e;
1300
+ const n = e.filter((l) => !o.includes(l.id));
1301
+ return t === "remove" ? n : [...o.map((l) => e.find((s) => s.id === l)).filter(Boolean), ...n];
1302
+ }
1303
+ const vn = {
1304
+ getInitialState: (e) => ({
1305
+ columnOrder: [],
1306
+ ...e
1307
+ }),
1308
+ getDefaultOptions: (e) => ({
1309
+ onColumnOrderChange: G("columnOrder", e)
1310
+ }),
1311
+ createColumn: (e, o) => {
1312
+ e.getIndex = S((t) => [ue(o, t)], (t) => t.findIndex((n) => n.id === e.id), R(o.options, "debugColumns", "getIndex")), e.getIsFirstColumn = (t) => {
1313
+ var n;
1314
+ return ((n = ue(o, t)[0]) == null ? void 0 : n.id) === e.id;
1315
+ }, e.getIsLastColumn = (t) => {
1316
+ var n;
1317
+ const r = ue(o, t);
1318
+ return ((n = r[r.length - 1]) == null ? void 0 : n.id) === e.id;
1319
+ };
1320
+ },
1321
+ createTable: (e) => {
1322
+ e.setColumnOrder = (o) => e.options.onColumnOrderChange == null ? void 0 : e.options.onColumnOrderChange(o), e.resetColumnOrder = (o) => {
1323
+ var t;
1324
+ e.setColumnOrder(o ? [] : (t = e.initialState.columnOrder) != null ? t : []);
1325
+ }, e._getOrderColumnsFn = S(() => [e.getState().columnOrder, e.getState().grouping, e.options.groupedColumnMode], (o, t, n) => (r) => {
1326
+ let l = [];
1327
+ if (!(o != null && o.length))
1328
+ l = r;
1329
+ else {
1330
+ const s = [...o], i = [...r];
1331
+ for (; i.length && s.length; ) {
1332
+ const u = s.shift(), f = i.findIndex((p) => p.id === u);
1333
+ f > -1 && l.push(i.splice(f, 1)[0]);
1334
+ }
1335
+ l = [...l, ...i];
1336
+ }
1337
+ return hn(l, t, n);
1338
+ }, R(e.options, "debugTable", "_getOrderColumnsFn"));
1339
+ }
1340
+ }, Se = () => ({
1341
+ left: [],
1342
+ right: []
1343
+ }), wn = {
1344
+ getInitialState: (e) => ({
1345
+ columnPinning: Se(),
1346
+ ...e
1347
+ }),
1348
+ getDefaultOptions: (e) => ({
1349
+ onColumnPinningChange: G("columnPinning", e)
1350
+ }),
1351
+ createColumn: (e, o) => {
1352
+ e.pin = (t) => {
1353
+ const n = e.getLeafColumns().map((r) => r.id).filter(Boolean);
1354
+ o.setColumnPinning((r) => {
1355
+ var l, s;
1356
+ if (t === "right") {
1357
+ var i, u;
1358
+ return {
1359
+ left: ((i = r == null ? void 0 : r.left) != null ? i : []).filter((g) => !(n != null && n.includes(g))),
1360
+ right: [...((u = r == null ? void 0 : r.right) != null ? u : []).filter((g) => !(n != null && n.includes(g))), ...n]
1361
+ };
1362
+ }
1363
+ if (t === "left") {
1364
+ var f, p;
1365
+ return {
1366
+ left: [...((f = r == null ? void 0 : r.left) != null ? f : []).filter((g) => !(n != null && n.includes(g))), ...n],
1367
+ right: ((p = r == null ? void 0 : r.right) != null ? p : []).filter((g) => !(n != null && n.includes(g)))
1368
+ };
1369
+ }
1370
+ return {
1371
+ left: ((l = r == null ? void 0 : r.left) != null ? l : []).filter((g) => !(n != null && n.includes(g))),
1372
+ right: ((s = r == null ? void 0 : r.right) != null ? s : []).filter((g) => !(n != null && n.includes(g)))
1373
+ };
1374
+ });
1375
+ }, e.getCanPin = () => e.getLeafColumns().some((n) => {
1376
+ var r, l, s;
1377
+ return ((r = n.columnDef.enablePinning) != null ? r : !0) && ((l = (s = o.options.enableColumnPinning) != null ? s : o.options.enablePinning) != null ? l : !0);
1378
+ }), e.getIsPinned = () => {
1379
+ const t = e.getLeafColumns().map((i) => i.id), {
1380
+ left: n,
1381
+ right: r
1382
+ } = o.getState().columnPinning, l = t.some((i) => n == null ? void 0 : n.includes(i)), s = t.some((i) => r == null ? void 0 : r.includes(i));
1383
+ return l ? "left" : s ? "right" : !1;
1384
+ }, e.getPinnedIndex = () => {
1385
+ var t, n;
1386
+ const r = e.getIsPinned();
1387
+ return r ? (t = (n = o.getState().columnPinning) == null || (n = n[r]) == null ? void 0 : n.indexOf(e.id)) != null ? t : -1 : 0;
1388
+ };
1389
+ },
1390
+ createRow: (e, o) => {
1391
+ e.getCenterVisibleCells = S(() => [e._getAllVisibleCells(), o.getState().columnPinning.left, o.getState().columnPinning.right], (t, n, r) => {
1392
+ const l = [...n ?? [], ...r ?? []];
1393
+ return t.filter((s) => !l.includes(s.column.id));
1394
+ }, R(o.options, "debugRows", "getCenterVisibleCells")), e.getLeftVisibleCells = S(() => [e._getAllVisibleCells(), o.getState().columnPinning.left], (t, n) => (n ?? []).map((l) => t.find((s) => s.column.id === l)).filter(Boolean).map((l) => ({
1395
+ ...l,
1396
+ position: "left"
1397
+ })), R(o.options, "debugRows", "getLeftVisibleCells")), e.getRightVisibleCells = S(() => [e._getAllVisibleCells(), o.getState().columnPinning.right], (t, n) => (n ?? []).map((l) => t.find((s) => s.column.id === l)).filter(Boolean).map((l) => ({
1398
+ ...l,
1399
+ position: "right"
1400
+ })), R(o.options, "debugRows", "getRightVisibleCells"));
1401
+ },
1402
+ createTable: (e) => {
1403
+ e.setColumnPinning = (o) => e.options.onColumnPinningChange == null ? void 0 : e.options.onColumnPinningChange(o), e.resetColumnPinning = (o) => {
1404
+ var t, n;
1405
+ return e.setColumnPinning(o ? Se() : (t = (n = e.initialState) == null ? void 0 : n.columnPinning) != null ? t : Se());
1406
+ }, e.getIsSomeColumnsPinned = (o) => {
1407
+ var t;
1408
+ const n = e.getState().columnPinning;
1409
+ if (!o) {
1410
+ var r, l;
1411
+ return !!((r = n.left) != null && r.length || (l = n.right) != null && l.length);
1412
+ }
1413
+ return !!((t = n[o]) != null && t.length);
1414
+ }, e.getLeftLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.left], (o, t) => (t ?? []).map((n) => o.find((r) => r.id === n)).filter(Boolean), R(e.options, "debugColumns", "getLeftLeafColumns")), e.getRightLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.right], (o, t) => (t ?? []).map((n) => o.find((r) => r.id === n)).filter(Boolean), R(e.options, "debugColumns", "getRightLeafColumns")), e.getCenterLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (o, t, n) => {
1415
+ const r = [...t ?? [], ...n ?? []];
1416
+ return o.filter((l) => !r.includes(l.id));
1417
+ }, R(e.options, "debugColumns", "getCenterLeafColumns"));
1418
+ }
1419
+ };
1420
+ function Cn(e) {
1421
+ return e || (typeof document < "u" ? document : null);
1422
+ }
1423
+ const pe = {
1424
+ size: 150,
1425
+ minSize: 20,
1426
+ maxSize: Number.MAX_SAFE_INTEGER
1427
+ }, Re = () => ({
1428
+ startOffset: null,
1429
+ startSize: null,
1430
+ deltaOffset: null,
1431
+ deltaPercentage: null,
1432
+ isResizingColumn: !1,
1433
+ columnSizingStart: []
1434
+ }), yn = {
1435
+ getDefaultColumnDef: () => pe,
1436
+ getInitialState: (e) => ({
1437
+ columnSizing: {},
1438
+ columnSizingInfo: Re(),
1439
+ ...e
1440
+ }),
1441
+ getDefaultOptions: (e) => ({
1442
+ columnResizeMode: "onEnd",
1443
+ columnResizeDirection: "ltr",
1444
+ onColumnSizingChange: G("columnSizing", e),
1445
+ onColumnSizingInfoChange: G("columnSizingInfo", e)
1446
+ }),
1447
+ createColumn: (e, o) => {
1448
+ e.getSize = () => {
1449
+ var t, n, r;
1450
+ const l = o.getState().columnSizing[e.id];
1451
+ return Math.min(Math.max((t = e.columnDef.minSize) != null ? t : pe.minSize, (n = l ?? e.columnDef.size) != null ? n : pe.size), (r = e.columnDef.maxSize) != null ? r : pe.maxSize);
1452
+ }, e.getStart = S((t) => [t, ue(o, t), o.getState().columnSizing], (t, n) => n.slice(0, e.getIndex(t)).reduce((r, l) => r + l.getSize(), 0), R(o.options, "debugColumns", "getStart")), e.getAfter = S((t) => [t, ue(o, t), o.getState().columnSizing], (t, n) => n.slice(e.getIndex(t) + 1).reduce((r, l) => r + l.getSize(), 0), R(o.options, "debugColumns", "getAfter")), e.resetSize = () => {
1453
+ o.setColumnSizing((t) => {
1454
+ let {
1455
+ [e.id]: n,
1456
+ ...r
1457
+ } = t;
1458
+ return r;
1459
+ });
1460
+ }, e.getCanResize = () => {
1461
+ var t, n;
1462
+ return ((t = e.columnDef.enableResizing) != null ? t : !0) && ((n = o.options.enableColumnResizing) != null ? n : !0);
1463
+ }, e.getIsResizing = () => o.getState().columnSizingInfo.isResizingColumn === e.id;
1464
+ },
1465
+ createHeader: (e, o) => {
1466
+ e.getSize = () => {
1467
+ let t = 0;
1468
+ const n = (r) => {
1469
+ if (r.subHeaders.length)
1470
+ r.subHeaders.forEach(n);
1471
+ else {
1472
+ var l;
1473
+ t += (l = r.column.getSize()) != null ? l : 0;
1474
+ }
1475
+ };
1476
+ return n(e), t;
1477
+ }, e.getStart = () => {
1478
+ if (e.index > 0) {
1479
+ const t = e.headerGroup.headers[e.index - 1];
1480
+ return t.getStart() + t.getSize();
1481
+ }
1482
+ return 0;
1483
+ }, e.getResizeHandler = (t) => {
1484
+ const n = o.getColumn(e.column.id), r = n == null ? void 0 : n.getCanResize();
1485
+ return (l) => {
1486
+ if (!n || !r || (l.persist == null || l.persist(), xe(l) && l.touches && l.touches.length > 1))
1487
+ return;
1488
+ const s = e.getSize(), i = e ? e.getLeafHeaders().map((w) => [w.column.id, w.column.getSize()]) : [[n.id, n.getSize()]], u = xe(l) ? Math.round(l.touches[0].clientX) : l.clientX, f = {}, p = (w, y) => {
1489
+ typeof y == "number" && (o.setColumnSizingInfo((x) => {
1490
+ var N, _;
1491
+ const P = o.options.columnResizeDirection === "rtl" ? -1 : 1, ee = (y - ((N = x == null ? void 0 : x.startOffset) != null ? N : 0)) * P, E = Math.max(ee / ((_ = x == null ? void 0 : x.startSize) != null ? _ : 0), -0.999999);
1492
+ return x.columnSizingStart.forEach((B) => {
1493
+ let [Z, D] = B;
1494
+ f[Z] = Math.round(Math.max(D + D * E, 0) * 100) / 100;
1495
+ }), {
1496
+ ...x,
1497
+ deltaOffset: ee,
1498
+ deltaPercentage: E
1499
+ };
1500
+ }), (o.options.columnResizeMode === "onChange" || w === "end") && o.setColumnSizing((x) => ({
1501
+ ...x,
1502
+ ...f
1503
+ })));
1504
+ }, g = (w) => p("move", w), c = (w) => {
1505
+ p("end", w), o.setColumnSizingInfo((y) => ({
1506
+ ...y,
1507
+ isResizingColumn: !1,
1508
+ startOffset: null,
1509
+ startSize: null,
1510
+ deltaOffset: null,
1511
+ deltaPercentage: null,
1512
+ columnSizingStart: []
1513
+ }));
1514
+ }, a = Cn(t), m = {
1515
+ moveHandler: (w) => g(w.clientX),
1516
+ upHandler: (w) => {
1517
+ a == null || a.removeEventListener("mousemove", m.moveHandler), a == null || a.removeEventListener("mouseup", m.upHandler), c(w.clientX);
1518
+ }
1519
+ }, v = {
1520
+ moveHandler: (w) => (w.cancelable && (w.preventDefault(), w.stopPropagation()), g(w.touches[0].clientX), !1),
1521
+ upHandler: (w) => {
1522
+ var y;
1523
+ a == null || a.removeEventListener("touchmove", v.moveHandler), a == null || a.removeEventListener("touchend", v.upHandler), w.cancelable && (w.preventDefault(), w.stopPropagation()), c((y = w.touches[0]) == null ? void 0 : y.clientX);
1524
+ }
1525
+ }, C = Sn() ? {
1526
+ passive: !1
1527
+ } : !1;
1528
+ xe(l) ? (a == null || a.addEventListener("touchmove", v.moveHandler, C), a == null || a.addEventListener("touchend", v.upHandler, C)) : (a == null || a.addEventListener("mousemove", m.moveHandler, C), a == null || a.addEventListener("mouseup", m.upHandler, C)), o.setColumnSizingInfo((w) => ({
1529
+ ...w,
1530
+ startOffset: u,
1531
+ startSize: s,
1532
+ deltaOffset: 0,
1533
+ deltaPercentage: 0,
1534
+ columnSizingStart: i,
1535
+ isResizingColumn: n.id
1536
+ }));
1537
+ };
1538
+ };
1539
+ },
1540
+ createTable: (e) => {
1541
+ e.setColumnSizing = (o) => e.options.onColumnSizingChange == null ? void 0 : e.options.onColumnSizingChange(o), e.setColumnSizingInfo = (o) => e.options.onColumnSizingInfoChange == null ? void 0 : e.options.onColumnSizingInfoChange(o), e.resetColumnSizing = (o) => {
1542
+ var t;
1543
+ e.setColumnSizing(o ? {} : (t = e.initialState.columnSizing) != null ? t : {});
1544
+ }, e.resetHeaderSizeInfo = (o) => {
1545
+ var t;
1546
+ e.setColumnSizingInfo(o ? Re() : (t = e.initialState.columnSizingInfo) != null ? t : Re());
1547
+ }, e.getTotalSize = () => {
1548
+ var o, t;
1549
+ return (o = (t = e.getHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, r) => n + r.getSize(), 0)) != null ? o : 0;
1550
+ }, e.getLeftTotalSize = () => {
1551
+ var o, t;
1552
+ return (o = (t = e.getLeftHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, r) => n + r.getSize(), 0)) != null ? o : 0;
1553
+ }, e.getCenterTotalSize = () => {
1554
+ var o, t;
1555
+ return (o = (t = e.getCenterHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, r) => n + r.getSize(), 0)) != null ? o : 0;
1556
+ }, e.getRightTotalSize = () => {
1557
+ var o, t;
1558
+ return (o = (t = e.getRightHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, r) => n + r.getSize(), 0)) != null ? o : 0;
1559
+ };
1560
+ }
1561
+ };
1562
+ let me = null;
1563
+ function Sn() {
1564
+ if (typeof me == "boolean") return me;
1565
+ let e = !1;
1566
+ try {
1567
+ const o = {
1568
+ get passive() {
1569
+ return e = !0, !1;
1570
+ }
1571
+ }, t = () => {
1572
+ };
1573
+ window.addEventListener("test", t, o), window.removeEventListener("test", t);
1574
+ } catch {
1575
+ e = !1;
1576
+ }
1577
+ return me = e, me;
1578
+ }
1579
+ function xe(e) {
1580
+ return e.type === "touchstart";
1581
+ }
1582
+ const Rn = {
1583
+ getInitialState: (e) => ({
1584
+ columnVisibility: {},
1585
+ ...e
1586
+ }),
1587
+ getDefaultOptions: (e) => ({
1588
+ onColumnVisibilityChange: G("columnVisibility", e)
1589
+ }),
1590
+ createColumn: (e, o) => {
1591
+ e.toggleVisibility = (t) => {
1592
+ e.getCanHide() && o.setColumnVisibility((n) => ({
1593
+ ...n,
1594
+ [e.id]: t ?? !e.getIsVisible()
1595
+ }));
1596
+ }, e.getIsVisible = () => {
1597
+ var t, n;
1598
+ const r = e.columns;
1599
+ return (t = r.length ? r.some((l) => l.getIsVisible()) : (n = o.getState().columnVisibility) == null ? void 0 : n[e.id]) != null ? t : !0;
1600
+ }, e.getCanHide = () => {
1601
+ var t, n;
1602
+ return ((t = e.columnDef.enableHiding) != null ? t : !0) && ((n = o.options.enableHiding) != null ? n : !0);
1603
+ }, e.getToggleVisibilityHandler = () => (t) => {
1604
+ e.toggleVisibility == null || e.toggleVisibility(t.target.checked);
1605
+ };
1606
+ },
1607
+ createRow: (e, o) => {
1608
+ e._getAllVisibleCells = S(() => [e.getAllCells(), o.getState().columnVisibility], (t) => t.filter((n) => n.column.getIsVisible()), R(o.options, "debugRows", "_getAllVisibleCells")), e.getVisibleCells = S(() => [e.getLeftVisibleCells(), e.getCenterVisibleCells(), e.getRightVisibleCells()], (t, n, r) => [...t, ...n, ...r], R(o.options, "debugRows", "getVisibleCells"));
1609
+ },
1610
+ createTable: (e) => {
1611
+ const o = (t, n) => S(() => [n(), n().filter((r) => r.getIsVisible()).map((r) => r.id).join("_")], (r) => r.filter((l) => l.getIsVisible == null ? void 0 : l.getIsVisible()), R(e.options, "debugColumns", t));
1612
+ e.getVisibleFlatColumns = o("getVisibleFlatColumns", () => e.getAllFlatColumns()), e.getVisibleLeafColumns = o("getVisibleLeafColumns", () => e.getAllLeafColumns()), e.getLeftVisibleLeafColumns = o("getLeftVisibleLeafColumns", () => e.getLeftLeafColumns()), e.getRightVisibleLeafColumns = o("getRightVisibleLeafColumns", () => e.getRightLeafColumns()), e.getCenterVisibleLeafColumns = o("getCenterVisibleLeafColumns", () => e.getCenterLeafColumns()), e.setColumnVisibility = (t) => e.options.onColumnVisibilityChange == null ? void 0 : e.options.onColumnVisibilityChange(t), e.resetColumnVisibility = (t) => {
1613
+ var n;
1614
+ e.setColumnVisibility(t ? {} : (n = e.initialState.columnVisibility) != null ? n : {});
1615
+ }, e.toggleAllColumnsVisible = (t) => {
1616
+ var n;
1617
+ t = (n = t) != null ? n : !e.getIsAllColumnsVisible(), e.setColumnVisibility(e.getAllLeafColumns().reduce((r, l) => ({
1618
+ ...r,
1619
+ [l.id]: t || !(l.getCanHide != null && l.getCanHide())
1620
+ }), {}));
1621
+ }, e.getIsAllColumnsVisible = () => !e.getAllLeafColumns().some((t) => !(t.getIsVisible != null && t.getIsVisible())), e.getIsSomeColumnsVisible = () => e.getAllLeafColumns().some((t) => t.getIsVisible == null ? void 0 : t.getIsVisible()), e.getToggleAllColumnsVisibilityHandler = () => (t) => {
1622
+ var n;
1623
+ e.toggleAllColumnsVisible((n = t.target) == null ? void 0 : n.checked);
1624
+ };
1625
+ }
1626
+ };
1627
+ function ue(e, o) {
1628
+ return o ? o === "center" ? e.getCenterVisibleLeafColumns() : o === "left" ? e.getLeftVisibleLeafColumns() : e.getRightVisibleLeafColumns() : e.getVisibleLeafColumns();
1629
+ }
1630
+ const xn = {
1631
+ createTable: (e) => {
1632
+ e._getGlobalFacetedRowModel = e.options.getFacetedRowModel && e.options.getFacetedRowModel(e, "__global__"), e.getGlobalFacetedRowModel = () => e.options.manualFiltering || !e._getGlobalFacetedRowModel ? e.getPreFilteredRowModel() : e._getGlobalFacetedRowModel(), e._getGlobalFacetedUniqueValues = e.options.getFacetedUniqueValues && e.options.getFacetedUniqueValues(e, "__global__"), e.getGlobalFacetedUniqueValues = () => e._getGlobalFacetedUniqueValues ? e._getGlobalFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getGlobalFacetedMinMaxValues = e.options.getFacetedMinMaxValues && e.options.getFacetedMinMaxValues(e, "__global__"), e.getGlobalFacetedMinMaxValues = () => {
1633
+ if (e._getGlobalFacetedMinMaxValues)
1634
+ return e._getGlobalFacetedMinMaxValues();
1635
+ };
1636
+ }
1637
+ }, _n = {
1638
+ getInitialState: (e) => ({
1639
+ globalFilter: void 0,
1640
+ ...e
1641
+ }),
1642
+ getDefaultOptions: (e) => ({
1643
+ onGlobalFilterChange: G("globalFilter", e),
1644
+ globalFilterFn: "auto",
1645
+ getColumnCanGlobalFilter: (o) => {
1646
+ var t;
1647
+ const n = (t = e.getCoreRowModel().flatRows[0]) == null || (t = t._getAllCellsByColumnId()[o.id]) == null ? void 0 : t.getValue();
1648
+ return typeof n == "string" || typeof n == "number";
1649
+ }
1650
+ }),
1651
+ createColumn: (e, o) => {
1652
+ e.getCanGlobalFilter = () => {
1653
+ var t, n, r, l;
1654
+ return ((t = e.columnDef.enableGlobalFilter) != null ? t : !0) && ((n = o.options.enableGlobalFilter) != null ? n : !0) && ((r = o.options.enableFilters) != null ? r : !0) && ((l = o.options.getColumnCanGlobalFilter == null ? void 0 : o.options.getColumnCanGlobalFilter(e)) != null ? l : !0) && !!e.accessorFn;
1655
+ };
1656
+ },
1657
+ createTable: (e) => {
1658
+ e.getGlobalAutoFilterFn = () => U.includesString, e.getGlobalFilterFn = () => {
1659
+ var o, t;
1660
+ const {
1661
+ globalFilterFn: n
1662
+ } = e.options;
1663
+ return ve(n) ? n : n === "auto" ? e.getGlobalAutoFilterFn() : (o = (t = e.options.filterFns) == null ? void 0 : t[n]) != null ? o : U[n];
1664
+ }, e.setGlobalFilter = (o) => {
1665
+ e.options.onGlobalFilterChange == null || e.options.onGlobalFilterChange(o);
1666
+ }, e.resetGlobalFilter = (o) => {
1667
+ e.setGlobalFilter(o ? void 0 : e.initialState.globalFilter);
1668
+ };
1669
+ }
1670
+ }, Fn = {
1671
+ getInitialState: (e) => ({
1672
+ expanded: {},
1673
+ ...e
1674
+ }),
1675
+ getDefaultOptions: (e) => ({
1676
+ onExpandedChange: G("expanded", e),
1677
+ paginateExpandedRows: !0
1678
+ }),
1679
+ createTable: (e) => {
1680
+ let o = !1, t = !1;
1681
+ e._autoResetExpanded = () => {
1682
+ var n, r;
1683
+ if (!o) {
1684
+ e._queue(() => {
1685
+ o = !0;
1686
+ });
1687
+ return;
1688
+ }
1689
+ if ((n = (r = e.options.autoResetAll) != null ? r : e.options.autoResetExpanded) != null ? n : !e.options.manualExpanding) {
1690
+ if (t) return;
1691
+ t = !0, e._queue(() => {
1692
+ e.resetExpanded(), t = !1;
1693
+ });
1694
+ }
1695
+ }, e.setExpanded = (n) => e.options.onExpandedChange == null ? void 0 : e.options.onExpandedChange(n), e.toggleAllRowsExpanded = (n) => {
1696
+ n ?? !e.getIsAllRowsExpanded() ? e.setExpanded(!0) : e.setExpanded({});
1697
+ }, e.resetExpanded = (n) => {
1698
+ var r, l;
1699
+ e.setExpanded(n ? {} : (r = (l = e.initialState) == null ? void 0 : l.expanded) != null ? r : {});
1700
+ }, e.getCanSomeRowsExpand = () => e.getPrePaginationRowModel().flatRows.some((n) => n.getCanExpand()), e.getToggleAllRowsExpandedHandler = () => (n) => {
1701
+ n.persist == null || n.persist(), e.toggleAllRowsExpanded();
1702
+ }, e.getIsSomeRowsExpanded = () => {
1703
+ const n = e.getState().expanded;
1704
+ return n === !0 || Object.values(n).some(Boolean);
1705
+ }, e.getIsAllRowsExpanded = () => {
1706
+ const n = e.getState().expanded;
1707
+ return typeof n == "boolean" ? n === !0 : !(!Object.keys(n).length || e.getRowModel().flatRows.some((r) => !r.getIsExpanded()));
1708
+ }, e.getExpandedDepth = () => {
1709
+ let n = 0;
1710
+ return (e.getState().expanded === !0 ? Object.keys(e.getRowModel().rowsById) : Object.keys(e.getState().expanded)).forEach((l) => {
1711
+ const s = l.split(".");
1712
+ n = Math.max(n, s.length);
1713
+ }), n;
1714
+ }, e.getPreExpandedRowModel = () => e.getSortedRowModel(), e.getExpandedRowModel = () => (!e._getExpandedRowModel && e.options.getExpandedRowModel && (e._getExpandedRowModel = e.options.getExpandedRowModel(e)), e.options.manualExpanding || !e._getExpandedRowModel ? e.getPreExpandedRowModel() : e._getExpandedRowModel());
1715
+ },
1716
+ createRow: (e, o) => {
1717
+ e.toggleExpanded = (t) => {
1718
+ o.setExpanded((n) => {
1719
+ var r;
1720
+ const l = n === !0 ? !0 : !!(n != null && n[e.id]);
1721
+ let s = {};
1722
+ if (n === !0 ? Object.keys(o.getRowModel().rowsById).forEach((i) => {
1723
+ s[i] = !0;
1724
+ }) : s = n, t = (r = t) != null ? r : !l, !l && t)
1725
+ return {
1726
+ ...s,
1727
+ [e.id]: !0
1728
+ };
1729
+ if (l && !t) {
1730
+ const {
1731
+ [e.id]: i,
1732
+ ...u
1733
+ } = s;
1734
+ return u;
1735
+ }
1736
+ return n;
1737
+ });
1738
+ }, e.getIsExpanded = () => {
1739
+ var t;
1740
+ const n = o.getState().expanded;
1741
+ return !!((t = o.options.getIsRowExpanded == null ? void 0 : o.options.getIsRowExpanded(e)) != null ? t : n === !0 || n != null && n[e.id]);
1742
+ }, e.getCanExpand = () => {
1743
+ var t, n, r;
1744
+ return (t = o.options.getRowCanExpand == null ? void 0 : o.options.getRowCanExpand(e)) != null ? t : ((n = o.options.enableExpanding) != null ? n : !0) && !!((r = e.subRows) != null && r.length);
1745
+ }, e.getIsAllParentsExpanded = () => {
1746
+ let t = !0, n = e;
1747
+ for (; t && n.parentId; )
1748
+ n = o.getRow(n.parentId, !0), t = n.getIsExpanded();
1749
+ return t;
1750
+ }, e.getToggleExpandedHandler = () => {
1751
+ const t = e.getCanExpand();
1752
+ return () => {
1753
+ t && e.toggleExpanded();
1754
+ };
1755
+ };
1756
+ }
1757
+ }, Ve = 0, Pe = 10, _e = () => ({
1758
+ pageIndex: Ve,
1759
+ pageSize: Pe
1760
+ }), In = {
1761
+ getInitialState: (e) => ({
1762
+ ...e,
1763
+ pagination: {
1764
+ ..._e(),
1765
+ ...e == null ? void 0 : e.pagination
1766
+ }
1767
+ }),
1768
+ getDefaultOptions: (e) => ({
1769
+ onPaginationChange: G("pagination", e)
1770
+ }),
1771
+ createTable: (e) => {
1772
+ let o = !1, t = !1;
1773
+ e._autoResetPageIndex = () => {
1774
+ var n, r;
1775
+ if (!o) {
1776
+ e._queue(() => {
1777
+ o = !0;
1778
+ });
1779
+ return;
1780
+ }
1781
+ if ((n = (r = e.options.autoResetAll) != null ? r : e.options.autoResetPageIndex) != null ? n : !e.options.manualPagination) {
1782
+ if (t) return;
1783
+ t = !0, e._queue(() => {
1784
+ e.resetPageIndex(), t = !1;
1785
+ });
1786
+ }
1787
+ }, e.setPagination = (n) => {
1788
+ const r = (l) => Y(n, l);
1789
+ return e.options.onPaginationChange == null ? void 0 : e.options.onPaginationChange(r);
1790
+ }, e.resetPagination = (n) => {
1791
+ var r;
1792
+ e.setPagination(n ? _e() : (r = e.initialState.pagination) != null ? r : _e());
1793
+ }, e.setPageIndex = (n) => {
1794
+ e.setPagination((r) => {
1795
+ let l = Y(n, r.pageIndex);
1796
+ const s = typeof e.options.pageCount > "u" || e.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : e.options.pageCount - 1;
1797
+ return l = Math.max(0, Math.min(l, s)), {
1798
+ ...r,
1799
+ pageIndex: l
1800
+ };
1801
+ });
1802
+ }, e.resetPageIndex = (n) => {
1803
+ var r, l;
1804
+ e.setPageIndex(n ? Ve : (r = (l = e.initialState) == null || (l = l.pagination) == null ? void 0 : l.pageIndex) != null ? r : Ve);
1805
+ }, e.resetPageSize = (n) => {
1806
+ var r, l;
1807
+ e.setPageSize(n ? Pe : (r = (l = e.initialState) == null || (l = l.pagination) == null ? void 0 : l.pageSize) != null ? r : Pe);
1808
+ }, e.setPageSize = (n) => {
1809
+ e.setPagination((r) => {
1810
+ const l = Math.max(1, Y(n, r.pageSize)), s = r.pageSize * r.pageIndex, i = Math.floor(s / l);
1811
+ return {
1812
+ ...r,
1813
+ pageIndex: i,
1814
+ pageSize: l
1815
+ };
1816
+ });
1817
+ }, e.setPageCount = (n) => e.setPagination((r) => {
1818
+ var l;
1819
+ let s = Y(n, (l = e.options.pageCount) != null ? l : -1);
1820
+ return typeof s == "number" && (s = Math.max(-1, s)), {
1821
+ ...r,
1822
+ pageCount: s
1823
+ };
1824
+ }), e.getPageOptions = S(() => [e.getPageCount()], (n) => {
1825
+ let r = [];
1826
+ return n && n > 0 && (r = [...new Array(n)].fill(null).map((l, s) => s)), r;
1827
+ }, R(e.options, "debugTable", "getPageOptions")), e.getCanPreviousPage = () => e.getState().pagination.pageIndex > 0, e.getCanNextPage = () => {
1828
+ const {
1829
+ pageIndex: n
1830
+ } = e.getState().pagination, r = e.getPageCount();
1831
+ return r === -1 ? !0 : r === 0 ? !1 : n < r - 1;
1832
+ }, e.previousPage = () => e.setPageIndex((n) => n - 1), e.nextPage = () => e.setPageIndex((n) => n + 1), e.firstPage = () => e.setPageIndex(0), e.lastPage = () => e.setPageIndex(e.getPageCount() - 1), e.getPrePaginationRowModel = () => e.getExpandedRowModel(), e.getPaginationRowModel = () => (!e._getPaginationRowModel && e.options.getPaginationRowModel && (e._getPaginationRowModel = e.options.getPaginationRowModel(e)), e.options.manualPagination || !e._getPaginationRowModel ? e.getPrePaginationRowModel() : e._getPaginationRowModel()), e.getPageCount = () => {
1833
+ var n;
1834
+ return (n = e.options.pageCount) != null ? n : Math.ceil(e.getRowCount() / e.getState().pagination.pageSize);
1835
+ }, e.getRowCount = () => {
1836
+ var n;
1837
+ return (n = e.options.rowCount) != null ? n : e.getPrePaginationRowModel().rows.length;
1838
+ };
1839
+ }
1840
+ }, Fe = () => ({
1841
+ top: [],
1842
+ bottom: []
1843
+ }), $n = {
1844
+ getInitialState: (e) => ({
1845
+ rowPinning: Fe(),
1846
+ ...e
1847
+ }),
1848
+ getDefaultOptions: (e) => ({
1849
+ onRowPinningChange: G("rowPinning", e)
1850
+ }),
1851
+ createRow: (e, o) => {
1852
+ e.pin = (t, n, r) => {
1853
+ const l = n ? e.getLeafRows().map((u) => {
1854
+ let {
1855
+ id: f
1856
+ } = u;
1857
+ return f;
1858
+ }) : [], s = r ? e.getParentRows().map((u) => {
1859
+ let {
1860
+ id: f
1861
+ } = u;
1862
+ return f;
1863
+ }) : [], i = /* @__PURE__ */ new Set([...s, e.id, ...l]);
1864
+ o.setRowPinning((u) => {
1865
+ var f, p;
1866
+ if (t === "bottom") {
1867
+ var g, c;
1868
+ return {
1869
+ top: ((g = u == null ? void 0 : u.top) != null ? g : []).filter((v) => !(i != null && i.has(v))),
1870
+ bottom: [...((c = u == null ? void 0 : u.bottom) != null ? c : []).filter((v) => !(i != null && i.has(v))), ...Array.from(i)]
1871
+ };
1872
+ }
1873
+ if (t === "top") {
1874
+ var a, m;
1875
+ return {
1876
+ top: [...((a = u == null ? void 0 : u.top) != null ? a : []).filter((v) => !(i != null && i.has(v))), ...Array.from(i)],
1877
+ bottom: ((m = u == null ? void 0 : u.bottom) != null ? m : []).filter((v) => !(i != null && i.has(v)))
1878
+ };
1879
+ }
1880
+ return {
1881
+ top: ((f = u == null ? void 0 : u.top) != null ? f : []).filter((v) => !(i != null && i.has(v))),
1882
+ bottom: ((p = u == null ? void 0 : u.bottom) != null ? p : []).filter((v) => !(i != null && i.has(v)))
1883
+ };
1884
+ });
1885
+ }, e.getCanPin = () => {
1886
+ var t;
1887
+ const {
1888
+ enableRowPinning: n,
1889
+ enablePinning: r
1890
+ } = o.options;
1891
+ return typeof n == "function" ? n(e) : (t = n ?? r) != null ? t : !0;
1892
+ }, e.getIsPinned = () => {
1893
+ const t = [e.id], {
1894
+ top: n,
1895
+ bottom: r
1896
+ } = o.getState().rowPinning, l = t.some((i) => n == null ? void 0 : n.includes(i)), s = t.some((i) => r == null ? void 0 : r.includes(i));
1897
+ return l ? "top" : s ? "bottom" : !1;
1898
+ }, e.getPinnedIndex = () => {
1899
+ var t, n;
1900
+ const r = e.getIsPinned();
1901
+ if (!r) return -1;
1902
+ const l = (t = r === "top" ? o.getTopRows() : o.getBottomRows()) == null ? void 0 : t.map((s) => {
1903
+ let {
1904
+ id: i
1905
+ } = s;
1906
+ return i;
1907
+ });
1908
+ return (n = l == null ? void 0 : l.indexOf(e.id)) != null ? n : -1;
1909
+ };
1910
+ },
1911
+ createTable: (e) => {
1912
+ e.setRowPinning = (o) => e.options.onRowPinningChange == null ? void 0 : e.options.onRowPinningChange(o), e.resetRowPinning = (o) => {
1913
+ var t, n;
1914
+ return e.setRowPinning(o ? Fe() : (t = (n = e.initialState) == null ? void 0 : n.rowPinning) != null ? t : Fe());
1915
+ }, e.getIsSomeRowsPinned = (o) => {
1916
+ var t;
1917
+ const n = e.getState().rowPinning;
1918
+ if (!o) {
1919
+ var r, l;
1920
+ return !!((r = n.top) != null && r.length || (l = n.bottom) != null && l.length);
1921
+ }
1922
+ return !!((t = n[o]) != null && t.length);
1923
+ }, e._getPinnedRows = (o, t, n) => {
1924
+ var r;
1925
+ return ((r = e.options.keepPinnedRows) == null || r ? (
1926
+ //get all rows that are pinned even if they would not be otherwise visible
1927
+ //account for expanded parent rows, but not pagination or filtering
1928
+ (t ?? []).map((s) => {
1929
+ const i = e.getRow(s, !0);
1930
+ return i.getIsAllParentsExpanded() ? i : null;
1931
+ })
1932
+ ) : (
1933
+ //else get only visible rows that are pinned
1934
+ (t ?? []).map((s) => o.find((i) => i.id === s))
1935
+ )).filter(Boolean).map((s) => ({
1936
+ ...s,
1937
+ position: n
1938
+ }));
1939
+ }, e.getTopRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.top], (o, t) => e._getPinnedRows(o, t, "top"), R(e.options, "debugRows", "getTopRows")), e.getBottomRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.bottom], (o, t) => e._getPinnedRows(o, t, "bottom"), R(e.options, "debugRows", "getBottomRows")), e.getCenterRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.top, e.getState().rowPinning.bottom], (o, t, n) => {
1940
+ const r = /* @__PURE__ */ new Set([...t ?? [], ...n ?? []]);
1941
+ return o.filter((l) => !r.has(l.id));
1942
+ }, R(e.options, "debugRows", "getCenterRows"));
1943
+ }
1944
+ }, Nn = {
1945
+ getInitialState: (e) => ({
1946
+ rowSelection: {},
1947
+ ...e
1948
+ }),
1949
+ getDefaultOptions: (e) => ({
1950
+ onRowSelectionChange: G("rowSelection", e),
1951
+ enableRowSelection: !0,
1952
+ enableMultiRowSelection: !0,
1953
+ enableSubRowSelection: !0
1954
+ // enableGroupingRowSelection: false,
1955
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1956
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1957
+ }),
1958
+ createTable: (e) => {
1959
+ e.setRowSelection = (o) => e.options.onRowSelectionChange == null ? void 0 : e.options.onRowSelectionChange(o), e.resetRowSelection = (o) => {
1960
+ var t;
1961
+ return e.setRowSelection(o ? {} : (t = e.initialState.rowSelection) != null ? t : {});
1962
+ }, e.toggleAllRowsSelected = (o) => {
1963
+ e.setRowSelection((t) => {
1964
+ o = typeof o < "u" ? o : !e.getIsAllRowsSelected();
1965
+ const n = {
1966
+ ...t
1967
+ }, r = e.getPreGroupedRowModel().flatRows;
1968
+ return o ? r.forEach((l) => {
1969
+ l.getCanSelect() && (n[l.id] = !0);
1970
+ }) : r.forEach((l) => {
1971
+ delete n[l.id];
1972
+ }), n;
1973
+ });
1974
+ }, e.toggleAllPageRowsSelected = (o) => e.setRowSelection((t) => {
1975
+ const n = typeof o < "u" ? o : !e.getIsAllPageRowsSelected(), r = {
1976
+ ...t
1977
+ };
1978
+ return e.getRowModel().rows.forEach((l) => {
1979
+ ke(r, l.id, n, !0, e);
1980
+ }), r;
1981
+ }), e.getPreSelectedRowModel = () => e.getCoreRowModel(), e.getSelectedRowModel = S(() => [e.getState().rowSelection, e.getCoreRowModel()], (o, t) => Object.keys(o).length ? Ie(e, t) : {
1982
+ rows: [],
1983
+ flatRows: [],
1984
+ rowsById: {}
1985
+ }, R(e.options, "debugTable", "getSelectedRowModel")), e.getFilteredSelectedRowModel = S(() => [e.getState().rowSelection, e.getFilteredRowModel()], (o, t) => Object.keys(o).length ? Ie(e, t) : {
1986
+ rows: [],
1987
+ flatRows: [],
1988
+ rowsById: {}
1989
+ }, R(e.options, "debugTable", "getFilteredSelectedRowModel")), e.getGroupedSelectedRowModel = S(() => [e.getState().rowSelection, e.getSortedRowModel()], (o, t) => Object.keys(o).length ? Ie(e, t) : {
1990
+ rows: [],
1991
+ flatRows: [],
1992
+ rowsById: {}
1993
+ }, R(e.options, "debugTable", "getGroupedSelectedRowModel")), e.getIsAllRowsSelected = () => {
1994
+ const o = e.getFilteredRowModel().flatRows, {
1995
+ rowSelection: t
1996
+ } = e.getState();
1997
+ let n = !!(o.length && Object.keys(t).length);
1998
+ return n && o.some((r) => r.getCanSelect() && !t[r.id]) && (n = !1), n;
1999
+ }, e.getIsAllPageRowsSelected = () => {
2000
+ const o = e.getPaginationRowModel().flatRows.filter((r) => r.getCanSelect()), {
2001
+ rowSelection: t
2002
+ } = e.getState();
2003
+ let n = !!o.length;
2004
+ return n && o.some((r) => !t[r.id]) && (n = !1), n;
2005
+ }, e.getIsSomeRowsSelected = () => {
2006
+ var o;
2007
+ const t = Object.keys((o = e.getState().rowSelection) != null ? o : {}).length;
2008
+ return t > 0 && t < e.getFilteredRowModel().flatRows.length;
2009
+ }, e.getIsSomePageRowsSelected = () => {
2010
+ const o = e.getPaginationRowModel().flatRows;
2011
+ return e.getIsAllPageRowsSelected() ? !1 : o.filter((t) => t.getCanSelect()).some((t) => t.getIsSelected() || t.getIsSomeSelected());
2012
+ }, e.getToggleAllRowsSelectedHandler = () => (o) => {
2013
+ e.toggleAllRowsSelected(o.target.checked);
2014
+ }, e.getToggleAllPageRowsSelectedHandler = () => (o) => {
2015
+ e.toggleAllPageRowsSelected(o.target.checked);
2016
+ };
2017
+ },
2018
+ createRow: (e, o) => {
2019
+ e.toggleSelected = (t, n) => {
2020
+ const r = e.getIsSelected();
2021
+ o.setRowSelection((l) => {
2022
+ var s;
2023
+ if (t = typeof t < "u" ? t : !r, e.getCanSelect() && r === t)
2024
+ return l;
2025
+ const i = {
2026
+ ...l
2027
+ };
2028
+ return ke(i, e.id, t, (s = n == null ? void 0 : n.selectChildren) != null ? s : !0, o), i;
2029
+ });
2030
+ }, e.getIsSelected = () => {
2031
+ const {
2032
+ rowSelection: t
2033
+ } = o.getState();
2034
+ return Ge(e, t);
2035
+ }, e.getIsSomeSelected = () => {
2036
+ const {
2037
+ rowSelection: t
2038
+ } = o.getState();
2039
+ return be(e, t) === "some";
2040
+ }, e.getIsAllSubRowsSelected = () => {
2041
+ const {
2042
+ rowSelection: t
2043
+ } = o.getState();
2044
+ return be(e, t) === "all";
2045
+ }, e.getCanSelect = () => {
2046
+ var t;
2047
+ return typeof o.options.enableRowSelection == "function" ? o.options.enableRowSelection(e) : (t = o.options.enableRowSelection) != null ? t : !0;
2048
+ }, e.getCanSelectSubRows = () => {
2049
+ var t;
2050
+ return typeof o.options.enableSubRowSelection == "function" ? o.options.enableSubRowSelection(e) : (t = o.options.enableSubRowSelection) != null ? t : !0;
2051
+ }, e.getCanMultiSelect = () => {
2052
+ var t;
2053
+ return typeof o.options.enableMultiRowSelection == "function" ? o.options.enableMultiRowSelection(e) : (t = o.options.enableMultiRowSelection) != null ? t : !0;
2054
+ }, e.getToggleSelectedHandler = () => {
2055
+ const t = e.getCanSelect();
2056
+ return (n) => {
2057
+ var r;
2058
+ t && e.toggleSelected((r = n.target) == null ? void 0 : r.checked);
2059
+ };
2060
+ };
2061
+ }
2062
+ }, ke = (e, o, t, n, r) => {
2063
+ var l;
2064
+ const s = r.getRow(o, !0);
2065
+ t ? (s.getCanMultiSelect() || Object.keys(e).forEach((i) => delete e[i]), s.getCanSelect() && (e[o] = !0)) : delete e[o], n && (l = s.subRows) != null && l.length && s.getCanSelectSubRows() && s.subRows.forEach((i) => ke(e, i.id, t, n, r));
2066
+ };
2067
+ function Ie(e, o) {
2068
+ const t = e.getState().rowSelection, n = [], r = {}, l = function(s, i) {
2069
+ return s.map((u) => {
2070
+ var f;
2071
+ const p = Ge(u, t);
2072
+ if (p && (n.push(u), r[u.id] = u), (f = u.subRows) != null && f.length && (u = {
2073
+ ...u,
2074
+ subRows: l(u.subRows)
2075
+ }), p)
2076
+ return u;
2077
+ }).filter(Boolean);
2078
+ };
2079
+ return {
2080
+ rows: l(o.rows),
2081
+ flatRows: n,
2082
+ rowsById: r
2083
+ };
2084
+ }
2085
+ function Ge(e, o) {
2086
+ var t;
2087
+ return (t = o[e.id]) != null ? t : !1;
2088
+ }
2089
+ function be(e, o, t) {
2090
+ var n;
2091
+ if (!((n = e.subRows) != null && n.length)) return !1;
2092
+ let r = !0, l = !1;
2093
+ return e.subRows.forEach((s) => {
2094
+ if (!(l && !r) && (s.getCanSelect() && (Ge(s, o) ? l = !0 : r = !1), s.subRows && s.subRows.length)) {
2095
+ const i = be(s, o);
2096
+ i === "all" ? l = !0 : (i === "some" && (l = !0), r = !1);
2097
+ }
2098
+ }), r ? "all" : l ? "some" : !1;
2099
+ }
2100
+ const Ee = /([0-9]+)/gm, Mn = (e, o, t) => ct(J(e.getValue(t)).toLowerCase(), J(o.getValue(t)).toLowerCase()), Vn = (e, o, t) => ct(J(e.getValue(t)), J(o.getValue(t))), Pn = (e, o, t) => Oe(J(e.getValue(t)).toLowerCase(), J(o.getValue(t)).toLowerCase()), kn = (e, o, t) => Oe(J(e.getValue(t)), J(o.getValue(t))), bn = (e, o, t) => {
2101
+ const n = e.getValue(t), r = o.getValue(t);
2102
+ return n > r ? 1 : n < r ? -1 : 0;
2103
+ }, En = (e, o, t) => Oe(e.getValue(t), o.getValue(t));
2104
+ function Oe(e, o) {
2105
+ return e === o ? 0 : e > o ? 1 : -1;
2106
+ }
2107
+ function J(e) {
2108
+ return typeof e == "number" ? isNaN(e) || e === 1 / 0 || e === -1 / 0 ? "" : String(e) : typeof e == "string" ? e : "";
2109
+ }
2110
+ function ct(e, o) {
2111
+ const t = e.split(Ee).filter(Boolean), n = o.split(Ee).filter(Boolean);
2112
+ for (; t.length && n.length; ) {
2113
+ const r = t.shift(), l = n.shift(), s = parseInt(r, 10), i = parseInt(l, 10), u = [s, i].sort();
2114
+ if (isNaN(u[0])) {
2115
+ if (r > l)
2116
+ return 1;
2117
+ if (l > r)
2118
+ return -1;
2119
+ continue;
2120
+ }
2121
+ if (isNaN(u[1]))
2122
+ return isNaN(s) ? -1 : 1;
2123
+ if (s > i)
2124
+ return 1;
2125
+ if (i > s)
2126
+ return -1;
2127
+ }
2128
+ return t.length - n.length;
2129
+ }
2130
+ const ae = {
2131
+ alphanumeric: Mn,
2132
+ alphanumericCaseSensitive: Vn,
2133
+ text: Pn,
2134
+ textCaseSensitive: kn,
2135
+ datetime: bn,
2136
+ basic: En
2137
+ }, Dn = {
2138
+ getInitialState: (e) => ({
2139
+ sorting: [],
2140
+ ...e
2141
+ }),
2142
+ getDefaultColumnDef: () => ({
2143
+ sortingFn: "auto",
2144
+ sortUndefined: 1
2145
+ }),
2146
+ getDefaultOptions: (e) => ({
2147
+ onSortingChange: G("sorting", e),
2148
+ isMultiSortEvent: (o) => o.shiftKey
2149
+ }),
2150
+ createColumn: (e, o) => {
2151
+ e.getAutoSortingFn = () => {
2152
+ const t = o.getFilteredRowModel().flatRows.slice(10);
2153
+ let n = !1;
2154
+ for (const r of t) {
2155
+ const l = r == null ? void 0 : r.getValue(e.id);
2156
+ if (Object.prototype.toString.call(l) === "[object Date]")
2157
+ return ae.datetime;
2158
+ if (typeof l == "string" && (n = !0, l.split(Ee).length > 1))
2159
+ return ae.alphanumeric;
2160
+ }
2161
+ return n ? ae.text : ae.basic;
2162
+ }, e.getAutoSortDir = () => {
2163
+ const t = o.getFilteredRowModel().flatRows[0];
2164
+ return typeof (t == null ? void 0 : t.getValue(e.id)) == "string" ? "asc" : "desc";
2165
+ }, e.getSortingFn = () => {
2166
+ var t, n;
2167
+ if (!e)
2168
+ throw new Error();
2169
+ return ve(e.columnDef.sortingFn) ? e.columnDef.sortingFn : e.columnDef.sortingFn === "auto" ? e.getAutoSortingFn() : (t = (n = o.options.sortingFns) == null ? void 0 : n[e.columnDef.sortingFn]) != null ? t : ae[e.columnDef.sortingFn];
2170
+ }, e.toggleSorting = (t, n) => {
2171
+ const r = e.getNextSortingOrder(), l = typeof t < "u" && t !== null;
2172
+ o.setSorting((s) => {
2173
+ const i = s == null ? void 0 : s.find((a) => a.id === e.id), u = s == null ? void 0 : s.findIndex((a) => a.id === e.id);
2174
+ let f = [], p, g = l ? t : r === "desc";
2175
+ if (s != null && s.length && e.getCanMultiSort() && n ? i ? p = "toggle" : p = "add" : s != null && s.length && u !== s.length - 1 ? p = "replace" : i ? p = "toggle" : p = "replace", p === "toggle" && (l || r || (p = "remove")), p === "add") {
2176
+ var c;
2177
+ f = [...s, {
2178
+ id: e.id,
2179
+ desc: g
2180
+ }], f.splice(0, f.length - ((c = o.options.maxMultiSortColCount) != null ? c : Number.MAX_SAFE_INTEGER));
2181
+ } else p === "toggle" ? f = s.map((a) => a.id === e.id ? {
2182
+ ...a,
2183
+ desc: g
2184
+ } : a) : p === "remove" ? f = s.filter((a) => a.id !== e.id) : f = [{
2185
+ id: e.id,
2186
+ desc: g
2187
+ }];
2188
+ return f;
2189
+ });
2190
+ }, e.getFirstSortDir = () => {
2191
+ var t, n;
2192
+ return ((t = (n = e.columnDef.sortDescFirst) != null ? n : o.options.sortDescFirst) != null ? t : e.getAutoSortDir() === "desc") ? "desc" : "asc";
2193
+ }, e.getNextSortingOrder = (t) => {
2194
+ var n, r;
2195
+ const l = e.getFirstSortDir(), s = e.getIsSorted();
2196
+ return s ? s !== l && ((n = o.options.enableSortingRemoval) == null || n) && // If enableSortRemove, enable in general
2197
+ (!(t && (r = o.options.enableMultiRemove) != null) || r) ? !1 : s === "desc" ? "asc" : "desc" : l;
2198
+ }, e.getCanSort = () => {
2199
+ var t, n;
2200
+ return ((t = e.columnDef.enableSorting) != null ? t : !0) && ((n = o.options.enableSorting) != null ? n : !0) && !!e.accessorFn;
2201
+ }, e.getCanMultiSort = () => {
2202
+ var t, n;
2203
+ return (t = (n = e.columnDef.enableMultiSort) != null ? n : o.options.enableMultiSort) != null ? t : !!e.accessorFn;
2204
+ }, e.getIsSorted = () => {
2205
+ var t;
2206
+ const n = (t = o.getState().sorting) == null ? void 0 : t.find((r) => r.id === e.id);
2207
+ return n ? n.desc ? "desc" : "asc" : !1;
2208
+ }, e.getSortIndex = () => {
2209
+ var t, n;
2210
+ return (t = (n = o.getState().sorting) == null ? void 0 : n.findIndex((r) => r.id === e.id)) != null ? t : -1;
2211
+ }, e.clearSorting = () => {
2212
+ o.setSorting((t) => t != null && t.length ? t.filter((n) => n.id !== e.id) : []);
2213
+ }, e.getToggleSortingHandler = () => {
2214
+ const t = e.getCanSort();
2215
+ return (n) => {
2216
+ t && (n.persist == null || n.persist(), e.toggleSorting == null || e.toggleSorting(void 0, e.getCanMultiSort() ? o.options.isMultiSortEvent == null ? void 0 : o.options.isMultiSortEvent(n) : !1));
2217
+ };
2218
+ };
2219
+ },
2220
+ createTable: (e) => {
2221
+ e.setSorting = (o) => e.options.onSortingChange == null ? void 0 : e.options.onSortingChange(o), e.resetSorting = (o) => {
2222
+ var t, n;
2223
+ e.setSorting(o ? [] : (t = (n = e.initialState) == null ? void 0 : n.sorting) != null ? t : []);
2224
+ }, e.getPreSortedRowModel = () => e.getGroupedRowModel(), e.getSortedRowModel = () => (!e._getSortedRowModel && e.options.getSortedRowModel && (e._getSortedRowModel = e.options.getSortedRowModel(e)), e.options.manualSorting || !e._getSortedRowModel ? e.getPreSortedRowModel() : e._getSortedRowModel());
2225
+ }
2226
+ }, Ln = [
2227
+ nn,
2228
+ Rn,
2229
+ vn,
2230
+ wn,
2231
+ on,
2232
+ rn,
2233
+ xn,
2234
+ //depends on ColumnFaceting
2235
+ _n,
2236
+ //depends on ColumnFiltering
2237
+ Dn,
2238
+ mn,
2239
+ //depends on RowSorting
2240
+ Fn,
2241
+ In,
2242
+ $n,
2243
+ Nn,
2244
+ yn
2245
+ ];
2246
+ function zn(e) {
2247
+ var o, t;
2248
+ process.env.NODE_ENV !== "production" && (e.debugAll || e.debugTable) && console.info("Creating Table Instance...");
2249
+ const n = [...Ln, ...(o = e._features) != null ? o : []];
2250
+ let r = {
2251
+ _features: n
2252
+ };
2253
+ const l = r._features.reduce((c, a) => Object.assign(c, a.getDefaultOptions == null ? void 0 : a.getDefaultOptions(r)), {}), s = (c) => r.options.mergeOptions ? r.options.mergeOptions(l, c) : {
2254
+ ...l,
2255
+ ...c
2256
+ };
2257
+ let u = {
2258
+ ...{},
2259
+ ...(t = e.initialState) != null ? t : {}
2260
+ };
2261
+ r._features.forEach((c) => {
2262
+ var a;
2263
+ u = (a = c.getInitialState == null ? void 0 : c.getInitialState(u)) != null ? a : u;
2264
+ });
2265
+ const f = [];
2266
+ let p = !1;
2267
+ const g = {
2268
+ _features: n,
2269
+ options: {
2270
+ ...l,
2271
+ ...e
2272
+ },
2273
+ initialState: u,
2274
+ _queue: (c) => {
2275
+ f.push(c), p || (p = !0, Promise.resolve().then(() => {
2276
+ for (; f.length; )
2277
+ f.shift()();
2278
+ p = !1;
2279
+ }).catch((a) => setTimeout(() => {
2280
+ throw a;
2281
+ })));
2282
+ },
2283
+ reset: () => {
2284
+ r.setState(r.initialState);
2285
+ },
2286
+ setOptions: (c) => {
2287
+ const a = Y(c, r.options);
2288
+ r.options = s(a);
2289
+ },
2290
+ getState: () => r.options.state,
2291
+ setState: (c) => {
2292
+ r.options.onStateChange == null || r.options.onStateChange(c);
2293
+ },
2294
+ _getRowId: (c, a, m) => {
2295
+ var v;
2296
+ return (v = r.options.getRowId == null ? void 0 : r.options.getRowId(c, a, m)) != null ? v : `${m ? [m.id, a].join(".") : a}`;
2297
+ },
2298
+ getCoreRowModel: () => (r._getCoreRowModel || (r._getCoreRowModel = r.options.getCoreRowModel(r)), r._getCoreRowModel()),
2299
+ // The final calls start at the bottom of the model,
2300
+ // expanded rows, which then work their way up
2301
+ getRowModel: () => r.getPaginationRowModel(),
2302
+ //in next version, we should just pass in the row model as the optional 2nd arg
2303
+ getRow: (c, a) => {
2304
+ let m = (a ? r.getPrePaginationRowModel() : r.getRowModel()).rowsById[c];
2305
+ if (!m && (m = r.getCoreRowModel().rowsById[c], !m))
2306
+ throw process.env.NODE_ENV !== "production" ? new Error(`getRow could not find row with ID: ${c}`) : new Error();
2307
+ return m;
2308
+ },
2309
+ _getDefaultColumnDef: S(() => [r.options.defaultColumn], (c) => {
2310
+ var a;
2311
+ return c = (a = c) != null ? a : {}, {
2312
+ header: (m) => {
2313
+ const v = m.header.column.columnDef;
2314
+ return v.accessorKey ? v.accessorKey : v.accessorFn ? v.id : null;
2315
+ },
2316
+ // footer: props => props.header.column.id,
2317
+ cell: (m) => {
2318
+ var v, C;
2319
+ return (v = (C = m.renderValue()) == null || C.toString == null ? void 0 : C.toString()) != null ? v : null;
2320
+ },
2321
+ ...r._features.reduce((m, v) => Object.assign(m, v.getDefaultColumnDef == null ? void 0 : v.getDefaultColumnDef()), {}),
2322
+ ...c
2323
+ };
2324
+ }, R(e, "debugColumns", "_getDefaultColumnDef")),
2325
+ _getColumnDefs: () => r.options.columns,
2326
+ getAllColumns: S(() => [r._getColumnDefs()], (c) => {
2327
+ const a = function(m, v, C) {
2328
+ return C === void 0 && (C = 0), m.map((w) => {
2329
+ const y = tn(r, w, C, v), x = w;
2330
+ return y.columns = x.columns ? a(x.columns, y, C + 1) : [], y;
2331
+ });
2332
+ };
2333
+ return a(c);
2334
+ }, R(e, "debugColumns", "getAllColumns")),
2335
+ getAllFlatColumns: S(() => [r.getAllColumns()], (c) => c.flatMap((a) => a.getFlatColumns()), R(e, "debugColumns", "getAllFlatColumns")),
2336
+ _getAllFlatColumnsById: S(() => [r.getAllFlatColumns()], (c) => c.reduce((a, m) => (a[m.id] = m, a), {}), R(e, "debugColumns", "getAllFlatColumnsById")),
2337
+ getAllLeafColumns: S(() => [r.getAllColumns(), r._getOrderColumnsFn()], (c, a) => {
2338
+ let m = c.flatMap((v) => v.getLeafColumns());
2339
+ return a(m);
2340
+ }, R(e, "debugColumns", "getAllLeafColumns")),
2341
+ getColumn: (c) => {
2342
+ const a = r._getAllFlatColumnsById()[c];
2343
+ return process.env.NODE_ENV !== "production" && !a && console.error(`[Table] Column with id '${c}' does not exist.`), a;
2344
+ }
2345
+ };
2346
+ Object.assign(r, g);
2347
+ for (let c = 0; c < r._features.length; c++) {
2348
+ const a = r._features[c];
2349
+ a == null || a.createTable == null || a.createTable(r);
2350
+ }
2351
+ return r;
2352
+ }
2353
+ function An() {
2354
+ return (e) => S(() => [e.options.data], (o) => {
2355
+ const t = {
2356
+ rows: [],
2357
+ flatRows: [],
2358
+ rowsById: {}
2359
+ }, n = function(r, l, s) {
2360
+ l === void 0 && (l = 0);
2361
+ const i = [];
2362
+ for (let f = 0; f < r.length; f++) {
2363
+ const p = Ae(e, e._getRowId(r[f], f, s), r[f], f, l, void 0, s == null ? void 0 : s.id);
2364
+ if (t.flatRows.push(p), t.rowsById[p.id] = p, i.push(p), e.options.getSubRows) {
2365
+ var u;
2366
+ p.originalSubRows = e.options.getSubRows(r[f], f), (u = p.originalSubRows) != null && u.length && (p.subRows = n(p.originalSubRows, l + 1, p));
2367
+ }
2368
+ }
2369
+ return i;
2370
+ };
2371
+ return t.rows = n(o), t;
2372
+ }, R(e.options, "debugTable", "getRowModel", () => e._autoResetPageIndex()));
2373
+ }
2374
+ function Hn(e) {
2375
+ const o = [], t = (n) => {
2376
+ var r;
2377
+ o.push(n), (r = n.subRows) != null && r.length && n.getIsExpanded() && n.subRows.forEach(t);
2378
+ };
2379
+ return e.rows.forEach(t), {
2380
+ rows: o,
2381
+ flatRows: e.flatRows,
2382
+ rowsById: e.rowsById
2383
+ };
2384
+ }
2385
+ function Gn(e, o, t) {
2386
+ return t.options.filterFromLeafRows ? On(e, o, t) : Tn(e, o, t);
2387
+ }
2388
+ function On(e, o, t) {
2389
+ var n;
2390
+ const r = [], l = {}, s = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, i = function(u, f) {
2391
+ f === void 0 && (f = 0);
2392
+ const p = [];
2393
+ for (let c = 0; c < u.length; c++) {
2394
+ var g;
2395
+ let a = u[c];
2396
+ const m = Ae(t, a.id, a.original, a.index, a.depth, void 0, a.parentId);
2397
+ if (m.columnFilters = a.columnFilters, (g = a.subRows) != null && g.length && f < s) {
2398
+ if (m.subRows = i(a.subRows, f + 1), a = m, o(a) && !m.subRows.length) {
2399
+ p.push(a), l[a.id] = a, r.push(a);
2400
+ continue;
2401
+ }
2402
+ if (o(a) || m.subRows.length) {
2403
+ p.push(a), l[a.id] = a, r.push(a);
2404
+ continue;
2405
+ }
2406
+ } else
2407
+ a = m, o(a) && (p.push(a), l[a.id] = a, r.push(a));
2408
+ }
2409
+ return p;
2410
+ };
2411
+ return {
2412
+ rows: i(e),
2413
+ flatRows: r,
2414
+ rowsById: l
2415
+ };
2416
+ }
2417
+ function Tn(e, o, t) {
2418
+ var n;
2419
+ const r = [], l = {}, s = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, i = function(u, f) {
2420
+ f === void 0 && (f = 0);
2421
+ const p = [];
2422
+ for (let c = 0; c < u.length; c++) {
2423
+ let a = u[c];
2424
+ if (o(a)) {
2425
+ var g;
2426
+ if ((g = a.subRows) != null && g.length && f < s) {
2427
+ const v = Ae(t, a.id, a.original, a.index, a.depth, void 0, a.parentId);
2428
+ v.subRows = i(a.subRows, f + 1), a = v;
2429
+ }
2430
+ p.push(a), r.push(a), l[a.id] = a;
2431
+ }
2432
+ }
2433
+ return p;
2434
+ };
2435
+ return {
2436
+ rows: i(e),
2437
+ flatRows: r,
2438
+ rowsById: l
2439
+ };
2440
+ }
2441
+ function Bn() {
2442
+ return (e) => S(() => [e.getPreFilteredRowModel(), e.getState().columnFilters, e.getState().globalFilter], (o, t, n) => {
2443
+ if (!o.rows.length || !(t != null && t.length) && !n) {
2444
+ for (let c = 0; c < o.flatRows.length; c++)
2445
+ o.flatRows[c].columnFilters = {}, o.flatRows[c].columnFiltersMeta = {};
2446
+ return o;
2447
+ }
2448
+ const r = [], l = [];
2449
+ (t ?? []).forEach((c) => {
2450
+ var a;
2451
+ const m = e.getColumn(c.id);
2452
+ if (!m)
2453
+ return;
2454
+ const v = m.getFilterFn();
2455
+ if (!v) {
2456
+ process.env.NODE_ENV !== "production" && console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${m.id}.`);
2457
+ return;
2458
+ }
2459
+ r.push({
2460
+ id: c.id,
2461
+ filterFn: v,
2462
+ resolvedValue: (a = v.resolveFilterValue == null ? void 0 : v.resolveFilterValue(c.value)) != null ? a : c.value
2463
+ });
2464
+ });
2465
+ const s = (t ?? []).map((c) => c.id), i = e.getGlobalFilterFn(), u = e.getAllLeafColumns().filter((c) => c.getCanGlobalFilter());
2466
+ n && i && u.length && (s.push("__global__"), u.forEach((c) => {
2467
+ var a;
2468
+ l.push({
2469
+ id: c.id,
2470
+ filterFn: i,
2471
+ resolvedValue: (a = i.resolveFilterValue == null ? void 0 : i.resolveFilterValue(n)) != null ? a : n
2472
+ });
2473
+ }));
2474
+ let f, p;
2475
+ for (let c = 0; c < o.flatRows.length; c++) {
2476
+ const a = o.flatRows[c];
2477
+ if (a.columnFilters = {}, r.length)
2478
+ for (let m = 0; m < r.length; m++) {
2479
+ f = r[m];
2480
+ const v = f.id;
2481
+ a.columnFilters[v] = f.filterFn(a, v, f.resolvedValue, (C) => {
2482
+ a.columnFiltersMeta[v] = C;
2483
+ });
2484
+ }
2485
+ if (l.length) {
2486
+ for (let m = 0; m < l.length; m++) {
2487
+ p = l[m];
2488
+ const v = p.id;
2489
+ if (p.filterFn(a, v, p.resolvedValue, (C) => {
2490
+ a.columnFiltersMeta[v] = C;
2491
+ })) {
2492
+ a.columnFilters.__global__ = !0;
2493
+ break;
2494
+ }
2495
+ }
2496
+ a.columnFilters.__global__ !== !0 && (a.columnFilters.__global__ = !1);
2497
+ }
2498
+ }
2499
+ const g = (c) => {
2500
+ for (let a = 0; a < s.length; a++)
2501
+ if (c.columnFilters[s[a]] === !1)
2502
+ return !1;
2503
+ return !0;
2504
+ };
2505
+ return Gn(o.rows, g, e);
2506
+ }, R(e.options, "debugTable", "getFilteredRowModel", () => e._autoResetPageIndex()));
2507
+ }
2508
+ function Kn(e) {
2509
+ return (o) => S(() => [o.getState().pagination, o.getPrePaginationRowModel(), o.options.paginateExpandedRows ? void 0 : o.getState().expanded], (t, n) => {
2510
+ if (!n.rows.length)
2511
+ return n;
2512
+ const {
2513
+ pageSize: r,
2514
+ pageIndex: l
2515
+ } = t;
2516
+ let {
2517
+ rows: s,
2518
+ flatRows: i,
2519
+ rowsById: u
2520
+ } = n;
2521
+ const f = r * l, p = f + r;
2522
+ s = s.slice(f, p);
2523
+ let g;
2524
+ o.options.paginateExpandedRows ? g = {
2525
+ rows: s,
2526
+ flatRows: i,
2527
+ rowsById: u
2528
+ } : g = Hn({
2529
+ rows: s,
2530
+ flatRows: i,
2531
+ rowsById: u
2532
+ }), g.flatRows = [];
2533
+ const c = (a) => {
2534
+ g.flatRows.push(a), a.subRows.length && a.subRows.forEach(c);
2535
+ };
2536
+ return g.rows.forEach(c), g;
2537
+ }, R(o.options, "debugTable", "getPaginationRowModel"));
2538
+ }
2539
+ function jn() {
2540
+ return (e) => S(() => [e.getState().sorting, e.getPreSortedRowModel()], (o, t) => {
2541
+ if (!t.rows.length || !(o != null && o.length))
2542
+ return t;
2543
+ const n = e.getState().sorting, r = [], l = n.filter((u) => {
2544
+ var f;
2545
+ return (f = e.getColumn(u.id)) == null ? void 0 : f.getCanSort();
2546
+ }), s = {};
2547
+ l.forEach((u) => {
2548
+ const f = e.getColumn(u.id);
2549
+ f && (s[u.id] = {
2550
+ sortUndefined: f.columnDef.sortUndefined,
2551
+ invertSorting: f.columnDef.invertSorting,
2552
+ sortingFn: f.getSortingFn()
2553
+ });
2554
+ });
2555
+ const i = (u) => {
2556
+ const f = u.map((p) => ({
2557
+ ...p
2558
+ }));
2559
+ return f.sort((p, g) => {
2560
+ for (let a = 0; a < l.length; a += 1) {
2561
+ var c;
2562
+ const m = l[a], v = s[m.id], C = v.sortUndefined, w = (c = m == null ? void 0 : m.desc) != null ? c : !1;
2563
+ let y = 0;
2564
+ if (C) {
2565
+ const x = p.getValue(m.id), N = g.getValue(m.id), _ = x === void 0, P = N === void 0;
2566
+ if (_ || P) {
2567
+ if (C === "first") return _ ? -1 : 1;
2568
+ if (C === "last") return _ ? 1 : -1;
2569
+ y = _ && P ? 0 : _ ? C : -C;
2570
+ }
2571
+ }
2572
+ if (y === 0 && (y = v.sortingFn(p, g, m.id)), y !== 0)
2573
+ return w && (y *= -1), v.invertSorting && (y *= -1), y;
2574
+ }
2575
+ return p.index - g.index;
2576
+ }), f.forEach((p) => {
2577
+ var g;
2578
+ r.push(p), (g = p.subRows) != null && g.length && (p.subRows = i(p.subRows));
2579
+ }), f;
2580
+ };
2581
+ return {
2582
+ rows: i(t.rows),
2583
+ flatRows: r,
2584
+ rowsById: t.rowsById
2585
+ };
2586
+ }, R(e.options, "debugTable", "getSortedRowModel", () => e._autoResetPageIndex()));
2587
+ }
2588
+ /**
2589
+ * react-table
2590
+ *
2591
+ * Copyright (c) TanStack
2592
+ *
2593
+ * This source code is licensed under the MIT license found in the
2594
+ * LICENSE.md file in the root directory of this source tree.
2595
+ *
2596
+ * @license MIT
2597
+ */
2598
+ function et(e, o) {
2599
+ return e ? qn(e) ? /* @__PURE__ */ Ne.createElement(e, o) : e : null;
2600
+ }
2601
+ function qn(e) {
2602
+ return Un(e) || typeof e == "function" || Xn(e);
2603
+ }
2604
+ function Un(e) {
2605
+ return typeof e == "function" && (() => {
2606
+ const o = Object.getPrototypeOf(e);
2607
+ return o.prototype && o.prototype.isReactComponent;
2608
+ })();
2609
+ }
2610
+ function Xn(e) {
2611
+ return typeof e == "object" && typeof e.$$typeof == "symbol" && ["react.memo", "react.forward_ref"].includes(e.$$typeof.description);
2612
+ }
2613
+ function Zn(e) {
2614
+ const o = {
2615
+ state: {},
2616
+ // Dummy state
2617
+ onStateChange: () => {
2618
+ },
2619
+ // noop
2620
+ renderFallbackValue: null,
2621
+ ...e
2622
+ }, [t] = Ne.useState(() => ({
2623
+ current: zn(o)
2624
+ })), [n, r] = Ne.useState(() => t.current.initialState);
2625
+ return t.current.setOptions((l) => ({
2626
+ ...l,
2627
+ ...e,
2628
+ state: {
2629
+ ...n,
2630
+ ...e.state
2631
+ },
2632
+ // Similarly, we'll maintain both our internal state and any user-provided
2633
+ // state.
2634
+ onStateChange: (s) => {
2635
+ r(s), e.onStateChange == null || e.onStateChange(s);
2636
+ }
2637
+ })), t.current;
2638
+ }
2639
+ const tt = ({
2640
+ editable: e = !0,
2641
+ deletable: o = !0,
2642
+ pageSize: t = 25,
2643
+ onCellEdit: n,
2644
+ onRowDelete: r
2645
+ }) => {
2646
+ const {
2647
+ rows: l,
2648
+ schema: s,
2649
+ mappings: i,
2650
+ errorsByRow: u,
2651
+ editingCell: f,
2652
+ startEditing: p,
2653
+ stopEditing: g,
2654
+ updateCell: c,
2655
+ deleteRow: a
2656
+ } = re(), [m, v] = X([]), [C, w] = X(""), [y, x] = X(""), N = Ue(() => i.filter((F) => F.targetKey !== null).map((F) => {
2657
+ const I = s == null ? void 0 : s.columns.find((M) => M.key === F.targetKey);
2658
+ return {
2659
+ sourceColumn: F.sourceColumn,
2660
+ targetKey: F.targetKey,
2661
+ label: (I == null ? void 0 : I.label) || F.targetKey,
2662
+ type: (I == null ? void 0 : I.type) || "string"
2663
+ };
2664
+ }), [i, s]), _ = De(
2665
+ (F, I) => {
2666
+ const M = u.get(F);
2667
+ return M == null ? void 0 : M.find((T) => T.columnKey === I);
2668
+ },
2669
+ [u]
2670
+ ), P = (F, I, M) => {
2671
+ x(M), p(F, I);
2672
+ }, ee = () => {
2673
+ f && (c(f.rowIndex, f.columnKey, y), n == null || n(f.rowIndex, f.columnKey, y)), g();
2674
+ }, E = () => {
2675
+ x(""), g();
2676
+ }, B = (F) => {
2677
+ a(F), r == null || r(F);
2678
+ }, Z = Yt(), D = Ue(
2679
+ () => [
2680
+ Z.accessor("rowIndex", {
2681
+ header: "#",
2682
+ size: o ? 80 : 60,
2683
+ cell: (F) => {
2684
+ const I = F.getValue();
2685
+ return /* @__PURE__ */ h("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
2686
+ /* @__PURE__ */ d("span", { className: "ff-font-mono ff-text-xs", style: { color: "var(--ff-text-muted)" }, children: I + 1 }),
2687
+ o && /* @__PURE__ */ d(
2688
+ "button",
2689
+ {
2690
+ onClick: (M) => {
2691
+ M.stopPropagation(), B(I);
2692
+ },
2693
+ title: "Delete row",
2694
+ style: {
2695
+ display: "inline-flex",
2696
+ alignItems: "center",
2697
+ justifyContent: "center",
2698
+ padding: "4px",
2699
+ borderRadius: "4px",
2700
+ cursor: "pointer",
2701
+ color: "#8e8d89",
2702
+ background: "transparent",
2703
+ border: "none",
2704
+ transition: "color 0.15s, background-color 0.15s",
2705
+ marginLeft: "2px",
2706
+ flexShrink: 0
2707
+ },
2708
+ onMouseEnter: (M) => {
2709
+ M.currentTarget.style.color = "#d43338", M.currentTarget.style.backgroundColor = "#fcdede";
2710
+ },
2711
+ onMouseLeave: (M) => {
2712
+ M.currentTarget.style.color = "#8e8d89", M.currentTarget.style.backgroundColor = "transparent";
2713
+ },
2714
+ children: /* @__PURE__ */ d(Ut, { style: { width: "14px", height: "14px", display: "block" } })
2715
+ }
2716
+ )
2717
+ ] });
2718
+ }
2719
+ }),
2720
+ ...N.map(
2721
+ (F) => Z.accessor((I) => I.data[F.targetKey] || I.data[F.sourceColumn], {
2722
+ id: F.targetKey,
2723
+ header: F.label,
2724
+ cell: (I) => {
2725
+ const M = I.row.original.rowIndex, T = String(I.getValue() ?? ""), A = _(M, F.targetKey);
2726
+ return (f == null ? void 0 : f.rowIndex) === M && (f == null ? void 0 : f.columnKey) === F.targetKey ? /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-2 ff-min-w-[280px]", children: [
2727
+ /* @__PURE__ */ d(
2728
+ "input",
2729
+ {
2730
+ type: "text",
2731
+ value: y,
2732
+ onChange: (te) => x(te.target.value),
2733
+ onKeyDown: (te) => {
2734
+ te.key === "Enter" && ee(), te.key === "Escape" && E();
2735
+ },
2736
+ className: "ff-input ff-py-2 ff-px-3 ff-text-sm ff-flex-1 ff-min-w-[160px]",
2737
+ autoFocus: !0
2738
+ }
2739
+ ),
2740
+ /* @__PURE__ */ d(
2741
+ "button",
2742
+ {
2743
+ onClick: ee,
2744
+ className: "ff-btn ff-btn-primary ff-btn-sm ff-flex-shrink-0",
2745
+ children: "Save"
2746
+ }
2747
+ ),
2748
+ /* @__PURE__ */ d(
2749
+ "button",
2750
+ {
2751
+ onClick: E,
2752
+ className: "ff-btn ff-btn-secondary ff-btn-sm ff-flex-shrink-0",
2753
+ children: "Cancel"
2754
+ }
2755
+ )
2756
+ ] }) : /* @__PURE__ */ h(
2757
+ "div",
2758
+ {
2759
+ className: Q(
2760
+ "ff-group ff-flex ff-items-center ff-gap-2",
2761
+ (A == null ? void 0 : A.severity) === "error" && "ff-cell-error",
2762
+ (A == null ? void 0 : A.severity) === "warning" && "ff-cell-warning"
2763
+ ),
2764
+ children: [
2765
+ /* @__PURE__ */ d("span", { className: "ff-flex-1 ff-truncate", children: T || /* @__PURE__ */ d("span", { style: { color: "var(--ff-text-muted)" }, children: "—" }) }),
2766
+ A && /* @__PURE__ */ h("div", { className: "ff-relative ff-group/tooltip", children: [
2767
+ A.severity === "error" ? /* @__PURE__ */ d(Le, { className: "ff-w-4 ff-h-4", style: { color: "var(--ff-error)" } }) : /* @__PURE__ */ d(Me, { className: "ff-w-4 ff-h-4", style: { color: "var(--ff-warning)" } }),
2768
+ /* @__PURE__ */ h("div", { className: "ff-tooltip ff-bottom-full ff-left-1/2 ff-transform ff--translate-x-1/2 ff-mb-2 ff-w-48 group-hover/tooltip:ff-tooltip-visible", children: [
2769
+ A.message,
2770
+ A.suggestion && /* @__PURE__ */ d("span", { className: "ff-block ff-mt-1", style: { color: "var(--ff-text-muted)" }, children: A.suggestion })
2771
+ ] })
2772
+ ] }),
2773
+ e && /* @__PURE__ */ d(
2774
+ "button",
2775
+ {
2776
+ onClick: () => P(M, F.targetKey, T),
2777
+ className: "ff-opacity-0 group-hover:ff-opacity-100 ff-p-1 ff-rounded ff-transition-opacity ff-edit-btn",
2778
+ children: /* @__PURE__ */ d(Bt, { className: "ff-w-3 ff-h-3" })
2779
+ }
2780
+ )
2781
+ ]
2782
+ }
2783
+ );
2784
+ }
2785
+ })
2786
+ )
2787
+ // Delete button is now in the # column (first column) so it's always visible
2788
+ // even when the table has many columns and requires horizontal scrolling.
2789
+ ],
2790
+ [N, f, y, e, o, _, Z]
2791
+ ), O = Zn({
2792
+ data: l,
2793
+ columns: D,
2794
+ state: {
2795
+ sorting: m,
2796
+ globalFilter: C
2797
+ },
2798
+ onSortingChange: v,
2799
+ onGlobalFilterChange: w,
2800
+ getCoreRowModel: An(),
2801
+ getPaginationRowModel: Kn(),
2802
+ getSortedRowModel: jn(),
2803
+ getFilteredRowModel: Bn(),
2804
+ initialState: {
2805
+ pagination: {
2806
+ pageSize: t
2807
+ }
2808
+ }
2809
+ });
2810
+ return /* @__PURE__ */ h("div", { className: "ff-space-y-4", children: [
2811
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-justify-between", children: [
2812
+ /* @__PURE__ */ d(
2813
+ "input",
2814
+ {
2815
+ type: "text",
2816
+ value: C,
2817
+ onChange: (F) => w(F.target.value),
2818
+ placeholder: "Search all columns...",
2819
+ className: "ff-input ff-max-w-xs"
2820
+ }
2821
+ ),
2822
+ /* @__PURE__ */ h("div", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
2823
+ O.getFilteredRowModel().rows.length,
2824
+ " rows"
2825
+ ] })
2826
+ ] }),
2827
+ /* @__PURE__ */ d("div", { className: "ff-table-container ff-max-h-[500px]", children: /* @__PURE__ */ h("table", { className: "ff-table", children: [
2828
+ /* @__PURE__ */ d("thead", { children: O.getHeaderGroups().map((F) => /* @__PURE__ */ d("tr", { children: F.headers.map((I) => /* @__PURE__ */ d(
2829
+ "th",
2830
+ {
2831
+ style: { width: I.getSize() },
2832
+ onClick: I.column.getToggleSortingHandler(),
2833
+ className: Q(
2834
+ I.column.getCanSort() && "ff-cursor-pointer ff-select-none"
2835
+ ),
2836
+ children: /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-1", children: [
2837
+ et(I.column.columnDef.header, I.getContext()),
2838
+ I.column.getIsSorted() && /* @__PURE__ */ d("span", { children: I.column.getIsSorted() === "asc" ? "↑" : "↓" })
2839
+ ] })
2840
+ },
2841
+ I.id
2842
+ )) }, F.id)) }),
2843
+ /* @__PURE__ */ d("tbody", { children: O.getRowModel().rows.map((F) => {
2844
+ const I = u.has(F.original.rowIndex);
2845
+ return /* @__PURE__ */ d(
2846
+ "tr",
2847
+ {
2848
+ className: Q(I && "ff-row-error"),
2849
+ children: F.getVisibleCells().map((M) => /* @__PURE__ */ d("td", { children: et(M.column.columnDef.cell, M.getContext()) }, M.id))
2850
+ },
2851
+ F.id
2852
+ );
2853
+ }) })
2854
+ ] }) }),
2855
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-justify-between ff-px-2", children: [
2856
+ /* @__PURE__ */ h("div", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
2857
+ "Page ",
2858
+ O.getState().pagination.pageIndex + 1,
2859
+ " of ",
2860
+ O.getPageCount()
2861
+ ] }),
2862
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-2", children: [
2863
+ /* @__PURE__ */ h(
2864
+ "button",
2865
+ {
2866
+ onClick: () => O.previousPage(),
2867
+ disabled: !O.getCanPreviousPage(),
2868
+ className: "ff-btn ff-btn-secondary ff-btn-sm",
2869
+ children: [
2870
+ /* @__PURE__ */ d(Pt, { className: "ff-w-4 ff-h-4" }),
2871
+ "Previous"
2872
+ ]
2873
+ }
2874
+ ),
2875
+ /* @__PURE__ */ h(
2876
+ "button",
2877
+ {
2878
+ onClick: () => O.nextPage(),
2879
+ disabled: !O.getCanNextPage(),
2880
+ className: "ff-btn ff-btn-secondary ff-btn-sm",
2881
+ children: [
2882
+ "Next",
2883
+ /* @__PURE__ */ d(xt, { className: "ff-w-4 ff-h-4" })
2884
+ ]
2885
+ }
2886
+ )
2887
+ ] })
2888
+ ] })
2889
+ ] });
2890
+ }, nt = ({
2891
+ showDetails: e = !0
2892
+ }) => {
2893
+ const { validationResults: o } = re();
2894
+ if (!o)
2895
+ return null;
2896
+ const { isValid: t, totalRows: n, validRows: r, errorCount: l, warningCount: s, infoCount: i, summary: u } = o, f = Math.round(r / n * 100);
2897
+ return /* @__PURE__ */ h("div", { className: "ff-space-y-4", children: [
2898
+ /* @__PURE__ */ h(
2899
+ "div",
2900
+ {
2901
+ className: "ff-flex ff-items-center ff-gap-4 ff-p-4 ff-rounded-lg ff-border",
2902
+ style: {
2903
+ backgroundColor: t ? "var(--ff-success-light)" : "var(--ff-error-light)",
2904
+ borderColor: t ? "var(--ff-success)" : "var(--ff-error)"
2905
+ },
2906
+ children: [
2907
+ t ? /* @__PURE__ */ d(ze, { className: "ff-w-8 ff-h-8", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ d(Ze, { className: "ff-w-8 ff-h-8", style: { color: "var(--ff-error)" } }),
2908
+ /* @__PURE__ */ h("div", { children: [
2909
+ /* @__PURE__ */ d(
2910
+ "h3",
2911
+ {
2912
+ className: "ff-text-lg ff-font-semibold",
2913
+ style: { color: t ? "var(--ff-success-dark)" : "var(--ff-error-dark)" },
2914
+ children: t ? "Validation Passed" : "Validation Failed"
2915
+ }
2916
+ ),
2917
+ /* @__PURE__ */ h("p", { className: "ff-text-sm", style: { color: t ? "var(--ff-success)" : "var(--ff-error)" }, children: [
2918
+ r,
2919
+ " of ",
2920
+ n,
2921
+ " rows are valid (",
2922
+ f,
2923
+ "%)"
2924
+ ] })
2925
+ ] })
2926
+ ]
2927
+ }
2928
+ ),
2929
+ /* @__PURE__ */ h("div", { className: "ff-grid ff-grid-cols-4 ff-gap-4", children: [
2930
+ /* @__PURE__ */ h("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-bg-primary)", borderColor: "var(--ff-border-light)" }, children: [
2931
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: n }),
2932
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Total Rows" })
2933
+ ] }),
2934
+ /* @__PURE__ */ h("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-success-light)", borderColor: "var(--ff-success)" }, children: [
2935
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-success-dark)" }, children: r }),
2936
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: "Valid Rows" })
2937
+ ] }),
2938
+ /* @__PURE__ */ h("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-error-light)", borderColor: "var(--ff-error)" }, children: [
2939
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-error-dark)" }, children: l }),
2940
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-error)" }, children: "Errors" })
2941
+ ] }),
2942
+ /* @__PURE__ */ h("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: [
2943
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-warning-dark)" }, children: s }),
2944
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-warning)" }, children: "Warnings" })
2945
+ ] })
2946
+ ] }),
2947
+ e && u.byColumn && Object.keys(u.byColumn).length > 0 && /* @__PURE__ */ h("div", { className: "ff-border ff-rounded-xl ff-overflow-hidden", style: { backgroundColor: "var(--ff-bg-primary)", borderColor: "var(--ff-border-light)" }, children: [
2948
+ /* @__PURE__ */ d("div", { className: "ff-px-4 ff-py-3", style: { backgroundColor: "var(--ff-bg-secondary)" }, children: /* @__PURE__ */ d("h4", { className: "ff-font-medium ff-text-sm", style: { color: "var(--ff-text-secondary)" }, children: "Issues by Column" }) }),
2949
+ /* @__PURE__ */ d("div", { children: Object.entries(u.byColumn).filter(([, p]) => p.errorCount > 0 || p.warningCount > 0).map(([p, g], c, a) => /* @__PURE__ */ h(
2950
+ "div",
2951
+ {
2952
+ className: "ff-flex ff-items-center ff-justify-between ff-px-4 ff-py-3",
2953
+ style: {
2954
+ borderTop: c > 0 ? "1px solid var(--ff-border-light)" : void 0
2955
+ },
2956
+ children: [
2957
+ /* @__PURE__ */ h("div", { className: "ff-flex-1 ff-min-w-0 ff-mr-4", children: [
2958
+ /* @__PURE__ */ d("p", { className: "ff-font-medium ff-text-sm", style: { color: "var(--ff-text-primary)" }, children: g.columnKey }),
2959
+ g.mostCommonError && /* @__PURE__ */ d("p", { className: "ff-text-sm ff-truncate", style: { color: "var(--ff-text-muted)" }, children: g.mostCommonError })
2960
+ ] }),
2961
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-2 ff-flex-shrink-0", children: [
2962
+ g.errorCount > 0 && /* @__PURE__ */ h("span", { className: "ff-badge ff-badge-error ff-whitespace-nowrap", children: [
2963
+ /* @__PURE__ */ d(Ze, { className: "ff-w-3 ff-h-3 ff-mr-1" }),
2964
+ g.errorCount,
2965
+ " ",
2966
+ g.errorCount === 1 ? "error" : "errors"
2967
+ ] }),
2968
+ g.warningCount > 0 && /* @__PURE__ */ h("span", { className: "ff-badge ff-badge-warning ff-whitespace-nowrap", children: [
2969
+ /* @__PURE__ */ d(Me, { className: "ff-w-3 ff-h-3 ff-mr-1" }),
2970
+ g.warningCount,
2971
+ " ",
2972
+ g.warningCount === 1 ? "warning" : "warnings"
2973
+ ] })
2974
+ ] })
2975
+ ]
2976
+ },
2977
+ p
2978
+ )) })
2979
+ ] }),
2980
+ e && u.duplicates && u.duplicates.length > 0 && /* @__PURE__ */ d("div", { className: "ff-border ff-rounded-lg ff-p-4", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: /* @__PURE__ */ h("div", { className: "ff-flex ff-items-start ff-gap-3", children: [
2981
+ /* @__PURE__ */ d(Me, { className: "ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5", style: { color: "var(--ff-warning)" } }),
2982
+ /* @__PURE__ */ h("div", { children: [
2983
+ /* @__PURE__ */ d("h4", { className: "ff-font-medium", style: { color: "var(--ff-warning-dark)" }, children: "Duplicate Values Found" }),
2984
+ /* @__PURE__ */ h("ul", { className: "ff-mt-2 ff-space-y-1 ff-text-sm", style: { color: "var(--ff-warning-dark)" }, children: [
2985
+ u.duplicates.slice(0, 5).map((p, g) => /* @__PURE__ */ h("li", { children: [
2986
+ /* @__PURE__ */ d("span", { className: "ff-font-mono", children: p.columnKey }),
2987
+ ': "',
2988
+ String(p.value),
2989
+ '" appears',
2990
+ " ",
2991
+ p.rowIndices.length,
2992
+ " times (rows",
2993
+ " ",
2994
+ p.rowIndices.slice(0, 3).map((c) => c + 1).join(", "),
2995
+ p.rowIndices.length > 3 ? "..." : "",
2996
+ ")"
2997
+ ] }, g)),
2998
+ u.duplicates.length > 5 && /* @__PURE__ */ h("li", { style: { color: "var(--ff-warning)" }, children: [
2999
+ "... and ",
3000
+ u.duplicates.length - 5,
3001
+ " more duplicate groups"
3002
+ ] })
3003
+ ] })
3004
+ ] })
3005
+ ] }) })
3006
+ ] });
3007
+ }, $e = ["upload", "mapping", "validation", "complete"], Wn = [
3008
+ { key: "upload", label: "Upload", icon: ot },
3009
+ { key: "mapping", label: "Map Columns", icon: Ot },
3010
+ { key: "validation", label: "Validate", icon: jt },
3011
+ { key: "review", label: "Review", icon: Dt },
3012
+ { key: "complete", label: "Complete", icon: ze }
3013
+ ], to = ({
3014
+ template: e,
3015
+ schema: o,
3016
+ mode: t = "modal",
3017
+ theme: n,
3018
+ useShadowDom: r = !1,
3019
+ onComplete: l,
3020
+ onCancel: s,
3021
+ onError: i
3022
+ }) => {
3023
+ const {
3024
+ step: u,
3025
+ sessionId: f,
3026
+ file: p,
3027
+ mappings: g,
3028
+ validationResults: c,
3029
+ isLoading: a,
3030
+ error: m,
3031
+ setSchema: v,
3032
+ setSessionId: C,
3033
+ setParsedData: w,
3034
+ setMappings: y,
3035
+ setUnmapped: x,
3036
+ setValidationResults: N,
3037
+ setStep: _,
3038
+ nextStep: P,
3039
+ previousStep: ee,
3040
+ setLoading: E,
3041
+ setError: B,
3042
+ reset: Z
3043
+ } = re(), [D, O] = X(null), [F, I] = X(null), [M, T] = X(0), [A, W] = X("");
3044
+ Xe(() => {
3045
+ if (I(null), e)
3046
+ if (_t(e)) {
3047
+ const $ = Ft(e);
3048
+ $ ? O($) : (I(`Failed to load template "${e}"`), i == null || i(new Error(`Failed to load template "${e}"`)));
3049
+ } else {
3050
+ const $ = `Template "${e}" not found. Available templates: ${We.join(", ")}`;
3051
+ I($), i == null || i(new Error($));
3052
+ }
3053
+ else if (o)
3054
+ O(o);
3055
+ else {
3056
+ const $ = `No template or schema provided. Please specify a template (${We.join(", ")}) or provide a custom schema.`;
3057
+ I($), i == null || i(new Error($));
3058
+ }
3059
+ }, [e, o, i]), Xe(() => {
3060
+ D && (v(D), te(D));
3061
+ }, [D]);
3062
+ const te = async ($) => {
3063
+ try {
3064
+ E(!0);
3065
+ const k = await ie().createImportSession($);
3066
+ C(k.sessionId);
3067
+ } catch (V) {
3068
+ const k = V;
3069
+ B(k.message), i == null || i(k);
3070
+ } finally {
3071
+ E(!1);
3072
+ }
3073
+ }, gt = De(async ($) => {
3074
+ if (f)
3075
+ try {
3076
+ E(!0), B(null), T(10), W("Uploading file...");
3077
+ const V = ie();
3078
+ T(30), W("Parsing file data...");
3079
+ const k = await V.uploadFile(f, $);
3080
+ T(60), W("Processing rows...");
3081
+ const K = (L, H) => ({
3082
+ rowIndex: L.rowIndex ?? H,
3083
+ data: L.data ?? L,
3084
+ rawData: L.rawData ?? Object.values(L.data ?? L)
3085
+ });
3086
+ w({
3087
+ headers: k.data.headers,
3088
+ rows: k.data.sampleRows.map(K),
3089
+ totalRows: k.data.totalRows,
3090
+ sampleRows: k.data.sampleRows.map(K)
3091
+ }), T(80), W("Matching columns..."), P(), await pt(), T(100), W("Done");
3092
+ } catch (V) {
3093
+ B(`Failed to process the uploaded file: ${V.message}`);
3094
+ } finally {
3095
+ E(!1), T(0), W("");
3096
+ }
3097
+ }, [f]), pt = async () => {
3098
+ if (f)
3099
+ try {
3100
+ E(!0);
3101
+ const V = await ie().matchColumns(f);
3102
+ y(V.mappings), x(V.unmappedSource, V.unmappedTarget);
3103
+ } catch ($) {
3104
+ B(`Column matching failed: ${$.message}`);
3105
+ } finally {
3106
+ E(!1);
3107
+ }
3108
+ }, mt = async () => {
3109
+ if (f)
3110
+ try {
3111
+ E(!0), B(null);
3112
+ const V = await ie().validateImport(f);
3113
+ N(V.validation), P();
3114
+ } catch ($) {
3115
+ B(`Validation failed: ${$.message}`);
3116
+ } finally {
3117
+ E(!1);
3118
+ }
3119
+ }, [Te, fe] = X(null), [b, Be] = X(null), ht = async () => {
3120
+ if (f)
3121
+ try {
3122
+ E(!0), B(null), fe(null);
3123
+ const k = await ie().completeImport(f, {
3124
+ skipInvalidRows: !0,
3125
+ acknowledgeWarnings: !0
3126
+ }), K = {
3127
+ ...k,
3128
+ data: (k.data || []).map((L) => L.data && typeof L.data == "object" && !Array.isArray(L.data) ? {
3129
+ rowIndex: L.rowIndex ?? 0,
3130
+ data: L.data,
3131
+ wasEdited: L.wasEdited ?? !1
3132
+ } : L)
3133
+ };
3134
+ Be(K), _("complete"), l == null || l(K);
3135
+ } catch ($) {
3136
+ fe($.message), _("complete");
3137
+ } finally {
3138
+ E(!1);
3139
+ }
3140
+ }, de = () => {
3141
+ Z(), s == null || s();
3142
+ }, Ke = () => {
3143
+ fe(null), Be(null), T(0), W(""), Z(), D && (v(D), te(D));
3144
+ }, vt = () => Wn.findIndex(($) => $.key === u), wt = () => {
3145
+ switch (u) {
3146
+ case "upload":
3147
+ return p !== null;
3148
+ case "mapping":
3149
+ return g.length > 0 && g.some(($) => $.targetKey !== null);
3150
+ case "validation":
3151
+ return c !== null;
3152
+ case "review":
3153
+ return c !== null && (c.isValid || c.errorCount === 0);
3154
+ default:
3155
+ return !1;
3156
+ }
3157
+ }, Ct = async () => {
3158
+ switch (u) {
3159
+ case "mapping":
3160
+ await mt();
3161
+ break;
3162
+ case "validation":
3163
+ P();
3164
+ break;
3165
+ case "review":
3166
+ await ht();
3167
+ break;
3168
+ default:
3169
+ P();
3170
+ }
3171
+ };
3172
+ if (F)
3173
+ return /* @__PURE__ */ d(we, { theme: n, useShadowDom: r, children: /* @__PURE__ */ d("div", { className: "ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6", children: /* @__PURE__ */ h("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: [
3174
+ /* @__PURE__ */ d("div", { className: "ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4", style: { backgroundColor: "var(--ff-error-light)" }, children: /* @__PURE__ */ d(he, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-error)" } }) }),
3175
+ /* @__PURE__ */ d("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Configuration Error" }),
3176
+ /* @__PURE__ */ d("p", { className: "ff-text-center ff-max-w-md ff-mb-4", style: { color: "var(--ff-text-muted)" }, children: F }),
3177
+ s && /* @__PURE__ */ d("button", { onClick: de, className: "ff-btn ff-btn-secondary", children: "Close" })
3178
+ ] }) }) });
3179
+ if (!D)
3180
+ return /* @__PURE__ */ d(we, { theme: n, useShadowDom: r, children: /* @__PURE__ */ d("div", { className: "ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6", children: /* @__PURE__ */ h("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: [
3181
+ /* @__PURE__ */ d(ce, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3182
+ /* @__PURE__ */ d("p", { style: { color: "var(--ff-text-muted)" }, children: "Loading template..." })
3183
+ ] }) }) });
3184
+ const le = () => {
3185
+ const $ = u === "review" ? "validation" : u;
3186
+ return $e.indexOf($);
3187
+ }, je = /* @__PURE__ */ d(oe, { children: /* @__PURE__ */ h("div", { className: t === "embed" ? "ff-container ff-embed" : "ff-container ff-modal", children: [
3188
+ /* @__PURE__ */ h("div", { className: "ff-modal-header", children: [
3189
+ /* @__PURE__ */ h("div", { className: "ff-modal-header-left", children: [
3190
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
3191
+ /* @__PURE__ */ d("div", { className: "ff-modal-icon", children: /* @__PURE__ */ d(zt, {}) }),
3192
+ /* @__PURE__ */ d("h2", { className: "ff-modal-title", children: "Import Data" })
3193
+ ] }),
3194
+ /* @__PURE__ */ d("div", { className: "ff-steps ff-ml-4", children: $e.map(($, V) => /* @__PURE__ */ h(yt.Fragment, { children: [
3195
+ /* @__PURE__ */ d(
3196
+ "div",
3197
+ {
3198
+ className: Q(
3199
+ "ff-step",
3200
+ le() === V && "ff-step-active",
3201
+ le() > V && "ff-step-complete",
3202
+ le() < V && "ff-step-pending"
3203
+ ),
3204
+ children: le() > V ? "✓" : V + 1
3205
+ }
3206
+ ),
3207
+ V < $e.length - 1 && /* @__PURE__ */ d("div", { className: Q(
3208
+ "ff-step-connector",
3209
+ le() > V && "ff-step-connector-complete"
3210
+ ) })
3211
+ ] }, $)) })
3212
+ ] }),
3213
+ /* @__PURE__ */ d(
3214
+ "button",
3215
+ {
3216
+ onClick: de,
3217
+ className: "ff-modal-close",
3218
+ children: /* @__PURE__ */ d(he, { className: "ff-w-5 ff-h-5" })
3219
+ }
3220
+ )
3221
+ ] }),
3222
+ /* @__PURE__ */ h("div", { className: "ff-modal-body", children: [
3223
+ m && /* @__PURE__ */ d("div", { className: "ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", borderColor: "var(--ff-error)", color: "var(--ff-error)" }, children: m }),
3224
+ u === "upload" && /* @__PURE__ */ d("div", { className: "ff-py-4", children: /* @__PURE__ */ d("div", { className: "ff-max-w-xl ff-mx-auto", children: a && M > 0 ? /* @__PURE__ */ h("div", { className: "ff-p-8 ff-text-center", children: [
3225
+ /* @__PURE__ */ d(ce, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3226
+ /* @__PURE__ */ d("p", { className: "ff-font-medium ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: A }),
3227
+ /* @__PURE__ */ d("div", { className: "ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2", children: /* @__PURE__ */ d(
3228
+ "div",
3229
+ {
3230
+ className: "ff-progress-bar",
3231
+ style: { width: `${M}%`, transition: "width 0.3s ease" }
3232
+ }
3233
+ ) }),
3234
+ /* @__PURE__ */ h("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
3235
+ M,
3236
+ "% complete"
3237
+ ] })
3238
+ ] }) : /* @__PURE__ */ d(Zt, { onFileSelect: gt }) }) }),
3239
+ u === "mapping" && (a && M > 0 ? /* @__PURE__ */ h("div", { className: "ff-py-12 ff-text-center", children: [
3240
+ /* @__PURE__ */ d(ce, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3241
+ /* @__PURE__ */ d("p", { className: "ff-font-medium ff-mb-3", style: { color: "var(--ff-text-primary)" }, children: A }),
3242
+ /* @__PURE__ */ d("div", { className: "ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2", children: /* @__PURE__ */ d(
3243
+ "div",
3244
+ {
3245
+ className: "ff-progress-bar",
3246
+ style: { width: `${M}%`, transition: "width 0.3s ease" }
3247
+ }
3248
+ ) }),
3249
+ /* @__PURE__ */ h("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
3250
+ M,
3251
+ "% complete"
3252
+ ] })
3253
+ ] }) : /* @__PURE__ */ d(Wt, {})),
3254
+ u === "validation" && /* @__PURE__ */ h("div", { className: "ff-space-y-6", children: [
3255
+ /* @__PURE__ */ d(nt, {}),
3256
+ /* @__PURE__ */ d(tt, { editable: !0 })
3257
+ ] }),
3258
+ u === "review" && /* @__PURE__ */ h("div", { className: "ff-space-y-6", children: [
3259
+ /* @__PURE__ */ d(nt, { showDetails: !1 }),
3260
+ /* @__PURE__ */ d(tt, { editable: !1, pageSize: 10 })
3261
+ ] }),
3262
+ u === "complete" && /* @__PURE__ */ d("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: Te ? /* @__PURE__ */ h(oe, { children: [
3263
+ /* @__PURE__ */ d("div", { className: "ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4", style: { backgroundColor: "var(--ff-error-light)" }, children: /* @__PURE__ */ d(he, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-error)" } }) }),
3264
+ /* @__PURE__ */ d("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Import Failed" }),
3265
+ /* @__PURE__ */ d("p", { className: "ff-text-center ff-max-w-md ff-mb-4", style: { color: "var(--ff-text-muted)" }, children: Te }),
3266
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-gap-3", children: [
3267
+ /* @__PURE__ */ d(
3268
+ "button",
3269
+ {
3270
+ onClick: () => {
3271
+ fe(null), _("review");
3272
+ },
3273
+ className: "ff-btn ff-btn-secondary",
3274
+ children: "Back to Review"
3275
+ }
3276
+ ),
3277
+ s && /* @__PURE__ */ d("button", { onClick: de, className: "ff-btn ff-btn-secondary", children: "Close" })
3278
+ ] })
3279
+ ] }) : /* @__PURE__ */ h(oe, { children: [
3280
+ /* @__PURE__ */ d("div", { className: "ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6", style: { backgroundColor: "var(--ff-success-light)" }, children: /* @__PURE__ */ d(ze, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-success)" } }) }),
3281
+ /* @__PURE__ */ d("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Import Complete!" }),
3282
+ /* @__PURE__ */ d("p", { className: "ff-mb-6", style: { color: "var(--ff-text-muted)" }, children: "Your data has been successfully imported." }),
3283
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-gap-6 ff-mb-6", children: [
3284
+ /* @__PURE__ */ h("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-border-light)", backgroundColor: "var(--ff-bg-primary)" }, children: [
3285
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: (b == null ? void 0 : b.totalRows) ?? (c == null ? void 0 : c.totalRows) ?? 0 }),
3286
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Total Rows" })
3287
+ ] }),
3288
+ /* @__PURE__ */ h("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-success)", backgroundColor: "var(--ff-success-light)" }, children: [
3289
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-success-dark)" }, children: (b == null ? void 0 : b.importedRows) ?? (c == null ? void 0 : c.validRows) ?? 0 }),
3290
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: "Imported" })
3291
+ ] }),
3292
+ ((b == null ? void 0 : b.skippedRows) ?? 0) > 0 && /* @__PURE__ */ h("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-warning)", backgroundColor: "var(--ff-warning-light)" }, children: [
3293
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-warning-dark)" }, children: (b == null ? void 0 : b.skippedRows) ?? 0 }),
3294
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-warning)" }, children: "Skipped" })
3295
+ ] }),
3296
+ /* @__PURE__ */ h("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-border-light)", backgroundColor: "var(--ff-bg-primary)" }, children: [
3297
+ /* @__PURE__ */ d("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: g.filter(($) => $.targetKey !== null).length }),
3298
+ /* @__PURE__ */ d("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Columns Mapped" })
3299
+ ] })
3300
+ ] }),
3301
+ (b == null ? void 0 : b.data) && b.data.length > 0 && (() => {
3302
+ const $ = b.data.slice(0, 5), V = $[0], k = (V == null ? void 0 : V.data) || V, K = Object.keys(typeof k == "object" ? k : {}).slice(0, 6), L = (D == null ? void 0 : D.columns) || [];
3303
+ return K.length === 0 ? null : /* @__PURE__ */ h("div", { className: "ff-w-full ff-mb-6", children: [
3304
+ /* @__PURE__ */ h("p", { className: "ff-text-xs ff-font-semibold ff-uppercase ff-tracking-wider ff-mb-2", style: { color: "var(--ff-text-muted)" }, children: [
3305
+ "Data Preview (first ",
3306
+ $.length,
3307
+ " rows)"
3308
+ ] }),
3309
+ /* @__PURE__ */ d("div", { className: "ff-table-container ff-max-h-[250px]", children: /* @__PURE__ */ h("table", { className: "ff-table", children: [
3310
+ /* @__PURE__ */ d("thead", { children: /* @__PURE__ */ h("tr", { children: [
3311
+ /* @__PURE__ */ d("th", { style: { width: 40 }, children: "#" }),
3312
+ K.map((H) => {
3313
+ const ne = L.find((se) => se.key === H);
3314
+ return /* @__PURE__ */ d("th", { children: (ne == null ? void 0 : ne.label) || H }, H);
3315
+ }),
3316
+ K.length < Object.keys(typeof k == "object" ? k : {}).length && /* @__PURE__ */ d("th", { children: "..." })
3317
+ ] }) }),
3318
+ /* @__PURE__ */ d("tbody", { children: $.map((H, ne) => {
3319
+ const se = (H == null ? void 0 : H.data) || H;
3320
+ return /* @__PURE__ */ h("tr", { children: [
3321
+ /* @__PURE__ */ d("td", { children: /* @__PURE__ */ d("span", { className: "ff-font-mono ff-text-xs", style: { color: "var(--ff-text-muted)" }, children: ((H == null ? void 0 : H.rowIndex) ?? ne) + 1 }) }),
3322
+ K.map((qe) => /* @__PURE__ */ d("td", { children: /* @__PURE__ */ d("span", { className: "ff-text-sm ff-truncate ff-block ff-max-w-[150px]", children: String((se == null ? void 0 : se[qe]) ?? "—") }) }, qe)),
3323
+ K.length < Object.keys(typeof k == "object" ? k : {}).length && /* @__PURE__ */ d("td", { children: /* @__PURE__ */ d("span", { style: { color: "var(--ff-text-muted)" }, children: "..." }) })
3324
+ ] }, ne);
3325
+ }) })
3326
+ ] }) }),
3327
+ b.data.length > 5 && /* @__PURE__ */ h("p", { className: "ff-text-xs ff-mt-1", style: { color: "var(--ff-text-muted)" }, children: [
3328
+ "Showing 5 of ",
3329
+ b.data.length,
3330
+ " imported rows"
3331
+ ] })
3332
+ ] });
3333
+ })(),
3334
+ /* @__PURE__ */ h("div", { className: "ff-flex ff-gap-3", children: [
3335
+ /* @__PURE__ */ d(
3336
+ "button",
3337
+ {
3338
+ onClick: Ke,
3339
+ className: "ff-btn ff-btn-primary",
3340
+ children: "Start New Import"
3341
+ }
3342
+ ),
3343
+ s && /* @__PURE__ */ d("button", { onClick: de, className: "ff-btn ff-btn-secondary", children: "Close" })
3344
+ ] })
3345
+ ] }) })
3346
+ ] }),
3347
+ /* @__PURE__ */ d("div", { className: "ff-modal-footer", children: u === "complete" ? /* @__PURE__ */ h(oe, { children: [
3348
+ /* @__PURE__ */ d("div", {}),
3349
+ /* @__PURE__ */ d("button", { onClick: Ke, className: "ff-btn ff-btn-primary", children: "Start New Import" })
3350
+ ] }) : /* @__PURE__ */ h(oe, { children: [
3351
+ /* @__PURE__ */ d(
3352
+ "button",
3353
+ {
3354
+ onClick: ee,
3355
+ disabled: vt() === 0 || a,
3356
+ className: "ff-btn ff-btn-ghost",
3357
+ children: "Back"
3358
+ }
3359
+ ),
3360
+ /* @__PURE__ */ d(
3361
+ "button",
3362
+ {
3363
+ onClick: Ct,
3364
+ disabled: !wt() || a,
3365
+ className: "ff-btn ff-btn-primary",
3366
+ children: a ? /* @__PURE__ */ h(oe, { children: [
3367
+ /* @__PURE__ */ d(ce, { className: "ff-w-4 ff-h-4 ff-animate-spin" }),
3368
+ "Processing..."
3369
+ ] }) : u === "review" ? "Complete Import" : "Continue"
3370
+ }
3371
+ )
3372
+ ] }) })
3373
+ ] }) });
3374
+ return /* @__PURE__ */ d(we, { theme: n, useShadowDom: r, children: t === "modal" ? /* @__PURE__ */ d("div", { className: "ff-overlay", children: je }) : je });
3375
+ };
3376
+ export {
3377
+ Wt as C,
3378
+ tt as D,
3379
+ Zt as F,
3380
+ to as I,
3381
+ nt as V,
3382
+ re as u
3383
+ };
3384
+ //# sourceMappingURL=ImportWizard-_wJ7Qxpr.mjs.map