@opennsw/jsonforms-renderers 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,194 +1,313 @@
1
- var Jt = Object.defineProperty;
2
- var Zt = (e, r, t) => r in e ? Jt(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
- var ut = (e, r, t) => Zt(e, typeof r != "symbol" ? r + "" : r, t);
4
- import { jsx as i, jsxs as y, Fragment as ge } from "react/jsx-runtime";
5
- import { useContext as Rt, createContext as Ct, useMemo as _e, useEffect as de, useState as j, useRef as ae, useCallback as Fe } from "react";
6
- import { rankWith as ee, isStringControl as Qt, or as Je, isNumberControl as er, isIntegerControl as tr, isBooleanControl as rr, isEnumControl as St, isOneOfControl as Ot, Resolve as Ve, schemaMatches as Ie, isDateControl as nr, isDateTimeControl as or, isTimeControl as ir, uiTypeIs as He, and as Nt, not as sr, optionIs as lr, update as cr, createDefaultValue as ar, isObjectArrayControl as ur, isPrimitiveArrayControl as dr } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as ue, useJsonForms as We, JsonFormsDispatch as Be, withJsonFormsArrayControlProps as fr } from "@jsonforms/react";
8
- import { Box as S, Flex as D, Text as f, TextField as Ae, Checkbox as pr, RadioGroup as dt, ScrollArea as kt, Select as Ke, Spinner as Ue, Button as De, Tabs as Ye, Heading as It, Card as Dt, IconButton as je, Table as Te, Tooltip as qe } from "@radix-ui/themes";
9
- import { ChevronDownIcon as Lt, FileTextIcon as hr, CheckCircledIcon as mr, Cross2Icon as rt, ExclamationTriangleIcon as nt, UploadIcon as ze, DownloadIcon as Mt, TrashIcon as gr, PlusIcon as yr } from "@radix-ui/react-icons";
10
- import zt from "dayjs";
11
- const Ft = Ct(null);
12
- function ei({
1
+ var yr = Object.defineProperty;
2
+ var br = (e, r, t) => r in e ? yr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
3
+ var vt = (e, r, t) => br(e, typeof r != "symbol" ? r + "" : r, t);
4
+ import { jsx as l, jsxs as g, Fragment as xe } from "react/jsx-runtime";
5
+ import { useContext as Pt, createContext as _t, useMemo as Ve, useEffect as we, useState as B, useRef as ge, useCallback as We } from "react";
6
+ import { rankWith as ie, isStringControl as vr, or as ot, isNumberControl as wr, isIntegerControl as Er, isBooleanControl as Tr, isEnumControl as jt, isOneOfControl as Vt, schemaMatches as ze, Resolve as He, isDateControl as xr, isDateTimeControl as Ar, isTimeControl as Rr, uiTypeIs as Ye, and as Wt, not as Cr, optionIs as Sr, update as Or, createDefaultValue as Nr, isObjectArrayControl as Dr, isPrimitiveArrayControl as Ir } from "@jsonforms/core";
7
+ import { useJsonForms as $e, withJsonFormsControlProps as be, JsonFormsDispatch as Ge, withJsonFormsArrayControlProps as kr, withJsonFormsLayoutProps as Ze } from "@jsonforms/react";
8
+ import { Box as M, Flex as $, Text as p, TextField as Ie, Checkbox as Lr, RadioGroup as wt, ScrollArea as Ht, Select as Qe, Spinner as Be, Button as Ue, Tabs as et, Heading as Bt, Card as Xt, Tooltip as Ke, IconButton as Xe, Table as De } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as qt, FileTextIcon as Mr, DownloadIcon as dt, CheckCircledIcon as zr, Cross2Icon as ft, ExclamationTriangleIcon as pt, UploadIcon as je, TrashIcon as Fr, PlusIcon as $r } from "@radix-ui/react-icons";
10
+ import Kt from "dayjs";
11
+ const Yt = _t(null);
12
+ function Pi({
13
13
  children: e,
14
14
  onUpload: r,
15
15
  getDownloadUrl: t
16
16
  }) {
17
17
  const n = { onUpload: r, getDownloadUrl: t };
18
- return /* @__PURE__ */ i(Ft.Provider, { value: n, children: e });
18
+ return /* @__PURE__ */ l(Yt.Provider, { value: n, children: e });
19
19
  }
20
- function br() {
21
- return Rt(Ft);
20
+ function Ur() {
21
+ return Pt(Yt);
22
22
  }
23
- const Ut = Ct(null);
24
- function ti({
23
+ const Gt = _t(null);
24
+ function _i({
25
25
  children: e,
26
26
  services: r
27
27
  }) {
28
- const t = _e(() => r, [r]);
29
- return /* @__PURE__ */ i(Ut.Provider, { value: t, children: e });
28
+ const t = Ve(() => r, [r]);
29
+ return /* @__PURE__ */ l(Gt.Provider, { value: t, children: e });
30
30
  }
31
- function vr(e) {
32
- const r = Rt(Ut);
31
+ function Pr(e) {
32
+ const r = Pt(Gt);
33
33
  return !r || !e ? null : r[e] ?? null;
34
34
  }
35
- const Ee = (e, r, t, n = void 0) => {
36
- de(() => {
35
+ const Oe = (e, r, t, n = void 0) => {
36
+ we(() => {
37
37
  e === !1 && t(r, n);
38
38
  }, [e, r, t, n]);
39
- }, ye = (e, r) => e ? e.split(`
40
- `).map((t) => t.trim() === "is a required property" ? `${r || "This field"} is required` : t).join(`
41
- `) : "", wr = ({
39
+ }, Et = /* @__PURE__ */ new WeakMap();
40
+ function _r(e) {
41
+ if (!e || typeof e != "object") return !1;
42
+ const r = Et.get(e);
43
+ if (r !== void 0) return r;
44
+ const t = _e(e, e, /* @__PURE__ */ new Set());
45
+ return Et.set(e, t), t;
46
+ }
47
+ function jr(e, r) {
48
+ if (!r.startsWith("#/")) return;
49
+ const t = r.slice(2).split("/");
50
+ let n = e;
51
+ for (const i of t) {
52
+ if (!n || typeof n != "object") return;
53
+ n = n[i];
54
+ }
55
+ return n && typeof n == "object" ? n : void 0;
56
+ }
57
+ function _e(e, r, t) {
58
+ if (!e || typeof e != "object" || t.has(e)) return !1;
59
+ t.add(e);
60
+ const n = e;
61
+ if (n.if != null || n.dependentRequired != null || n.dependencies != null) return !0;
62
+ for (const i of ["allOf", "anyOf", "oneOf"]) {
63
+ const o = n[i];
64
+ if (Array.isArray(o))
65
+ for (const s of o) {
66
+ if (!s || typeof s != "object") continue;
67
+ const a = s;
68
+ if (Array.isArray(a.required) && a.required.length > 0 || _e(a, r, t)) return !0;
69
+ }
70
+ }
71
+ if (typeof n.$ref == "string") {
72
+ const i = jr(r, n.$ref);
73
+ if (i && _e(i, r, t)) return !0;
74
+ }
75
+ for (const i of ["then", "else", "not", "contains", "additionalProperties", "items"]) {
76
+ const o = n[i];
77
+ if (o && typeof o == "object" && !Array.isArray(o) && _e(o, r, t))
78
+ return !0;
79
+ }
80
+ if (Array.isArray(n.items)) {
81
+ for (const i of n.items)
82
+ if (_e(i, r, t)) return !0;
83
+ }
84
+ for (const i of ["properties", "patternProperties", "$defs", "definitions"]) {
85
+ const o = n[i];
86
+ if (!(!o || typeof o != "object")) {
87
+ for (const s of Object.values(o))
88
+ if (_e(s, r, t)) return !0;
89
+ }
90
+ }
91
+ return !1;
92
+ }
93
+ function Vr(e, r) {
94
+ const t = structuredClone(e ?? {});
95
+ if (!r) return t;
96
+ const n = r.split(".");
97
+ let i = t;
98
+ for (let s = 0; s < n.length - 1; s++) {
99
+ const a = n[s];
100
+ if (i == null || typeof i != "object") return t;
101
+ const c = i[a];
102
+ if (c == null || typeof c != "object") return t;
103
+ i = c;
104
+ }
105
+ const o = n[n.length - 1];
106
+ return i != null && typeof i == "object" && delete i[o], t;
107
+ }
108
+ function Wr(e) {
109
+ const r = e.lastIndexOf(".");
110
+ return r === -1 ? "" : "/" + e.slice(0, r).split(".").join("/");
111
+ }
112
+ function Hr(e) {
113
+ if (!e) return "";
114
+ const r = e.lastIndexOf(".");
115
+ return r === -1 ? e : e.slice(r + 1);
116
+ }
117
+ function Br(e, r) {
118
+ var t;
119
+ return e.keyword !== "required" && e.keyword !== "dependencies" || ((t = e.params) == null ? void 0 : t.missingProperty) !== Hr(r) ? !1 : (e.instancePath ?? "") === Wr(r);
120
+ }
121
+ function Xr(e, r, t) {
122
+ if (!e || !t) return !1;
123
+ const n = Vr(r, e);
124
+ t(n);
125
+ const i = t.errors;
126
+ return i != null && i.length ? i.some((o) => Br(o, e)) : !1;
127
+ }
128
+ function Ae(e, r = !1, t = !0) {
129
+ var a, c, u;
130
+ const n = $e(), i = (a = n.core) == null ? void 0 : a.data, o = (c = n.core) == null ? void 0 : c.validator, s = (u = n.core) == null ? void 0 : u.schema;
131
+ return Ve(() => t ? r ? !0 : _r(s) ? Xr(e, i, o) : !1 : !1, [t, r, e, i, o, s]);
132
+ }
133
+ const Re = (e, r) => {
134
+ if (!e) return "";
135
+ const t = r || "This field";
136
+ return e.split(`
137
+ `).map((n) => {
138
+ const i = n.trim();
139
+ return i === "is a required property" ? `${t} is required` : i.startsWith("must be > ") ? `${t} must be greater than ${i.slice(10)}` : i.startsWith("must be >= ") ? `${t} must be at least ${i.slice(11)}` : i.startsWith("must be multiple of ") ? `${t} must be a multiple of ${i.slice(20)}` : n;
140
+ }).join(`
141
+ `);
142
+ }, qr = ({
42
143
  data: e,
43
144
  handleChange: r,
44
145
  path: t,
45
146
  label: n,
46
- required: l,
147
+ required: i,
47
148
  errors: o,
48
149
  uischema: s,
49
- schema: c,
50
- enabled: a,
51
- visible: d = !0
150
+ schema: a,
151
+ enabled: c,
152
+ visible: u = !0
52
153
  }) => {
53
- var h;
54
- if (Ee(d, t, r), d === !1)
154
+ var m;
155
+ Oe(u, t, r);
156
+ const d = Ae(t, i, u);
157
+ if (u === !1)
55
158
  return null;
56
- const u = o.length === 0;
57
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
58
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
159
+ const y = o.length === 0;
160
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
161
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
59
162
  n,
60
163
  " ",
61
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
164
+ d && /* @__PURE__ */ l(p, { color: "red", children: "*" })
62
165
  ] }),
63
- /* @__PURE__ */ i(
64
- Ae.Root,
166
+ /* @__PURE__ */ l(
167
+ Ie.Root,
65
168
  {
66
169
  value: e || "",
67
- onChange: (p) => r(t, p.target.value),
68
- disabled: !a,
69
- placeholder: (h = s.options) == null ? void 0 : h.placeholder,
70
- color: u ? void 0 : "red",
170
+ onChange: (f) => r(t, f.target.value),
171
+ disabled: !c,
172
+ placeholder: (m = s.options) == null ? void 0 : m.placeholder,
173
+ color: y ? void 0 : "red",
71
174
  id: t
72
175
  }
73
176
  ),
74
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
75
- c.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: c.description })
177
+ !y && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Re(o, n) }),
178
+ a.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: a.description })
76
179
  ] }) });
77
- }, Er = ee(1, Qt), Tr = ue(wr), Ar = ({
180
+ }, Kr = ie(1, vr), Yr = be(qr), Gr = /* @__PURE__ */ new Set(["-", "+", "e", "E"]), Jr = ({
78
181
  data: e,
79
182
  handleChange: r,
80
183
  path: t,
81
184
  label: n,
82
- required: l,
185
+ required: i,
83
186
  errors: o,
84
187
  uischema: s,
85
- schema: c,
86
- enabled: a,
87
- visible: d = !0
188
+ schema: a,
189
+ enabled: c,
190
+ visible: u = !0
88
191
  }) => {
89
- var p;
90
- if (Ee(d, t, r), d === !1)
192
+ var R;
193
+ Oe(u, t, r);
194
+ const d = Ae(t, i, u);
195
+ if (u === !1)
91
196
  return null;
92
- const u = o.length === 0, h = (g) => {
93
- if (g === "") {
197
+ const y = o.length === 0, m = typeof a.exclusiveMinimum == "number" ? a.exclusiveMinimum : void 0, f = typeof a.minimum == "number" ? a.minimum : void 0, T = m ?? f, w = T !== void 0 && T >= 0, L = typeof a.multipleOf == "number" ? a.multipleOf : a.type === "integer" ? 1 : void 0, D = (v) => {
198
+ if (v === "") {
94
199
  r(t, void 0);
95
200
  return;
96
201
  }
97
- const b = Number(g);
202
+ const b = Number(v);
98
203
  isNaN(b) || r(t, b);
204
+ }, N = (v) => {
205
+ w && Gr.has(v.key) && v.preventDefault();
206
+ }, A = (v) => {
207
+ if (!w) return;
208
+ const b = v.clipboardData.getData("text");
209
+ /[-+eE]/.test(b) && v.preventDefault();
99
210
  };
100
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
101
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
211
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
212
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
102
213
  n,
103
214
  " ",
104
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
215
+ d && /* @__PURE__ */ l(p, { color: "red", children: "*" })
105
216
  ] }),
106
- /* @__PURE__ */ i(
107
- Ae.Root,
217
+ /* @__PURE__ */ l(
218
+ Ie.Root,
108
219
  {
109
220
  type: "number",
110
221
  value: e ?? "",
111
- onChange: (g) => h(g.target.value),
112
- disabled: !a,
113
- placeholder: (p = s.options) == null ? void 0 : p.placeholder,
114
- color: u ? void 0 : "red",
222
+ onChange: (v) => D(v.target.value),
223
+ onKeyDown: N,
224
+ onPaste: A,
225
+ min: T,
226
+ step: L,
227
+ disabled: !c,
228
+ placeholder: (R = s.options) == null ? void 0 : R.placeholder,
229
+ color: y ? void 0 : "red",
115
230
  id: t
116
231
  }
117
232
  ),
118
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
119
- c.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: c.description })
233
+ !y && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Re(o, n) }),
234
+ a.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: a.description })
120
235
  ] }) });
121
- }, xr = ee(2, Je(er, tr)), Rr = ue(Ar), Cr = ({
236
+ }, Zr = ie(2, ot(wr, Er)), Qr = be(Jr), en = ({
122
237
  data: e,
123
238
  handleChange: r,
124
239
  path: t,
125
240
  label: n,
126
- required: l,
241
+ required: i,
127
242
  errors: o,
128
243
  schema: s,
129
- enabled: c,
130
- visible: a = !0
244
+ enabled: a,
245
+ visible: c = !0
131
246
  }) => {
132
- if (Ee(a, t, r), a === !1)
247
+ Oe(c, t, r);
248
+ const u = Ae(t, i, c);
249
+ if (c === !1)
133
250
  return null;
134
251
  const d = o.length === 0;
135
- return /* @__PURE__ */ y(S, { mb: "4", children: [
136
- /* @__PURE__ */ y(D, { gap: "2", align: "center", children: [
137
- /* @__PURE__ */ i(
138
- pr,
252
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
253
+ /* @__PURE__ */ g($, { gap: "2", align: "center", children: [
254
+ /* @__PURE__ */ l(
255
+ Lr,
139
256
  {
140
257
  checked: !!e,
141
- onCheckedChange: (u) => r(t, u === !0),
142
- disabled: !c,
258
+ onCheckedChange: (y) => r(t, y === !0),
259
+ disabled: !a,
143
260
  id: t
144
261
  }
145
262
  ),
146
- /* @__PURE__ */ y(f, { as: "label", size: "2", htmlFor: t, children: [
263
+ /* @__PURE__ */ g(p, { as: "label", size: "2", htmlFor: t, children: [
147
264
  n,
148
265
  " ",
149
- l && "*"
266
+ u && "*"
150
267
  ] })
151
268
  ] }),
152
- !d && /* @__PURE__ */ i(f, { color: "red", size: "1", className: "block mt-1", children: ye(o, n) }),
153
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", className: "block mt-1", children: s.description })
269
+ !d && /* @__PURE__ */ l(p, { color: "red", size: "1", className: "block mt-1", children: Re(o, n) }),
270
+ s.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", className: "block mt-1", children: s.description })
154
271
  ] });
155
- }, Sr = ee(2, rr), Or = ue(Cr), Nr = ({
272
+ }, tn = ie(2, Tr), rn = be(en), nn = ({
156
273
  data: e,
157
274
  handleChange: r,
158
275
  path: t,
159
276
  label: n,
160
- required: l,
277
+ required: i,
161
278
  errors: o,
162
279
  schema: s,
163
- enabled: c,
164
- visible: a = !0
280
+ enabled: a,
281
+ visible: c = !0
165
282
  }) => {
166
- if (Ee(a, t, r), a === !1)
283
+ Oe(c, t, r);
284
+ const u = Ae(t, i, c);
285
+ if (c === !1)
167
286
  return null;
168
287
  const d = o.length === 0;
169
- let u = [];
170
- s.enum ? u = s.enum.map((p) => ({ value: p, label: String(p) })) : s.oneOf && (u = s.oneOf.map((p) => ({
171
- value: p.const,
172
- label: p.title || String(p.const)
288
+ let y = [];
289
+ s.enum ? y = s.enum.map((f) => ({ value: f, label: String(f) })) : s.oneOf && (y = s.oneOf.map((f) => ({
290
+ value: f.const,
291
+ label: f.title || String(f.const)
173
292
  })));
174
- const h = e;
175
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
176
- /* @__PURE__ */ y(f, { as: "div", size: "2", weight: "bold", children: [
293
+ const m = e;
294
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
295
+ /* @__PURE__ */ g(p, { as: "div", size: "2", weight: "bold", children: [
177
296
  n,
178
297
  " ",
179
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
298
+ u && /* @__PURE__ */ l(p, { color: "red", children: "*" })
180
299
  ] }),
181
- /* @__PURE__ */ i(
182
- dt.Root,
300
+ /* @__PURE__ */ l(
301
+ wt.Root,
183
302
  {
184
- value: h !== void 0 ? String(h) : "",
185
- onValueChange: (p) => {
186
- const g = u.find((b) => String(b.value) === p);
187
- g && r(t, g.value);
303
+ value: m !== void 0 ? String(m) : "",
304
+ onValueChange: (f) => {
305
+ const T = y.find((w) => String(w.value) === f);
306
+ T && r(t, T.value);
188
307
  },
189
- disabled: !c,
190
- children: /* @__PURE__ */ i(
191
- D,
308
+ disabled: !a,
309
+ children: /* @__PURE__ */ l(
310
+ $,
192
311
  {
193
312
  direction: "row",
194
313
  style: {
@@ -196,107 +315,109 @@ const Ee = (e, r, t, n = void 0) => {
196
315
  columnGap: "clamp(14px, 3vw, 36px)",
197
316
  rowGap: "clamp(8px, 1.6vw, 14px)"
198
317
  },
199
- children: u.map((p) => /* @__PURE__ */ y(D, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
200
- /* @__PURE__ */ i(dt.Item, { value: String(p.value) }),
201
- /* @__PURE__ */ i(f, { size: "2", color: c ? void 0 : "gray", children: p.label })
202
- ] }, String(p.value)))
318
+ children: y.map((f) => /* @__PURE__ */ g($, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
319
+ /* @__PURE__ */ l(wt.Item, { value: String(f.value) }),
320
+ /* @__PURE__ */ l(p, { size: "2", color: a ? void 0 : "gray", children: f.label })
321
+ ] }, String(f.value)))
203
322
  }
204
323
  )
205
324
  }
206
325
  ),
207
- !d && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
208
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
326
+ !d && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Re(o, n) }),
327
+ s.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: s.description })
209
328
  ] }) });
210
- }, kr = (e, r, t) => {
211
- var l;
212
- return Je(St, Ot)(e, r, t) && ((l = e == null ? void 0 : e.options) == null ? void 0 : l.format) === "radio" ? 3 : -1;
213
- }, Ir = ue(Nr), Dr = ({
329
+ }, on = (e, r, t) => {
330
+ var i;
331
+ return ot(jt, Vt)(e, r, t) && ((i = e == null ? void 0 : e.options) == null ? void 0 : i.format) === "radio" ? 3 : -1;
332
+ }, sn = be(nn), ln = ({
214
333
  data: e,
215
334
  handleChange: r,
216
335
  path: t,
217
336
  label: n,
218
- required: l,
337
+ required: i,
219
338
  errors: o,
220
339
  schema: s,
221
- uischema: c,
222
- enabled: a,
223
- visible: d = !0
340
+ uischema: a,
341
+ enabled: c,
342
+ visible: u = !0
224
343
  }) => {
225
- var N, U, z;
226
- Ee(d, t, r);
227
- const u = ((N = c.options) == null ? void 0 : N.autocomplete) === !0, [h, p] = j(!1), [g, b] = j(""), [I, O] = j(0), T = ae(null);
228
- if (de(() => {
229
- if (!u || !h) return;
230
- const v = (E) => {
231
- T.current && !T.current.contains(E.target) && p(!1);
344
+ var ee, fe, oe, te;
345
+ Oe(u, t, r);
346
+ const d = Ae(t, i, u), y = ((ee = a.options) == null ? void 0 : ee.autocomplete) === !0, [m, f] = B(!1), [T, w] = B(""), [L, D] = B(0), N = ge(null);
347
+ if (we(() => {
348
+ if (!y || !m) return;
349
+ const k = (G) => {
350
+ N.current && !N.current.contains(G.target) && f(!1);
232
351
  };
233
- return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
234
- }, [u, h]), d === !1)
352
+ return document.addEventListener("mousedown", k), () => document.removeEventListener("mousedown", k);
353
+ }, [y, m]), u === !1)
235
354
  return null;
236
- const A = o.length === 0;
237
- let k = [];
238
- s.enum ? k = s.enum.map((v) => ({ value: String(v), label: String(v) })) : s.oneOf && (k = s.oneOf.map((v) => ({
239
- value: String(v.const),
240
- label: v.title || String(v.const)
241
- })));
242
- const M = e !== void 0 ? String(e) : "", L = ((U = c.options) == null ? void 0 : U.placeholder) || "Select an option";
243
- if (u) {
244
- const v = ((z = k.find((R) => R.value === M)) == null ? void 0 : z.label) ?? "", E = h ? k.filter((R) => R.label.toLowerCase().includes(g.toLowerCase())) : k, B = Math.min(I, E.length - 1), K = (R) => {
245
- r(t, R.value), p(!1);
246
- }, J = (R) => {
247
- R.stopPropagation(), r(t, void 0), b("");
248
- }, F = (R) => {
249
- (R.key === "Enter" || R.key === " ") && J(R);
355
+ const A = s.type === "object", R = A ? ((fe = s.properties) == null ? void 0 : fe.value) ?? {} : s;
356
+ let v = [];
357
+ R.enum ? v = R.enum.map((k) => ({ value: String(k), label: String(k), raw: k })) : R.oneOf && (v = R.oneOf.map((k) => {
358
+ const G = k.const;
359
+ return { value: String(G), label: k.title || String(G), raw: G };
360
+ }));
361
+ const b = A ? typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? { value: e } : e ?? void 0 : void 0, U = A ? b == null ? void 0 : b.value : e, P = b == null ? void 0 : b.label, O = U != null ? String(U) : "", j = P ?? ((oe = v.find((k) => k.value === O)) == null ? void 0 : oe.label) ?? "", I = ((te = a.options) == null ? void 0 : te.placeholder) || "Select an option", ne = A && O !== "" && !v.some((k) => k.value === O), Y = o ? Re(o, n) : ne ? `"${j || O}" is no longer an available option` : "", z = Y === "", _ = (k) => {
362
+ r(t, A ? { value: k.raw, label: k.label } : k.value);
363
+ };
364
+ if (y) {
365
+ const k = m ? v.filter((F) => F.label.toLowerCase().includes(T.toLowerCase())) : v, G = Math.min(L, k.length - 1), C = (F) => {
366
+ _(F), f(!1);
367
+ }, J = (F) => {
368
+ F.stopPropagation(), r(t, void 0), w("");
369
+ }, pe = (F) => {
370
+ (F.key === "Enter" || F.key === " ") && J(F);
250
371
  };
251
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
252
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
372
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
373
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
253
374
  n,
254
375
  " ",
255
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
376
+ d && /* @__PURE__ */ l(p, { color: "red", children: "*" })
256
377
  ] }),
257
- /* @__PURE__ */ y("div", { ref: T, style: { position: "relative" }, children: [
258
- /* @__PURE__ */ i(
259
- Ae.Root,
378
+ /* @__PURE__ */ g("div", { ref: N, style: { position: "relative" }, children: [
379
+ /* @__PURE__ */ l(
380
+ Ie.Root,
260
381
  {
261
382
  id: t,
262
- value: h ? g : v,
263
- placeholder: L,
264
- disabled: !a,
265
- style: A ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
266
- onChange: (R) => {
267
- b(R.target.value), O(0), h || p(!0);
383
+ value: m ? T : j,
384
+ placeholder: I,
385
+ disabled: !c,
386
+ style: z ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
387
+ onChange: (F) => {
388
+ w(F.target.value), D(0), m || f(!0);
268
389
  },
269
390
  onFocus: () => {
270
- a && !h && (b(""), O(0), p(!0));
391
+ c && !m && (w(""), D(0), f(!0));
271
392
  },
272
- onKeyDown: (R) => {
273
- R.key === "Escape" ? p(!1) : R.key === "ArrowDown" ? (R.preventDefault(), h ? O((Y) => Math.min(Y + 1, E.length - 1)) : (b(""), p(!0))) : R.key === "ArrowUp" ? (R.preventDefault(), h && O((Y) => Math.max(Y - 1, 0))) : R.key === "Enter" && h && E[B] && (R.preventDefault(), K(E[B]));
393
+ onKeyDown: (F) => {
394
+ F.key === "Escape" ? f(!1) : F.key === "ArrowDown" ? (F.preventDefault(), m ? D((Z) => Math.min(Z + 1, k.length - 1)) : (w(""), f(!0))) : F.key === "ArrowUp" ? (F.preventDefault(), m && D((Z) => Math.max(Z - 1, 0))) : F.key === "Enter" && m && k[G] && (F.preventDefault(), C(k[G]));
274
395
  },
275
- children: /* @__PURE__ */ i(Ae.Slot, { side: "right", children: /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
276
- M && a && /* @__PURE__ */ i(
396
+ children: /* @__PURE__ */ l(Ie.Slot, { side: "right", children: /* @__PURE__ */ g($, { align: "center", gap: "1", children: [
397
+ O && c && /* @__PURE__ */ l(
277
398
  "span",
278
399
  {
279
400
  role: "button",
280
401
  tabIndex: 0,
281
- onMouseDown: (R) => R.preventDefault(),
402
+ onMouseDown: (F) => F.preventDefault(),
282
403
  onClick: J,
283
- onKeyDown: F,
404
+ onKeyDown: pe,
284
405
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
285
406
  "aria-label": "Clear selection",
286
407
  children: "×"
287
408
  }
288
409
  ),
289
- /* @__PURE__ */ i(
290
- Lt,
410
+ /* @__PURE__ */ l(
411
+ qt,
291
412
  {
292
- style: { transform: h ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
413
+ style: { transform: m ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
293
414
  }
294
415
  )
295
416
  ] }) })
296
417
  }
297
418
  ),
298
- h && /* @__PURE__ */ i(
299
- S,
419
+ m && /* @__PURE__ */ l(
420
+ M,
300
421
  {
301
422
  style: {
302
423
  position: "absolute",
@@ -310,273 +431,299 @@ const Ee = (e, r, t, n = void 0) => {
310
431
  border: "1px solid var(--gray-a6)",
311
432
  overflow: "hidden"
312
433
  },
313
- children: /* @__PURE__ */ i(kt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(S, { p: "1", children: [
314
- E.length === 0 && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "No results found." }) }),
315
- E.map((R, Y) => /* @__PURE__ */ i(
316
- S,
434
+ children: /* @__PURE__ */ l(Ht, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(M, { p: "1", children: [
435
+ k.length === 0 && /* @__PURE__ */ l(M, { px: "3", py: "2", children: /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "No results found." }) }),
436
+ k.map((F, Z) => /* @__PURE__ */ l(
437
+ M,
317
438
  {
318
439
  px: "3",
319
440
  py: "2",
320
- onMouseDown: (Q) => Q.preventDefault(),
321
- onClick: () => K(R),
322
- onMouseEnter: () => O(Y),
441
+ onMouseDown: (le) => le.preventDefault(),
442
+ onClick: () => C(F),
443
+ onMouseEnter: () => D(Z),
323
444
  style: {
324
445
  cursor: "pointer",
325
446
  borderRadius: "var(--radius-2)",
326
- backgroundColor: Y === B ? "var(--accent-4)" : R.value === M ? "var(--accent-3)" : void 0
447
+ backgroundColor: Z === G ? "var(--accent-4)" : F.value === O ? "var(--accent-3)" : void 0
327
448
  },
328
- children: /* @__PURE__ */ i(f, { size: "2", children: R.label })
449
+ children: /* @__PURE__ */ l(p, { size: "2", children: F.label })
329
450
  },
330
- R.value
451
+ F.value
331
452
  ))
332
453
  ] }) })
333
454
  }
334
455
  )
335
456
  ] }),
336
- !A && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
337
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
457
+ !z && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Y }),
458
+ s.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: s.description })
338
459
  ] }) });
339
460
  }
340
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
341
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
461
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
462
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
342
463
  n,
343
464
  " ",
344
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
345
- ] }),
346
- /* @__PURE__ */ y(Ke.Root, { value: M, onValueChange: (v) => r(t, v), disabled: !a, children: [
347
- /* @__PURE__ */ i(Ke.Trigger, { placeholder: L, color: A ? void 0 : "red", id: t }),
348
- /* @__PURE__ */ i(Ke.Content, { children: k.map((v) => /* @__PURE__ */ i(Ke.Item, { value: v.value, children: v.label }, v.value)) })
465
+ d && /* @__PURE__ */ l(p, { color: "red", children: "*" })
349
466
  ] }),
350
- !A && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
351
- s.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: s.description })
467
+ /* @__PURE__ */ g(
468
+ Qe.Root,
469
+ {
470
+ value: O,
471
+ onValueChange: (k) => {
472
+ const G = v.find((C) => C.value === k);
473
+ G && _(G);
474
+ },
475
+ disabled: !c,
476
+ children: [
477
+ /* @__PURE__ */ l(Qe.Trigger, { placeholder: I, color: z ? void 0 : "red", id: t, children: A && P ? P : void 0 }),
478
+ /* @__PURE__ */ l(Qe.Content, { children: v.map((k) => /* @__PURE__ */ l(Qe.Item, { value: k.value, children: k.label }, k.value)) })
479
+ ]
480
+ }
481
+ ),
482
+ !z && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Y }),
483
+ s.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: s.description })
352
484
  ] }) });
353
- }, Lr = ee(2, Je(St, Ot)), Mr = ue(Dr), Pt = /\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g, zr = {
354
- today: (e) => zt().format(e || "YYYY-MM-DD")
355
- }, Fr = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint", ft = (e, r) => Object.prototype.hasOwnProperty.call(e, r);
356
- function ot(e, r, t = {}) {
357
- const n = { ...zr, ...t };
358
- return e.replace(Pt, (l, o, s) => {
359
- let c;
485
+ }, cn = ie(2, ot(jt, Vt)), an = ie(
486
+ 3,
487
+ ze((e) => {
488
+ var t;
489
+ if (e.type !== "object" || e["x-search"] !== void 0) return !1;
490
+ const r = (t = e.properties) == null ? void 0 : t.value;
491
+ return Array.isArray(r == null ? void 0 : r.enum) || Array.isArray(r == null ? void 0 : r.oneOf);
492
+ })
493
+ ), Tt = be(ln), Jt = /\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g, un = {
494
+ today: (e) => Kt().format(e || "YYYY-MM-DD")
495
+ }, dn = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint", xt = (e, r) => Object.prototype.hasOwnProperty.call(e, r);
496
+ function it(e, r, t = {}) {
497
+ const n = { ...un, ...t };
498
+ return e.replace(Jt, (i, o, s) => {
499
+ let a;
360
500
  if (s === void 0) {
361
- if (!ft(r, o)) return l;
362
- c = r[o];
501
+ if (!xt(r, o)) return i;
502
+ a = r[o];
363
503
  } else {
364
- if (!ft(n, o)) return l;
504
+ if (!xt(n, o)) return i;
365
505
  try {
366
- c = n[o](s);
506
+ a = n[o](s);
367
507
  } catch {
368
- return l;
508
+ return i;
369
509
  }
370
510
  }
371
- return c == null ? "" : Fr(c) ? String(c) : l;
511
+ return a == null ? "" : dn(a) ? String(a) : i;
372
512
  });
373
513
  }
374
- function it(e) {
514
+ function ht(e) {
375
515
  const r = [];
376
516
  let t = 0;
377
- for (const n of e.matchAll(Pt))
517
+ for (const n of e.matchAll(Jt))
378
518
  n.index > t && r.push(e.slice(t, n.index)), r.push(n[2] === void 0 ? { name: n[1] } : { name: n[1], arg: n[2] }), t = n.index + n[0].length;
379
519
  return t < e.length && r.push(e.slice(t)), r;
380
520
  }
381
- function Ur(e) {
521
+ function fn(e) {
382
522
  if (typeof e == "string" && e.length > 0) return e;
383
523
  if (e && typeof e == "object" && typeof e.value == "string") {
384
524
  const r = e.value;
385
525
  return r.length > 0 ? r : void 0;
386
526
  }
387
527
  }
388
- function Pr(e) {
528
+ function pn(e) {
389
529
  if (typeof e == "string") return e.length > 0 ? { parent: e } : void 0;
390
530
  if (!e || typeof e != "object") return;
391
531
  const r = Object.entries(e);
392
532
  if (r.length === 0) return;
393
533
  const t = {}, n = [];
394
- for (const [l, o] of r)
395
- typeof o == "string" && o.length > 0 ? t[l] = o : n.push(l);
534
+ for (const [i, o] of r)
535
+ typeof o == "string" && o.length > 0 ? t[i] = o : n.push(i);
396
536
  return n.length > 0 && console.warn(`x-search.dependsOn: ignoring invalid entries [${n.join(", ")}]`), Object.keys(t).length === 0 ? (console.warn("x-search.dependsOn: map has no valid entries; search will not fetch until fixed"), {}) : t;
397
537
  }
398
- function $r(e, r, t) {
538
+ function hn(e, r, t) {
399
539
  const n = {};
400
- for (const [l, o] of Object.entries(e))
401
- n[l] = Ur(Ve.data(r, t ? `${t}.${o}` : o));
540
+ for (const [i, o] of Object.entries(e))
541
+ n[i] = fn(He.data(r, t ? `${t}.${o}` : o));
402
542
  return n;
403
543
  }
404
- function pt(e, r) {
405
- return r ? { ...e, name: ot(r, e) } : e;
544
+ function At(e, r) {
545
+ return r ? { ...e, name: it(r, e) } : e;
406
546
  }
407
- const _r = {
547
+ const mn = {
408
548
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
409
549
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
410
550
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
411
- }, Vr = ({
551
+ }, gn = ({
412
552
  data: e,
413
553
  handleChange: r,
414
554
  path: t,
415
555
  label: n,
416
- required: l,
556
+ required: i,
417
557
  errors: o,
418
558
  enabled: s,
419
- visible: c = !0,
420
- schema: a,
421
- uischema: d
559
+ visible: a = !0,
560
+ schema: c,
561
+ uischema: u
422
562
  }) => {
423
- var Xe, pe;
424
- const u = (a == null ? void 0 : a["x-search"]) ?? {
563
+ var Je, Ee;
564
+ const d = (c == null ? void 0 : c["x-search"]) ?? {
425
565
  service: "",
426
566
  displayTemplate: ""
427
- }, h = u.service ?? "", p = u.mode ?? "large-paginated-list", g = _r[p], b = (g == null ? void 0 : g.fetchOnOpen) ?? !1, I = typeof u.displayTemplate == "string" ? u.displayTemplate : "", O = We(), T = t.split(".").slice(0, -1).join("."), { parentValues: A, parentValuesKey: k, missingParent: M } = _e(() => {
428
- var he;
429
- const w = Pr(u.dependsOn);
430
- if (!w) return { parentValues: void 0, parentValuesKey: "", missingParent: !1 };
431
- const Z = $r(w, (he = O.core) == null ? void 0 : he.data, T), ne = Object.keys(Z).length === 0 || Object.values(Z).some((Me) => !Me);
432
- return { parentValues: Z, parentValuesKey: JSON.stringify(Z), missingParent: ne };
433
- }, [u.dependsOn, (Xe = O.core) == null ? void 0 : Xe.data, T]), L = _e(() => A ? { ...u.params, ...A } : u.params, [A, k, u.params]), N = vr(h), U = a.type === "object", z = U ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, v = U ? z == null ? void 0 : z.value : e, E = z == null ? void 0 : z.label, B = h ? N ? g ? I ? null : "x-search.displayTemplate is required." : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${h}" is not registered.` : "Search not configured.", K = s !== !1, J = !o || o.length === 0, [F, R] = j(!1), [Y, Q] = j(""), [be, oe] = j([]), [Se, m] = j(!1), [C, G] = j(!1), [P, _] = j(!1), [re, q] = j(null), [ie, $] = j(void 0), fe = ae(void 0), Oe = ae(null), Pe = ae(null), $e = ae(null), xe = ae(void 0), x = ae(void 0);
434
- de(() => {
435
- if (!A) return;
436
- const w = x.current;
437
- if (x.current = A, !w || !v) return;
438
- Object.keys(A).some((ne) => w[ne] !== void 0 && w[ne] !== A[ne]) && r(t, U ? void 0 : null);
439
- }, [k, v, r, t, U]), de(() => {
440
- var Z, ne;
441
- if (B) {
442
- $(void 0), xe.current = void 0;
567
+ }, y = d.service ?? "", m = d.mode ?? "large-paginated-list", f = mn[m], T = (f == null ? void 0 : f.fetchOnOpen) ?? !1, w = typeof d.displayTemplate == "string" ? d.displayTemplate : "", L = $e(), D = t.split(".").slice(0, -1).join("."), { parentValues: N, parentValuesKey: A, missingParent: R } = Ve(() => {
568
+ var Te;
569
+ const E = pn(d.dependsOn);
570
+ if (!E) return { parentValues: void 0, parentValuesKey: "", missingParent: !1 };
571
+ const re = hn(E, (Te = L.core) == null ? void 0 : Te.data, D), ae = Object.keys(re).length === 0 || Object.values(re).some((Ne) => !Ne);
572
+ return { parentValues: re, parentValuesKey: JSON.stringify(re), missingParent: ae };
573
+ }, [d.dependsOn, (Je = L.core) == null ? void 0 : Je.data, D]), v = Ve(() => N ? { ...d.params, ...N } : d.params, [N, A, d.params]), b = Pr(y), U = c.type === "object", P = U ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, O = U ? P == null ? void 0 : P.value : e, j = P == null ? void 0 : P.label, I = y ? b ? f ? w ? null : "x-search.displayTemplate is required." : `Invalid x-search.mode "${m}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", ne = s !== !1, Y = !o || o.length === 0, [z, _] = B(!1), [ee, fe] = B(""), [oe, te] = B([]), [k, G] = B(!1), [C, J] = B(!1), [pe, F] = B(!1), [Z, le] = B(null), [ye, he] = B(void 0), h = ge(void 0), x = ge(null), V = ge(null), Q = ge(null), X = ge(void 0), me = ge(void 0);
574
+ we(() => {
575
+ if (!N) return;
576
+ const E = me.current;
577
+ if (me.current = N, !E || !O) return;
578
+ Object.keys(N).some((ae) => E[ae] !== void 0 && E[ae] !== N[ae]) && r(t, U ? void 0 : null);
579
+ }, [A, O, r, t, U]), we(() => {
580
+ var Te, Ne;
581
+ if (I) {
582
+ he(void 0), X.current = void 0;
583
+ return;
584
+ }
585
+ if (!O) {
586
+ he(void 0), X.current = void 0;
443
587
  return;
444
588
  }
445
- if (!v) {
446
- $(void 0), xe.current = void 0;
589
+ if (((Te = X.current) == null ? void 0 : Te.value) === O && ((Ne = X.current) == null ? void 0 : Ne.label) === j) return;
590
+ if (U && j) {
591
+ he({ id: O, name: j }), X.current = { value: O, label: j };
447
592
  return;
448
593
  }
449
- if (((Z = xe.current) == null ? void 0 : Z.value) === v && ((ne = xe.current) == null ? void 0 : ne.label) === E) return;
450
- if (xe.current = { value: v, label: E }, U && E) {
451
- $({ id: v, name: E });
594
+ if (he({ id: O, name: j ?? O }), !(b != null && b.resolve)) {
595
+ X.current = { value: O, label: j };
452
596
  return;
453
597
  }
454
- if ($({ id: v, name: E ?? v }), !(N != null && N.resolve)) return;
455
- let w = !1;
456
- return N.resolve(v, L).then((he) => {
457
- !w && he && $(pt(he, I));
598
+ let E = !1;
599
+ const re = O, ae = j;
600
+ return b.resolve(re, v).then((qe) => {
601
+ E || (qe && he(At(qe, w)), X.current = { value: re, label: ae });
458
602
  }).catch(() => {
603
+ E || (X.current = { value: re, label: ae });
459
604
  }), () => {
460
- w = !0;
605
+ E = !0;
461
606
  };
462
- }, [B, v, E, U, N, L, I]);
463
- const V = Fe(
464
- async (w, Z = !1) => {
465
- var he;
466
- if (B) return;
467
- if (!N) {
468
- q("Search service not configured.");
607
+ }, [I, O, j, U, b, v, w]);
608
+ const S = We(
609
+ async (E, re = !1) => {
610
+ var Te;
611
+ if (I) return;
612
+ if (!b) {
613
+ le("Search service not configured.");
469
614
  return;
470
615
  }
471
- (he = Pe.current) == null || he.abort();
472
- const ne = new AbortController();
473
- Pe.current = ne, Z ? _(!0) : (G(!0), _(!1), q(null));
616
+ (Te = V.current) == null || Te.abort();
617
+ const ae = new AbortController();
618
+ V.current = ae, re ? F(!0) : (J(!0), F(!1), le(null));
474
619
  try {
475
- const Me = await N.search({
476
- query: w,
477
- cursor: Z ? fe.current : void 0,
478
- signal: ne.signal,
479
- params: L
620
+ const Ne = await b.search({
621
+ query: E,
622
+ cursor: re ? h.current : void 0,
623
+ signal: ae.signal,
624
+ params: v
480
625
  });
481
- if (ne.signal.aborted) return;
482
- const at = (Me.options ?? []).map((Ze) => pt(Ze, I));
483
- oe(Z ? (Ze) => [...Ze, ...at] : at), fe.current = Me.nextCursor, m(((g == null ? void 0 : g.paginated) ?? !1) && Me.nextCursor != null);
626
+ if (ae.signal.aborted) return;
627
+ const qe = (Ne.options ?? []).map((st) => At(st, w));
628
+ te(re ? (st) => [...st, ...qe] : qe), h.current = Ne.nextCursor, G(((f == null ? void 0 : f.paginated) ?? !1) && Ne.nextCursor != null);
484
629
  } catch {
485
- if (ne.signal.aborted) return;
486
- q("Failed to load results. Please try again.");
630
+ if (ae.signal.aborted) return;
631
+ le("Failed to load results. Please try again.");
487
632
  } finally {
488
- ne.signal.aborted || (Z ? _(!1) : G(!1));
633
+ ae.signal.aborted || (re ? F(!1) : J(!1));
489
634
  }
490
635
  },
491
- [B, N, g == null ? void 0 : g.paginated, L, I]
636
+ [I, b, f == null ? void 0 : f.paginated, v, w]
492
637
  );
493
- if (de(() => {
494
- if (!F) return;
495
- const w = (Z) => {
496
- $e.current && !$e.current.contains(Z.target) && R(!1);
638
+ we(() => {
639
+ if (!z) return;
640
+ const E = (re) => {
641
+ Q.current && !Q.current.contains(re.target) && _(!1);
497
642
  };
498
- return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
499
- }, [F]), de(() => {
500
- var w;
501
- F || ((w = Pe.current) == null || w.abort(), Q(""), oe([]), m(!1), q(null), G(!1), _(!1), fe.current = void 0);
502
- }, [F]), de(() => {
503
- if (!F) return;
504
- if (M) {
505
- oe([]), m(!1), q(null), fe.current = void 0;
643
+ return document.addEventListener("mousedown", E), () => document.removeEventListener("mousedown", E);
644
+ }, [z]), we(() => {
645
+ var E;
646
+ z || ((E = V.current) == null || E.abort(), fe(""), te([]), G(!1), le(null), J(!1), F(!1), h.current = void 0);
647
+ }, [z]), we(() => {
648
+ if (!z) return;
649
+ if (R) {
650
+ te([]), G(!1), le(null), h.current = void 0;
506
651
  return;
507
652
  }
508
- if (!Y && !b) {
509
- oe([]), m(!1), q(null), fe.current = void 0;
653
+ if (!ee && !T) {
654
+ te([]), G(!1), le(null), h.current = void 0;
510
655
  return;
511
656
  }
512
- Oe.current && clearTimeout(Oe.current);
513
- const w = Y ? 300 : 0;
514
- return Oe.current = setTimeout(() => {
515
- oe([]), m(!1), fe.current = void 0, V(Y);
516
- }, w), () => {
517
- Oe.current && clearTimeout(Oe.current);
657
+ x.current && clearTimeout(x.current);
658
+ const E = ee ? 300 : 0;
659
+ return x.current = setTimeout(() => {
660
+ te([]), G(!1), h.current = void 0, S(ee);
661
+ }, E), () => {
662
+ x.current && clearTimeout(x.current);
518
663
  };
519
- }, [Y, F, b, V, M, k]), Ee(c, t, r), c === !1)
664
+ }, [ee, z, T, S, R, A]), Oe(a, t, r);
665
+ const W = Ae(t, i, a);
666
+ if (a === !1)
520
667
  return null;
521
- const se = () => {
522
- Q(""), oe([]), m(!1), q(null), fe.current = void 0, R(!0);
523
- }, X = (w) => {
524
- r(t, U ? { value: w.id, label: w.name } : w.id), $(w), xe.current = { value: w.id, label: U ? w.name : void 0 }, R(!1);
525
- }, H = (w) => {
526
- w.stopPropagation(), r(t, void 0), $(void 0);
527
- }, Re = (w) => {
528
- (w.key === "Enter" || w.key === " ") && H(w);
529
- }, Le = ((pe = d == null ? void 0 : d.options) == null ? void 0 : pe.placeholder) ?? "Select an option";
530
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
531
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
668
+ const ce = () => {
669
+ fe(""), te([]), G(!1), le(null), h.current = void 0, _(!0);
670
+ }, q = (E) => {
671
+ r(t, U ? { value: E.id, label: E.name } : E.id), he(E), X.current = { value: E.id, label: U ? E.name : void 0 }, _(!1);
672
+ }, H = (E) => {
673
+ E.stopPropagation(), r(t, void 0), he(void 0);
674
+ }, ke = (E) => {
675
+ (E.key === "Enter" || E.key === " ") && H(E);
676
+ }, Pe = ((Ee = u == null ? void 0 : u.options) == null ? void 0 : Ee.placeholder) ?? "Select an option";
677
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
678
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
532
679
  n,
533
680
  " ",
534
- l && /* @__PURE__ */ i(f, { color: "red", children: "*" })
681
+ W && /* @__PURE__ */ l(p, { color: "red", children: "*" })
535
682
  ] }),
536
- /* @__PURE__ */ y("div", { ref: $e, style: { position: "relative" }, children: [
537
- /* @__PURE__ */ i(
538
- Ae.Root,
683
+ /* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
684
+ /* @__PURE__ */ l(
685
+ Ie.Root,
539
686
  {
540
687
  id: t,
541
- value: F ? Y : (ie == null ? void 0 : ie.name) ?? "",
542
- placeholder: F && (g != null && g.searchable) ? "Search..." : Le,
543
- disabled: !K,
544
- readOnly: F && !(g != null && g.searchable),
545
- style: J ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
546
- onChange: (w) => {
547
- g != null && g.searchable && (Q(w.target.value), F || se());
688
+ value: z ? ee : (ye == null ? void 0 : ye.name) ?? "",
689
+ placeholder: z && (f != null && f.searchable) ? "Search..." : Pe,
690
+ disabled: !ne,
691
+ readOnly: z && !(f != null && f.searchable),
692
+ style: Y ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
693
+ onChange: (E) => {
694
+ f != null && f.searchable && (fe(E.target.value), z || ce());
548
695
  },
549
696
  onFocus: () => {
550
- K && !F && se();
697
+ ne && !z && ce();
551
698
  },
552
- onKeyDown: (w) => {
553
- w.key === "Escape" && R(!1);
699
+ onKeyDown: (E) => {
700
+ E.key === "Escape" && _(!1);
554
701
  },
555
- children: /* @__PURE__ */ i(Ae.Slot, { side: "right", children: /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
556
- v && K && /* @__PURE__ */ i(
702
+ children: /* @__PURE__ */ l(Ie.Slot, { side: "right", children: /* @__PURE__ */ g($, { align: "center", gap: "1", children: [
703
+ O && ne && /* @__PURE__ */ l(
557
704
  "span",
558
705
  {
559
706
  role: "button",
560
707
  tabIndex: 0,
561
- onMouseDown: (w) => w.preventDefault(),
708
+ onMouseDown: (E) => E.preventDefault(),
562
709
  onClick: H,
563
- onKeyDown: Re,
710
+ onKeyDown: ke,
564
711
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
565
712
  "aria-label": "Clear selection",
566
713
  children: "×"
567
714
  }
568
715
  ),
569
- /* @__PURE__ */ i(
570
- Lt,
716
+ /* @__PURE__ */ l(
717
+ qt,
571
718
  {
572
- style: { transform: F ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
719
+ style: { transform: z ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
573
720
  }
574
721
  )
575
722
  ] }) })
576
723
  }
577
724
  ),
578
- F && /* @__PURE__ */ i(
579
- S,
725
+ z && /* @__PURE__ */ l(
726
+ M,
580
727
  {
581
728
  style: {
582
729
  position: "absolute",
@@ -590,426 +737,543 @@ const _r = {
590
737
  border: "1px solid var(--gray-a6)",
591
738
  overflow: "hidden"
592
739
  },
593
- children: B ? /* @__PURE__ */ i(S, { p: "3", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: B }) }) : /* @__PURE__ */ i(kt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(S, { p: "1", children: [
594
- C && /* @__PURE__ */ i(D, { justify: "center", p: "4", children: /* @__PURE__ */ i(Ue, {}) }),
595
- !C && re && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "red", children: re }) }),
596
- !C && !re && be.length === 0 && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: M ? "Select the related field first." : Y || b ? "No results found." : "Type to search…" }) }),
597
- be.map((w) => /* @__PURE__ */ i(
598
- S,
740
+ children: I ? /* @__PURE__ */ l(M, { p: "3", children: /* @__PURE__ */ l(p, { size: "2", color: "gray", children: I }) }) : /* @__PURE__ */ l(Ht, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(M, { p: "1", children: [
741
+ C && /* @__PURE__ */ l($, { justify: "center", p: "4", children: /* @__PURE__ */ l(Be, {}) }),
742
+ !C && Z && /* @__PURE__ */ l(M, { px: "3", py: "2", children: /* @__PURE__ */ l(p, { size: "2", color: "red", children: Z }) }),
743
+ !C && !Z && oe.length === 0 && /* @__PURE__ */ l(M, { px: "3", py: "2", children: /* @__PURE__ */ l(p, { size: "2", color: "gray", children: R ? "Select the related field first." : ee || T ? "No results found." : "Type to search…" }) }),
744
+ oe.map((E) => /* @__PURE__ */ l(
745
+ M,
599
746
  {
600
747
  px: "3",
601
748
  py: "2",
602
- onMouseDown: (Z) => Z.preventDefault(),
603
- onClick: () => X(w),
749
+ onMouseDown: (re) => re.preventDefault(),
750
+ onClick: () => q(E),
604
751
  style: {
605
752
  cursor: "pointer",
606
753
  borderRadius: "var(--radius-2)",
607
- backgroundColor: w.id === v ? "var(--accent-3)" : void 0
754
+ backgroundColor: E.id === O ? "var(--accent-3)" : void 0
608
755
  },
609
756
  className: "hover:bg-(--gray-3)",
610
- children: /* @__PURE__ */ i(f, { size: "2", children: w.name })
757
+ children: /* @__PURE__ */ l(p, { size: "2", children: E.name })
611
758
  },
612
- w.id
759
+ E.id
613
760
  )),
614
- (g == null ? void 0 : g.paginated) && Se && !P && /* @__PURE__ */ i(S, { px: "3", py: "2", children: /* @__PURE__ */ i(
615
- De,
761
+ (f == null ? void 0 : f.paginated) && k && !pe && /* @__PURE__ */ l(M, { px: "3", py: "2", children: /* @__PURE__ */ l(
762
+ Ue,
616
763
  {
617
764
  variant: "ghost",
618
765
  size: "1",
619
766
  style: { width: "100%" },
620
- onMouseDown: (w) => w.preventDefault(),
621
- onClick: () => void V(Y, !0),
767
+ onMouseDown: (E) => E.preventDefault(),
768
+ onClick: () => void S(ee, !0),
622
769
  children: "Load more"
623
770
  }
624
771
  ) }),
625
- P && /* @__PURE__ */ i(D, { justify: "center", p: "2", children: /* @__PURE__ */ i(Ue, {}) })
772
+ pe && /* @__PURE__ */ l($, { justify: "center", p: "2", children: /* @__PURE__ */ l(Be, {}) })
626
773
  ] }) })
627
774
  }
628
775
  )
629
776
  ] }),
630
- !J && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(o, n) }),
631
- a.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: a.description })
777
+ !Y && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Re(o, n) }),
778
+ c.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: c.description })
632
779
  ] }) });
633
- }, jr = ue(Vr), Hr = ee(
780
+ }, yn = be(gn), bn = ie(
634
781
  3,
635
- Ie((e) => {
782
+ ze((e) => {
636
783
  const r = e["x-search"];
637
784
  return (e.type === "string" || e.type === "object") && typeof (r == null ? void 0 : r.service) == "string" && r.service !== "";
638
785
  })
639
- ), Wr = (e, r) => zt(`${e}T${r}`).format(), Br = ({ path: e, label: r, required: t, errors: n, description: l, children: o }) => {
786
+ ), vn = (e) => {
787
+ if (e)
788
+ return /^\d{2}:\d{2}$/.test(e) ? `${e}:00` : e;
789
+ }, Rt = (e, r) => {
790
+ if (!e) return "";
791
+ const t = e.match(/^(\d{2}:\d{2})(:\d{2})?/);
792
+ return t ? r ? `${t[1]}${t[2] ?? ":00"}` : t[1] : e;
793
+ }, wn = (e, r) => Kt(`${e}T${r}`).format(), En = ({ path: e, label: r, required: t, errors: n, description: i, children: o }) => {
640
794
  const s = n.length === 0;
641
- return /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
642
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
795
+ return /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
796
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
643
797
  r,
644
798
  " ",
645
- t && /* @__PURE__ */ i(f, { color: "red", children: "*" })
799
+ t && /* @__PURE__ */ l(p, { color: "red", children: "*" })
646
800
  ] }),
647
801
  o,
648
- !s && /* @__PURE__ */ i(f, { color: "red", size: "1", children: ye(n, r) }),
649
- l && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: l })
802
+ !s && /* @__PURE__ */ l(p, { color: "red", size: "1", children: Re(n, r) }),
803
+ i && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: i })
650
804
  ] }) });
651
- }, Xr = ({
805
+ }, Tn = ({
652
806
  data: e,
653
807
  handleChange: r,
654
808
  path: t,
655
809
  label: n,
656
- required: l,
810
+ required: i,
657
811
  errors: o,
658
812
  schema: s,
813
+ uischema: a,
659
814
  enabled: c,
660
- visible: a = !0
815
+ visible: u = !0
661
816
  }) => {
662
- if (de(() => {
663
- a === !1 && r(t, void 0);
664
- }, [a, t, r]), a === !1)
817
+ var v;
818
+ we(() => {
819
+ u === !1 && r(t, void 0);
820
+ }, [u, t, r]);
821
+ const d = Ae(t, i, u);
822
+ if (u === !1)
665
823
  return null;
666
- const d = o.length === 0, u = typeof e == "string" ? e : "", h = (T) => /* @__PURE__ */ i(Br, { path: t, label: n, required: l, errors: o, description: s.description, children: T });
824
+ const y = o.length === 0, m = typeof e == "string" ? e : "", f = ((v = a == null ? void 0 : a.options) == null ? void 0 : v.showSeconds) === !0, T = f ? 1 : 60, w = (b) => /* @__PURE__ */ l(En, { path: t, label: n, required: d, errors: o, description: s.description, children: b });
667
825
  if (s.format === "time")
668
- return h(
669
- /* @__PURE__ */ i(
670
- Ae.Root,
826
+ return w(
827
+ /* @__PURE__ */ l(
828
+ Ie.Root,
671
829
  {
672
830
  type: "time",
673
- value: u,
674
- onChange: (T) => r(t, T.target.value),
831
+ step: T,
832
+ value: Rt(m, f),
833
+ onChange: (b) => r(t, vn(b.target.value)),
675
834
  disabled: !c,
676
- color: d ? void 0 : "red",
835
+ color: y ? void 0 : "red",
677
836
  id: t
678
837
  }
679
838
  )
680
839
  );
681
- const p = s.format === "date-time", [g = "", b = ""] = u.split("T"), I = b.slice(0, 5), O = (T, A) => {
682
- if (!T) {
840
+ const L = s.format === "date-time", [D = "", N = ""] = m.split("T"), A = Rt(N, f), R = (b, U) => {
841
+ if (!b) {
683
842
  r(t, void 0);
684
843
  return;
685
844
  }
686
- r(t, p ? Wr(T, A || "00:00") : T);
845
+ r(t, L ? wn(b, U || "00:00") : b);
687
846
  };
688
- return h(
689
- /* @__PURE__ */ y(D, { gap: "2", align: "center", children: [
690
- /* @__PURE__ */ i(
691
- Ae.Root,
847
+ return w(
848
+ /* @__PURE__ */ g($, { gap: "2", align: "center", children: [
849
+ /* @__PURE__ */ l(
850
+ Ie.Root,
692
851
  {
693
852
  type: "date",
694
- value: g,
853
+ value: D,
695
854
  disabled: !c,
696
- color: d ? void 0 : "red",
697
- onChange: (T) => O(T.target.value, I),
855
+ color: y ? void 0 : "red",
856
+ onChange: (b) => R(b.target.value, A),
698
857
  id: t,
699
858
  style: { flex: 1 }
700
859
  }
701
860
  ),
702
- p && /* @__PURE__ */ i(
703
- Ae.Root,
861
+ L && /* @__PURE__ */ l(
862
+ Ie.Root,
704
863
  {
705
864
  type: "time",
706
- value: I,
707
- disabled: !c || !g,
708
- color: d ? void 0 : "red",
709
- onChange: (T) => O(g, T.target.value),
865
+ step: T,
866
+ value: A,
867
+ disabled: !c || !D,
868
+ color: y ? void 0 : "red",
869
+ onChange: (b) => R(D, b.target.value),
710
870
  style: { flex: 1 }
711
871
  }
712
872
  )
713
873
  ] })
714
874
  );
715
- }, Kr = ee(2, Je(nr, or, ir)), Yr = ue(Xr), Gr = ({
875
+ }, xn = ie(2, ot(xr, Ar, Rr)), An = be(Tn), Rn = ({
716
876
  uischema: e,
717
877
  schema: r,
718
878
  path: t,
719
879
  renderers: n,
720
- cells: l,
880
+ cells: i,
721
881
  enabled: o,
722
882
  visible: s = !0
723
883
  }) => {
724
- const a = e.elements;
725
- return s === !1 ? null : /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(
726
- Be,
884
+ const c = e.elements;
885
+ return s === !1 ? null : /* @__PURE__ */ l($, { direction: "column", gap: "4", children: c.map((u, d) => /* @__PURE__ */ l(
886
+ Ge,
727
887
  {
728
- uischema: d,
888
+ uischema: u,
729
889
  schema: r,
730
890
  path: t,
731
891
  renderers: n,
732
- cells: l,
892
+ cells: i,
733
893
  enabled: o
734
894
  },
735
- `${t}-${u}`
895
+ `${t}-${d}`
736
896
  )) });
737
- }, qr = ee(1, He("VerticalLayout")), Jr = ({
897
+ }, Cn = ie(1, Ye("VerticalLayout")), Sn = ({
738
898
  uischema: e,
739
899
  schema: r,
740
900
  path: t,
741
901
  renderers: n,
742
- cells: l,
902
+ cells: i,
743
903
  enabled: o,
744
904
  visible: s = !0
745
905
  }) => {
746
- const a = e.elements;
747
- return s === !1 ? null : /* @__PURE__ */ i(D, { direction: "row", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(S, { style: { flex: 1 }, children: /* @__PURE__ */ i(
748
- Be,
906
+ const c = e.elements;
907
+ return s === !1 ? null : /* @__PURE__ */ l($, { direction: "row", gap: "4", children: c.map((u, d) => /* @__PURE__ */ l(M, { style: { flex: 1 }, children: /* @__PURE__ */ l(
908
+ Ge,
749
909
  {
750
- uischema: d,
910
+ uischema: u,
751
911
  schema: r,
752
912
  path: t,
753
913
  renderers: n,
754
- cells: l,
914
+ cells: i,
755
915
  enabled: o
756
916
  }
757
- ) }, `${t}-${u}`)) });
758
- }, Zr = ee(1, He("HorizontalLayout")), Qr = ({
917
+ ) }, `${t}-${d}`)) });
918
+ }, On = ie(1, Ye("HorizontalLayout")), Nn = ({
759
919
  uischema: e,
760
920
  schema: r,
761
921
  path: t,
762
922
  renderers: n,
763
- cells: l,
923
+ cells: i,
764
924
  enabled: o,
765
925
  visible: s = !0
766
926
  }) => {
767
- const c = e, a = c.elements;
768
- return s === !1 ? null : /* @__PURE__ */ y(S, { mb: "6", children: [
769
- c.label && /* @__PURE__ */ i(It, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: c.label }),
770
- /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: a.map((d, u) => /* @__PURE__ */ i(
771
- Be,
927
+ const a = e, c = a.elements;
928
+ return s === !1 ? null : /* @__PURE__ */ g(M, { mb: "6", children: [
929
+ a.label && /* @__PURE__ */ l(Bt, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: a.label }),
930
+ /* @__PURE__ */ l($, { direction: "column", gap: "4", children: c.map((u, d) => /* @__PURE__ */ l(
931
+ Ge,
772
932
  {
773
- uischema: d,
933
+ uischema: u,
774
934
  schema: r,
775
935
  path: t,
776
936
  renderers: n,
777
- cells: l,
937
+ cells: i,
778
938
  enabled: o
779
939
  },
780
- `${t}-${u}`
940
+ `${t}-${d}`
781
941
  )) })
782
942
  ] });
783
- }, en = ee(1, He("Group")), tn = ({
943
+ }, Dn = ie(1, Ye("Group")), In = ({
784
944
  uischema: e,
785
945
  schema: r,
786
946
  path: t,
787
947
  renderers: n,
788
- cells: l,
948
+ cells: i,
789
949
  enabled: o,
790
950
  visible: s = !0
791
951
  }) => {
792
- var p;
793
- const a = e.elements.filter((g) => g.type === "Category"), [d, u] = j(((p = a[0]) == null ? void 0 : p.label) || "");
794
- if (s === !1 || !a.length) return null;
795
- const h = a.find((g) => g.label === d) ? d : a[0].label;
796
- return /* @__PURE__ */ y(Ye.Root, { value: h, onValueChange: u, children: [
797
- /* @__PURE__ */ i(Ye.List, { children: a.map((g, b) => /* @__PURE__ */ i(Ye.Trigger, { value: g.label, children: g.label }, `${t}-${b}`)) }),
798
- /* @__PURE__ */ i(S, { pt: "3", children: a.map((g, b) => /* @__PURE__ */ i(Ye.Content, { value: g.label, children: /* @__PURE__ */ i(D, { direction: "column", gap: "4", children: g.elements.map((I, O) => /* @__PURE__ */ i(
799
- Be,
952
+ var m;
953
+ const c = e.elements.filter((f) => f.type === "Category"), [u, d] = B(((m = c[0]) == null ? void 0 : m.label) || "");
954
+ if (s === !1 || !c.length) return null;
955
+ const y = c.find((f) => f.label === u) ? u : c[0].label;
956
+ return /* @__PURE__ */ g(et.Root, { value: y, onValueChange: d, children: [
957
+ /* @__PURE__ */ l(et.List, { children: c.map((f, T) => /* @__PURE__ */ l(et.Trigger, { value: f.label, children: f.label }, `${t}-${T}`)) }),
958
+ /* @__PURE__ */ l(M, { pt: "3", children: c.map((f, T) => /* @__PURE__ */ l(et.Content, { value: f.label, children: /* @__PURE__ */ l($, { direction: "column", gap: "4", children: f.elements.map((w, L) => /* @__PURE__ */ l(
959
+ Ge,
800
960
  {
801
- uischema: I,
961
+ uischema: w,
802
962
  schema: r,
803
963
  path: t,
804
964
  renderers: n,
805
- cells: l,
965
+ cells: i,
806
966
  enabled: o
807
967
  },
808
- `${t}-${b}-${O}`
809
- )) }) }, `${t}-${b}`)) })
968
+ `${t}-${T}-${L}`
969
+ )) }) }, `${t}-${T}`)) })
810
970
  ] });
811
- }, rn = ee(1, He("Categorization"));
812
- function ve(e) {
971
+ }, kn = ie(1, Ye("Categorization"));
972
+ function Ce(e) {
813
973
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
814
974
  }
815
- function we(e) {
816
- const r = e.split(",").map((o) => o.trim()).filter(Boolean), t = r.filter((o) => o.startsWith(".")), l = (t.length > 0 ? t : r).map((o) => {
975
+ function Se(e) {
976
+ const r = e.split(",").map((o) => o.trim()).filter(Boolean), t = r.filter((o) => o.startsWith(".")), i = (t.length > 0 ? t : r).map((o) => {
817
977
  if (o.endsWith("/*")) return o.split("/")[0].toUpperCase() + "S";
818
978
  if (o.startsWith(".")) return o.slice(1).toUpperCase();
819
979
  const s = o.split("/")[1];
820
980
  return s ? s.toUpperCase() : o;
821
981
  });
822
- return [...new Set(l)].join(", ");
982
+ return [...new Set(i)].join(", ");
823
983
  }
824
- function nn(e) {
984
+ const Ln = "image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";
985
+ function Zt(e, r) {
986
+ return r.split(",").map((n) => n.trim()).filter(Boolean).some((n) => n === "*" || n === "*/*" ? !0 : n.endsWith("/*") ? (e.type ?? "").startsWith(n.slice(0, -1)) : n.startsWith(".") ? e.name.toLowerCase().endsWith(n.toLowerCase()) : e.type === n);
987
+ }
988
+ function Mn(e) {
989
+ const r = !!e.type, t = ct(e.name) !== void 0;
990
+ return !r && !t ? !0 : Zt(e, Ln);
991
+ }
992
+ function ct(e) {
993
+ const r = e.split(/[/\\]/).pop() ?? e, t = r.lastIndexOf(".");
994
+ if (!(t <= 0 || t === r.length - 1))
995
+ return r.slice(t);
996
+ }
997
+ function zn(e, r, t) {
998
+ Qt(new Blob([e], { type: t }), r);
999
+ }
1000
+ function Qt(e, r) {
1001
+ const t = URL.createObjectURL(e), n = document.createElement("a");
1002
+ n.href = t, n.download = r, n.click(), setTimeout(() => URL.revokeObjectURL(t), 0);
1003
+ }
1004
+ async function Fn(e, r) {
1005
+ const t = await fetch(e);
1006
+ if (!t.ok) throw new Error(`Download failed (${t.status})`);
1007
+ Qt(await t.blob(), r);
1008
+ }
1009
+ function $n(e, r, t) {
1010
+ const n = t.name || t.key;
1011
+ if (!e) return n;
1012
+ const i = mt(e, r, n), o = ct(t.name ?? "") ?? ct(t.key);
1013
+ return !o || i.toLowerCase().endsWith(o.toLowerCase()) ? i : `${i}${o}`;
1014
+ }
1015
+ const Un = /* @__PURE__ */ new Set(["/", "\\", "<", ">", ":", '"', "|", "?", "*"]), Pn = (e) => Un.has(e) || e.charCodeAt(0) < 32 || e.charCodeAt(0) === 127;
1016
+ function _n(e, r) {
1017
+ const t = Array.from(e, (n) => Pn(n) ? "_" : n).join("").trim();
1018
+ return t === "" || t.startsWith(".") ? r : t;
1019
+ }
1020
+ function mt(e, r, t) {
1021
+ const n = r !== null && typeof r == "object" && !Array.isArray(r) ? r : {};
1022
+ return _n(it(e, n), t);
1023
+ }
1024
+ function jn(e) {
825
1025
  return e ? Array.isArray(e) ? e : [e] : [];
826
1026
  }
827
- const on = ({
1027
+ const Vn = ({
828
1028
  data: e,
829
1029
  handleChange: r,
830
1030
  path: t,
831
1031
  label: n,
832
- required: l,
1032
+ required: i,
833
1033
  uischema: o,
834
1034
  schema: s,
835
- enabled: c,
836
- errors: a,
837
- visible: d = !0
1035
+ enabled: a,
1036
+ errors: c,
1037
+ visible: u = !0
838
1038
  }) => {
839
- const u = br();
840
- Ee(d, t, r);
841
- const h = !a || a.length === 0, p = (s == null ? void 0 : s["x-file"]) ?? {}, g = (o == null ? void 0 : o.options) ?? {}, b = p.maxFiles ?? g.maxFiles ?? 1, I = p.maxSize ?? g.maxSize ?? 5 * 1024 * 1024, O = p.accept ?? g.accept ?? "image/*,application/pdf", T = b > 1, A = c !== !1, [k, M] = j(!1), [L, N] = j(null), [U, z] = j({}), v = ae(/* @__PURE__ */ new Set()), E = ae(null), B = nn(e), K = B.length >= b;
842
- de(() => () => {
843
- v.current.forEach((m) => URL.revokeObjectURL(m)), v.current.clear();
1039
+ const d = Ur();
1040
+ Oe(u, t, r);
1041
+ const y = Ae(t, i, u), m = !c || c.length === 0, f = (s == null ? void 0 : s["x-file"]) ?? {}, T = (o == null ? void 0 : o.options) ?? {}, w = f.maxFiles ?? T.maxFiles ?? 1, L = f.maxSize ?? T.maxSize ?? 5 * 1024 * 1024, D = f.accept ?? T.accept ?? "image/*,application/pdf", N = typeof f.fileName == "string" ? f.fileName : void 0, A = w > 1, R = a !== !1, [v, b] = B(!1), [U, P] = B(null), [O, j] = B({}), [I, ne] = B({}), Y = ge(/* @__PURE__ */ new Set()), z = ge(null), _ = jn(e), ee = _.length >= w, fe = (h) => {
1042
+ const x = I[h];
1043
+ return { name: (x == null ? void 0 : x.name) ?? h, type: x == null ? void 0 : x.type };
1044
+ }, oe = async (h) => {
1045
+ var Q, X;
1046
+ const x = (Q = I[h]) == null ? void 0 : Q.blobUrl;
1047
+ if (x) return x;
1048
+ const V = await ((X = d == null ? void 0 : d.getDownloadUrl) == null ? void 0 : X.call(d, h));
1049
+ return V == null ? void 0 : V.url;
1050
+ }, te = (h, x) => {
1051
+ j((V) => ({ ...V, [h]: x }));
1052
+ }, k = (h) => {
1053
+ j((x) => {
1054
+ if (!x[h]) return x;
1055
+ const V = { ...x };
1056
+ return delete V[h], V;
1057
+ });
1058
+ };
1059
+ we(() => () => {
1060
+ Y.current.forEach((h) => URL.revokeObjectURL(h)), Y.current.clear();
844
1061
  }, []);
845
- const J = Fe(
846
- async (m) => {
847
- if (N(null), B.length >= b) {
848
- N(`Maximum ${b} file${b > 1 ? "s" : ""} allowed.`);
1062
+ const G = We(
1063
+ async (h) => {
1064
+ if (P(null), _.length >= w) {
1065
+ P(`Maximum ${w} file${w > 1 ? "s" : ""} allowed.`);
849
1066
  return;
850
1067
  }
851
- if (m.size > I) {
852
- N(`File exceeds the ${ve(I)} limit.`);
1068
+ if (h.size > L) {
1069
+ P(`File exceeds the ${Ce(L)} limit.`);
853
1070
  return;
854
1071
  }
855
- if (!O.split(",").map((P) => P.trim()).some((P) => P === "*" || P === "*/*" ? !0 : P.endsWith("/*") ? m.type.startsWith(P.slice(0, -1)) : P.startsWith(".") ? m.name.toLowerCase().endsWith(P.toLowerCase()) : m.type === P)) {
856
- N(`Invalid type. Accepted: ${we(O)}`);
1072
+ if (!Zt(h, D)) {
1073
+ P(`Invalid type. Accepted: ${Se(D)}`);
857
1074
  return;
858
1075
  }
859
- if (!(u != null && u.onUpload)) {
860
- N("Upload service not configured.");
1076
+ if (!(d != null && d.onUpload)) {
1077
+ P("Upload service not configured.");
861
1078
  return;
862
1079
  }
863
1080
  try {
864
- const P = await u.onUpload(m), _ = URL.createObjectURL(m);
865
- v.current.add(_);
866
- const re = { key: P.key, name: P.name ?? m.name, blobUrl: _ };
867
- z((ie) => ({ ...ie, [P.key]: re }));
868
- const q = [...B, P.key];
869
- r(t, T ? q : q[0]);
1081
+ const x = await d.onUpload(h), V = URL.createObjectURL(h);
1082
+ Y.current.add(V);
1083
+ const Q = {
1084
+ key: x.key,
1085
+ name: x.name ?? h.name,
1086
+ type: h.type || void 0,
1087
+ blobUrl: V
1088
+ };
1089
+ ne((me) => ({ ...me, [x.key]: Q }));
1090
+ const X = [..._, x.key];
1091
+ r(t, A ? X : X[0]);
870
1092
  } catch {
871
- N("Upload failed. Please try again."), E.current && (E.current.value = "");
1093
+ P("Upload failed. Please try again."), z.current && (z.current.value = "");
872
1094
  }
873
1095
  },
874
- [B, b, I, O, u, t, r, T]
1096
+ [_, w, L, D, d, t, r, A]
875
1097
  );
876
- if (d === !1)
1098
+ if (u === !1)
877
1099
  return null;
878
- const F = (m) => {
879
- m.preventDefault(), m.stopPropagation(), !(!A || K) && M(m.type === "dragenter" || m.type === "dragover");
880
- }, R = (m) => {
881
- var C;
882
- m.preventDefault(), m.stopPropagation(), M(!1), !(!A || K) && (C = m.dataTransfer.files) != null && C[0] && J(m.dataTransfer.files[0]);
883
- }, Y = (m) => {
884
- var C;
885
- (C = m.target.files) != null && C[0] && (J(m.target.files[0]), m.target.value = "");
886
- }, Q = (m) => {
887
- if (!A) return;
888
- z((G) => {
889
- var re;
890
- const P = { ...G }, _ = (re = P[m]) == null ? void 0 : re.blobUrl;
891
- return _ && (URL.revokeObjectURL(_), v.current.delete(_)), delete P[m], P;
892
- });
893
- const C = B.filter((G) => G !== m);
894
- r(t, T ? C.length > 0 ? C : void 0 : C[0]);
895
- }, be = async (m, C) => {
896
- var _, re, q;
897
- m.preventDefault();
898
- const G = (_ = U[C]) == null ? void 0 : _.blobUrl;
899
- if (G) {
900
- (re = window.open(G, "_blank", "noopener,noreferrer")) == null || re.focus();
1100
+ const C = (h) => {
1101
+ h.preventDefault(), h.stopPropagation(), !(!R || ee) && b(h.type === "dragenter" || h.type === "dragover");
1102
+ }, J = (h) => {
1103
+ var x;
1104
+ h.preventDefault(), h.stopPropagation(), b(!1), !(!R || ee) && (x = h.dataTransfer.files) != null && x[0] && G(h.dataTransfer.files[0]);
1105
+ }, pe = (h) => {
1106
+ var x;
1107
+ (x = h.target.files) != null && x[0] && (G(h.target.files[0]), h.target.value = "");
1108
+ }, F = (h) => {
1109
+ if (!R) return;
1110
+ ne((V) => {
1111
+ var me;
1112
+ const Q = { ...V }, X = (me = Q[h]) == null ? void 0 : me.blobUrl;
1113
+ return X && (URL.revokeObjectURL(X), Y.current.delete(X)), delete Q[h], Q;
1114
+ }), k(h);
1115
+ const x = _.filter((V) => V !== h);
1116
+ r(t, A ? x.length > 0 ? x : void 0 : x[0]);
1117
+ }, Z = async (h, x) => {
1118
+ var X, me;
1119
+ h.preventDefault(), k(x);
1120
+ const V = (X = I[x]) == null ? void 0 : X.blobUrl;
1121
+ if (V) {
1122
+ (me = window.open(V, "_blank", "noopener,noreferrer")) == null || me.focus();
901
1123
  return;
902
1124
  }
903
- const P = window.open("", "_blank");
904
- if (P)
1125
+ const Q = window.open("", "_blank");
1126
+ if (Q)
905
1127
  try {
906
- const ie = await ((q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : q.call(u, C));
907
- ie != null && ie.url ? P.location.href = ie.url : P.close();
1128
+ const S = await oe(x);
1129
+ S ? Q.location.href = S : (Q.close(), te(x, "Unable to open file."));
908
1130
  } catch {
909
- P.close();
1131
+ Q.close(), te(x, "Unable to open file.");
1132
+ }
1133
+ }, le = async (h, x) => {
1134
+ k(h);
1135
+ try {
1136
+ const V = await oe(h);
1137
+ if (!V) {
1138
+ te(h, "Unable to download file.");
1139
+ return;
910
1140
  }
1141
+ await Fn(V, x);
1142
+ } catch {
1143
+ te(h, "Unable to download file.");
1144
+ }
911
1145
  };
912
- if (!A && B.length === 0) return null;
913
- const oe = b - B.length, Se = A && !K;
914
- return /* @__PURE__ */ y(S, { mb: "4", children: [
915
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
916
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
1146
+ if (!R && _.length === 0) return null;
1147
+ const ye = w - _.length, he = R && !ee;
1148
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
1149
+ /* @__PURE__ */ g($, { align: "center", justify: "between", mb: "2", children: [
1150
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", children: [
917
1151
  n,
918
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
1152
+ y && /* @__PURE__ */ l(p, { color: "red", children: " *" })
919
1153
  ] }),
920
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: T ? `Up to ${b} files · ${ve(I)} each · ${we(O)}` : `${ve(I)} · ${we(O)}` })
1154
+ /* @__PURE__ */ l(p, { size: "1", color: "gray", children: A ? `Up to ${w} files · ${Ce(L)} each · ${Se(D)}` : `${Ce(L)} · ${Se(D)}` })
921
1155
  ] }),
922
- B.map((m) => {
923
- var C;
924
- return /* @__PURE__ */ i(Dt, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ y(D, { align: "center", gap: "3", children: [
925
- /* @__PURE__ */ i(
926
- S,
927
- {
928
- style: {
929
- background: "var(--blue-3)",
930
- padding: 8,
931
- borderRadius: 6,
932
- color: "var(--blue-9)",
933
- flexShrink: 0
934
- },
935
- children: /* @__PURE__ */ i(hr, { width: "20", height: "20" })
936
- }
937
- ),
938
- /* @__PURE__ */ i(S, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ i(
939
- f,
940
- {
941
- size: "2",
942
- weight: "bold",
943
- style: {
944
- display: "block",
945
- overflow: "hidden",
946
- textOverflow: "ellipsis",
947
- whiteSpace: "nowrap"
948
- },
949
- children: ((C = U[m]) == null ? void 0 : C.name) ?? "Uploaded File"
950
- }
951
- ) }),
952
- /* @__PURE__ */ y(D, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
953
- /* @__PURE__ */ i(De, { variant: "soft", color: "blue", size: "1", onClick: (G) => be(G, m), children: "View" }),
954
- /* @__PURE__ */ i(mr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
955
- A && /* @__PURE__ */ i(je, { variant: "ghost", color: "gray", onClick: () => Q(m), children: /* @__PURE__ */ i(rt, {}) })
956
- ] })
957
- ] }) }, m);
1156
+ _.map((h, x) => {
1157
+ var q;
1158
+ const V = x + 1, Q = (q = I[h]) == null ? void 0 : q.name, X = $n(N, { index: V }, { name: Q, key: h }), me = N ? X : Q ?? "Uploaded File", S = !!(N && Q), W = O[h], ce = Mn(fe(h));
1159
+ return /* @__PURE__ */ g(Xt, { size: "2", variant: "surface", mb: "2", children: [
1160
+ /* @__PURE__ */ g($, { align: "center", gap: "3", children: [
1161
+ /* @__PURE__ */ l(
1162
+ M,
1163
+ {
1164
+ style: {
1165
+ background: "var(--blue-3)",
1166
+ padding: 8,
1167
+ borderRadius: 6,
1168
+ color: "var(--blue-9)",
1169
+ flexShrink: 0
1170
+ },
1171
+ children: /* @__PURE__ */ l(Mr, { width: "20", height: "20" })
1172
+ }
1173
+ ),
1174
+ /* @__PURE__ */ g(M, { style: { flex: 1, overflow: "hidden" }, children: [
1175
+ /* @__PURE__ */ l(
1176
+ p,
1177
+ {
1178
+ size: "2",
1179
+ weight: "bold",
1180
+ style: {
1181
+ display: "block",
1182
+ overflow: "hidden",
1183
+ textOverflow: "ellipsis",
1184
+ whiteSpace: "nowrap"
1185
+ },
1186
+ children: me
1187
+ }
1188
+ ),
1189
+ S && /* @__PURE__ */ l(
1190
+ p,
1191
+ {
1192
+ size: "1",
1193
+ color: "gray",
1194
+ style: {
1195
+ display: "block",
1196
+ overflow: "hidden",
1197
+ textOverflow: "ellipsis",
1198
+ whiteSpace: "nowrap"
1199
+ },
1200
+ children: Q
1201
+ }
1202
+ )
1203
+ ] }),
1204
+ /* @__PURE__ */ g($, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
1205
+ ce && /* @__PURE__ */ l(Ue, { variant: "soft", color: "blue", size: "1", onClick: (H) => void Z(H, h), children: "View" }),
1206
+ /* @__PURE__ */ l(Ke, { content: "Download", children: /* @__PURE__ */ l(
1207
+ Xe,
1208
+ {
1209
+ variant: "ghost",
1210
+ color: "gray",
1211
+ "aria-label": "Download",
1212
+ onClick: () => void le(h, X),
1213
+ children: /* @__PURE__ */ l(dt, {})
1214
+ }
1215
+ ) }),
1216
+ /* @__PURE__ */ l(zr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
1217
+ R && /* @__PURE__ */ l(Xe, { variant: "ghost", color: "gray", onClick: () => F(h), children: /* @__PURE__ */ l(ft, {}) })
1218
+ ] })
1219
+ ] }),
1220
+ W && /* @__PURE__ */ l(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: W })
1221
+ ] }, h);
958
1222
  }),
959
- Se && /* @__PURE__ */ y(
1223
+ he && /* @__PURE__ */ g(
960
1224
  "div",
961
1225
  {
962
1226
  role: "button",
963
1227
  tabIndex: 0,
964
1228
  onClick: () => {
965
- var m;
966
- return (m = E.current) == null ? void 0 : m.click();
1229
+ var h;
1230
+ return (h = z.current) == null ? void 0 : h.click();
967
1231
  },
968
- onKeyDown: (m) => {
969
- var C;
970
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), (C = E.current) == null || C.click());
1232
+ onKeyDown: (h) => {
1233
+ var x;
1234
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = z.current) == null || x.click());
971
1235
  },
972
- onDragEnter: F,
973
- onDragLeave: F,
974
- onDragOver: F,
975
- onDrop: R,
1236
+ onDragEnter: C,
1237
+ onDragLeave: C,
1238
+ onDragOver: C,
1239
+ onDrop: J,
976
1240
  style: { cursor: "pointer" },
977
1241
  className: [
978
1242
  "border-2 border-dashed rounded-lg p-6 text-center",
979
1243
  "transition-all duration-200 ease-in-out",
980
- k ? "border-blue-500 bg-blue-50" : L ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1244
+ v ? "border-blue-500 bg-blue-50" : U ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
981
1245
  ].join(" "),
982
1246
  children: [
983
- /* @__PURE__ */ i("input", { ref: E, type: "file", style: { display: "none" }, accept: O, onChange: Y }),
984
- /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: L ? /* @__PURE__ */ y(ge, { children: [
985
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
986
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: L }),
987
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
988
- ] }) : /* @__PURE__ */ y(ge, { children: [
989
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
990
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: B.length > 0 ? `Add another file (${oe} remaining)` : "Click to upload or drag and drop" }),
991
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
992
- ve(I),
1247
+ /* @__PURE__ */ l("input", { ref: z, type: "file", style: { display: "none" }, accept: D, onChange: pe }),
1248
+ /* @__PURE__ */ l($, { direction: "column", align: "center", gap: "2", children: U ? /* @__PURE__ */ g(xe, { children: [
1249
+ /* @__PURE__ */ l(pt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1250
+ /* @__PURE__ */ l(p, { size: "2", color: "red", weight: "medium", children: U }),
1251
+ /* @__PURE__ */ l(p, { size: "1", color: "gray", children: "Click to try again" })
1252
+ ] }) : /* @__PURE__ */ g(xe, { children: [
1253
+ /* @__PURE__ */ l(je, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1254
+ /* @__PURE__ */ l(p, { size: "2", weight: "medium", children: _.length > 0 ? `Add another file (${ye} remaining)` : "Click to upload or drag and drop" }),
1255
+ /* @__PURE__ */ g(p, { size: "1", color: "gray", children: [
1256
+ Ce(L),
993
1257
  " max · ",
994
- we(O)
1258
+ Se(D)
995
1259
  ] })
996
1260
  ] }) })
997
1261
  ]
998
1262
  }
999
1263
  ),
1000
- A && K && T && /* @__PURE__ */ y(f, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
1264
+ R && ee && A && /* @__PURE__ */ g(p, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
1001
1265
  "Maximum ",
1002
- b,
1266
+ w,
1003
1267
  " files uploaded. Remove one to replace it."
1004
1268
  ] }),
1005
- !h && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
1269
+ !m && /* @__PURE__ */ l(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: Re(c, n) })
1006
1270
  ] });
1007
- }, sn = ue(on), ln = ee(
1271
+ }, Wn = be(Vn), Hn = ie(
1008
1272
  10,
1009
1273
  // high rank to beat default array renderer
1010
- Nt(
1274
+ Wt(
1011
1275
  // Match both single-file (type: string) and multi-file (type: array)
1012
- Ie((e) => {
1276
+ ze((e) => {
1013
1277
  if (e.type === "string" && e.format === "file") return !0;
1014
1278
  if (e.type === "array") {
1015
1279
  const r = e.items;
@@ -1019,27 +1283,27 @@ const on = ({
1019
1283
  })
1020
1284
  )
1021
1285
  );
1022
- function $t(e, r) {
1286
+ function er(e, r) {
1023
1287
  return e !== !1 && r !== !0;
1024
1288
  }
1025
- class et extends Error {
1289
+ class at extends Error {
1026
1290
  }
1027
- async function cn(e, r) {
1028
- const { read: t, utils: n } = await import("@e965/xlsx"), l = t(e, { type: "array", cellDates: !0 });
1029
- if (l.SheetNames.length === 0)
1030
- throw new et("This file has no sheets.");
1031
- const o = r ?? l.SheetNames[0], s = l.Sheets[o];
1291
+ async function Bn(e, r) {
1292
+ const { read: t, utils: n } = await import("@e965/xlsx"), i = t(e, { type: "array", cellDates: !0 });
1293
+ if (i.SheetNames.length === 0)
1294
+ throw new at("This file has no sheets.");
1295
+ const o = r ?? i.SheetNames[0], s = i.Sheets[o];
1032
1296
  if (!s)
1033
- throw new et(`This file doesn't have a sheet named "${o}".`);
1034
- const c = n.sheet_to_json(s, { header: 1, raw: !0, defval: null });
1297
+ throw new at(`This file doesn't have a sheet named "${o}".`);
1298
+ const a = n.sheet_to_json(s, { header: 1, raw: !0, defval: null });
1035
1299
  return {
1036
1300
  sheetName: o,
1037
- matrix: c,
1038
- rowCount: c.length,
1039
- colCount: Math.max(0, ...c.map((a) => a.length))
1301
+ matrix: a,
1302
+ rowCount: a.length,
1303
+ colCount: Math.max(0, ...a.map((c) => c.length))
1040
1304
  };
1041
1305
  }
1042
- function an(e) {
1306
+ function Xn(e) {
1043
1307
  let r = e + 1, t = "";
1044
1308
  for (; r > 0; ) {
1045
1309
  const n = (r - 1) % 26;
@@ -1047,14 +1311,14 @@ function an(e) {
1047
1311
  }
1048
1312
  return t;
1049
1313
  }
1050
- class ce extends Error {
1314
+ class de extends Error {
1051
1315
  constructor(t, n) {
1052
1316
  super(n ?? t);
1053
- ut(this, "code");
1317
+ vt(this, "code");
1054
1318
  this.code = t, this.name = "FormulaError";
1055
1319
  }
1056
1320
  }
1057
- const un = [
1321
+ const qn = [
1058
1322
  // Logical
1059
1323
  // IF is excluded here even though its native body is real, non-stub code —
1060
1324
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -1080,7 +1344,7 @@ const un = [
1080
1344
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
1081
1345
  "DATE",
1082
1346
  "TODAY"
1083
- ], dn = [
1347
+ ], Kn = [
1084
1348
  "MAX",
1085
1349
  "MIN",
1086
1350
  "MAXA",
@@ -1099,7 +1363,7 @@ const un = [
1099
1363
  "COUNTA",
1100
1364
  // not present in fast-formula-parser's function table at all.
1101
1365
  "UPPER"
1102
- ], fn = ["YEAR", "MONTH", "DAY", "WEEKDAY"], pn = ["IF"], hn = [
1366
+ ], Yn = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Gn = ["IF"], Jn = [
1103
1367
  "CONCATENATE",
1104
1368
  "CONCAT",
1105
1369
  "LEN",
@@ -1110,24 +1374,24 @@ const un = [
1110
1374
  "MID",
1111
1375
  "FIND",
1112
1376
  "SEARCH"
1113
- ], mn = /* @__PURE__ */ new Set([
1114
- ...un,
1115
- ...dn,
1116
- ...fn,
1117
- ...hn,
1118
- ...pn
1119
- ]), gn = /"(?:[^"]|"")*"/g, ht = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1120
- function yn(e) {
1121
- const r = e.replace(gn, (n) => " ".repeat(n.length));
1122
- ht.lastIndex = 0;
1377
+ ], Zn = /* @__PURE__ */ new Set([
1378
+ ...qn,
1379
+ ...Kn,
1380
+ ...Yn,
1381
+ ...Jn,
1382
+ ...Gn
1383
+ ]), Qn = /"(?:[^"]|"")*"/g, Ct = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1384
+ function eo(e) {
1385
+ const r = e.replace(Qn, (n) => " ".repeat(n.length));
1386
+ Ct.lastIndex = 0;
1123
1387
  let t;
1124
- for (; (t = ht.exec(r)) !== null; ) {
1388
+ for (; (t = Ct.exec(r)) !== null; ) {
1125
1389
  const n = t[1].toUpperCase();
1126
- if (!mn.has(n))
1127
- throw new ce("NAME", `Function ${n} is not allowed.`);
1390
+ if (!Zn.has(n))
1391
+ throw new de("NAME", `Function ${n} is not allowed.`);
1128
1392
  }
1129
1393
  }
1130
- function bn(e, r, t) {
1394
+ function to(e, r, t) {
1131
1395
  let n = e;
1132
1396
  if (n == null) throw t.NA;
1133
1397
  if (typeof n == "object" && !(n instanceof t) && (n = r.retrieveRef(n)), n instanceof t) throw n;
@@ -1135,54 +1399,54 @@ function bn(e, r, t) {
1135
1399
  if (typeof n == "number") return n !== 0;
1136
1400
  throw t.VALUE;
1137
1401
  }
1138
- function _t(e) {
1402
+ function tr(e) {
1139
1403
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
1140
1404
  }
1141
- function Ne(e) {
1142
- const r = _t(e);
1405
+ function Fe(e) {
1406
+ const r = tr(e);
1143
1407
  return Array.isArray(r) ? r.flat(1 / 0) : [r];
1144
1408
  }
1145
- function W(e) {
1146
- const r = _t(e);
1409
+ function K(e) {
1410
+ const r = tr(e);
1147
1411
  return Array.isArray(r) ? r.flat(1 / 0)[0] : r;
1148
1412
  }
1149
- function Ge(e) {
1150
- return e === void 0 ? void 0 : W(e);
1413
+ function tt(e) {
1414
+ return e === void 0 ? void 0 : K(e);
1151
1415
  }
1152
- function le(e) {
1416
+ function ue(e) {
1153
1417
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
1154
1418
  }
1155
- function vn(e, r) {
1419
+ function ro(e, r) {
1156
1420
  return e instanceof r ? e : new r(e.message || "#ERROR!");
1157
1421
  }
1158
- function te(e) {
1422
+ function se(e) {
1159
1423
  return e.find((r) => r instanceof Error);
1160
1424
  }
1161
- function wn(e, r) {
1425
+ function no(e, r) {
1162
1426
  const t = (o) => {
1163
- throw vn(o, r);
1164
- }, n = (o, { checkArgsForErrors: s = !0 } = {}) => (...c) => {
1165
- const a = c.flatMap(Ne);
1427
+ throw ro(o, r);
1428
+ }, n = (o, { checkArgsForErrors: s = !0 } = {}) => (...a) => {
1429
+ const c = a.flatMap(Fe);
1166
1430
  if (s) {
1167
- const u = te(a);
1168
- u && t(u);
1431
+ const d = se(c);
1432
+ d && t(d);
1169
1433
  }
1170
- const d = o(...a);
1171
- return d instanceof Error ? t(d) : d;
1172
- }, l = (o, { toText: s = !1 } = {}) => (c) => {
1173
- const a = W(c), d = te([a]);
1174
- d && t(d);
1175
- const u = o(s ? le(a) : a);
1434
+ const u = o(...c);
1176
1435
  return u instanceof Error ? t(u) : u;
1436
+ }, i = (o, { toText: s = !1 } = {}) => (a) => {
1437
+ const c = K(a), u = se([c]);
1438
+ u && t(u);
1439
+ const d = o(s ? ue(c) : c);
1440
+ return d instanceof Error ? t(d) : d;
1177
1441
  };
1178
1442
  return {
1179
1443
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
1180
1444
  // dereferenced or type-checked here) — that's what makes
1181
1445
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
1182
- IF: (o, s, c, a) => {
1183
- const d = bn(s, o, r);
1184
- if (c == null) throw r.NA;
1185
- return d ? c : a ?? !1;
1446
+ IF: (o, s, a, c) => {
1447
+ const u = to(s, o, r);
1448
+ if (a == null) throw r.NA;
1449
+ return u ? a : c ?? !1;
1186
1450
  },
1187
1451
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1188
1452
  // and formulajs's own convention for MAX/MIN.
@@ -1197,28 +1461,28 @@ function wn(e, r) {
1197
1461
  // the other aggregates use.
1198
1462
  COUNTA: n(e.COUNTA, { checkArgsForErrors: !1 }),
1199
1463
  LARGE: (o, s) => {
1200
- const c = Ne(o), a = W(s), d = te([...c, a]);
1201
- d && t(d);
1202
- const u = e.LARGE(c, a);
1203
- return u instanceof Error ? t(u) : u;
1464
+ const a = Fe(o), c = K(s), u = se([...a, c]);
1465
+ u && t(u);
1466
+ const d = e.LARGE(a, c);
1467
+ return d instanceof Error ? t(d) : d;
1204
1468
  },
1205
1469
  SMALL: (o, s) => {
1206
- const c = Ne(o), a = W(s), d = te([...c, a]);
1207
- d && t(d);
1208
- const u = e.SMALL(c, a);
1209
- return u instanceof Error ? t(u) : u;
1470
+ const a = Fe(o), c = K(s), u = se([...a, c]);
1471
+ u && t(u);
1472
+ const d = e.SMALL(a, c);
1473
+ return d instanceof Error ? t(d) : d;
1210
1474
  },
1211
1475
  PERMUT: (o, s) => {
1212
- const c = [W(o), W(s)], a = te(c);
1213
- a && t(a);
1214
- const d = e.PERMUT(c[0], c[1]);
1215
- return d instanceof Error ? t(d) : d;
1476
+ const a = [K(o), K(s)], c = se(a);
1477
+ c && t(c);
1478
+ const u = e.PERMUT(a[0], a[1]);
1479
+ return u instanceof Error ? t(u) : u;
1216
1480
  },
1217
1481
  PERMUTATIONA: (o, s) => {
1218
- const c = [W(o), W(s)], a = te(c);
1219
- a && t(a);
1220
- const d = e.PERMUTATIONA(c[0], c[1]);
1221
- return d instanceof Error ? t(d) : d;
1482
+ const a = [K(o), K(s)], c = se(a);
1483
+ c && t(c);
1484
+ const u = e.PERMUTATIONA(a[0], a[1]);
1485
+ return u instanceof Error ? t(u) : u;
1222
1486
  },
1223
1487
  // match_type is intentionally ignored and forced to 0 (exact match)
1224
1488
  // regardless of what the formula author supplied — approximate/sorted
@@ -1227,42 +1491,42 @@ function wn(e, r) {
1227
1491
  // real-world data. Same scope decision as the hand-rolled engine this
1228
1492
  // replaces, carried forward deliberately rather than dropped.
1229
1493
  MATCH: (o, s) => {
1230
- const c = W(o), a = Ne(s), d = te([c, ...a]);
1231
- d && t(d);
1232
- const u = e.MATCH(c, a, 0);
1233
- return u instanceof Error ? t(u) : u;
1494
+ const a = K(o), c = Fe(s), u = se([a, ...c]);
1495
+ u && t(u);
1496
+ const d = e.MATCH(a, c, 0);
1497
+ return d instanceof Error ? t(d) : d;
1234
1498
  },
1235
1499
  SWITCH: (...o) => {
1236
- const s = o.map(W), c = te(s);
1237
- c && t(c);
1238
- const a = e.SWITCH(...s);
1239
- return a instanceof Error ? t(a) : a;
1500
+ const s = o.map(K), a = se(s);
1501
+ a && t(a);
1502
+ const c = e.SWITCH(...s);
1503
+ return c instanceof Error ? t(c) : c;
1240
1504
  },
1241
- SUBSTITUTE: (o, s, c, a) => {
1242
- const d = [le(W(o)), le(W(s)), le(W(c))];
1243
- a !== void 0 && d.push(W(a));
1244
- const u = te(d);
1245
- u && t(u);
1246
- const h = e.SUBSTITUTE(...d);
1247
- return h instanceof Error ? t(h) : h;
1505
+ SUBSTITUTE: (o, s, a, c) => {
1506
+ const u = [ue(K(o)), ue(K(s)), ue(K(a))];
1507
+ c !== void 0 && u.push(K(c));
1508
+ const d = se(u);
1509
+ d && t(d);
1510
+ const y = e.SUBSTITUTE(...u);
1511
+ return y instanceof Error ? t(y) : y;
1248
1512
  },
1249
- TEXTJOIN: (o, s, ...c) => {
1250
- const a = le(W(o)), d = W(s), u = c.flatMap(Ne).map(le), h = te([a, d]);
1251
- h && t(h);
1252
- const p = e.TEXTJOIN(a, d, u);
1253
- return p instanceof Error ? t(p) : p;
1513
+ TEXTJOIN: (o, s, ...a) => {
1514
+ const c = ue(K(o)), u = K(s), d = a.flatMap(Fe).map(ue), y = se([c, u]);
1515
+ y && t(y);
1516
+ const m = e.TEXTJOIN(c, u, d);
1517
+ return m instanceof Error ? t(m) : m;
1254
1518
  },
1255
- UPPER: l(e.UPPER),
1519
+ UPPER: i(e.UPPER),
1256
1520
  // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
1257
1521
  // fast-formula-parser's own (real, but broken-for-Date-cells) versions.
1258
- YEAR: l(e.YEAR),
1259
- MONTH: l(e.MONTH),
1260
- DAY: l(e.DAY),
1522
+ YEAR: i(e.YEAR),
1523
+ MONTH: i(e.MONTH),
1524
+ DAY: i(e.DAY),
1261
1525
  WEEKDAY: (o, s) => {
1262
- const c = W(o), a = W(s), d = te([c]);
1263
- d && t(d);
1264
- const u = e.WEEKDAY(c, a);
1265
- return u instanceof Error ? t(u) : u;
1526
+ const a = K(o), c = K(s), u = se([a]);
1527
+ u && t(u);
1528
+ const d = e.WEEKDAY(a, c);
1529
+ return d instanceof Error ? t(d) : d;
1266
1530
  },
1267
1531
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1268
1532
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1274,53 +1538,53 @@ function wn(e, r) {
1274
1538
  // separator, matching Excel's own range-argument behavior — the native
1275
1539
  // implementation instead inserts stray commas for a whole-range argument.
1276
1540
  CONCATENATE: (...o) => {
1277
- const s = o.flatMap(Ne), c = te(s);
1278
- c && t(c);
1279
- const a = e.CONCATENATE(...s.map(le));
1280
- return a instanceof Error ? t(a) : a;
1541
+ const s = o.flatMap(Fe), a = se(s);
1542
+ a && t(a);
1543
+ const c = e.CONCATENATE(...s.map(ue));
1544
+ return c instanceof Error ? t(c) : c;
1281
1545
  },
1282
1546
  CONCAT: (...o) => {
1283
- const s = o.flatMap(Ne), c = te(s);
1284
- c && t(c);
1285
- const a = e.CONCAT(...s.map(le));
1286
- return a instanceof Error ? t(a) : a;
1547
+ const s = o.flatMap(Fe), a = se(s);
1548
+ a && t(a);
1549
+ const c = e.CONCAT(...s.map(ue));
1550
+ return c instanceof Error ? t(c) : c;
1287
1551
  },
1288
- LEN: l(e.LEN, { toText: !0 }),
1289
- TRIM: l(e.TRIM, { toText: !0 }),
1290
- LOWER: l(e.LOWER, { toText: !0 }),
1552
+ LEN: i(e.LEN, { toText: !0 }),
1553
+ TRIM: i(e.TRIM, { toText: !0 }),
1554
+ LOWER: i(e.LOWER, { toText: !0 }),
1291
1555
  LEFT: (o, s) => {
1292
- const c = W(o), a = Ge(s), d = te([c]);
1293
- d && t(d);
1294
- const u = e.LEFT(le(c), a);
1295
- return u instanceof Error ? t(u) : u;
1556
+ const a = K(o), c = tt(s), u = se([a]);
1557
+ u && t(u);
1558
+ const d = e.LEFT(ue(a), c);
1559
+ return d instanceof Error ? t(d) : d;
1296
1560
  },
1297
1561
  RIGHT: (o, s) => {
1298
- const c = W(o), a = Ge(s), d = te([c]);
1299
- d && t(d);
1300
- const u = e.RIGHT(le(c), a);
1301
- return u instanceof Error ? t(u) : u;
1562
+ const a = K(o), c = tt(s), u = se([a]);
1563
+ u && t(u);
1564
+ const d = e.RIGHT(ue(a), c);
1565
+ return d instanceof Error ? t(d) : d;
1302
1566
  },
1303
- MID: (o, s, c) => {
1304
- const a = W(o), d = W(s), u = W(c), h = te([a, d, u]);
1305
- h && t(h);
1306
- const p = e.MID(le(a), d, u);
1307
- return p instanceof Error ? t(p) : p;
1567
+ MID: (o, s, a) => {
1568
+ const c = K(o), u = K(s), d = K(a), y = se([c, u, d]);
1569
+ y && t(y);
1570
+ const m = e.MID(ue(c), u, d);
1571
+ return m instanceof Error ? t(m) : m;
1308
1572
  },
1309
- FIND: (o, s, c) => {
1310
- const a = W(o), d = W(s), u = Ge(c), h = te([a, d]);
1311
- h && t(h);
1312
- const p = e.FIND(le(a), le(d), u);
1313
- return p instanceof Error ? t(p) : p;
1573
+ FIND: (o, s, a) => {
1574
+ const c = K(o), u = K(s), d = tt(a), y = se([c, u]);
1575
+ y && t(y);
1576
+ const m = e.FIND(ue(c), ue(u), d);
1577
+ return m instanceof Error ? t(m) : m;
1314
1578
  },
1315
- SEARCH: (o, s, c) => {
1316
- const a = W(o), d = W(s), u = Ge(c), h = te([a, d]);
1317
- h && t(h);
1318
- const p = e.SEARCH(le(a), le(d), u);
1319
- return p instanceof Error ? t(p) : p;
1579
+ SEARCH: (o, s, a) => {
1580
+ const c = K(o), u = K(s), d = tt(a), y = se([c, u]);
1581
+ y && t(y);
1582
+ const m = e.SEARCH(ue(c), ue(u), d);
1583
+ return m instanceof Error ? t(m) : m;
1320
1584
  }
1321
1585
  };
1322
1586
  }
1323
- const En = {
1587
+ const oo = {
1324
1588
  "#REF!": "REF",
1325
1589
  "#VALUE!": "VALUE",
1326
1590
  "#DIV/0!": "DIV0",
@@ -1329,100 +1593,100 @@ const En = {
1329
1593
  "#NUM!": "NUM",
1330
1594
  "#NULL!": "NULL"
1331
1595
  };
1332
- function mt(e) {
1333
- return En[e.error] ?? "ERROR";
1596
+ function St(e) {
1597
+ return oo[e.error] ?? "ERROR";
1334
1598
  }
1335
- function gt(e, r) {
1336
- if (e instanceof ce) return e;
1599
+ function Ot(e, r) {
1600
+ if (e instanceof de) return e;
1337
1601
  if (e instanceof r) {
1338
1602
  const t = e.details;
1339
- return t instanceof ce ? t : t instanceof r ? new ce(mt(t), t.message) : new ce(mt(e), e.message);
1603
+ return t instanceof de ? t : t instanceof r ? new de(St(t), t.message) : new de(St(e), e.message);
1340
1604
  }
1341
- return new ce("ERROR", e instanceof Error ? e.message : void 0);
1605
+ return new de("ERROR", e instanceof Error ? e.message : void 0);
1342
1606
  }
1343
- function Tn(e) {
1607
+ function io(e) {
1344
1608
  return Math.max(0, ...e.map((r) => (r == null ? void 0 : r.length) ?? 0));
1345
1609
  }
1346
- function An(e) {
1610
+ function so(e) {
1347
1611
  return (r) => {
1348
1612
  const t = e[r.row - 1];
1349
1613
  if (r.row < 1 || r.col < 1 || t == null || r.col - 1 >= t.length)
1350
- throw new ce("REF");
1614
+ throw new de("REF");
1351
1615
  const n = t[r.col - 1];
1352
1616
  return n == null || n === "" ? null : n;
1353
1617
  };
1354
1618
  }
1355
- function xn(e) {
1619
+ function lo(e) {
1356
1620
  return (r) => {
1357
- const t = Math.min(r.from.row, r.to.row), n = Math.min(r.from.col, r.to.col), l = Math.max(r.from.row, r.to.row), o = Math.max(r.from.col, r.to.col), s = Tn(e);
1621
+ const t = Math.min(r.from.row, r.to.row), n = Math.min(r.from.col, r.to.col), i = Math.max(r.from.row, r.to.row), o = Math.max(r.from.col, r.to.col), s = io(e);
1358
1622
  if (t > e.length || n > s)
1359
- throw new ce("REF");
1360
- const c = Math.min(l, e.length), a = [];
1361
- for (let d = t; d <= c; d++) {
1362
- const u = e[d - 1], h = [];
1363
- if (u != null) {
1364
- const p = Math.min(o, u.length);
1365
- for (let g = n; g <= p; g++) {
1366
- const b = u[g - 1];
1367
- h.push(b == null || b === "" ? null : b);
1623
+ throw new de("REF");
1624
+ const a = Math.min(i, e.length), c = [];
1625
+ for (let u = t; u <= a; u++) {
1626
+ const d = e[u - 1], y = [];
1627
+ if (d != null) {
1628
+ const m = Math.min(o, d.length);
1629
+ for (let f = n; f <= m; f++) {
1630
+ const T = d[f - 1];
1631
+ y.push(T == null || T === "" ? null : T);
1368
1632
  }
1369
1633
  }
1370
- a.push(h);
1634
+ c.push(y);
1371
1635
  }
1372
- return a;
1636
+ return c;
1373
1637
  };
1374
1638
  }
1375
- function Rn(e) {
1639
+ function co(e) {
1376
1640
  if (e == null || e === "") return null;
1377
1641
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1378
1642
  return e;
1379
- throw new ce("VALUE");
1643
+ throw new de("VALUE");
1380
1644
  }
1381
- async function Vt(e, r) {
1382
- if (typeof e != "string") throw new ce("ERROR");
1645
+ async function rr(e, r) {
1646
+ if (typeof e != "string") throw new de("ERROR");
1383
1647
  const t = e.trim();
1384
- if (t === "") throw new ce("ERROR");
1648
+ if (t === "") throw new de("ERROR");
1385
1649
  const n = t.startsWith("=") ? t.slice(1) : t;
1386
- yn(n);
1387
- const [l, o] = await Promise.all([
1650
+ eo(n);
1651
+ const [i, o] = await Promise.all([
1388
1652
  import("fast-formula-parser"),
1389
1653
  import("@formulajs/formulajs")
1390
- ]), s = l.default ?? l, c = s.FormulaError, a = new s({
1654
+ ]), s = i.default ?? i, a = s.FormulaError, c = new s({
1391
1655
  ...r,
1392
1656
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- formulajs's own types are all `any`-typed; formulaFunctions.ts narrows the surface it actually calls.
1393
- functions: wn(o, c)
1657
+ functions: no(o, a)
1394
1658
  });
1395
- let d;
1659
+ let u;
1396
1660
  try {
1397
- d = a.parse(n, { row: 1, col: 1, sheet: "Sheet1" });
1398
- } catch (u) {
1399
- throw gt(u, c);
1661
+ u = c.parse(n, { row: 1, col: 1, sheet: "Sheet1" });
1662
+ } catch (d) {
1663
+ throw Ot(d, a);
1400
1664
  }
1401
- if (d instanceof c)
1402
- throw gt(d, c);
1403
- return Rn(d);
1665
+ if (u instanceof a)
1666
+ throw Ot(u, a);
1667
+ return co(u);
1404
1668
  }
1405
- async function Cn(e, r) {
1406
- return Vt(r, { onCell: An(e), onRange: xn(e) });
1669
+ async function ao(e, r) {
1670
+ return rr(r, { onCell: so(e), onRange: lo(e) });
1407
1671
  }
1408
- const yt = -1;
1409
- async function jt(e, r) {
1672
+ const Nt = -1;
1673
+ async function nr(e, r) {
1410
1674
  const t = Object.keys(e);
1411
- return Vt(r, {
1675
+ return rr(r, {
1412
1676
  onVariable: (n) => {
1413
- const l = t.indexOf(n);
1414
- return l === -1 ? null : { row: yt, col: l + 1 };
1677
+ const i = t.indexOf(n);
1678
+ return i === -1 ? null : { row: Nt, col: i + 1 };
1415
1679
  },
1416
1680
  onCell: (n) => {
1417
- if (n.row === yt) return e[t[n.col - 1]] ?? null;
1418
- throw new ce("REF");
1681
+ if (n.row === Nt) return e[t[n.col - 1]] ?? null;
1682
+ throw new de("REF");
1419
1683
  },
1420
1684
  onRange: () => {
1421
- throw new ce("REF");
1685
+ throw new de("REF");
1422
1686
  }
1423
1687
  });
1424
1688
  }
1425
- const Ht = {
1689
+ const or = {
1426
1690
  REF: "#REF!",
1427
1691
  VALUE: "#VALUE!",
1428
1692
  DIV0: "#DIV/0!",
@@ -1432,34 +1696,34 @@ const Ht = {
1432
1696
  NUM: "#NUM!",
1433
1697
  NULL: "#NULL!"
1434
1698
  };
1435
- function st(e) {
1436
- const r = e instanceof ce ? e.code : "ERROR";
1437
- return Ht[r];
1699
+ function gt(e) {
1700
+ const r = e instanceof de ? e.code : "ERROR";
1701
+ return or[r];
1438
1702
  }
1439
- async function Sn(e, r) {
1703
+ async function uo(e, r) {
1440
1704
  return e.length === 0 ? r.map((t) => ({
1441
1705
  id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
1442
1706
  label: (t == null ? void 0 : t.label) ?? "(unknown)",
1443
1707
  value: null,
1444
- error: Ht.ERROR
1708
+ error: or.ERROR
1445
1709
  })) : Promise.all(
1446
1710
  r.map(async (t) => {
1447
1711
  try {
1448
1712
  if (!t || typeof t.label != "string" || typeof t.expression != "string" || typeof t.id != "string")
1449
- throw new ce("ERROR");
1450
- return { id: t.id, label: t.label, value: await Cn(e, t.expression) };
1713
+ throw new de("ERROR");
1714
+ return { id: t.id, label: t.label, value: await ao(e, t.expression) };
1451
1715
  } catch (n) {
1452
1716
  return {
1453
1717
  id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
1454
1718
  label: (t == null ? void 0 : t.label) ?? "(unknown)",
1455
1719
  value: null,
1456
- error: st(n)
1720
+ error: gt(n)
1457
1721
  };
1458
1722
  }
1459
1723
  })
1460
1724
  );
1461
1725
  }
1462
- function bt(e) {
1726
+ function Dt(e) {
1463
1727
  const r = /* @__PURE__ */ new Set();
1464
1728
  for (const { id: t } of e) {
1465
1729
  if (r.has(t)) return t;
@@ -1467,99 +1731,99 @@ function bt(e) {
1467
1731
  }
1468
1732
  return null;
1469
1733
  }
1470
- function Wt(e) {
1471
- const { columnHeader: r, rowHeader: t, columns: n, rows: l } = e;
1734
+ function ir(e) {
1735
+ const { columnHeader: r, rowHeader: t, columns: n, rows: i } = e;
1472
1736
  if (n !== void 0 && !Array.isArray(n))
1473
1737
  return "columns must be an array of { id, label } objects.";
1474
- if (l !== void 0 && !Array.isArray(l))
1738
+ if (i !== void 0 && !Array.isArray(i))
1475
1739
  return "rows must be an array of { id, label } objects.";
1476
1740
  if (n !== void 0 && n.length === 0)
1477
1741
  return "columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1478
- if (l !== void 0 && l.length === 0)
1742
+ if (i !== void 0 && i.length === 0)
1479
1743
  return "rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1480
- const o = (u) => !!u && typeof u.id == "string" && u.id !== "" && typeof u.label == "string" && u.label !== "", s = n == null ? void 0 : n.findIndex((u) => !o(u));
1744
+ const o = (d) => !!d && typeof d.id == "string" && d.id !== "" && typeof d.label == "string" && d.label !== "", s = n == null ? void 0 : n.findIndex((d) => !o(d));
1481
1745
  if (s != null && s !== -1)
1482
1746
  return `columns[${s}] must be a { id, label } object with non-empty string fields.`;
1483
- const c = l == null ? void 0 : l.findIndex((u) => !o(u));
1484
- if (c != null && c !== -1)
1485
- return `rows[${c}] must be a { id, label } object with non-empty string fields.`;
1486
- const a = !!n && n.length > 0, d = !!l && l.length > 0;
1487
- if (a) {
1488
- const u = bt(n);
1489
- if (u) return `duplicate column id "${u}" — every declared column id must be unique.`;
1747
+ const a = i == null ? void 0 : i.findIndex((d) => !o(d));
1748
+ if (a != null && a !== -1)
1749
+ return `rows[${a}] must be a { id, label } object with non-empty string fields.`;
1750
+ const c = !!n && n.length > 0, u = !!i && i.length > 0;
1751
+ if (c) {
1752
+ const d = Dt(n);
1753
+ if (d) return `duplicate column id "${d}" — every declared column id must be unique.`;
1490
1754
  }
1491
- if (d) {
1492
- const u = bt(l);
1493
- if (u) return `duplicate row id "${u}" — every declared row id must be unique.`;
1755
+ if (u) {
1756
+ const d = Dt(i);
1757
+ if (d) return `duplicate row id "${d}" — every declared row id must be unique.`;
1494
1758
  }
1495
- return r && t ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : a && d ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : r && !a ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : t && !d ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1759
+ return r && t ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : c && u ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : r && !c ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : t && !u ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1496
1760
  }
1497
- function vt(e, r = {}) {
1498
- const t = Wt(r);
1761
+ function It(e, r = {}) {
1762
+ const t = ir(r);
1499
1763
  if (t) throw new Error(`x-spreadsheet: ${t}`);
1500
- const { columnHeader: n, rowHeader: l, columns: o, rows: s } = r;
1501
- return o && o.length > 0 ? On(e, o, n === !0) : s && s.length > 0 ? Nn(e, s, l === !0) : e;
1764
+ const { columnHeader: n, rowHeader: i, columns: o, rows: s } = r;
1765
+ return o && o.length > 0 ? fo(e, o, n === !0) : s && s.length > 0 ? po(e, s, i === !0) : e;
1502
1766
  }
1503
- function On(e, r, t) {
1504
- return (t ? e.slice(1) : e).map((l) => {
1767
+ function fo(e, r, t) {
1768
+ return (t ? e.slice(1) : e).map((i) => {
1505
1769
  const o = /* @__PURE__ */ Object.create(null);
1506
- return r.forEach((s, c) => {
1507
- o[s.id] = l[c] ?? null;
1770
+ return r.forEach((s, a) => {
1771
+ o[s.id] = i[a] ?? null;
1508
1772
  }), o;
1509
1773
  });
1510
1774
  }
1511
- function Nn(e, r, t) {
1512
- const n = t ? 1 : 0, l = Math.max(0, ...e.map((s) => s.length)), o = Math.max(0, l - n);
1513
- return Array.from({ length: o }, (s, c) => {
1514
- const a = n + c, d = /* @__PURE__ */ Object.create(null);
1515
- return r.forEach((u, h) => {
1516
- var p;
1517
- d[u.id] = ((p = e[h]) == null ? void 0 : p[a]) ?? null;
1518
- }), d;
1775
+ function po(e, r, t) {
1776
+ const n = t ? 1 : 0, i = Math.max(0, ...e.map((s) => s.length)), o = Math.max(0, i - n);
1777
+ return Array.from({ length: o }, (s, a) => {
1778
+ const c = n + a, u = /* @__PURE__ */ Object.create(null);
1779
+ return r.forEach((d, y) => {
1780
+ var m;
1781
+ u[d.id] = ((m = e[y]) == null ? void 0 : m[c]) ?? null;
1782
+ }), u;
1519
1783
  });
1520
1784
  }
1521
- function Bt(e) {
1785
+ function sr(e) {
1522
1786
  return !Array.isArray(e[0]);
1523
1787
  }
1524
- function kn(e) {
1788
+ function ho(e) {
1525
1789
  const r = /* @__PURE__ */ Object.create(null);
1526
- for (const { id: t, label: n, value: l, error: o } of e)
1527
- r[t] = o === void 0 ? { label: n, value: l } : { label: n, value: l, error: o };
1790
+ for (const { id: t, label: n, value: i, error: o } of e)
1791
+ r[t] = o === void 0 ? { label: n, value: i } : { label: n, value: i, error: o };
1528
1792
  return r;
1529
1793
  }
1530
- function tt(e, r) {
1794
+ function ut(e, r) {
1531
1795
  const t = (n) => n instanceof Date ? n.toISOString() : n ?? null;
1532
1796
  return t(e) === t(r);
1533
1797
  }
1534
- function In(e, r) {
1535
- const t = e ?? {}, n = r ?? {}, l = Object.keys(t);
1536
- return l.length !== Object.keys(n).length ? !1 : l.every((o) => {
1798
+ function mo(e, r) {
1799
+ const t = e ?? {}, n = r ?? {}, i = Object.keys(t);
1800
+ return i.length !== Object.keys(n).length ? !1 : i.every((o) => {
1537
1801
  if (!Object.prototype.hasOwnProperty.call(n, o)) return !1;
1538
- const s = t[o], c = n[o];
1539
- return s.label === c.label && s.error === c.error && tt(s.value, c.value);
1802
+ const s = t[o], a = n[o];
1803
+ return s.label === a.label && s.error === a.error && ut(s.value, a.value);
1540
1804
  });
1541
1805
  }
1542
- function Dn(e, r) {
1806
+ function go(e, r) {
1543
1807
  if (e == null || r == null) return e === r;
1544
1808
  const t = Array.isArray(e);
1545
1809
  if (t !== Array.isArray(r)) return !1;
1546
1810
  if (t) {
1547
- const s = e, c = r;
1548
- return s.length === c.length && s.every((a, d) => tt(a, c[d]));
1811
+ const s = e, a = r;
1812
+ return s.length === a.length && s.every((c, u) => ut(c, a[u]));
1549
1813
  }
1550
- const n = e, l = r, o = Object.keys(n);
1551
- return o.length !== Object.keys(l).length ? !1 : o.every((s) => Object.prototype.hasOwnProperty.call(l, s) && tt(n[s], l[s]));
1814
+ const n = e, i = r, o = Object.keys(n);
1815
+ return o.length !== Object.keys(i).length ? !1 : o.every((s) => Object.prototype.hasOwnProperty.call(i, s) && ut(n[s], i[s]));
1552
1816
  }
1553
- function Ln(e, r) {
1817
+ function yo(e, r) {
1554
1818
  if (e === r) return !0;
1555
1819
  if (e == null || r == null) return !1;
1556
1820
  const t = e, n = r;
1557
- return t.length !== n.length ? !1 : t.every((l, o) => Dn(l, n[o]));
1821
+ return t.length !== n.length ? !1 : t.every((i, o) => go(i, n[o]));
1558
1822
  }
1559
- function Mn(e) {
1823
+ function bo(e) {
1560
1824
  return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
1561
1825
  }
1562
- function Xt(e, r) {
1826
+ function lr(e, r) {
1563
1827
  if (e.length === 0) return [];
1564
1828
  const t = [], n = /* @__PURE__ */ new Set();
1565
1829
  for (const o of r ?? [])
@@ -1568,59 +1832,59 @@ function Xt(e, r) {
1568
1832
  for (const s of Object.keys(o))
1569
1833
  n.has(s) || (n.add(s), t.push(s));
1570
1834
  if (t.length === 0) return [];
1571
- const l = e.map(
1835
+ const i = e.map(
1572
1836
  (o) => t.map((s) => {
1573
1837
  if (!Object.prototype.hasOwnProperty.call(o, s)) return null;
1574
- const c = o[s];
1575
- return Mn(c) ? c : null;
1838
+ const a = o[s];
1839
+ return bo(a) ? a : null;
1576
1840
  })
1577
1841
  );
1578
- return [t, ...l];
1842
+ return [t, ...i];
1579
1843
  }
1580
- function zn(e) {
1844
+ function vo(e) {
1581
1845
  const r = Math.max(0, ...e.map((t) => t.length));
1582
- return Array.from({ length: r }, (t, n) => e.map((l) => l[n] ?? null));
1846
+ return Array.from({ length: r }, (t, n) => e.map((i) => i[n] ?? null));
1583
1847
  }
1584
- const Fn = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Un = 10 * 1024 * 1024, Qe = 200, Pn = 50, $n = [];
1585
- function wt(e) {
1848
+ const wo = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Eo = 10 * 1024 * 1024, lt = 200, To = 50, xo = [];
1849
+ function kt(e) {
1586
1850
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1587
1851
  }
1588
- const _n = ({
1852
+ const Ao = ({
1589
1853
  data: e,
1590
1854
  handleChange: r,
1591
1855
  path: t,
1592
1856
  label: n,
1593
- required: l,
1857
+ required: i,
1594
1858
  schema: o,
1595
1859
  enabled: s,
1596
- readonly: c,
1597
- errors: a,
1598
- visible: d = !0
1860
+ readonly: a,
1861
+ errors: c,
1862
+ visible: u = !0
1599
1863
  }) => {
1600
- Ee(d, t, r);
1601
- const u = !a || a.length === 0, h = $t(s, c), p = (o == null ? void 0 : o["x-spreadsheet"]) ?? {}, g = (o == null ? void 0 : o["x-evaluate"]) ?? $n, b = p.accept ?? Fn, I = p.maxSize ?? Un, O = p.columnHeader === !0, T = p.rowHeader === !0, A = p.columns, k = p.rows, M = Array.isArray(A) && A.length > 0, L = Array.isArray(k) && k.length > 0, N = Wt({ columnHeader: O, rowHeader: T, columns: A, rows: k }), U = p.showSheet !== !1, z = p.sheetName, v = p.persistSheet !== !1, E = e ?? null, [B, K] = j(
1602
- () => E != null && E.sheet || Object.keys((E == null ? void 0 : E.derivations) ?? {}).length > 0 ? "ready" : "empty"
1603
- ), [J, F] = j(null), [R, Y] = j(!1), [Q, be] = j(null), [oe, Se] = j(null), m = ae(null), C = ae(null), G = (E == null ? void 0 : E.sheet) ?? null, P = Fe(
1604
- (x) => {
1605
- if (!Bt(x)) return x;
1606
- const V = L ? k : M ? A : void 0, se = Xt(
1607
- x,
1608
- V == null ? void 0 : V.map((X) => X.id)
1864
+ Oe(u, t, r);
1865
+ const d = Ae(t, i, u), y = !c || c.length === 0, m = er(s, a), f = (o == null ? void 0 : o["x-spreadsheet"]) ?? {}, T = (o == null ? void 0 : o["x-evaluate"]) ?? xo, w = f.accept ?? wo, L = f.maxSize ?? Eo, D = f.columnHeader === !0, N = f.rowHeader === !0, A = f.columns, R = f.rows, v = Array.isArray(A) && A.length > 0, b = Array.isArray(R) && R.length > 0, U = ir({ columnHeader: D, rowHeader: N, columns: A, rows: R }), P = f.showSheet !== !1, O = f.sheetName, j = f.persistSheet !== !1, I = e ?? null, [ne, Y] = B(
1866
+ () => I != null && I.sheet || Object.keys((I == null ? void 0 : I.derivations) ?? {}).length > 0 ? "ready" : "empty"
1867
+ ), [z, _] = B(null), [ee, fe] = B(!1), [oe, te] = B(null), [k, G] = B(null), C = ge(null), J = ge(null), pe = (I == null ? void 0 : I.sheet) ?? null, F = We(
1868
+ (S) => {
1869
+ if (!sr(S)) return S;
1870
+ const W = b ? R : v ? A : void 0, ce = lr(
1871
+ S,
1872
+ W == null ? void 0 : W.map((q) => q.id)
1609
1873
  );
1610
- return L ? zn(se) : se;
1874
+ return b ? vo(ce) : ce;
1611
1875
  },
1612
- [M, L, A, k]
1613
- ), _ = _e(() => Q ?? (G ? P(G) : null), [Q, G, P]), re = ((oe == null ? void 0 : oe.matrix) === _ ? oe.derivations : null) ?? (E == null ? void 0 : E.derivations) ?? {}, q = _ != null || E != null, ie = _e(() => {
1614
- const x = M ? 1 : 0, V = L ? 1 : 0, se = _ ? _.slice(x) : [], X = se.slice(0, Qe), H = Math.min(
1615
- Pn,
1616
- Math.max(0, ...X.map((pe) => Math.max(0, pe.length - V)))
1617
- ), Re = Array.from({ length: H }, (pe, w) => w + V), Le = "", Xe = L && !M;
1618
- return /* @__PURE__ */ i(ge, { children: _ && U && /* @__PURE__ */ y(S, { mt: "3", children: [
1619
- /* @__PURE__ */ i(S, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ y(Te.Root, { variant: "surface", size: "1", children: [
1620
- !Xe && /* @__PURE__ */ i(Te.Header, { children: /* @__PURE__ */ y(Te.Row, { children: [
1621
- /* @__PURE__ */ i(Te.ColumnHeaderCell, { children: Le }),
1622
- Re.map((pe) => {
1623
- var w;
1876
+ [v, b, A, R]
1877
+ ), Z = Ve(() => oe ?? (pe ? F(pe) : null), [oe, pe, F]), le = ((k == null ? void 0 : k.matrix) === Z ? k.derivations : null) ?? (I == null ? void 0 : I.derivations) ?? {}, ye = Z != null || I != null, he = Ve(() => {
1878
+ const S = v ? 1 : 0, W = b ? 1 : 0, ce = Z ? Z.slice(S) : [], q = ce.slice(0, lt), H = Math.min(
1879
+ To,
1880
+ Math.max(0, ...q.map((Ee) => Math.max(0, Ee.length - W)))
1881
+ ), ke = Array.from({ length: H }, (Ee, E) => E + W), Pe = "", Je = b && !v;
1882
+ return /* @__PURE__ */ l(xe, { children: Z && P && /* @__PURE__ */ g(M, { mt: "3", children: [
1883
+ /* @__PURE__ */ l(M, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(De.Root, { variant: "surface", size: "1", children: [
1884
+ !Je && /* @__PURE__ */ l(De.Header, { children: /* @__PURE__ */ g(De.Row, { children: [
1885
+ /* @__PURE__ */ l(De.ColumnHeaderCell, { children: Pe }),
1886
+ ke.map((Ee) => {
1887
+ var E;
1624
1888
  return (
1625
1889
  // This row only renders when hasRows isn't the sole
1626
1890
  // flag set (see suppressColumnHeaderRow) — so reaching
@@ -1628,227 +1892,227 @@ const _n = ({
1628
1892
  // looked up positionally — never read from the matrix
1629
1893
  // cell itself, which only ever holds the id) or both
1630
1894
  // are false (columnLetter fallback).
1631
- /* @__PURE__ */ i(Te.ColumnHeaderCell, { children: M ? ((w = A == null ? void 0 : A[pe]) == null ? void 0 : w.label) ?? "" : an(pe) }, pe)
1895
+ /* @__PURE__ */ l(De.ColumnHeaderCell, { children: v ? ((E = A == null ? void 0 : A[Ee]) == null ? void 0 : E.label) ?? "" : Xn(Ee) }, Ee)
1632
1896
  );
1633
1897
  })
1634
1898
  ] }) }),
1635
- /* @__PURE__ */ i(Te.Body, { children: X.map((pe, w) => {
1636
- var ne;
1637
- const Z = x + w;
1638
- return /* @__PURE__ */ y(Te.Row, { children: [
1639
- /* @__PURE__ */ i(
1640
- Te.RowHeaderCell,
1899
+ /* @__PURE__ */ l(De.Body, { children: q.map((Ee, E) => {
1900
+ var ae;
1901
+ const re = S + E;
1902
+ return /* @__PURE__ */ g(De.Row, { children: [
1903
+ /* @__PURE__ */ l(
1904
+ De.RowHeaderCell,
1641
1905
  {
1642
- style: L ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1643
- children: L ? ((ne = k == null ? void 0 : k[Z]) == null ? void 0 : ne.label) ?? "" : M ? "" : Z + 1
1906
+ style: b ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1907
+ children: b ? ((ae = R == null ? void 0 : R[re]) == null ? void 0 : ae.label) ?? "" : v ? "" : re + 1
1644
1908
  }
1645
1909
  ),
1646
- Re.map((he) => /* @__PURE__ */ i(Te.Cell, { children: wt(pe[he]) }, he))
1647
- ] }, w);
1910
+ ke.map((Te) => /* @__PURE__ */ l(De.Cell, { children: kt(Ee[Te]) }, Te))
1911
+ ] }, E);
1648
1912
  }) })
1649
1913
  ] }) }),
1650
- se.length > Qe && /* @__PURE__ */ y(f, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1914
+ ce.length > lt && /* @__PURE__ */ g(p, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1651
1915
  "Showing first ",
1652
- Qe,
1916
+ lt,
1653
1917
  " of ",
1654
- se.length,
1918
+ ce.length,
1655
1919
  " rows"
1656
1920
  ] })
1657
1921
  ] }) });
1658
- }, [_, U, M, L, A, k]), $ = Fe(
1659
- async (x) => {
1660
- if (F(null), x.size > I) {
1661
- F(`File exceeds the ${ve(I)} limit.`);
1922
+ }, [Z, P, v, b, A, R]), h = We(
1923
+ async (S) => {
1924
+ if (_(null), S.size > L) {
1925
+ _(`File exceeds the ${Ce(L)} limit.`);
1662
1926
  return;
1663
1927
  }
1664
- if (!b.split(",").map((H) => H.trim()).some((H) => H === "*" || H === "*/*" ? !0 : H.endsWith("/*") ? x.type.startsWith(H.slice(0, -1)) : H.startsWith(".") ? x.name.toLowerCase().endsWith(H.toLowerCase()) : x.type === H)) {
1665
- F(`Invalid type. Accepted: ${we(b)}`);
1928
+ if (!w.split(",").map((H) => H.trim()).some((H) => H === "*" || H === "*/*" ? !0 : H.endsWith("/*") ? S.type.startsWith(H.slice(0, -1)) : H.startsWith(".") ? S.name.toLowerCase().endsWith(H.toLowerCase()) : S.type === H)) {
1929
+ _(`Invalid type. Accepted: ${Se(w)}`);
1666
1930
  return;
1667
1931
  }
1668
- K("parsing");
1669
- let X;
1932
+ Y("parsing");
1933
+ let q;
1670
1934
  try {
1671
- const H = await x.arrayBuffer();
1672
- X = (await cn(H, z)).matrix;
1935
+ const H = await S.arrayBuffer();
1936
+ q = (await Bn(H, O)).matrix;
1673
1937
  } catch (H) {
1674
- K("error"), F(
1675
- H instanceof et ? H.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1938
+ Y("error"), _(
1939
+ H instanceof at ? H.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1676
1940
  );
1677
1941
  return;
1678
1942
  }
1679
- if (M || L)
1943
+ if (v || b)
1680
1944
  try {
1681
- X = P(vt(X, { columnHeader: O, rowHeader: T, columns: A, rows: k }));
1945
+ q = F(It(q, { columnHeader: D, rowHeader: N, columns: A, rows: R }));
1682
1946
  } catch (H) {
1683
- K("error"), F(H instanceof Error ? H.message : "Failed to process this sheet.");
1947
+ Y("error"), _(H instanceof Error ? H.message : "Failed to process this sheet.");
1684
1948
  return;
1685
1949
  }
1686
- C.current = (e == null ? void 0 : e.sheet) ?? null, be(X), K("ready");
1950
+ J.current = (e == null ? void 0 : e.sheet) ?? null, te(q), Y("ready");
1687
1951
  },
1688
- [b, I, z, e, O, T, A, k, M, L, P]
1952
+ [w, L, O, e, D, N, A, R, v, b, F]
1689
1953
  );
1690
- if (de(() => {
1691
- Q != null && G != null && G !== C.current && be(null);
1692
- }, [Q, G]), de(() => {
1693
- if (N || g.length === 0 && !v) return;
1694
- let x = !1;
1695
- const V = (X) => {
1696
- h && (In(E == null ? void 0 : E.derivations, X == null ? void 0 : X.derivations) && Ln(E == null ? void 0 : E.sheet, X == null ? void 0 : X.sheet) || (C.current = (X == null ? void 0 : X.sheet) ?? null, r(t, X)));
1697
- }, se = _ ?? [];
1698
- if (se.length === 0) {
1699
- E != null && V(void 0);
1954
+ if (we(() => {
1955
+ oe != null && pe != null && pe !== J.current && te(null);
1956
+ }, [oe, pe]), we(() => {
1957
+ if (U || T.length === 0 && !j) return;
1958
+ let S = !1;
1959
+ const W = (q) => {
1960
+ m && (mo(I == null ? void 0 : I.derivations, q == null ? void 0 : q.derivations) && yo(I == null ? void 0 : I.sheet, q == null ? void 0 : q.sheet) || (J.current = (q == null ? void 0 : q.sheet) ?? null, r(t, q)));
1961
+ }, ce = Z ?? [];
1962
+ if (ce.length === 0) {
1963
+ I != null && W(void 0);
1700
1964
  return;
1701
1965
  }
1702
- return Sn(se, g).then((X) => {
1703
- if (x) return;
1966
+ return uo(ce, T).then((q) => {
1967
+ if (S) return;
1704
1968
  let H;
1705
- if (Q != null) {
1706
- if (v)
1969
+ if (oe != null) {
1970
+ if (j)
1707
1971
  try {
1708
- H = vt(se, { columnHeader: M, rowHeader: L, columns: A, rows: k });
1709
- } catch (Le) {
1710
- F(Le instanceof Error ? Le.message : "Failed to process this sheet.");
1972
+ H = It(ce, { columnHeader: v, rowHeader: b, columns: A, rows: R });
1973
+ } catch (Pe) {
1974
+ _(Pe instanceof Error ? Pe.message : "Failed to process this sheet.");
1711
1975
  return;
1712
1976
  }
1713
1977
  } else
1714
- H = E == null ? void 0 : E.sheet;
1715
- F(null);
1716
- const Re = kn(X);
1717
- Se({ matrix: se, derivations: Re }), V(H === void 0 ? { derivations: Re } : { sheet: H, derivations: Re });
1978
+ H = I == null ? void 0 : I.sheet;
1979
+ _(null);
1980
+ const ke = ho(q);
1981
+ G({ matrix: ce, derivations: ke }), W(H === void 0 ? { derivations: ke } : { sheet: H, derivations: ke });
1718
1982
  }), () => {
1719
- x = !0;
1983
+ S = !0;
1720
1984
  };
1721
- }, [_, Q, g, h, v, M, L, A, k, N]), d === !1)
1985
+ }, [Z, oe, T, m, j, v, b, A, R, U]), u === !1)
1722
1986
  return null;
1723
- if (N)
1724
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1725
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: n }),
1726
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
1987
+ if (U)
1988
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
1989
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", children: n }),
1990
+ /* @__PURE__ */ g(p, { size: "2", color: "red", style: { display: "block" }, children: [
1727
1991
  "Invalid x-spreadsheet config: ",
1728
- N
1992
+ U
1729
1993
  ] })
1730
1994
  ] });
1731
- if (!h && !q) return null;
1732
- const fe = (x) => {
1733
- x.preventDefault(), x.stopPropagation(), h && Y(x.type === "dragenter" || x.type === "dragover");
1734
- }, Oe = (x) => {
1735
- var V;
1736
- x.preventDefault(), x.stopPropagation(), Y(!1), h && (V = x.dataTransfer.files) != null && V[0] && $(x.dataTransfer.files[0]);
1737
- }, Pe = (x) => {
1738
- var V;
1739
- (V = x.target.files) != null && V[0] && ($(x.target.files[0]), x.target.value = "");
1740
- }, $e = () => {
1741
- h && (be(null), Se(null), C.current = null, F(null), K("empty"), r(t, void 0));
1742
- }, xe = U && _ == null && E != null;
1743
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1744
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
1745
- /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
1746
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
1995
+ if (!m && !ye) return null;
1996
+ const x = (S) => {
1997
+ S.preventDefault(), S.stopPropagation(), m && fe(S.type === "dragenter" || S.type === "dragover");
1998
+ }, V = (S) => {
1999
+ var W;
2000
+ S.preventDefault(), S.stopPropagation(), fe(!1), m && (W = S.dataTransfer.files) != null && W[0] && h(S.dataTransfer.files[0]);
2001
+ }, Q = (S) => {
2002
+ var W;
2003
+ (W = S.target.files) != null && W[0] && (h(S.target.files[0]), S.target.value = "");
2004
+ }, X = () => {
2005
+ m && (te(null), G(null), J.current = null, _(null), Y("empty"), r(t, void 0));
2006
+ }, me = P && Z == null && I != null;
2007
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
2008
+ /* @__PURE__ */ g($, { align: "center", justify: "between", mb: "2", children: [
2009
+ /* @__PURE__ */ g($, { align: "center", gap: "1", children: [
2010
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", children: [
1747
2011
  n,
1748
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
2012
+ d && /* @__PURE__ */ l(p, { color: "red", children: " *" })
1749
2013
  ] }),
1750
- q && h && /* @__PURE__ */ y(ge, { children: [
1751
- /* @__PURE__ */ i(qe, { content: "Replace spreadsheet", children: /* @__PURE__ */ i(
1752
- je,
2014
+ ye && m && /* @__PURE__ */ g(xe, { children: [
2015
+ /* @__PURE__ */ l(Ke, { content: "Replace spreadsheet", children: /* @__PURE__ */ l(
2016
+ Xe,
1753
2017
  {
1754
2018
  variant: "ghost",
1755
2019
  size: "1",
1756
2020
  onClick: () => {
1757
- var x;
1758
- return (x = m.current) == null ? void 0 : x.click();
2021
+ var S;
2022
+ return (S = C.current) == null ? void 0 : S.click();
1759
2023
  },
1760
2024
  "aria-label": "Replace spreadsheet",
1761
- children: /* @__PURE__ */ i(ze, {})
2025
+ children: /* @__PURE__ */ l(je, {})
1762
2026
  }
1763
2027
  ) }),
1764
- /* @__PURE__ */ i(qe, { content: "Remove spreadsheet", children: /* @__PURE__ */ i(
1765
- je,
2028
+ /* @__PURE__ */ l(Ke, { content: "Remove spreadsheet", children: /* @__PURE__ */ l(
2029
+ Xe,
1766
2030
  {
1767
2031
  variant: "ghost",
1768
2032
  size: "1",
1769
2033
  color: "gray",
1770
- onClick: $e,
2034
+ onClick: X,
1771
2035
  "aria-label": "Remove spreadsheet",
1772
- children: /* @__PURE__ */ i(rt, {})
2036
+ children: /* @__PURE__ */ l(ft, {})
1773
2037
  }
1774
2038
  ) })
1775
2039
  ] })
1776
2040
  ] }),
1777
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
1778
- ve(I),
2041
+ /* @__PURE__ */ g(p, { size: "1", color: "gray", children: [
2042
+ Ce(L),
1779
2043
  " max · ",
1780
- we(b)
2044
+ Se(w)
1781
2045
  ] })
1782
2046
  ] }),
1783
- q && J && /* @__PURE__ */ i(f, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: J }),
1784
- /* @__PURE__ */ i("input", { ref: m, type: "file", style: { display: "none" }, accept: b, onChange: Pe }),
1785
- h && !q && /* @__PURE__ */ i(
2047
+ ye && z && /* @__PURE__ */ l(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: z }),
2048
+ /* @__PURE__ */ l("input", { ref: C, type: "file", style: { display: "none" }, accept: w, onChange: Q }),
2049
+ m && !ye && /* @__PURE__ */ l(
1786
2050
  "div",
1787
2051
  {
1788
2052
  role: "button",
1789
2053
  tabIndex: 0,
1790
2054
  onClick: () => {
1791
- var x;
1792
- return (x = m.current) == null ? void 0 : x.click();
2055
+ var S;
2056
+ return (S = C.current) == null ? void 0 : S.click();
1793
2057
  },
1794
- onKeyDown: (x) => {
1795
- var V;
1796
- (x.key === "Enter" || x.key === " ") && (x.preventDefault(), (V = m.current) == null || V.click());
2058
+ onKeyDown: (S) => {
2059
+ var W;
2060
+ (S.key === "Enter" || S.key === " ") && (S.preventDefault(), (W = C.current) == null || W.click());
1797
2061
  },
1798
- onDragEnter: fe,
1799
- onDragLeave: fe,
1800
- onDragOver: fe,
1801
- onDrop: Oe,
2062
+ onDragEnter: x,
2063
+ onDragLeave: x,
2064
+ onDragOver: x,
2065
+ onDrop: V,
1802
2066
  style: { cursor: "pointer" },
1803
2067
  className: [
1804
2068
  "border-2 border-dashed rounded-lg p-6 text-center",
1805
2069
  "transition-all duration-200 ease-in-out",
1806
- R ? "border-blue-500 bg-blue-50" : J ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2070
+ ee ? "border-blue-500 bg-blue-50" : z ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1807
2071
  ].join(" "),
1808
- children: /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: B === "parsing" ? /* @__PURE__ */ y(ge, { children: [
1809
- /* @__PURE__ */ i(Ue, { size: "3" }),
1810
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1811
- ] }) : J ? /* @__PURE__ */ y(ge, { children: [
1812
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1813
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: J }),
1814
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
1815
- ] }) : /* @__PURE__ */ y(ge, { children: [
1816
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1817
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1818
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
1819
- ve(I),
2072
+ children: /* @__PURE__ */ l($, { direction: "column", align: "center", gap: "2", children: ne === "parsing" ? /* @__PURE__ */ g(xe, { children: [
2073
+ /* @__PURE__ */ l(Be, { size: "3" }),
2074
+ /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
2075
+ ] }) : z ? /* @__PURE__ */ g(xe, { children: [
2076
+ /* @__PURE__ */ l(pt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2077
+ /* @__PURE__ */ l(p, { size: "2", color: "red", weight: "medium", children: z }),
2078
+ /* @__PURE__ */ l(p, { size: "1", color: "gray", children: "Click to try again" })
2079
+ ] }) : /* @__PURE__ */ g(xe, { children: [
2080
+ /* @__PURE__ */ l(je, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2081
+ /* @__PURE__ */ l(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2082
+ /* @__PURE__ */ g(p, { size: "1", color: "gray", children: [
2083
+ Ce(L),
1820
2084
  " max · ",
1821
- we(b)
2085
+ Se(w)
1822
2086
  ] })
1823
2087
  ] }) })
1824
2088
  }
1825
2089
  ),
1826
- ie,
1827
- xe && /* @__PURE__ */ i(f, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1828
- Object.keys(re).length > 0 && /* @__PURE__ */ y(S, { mt: "3", children: [
1829
- /* @__PURE__ */ i(f, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1830
- /* @__PURE__ */ i(D, { direction: "column", gap: "1", children: Object.entries(re).map(([x, V]) => /* @__PURE__ */ y(D, { justify: "between", children: [
1831
- /* @__PURE__ */ i(f, { size: "2", children: V.label }),
1832
- V.error ? /* @__PURE__ */ i(f, { size: "2", color: "red", children: V.error }) : (
2090
+ he,
2091
+ me && /* @__PURE__ */ l(p, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
2092
+ Object.keys(le).length > 0 && /* @__PURE__ */ g(M, { mt: "3", children: [
2093
+ /* @__PURE__ */ l(p, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
2094
+ /* @__PURE__ */ l($, { direction: "column", gap: "1", children: Object.entries(le).map(([S, W]) => /* @__PURE__ */ g($, { justify: "between", children: [
2095
+ /* @__PURE__ */ l(p, { size: "2", children: W.label }),
2096
+ W.error ? /* @__PURE__ */ l(p, { size: "2", color: "red", children: W.error }) : (
1833
2097
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1834
2098
  // possible results anymore — INDEX/CONCATENATE can return a
1835
2099
  // string, a bare comparison can return a boolean, etc.), so
1836
2100
  // `.toLocaleString()` would throw for e.g. a boolean result.
1837
2101
  // Reuse the same formatCell used for the sheet-preview grid.
1838
- /* @__PURE__ */ i(f, { size: "2", children: wt(V.value) })
2102
+ /* @__PURE__ */ l(p, { size: "2", children: kt(W.value) })
1839
2103
  )
1840
- ] }, x)) })
2104
+ ] }, S)) })
1841
2105
  ] }),
1842
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
2106
+ !y && /* @__PURE__ */ l(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: Re(c, n) })
1843
2107
  ] });
1844
- }, Vn = ue(_n), jn = ee(
2108
+ }, Ro = be(Ao), Co = ie(
1845
2109
  10,
1846
2110
  // matches FileControlTester's rank — beats the default object/Group renderer
1847
- Ie(
2111
+ ze(
1848
2112
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1849
2113
  )
1850
- ), Hn = "Sheet1", Wn = "xlsx";
1851
- function Bn(e) {
2114
+ ), So = "Sheet1", Oo = "xlsx";
2115
+ function No(e) {
1852
2116
  if (e === void 0) return null;
1853
2117
  if (!Array.isArray(e)) return "columns must be an array of { id, label } objects.";
1854
2118
  if (e.length === 0)
@@ -1858,61 +2122,64 @@ function Bn(e) {
1858
2122
  );
1859
2123
  return r !== -1 ? `columns[${r}] must be a { id, label } object with non-empty string fields.` : null;
1860
2124
  }
1861
- function Xn(e, r) {
1862
- if (!Bt(e)) return e;
1863
- const t = Xt(
2125
+ function Do(e, r) {
2126
+ if (!sr(e)) return e;
2127
+ const t = lr(
1864
2128
  e,
1865
2129
  r == null ? void 0 : r.map((s) => s.id)
1866
2130
  );
1867
2131
  if (!r || t.length === 0) return t;
1868
- const n = new Map(r.map((s) => [s.id, s.label])), [l, ...o] = t;
1869
- return [l.map((s) => n.get(String(s)) ?? s), ...o];
2132
+ const n = new Map(r.map((s) => [s.id, s.label])), [i, ...o] = t;
2133
+ return [i.map((s) => n.get(String(s)) ?? s), ...o];
1870
2134
  }
1871
- const Kn = ({ data: e, label: r, schema: t, visible: n = !0 }) => {
1872
- const [l, o] = j(null);
1873
- if (n === !1)
2135
+ const Io = ({ data: e, path: r, label: t, schema: n, visible: i = !0 }) => {
2136
+ const [o, s] = B(null), a = $e();
2137
+ if (i === !1)
1874
2138
  return null;
1875
- const s = (t == null ? void 0 : t["x-spreadsheet-export"]) ?? {}, c = s.columns, a = s.sheetName ?? Hn, d = s.fileType ?? Wn, u = s.fileName ?? `export.${d}`, h = Bn(c);
1876
- if (h)
1877
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1878
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: r }),
1879
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
2139
+ const c = (n == null ? void 0 : n["x-spreadsheet-export"]) ?? {}, u = c.columns, d = c.sheetName ?? So, y = c.fileType ?? Oo, m = c.fileName ?? `export.${y}`, f = No(u);
2140
+ if (f)
2141
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
2142
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", children: t }),
2143
+ /* @__PURE__ */ g(p, { size: "2", color: "red", style: { display: "block" }, children: [
1880
2144
  "Invalid x-spreadsheet-export config: ",
1881
- h
2145
+ f
1882
2146
  ] })
1883
2147
  ] });
1884
- const p = Array.isArray(e) && e.length > 0, g = async () => {
1885
- if (p) {
1886
- o(null);
2148
+ const T = Array.isArray(e) && e.length > 0, w = async () => {
2149
+ var L, D;
2150
+ if (T) {
2151
+ s(null);
1887
2152
  try {
1888
- const b = await import("@e965/xlsx"), I = Xn(e, c), O = b.utils.aoa_to_sheet(I), T = b.utils.book_new();
1889
- b.utils.book_append_sheet(T, O, a), b.writeFile(T, u, { bookType: d });
1890
- } catch (b) {
1891
- o(b instanceof Error ? b.message : "Failed to build the workbook.");
2153
+ const N = await import("@e965/xlsx"), A = Do(e, u), R = N.utils.aoa_to_sheet(A), v = N.utils.book_new();
2154
+ N.utils.book_append_sheet(v, R, d);
2155
+ const b = r.split(".").slice(0, -1).join("."), U = b ? He.data((L = a.core) == null ? void 0 : L.data, b) : (D = a.core) == null ? void 0 : D.data;
2156
+ N.writeFile(v, mt(m, U, `export.${y}`), { bookType: y });
2157
+ } catch (N) {
2158
+ s(N instanceof Error ? N.message : "Failed to build the workbook.");
1892
2159
  }
1893
2160
  }
1894
2161
  };
1895
- return /* @__PURE__ */ y(S, { mb: "4", children: [
1896
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
1897
- /* @__PURE__ */ y(De, { type: "button", variant: "soft", disabled: !p, onClick: () => void g(), children: [
1898
- /* @__PURE__ */ i(Mt, {}),
2162
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
2163
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: t }),
2164
+ /* @__PURE__ */ g(Ue, { type: "button", variant: "soft", disabled: !T, onClick: () => void w(), children: [
2165
+ /* @__PURE__ */ l(dt, {}),
1899
2166
  " Download Spreadsheet"
1900
2167
  ] }),
1901
- l && /* @__PURE__ */ i(f, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: l })
2168
+ o && /* @__PURE__ */ l(p, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: o })
1902
2169
  ] });
1903
- }, Yn = ue(Kn), Gn = ee(
2170
+ }, ko = be(Io), Lo = ie(
1904
2171
  10,
1905
- Nt(
1906
- Ie((e) => {
2172
+ Wt(
2173
+ ze((e) => {
1907
2174
  const r = e["x-spreadsheet-export"];
1908
2175
  return e.type === "array" && typeof r == "object" && r !== null;
1909
2176
  }),
1910
- sr(lr("editable", !0))
2177
+ Cr(Sr("editable", !0))
1911
2178
  )
1912
2179
  );
1913
- class Ce extends Error {
2180
+ class Le extends Error {
1914
2181
  }
1915
- const Et = 5e6, qn = 1024, Jn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, Zn = {
2182
+ const Lt = 5e6, Mo = 1024, zo = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, Fo = {
1916
2183
  // Default is true, which would silently drop what in many formats is most of
1917
2184
  // the payload.
1918
2185
  ignoreAttributes: !1,
@@ -1959,7 +2226,7 @@ const Et = 5e6, qn = 1024, Jn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["'
1959
2226
  maxNestedTags: 100,
1960
2227
  strictReservedNames: !0
1961
2228
  };
1962
- function Qn(e) {
2229
+ function $o(e) {
1963
2230
  const r = new Set(e);
1964
2231
  return r.size === 0 ? () => !1 : (t, n) => (
1965
2232
  // A string while the library's own `jPath` option is true (the default) and
@@ -1967,650 +2234,736 @@ function Qn(e) {
1967
2234
  r.has(typeof n == "string" ? n : n.toString()) || r.has(t)
1968
2235
  );
1969
2236
  }
1970
- function eo(e) {
2237
+ function Uo(e) {
1971
2238
  const r = e instanceof Error ? e.message : "";
1972
2239
  return r.startsWith("[SECURITY] Invalid name:") ? "This document uses a reserved JavaScript name (__proto__, constructor or prototype) as an element or attribute name, which cannot be represented safely." : r === "External entities are not supported" || r === "Parameter entities are not supported" ? `${r}. Please remove the DOCTYPE entity declarations and try again.` : r.startsWith("Maximum nested tags exceeded") ? "This document is nested too deeply to parse." : r.startsWith("Entity count") || r.includes("exceeds maximum allowed") ? "This document declares too many or too large entity definitions to expand safely." : "This doesn't look like a valid XML document. Please check the file and try again.";
1973
2240
  }
1974
- async function to(e, r = {}) {
1975
- var d;
1976
- if (typeof e != "string") throw new Ce("This file could not be read as text.");
2241
+ async function Po(e, r = {}) {
2242
+ var u;
2243
+ if (typeof e != "string") throw new Le("This file could not be read as text.");
1977
2244
  const t = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
1978
- if (t.trim() === "") throw new Ce("This file is empty.");
1979
- if (t.length > Et)
1980
- throw new Ce(
1981
- `This document is too large to parse (over ${Et / 1e6} million characters).`
2245
+ if (t.trim() === "") throw new Le("This file is empty.");
2246
+ if (t.length > Lt)
2247
+ throw new Le(
2248
+ `This document is too large to parse (over ${Lt / 1e6} million characters).`
1982
2249
  );
1983
- const n = (d = Jn.exec(t.slice(0, qn))) == null ? void 0 : d[1];
2250
+ const n = (u = zo.exec(t.slice(0, Mo))) == null ? void 0 : u[1];
1984
2251
  if (n && !/^utf-?8$/i.test(n))
1985
- throw new Ce(
2252
+ throw new Le(
1986
2253
  `This document declares the unsupported encoding "${n}". Only UTF-8 is supported.`
1987
2254
  );
1988
- const { XMLParser: l, XMLValidator: o } = await import("fast-xml-parser"), s = o.validate(t, { allowBooleanAttributes: !1 });
2255
+ const { XMLParser: i, XMLValidator: o } = await import("fast-xml-parser"), s = o.validate(t, { allowBooleanAttributes: !1 });
1989
2256
  if (s !== !0) {
1990
- const { msg: u, line: h, col: p } = s.err;
1991
- throw new Ce(`Invalid XML at line ${h}, column ${p}: ${u}`);
2257
+ const { msg: d, line: y, col: m } = s.err;
2258
+ throw new Le(`Invalid XML at line ${y}, column ${m}: ${d}`);
1992
2259
  }
1993
- const c = new l({
1994
- ...Zn,
2260
+ const a = new i({
2261
+ ...Fo,
1995
2262
  removeNSPrefix: r.removeNamespaces === !0,
1996
- isArray: Qn(r.arrayPaths ?? [])
2263
+ isArray: $o(r.arrayPaths ?? [])
1997
2264
  });
1998
- let a;
2265
+ let c;
2266
+ try {
2267
+ c = a.parse(t);
2268
+ } catch (d) {
2269
+ throw new Le(Uo(d));
2270
+ }
2271
+ if (c == null || typeof c != "object" || Array.isArray(c))
2272
+ throw new Le("This document has no root element.");
2273
+ return c;
2274
+ }
2275
+ function cr(e, r, t) {
2276
+ const { path: n, default: i } = typeof t == "string" ? { path: t, default: void 0 } : t, o = He.data(e, r ? `${r}.${n}` : n);
2277
+ return o ?? i;
2278
+ }
2279
+ function _o(e, r, t) {
2280
+ const n = {};
2281
+ for (const [i, o] of Object.entries(t)) {
2282
+ const s = cr(e, r, o);
2283
+ if (s === void 0) return;
2284
+ n[i] = s;
2285
+ }
2286
+ return n;
2287
+ }
2288
+ async function jo(e, r) {
1999
2289
  try {
2000
- a = c.parse(t);
2001
- } catch (u) {
2002
- throw new Ce(eo(u));
2290
+ return { status: "ok", value: await nr(e, r) };
2291
+ } catch (t) {
2292
+ return { status: "error", error: gt(t) };
2003
2293
  }
2004
- if (a == null || typeof a != "object" || Array.isArray(a))
2005
- throw new Ce("This document has no root element.");
2006
- return a;
2007
2294
  }
2008
- const ke = { found: !1 }, me = (e) => ({ found: !0, value: e });
2009
- function Tt(e) {
2010
- return e == null || e === "" ? ke : Array.isArray(e) || e instanceof Date ? me(e) : typeof e == "object" ? ke : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? me(e) : ke;
2295
+ function ar(e, r) {
2296
+ return e == null ? "" : typeof e == "number" ? e.toFixed(Vo(r)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2297
+ }
2298
+ function Vo(e) {
2299
+ return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
2011
2300
  }
2012
- const ro = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), no = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
2013
- async function oo(e, r) {
2301
+ const Me = { found: !1 }, ve = (e) => ({ found: !0, value: e });
2302
+ function Mt(e) {
2303
+ return e == null || e === "" ? Me : Array.isArray(e) || e instanceof Date ? ve(e) : typeof e == "object" ? Me : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? ve(e) : Me;
2304
+ }
2305
+ const Wo = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), Ho = /* @__PURE__ */ new Set(["false", "0", "no", "n"]), Bo = /^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;
2306
+ async function Xo(e, r, t) {
2014
2307
  switch (r.as) {
2015
2308
  case void 0:
2016
- return me(e);
2309
+ return ve(e);
2017
2310
  case "string":
2018
- return me(e instanceof Date ? e.toISOString() : String(e));
2311
+ return ve(e instanceof Date ? e.toISOString() : String(e));
2019
2312
  case "number": {
2020
- const t = e instanceof Date ? e.getTime() : Number(e);
2021
- return Number.isFinite(t) ? me(t) : ke;
2313
+ const n = e instanceof Date ? e.getTime() : Number(e);
2314
+ return Number.isFinite(n) ? ve(r.decimals === void 0 ? n : ar(n, r.decimals)) : Me;
2022
2315
  }
2023
2316
  case "boolean": {
2024
- const t = String(e).trim().toLowerCase();
2025
- return ro.has(t) ? me(!0) : no.has(t) ? me(!1) : ke;
2317
+ const n = String(e).trim().toLowerCase();
2318
+ return Wo.has(n) ? ve(!0) : Ho.has(n) ? ve(!1) : Me;
2026
2319
  }
2027
2320
  case "date": {
2028
- const { default: t } = await import("dayjs"), { default: n } = await import("./customParseFormat-D14EWdSX.js").then((s) => s.c);
2029
- t.extend(n);
2030
- const l = e instanceof Date ? e.toISOString() : String(e), o = r.format ? t(l, r.format, !0) : t(l);
2031
- return o.isValid() ? me(o.format("YYYY-MM-DD")) : ke;
2321
+ const { default: n } = await import("dayjs"), { default: i } = await import("./customParseFormat-D14EWdSX.js").then((a) => a.c);
2322
+ if (n.extend(i), t === "export") {
2323
+ const a = typeof e == "string" ? Bo.exec(e) : null, c = e instanceof Date ? n(e) : a ? n(a[1], "YYYY-MM-DD", !0) : null;
2324
+ return c != null && c.isValid() ? ve(c.format(r.format ?? "YYYY-MM-DD")) : Me;
2325
+ }
2326
+ const o = e instanceof Date ? e.toISOString() : String(e), s = r.format ? n(o, r.format, !0) : n(o);
2327
+ return s.isValid() ? ve(s.format("YYYY-MM-DD")) : Me;
2032
2328
  }
2033
2329
  }
2034
2330
  }
2035
- async function io(e, r) {
2331
+ async function qo(e, r) {
2036
2332
  if (r.formula !== void 0) {
2037
2333
  const t = {};
2038
- for (const [n, l] of Object.entries(r.inputs ?? {})) {
2039
- const o = Tt(Ve.data(e, l));
2040
- if (!o.found || Array.isArray(o.value)) return ke;
2334
+ for (const [n, i] of Object.entries(r.inputs ?? {})) {
2335
+ const o = Mt(He.data(e, i));
2336
+ if (!o.found || Array.isArray(o.value)) return Me;
2041
2337
  t[n] = o.value;
2042
2338
  }
2043
2339
  try {
2044
- return me(await jt(t, r.formula));
2340
+ return ve(await nr(t, r.formula));
2045
2341
  } catch (n) {
2046
- throw new Error(`writeTo "${r.to}": ${st(n)}`);
2342
+ throw new Error(`writeTo "${r.to}": ${gt(n)}`);
2047
2343
  }
2048
2344
  }
2049
2345
  if (r.from === void 0) throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);
2050
- return Tt(Ve.data(e, r.from));
2051
- }
2052
- function Kt(e) {
2053
- const r = {};
2054
- for (const { to: t, value: n } of e) {
2055
- const l = t.split(".").filter(Boolean);
2056
- if (l.length === 0) continue;
2057
- let o = r;
2058
- for (const s of l.slice(0, -1)) {
2059
- const c = o[s];
2060
- if (c && typeof c == "object" && !Array.isArray(c))
2061
- o = c;
2062
- else {
2063
- const a = {};
2064
- o[s] = a, o = a;
2065
- }
2346
+ return Mt(He.data(e, r.from));
2347
+ }
2348
+ const rt = "@_", ur = "#text", nt = (e) => e.split(".").filter(Boolean), dr = (e) => e.startsWith(rt) || e === ur;
2349
+ function fr(e, r) {
2350
+ if (typeof e.to != "string" || nt(e.to).length === 0) return '"to" must be a non-empty path.';
2351
+ if (e.format !== void 0 && e.as !== "date") return '"format" needs "as": "date".';
2352
+ if (e.decimals !== void 0) {
2353
+ if (r === "import")
2354
+ return '"decimals" only applies on export — on import it would put text in a number field.';
2355
+ if (e.as !== "number") return '"decimals" needs "as": "number".';
2356
+ const { decimals: t } = e;
2357
+ if (!Number.isInteger(t) || t < 0 || t > 100)
2358
+ return '"decimals" must be a whole number from 0 to 100.';
2359
+ }
2360
+ if (r === "export") {
2361
+ const t = nt(e.to);
2362
+ for (const [n, i] of t.entries()) {
2363
+ if (i === rt) return '"@_" needs an attribute name after it, e.g. "@_id".';
2364
+ if (dr(i) && n < t.length - 1)
2365
+ return `"${i}" must be the last segment — it belongs to the element before it.`;
2366
+ }
2367
+ }
2368
+ return null;
2369
+ }
2370
+ function zt(e, r, t) {
2371
+ const n = t ? ` To give "${r}" both text and attributes, write its text to "${r}.${ur}".` : "";
2372
+ return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${n}`);
2373
+ }
2374
+ function pr(e) {
2375
+ const r = {}, t = /* @__PURE__ */ new Set([r]);
2376
+ for (const { to: n, value: i } of e) {
2377
+ const o = nt(n);
2378
+ if (o.length === 0) continue;
2379
+ let s = r;
2380
+ for (const [u, d] of o.slice(0, -1).entries()) {
2381
+ const y = s[d];
2382
+ if (y === void 0) {
2383
+ const m = {};
2384
+ t.add(m), s[d] = m, s = m;
2385
+ } else if (t.has(y))
2386
+ s = y;
2387
+ else
2388
+ throw zt(n, o.slice(0, u + 1).join("."), o[u + 1].startsWith(rt));
2389
+ }
2390
+ const a = o[o.length - 1], c = s[a];
2391
+ if (t.has(c)) {
2392
+ const u = Object.keys(c).some((d) => d.startsWith(rt));
2393
+ throw zt(n, o.join("."), u);
2066
2394
  }
2067
- o[l[l.length - 1]] = n;
2395
+ s[a] = i;
2068
2396
  }
2069
2397
  return r;
2070
2398
  }
2071
- async function lt(e, r) {
2072
- const t = [];
2073
- for (const n of r) {
2074
- let l = await io(e, n);
2075
- const o = l.found && Array.isArray(l.value);
2076
- if (l.found && o && n.writeTo) {
2077
- const s = await Promise.all(
2078
- l.value.map(
2079
- async (c) => Kt(await lt(c, n.writeTo))
2399
+ const Ko = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean";
2400
+ async function yt(e, r, t) {
2401
+ const n = [];
2402
+ for (const i of r) {
2403
+ const o = fr(i, t);
2404
+ if (o) throw new Error(`writeTo "${i.to}": ${o}`);
2405
+ const s = nt(i.to), a = t === "export" && dr(s[s.length - 1]), c = (y) => {
2406
+ if (!(a && y == null)) {
2407
+ if (a && !Ko(y)) {
2408
+ const m = y instanceof Date ? ' Add "as": "date" to write a date.' : "";
2409
+ throw new Error(
2410
+ `writeTo "${i.to}": an attribute or #text value must be text, a number or a boolean.${m}`
2411
+ );
2412
+ }
2413
+ n.push({ to: i.to, value: y });
2414
+ }
2415
+ };
2416
+ let u = await qo(e, i);
2417
+ const d = u.found && Array.isArray(u.value);
2418
+ if (u.found && d && i.writeTo) {
2419
+ const y = await Promise.all(
2420
+ u.value.map(
2421
+ async (m) => pr(await yt(m, i.writeTo, t))
2080
2422
  )
2081
2423
  );
2082
- t.push({ to: n.to, value: s });
2424
+ c(y);
2083
2425
  continue;
2084
2426
  }
2085
- if (l.found && !o && n.writeTo)
2086
- throw new Error(`writeTo "${n.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);
2087
- if (l.found && !o && n.map) {
2088
- const s = l.value instanceof Date ? l.value.toISOString() : String(l.value);
2089
- Object.prototype.hasOwnProperty.call(n.map, s) && (l = me(n.map[s]));
2427
+ if (u.found && !d && i.writeTo)
2428
+ throw new Error(`writeTo "${i.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);
2429
+ if (u.found && !d && i.map) {
2430
+ const y = u.value instanceof Date ? u.value.toISOString() : String(u.value);
2431
+ Object.prototype.hasOwnProperty.call(i.map, y) && (u = ve(i.map[y]));
2090
2432
  }
2091
- if (l.found && !o && (l = await oo(l.value, n)), !l.found) {
2092
- if (n.default === void 0) continue;
2093
- t.push({ to: n.to, value: n.default });
2433
+ if (u.found && !d && (u = await Xo(u.value, i, t)), !u.found) {
2434
+ if (i.default === void 0) continue;
2435
+ c(i.default);
2094
2436
  continue;
2095
2437
  }
2096
- t.push({ to: n.to, value: l.value });
2438
+ c(u.value);
2097
2439
  }
2098
- return t;
2440
+ return n;
2099
2441
  }
2100
- const so = ".xml,text/xml,application/xml", lo = 5 * 1024 * 1024, co = ({
2442
+ const Yo = ".xml,text/xml,application/xml", Go = 5 * 1024 * 1024, Jo = ({
2101
2443
  data: e,
2102
2444
  handleChange: r,
2103
2445
  path: t,
2104
2446
  label: n,
2105
- required: l,
2447
+ required: i,
2106
2448
  schema: o,
2107
2449
  enabled: s,
2108
- readonly: c,
2109
- errors: a,
2110
- visible: d = !0
2450
+ readonly: a,
2451
+ errors: c,
2452
+ visible: u = !0
2111
2453
  }) => {
2112
- Ee(d, t, r);
2113
- const u = !a || a.length === 0, h = $t(s, c), p = (o == null ? void 0 : o["x-xml"]) ?? {}, g = p.accept ?? so, b = p.maxSize ?? lo, I = p.arrayPaths, O = p.removeNamespaces === !0, T = p.writeTo, A = p.writeBase ?? "root", k = p.persistDocument !== !1, M = We(), L = e ?? null, [N, U] = j(() => L ? "ready" : "empty"), [z, v] = j(null), [E, B] = j(!1), K = ae(null), J = ae(0), F = L != null, R = T !== void 0 && T.length > 0, Y = Fe(
2114
- async (m) => {
2115
- var ie;
2116
- const C = ++J.current;
2117
- if (v(null), m.size > b) {
2118
- v(`File exceeds the ${ve(b)} limit.`);
2454
+ Oe(u, t, r);
2455
+ const d = Ae(t, i, u), y = !c || c.length === 0, m = er(s, a), f = (o == null ? void 0 : o["x-xml"]) ?? {}, T = f.accept ?? Yo, w = f.maxSize ?? Go, L = f.arrayPaths, D = f.removeNamespaces === !0, N = f.writeTo, A = f.writeBase ?? "root", R = f.persistDocument !== !1, v = $e(), b = e ?? null, [U, P] = B(() => b ? "ready" : "empty"), [O, j] = B(null), [I, ne] = B(!1), Y = ge(null), z = ge(0), _ = b != null, ee = N !== void 0 && N.length > 0, fe = We(
2456
+ async (C) => {
2457
+ var he;
2458
+ const J = ++z.current;
2459
+ if (j(null), C.size > w) {
2460
+ j(`File exceeds the ${Ce(w)} limit.`);
2119
2461
  return;
2120
2462
  }
2121
- if (!g.split(",").map(($) => $.trim()).some(($) => $ === "*" || $ === "*/*" ? !0 : $.endsWith("/*") ? m.type.startsWith($.slice(0, -1)) : $.startsWith(".") ? m.name.toLowerCase().endsWith($.toLowerCase()) : m.type === $)) {
2122
- v(`Invalid type. Accepted: ${we(g)}`);
2463
+ if (!T.split(",").map((h) => h.trim()).some((h) => h === "*" || h === "*/*" ? !0 : h.endsWith("/*") ? C.type.startsWith(h.slice(0, -1)) : h.startsWith(".") ? C.name.toLowerCase().endsWith(h.toLowerCase()) : C.type === h)) {
2464
+ j(`Invalid type. Accepted: ${Se(T)}`);
2123
2465
  return;
2124
2466
  }
2125
- U("parsing");
2126
- let _;
2467
+ P("parsing");
2468
+ let Z;
2127
2469
  try {
2128
- const $ = await m.text();
2129
- _ = await to($, { arrayPaths: I, removeNamespaces: O });
2130
- } catch ($) {
2131
- if (C !== J.current) return;
2132
- U("error"), v(
2133
- $ instanceof Ce ? $.message : "This doesn't look like a valid XML document. Please check the file and try again."
2470
+ const h = await C.text();
2471
+ Z = await Po(h, { arrayPaths: L, removeNamespaces: D });
2472
+ } catch (h) {
2473
+ if (J !== z.current) return;
2474
+ P("error"), j(
2475
+ h instanceof Le ? h.message : "This doesn't look like a valid XML document. Please check the file and try again."
2134
2476
  );
2135
2477
  return;
2136
2478
  }
2137
- let re = [];
2138
- if (T && T.length > 0)
2479
+ let le = [];
2480
+ if (N && N.length > 0)
2139
2481
  try {
2140
- re = await lt(_, T);
2141
- } catch ($) {
2142
- if (C !== J.current) return;
2143
- U("error"), v($ instanceof Error ? $.message : "This document could not be mapped onto the form.");
2482
+ le = await yt(Z, N, "import");
2483
+ } catch (h) {
2484
+ if (J !== z.current) return;
2485
+ P("error"), j(h instanceof Error ? h.message : "This document could not be mapped onto the form.");
2144
2486
  return;
2145
2487
  }
2146
- if (C !== J.current) return;
2147
- k && r(t, _);
2148
- const q = A === "parent" ? t.split(".").slice(0, -1).join(".") : "";
2149
- for (const $ of re) (ie = M.dispatch) == null || ie.call(M, cr(q ? `${q}.${$.to}` : $.to, () => $.value));
2150
- U("ready");
2488
+ if (J !== z.current) return;
2489
+ R && r(t, Z);
2490
+ const ye = A === "parent" ? t.split(".").slice(0, -1).join(".") : "";
2491
+ for (const h of le) (he = v.dispatch) == null || he.call(v, Or(ye ? `${ye}.${h.to}` : h.to, () => h.value));
2492
+ P("ready");
2151
2493
  },
2152
- [g, b, I, O, T, A, k, t, r, M]
2494
+ [T, w, L, D, N, A, R, t, r, v]
2153
2495
  );
2154
- if (d === !1 || !h && !F) return null;
2155
- const Q = (m) => {
2156
- m.preventDefault(), m.stopPropagation(), h && B(m.type === "dragenter" || m.type === "dragover");
2157
- }, be = (m) => {
2158
- var C;
2159
- m.preventDefault(), m.stopPropagation(), B(!1), h && (C = m.dataTransfer.files) != null && C[0] && Y(m.dataTransfer.files[0]);
2160
- }, oe = (m) => {
2161
- var C;
2162
- (C = m.target.files) != null && C[0] && (Y(m.target.files[0]), m.target.value = "");
2496
+ if (u === !1 || !m && !_) return null;
2497
+ const oe = (C) => {
2498
+ C.preventDefault(), C.stopPropagation(), m && ne(C.type === "dragenter" || C.type === "dragover");
2499
+ }, te = (C) => {
2500
+ var J;
2501
+ C.preventDefault(), C.stopPropagation(), ne(!1), m && (J = C.dataTransfer.files) != null && J[0] && fe(C.dataTransfer.files[0]);
2502
+ }, k = (C) => {
2503
+ var J;
2504
+ (J = C.target.files) != null && J[0] && (fe(C.target.files[0]), C.target.value = "");
2163
2505
  };
2164
- return /* @__PURE__ */ y(S, { mb: "4", children: [
2165
- /* @__PURE__ */ y(D, { align: "center", justify: "between", mb: "2", children: [
2166
- /* @__PURE__ */ y(D, { align: "center", gap: "1", children: [
2167
- /* @__PURE__ */ y(f, { as: "label", size: "2", weight: "bold", children: [
2506
+ return /* @__PURE__ */ g(M, { mb: "4", children: [
2507
+ /* @__PURE__ */ g($, { align: "center", justify: "between", mb: "2", children: [
2508
+ /* @__PURE__ */ g($, { align: "center", gap: "1", children: [
2509
+ /* @__PURE__ */ g(p, { as: "label", size: "2", weight: "bold", children: [
2168
2510
  n,
2169
- l && /* @__PURE__ */ i(f, { color: "red", children: " *" })
2511
+ d && /* @__PURE__ */ l(p, { color: "red", children: " *" })
2170
2512
  ] }),
2171
- !R && F && h && /* @__PURE__ */ y(ge, { children: [
2172
- /* @__PURE__ */ i(qe, { content: "Replace document", children: /* @__PURE__ */ i(
2173
- je,
2513
+ !ee && _ && m && /* @__PURE__ */ g(xe, { children: [
2514
+ /* @__PURE__ */ l(Ke, { content: "Replace document", children: /* @__PURE__ */ l(
2515
+ Xe,
2174
2516
  {
2175
2517
  variant: "ghost",
2176
2518
  size: "1",
2177
2519
  onClick: () => {
2178
- var m;
2179
- return (m = K.current) == null ? void 0 : m.click();
2520
+ var C;
2521
+ return (C = Y.current) == null ? void 0 : C.click();
2180
2522
  },
2181
2523
  "aria-label": "Replace document",
2182
- children: /* @__PURE__ */ i(ze, {})
2524
+ children: /* @__PURE__ */ l(je, {})
2183
2525
  }
2184
2526
  ) }),
2185
- /* @__PURE__ */ i(qe, { content: "Remove document", children: /* @__PURE__ */ i(je, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2186
- h && (++J.current, v(null), U("empty"), r(t, void 0));
2187
- }, "aria-label": "Remove document", children: /* @__PURE__ */ i(rt, {}) }) })
2527
+ /* @__PURE__ */ l(Ke, { content: "Remove document", children: /* @__PURE__ */ l(Xe, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2528
+ m && (++z.current, j(null), P("empty"), r(t, void 0));
2529
+ }, "aria-label": "Remove document", children: /* @__PURE__ */ l(ft, {}) }) })
2188
2530
  ] })
2189
2531
  ] }),
2190
- /* @__PURE__ */ y(D, { align: "center", gap: "2", children: [
2191
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
2192
- ve(b),
2532
+ /* @__PURE__ */ g($, { align: "center", gap: "2", children: [
2533
+ /* @__PURE__ */ g(p, { size: "1", color: "gray", children: [
2534
+ Ce(w),
2193
2535
  " max · ",
2194
- we(g)
2536
+ Se(T)
2195
2537
  ] }),
2196
- R && h && /* @__PURE__ */ y(De, { size: "1", variant: "soft", onClick: () => {
2197
- var m;
2198
- return (m = K.current) == null ? void 0 : m.click();
2199
- }, disabled: N === "parsing", children: [
2200
- N === "parsing" ? /* @__PURE__ */ i(Ue, { size: "1" }) : /* @__PURE__ */ i(ze, {}),
2538
+ ee && m && /* @__PURE__ */ g(Ue, { size: "1", variant: "soft", onClick: () => {
2539
+ var C;
2540
+ return (C = Y.current) == null ? void 0 : C.click();
2541
+ }, disabled: U === "parsing", children: [
2542
+ U === "parsing" ? /* @__PURE__ */ l(Be, { size: "1" }) : /* @__PURE__ */ l(je, {}),
2201
2543
  "Upload"
2202
2544
  ] })
2203
2545
  ] })
2204
2546
  ] }),
2205
- (R || F) && z && /* @__PURE__ */ i(f, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: z }),
2206
- /* @__PURE__ */ i("input", { ref: K, type: "file", style: { display: "none" }, accept: g, onChange: oe }),
2207
- !R && h && !F && /* @__PURE__ */ i(
2547
+ (ee || _) && O && /* @__PURE__ */ l(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: O }),
2548
+ /* @__PURE__ */ l("input", { ref: Y, type: "file", style: { display: "none" }, accept: T, onChange: k }),
2549
+ !ee && m && !_ && /* @__PURE__ */ l(
2208
2550
  "div",
2209
2551
  {
2210
2552
  role: "button",
2211
2553
  tabIndex: 0,
2212
2554
  onClick: () => {
2213
- var m;
2214
- return (m = K.current) == null ? void 0 : m.click();
2215
- },
2216
- onKeyDown: (m) => {
2217
2555
  var C;
2218
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), (C = K.current) == null || C.click());
2556
+ return (C = Y.current) == null ? void 0 : C.click();
2557
+ },
2558
+ onKeyDown: (C) => {
2559
+ var J;
2560
+ (C.key === "Enter" || C.key === " ") && (C.preventDefault(), (J = Y.current) == null || J.click());
2219
2561
  },
2220
- onDragEnter: Q,
2221
- onDragLeave: Q,
2222
- onDragOver: Q,
2223
- onDrop: be,
2562
+ onDragEnter: oe,
2563
+ onDragLeave: oe,
2564
+ onDragOver: oe,
2565
+ onDrop: te,
2224
2566
  style: { cursor: "pointer" },
2225
2567
  className: [
2226
2568
  "border-2 border-dashed rounded-lg p-6 text-center",
2227
2569
  "transition-all duration-200 ease-in-out",
2228
- E ? "border-blue-500 bg-blue-50" : z ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2570
+ I ? "border-blue-500 bg-blue-50" : O ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2229
2571
  ].join(" "),
2230
- children: /* @__PURE__ */ i(D, { direction: "column", align: "center", gap: "2", children: N === "parsing" ? /* @__PURE__ */ y(ge, { children: [
2231
- /* @__PURE__ */ i(Ue, { size: "3" }),
2232
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Parsing document…" })
2233
- ] }) : z ? /* @__PURE__ */ y(ge, { children: [
2234
- /* @__PURE__ */ i(nt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2235
- /* @__PURE__ */ i(f, { size: "2", color: "red", weight: "medium", children: z }),
2236
- /* @__PURE__ */ i(f, { size: "1", color: "gray", children: "Click to try again" })
2237
- ] }) : /* @__PURE__ */ y(ge, { children: [
2238
- /* @__PURE__ */ i(ze, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2239
- /* @__PURE__ */ i(f, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2240
- /* @__PURE__ */ y(f, { size: "1", color: "gray", children: [
2241
- ve(b),
2572
+ children: /* @__PURE__ */ l($, { direction: "column", align: "center", gap: "2", children: U === "parsing" ? /* @__PURE__ */ g(xe, { children: [
2573
+ /* @__PURE__ */ l(Be, { size: "3" }),
2574
+ /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "Parsing document…" })
2575
+ ] }) : O ? /* @__PURE__ */ g(xe, { children: [
2576
+ /* @__PURE__ */ l(pt, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2577
+ /* @__PURE__ */ l(p, { size: "2", color: "red", weight: "medium", children: O }),
2578
+ /* @__PURE__ */ l(p, { size: "1", color: "gray", children: "Click to try again" })
2579
+ ] }) : /* @__PURE__ */ g(xe, { children: [
2580
+ /* @__PURE__ */ l(je, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2581
+ /* @__PURE__ */ l(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2582
+ /* @__PURE__ */ g(p, { size: "1", color: "gray", children: [
2583
+ Ce(w),
2242
2584
  " max · ",
2243
- we(g)
2585
+ Se(T)
2244
2586
  ] })
2245
2587
  ] }) })
2246
2588
  }
2247
2589
  ),
2248
- !u && /* @__PURE__ */ i(f, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ye(a, n) })
2590
+ !y && /* @__PURE__ */ l(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: Re(c, n) })
2249
2591
  ] });
2250
- }, ao = ue(co), uo = ee(
2592
+ }, Zo = be(Jo), Qo = ie(
2251
2593
  10,
2252
- Ie((e) => {
2594
+ ze((e) => {
2253
2595
  const r = e["x-xml"];
2254
2596
  return e.type === "object" && typeof r == "object" && r !== null;
2255
2597
  })
2256
- );
2257
- function fo(e, r, t) {
2258
- const n = new Blob([e], { type: t }), l = URL.createObjectURL(n), o = document.createElement("a");
2259
- o.href = l, o.download = r, o.click(), URL.revokeObjectURL(l);
2598
+ ), ei = "root", Ft = "export.xml", ti = {
2599
+ format: !0,
2600
+ indentBy: " ",
2601
+ ignoreAttributes: !1,
2602
+ attributeNamePrefix: "@_",
2603
+ textNodeName: "#text",
2604
+ suppressBooleanAttributes: !1,
2605
+ processEntities: !0
2606
+ };
2607
+ function ri(e) {
2608
+ if (e === null || typeof e != "object" || Array.isArray(e))
2609
+ return 'declaration must be an object, e.g. { "standalone": "no" }, or {} for the defaults.';
2610
+ const { version: r, encoding: t, standalone: n, ...i } = e, [o] = Object.keys(i);
2611
+ return o ? `declaration has an unknown key "${o}" — only version, encoding and standalone.` : r !== void 0 && r !== "1.0" && r !== "1.1" ? 'declaration.version must be "1.0" or "1.1".' : t !== void 0 && t !== "UTF-8" ? 'declaration.encoding can only be "UTF-8" — the file is always written as UTF-8.' : n !== void 0 && n !== "yes" && n !== "no" ? 'declaration.standalone must be "yes" or "no".' : null;
2612
+ }
2613
+ function hr(e) {
2614
+ for (const r of e) {
2615
+ if (r === null || typeof r != "object" || Array.isArray(r))
2616
+ return "every writeTo entry must be an object.";
2617
+ const { to: t, writeTo: n } = r, i = fr(r, "export");
2618
+ if (i) return `writeTo "${t}": ${i}`;
2619
+ if (n !== void 0) {
2620
+ if (!Array.isArray(n)) return `writeTo "${t}": its nested writeTo must be an array.`;
2621
+ const o = hr(n);
2622
+ if (o) return o;
2623
+ }
2624
+ }
2625
+ return null;
2626
+ }
2627
+ function ni({ writeTo: e, declaration: r }) {
2628
+ return e === void 0 ? "writeTo is required — see docs/xml-export-control.md." : Array.isArray(e) ? e.length === 0 ? "writeTo is declared but empty — declare at least one entry." : hr(e) ?? (r === void 0 ? null : ri(r)) : "writeTo must be an array of { from | formula, to } entries.";
2260
2629
  }
2261
- const po = "root", ho = "export.xml";
2262
- function mo(e) {
2263
- return e === void 0 ? "writeTo is required — see docs/xml-export-control.md." : Array.isArray(e) ? e.length === 0 ? "writeTo is declared but empty — declare at least one entry." : null : "writeTo must be an array of { from | formula, to } entries.";
2630
+ function oi({ version: e = "1.0", standalone: r }) {
2631
+ return { "@_version": e, "@_encoding": "UTF-8", ...r && { "@_standalone": r } };
2264
2632
  }
2265
- function go(e) {
2633
+ function ii(e) {
2266
2634
  return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1;
2267
2635
  }
2268
- const yo = ({ path: e, label: r, schema: t, visible: n = !0 }) => {
2269
- var T, A;
2270
- const l = (t == null ? void 0 : t["x-xml-export"]) ?? {}, o = l.rootElement ?? po, s = l.fileName ?? ho, c = l.writeTo, a = l.writeBase ?? "root", d = mo(c), u = We(), h = a === "parent" ? e.split(".").slice(0, -1).join(".") : "", p = h ? Ve.data((T = u.core) == null ? void 0 : T.data, h) : (A = u.core) == null ? void 0 : A.data, [g, b] = j(null), I = go(p), O = Fe(async () => {
2271
- if (!c) return;
2272
- b(null);
2273
- let k;
2274
- try {
2275
- const z = await lt(p, c);
2276
- k = Kt(z);
2277
- } catch (z) {
2278
- b(z instanceof Error ? z.message : "This mapping could not be resolved.");
2279
- return;
2636
+ const si = ({ path: e, label: r, schema: t, visible: n = !0 }) => {
2637
+ var N, A;
2638
+ const i = (t == null ? void 0 : t["x-xml-export"]) ?? {}, o = i.rootElement ?? ei, s = i.fileName ?? Ft, a = i.writeTo, c = i.writeBase ?? "root", u = i.declaration, d = ni(i), y = $e(), m = c === "parent" ? e.split(".").slice(0, -1).join(".") : "", f = m ? He.data((N = y.core) == null ? void 0 : N.data, m) : (A = y.core) == null ? void 0 : A.data, [T, w] = B(null), L = ii(f), D = We(async () => {
2639
+ if (a) {
2640
+ w(null);
2641
+ try {
2642
+ const R = pr(await yt(f, a, "export")), { XMLBuilder: v } = await import("fast-xml-parser"), b = {
2643
+ ...u && { "?xml": oi(u) },
2644
+ [o]: R
2645
+ }, U = new v(ti).build(b);
2646
+ zn(U, mt(s, f, Ft), "application/xml");
2647
+ } catch (R) {
2648
+ w(R instanceof Error ? R.message : "This export could not be built.");
2649
+ }
2280
2650
  }
2281
- const { XMLBuilder: M } = await import("fast-xml-parser"), L = { [o]: k }, U = new M({ format: !0, indentBy: " ", ignoreAttributes: !0 }).build(L);
2282
- fo(U, s, "application/xml");
2283
- }, [c, p, o, s]);
2284
- return n === !1 ? null : d ? /* @__PURE__ */ y(S, { mb: "4", children: [
2285
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: r }),
2286
- /* @__PURE__ */ y(f, { size: "2", color: "red", style: { display: "block" }, children: [
2651
+ }, [a, f, u, o, s]);
2652
+ return n === !1 ? null : d ? /* @__PURE__ */ g(M, { mb: "4", children: [
2653
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", children: r }),
2654
+ /* @__PURE__ */ g(p, { size: "2", color: "red", style: { display: "block" }, children: [
2287
2655
  "Invalid x-xml-export config: ",
2288
2656
  d
2289
2657
  ] })
2290
- ] }) : /* @__PURE__ */ y(S, { mb: "4", children: [
2291
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
2292
- /* @__PURE__ */ y(De, { size: "1", variant: "soft", disabled: I, onClick: () => void O(), children: [
2293
- /* @__PURE__ */ i(Mt, {}),
2658
+ ] }) : /* @__PURE__ */ g(M, { mb: "4", children: [
2659
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
2660
+ /* @__PURE__ */ g(Ue, { size: "1", variant: "soft", disabled: L, onClick: () => void D(), children: [
2661
+ /* @__PURE__ */ l(dt, {}),
2294
2662
  "Download XML"
2295
2663
  ] }),
2296
- g && /* @__PURE__ */ i(f, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: g })
2664
+ T && /* @__PURE__ */ l(p, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: T })
2297
2665
  ] });
2298
- }, bo = ue(yo), vo = ee(
2666
+ }, li = be(si), ci = ie(
2299
2667
  10,
2300
- Ie((e) => {
2668
+ ze((e) => {
2301
2669
  const r = e["x-xml-export"];
2302
2670
  return e.type === "object" && typeof r == "object" && r !== null;
2303
2671
  })
2304
- );
2305
- function Yt(e, r, t) {
2306
- const { path: n, default: l } = typeof t == "string" ? { path: t, default: void 0 } : t, o = Ve.data(e, r ? `${r}.${n}` : n);
2307
- return o ?? l;
2308
- }
2309
- function wo(e, r, t) {
2310
- const n = {};
2311
- for (const [l, o] of Object.entries(t)) {
2312
- const s = Yt(e, r, o);
2313
- if (s === void 0) return;
2314
- n[l] = s;
2315
- }
2316
- return n;
2317
- }
2318
- async function Eo(e, r) {
2319
- try {
2320
- return { status: "ok", value: await jt(e, r) };
2321
- } catch (t) {
2322
- return { status: "error", error: st(t) };
2323
- }
2324
- }
2325
- function To(e, r) {
2326
- return e == null ? "" : typeof e == "number" ? e.toFixed(Ao(r)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2327
- }
2328
- function Ao(e) {
2329
- return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
2330
- }
2331
- const xo = "{value}", Ro = 2, Co = {}, So = ({ data: e, handleChange: r, path: t, label: n, schema: l, visible: o = !0 }) => {
2332
- var N;
2333
- Ee(o, t, r);
2334
- const s = l == null ? void 0 : l["x-computed"], c = (s == null ? void 0 : s.inputs) ?? Co, a = (s == null ? void 0 : s.formula) ?? "", d = (s == null ? void 0 : s.format) ?? xo, u = (s == null ? void 0 : s.decimals) ?? Ro, h = We(), p = t.split(".").slice(0, -1).join("."), g = wo((N = h.core) == null ? void 0 : N.data, p, c), b = g ? JSON.stringify(g) : null, I = h.readonly === !0, [O, T] = j(() => typeof e == "number" ? "ok" : "unavailable"), [A, k] = j(() => typeof e == "number" ? e : null), [M, L] = j(null);
2335
- return de(() => {
2672
+ ), ai = "{value}", ui = 2, di = {}, fi = ({ data: e, handleChange: r, path: t, label: n, schema: i, visible: o = !0 }) => {
2673
+ var b;
2674
+ Oe(o, t, r);
2675
+ const s = i == null ? void 0 : i["x-computed"], a = (s == null ? void 0 : s.inputs) ?? di, c = (s == null ? void 0 : s.formula) ?? "", u = (s == null ? void 0 : s.format) ?? ai, d = (s == null ? void 0 : s.decimals) ?? ui, y = $e(), m = t.split(".").slice(0, -1).join("."), f = _o((b = y.core) == null ? void 0 : b.data, m, a), T = f ? JSON.stringify(f) : null, w = y.readonly === !0, [L, D] = B(() => typeof e == "number" ? "ok" : "unavailable"), [N, A] = B(() => typeof e == "number" ? e : null), [R, v] = B(null);
2676
+ return we(() => {
2336
2677
  if (!o) return;
2337
2678
  let U = !1;
2338
- const z = (v) => {
2339
- I || v !== e && r(t, v);
2679
+ const P = (O) => {
2680
+ w || O !== e && r(t, O);
2340
2681
  };
2341
- if (g === void 0) {
2342
- T("unavailable"), L(null), k(null), z(void 0);
2682
+ if (f === void 0) {
2683
+ D("unavailable"), v(null), A(null), P(void 0);
2343
2684
  return;
2344
2685
  }
2345
- return T((v) => v === "ok" ? v : "loading"), Eo(g, a).then((v) => {
2686
+ return D((O) => O === "ok" ? O : "loading"), jo(f, c).then((O) => {
2346
2687
  if (U) return;
2347
- const E = v.status === "ok" && typeof v.value == "number" && Number.isFinite(v.value) ? v.value : null;
2348
- if (E === null) {
2349
- T("error"), L(
2350
- v.status === "error" ? v.error ?? "Unable to compute value." : "Computed value must be a number."
2351
- ), k(null), z(void 0);
2688
+ const j = O.status === "ok" && typeof O.value == "number" && Number.isFinite(O.value) ? O.value : null;
2689
+ if (j === null) {
2690
+ D("error"), v(
2691
+ O.status === "error" ? O.error ?? "Unable to compute value." : "Computed value must be a number."
2692
+ ), A(null), P(void 0);
2352
2693
  return;
2353
2694
  }
2354
- T("ok"), L(null), k(E), z(E);
2695
+ D("ok"), v(null), A(j), P(j);
2355
2696
  }), () => {
2356
2697
  U = !0;
2357
2698
  };
2358
- }, [b, a, o, I]), o === !1 ? null : /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ y(D, { direction: "column", gap: "1", children: [
2359
- /* @__PURE__ */ i(f, { as: "label", size: "2", weight: "bold", children: n }),
2360
- O === "unavailable" ? /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Not yet available." }) : O === "loading" ? /* @__PURE__ */ y(D, { align: "center", gap: "2", children: [
2361
- /* @__PURE__ */ i(Ue, { size: "1" }),
2362
- /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "Computing…" })
2363
- ] }) : O === "error" ? /* @__PURE__ */ i(f, { size: "2", color: "red", children: M }) : /* @__PURE__ */ i(f, { size: "2", children: ot(d, { value: To(A, u) }) }),
2364
- l.description && /* @__PURE__ */ i(f, { size: "1", color: "gray", children: l.description })
2699
+ }, [T, c, o, w]), o === !1 ? null : /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ g($, { direction: "column", gap: "1", children: [
2700
+ /* @__PURE__ */ l(p, { as: "label", size: "2", weight: "bold", children: n }),
2701
+ L === "unavailable" ? /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "Not yet available." }) : L === "loading" ? /* @__PURE__ */ g($, { align: "center", gap: "2", children: [
2702
+ /* @__PURE__ */ l(Be, { size: "1" }),
2703
+ /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "Computing…" })
2704
+ ] }) : L === "error" ? /* @__PURE__ */ l(p, { size: "2", color: "red", children: R }) : /* @__PURE__ */ l(p, { size: "2", children: it(u, { value: ar(N, d) }) }),
2705
+ i.description && /* @__PURE__ */ l(p, { size: "1", color: "gray", children: i.description })
2365
2706
  ] }) });
2366
- }, Oo = ue(So), No = ee(
2707
+ }, pi = be(fi), hi = ie(
2367
2708
  5,
2368
- Ie((e) => {
2709
+ ze((e) => {
2369
2710
  const r = e["x-computed"];
2370
2711
  return e.type === "number" && typeof r == "object" && r !== null;
2371
2712
  })
2372
- ), Gt = "seq", At = 2, ko = (e) => e == null || e === "", qt = (e) => typeof e == "object" && e !== null && !Array.isArray(e) ? e : void 0, Io = (e) => {
2713
+ ), mr = "seq", $t = 2, mi = (e) => e == null || e === "", gr = (e) => typeof e == "object" && e !== null && !Array.isArray(e) ? e : void 0, gi = (e) => {
2373
2714
  const r = e == null ? void 0 : e["x-template"];
2374
2715
  if (typeof r != "object" || r === null) return;
2375
2716
  const { template: t, inputs: n } = r;
2376
2717
  if (!(typeof t != "string" || t === ""))
2377
2718
  return { template: t, inputs: n };
2378
- }, ct = (e) => typeof e == "object" && e.name === Gt && e.arg !== void 0, Do = (e) => e.every((r, t) => !ct(r) || typeof e[t - 1] != "object" && typeof e[t + 1] != "object"), Lo = (e) => {
2719
+ }, bt = (e) => typeof e == "object" && e.name === mr && e.arg !== void 0, yi = (e) => e.every((r, t) => !bt(r) || typeof e[t - 1] != "object" && typeof e[t + 1] != "object"), bi = (e) => {
2379
2720
  const r = /* @__PURE__ */ new Set();
2380
- for (const t of it(e))
2721
+ for (const t of ht(e))
2381
2722
  typeof t == "object" && t.arg === void 0 && r.add(t.name);
2382
2723
  return [...r];
2383
- }, Mo = (e) => {
2724
+ }, vi = (e) => {
2384
2725
  const r = [];
2385
2726
  for (const [t, n] of Object.entries((e == null ? void 0 : e.properties) ?? {})) {
2386
- const l = Io(n);
2387
- l && r.push([t, l]);
2727
+ const i = gi(n);
2728
+ i && r.push([t, i]);
2388
2729
  }
2389
2730
  return r;
2390
- }, zo = (e, r, t) => {
2391
- var l;
2731
+ }, wi = (e, r, t) => {
2732
+ var i;
2392
2733
  const n = {};
2393
- for (const o of Lo(t.template)) {
2394
- const s = Yt(e, r, ((l = t.inputs) == null ? void 0 : l[o]) ?? o);
2734
+ for (const o of bi(t.template)) {
2735
+ const s = cr(e, r, ((i = t.inputs) == null ? void 0 : i[o]) ?? o);
2395
2736
  n[o] = typeof s == "string" || typeof s == "number" || typeof s == "boolean" ? String(s) : "";
2396
2737
  }
2397
2738
  return n;
2398
- }, Fo = (e) => (r) => {
2399
- const t = r.trim() === "" ? At : Number(r);
2400
- return `${e}`.padStart(Number.isInteger(t) && t >= 0 ? t : At, "0");
2401
- }, Uo = (e) => {
2739
+ }, Ei = (e) => (r) => {
2740
+ const t = r.trim() === "" ? $t : Number(r);
2741
+ return `${e}`.padStart(Number.isInteger(t) && t >= 0 ? t : $t, "0");
2742
+ }, Ti = (e) => {
2402
2743
  const r = (n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2403
2744
  let t = "";
2404
- for (const n of it(e))
2405
- typeof n == "string" ? t += r(n) : t += ct(n) ? "(\\d+)" : ".*?";
2745
+ for (const n of ht(e))
2746
+ typeof n == "string" ? t += r(n) : t += bt(n) ? "(\\d+)" : ".*?";
2406
2747
  return new RegExp(`^${t}$`);
2407
- }, Po = (e, r, t) => {
2748
+ }, xi = (e, r, t) => {
2408
2749
  var o, s;
2409
- const n = Uo(t.template);
2410
- let l = 0;
2411
- for (const c of e) {
2412
- const a = (o = qt(c)) == null ? void 0 : o[r];
2413
- if (typeof a != "string") continue;
2414
- const d = Number((s = n.exec(a)) == null ? void 0 : s[1]);
2415
- Number.isFinite(d) && d > l && (l = d);
2750
+ const n = Ti(t.template);
2751
+ let i = 0;
2752
+ for (const a of e) {
2753
+ const c = (o = gr(a)) == null ? void 0 : o[r];
2754
+ if (typeof c != "string") continue;
2755
+ const u = Number((s = n.exec(c)) == null ? void 0 : s[1]);
2756
+ Number.isFinite(u) && u > i && (i = u);
2416
2757
  }
2417
- return l;
2418
- }, $o = (e, r, t, n, l, o) => {
2419
- const s = Mo(e);
2758
+ return i;
2759
+ }, Ai = (e, r, t, n, i, o) => {
2760
+ const s = vi(e);
2420
2761
  if (s.length === 0) return r;
2421
- const c = qt(r);
2422
- if (!c) return r;
2423
- const a = { ...c };
2424
- for (const [d, u] of s) {
2425
- if (!ko(a[d])) continue;
2426
- const h = it(u.template), p = {};
2427
- if (h.some(ct)) {
2428
- if (!Do(h)) {
2762
+ const a = gr(r);
2763
+ if (!a) return r;
2764
+ const c = { ...a };
2765
+ for (const [u, d] of s) {
2766
+ if (!mi(c[u])) continue;
2767
+ const y = ht(d.template), m = {};
2768
+ if (y.some(bt)) {
2769
+ if (!yi(y)) {
2429
2770
  console.warn(
2430
- `x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${u.template}"`
2771
+ `x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${d.template}"`
2431
2772
  );
2432
2773
  continue;
2433
2774
  }
2434
- const g = Math.max(o[d] ?? 0, Po(t, d, u)) + 1;
2435
- o[d] = g, p[Gt] = Fo(g);
2775
+ const f = Math.max(o[u] ?? 0, xi(t, u, d)) + 1;
2776
+ o[u] = f, m[mr] = Ei(f);
2436
2777
  }
2437
- a[d] = ot(u.template, zo(n, l, u), p);
2778
+ c[u] = it(d.template, wi(n, i, d), m);
2438
2779
  }
2439
- return a;
2440
- }, _o = ({ path: e, items: r, itemsSchema: t, rootSchema: n, addItem: l, sequences: o }) => {
2441
- const s = We();
2442
- return /* @__PURE__ */ i(S, { mt: "2", children: /* @__PURE__ */ y(De, { type: "button", variant: "surface", onClick: () => {
2443
- var d;
2444
- const a = $o(
2780
+ return c;
2781
+ }, Ri = ({ path: e, items: r, itemsSchema: t, rootSchema: n, addItem: i, sequences: o }) => {
2782
+ const s = $e();
2783
+ return /* @__PURE__ */ l(M, { mt: "2", children: /* @__PURE__ */ g(Ue, { type: "button", variant: "surface", onClick: () => {
2784
+ var u;
2785
+ const c = Ai(
2445
2786
  t,
2446
- ar(t, n),
2787
+ Nr(t, n),
2447
2788
  r,
2448
- (d = s.core) == null ? void 0 : d.data,
2789
+ (u = s.core) == null ? void 0 : u.data,
2449
2790
  // The object CONTAINING the array, not the row: a row being filled is
2450
2791
  // empty, so what a template reaches for sits alongside the array.
2451
2792
  e.split(".").slice(0, -1).join("."),
2452
2793
  o.current
2453
2794
  );
2454
- l && l(e, a)();
2795
+ i && i(e, c)();
2455
2796
  }, children: [
2456
- /* @__PURE__ */ i(yr, {}),
2797
+ /* @__PURE__ */ l($r, {}),
2457
2798
  "Add Item"
2458
2799
  ] }) });
2459
- }, Vo = ({
2800
+ }, Ci = ({
2460
2801
  data: e,
2461
2802
  path: r,
2462
2803
  schema: t,
2463
2804
  uischema: n,
2464
- enabled: l,
2805
+ enabled: i,
2465
2806
  visible: o,
2466
2807
  addItem: s,
2467
- removeItems: c,
2468
- rootSchema: a,
2469
- arraySchema: d
2808
+ removeItems: a,
2809
+ rootSchema: c,
2810
+ arraySchema: u,
2811
+ required: d = !1,
2812
+ errors: y = ""
2470
2813
  }) => {
2471
- const u = ae({}), h = d ? t : t.items, p = d || t;
2472
- if (o === !1 || !h || typeof h != "object" || Array.isArray(h))
2814
+ const m = ge({}), f = Ae(r, d, o), T = u ? t : t.items, w = u || t;
2815
+ if (o === !1 || !T || typeof T != "object" || Array.isArray(T))
2473
2816
  return null;
2474
- const g = h, b = Array.isArray(e) ? e : [], I = p.title || "Array Items", O = n.options ?? {}, T = l && O.addable !== !1, A = l && O.removable !== !1, k = O.itemLabel || "Item", M = (L) => {
2475
- if (c) {
2476
- const N = c(r, [L]);
2477
- N && N();
2817
+ const L = T, D = Array.isArray(e) ? e : [], N = w.title || "Array Items", A = n.options ?? {}, R = i && A.addable !== !1, v = i && A.removable !== !1, b = A.itemLabel || "Item", U = f || typeof w.minItems == "number" && w.minItems >= 1, P = !y, O = P ? "" : D.length === 0 && A.errorMessage || Re(y, N), j = (I) => {
2818
+ if (a) {
2819
+ const ne = a(r, [I]);
2820
+ ne && ne();
2478
2821
  }
2479
2822
  };
2480
- return /* @__PURE__ */ i(S, { mb: "6", children: /* @__PURE__ */ y(D, { direction: "column", gap: "4", children: [
2481
- /* @__PURE__ */ i(f, { as: "div", size: "4", weight: "bold", children: I }),
2482
- b.length === 0 && /* @__PURE__ */ i(S, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ i(f, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2483
- b.map((L, N) => {
2823
+ return /* @__PURE__ */ l(M, { mb: "6", children: /* @__PURE__ */ g($, { direction: "column", gap: "4", children: [
2824
+ /* @__PURE__ */ g(p, { as: "div", size: "4", weight: "bold", children: [
2825
+ N,
2826
+ " ",
2827
+ U && /* @__PURE__ */ l(p, { color: "red", children: "*" })
2828
+ ] }),
2829
+ D.length === 0 && /* @__PURE__ */ l(M, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ l(p, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2830
+ !P && /* @__PURE__ */ l(p, { color: "red", size: "1", children: O }),
2831
+ D.map((I, ne) => {
2484
2832
  var z;
2485
- const U = `${r}.${N}`;
2486
- return /* @__PURE__ */ i(Dt, { size: "3", variant: "surface", children: /* @__PURE__ */ y(D, { direction: "column", gap: "4", children: [
2487
- /* @__PURE__ */ y(D, { justify: "between", align: "center", children: [
2488
- /* @__PURE__ */ y(f, { size: "3", weight: "bold", children: [
2489
- k,
2833
+ const Y = `${r}.${ne}`;
2834
+ return /* @__PURE__ */ l(Xt, { size: "3", variant: "surface", children: /* @__PURE__ */ g($, { direction: "column", gap: "4", children: [
2835
+ /* @__PURE__ */ g($, { justify: "between", align: "center", children: [
2836
+ /* @__PURE__ */ g(p, { size: "3", weight: "bold", children: [
2837
+ b,
2490
2838
  " ",
2491
- N + 1
2839
+ ne + 1
2492
2840
  ] }),
2493
- A && /* @__PURE__ */ y(
2494
- De,
2841
+ v && /* @__PURE__ */ g(
2842
+ Ue,
2495
2843
  {
2496
2844
  type: "button",
2497
2845
  color: "red",
2498
2846
  variant: "soft",
2499
- onClick: () => M(N),
2847
+ onClick: () => j(ne),
2500
2848
  title: "Remove item",
2501
2849
  children: [
2502
- /* @__PURE__ */ i(gr, {}),
2850
+ /* @__PURE__ */ l(Fr, {}),
2503
2851
  "Remove"
2504
2852
  ]
2505
2853
  }
2506
2854
  )
2507
2855
  ] }),
2508
- /* @__PURE__ */ i(S, { children: /* @__PURE__ */ i(
2509
- Be,
2856
+ /* @__PURE__ */ l(M, { children: /* @__PURE__ */ l(
2857
+ Ge,
2510
2858
  {
2511
- schema: g,
2512
- uischema: ((z = n.options) == null ? void 0 : z.detail) || (g.type === "object" || g.properties ? {
2859
+ schema: L,
2860
+ uischema: ((z = n.options) == null ? void 0 : z.detail) || (L.type === "object" || L.properties ? {
2513
2861
  type: "VerticalLayout",
2514
- elements: Object.keys(g.properties || {}).map((v) => ({
2862
+ elements: Object.keys(L.properties || {}).map((_) => ({
2515
2863
  type: "Control",
2516
- scope: `#/properties/${v}`
2864
+ scope: `#/properties/${_}`
2517
2865
  }))
2518
2866
  } : {
2519
2867
  type: "Control",
2520
2868
  scope: "#"
2521
2869
  }),
2522
- path: U,
2523
- enabled: l,
2870
+ path: Y,
2871
+ enabled: i,
2524
2872
  renderers: void 0,
2525
2873
  cells: void 0
2526
2874
  }
2527
2875
  ) })
2528
- ] }) }, U);
2876
+ ] }) }, Y);
2529
2877
  }),
2530
- T && /* @__PURE__ */ i(
2531
- _o,
2878
+ R && /* @__PURE__ */ l(
2879
+ Ri,
2532
2880
  {
2533
2881
  path: r,
2534
- items: b,
2535
- itemsSchema: g,
2536
- rootSchema: a,
2882
+ items: D,
2883
+ itemsSchema: L,
2884
+ rootSchema: c,
2537
2885
  addItem: s,
2538
- sequences: u
2886
+ sequences: m
2539
2887
  }
2540
2888
  )
2541
2889
  ] }) });
2542
- }, xt = fr(Vo), jo = ee(3, ur), Ho = ({ uischema: e, visible: r }) => {
2890
+ }, Ut = kr(Ci), Si = ie(3, Dr), Oi = ({ uischema: e, visible: r }) => {
2543
2891
  const t = e;
2544
- return r === !1 ? null : /* @__PURE__ */ i(S, { mb: "4", children: /* @__PURE__ */ i(It, { size: "4", children: t.text }) });
2545
- }, Wo = ee(1, He("Label")), Bo = ee(3, dr), ri = [
2546
- { tester: Er, renderer: Tr },
2547
- { tester: xr, renderer: Rr },
2548
- { tester: Sr, renderer: Or },
2549
- { tester: kr, renderer: Ir },
2550
- { tester: Hr, renderer: jr },
2551
- { tester: Lr, renderer: Mr },
2892
+ return r === !1 ? null : /* @__PURE__ */ l(M, { mb: "4", children: /* @__PURE__ */ l(Bt, { size: "4", children: t.text }) });
2893
+ }, Ni = ie(1, Ye("Label")), Di = ie(3, Ir), ji = [
2552
2894
  { tester: Kr, renderer: Yr },
2553
- { tester: qr, renderer: Gr },
2554
- { tester: Zr, renderer: Jr },
2555
- { tester: en, renderer: Qr },
2556
- { tester: rn, renderer: tn },
2557
- { tester: ln, renderer: sn },
2558
- { tester: jn, renderer: Vn },
2559
- { tester: Gn, renderer: Yn },
2895
+ { tester: Zr, renderer: Qr },
2896
+ { tester: tn, renderer: rn },
2897
+ { tester: on, renderer: sn },
2898
+ { tester: bn, renderer: yn },
2899
+ { tester: cn, renderer: Tt },
2900
+ { tester: an, renderer: Tt },
2901
+ { tester: xn, renderer: An },
2902
+ // The layout renderers take their props from withJsonFormsLayoutProps, which
2903
+ // evaluates the layout's rule into `visible` and `enabled`, as
2904
+ // withJsonFormsControlProps does for the controls.
2905
+ { tester: Cn, renderer: Ze(Rn) },
2906
+ { tester: On, renderer: Ze(Sn) },
2907
+ { tester: Dn, renderer: Ze(Nn) },
2908
+ { tester: kn, renderer: Ze(In) },
2909
+ { tester: Hn, renderer: Wn },
2910
+ { tester: Co, renderer: Ro },
2911
+ { tester: Lo, renderer: ko },
2560
2912
  // After SpreadsheetControl on purpose: both testers rank 10, and a tie is
2561
2913
  // resolved by registration order (see XmlControlTester's comment).
2562
- { tester: uo, renderer: ao },
2914
+ { tester: Qo, renderer: Zo },
2563
2915
  // Also rank 10, but matches the distinct `x-xml-export` keyword rather
2564
2916
  // than `x-xml`, so it never ties with XmlControlTester on the same schema
2565
2917
  // node (see XmlExportControlTester's own comment).
2566
- { tester: vo, renderer: bo },
2567
- { tester: No, renderer: Oo },
2568
- { tester: jo, renderer: xt },
2569
- { tester: Bo, renderer: xt },
2570
- { tester: Wo, renderer: Ho }
2918
+ { tester: ci, renderer: li },
2919
+ { tester: hi, renderer: pi },
2920
+ { tester: Si, renderer: Ut },
2921
+ { tester: Di, renderer: Ut },
2922
+ { tester: Ni, renderer: Oi }
2571
2923
  ];
2572
2924
  export {
2573
- xt as ArrayControl,
2574
- jo as ArrayControlTester,
2575
- Cr as BooleanControl,
2576
- Sr as BooleanControlTester,
2577
- tn as CategorizationLayoutRenderer,
2578
- rn as CategorizationLayoutTester,
2579
- Oo as ComputedControl,
2580
- No as ComputedControlTester,
2581
- Xr as DateControl,
2582
- Kr as DateControlTester,
2583
- sn as FileControl,
2584
- ln as FileControlTester,
2585
- Qr as GroupLayoutRenderer,
2586
- en as GroupLayoutTester,
2587
- Jr as HorizontalLayoutRenderer,
2588
- Zr as HorizontalLayoutTester,
2589
- Ho as LabelRenderer,
2590
- Wo as LabelTester,
2591
- Ar as NumberControl,
2592
- xr as NumberControlTester,
2593
- Nr as RadioControl,
2594
- kr as RadioControlTester,
2595
- jr as SearchSelectControl,
2596
- Hr as SearchSelectControlTester,
2597
- ti as SearchServiceProvider,
2598
- Dr as SelectControl,
2599
- Lr as SelectControlTester,
2600
- Vn as SpreadsheetControl,
2601
- jn as SpreadsheetControlTester,
2602
- Yn as SpreadsheetExportControl,
2603
- Gn as SpreadsheetExportControlTester,
2604
- wr as TextControl,
2605
- Er as TextControlTester,
2606
- ei as UploadProvider,
2607
- Gr as VerticalLayoutRenderer,
2608
- qr as VerticalLayoutTester,
2609
- ao as XmlControl,
2610
- uo as XmlControlTester,
2611
- bo as XmlExportControl,
2612
- vo as XmlExportControlTester,
2613
- ri as radixRenderers,
2614
- vr as useSearchService,
2615
- br as useUpload
2925
+ Ut as ArrayControl,
2926
+ Si as ArrayControlTester,
2927
+ en as BooleanControl,
2928
+ tn as BooleanControlTester,
2929
+ In as CategorizationLayoutRenderer,
2930
+ kn as CategorizationLayoutTester,
2931
+ pi as ComputedControl,
2932
+ hi as ComputedControlTester,
2933
+ Tn as DateControl,
2934
+ xn as DateControlTester,
2935
+ Wn as FileControl,
2936
+ Hn as FileControlTester,
2937
+ Nn as GroupLayoutRenderer,
2938
+ Dn as GroupLayoutTester,
2939
+ Sn as HorizontalLayoutRenderer,
2940
+ On as HorizontalLayoutTester,
2941
+ Oi as LabelRenderer,
2942
+ Ni as LabelTester,
2943
+ Jr as NumberControl,
2944
+ Zr as NumberControlTester,
2945
+ nn as RadioControl,
2946
+ on as RadioControlTester,
2947
+ yn as SearchSelectControl,
2948
+ bn as SearchSelectControlTester,
2949
+ _i as SearchServiceProvider,
2950
+ ln as SelectControl,
2951
+ cn as SelectControlTester,
2952
+ an as SelectObjectControlTester,
2953
+ Ro as SpreadsheetControl,
2954
+ Co as SpreadsheetControlTester,
2955
+ ko as SpreadsheetExportControl,
2956
+ Lo as SpreadsheetExportControlTester,
2957
+ qr as TextControl,
2958
+ Kr as TextControlTester,
2959
+ Pi as UploadProvider,
2960
+ Rn as VerticalLayoutRenderer,
2961
+ Cn as VerticalLayoutTester,
2962
+ Zo as XmlControl,
2963
+ Qo as XmlControlTester,
2964
+ li as XmlExportControl,
2965
+ ci as XmlExportControlTester,
2966
+ ji as radixRenderers,
2967
+ Pr as useSearchService,
2968
+ Ur as useUpload
2616
2969
  };