@opennsw/jsonforms-renderers 0.9.0 → 0.10.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,45 +1,44 @@
1
- var Ar = Object.defineProperty;
2
- var Cr = (e, t, r) => t in e ? Ar(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Ze = (e, t, r) => Cr(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { jsx as n, jsxs as g, Fragment as he } from "react/jsx-runtime";
5
- import { useContext as cr, createContext as ar, useMemo as Be, useEffect as ge, useState as $, useRef as pe, useCallback as ke } from "react";
6
- import { rankWith as q, isStringControl as Sr, or as We, isNumberControl as Or, isIntegerControl as Nr, isBooleanControl as xr, isEnumControl as ur, isOneOfControl as dr, schemaMatches as ze, isDateControl as Ir, isDateTimeControl as kr, isTimeControl as Dr, uiTypeIs as Le, and as Mr, Resolve as je, update as zr, createDefaultValue as Lr, isObjectArrayControl as Fr, isPrimitiveArrayControl as Ur } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as me, JsonFormsDispatch as Fe, useJsonForms as fr, withJsonFormsArrayControlProps as Pr } from "@jsonforms/react";
8
- import { Box as x, Flex as S, Text as h, TextField as Se, Checkbox as $r, RadioGroup as Qe, Select as Pe, ScrollArea as _r, Spinner as xe, Button as De, Tabs as $e, Heading as hr, Card as pr, IconButton as Me, Table as Re, Tooltip as He } from "@radix-ui/themes";
9
- import { ChevronDownIcon as Vr, FileTextIcon as Hr, CheckCircledIcon as Wr, Cross2Icon as Ye, ExclamationTriangleIcon as Je, UploadIcon as Ne, TrashIcon as Xr, PlusIcon as Br } from "@radix-ui/react-icons";
10
- import jr from "dayjs";
11
- import { read as Kr, utils as Gr } from "@e965/xlsx";
12
- const mr = ar(null);
13
- function no({
1
+ var Dr = Object.defineProperty;
2
+ var Mr = (e, t, r) => t in e ? Dr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var tr = (e, t, r) => Mr(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as n, jsxs as m, Fragment as ae } from "react/jsx-runtime";
5
+ import { useContext as mr, createContext as gr, useMemo as Xe, useEffect as ue, useState as H, useRef as le, useCallback as Ne } from "react";
6
+ import { rankWith as te, isStringControl as zr, or as _e, isNumberControl as Lr, isIntegerControl as Fr, isBooleanControl as Ur, isEnumControl as yr, isOneOfControl as vr, schemaMatches as De, isDateControl as Pr, isDateTimeControl as $r, isTimeControl as _r, uiTypeIs as Me, and as Vr, Resolve as Ke, update as Hr, createDefaultValue as Wr, isObjectArrayControl as jr, isPrimitiveArrayControl as Br } from "@jsonforms/core";
7
+ import { withJsonFormsControlProps as fe, JsonFormsDispatch as ze, useJsonForms as br, withJsonFormsArrayControlProps as Xr } from "@jsonforms/react";
8
+ import { Box as I, Flex as k, Text as p, TextField as be, Checkbox as Kr, RadioGroup as nr, ScrollArea as wr, Select as Fe, Spinner as xe, Button as Ie, Tabs as Ue, Heading as Er, Card as Rr, IconButton as ke, Table as ve, Tooltip as $e } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as Ar, FileTextIcon as Gr, CheckCircledIcon as Yr, Cross2Icon as Je, ExclamationTriangleIcon as Ze, UploadIcon as Oe, TrashIcon as Jr, PlusIcon as Zr } from "@radix-ui/react-icons";
10
+ import qr from "dayjs";
11
+ const Cr = gr(null);
12
+ function io({
14
13
  children: e,
15
14
  onUpload: t,
16
15
  getDownloadUrl: r
17
16
  }) {
18
17
  const o = { onUpload: t, getDownloadUrl: r };
19
- return /* @__PURE__ */ n(mr.Provider, { value: o, children: e });
18
+ return /* @__PURE__ */ n(Cr.Provider, { value: o, children: e });
20
19
  }
21
- function Yr() {
22
- return cr(mr);
20
+ function Qr() {
21
+ return mr(Cr);
23
22
  }
24
- const gr = ar(null);
25
- function oo({
23
+ const Tr = gr(null);
24
+ function lo({
26
25
  children: e,
27
26
  services: t
28
27
  }) {
29
- const r = Be(() => t, [t]);
30
- return /* @__PURE__ */ n(gr.Provider, { value: r, children: e });
28
+ const r = Xe(() => t, [t]);
29
+ return /* @__PURE__ */ n(Tr.Provider, { value: r, children: e });
31
30
  }
32
- function Jr(e) {
33
- const t = cr(gr);
31
+ function et(e) {
32
+ const t = mr(Tr);
34
33
  return !t || !e ? null : t[e] ?? null;
35
34
  }
36
- const be = (e, t, r, o = void 0) => {
37
- ge(() => {
35
+ const ge = (e, t, r, o = void 0) => {
36
+ ue(() => {
38
37
  e === !1 && r(t, o);
39
38
  }, [e, t, r, o]);
40
- }, we = (e, t) => e ? e.split(`
39
+ }, de = (e, t) => e ? e.split(`
41
40
  `).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
42
- `) : "", qr = ({
41
+ `) : "", rt = ({
43
42
  data: e,
44
43
  handleChange: t,
45
44
  path: r,
@@ -47,35 +46,35 @@ const be = (e, t, r, o = void 0) => {
47
46
  required: u,
48
47
  errors: i,
49
48
  uischema: l,
50
- schema: a,
49
+ schema: c,
51
50
  enabled: s,
52
- visible: c = !0
51
+ visible: d = !0
53
52
  }) => {
54
- var y;
55
- if (be(c, r, t), c === !1)
53
+ var g;
54
+ if (ge(d, r, t), d === !1)
56
55
  return null;
57
- const d = i.length === 0;
58
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
59
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
56
+ const a = i.length === 0;
57
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
58
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
60
59
  o,
61
60
  " ",
62
- u && /* @__PURE__ */ n(h, { color: "red", children: "*" })
61
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
63
62
  ] }),
64
63
  /* @__PURE__ */ n(
65
- Se.Root,
64
+ be.Root,
66
65
  {
67
66
  value: e || "",
68
- onChange: (p) => t(r, p.target.value),
67
+ onChange: (f) => t(r, f.target.value),
69
68
  disabled: !s,
70
- placeholder: (y = l.options) == null ? void 0 : y.placeholder,
71
- color: d ? void 0 : "red",
69
+ placeholder: (g = l.options) == null ? void 0 : g.placeholder,
70
+ color: a ? void 0 : "red",
72
71
  id: r
73
72
  }
74
73
  ),
75
- !d && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(i, o) }),
76
- a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
74
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
75
+ c.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: c.description })
77
76
  ] }) });
78
- }, Zr = q(1, Sr), Qr = me(qr), et = ({
77
+ }, tt = te(1, zr), nt = fe(rt), ot = ({
79
78
  data: e,
80
79
  handleChange: t,
81
80
  path: r,
@@ -83,43 +82,43 @@ const be = (e, t, r, o = void 0) => {
83
82
  required: u,
84
83
  errors: i,
85
84
  uischema: l,
86
- schema: a,
85
+ schema: c,
87
86
  enabled: s,
88
- visible: c = !0
87
+ visible: d = !0
89
88
  }) => {
90
- var p;
91
- if (be(c, r, t), c === !1)
89
+ var f;
90
+ if (ge(d, r, t), d === !1)
92
91
  return null;
93
- const d = i.length === 0, y = (m) => {
94
- if (m === "") {
92
+ const a = i.length === 0, g = (y) => {
93
+ if (y === "") {
95
94
  t(r, void 0);
96
95
  return;
97
96
  }
98
- const v = Number(m);
99
- isNaN(v) || t(r, v);
97
+ const w = Number(y);
98
+ isNaN(w) || t(r, w);
100
99
  };
101
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
102
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
100
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
101
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
102
  o,
104
103
  " ",
105
- u && /* @__PURE__ */ n(h, { color: "red", children: "*" })
104
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
106
105
  ] }),
107
106
  /* @__PURE__ */ n(
108
- Se.Root,
107
+ be.Root,
109
108
  {
110
109
  type: "number",
111
110
  value: e ?? "",
112
- onChange: (m) => y(m.target.value),
111
+ onChange: (y) => g(y.target.value),
113
112
  disabled: !s,
114
- placeholder: (p = l.options) == null ? void 0 : p.placeholder,
115
- color: d ? void 0 : "red",
113
+ placeholder: (f = l.options) == null ? void 0 : f.placeholder,
114
+ color: a ? void 0 : "red",
116
115
  id: r
117
116
  }
118
117
  ),
119
- !d && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(i, o) }),
120
- a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
118
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
119
+ c.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: c.description })
121
120
  ] }) });
122
- }, rt = q(2, We(Or, Nr)), tt = me(et), nt = ({
121
+ }, it = te(2, _e(Lr, Fr)), lt = fe(ot), st = ({
123
122
  data: e,
124
123
  handleChange: t,
125
124
  path: r,
@@ -127,33 +126,33 @@ const be = (e, t, r, o = void 0) => {
127
126
  required: u,
128
127
  errors: i,
129
128
  schema: l,
130
- enabled: a,
129
+ enabled: c,
131
130
  visible: s = !0
132
131
  }) => {
133
- if (be(s, r, t), s === !1)
132
+ if (ge(s, r, t), s === !1)
134
133
  return null;
135
- const c = i.length === 0;
136
- return /* @__PURE__ */ g(x, { mb: "4", children: [
137
- /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
134
+ const d = i.length === 0;
135
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
136
+ /* @__PURE__ */ m(k, { gap: "2", align: "center", children: [
138
137
  /* @__PURE__ */ n(
139
- $r,
138
+ Kr,
140
139
  {
141
140
  checked: !!e,
142
- onCheckedChange: (d) => t(r, d === !0),
143
- disabled: !a,
141
+ onCheckedChange: (a) => t(r, a === !0),
142
+ disabled: !c,
144
143
  id: r
145
144
  }
146
145
  ),
147
- /* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
146
+ /* @__PURE__ */ m(p, { as: "label", size: "2", htmlFor: r, children: [
148
147
  o,
149
148
  " ",
150
149
  u && "*"
151
150
  ] })
152
151
  ] }),
153
- !c && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: we(i, o) }),
154
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: l.description })
152
+ !d && /* @__PURE__ */ n(p, { color: "red", size: "1", className: "block mt-1", children: de(i, o) }),
153
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", className: "block mt-1", children: l.description })
155
154
  ] });
156
- }, ot = q(2, xr), it = me(nt), lt = ({
155
+ }, ct = te(2, Ur), at = fe(st), ut = ({
157
156
  data: e,
158
157
  handleChange: t,
159
158
  path: r,
@@ -161,35 +160,35 @@ const be = (e, t, r, o = void 0) => {
161
160
  required: u,
162
161
  errors: i,
163
162
  schema: l,
164
- enabled: a,
163
+ enabled: c,
165
164
  visible: s = !0
166
165
  }) => {
167
- if (be(s, r, t), s === !1)
166
+ if (ge(s, r, t), s === !1)
168
167
  return null;
169
- const c = i.length === 0;
170
- let d = [];
171
- l.enum ? d = l.enum.map((p) => ({ value: p, label: String(p) })) : l.oneOf && (d = l.oneOf.map((p) => ({
172
- value: p.const,
173
- label: p.title || String(p.const)
168
+ const d = i.length === 0;
169
+ let a = [];
170
+ l.enum ? a = l.enum.map((f) => ({ value: f, label: String(f) })) : l.oneOf && (a = l.oneOf.map((f) => ({
171
+ value: f.const,
172
+ label: f.title || String(f.const)
174
173
  })));
175
- const y = e;
176
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
177
- /* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
174
+ const g = e;
175
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
176
+ /* @__PURE__ */ m(p, { as: "div", size: "2", weight: "bold", children: [
178
177
  o,
179
178
  " ",
180
- u && /* @__PURE__ */ n(h, { color: "red", children: "*" })
179
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
181
180
  ] }),
182
181
  /* @__PURE__ */ n(
183
- Qe.Root,
182
+ nr.Root,
184
183
  {
185
- value: y !== void 0 ? String(y) : "",
186
- onValueChange: (p) => {
187
- const m = d.find((v) => String(v.value) === p);
188
- m && t(r, m.value);
184
+ value: g !== void 0 ? String(g) : "",
185
+ onValueChange: (f) => {
186
+ const y = a.find((w) => String(w.value) === f);
187
+ y && t(r, y.value);
189
188
  },
190
- disabled: !a,
189
+ disabled: !c,
191
190
  children: /* @__PURE__ */ n(
192
- S,
191
+ k,
193
192
  {
194
193
  direction: "row",
195
194
  style: {
@@ -197,21 +196,21 @@ const be = (e, t, r, o = void 0) => {
197
196
  columnGap: "clamp(14px, 3vw, 36px)",
198
197
  rowGap: "clamp(8px, 1.6vw, 14px)"
199
198
  },
200
- children: d.map((p) => /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
- /* @__PURE__ */ n(Qe.Item, { value: String(p.value) }),
202
- /* @__PURE__ */ n(h, { size: "2", color: a ? void 0 : "gray", children: p.label })
203
- ] }, String(p.value)))
199
+ children: a.map((f) => /* @__PURE__ */ m(k, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
200
+ /* @__PURE__ */ n(nr.Item, { value: String(f.value) }),
201
+ /* @__PURE__ */ n(p, { size: "2", color: c ? void 0 : "gray", children: f.label })
202
+ ] }, String(f.value)))
204
203
  }
205
204
  )
206
205
  }
207
206
  ),
208
- !c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(i, o) }),
209
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
207
+ !d && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
208
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
210
209
  ] }) });
211
- }, st = (e, t, r) => {
210
+ }, dt = (e, t, r) => {
212
211
  var u;
213
- return We(ur, dr)(e, t, r) && ((u = e == null ? void 0 : e.options) == null ? void 0 : u.format) === "radio" ? 3 : -1;
214
- }, ct = me(lt), at = ({
212
+ return _e(yr, vr)(e, t, r) && ((u = e == null ? void 0 : e.options) == null ? void 0 : u.format) === "radio" ? 3 : -1;
213
+ }, ft = fe(ut), ht = ({
215
214
  data: e,
216
215
  handleChange: t,
217
216
  path: r,
@@ -219,45 +218,143 @@ const be = (e, t, r, o = void 0) => {
219
218
  required: u,
220
219
  errors: i,
221
220
  schema: l,
222
- uischema: a,
221
+ uischema: c,
223
222
  enabled: s,
224
- visible: c = !0
223
+ visible: d = !0
225
224
  }) => {
226
- var m;
227
- if (be(c, r, t), c === !1)
225
+ var $, W, z;
226
+ ge(d, r, t);
227
+ const a = (($ = c.options) == null ? void 0 : $.autocomplete) === !0, [g, f] = H(!1), [y, w] = H(""), [L, O] = H(0), R = le(null);
228
+ if (ue(() => {
229
+ if (!a || !g) return;
230
+ const E = (b) => {
231
+ R.current && !R.current.contains(b.target) && f(!1);
232
+ };
233
+ return document.addEventListener("mousedown", E), () => document.removeEventListener("mousedown", E);
234
+ }, [a, g]), d === !1)
228
235
  return null;
229
- const d = i.length === 0;
230
- let y = [];
231
- l.enum ? y = l.enum.map((v) => ({ value: String(v), label: String(v) })) : l.oneOf && (y = l.oneOf.map((v) => ({
232
- value: String(v.const),
233
- label: v.title || String(v.const)
236
+ const T = i.length === 0;
237
+ let S = [];
238
+ l.enum ? S = l.enum.map((E) => ({ value: String(E), label: String(E) })) : l.oneOf && (S = l.oneOf.map((E) => ({
239
+ value: String(E.const),
240
+ label: E.title || String(E.const)
234
241
  })));
235
- const p = e !== void 0 ? String(e) : "";
236
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
237
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
242
+ const N = e !== void 0 ? String(e) : "", D = ((W = c.options) == null ? void 0 : W.placeholder) || "Select an option";
243
+ if (a) {
244
+ const E = ((z = S.find((C) => C.value === N)) == null ? void 0 : z.label) ?? "", b = g ? S.filter((C) => C.label.toLowerCase().includes(y.toLowerCase())) : S, K = Math.min(L, b.length - 1), G = (C) => {
245
+ t(r, C.value), f(!1);
246
+ }, j = (C) => {
247
+ C.stopPropagation(), t(r, void 0), w("");
248
+ }, Y = (C) => {
249
+ (C.key === "Enter" || C.key === " ") && j(C);
250
+ };
251
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
252
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
253
+ o,
254
+ " ",
255
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
256
+ ] }),
257
+ /* @__PURE__ */ m("div", { ref: R, style: { position: "relative" }, children: [
258
+ /* @__PURE__ */ n(
259
+ be.Root,
260
+ {
261
+ id: r,
262
+ value: g ? y : E,
263
+ placeholder: D,
264
+ disabled: !s,
265
+ style: T ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
266
+ onChange: (C) => {
267
+ w(C.target.value), O(0), g || f(!0);
268
+ },
269
+ onFocus: () => {
270
+ s && !g && (w(""), O(0), f(!0));
271
+ },
272
+ onKeyDown: (C) => {
273
+ C.key === "Escape" ? f(!1) : C.key === "ArrowDown" ? (C.preventDefault(), g ? O((Z) => Math.min(Z + 1, b.length - 1)) : (w(""), f(!0))) : C.key === "ArrowUp" ? (C.preventDefault(), g && O((Z) => Math.max(Z - 1, 0))) : C.key === "Enter" && g && b[K] && (C.preventDefault(), G(b[K]));
274
+ },
275
+ children: /* @__PURE__ */ n(be.Slot, { side: "right", children: /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
276
+ N && s && /* @__PURE__ */ n(
277
+ "span",
278
+ {
279
+ role: "button",
280
+ tabIndex: 0,
281
+ onMouseDown: (C) => C.preventDefault(),
282
+ onClick: j,
283
+ onKeyDown: Y,
284
+ style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
285
+ "aria-label": "Clear selection",
286
+ children: "×"
287
+ }
288
+ ),
289
+ /* @__PURE__ */ n(
290
+ Ar,
291
+ {
292
+ style: { transform: g ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
293
+ }
294
+ )
295
+ ] }) })
296
+ }
297
+ ),
298
+ g && /* @__PURE__ */ n(
299
+ I,
300
+ {
301
+ style: {
302
+ position: "absolute",
303
+ top: "calc(100% + 4px)",
304
+ left: 0,
305
+ right: 0,
306
+ zIndex: 50,
307
+ background: "var(--color-panel-solid)",
308
+ borderRadius: "var(--radius-3)",
309
+ boxShadow: "var(--shadow-5)",
310
+ border: "1px solid var(--gray-a6)",
311
+ overflow: "hidden"
312
+ },
313
+ children: /* @__PURE__ */ n(wr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ m(I, { p: "1", children: [
314
+ b.length === 0 && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "No results found." }) }),
315
+ b.map((C, Z) => /* @__PURE__ */ n(
316
+ I,
317
+ {
318
+ px: "3",
319
+ py: "2",
320
+ onMouseDown: (J) => J.preventDefault(),
321
+ onClick: () => G(C),
322
+ onMouseEnter: () => O(Z),
323
+ style: {
324
+ cursor: "pointer",
325
+ borderRadius: "var(--radius-2)",
326
+ backgroundColor: Z === K ? "var(--accent-4)" : C.value === N ? "var(--accent-3)" : void 0
327
+ },
328
+ children: /* @__PURE__ */ n(p, { size: "2", children: C.label })
329
+ },
330
+ C.value
331
+ ))
332
+ ] }) })
333
+ }
334
+ )
335
+ ] }),
336
+ !T && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
337
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
338
+ ] }) });
339
+ }
340
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
341
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
238
342
  o,
239
343
  " ",
240
- u && /* @__PURE__ */ n(h, { color: "red", children: "*" })
344
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
241
345
  ] }),
242
- /* @__PURE__ */ g(Pe.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !s, children: [
243
- /* @__PURE__ */ n(
244
- Pe.Trigger,
245
- {
246
- placeholder: ((m = a.options) == null ? void 0 : m.placeholder) || "Select an option",
247
- color: d ? void 0 : "red",
248
- id: r
249
- }
250
- ),
251
- /* @__PURE__ */ n(Pe.Content, { children: y.map((v) => /* @__PURE__ */ n(Pe.Item, { value: v.value, children: v.label }, v.value)) })
346
+ /* @__PURE__ */ m(Fe.Root, { value: N, onValueChange: (E) => t(r, E), disabled: !s, children: [
347
+ /* @__PURE__ */ n(Fe.Trigger, { placeholder: D, color: T ? void 0 : "red", id: r }),
348
+ /* @__PURE__ */ n(Fe.Content, { children: S.map((E) => /* @__PURE__ */ n(Fe.Item, { value: E.value, children: E.label }, E.value)) })
252
349
  ] }),
253
- !d && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(i, o) }),
254
- l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
350
+ !T && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
351
+ l.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: l.description })
255
352
  ] }) });
256
- }, ut = q(2, We(ur, dr)), dt = me(at), ft = {
353
+ }, pt = te(2, _e(yr, vr)), mt = fe(ht), gt = {
257
354
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
258
355
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
259
356
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
260
- }, ht = ({
357
+ }, yt = ({
261
358
  data: e,
262
359
  handleChange: t,
263
360
  path: r,
@@ -265,142 +362,142 @@ const be = (e, t, r, o = void 0) => {
265
362
  required: u,
266
363
  errors: i,
267
364
  enabled: l,
268
- visible: a = !0,
365
+ visible: c = !0,
269
366
  schema: s,
270
- uischema: c
367
+ uischema: d
271
368
  }) => {
272
- var Ee;
273
- const d = (s == null ? void 0 : s["x-search"]) ?? { service: "" }, y = d.service ?? "", p = d.mode ?? "large-paginated-list", m = ft[p], v = (m == null ? void 0 : m.fetchOnOpen) ?? !1, I = d.params, A = Jr(y), b = s.type === "object", k = b ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, F = b ? k == null ? void 0 : k.value : e, z = k == null ? void 0 : k.label, w = y ? A ? m ? null : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", _ = l !== !1, V = !i || i.length === 0, [O, C] = $(!1), [H, B] = $(""), [W, j] = $([]), [ee, re] = $(!1), [le, oe] = $(!1), [se, de] = $(!1), [G, f] = $(null), [T, K] = $(void 0), N = pe(void 0), U = pe(null), Z = pe(null), ie = pe(null), J = pe(void 0);
274
- ge(() => {
275
- var ce, Q;
276
- if (!F) {
277
- K(void 0), J.current = void 0;
369
+ var A;
370
+ const a = (s == null ? void 0 : s["x-search"]) ?? { service: "" }, g = a.service ?? "", f = a.mode ?? "large-paginated-list", y = gt[f], w = (y == null ? void 0 : y.fetchOnOpen) ?? !1, L = a.params, O = et(g), R = s.type === "object", T = R ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, S = R ? T == null ? void 0 : T.value : e, N = T == null ? void 0 : T.label, D = g ? O ? y ? null : `Invalid x-search.mode "${f}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${g}" is not registered.` : "Search not configured.", $ = l !== !1, W = !i || i.length === 0, [z, E] = H(!1), [b, K] = H(""), [G, j] = H([]), [Y, C] = H(!1), [Z, J] = H(!1), [he, ie] = H(!1), [ye, h] = H(null), [x, B] = H(void 0), M = le(void 0), P = le(null), Q = le(null), ee = le(null), re = le(void 0);
371
+ ue(() => {
372
+ var X, F;
373
+ if (!S) {
374
+ B(void 0), re.current = void 0;
278
375
  return;
279
376
  }
280
- if (((ce = J.current) == null ? void 0 : ce.value) === F && ((Q = J.current) == null ? void 0 : Q.label) === z) return;
281
- if (J.current = { value: F, label: z }, b && z) {
282
- K({ id: F, name: z });
377
+ if (((X = re.current) == null ? void 0 : X.value) === S && ((F = re.current) == null ? void 0 : F.label) === N) return;
378
+ if (re.current = { value: S, label: N }, R && N) {
379
+ B({ id: S, name: N });
283
380
  return;
284
381
  }
285
- if (K({ id: F, name: z ?? F }), !(A != null && A.resolve)) return;
286
- let R = !1;
287
- return A.resolve(F, I).then((ae) => {
288
- !R && ae && K(ae);
382
+ if (B({ id: S, name: N ?? S }), !(O != null && O.resolve)) return;
383
+ let v = !1;
384
+ return O.resolve(S, L).then((U) => {
385
+ !v && U && B(U);
289
386
  }).catch(() => {
290
387
  }), () => {
291
- R = !0;
388
+ v = !0;
292
389
  };
293
- }, [F, z, b, A, I]);
294
- const D = ke(
295
- async (R, ce = !1) => {
296
- var ae;
297
- if (!A) {
298
- f("Search service not configured.");
390
+ }, [S, N, R, O, L]);
391
+ const _ = Ne(
392
+ async (v, X = !1) => {
393
+ var U;
394
+ if (!O) {
395
+ h("Search service not configured.");
299
396
  return;
300
397
  }
301
- (ae = Z.current) == null || ae.abort();
302
- const Q = new AbortController();
303
- Z.current = Q, ce ? de(!0) : (oe(!0), de(!1), f(null));
398
+ (U = Q.current) == null || U.abort();
399
+ const F = new AbortController();
400
+ Q.current = F, X ? ie(!0) : (J(!0), ie(!1), h(null));
304
401
  try {
305
- const Ae = await A.search({
306
- query: R,
307
- cursor: ce ? N.current : void 0,
308
- signal: Q.signal,
309
- params: I
310
- }), Ie = Ae.options ?? [];
311
- j(ce ? (Ue) => [...Ue, ...Ie] : Ie), N.current = Ae.nextCursor, re(((m == null ? void 0 : m.paginated) ?? !1) && Ae.nextCursor != null);
402
+ const se = await O.search({
403
+ query: v,
404
+ cursor: X ? M.current : void 0,
405
+ signal: F.signal,
406
+ params: L
407
+ }), Re = se.options ?? [];
408
+ j(X ? (je) => [...je, ...Re] : Re), M.current = se.nextCursor, C(((y == null ? void 0 : y.paginated) ?? !1) && se.nextCursor != null);
312
409
  } catch {
313
- if (Q.signal.aborted) return;
314
- f("Failed to load results. Please try again.");
410
+ if (F.signal.aborted) return;
411
+ h("Failed to load results. Please try again.");
315
412
  } finally {
316
- Q.signal.aborted || (ce ? de(!1) : oe(!1));
413
+ F.signal.aborted || (X ? ie(!1) : J(!1));
317
414
  }
318
415
  },
319
- [A, m == null ? void 0 : m.paginated, I]
416
+ [O, y == null ? void 0 : y.paginated, L]
320
417
  );
321
- if (ge(() => {
322
- if (!O) return;
323
- const R = (ce) => {
324
- ie.current && !ie.current.contains(ce.target) && C(!1);
418
+ if (ue(() => {
419
+ if (!z) return;
420
+ const v = (X) => {
421
+ ee.current && !ee.current.contains(X.target) && E(!1);
325
422
  };
326
- return document.addEventListener("mousedown", R), () => document.removeEventListener("mousedown", R);
327
- }, [O]), ge(() => {
328
- var R;
329
- O || ((R = Z.current) == null || R.abort(), B(""), j([]), re(!1), f(null), oe(!1), de(!1), N.current = void 0);
330
- }, [O]), ge(() => {
331
- if (!O) return;
332
- if (!H && !v) {
333
- j([]), re(!1), f(null), N.current = void 0;
423
+ return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
424
+ }, [z]), ue(() => {
425
+ var v;
426
+ z || ((v = Q.current) == null || v.abort(), K(""), j([]), C(!1), h(null), J(!1), ie(!1), M.current = void 0);
427
+ }, [z]), ue(() => {
428
+ if (!z) return;
429
+ if (!b && !w) {
430
+ j([]), C(!1), h(null), M.current = void 0;
334
431
  return;
335
432
  }
336
- U.current && clearTimeout(U.current);
337
- const R = H ? 300 : 0;
338
- return U.current = setTimeout(() => {
339
- j([]), re(!1), N.current = void 0, D(H);
340
- }, R), () => {
341
- U.current && clearTimeout(U.current);
433
+ P.current && clearTimeout(P.current);
434
+ const v = b ? 300 : 0;
435
+ return P.current = setTimeout(() => {
436
+ j([]), C(!1), M.current = void 0, _(b);
437
+ }, v), () => {
438
+ P.current && clearTimeout(P.current);
342
439
  };
343
- }, [H, O, v, D]), be(a, r, t, b ? void 0 : null), a === !1)
440
+ }, [b, z, w, _]), ge(c, r, t), c === !1)
344
441
  return null;
345
- const E = () => {
346
- B(""), j([]), re(!1), f(null), N.current = void 0, C(!0);
347
- }, L = (R) => {
348
- t(r, b ? { value: R.id, label: R.name } : R.id), K(R), J.current = { value: R.id, label: b ? R.name : void 0 }, C(!1);
349
- }, ue = (R) => {
350
- R.stopPropagation(), t(r, b ? void 0 : null), K(void 0);
351
- }, X = (R) => {
352
- (R.key === "Enter" || R.key === " ") && ue(R);
353
- }, P = ((Ee = c == null ? void 0 : c.options) == null ? void 0 : Ee.placeholder) ?? "Select an option";
354
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
355
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
442
+ const Se = () => {
443
+ K(""), j([]), C(!1), h(null), M.current = void 0, E(!0);
444
+ }, Ve = (v) => {
445
+ t(r, R ? { value: v.id, label: v.name } : v.id), B(v), re.current = { value: v.id, label: R ? v.name : void 0 }, E(!1);
446
+ }, Le = (v) => {
447
+ v.stopPropagation(), t(r, void 0), B(void 0);
448
+ }, He = (v) => {
449
+ (v.key === "Enter" || v.key === " ") && Le(v);
450
+ }, We = ((A = d == null ? void 0 : d.options) == null ? void 0 : A.placeholder) ?? "Select an option";
451
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
452
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
356
453
  o,
357
454
  " ",
358
- u && /* @__PURE__ */ n(h, { color: "red", children: "*" })
455
+ u && /* @__PURE__ */ n(p, { color: "red", children: "*" })
359
456
  ] }),
360
- /* @__PURE__ */ g("div", { ref: ie, style: { position: "relative" }, children: [
457
+ /* @__PURE__ */ m("div", { ref: ee, style: { position: "relative" }, children: [
361
458
  /* @__PURE__ */ n(
362
- Se.Root,
459
+ be.Root,
363
460
  {
364
461
  id: r,
365
- value: O ? H : (T == null ? void 0 : T.name) ?? "",
366
- placeholder: O && (m != null && m.searchable) ? "Search..." : P,
367
- disabled: !_,
368
- readOnly: O && !(m != null && m.searchable),
369
- style: V ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
370
- onChange: (R) => {
371
- m != null && m.searchable && (B(R.target.value), O || E());
462
+ value: z ? b : (x == null ? void 0 : x.name) ?? "",
463
+ placeholder: z && (y != null && y.searchable) ? "Search..." : We,
464
+ disabled: !$,
465
+ readOnly: z && !(y != null && y.searchable),
466
+ style: W ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
467
+ onChange: (v) => {
468
+ y != null && y.searchable && (K(v.target.value), z || Se());
372
469
  },
373
470
  onFocus: () => {
374
- _ && !O && E();
471
+ $ && !z && Se();
375
472
  },
376
- onKeyDown: (R) => {
377
- R.key === "Escape" && C(!1);
473
+ onKeyDown: (v) => {
474
+ v.key === "Escape" && E(!1);
378
475
  },
379
- children: /* @__PURE__ */ n(Se.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
380
- F && _ && /* @__PURE__ */ n(
476
+ children: /* @__PURE__ */ n(be.Slot, { side: "right", children: /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
477
+ S && $ && /* @__PURE__ */ n(
381
478
  "span",
382
479
  {
383
480
  role: "button",
384
481
  tabIndex: 0,
385
- onMouseDown: (R) => R.preventDefault(),
386
- onClick: ue,
387
- onKeyDown: X,
482
+ onMouseDown: (v) => v.preventDefault(),
483
+ onClick: Le,
484
+ onKeyDown: He,
388
485
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
389
486
  "aria-label": "Clear selection",
390
487
  children: "×"
391
488
  }
392
489
  ),
393
490
  /* @__PURE__ */ n(
394
- Vr,
491
+ Ar,
395
492
  {
396
- style: { transform: O ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
493
+ style: { transform: z ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
397
494
  }
398
495
  )
399
496
  ] }) })
400
497
  }
401
498
  ),
402
- O && /* @__PURE__ */ n(
403
- x,
499
+ z && /* @__PURE__ */ n(
500
+ I,
404
501
  {
405
502
  style: {
406
503
  position: "absolute",
@@ -414,65 +511,65 @@ const be = (e, t, r, o = void 0) => {
414
511
  border: "1px solid var(--gray-a6)",
415
512
  overflow: "hidden"
416
513
  },
417
- children: w ? /* @__PURE__ */ n(x, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: w }) }) : /* @__PURE__ */ n(_r, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(x, { p: "1", children: [
418
- le && /* @__PURE__ */ n(S, { justify: "center", p: "4", children: /* @__PURE__ */ n(xe, {}) }),
419
- !le && G && /* @__PURE__ */ n(x, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: G }) }),
420
- !le && !G && W.length === 0 && /* @__PURE__ */ n(x, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: H || v ? "No results found." : "Type to search…" }) }),
421
- W.map((R) => /* @__PURE__ */ n(
422
- x,
514
+ children: D ? /* @__PURE__ */ n(I, { p: "3", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: D }) }) : /* @__PURE__ */ n(wr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ m(I, { p: "1", children: [
515
+ Z && /* @__PURE__ */ n(k, { justify: "center", p: "4", children: /* @__PURE__ */ n(xe, {}) }),
516
+ !Z && ye && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "red", children: ye }) }),
517
+ !Z && !ye && G.length === 0 && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: b || w ? "No results found." : "Type to search…" }) }),
518
+ G.map((v) => /* @__PURE__ */ n(
519
+ I,
423
520
  {
424
521
  px: "3",
425
522
  py: "2",
426
- onMouseDown: (ce) => ce.preventDefault(),
427
- onClick: () => L(R),
523
+ onMouseDown: (X) => X.preventDefault(),
524
+ onClick: () => Ve(v),
428
525
  style: {
429
526
  cursor: "pointer",
430
527
  borderRadius: "var(--radius-2)",
431
- backgroundColor: R.id === F ? "var(--accent-3)" : void 0
528
+ backgroundColor: v.id === S ? "var(--accent-3)" : void 0
432
529
  },
433
530
  className: "hover:bg-(--gray-3)",
434
- children: /* @__PURE__ */ n(h, { size: "2", children: R.name })
531
+ children: /* @__PURE__ */ n(p, { size: "2", children: v.name })
435
532
  },
436
- R.id
533
+ v.id
437
534
  )),
438
- (m == null ? void 0 : m.paginated) && ee && !se && /* @__PURE__ */ n(x, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
- De,
535
+ (y == null ? void 0 : y.paginated) && Y && !he && /* @__PURE__ */ n(I, { px: "3", py: "2", children: /* @__PURE__ */ n(
536
+ Ie,
440
537
  {
441
538
  variant: "ghost",
442
539
  size: "1",
443
540
  style: { width: "100%" },
444
- onMouseDown: (R) => R.preventDefault(),
445
- onClick: () => void D(H, !0),
541
+ onMouseDown: (v) => v.preventDefault(),
542
+ onClick: () => void _(b, !0),
446
543
  children: "Load more"
447
544
  }
448
545
  ) }),
449
- se && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
546
+ he && /* @__PURE__ */ n(k, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
450
547
  ] }) })
451
548
  }
452
549
  )
453
550
  ] }),
454
- !V && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(i, o) }),
455
- s.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: s.description })
551
+ !W && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(i, o) }),
552
+ s.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: s.description })
456
553
  ] }) });
457
- }, pt = me(ht), mt = q(
554
+ }, vt = fe(yt), bt = te(
458
555
  3,
459
- ze((e) => {
556
+ De((e) => {
460
557
  const t = e["x-search"];
461
558
  return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
462
559
  })
463
- ), gt = (e, t) => jr(`${e}T${t}`).format(), yt = ({ path: e, label: t, required: r, errors: o, description: u, children: i }) => {
560
+ ), wt = (e, t) => qr(`${e}T${t}`).format(), Et = ({ path: e, label: t, required: r, errors: o, description: u, children: i }) => {
464
561
  const l = o.length === 0;
465
- return /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
466
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
562
+ return /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
563
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
467
564
  t,
468
565
  " ",
469
- r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
566
+ r && /* @__PURE__ */ n(p, { color: "red", children: "*" })
470
567
  ] }),
471
568
  i,
472
- !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: we(o, t) }),
473
- u && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: u })
569
+ !l && /* @__PURE__ */ n(p, { color: "red", size: "1", children: de(o, t) }),
570
+ u && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: u })
474
571
  ] }) });
475
- }, vt = ({
572
+ }, Rt = ({
476
573
  data: e,
477
574
  handleChange: t,
478
575
  path: r,
@@ -480,63 +577,63 @@ const be = (e, t, r, o = void 0) => {
480
577
  required: u,
481
578
  errors: i,
482
579
  schema: l,
483
- enabled: a,
580
+ enabled: c,
484
581
  visible: s = !0
485
582
  }) => {
486
- if (ge(() => {
583
+ if (ue(() => {
487
584
  s === !1 && t(r, void 0);
488
585
  }, [s, r, t]), s === !1)
489
586
  return null;
490
- const c = i.length === 0, d = typeof e == "string" ? e : "", y = (b) => /* @__PURE__ */ n(yt, { path: r, label: o, required: u, errors: i, description: l.description, children: b });
587
+ const d = i.length === 0, a = typeof e == "string" ? e : "", g = (R) => /* @__PURE__ */ n(Et, { path: r, label: o, required: u, errors: i, description: l.description, children: R });
491
588
  if (l.format === "time")
492
- return y(
589
+ return g(
493
590
  /* @__PURE__ */ n(
494
- Se.Root,
591
+ be.Root,
495
592
  {
496
593
  type: "time",
497
- value: d,
498
- onChange: (b) => t(r, b.target.value),
499
- disabled: !a,
500
- color: c ? void 0 : "red",
594
+ value: a,
595
+ onChange: (R) => t(r, R.target.value),
596
+ disabled: !c,
597
+ color: d ? void 0 : "red",
501
598
  id: r
502
599
  }
503
600
  )
504
601
  );
505
- const p = l.format === "date-time", [m = "", v = ""] = d.split("T"), I = v.slice(0, 5), A = (b, k) => {
506
- if (!b) {
602
+ const f = l.format === "date-time", [y = "", w = ""] = a.split("T"), L = w.slice(0, 5), O = (R, T) => {
603
+ if (!R) {
507
604
  t(r, void 0);
508
605
  return;
509
606
  }
510
- t(r, p ? gt(b, k || "00:00") : b);
607
+ t(r, f ? wt(R, T || "00:00") : R);
511
608
  };
512
- return y(
513
- /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
609
+ return g(
610
+ /* @__PURE__ */ m(k, { gap: "2", align: "center", children: [
514
611
  /* @__PURE__ */ n(
515
- Se.Root,
612
+ be.Root,
516
613
  {
517
614
  type: "date",
518
- value: m,
519
- disabled: !a,
520
- color: c ? void 0 : "red",
521
- onChange: (b) => A(b.target.value, I),
615
+ value: y,
616
+ disabled: !c,
617
+ color: d ? void 0 : "red",
618
+ onChange: (R) => O(R.target.value, L),
522
619
  id: r,
523
620
  style: { flex: 1 }
524
621
  }
525
622
  ),
526
- p && /* @__PURE__ */ n(
527
- Se.Root,
623
+ f && /* @__PURE__ */ n(
624
+ be.Root,
528
625
  {
529
626
  type: "time",
530
- value: I,
531
- disabled: !a || !m,
532
- color: c ? void 0 : "red",
533
- onChange: (b) => A(m, b.target.value),
627
+ value: L,
628
+ disabled: !c || !y,
629
+ color: d ? void 0 : "red",
630
+ onChange: (R) => O(y, R.target.value),
534
631
  style: { flex: 1 }
535
632
  }
536
633
  )
537
634
  ] })
538
635
  );
539
- }, bt = q(2, We(Ir, kr, Dr)), wt = me(vt), Et = ({
636
+ }, At = te(2, _e(Pr, $r, _r)), Ct = fe(Rt), Tt = ({
540
637
  uischema: e,
541
638
  schema: t,
542
639
  path: r,
@@ -546,19 +643,19 @@ const be = (e, t, r, o = void 0) => {
546
643
  visible: l = !0
547
644
  }) => {
548
645
  const s = e.elements;
549
- return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: s.map((c, d) => /* @__PURE__ */ n(
550
- Fe,
646
+ return l === !1 ? null : /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(
647
+ ze,
551
648
  {
552
- uischema: c,
649
+ uischema: d,
553
650
  schema: t,
554
651
  path: r,
555
652
  renderers: o,
556
653
  cells: u,
557
654
  enabled: i
558
655
  },
559
- `${r}-${d}`
656
+ `${r}-${a}`
560
657
  )) });
561
- }, Rt = q(1, Le("VerticalLayout")), Tt = ({
658
+ }, St = te(1, Me("VerticalLayout")), Ot = ({
562
659
  uischema: e,
563
660
  schema: t,
564
661
  path: r,
@@ -568,18 +665,18 @@ const be = (e, t, r, o = void 0) => {
568
665
  visible: l = !0
569
666
  }) => {
570
667
  const s = e.elements;
571
- return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "row", gap: "4", children: s.map((c, d) => /* @__PURE__ */ n(x, { style: { flex: 1 }, children: /* @__PURE__ */ n(
572
- Fe,
668
+ return l === !1 ? null : /* @__PURE__ */ n(k, { direction: "row", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(I, { style: { flex: 1 }, children: /* @__PURE__ */ n(
669
+ ze,
573
670
  {
574
- uischema: c,
671
+ uischema: d,
575
672
  schema: t,
576
673
  path: r,
577
674
  renderers: o,
578
675
  cells: u,
579
676
  enabled: i
580
677
  }
581
- ) }, `${r}-${d}`)) });
582
- }, At = q(1, Le("HorizontalLayout")), Ct = ({
678
+ ) }, `${r}-${a}`)) });
679
+ }, xt = te(1, Me("HorizontalLayout")), Nt = ({
583
680
  uischema: e,
584
681
  schema: t,
585
682
  path: r,
@@ -588,23 +685,23 @@ const be = (e, t, r, o = void 0) => {
588
685
  enabled: i,
589
686
  visible: l = !0
590
687
  }) => {
591
- const a = e, s = a.elements;
592
- return l === !1 ? null : /* @__PURE__ */ g(x, { mb: "6", children: [
593
- a.label && /* @__PURE__ */ n(hr, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: a.label }),
594
- /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: s.map((c, d) => /* @__PURE__ */ n(
595
- Fe,
688
+ const c = e, s = c.elements;
689
+ return l === !1 ? null : /* @__PURE__ */ m(I, { mb: "6", children: [
690
+ c.label && /* @__PURE__ */ n(Er, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: c.label }),
691
+ /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: s.map((d, a) => /* @__PURE__ */ n(
692
+ ze,
596
693
  {
597
- uischema: c,
694
+ uischema: d,
598
695
  schema: t,
599
696
  path: r,
600
697
  renderers: o,
601
698
  cells: u,
602
699
  enabled: i
603
700
  },
604
- `${r}-${d}`
701
+ `${r}-${a}`
605
702
  )) })
606
703
  ] });
607
- }, St = q(1, Le("Group")), Ot = ({
704
+ }, It = te(1, Me("Group")), kt = ({
608
705
  uischema: e,
609
706
  schema: t,
610
707
  path: r,
@@ -613,43 +710,42 @@ const be = (e, t, r, o = void 0) => {
613
710
  enabled: i,
614
711
  visible: l = !0
615
712
  }) => {
616
- var p;
617
- const s = e.elements.filter((m) => m.type === "Category"), [c, d] = $(((p = s[0]) == null ? void 0 : p.label) || "");
713
+ var f;
714
+ const s = e.elements.filter((y) => y.type === "Category"), [d, a] = H(((f = s[0]) == null ? void 0 : f.label) || "");
618
715
  if (l === !1 || !s.length) return null;
619
- const y = s.find((m) => m.label === c) ? c : s[0].label;
620
- return /* @__PURE__ */ g($e.Root, { value: y, onValueChange: d, children: [
621
- /* @__PURE__ */ n($e.List, { children: s.map((m, v) => /* @__PURE__ */ n($e.Trigger, { value: m.label, children: m.label }, `${r}-${v}`)) }),
622
- /* @__PURE__ */ n(x, { pt: "3", children: s.map((m, v) => /* @__PURE__ */ n($e.Content, { value: m.label, children: /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: m.elements.map((I, A) => /* @__PURE__ */ n(
623
- Fe,
716
+ const g = s.find((y) => y.label === d) ? d : s[0].label;
717
+ return /* @__PURE__ */ m(Ue.Root, { value: g, onValueChange: a, children: [
718
+ /* @__PURE__ */ n(Ue.List, { children: s.map((y, w) => /* @__PURE__ */ n(Ue.Trigger, { value: y.label, children: y.label }, `${r}-${w}`)) }),
719
+ /* @__PURE__ */ n(I, { pt: "3", children: s.map((y, w) => /* @__PURE__ */ n(Ue.Content, { value: y.label, children: /* @__PURE__ */ n(k, { direction: "column", gap: "4", children: y.elements.map((L, O) => /* @__PURE__ */ n(
720
+ ze,
624
721
  {
625
- uischema: I,
722
+ uischema: L,
626
723
  schema: t,
627
724
  path: r,
628
725
  renderers: o,
629
726
  cells: u,
630
727
  enabled: i
631
728
  },
632
- `${r}-${v}-${A}`
633
- )) }) }, `${r}-${v}`)) })
729
+ `${r}-${w}-${O}`
730
+ )) }) }, `${r}-${w}`)) })
634
731
  ] });
635
- }, Nt = q(1, Le("Categorization"));
636
- function ye(e) {
732
+ }, Dt = te(1, Me("Categorization"));
733
+ function pe(e) {
637
734
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
638
735
  }
639
- function ve(e) {
640
- return e.split(",").map((t) => {
641
- if (t = t.trim(), t.endsWith("/*"))
642
- return t.split("/")[0].toUpperCase() + "S";
643
- if (t.startsWith("."))
644
- return t.slice(1).toUpperCase();
645
- const r = t.split("/")[1];
646
- return r ? r.toUpperCase() : t;
647
- }).join(", ");
736
+ function me(e) {
737
+ const t = e.split(",").map((i) => i.trim()).filter(Boolean), r = t.filter((i) => i.startsWith(".")), u = (r.length > 0 ? r : t).map((i) => {
738
+ if (i.endsWith("/*")) return i.split("/")[0].toUpperCase() + "S";
739
+ if (i.startsWith(".")) return i.slice(1).toUpperCase();
740
+ const l = i.split("/")[1];
741
+ return l ? l.toUpperCase() : i;
742
+ });
743
+ return [...new Set(u)].join(", ");
648
744
  }
649
- function xt(e) {
745
+ function Mt(e) {
650
746
  return e ? Array.isArray(e) ? e : [e] : [];
651
747
  }
652
- const It = ({
748
+ const zt = ({
653
749
  data: e,
654
750
  handleChange: t,
655
751
  path: r,
@@ -657,98 +753,98 @@ const It = ({
657
753
  required: u,
658
754
  uischema: i,
659
755
  schema: l,
660
- enabled: a,
756
+ enabled: c,
661
757
  errors: s,
662
- visible: c = !0
758
+ visible: d = !0
663
759
  }) => {
664
- const d = Yr();
665
- be(c, r, t, null);
666
- const y = !s || s.length === 0, p = (l == null ? void 0 : l["x-file"]) ?? {}, m = (i == null ? void 0 : i.options) ?? {}, v = p.maxFiles ?? m.maxFiles ?? 1, I = p.maxSize ?? m.maxSize ?? 5 * 1024 * 1024, A = p.accept ?? m.accept ?? "image/*,application/pdf", b = v > 1, k = a !== !1, [F, z] = $(!1), [w, _] = $(null), [V, O] = $({}), C = pe(/* @__PURE__ */ new Set()), H = pe(null), B = xt(e), W = B.length >= v;
667
- ge(() => () => {
668
- C.current.forEach((f) => URL.revokeObjectURL(f)), C.current.clear();
760
+ const a = Qr();
761
+ ge(d, r, t);
762
+ const g = !s || s.length === 0, f = (l == null ? void 0 : l["x-file"]) ?? {}, y = (i == null ? void 0 : i.options) ?? {}, w = f.maxFiles ?? y.maxFiles ?? 1, L = f.maxSize ?? y.maxSize ?? 5 * 1024 * 1024, O = f.accept ?? y.accept ?? "image/*,application/pdf", R = w > 1, T = c !== !1, [S, N] = H(!1), [D, $] = H(null), [W, z] = H({}), E = le(/* @__PURE__ */ new Set()), b = le(null), K = Mt(e), G = K.length >= w;
763
+ ue(() => () => {
764
+ E.current.forEach((h) => URL.revokeObjectURL(h)), E.current.clear();
669
765
  }, []);
670
- const j = ke(
671
- async (f) => {
672
- if (_(null), B.length >= v) {
673
- _(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
766
+ const j = Ne(
767
+ async (h) => {
768
+ if ($(null), K.length >= w) {
769
+ $(`Maximum ${w} file${w > 1 ? "s" : ""} allowed.`);
674
770
  return;
675
771
  }
676
- if (f.size > I) {
677
- _(`File exceeds the ${ye(I)} limit.`);
772
+ if (h.size > L) {
773
+ $(`File exceeds the ${pe(L)} limit.`);
678
774
  return;
679
775
  }
680
- if (!A.split(",").map((N) => N.trim()).some((N) => N === "*" || N === "*/*" ? !0 : N.endsWith("/*") ? f.type.startsWith(N.slice(0, -1)) : N.startsWith(".") ? f.name.toLowerCase().endsWith(N.toLowerCase()) : f.type === N)) {
681
- _(`Invalid type. Accepted: ${ve(A)}`);
776
+ if (!O.split(",").map((M) => M.trim()).some((M) => M === "*" || M === "*/*" ? !0 : M.endsWith("/*") ? h.type.startsWith(M.slice(0, -1)) : M.startsWith(".") ? h.name.toLowerCase().endsWith(M.toLowerCase()) : h.type === M)) {
777
+ $(`Invalid type. Accepted: ${me(O)}`);
682
778
  return;
683
779
  }
684
- if (!(d != null && d.onUpload)) {
685
- _("Upload service not configured.");
780
+ if (!(a != null && a.onUpload)) {
781
+ $("Upload service not configured.");
686
782
  return;
687
783
  }
688
784
  try {
689
- const N = await d.onUpload(f), U = URL.createObjectURL(f);
690
- C.current.add(U);
691
- const Z = { key: N.key, name: N.name ?? f.name, blobUrl: U };
692
- O((J) => ({ ...J, [N.key]: Z }));
693
- const ie = [...B, N.key];
694
- t(r, b ? ie : ie[0]);
785
+ const M = await a.onUpload(h), P = URL.createObjectURL(h);
786
+ E.current.add(P);
787
+ const Q = { key: M.key, name: M.name ?? h.name, blobUrl: P };
788
+ z((re) => ({ ...re, [M.key]: Q }));
789
+ const ee = [...K, M.key];
790
+ t(r, R ? ee : ee[0]);
695
791
  } catch {
696
- _("Upload failed. Please try again."), H.current && (H.current.value = "");
792
+ $("Upload failed. Please try again."), b.current && (b.current.value = "");
697
793
  }
698
794
  },
699
- [B, v, I, A, d, r, t, b]
795
+ [K, w, L, O, a, r, t, R]
700
796
  );
701
- if (c === !1)
797
+ if (d === !1)
702
798
  return null;
703
- const ee = (f) => {
704
- f.preventDefault(), f.stopPropagation(), !(!k || W) && z(f.type === "dragenter" || f.type === "dragover");
705
- }, re = (f) => {
706
- var T;
707
- f.preventDefault(), f.stopPropagation(), z(!1), !(!k || W) && (T = f.dataTransfer.files) != null && T[0] && j(f.dataTransfer.files[0]);
708
- }, le = (f) => {
709
- var T;
710
- (T = f.target.files) != null && T[0] && (j(f.target.files[0]), f.target.value = "");
711
- }, oe = (f) => {
712
- if (!k) return;
713
- O((K) => {
714
- var Z;
715
- const N = { ...K }, U = (Z = N[f]) == null ? void 0 : Z.blobUrl;
716
- return U && (URL.revokeObjectURL(U), C.current.delete(U)), delete N[f], N;
799
+ const Y = (h) => {
800
+ h.preventDefault(), h.stopPropagation(), !(!T || G) && N(h.type === "dragenter" || h.type === "dragover");
801
+ }, C = (h) => {
802
+ var x;
803
+ h.preventDefault(), h.stopPropagation(), N(!1), !(!T || G) && (x = h.dataTransfer.files) != null && x[0] && j(h.dataTransfer.files[0]);
804
+ }, Z = (h) => {
805
+ var x;
806
+ (x = h.target.files) != null && x[0] && (j(h.target.files[0]), h.target.value = "");
807
+ }, J = (h) => {
808
+ if (!T) return;
809
+ z((B) => {
810
+ var Q;
811
+ const M = { ...B }, P = (Q = M[h]) == null ? void 0 : Q.blobUrl;
812
+ return P && (URL.revokeObjectURL(P), E.current.delete(P)), delete M[h], M;
717
813
  });
718
- const T = B.filter((K) => K !== f);
719
- t(r, b ? T.length > 0 ? T : null : T[0] ?? null);
720
- }, se = async (f, T) => {
721
- var U, Z, ie;
722
- f.preventDefault();
723
- const K = (U = V[T]) == null ? void 0 : U.blobUrl;
724
- if (K) {
725
- (Z = window.open(K, "_blank", "noopener,noreferrer")) == null || Z.focus();
814
+ const x = K.filter((B) => B !== h);
815
+ t(r, R ? x.length > 0 ? x : void 0 : x[0]);
816
+ }, he = async (h, x) => {
817
+ var P, Q, ee;
818
+ h.preventDefault();
819
+ const B = (P = W[x]) == null ? void 0 : P.blobUrl;
820
+ if (B) {
821
+ (Q = window.open(B, "_blank", "noopener,noreferrer")) == null || Q.focus();
726
822
  return;
727
823
  }
728
- const N = window.open("", "_blank");
729
- if (N)
824
+ const M = window.open("", "_blank");
825
+ if (M)
730
826
  try {
731
- const J = await ((ie = d == null ? void 0 : d.getDownloadUrl) == null ? void 0 : ie.call(d, T));
732
- J != null && J.url ? N.location.href = J.url : N.close();
827
+ const re = await ((ee = a == null ? void 0 : a.getDownloadUrl) == null ? void 0 : ee.call(a, x));
828
+ re != null && re.url ? M.location.href = re.url : M.close();
733
829
  } catch {
734
- N.close();
830
+ M.close();
735
831
  }
736
832
  };
737
- if (!k && B.length === 0) return null;
738
- const de = v - B.length, G = k && !W;
739
- return /* @__PURE__ */ g(x, { mb: "4", children: [
740
- /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
741
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
833
+ if (!T && K.length === 0) return null;
834
+ const ie = w - K.length, ye = T && !G;
835
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
836
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
837
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
742
838
  o,
743
- u && /* @__PURE__ */ n(h, { color: "red", children: " *" })
839
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
744
840
  ] }),
745
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: b ? `Up to ${v} files · ${ye(I)} each · ${ve(A)}` : `${ye(I)} · ${ve(A)}` })
841
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: R ? `Up to ${w} files · ${pe(L)} each · ${me(O)}` : `${pe(L)} · ${me(O)}` })
746
842
  ] }),
747
- B.map((f) => {
748
- var T;
749
- return /* @__PURE__ */ n(pr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
843
+ K.map((h) => {
844
+ var x;
845
+ return /* @__PURE__ */ n(Rr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ m(k, { align: "center", gap: "3", children: [
750
846
  /* @__PURE__ */ n(
751
- x,
847
+ I,
752
848
  {
753
849
  style: {
754
850
  background: "var(--blue-3)",
@@ -757,11 +853,11 @@ const It = ({
757
853
  color: "var(--blue-9)",
758
854
  flexShrink: 0
759
855
  },
760
- children: /* @__PURE__ */ n(Hr, { width: "20", height: "20" })
856
+ children: /* @__PURE__ */ n(Gr, { width: "20", height: "20" })
761
857
  }
762
858
  ),
763
- /* @__PURE__ */ n(x, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
764
- h,
859
+ /* @__PURE__ */ n(I, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
860
+ p,
765
861
  {
766
862
  size: "2",
767
863
  weight: "bold",
@@ -771,70 +867,70 @@ const It = ({
771
867
  textOverflow: "ellipsis",
772
868
  whiteSpace: "nowrap"
773
869
  },
774
- children: ((T = V[f]) == null ? void 0 : T.name) ?? "Uploaded File"
870
+ children: ((x = W[h]) == null ? void 0 : x.name) ?? "Uploaded File"
775
871
  }
776
872
  ) }),
777
- /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
778
- /* @__PURE__ */ n(De, { variant: "soft", color: "blue", size: "1", onClick: (K) => se(K, f), children: "View" }),
779
- /* @__PURE__ */ n(Wr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
780
- k && /* @__PURE__ */ n(Me, { variant: "ghost", color: "gray", onClick: () => oe(f), children: /* @__PURE__ */ n(Ye, {}) })
873
+ /* @__PURE__ */ m(k, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
874
+ /* @__PURE__ */ n(Ie, { variant: "soft", color: "blue", size: "1", onClick: (B) => he(B, h), children: "View" }),
875
+ /* @__PURE__ */ n(Yr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
876
+ T && /* @__PURE__ */ n(ke, { variant: "ghost", color: "gray", onClick: () => J(h), children: /* @__PURE__ */ n(Je, {}) })
781
877
  ] })
782
- ] }) }, f);
878
+ ] }) }, h);
783
879
  }),
784
- G && /* @__PURE__ */ g(
880
+ ye && /* @__PURE__ */ m(
785
881
  "div",
786
882
  {
787
883
  role: "button",
788
884
  tabIndex: 0,
789
885
  onClick: () => {
790
- var f;
791
- return (f = H.current) == null ? void 0 : f.click();
886
+ var h;
887
+ return (h = b.current) == null ? void 0 : h.click();
792
888
  },
793
- onKeyDown: (f) => {
794
- var T;
795
- (f.key === "Enter" || f.key === " ") && (f.preventDefault(), (T = H.current) == null || T.click());
889
+ onKeyDown: (h) => {
890
+ var x;
891
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = b.current) == null || x.click());
796
892
  },
797
- onDragEnter: ee,
798
- onDragLeave: ee,
799
- onDragOver: ee,
800
- onDrop: re,
893
+ onDragEnter: Y,
894
+ onDragLeave: Y,
895
+ onDragOver: Y,
896
+ onDrop: C,
801
897
  style: { cursor: "pointer" },
802
898
  className: [
803
899
  "border-2 border-dashed rounded-lg p-6 text-center",
804
900
  "transition-all duration-200 ease-in-out",
805
- F ? "border-blue-500 bg-blue-50" : w ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
901
+ S ? "border-blue-500 bg-blue-50" : D ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
806
902
  ].join(" "),
807
903
  children: [
808
- /* @__PURE__ */ n("input", { ref: H, type: "file", style: { display: "none" }, accept: A, onChange: le }),
809
- /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: w ? /* @__PURE__ */ g(he, { children: [
810
- /* @__PURE__ */ n(Je, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
811
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: w }),
812
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
813
- ] }) : /* @__PURE__ */ g(he, { children: [
814
- /* @__PURE__ */ n(Ne, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
815
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: B.length > 0 ? `Add another file (${de} remaining)` : "Click to upload or drag and drop" }),
816
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
817
- ye(I),
904
+ /* @__PURE__ */ n("input", { ref: b, type: "file", style: { display: "none" }, accept: O, onChange: Z }),
905
+ /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: D ? /* @__PURE__ */ m(ae, { children: [
906
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
907
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: D }),
908
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
909
+ ] }) : /* @__PURE__ */ m(ae, { children: [
910
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
911
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: K.length > 0 ? `Add another file (${ie} remaining)` : "Click to upload or drag and drop" }),
912
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
913
+ pe(L),
818
914
  " max · ",
819
- ve(A)
915
+ me(O)
820
916
  ] })
821
917
  ] }) })
822
918
  ]
823
919
  }
824
920
  ),
825
- k && W && b && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
921
+ T && G && R && /* @__PURE__ */ m(p, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
826
922
  "Maximum ",
827
- v,
923
+ w,
828
924
  " files uploaded. Remove one to replace it."
829
925
  ] }),
830
- !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(s, o) })
926
+ !g && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
831
927
  ] });
832
- }, kt = me(It), Dt = q(
928
+ }, Lt = fe(zt), Ft = te(
833
929
  10,
834
930
  // high rank to beat default array renderer
835
- Mr(
931
+ Vr(
836
932
  // Match both single-file (type: string) and multi-file (type: array)
837
- ze((e) => {
933
+ De((e) => {
838
934
  if (e.type === "string" && e.format === "file") return !0;
839
935
  if (e.type === "array") {
840
936
  const t = e.items;
@@ -844,27 +940,27 @@ const It = ({
844
940
  })
845
941
  )
846
942
  );
847
- function yr(e, t) {
943
+ function Sr(e, t) {
848
944
  return e !== !1 && t !== !0;
849
945
  }
850
- class Ke extends Error {
946
+ class Ge extends Error {
851
947
  }
852
- function Mt(e, t) {
853
- const r = Kr(e, { type: "array", cellDates: !0 });
854
- if (r.SheetNames.length === 0)
855
- throw new Ke("This file has no sheets.");
856
- const o = t ?? r.SheetNames[0], u = r.Sheets[o];
857
- if (!u)
858
- throw new Ke(`This file doesn't have a sheet named "${o}".`);
859
- const i = Gr.sheet_to_json(u, { header: 1, raw: !0, defval: null });
948
+ async function Ut(e, t) {
949
+ const { read: r, utils: o } = await import("@e965/xlsx"), u = r(e, { type: "array", cellDates: !0 });
950
+ if (u.SheetNames.length === 0)
951
+ throw new Ge("This file has no sheets.");
952
+ const i = t ?? u.SheetNames[0], l = u.Sheets[i];
953
+ if (!l)
954
+ throw new Ge(`This file doesn't have a sheet named "${i}".`);
955
+ const c = o.sheet_to_json(l, { header: 1, raw: !0, defval: null });
860
956
  return {
861
- sheetName: o,
862
- matrix: i,
863
- rowCount: i.length,
864
- colCount: Math.max(0, ...i.map((l) => l.length))
957
+ sheetName: i,
958
+ matrix: c,
959
+ rowCount: c.length,
960
+ colCount: Math.max(0, ...c.map((s) => s.length))
865
961
  };
866
962
  }
867
- function zt(e) {
963
+ function Pt(e) {
868
964
  let t = e + 1, r = "";
869
965
  for (; t > 0; ) {
870
966
  const o = (t - 1) % 26;
@@ -872,14 +968,14 @@ function zt(e) {
872
968
  }
873
969
  return r;
874
970
  }
875
- class ne extends Error {
971
+ class oe extends Error {
876
972
  constructor(r, o) {
877
973
  super(o ?? r);
878
- Ze(this, "code");
974
+ tr(this, "code");
879
975
  this.code = r, this.name = "FormulaError";
880
976
  }
881
977
  }
882
- const Lt = [
978
+ const $t = [
883
979
  // Logical
884
980
  // IF is excluded here even though its native body is real, non-stub code —
885
981
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -905,7 +1001,7 @@ const Lt = [
905
1001
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
906
1002
  "DATE",
907
1003
  "TODAY"
908
- ], Ft = [
1004
+ ], _t = [
909
1005
  "MAX",
910
1006
  "MIN",
911
1007
  "MAXA",
@@ -924,7 +1020,7 @@ const Lt = [
924
1020
  "COUNTA",
925
1021
  // not present in fast-formula-parser's function table at all.
926
1022
  "UPPER"
927
- ], Ut = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Pt = ["IF"], $t = [
1023
+ ], Vt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Ht = ["IF"], Wt = [
928
1024
  "CONCATENATE",
929
1025
  "CONCAT",
930
1026
  "LEN",
@@ -935,24 +1031,24 @@ const Lt = [
935
1031
  "MID",
936
1032
  "FIND",
937
1033
  "SEARCH"
938
- ], _t = /* @__PURE__ */ new Set([
939
- ...Lt,
940
- ...Ft,
941
- ...Ut,
1034
+ ], jt = /* @__PURE__ */ new Set([
942
1035
  ...$t,
943
- ...Pt
944
- ]), Vt = /"(?:[^"]|"")*"/g, er = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
945
- function Ht(e) {
946
- const t = e.replace(Vt, (o) => " ".repeat(o.length));
947
- er.lastIndex = 0;
1036
+ ..._t,
1037
+ ...Vt,
1038
+ ...Wt,
1039
+ ...Ht
1040
+ ]), Bt = /"(?:[^"]|"")*"/g, or = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
1041
+ function Xt(e) {
1042
+ const t = e.replace(Bt, (o) => " ".repeat(o.length));
1043
+ or.lastIndex = 0;
948
1044
  let r;
949
- for (; (r = er.exec(t)) !== null; ) {
1045
+ for (; (r = or.exec(t)) !== null; ) {
950
1046
  const o = r[1].toUpperCase();
951
- if (!_t.has(o))
952
- throw new ne("NAME", `Function ${o} is not allowed.`);
1047
+ if (!jt.has(o))
1048
+ throw new oe("NAME", `Function ${o} is not allowed.`);
953
1049
  }
954
1050
  }
955
- function Wt(e, t, r) {
1051
+ function Kt(e, t, r) {
956
1052
  let o = e;
957
1053
  if (o == null) throw r.NA;
958
1054
  if (typeof o == "object" && !(o instanceof r) && (o = t.retrieveRef(o)), o instanceof r) throw o;
@@ -960,54 +1056,54 @@ function Wt(e, t, r) {
960
1056
  if (typeof o == "number") return o !== 0;
961
1057
  throw r.VALUE;
962
1058
  }
963
- function vr(e) {
1059
+ function Or(e) {
964
1060
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
965
1061
  }
966
1062
  function Ce(e) {
967
- const t = vr(e);
1063
+ const t = Or(e);
968
1064
  return Array.isArray(t) ? t.flat(1 / 0) : [t];
969
1065
  }
970
- function M(e) {
971
- const t = vr(e);
1066
+ function V(e) {
1067
+ const t = Or(e);
972
1068
  return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
973
1069
  }
974
- function _e(e) {
975
- return e === void 0 ? void 0 : M(e);
1070
+ function Pe(e) {
1071
+ return e === void 0 ? void 0 : V(e);
976
1072
  }
977
- function te(e) {
1073
+ function ne(e) {
978
1074
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
979
1075
  }
980
- function Xt(e, t) {
1076
+ function Gt(e, t) {
981
1077
  return e instanceof t ? e : new t(e.message || "#ERROR!");
982
1078
  }
983
- function Y(e) {
1079
+ function q(e) {
984
1080
  return e.find((t) => t instanceof Error);
985
1081
  }
986
- function Bt(e, t) {
1082
+ function Yt(e, t) {
987
1083
  const r = (i) => {
988
- throw Xt(i, t);
989
- }, o = (i, { checkArgsForErrors: l = !0 } = {}) => (...a) => {
990
- const s = a.flatMap(Ce);
1084
+ throw Gt(i, t);
1085
+ }, o = (i, { checkArgsForErrors: l = !0 } = {}) => (...c) => {
1086
+ const s = c.flatMap(Ce);
991
1087
  if (l) {
992
- const d = Y(s);
993
- d && r(d);
1088
+ const a = q(s);
1089
+ a && r(a);
994
1090
  }
995
- const c = i(...s);
996
- return c instanceof Error ? r(c) : c;
997
- }, u = (i, { toText: l = !1 } = {}) => (a) => {
998
- const s = M(a), c = Y([s]);
999
- c && r(c);
1000
- const d = i(l ? te(s) : s);
1091
+ const d = i(...s);
1001
1092
  return d instanceof Error ? r(d) : d;
1093
+ }, u = (i, { toText: l = !1 } = {}) => (c) => {
1094
+ const s = V(c), d = q([s]);
1095
+ d && r(d);
1096
+ const a = i(l ? ne(s) : s);
1097
+ return a instanceof Error ? r(a) : a;
1002
1098
  };
1003
1099
  return {
1004
1100
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
1005
1101
  // dereferenced or type-checked here) — that's what makes
1006
1102
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
1007
- IF: (i, l, a, s) => {
1008
- const c = Wt(l, i, t);
1009
- if (a == null) throw t.NA;
1010
- return c ? a : s ?? !1;
1103
+ IF: (i, l, c, s) => {
1104
+ const d = Kt(l, i, t);
1105
+ if (c == null) throw t.NA;
1106
+ return d ? c : s ?? !1;
1011
1107
  },
1012
1108
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1013
1109
  // and formulajs's own convention for MAX/MIN.
@@ -1022,28 +1118,28 @@ function Bt(e, t) {
1022
1118
  // the other aggregates use.
1023
1119
  COUNTA: o(e.COUNTA, { checkArgsForErrors: !1 }),
1024
1120
  LARGE: (i, l) => {
1025
- const a = Ce(i), s = M(l), c = Y([...a, s]);
1026
- c && r(c);
1027
- const d = e.LARGE(a, s);
1028
- return d instanceof Error ? r(d) : d;
1121
+ const c = Ce(i), s = V(l), d = q([...c, s]);
1122
+ d && r(d);
1123
+ const a = e.LARGE(c, s);
1124
+ return a instanceof Error ? r(a) : a;
1029
1125
  },
1030
1126
  SMALL: (i, l) => {
1031
- const a = Ce(i), s = M(l), c = Y([...a, s]);
1032
- c && r(c);
1033
- const d = e.SMALL(a, s);
1034
- return d instanceof Error ? r(d) : d;
1127
+ const c = Ce(i), s = V(l), d = q([...c, s]);
1128
+ d && r(d);
1129
+ const a = e.SMALL(c, s);
1130
+ return a instanceof Error ? r(a) : a;
1035
1131
  },
1036
1132
  PERMUT: (i, l) => {
1037
- const a = [M(i), M(l)], s = Y(a);
1133
+ const c = [V(i), V(l)], s = q(c);
1038
1134
  s && r(s);
1039
- const c = e.PERMUT(a[0], a[1]);
1040
- return c instanceof Error ? r(c) : c;
1135
+ const d = e.PERMUT(c[0], c[1]);
1136
+ return d instanceof Error ? r(d) : d;
1041
1137
  },
1042
1138
  PERMUTATIONA: (i, l) => {
1043
- const a = [M(i), M(l)], s = Y(a);
1139
+ const c = [V(i), V(l)], s = q(c);
1044
1140
  s && r(s);
1045
- const c = e.PERMUTATIONA(a[0], a[1]);
1046
- return c instanceof Error ? r(c) : c;
1141
+ const d = e.PERMUTATIONA(c[0], c[1]);
1142
+ return d instanceof Error ? r(d) : d;
1047
1143
  },
1048
1144
  // match_type is intentionally ignored and forced to 0 (exact match)
1049
1145
  // regardless of what the formula author supplied — approximate/sorted
@@ -1052,30 +1148,30 @@ function Bt(e, t) {
1052
1148
  // real-world data. Same scope decision as the hand-rolled engine this
1053
1149
  // replaces, carried forward deliberately rather than dropped.
1054
1150
  MATCH: (i, l) => {
1055
- const a = M(i), s = Ce(l), c = Y([a, ...s]);
1056
- c && r(c);
1057
- const d = e.MATCH(a, s, 0);
1058
- return d instanceof Error ? r(d) : d;
1151
+ const c = V(i), s = Ce(l), d = q([c, ...s]);
1152
+ d && r(d);
1153
+ const a = e.MATCH(c, s, 0);
1154
+ return a instanceof Error ? r(a) : a;
1059
1155
  },
1060
1156
  SWITCH: (...i) => {
1061
- const l = i.map(M), a = Y(l);
1062
- a && r(a);
1157
+ const l = i.map(V), c = q(l);
1158
+ c && r(c);
1063
1159
  const s = e.SWITCH(...l);
1064
1160
  return s instanceof Error ? r(s) : s;
1065
1161
  },
1066
- SUBSTITUTE: (i, l, a, s) => {
1067
- const c = [te(M(i)), te(M(l)), te(M(a))];
1068
- s !== void 0 && c.push(M(s));
1069
- const d = Y(c);
1070
- d && r(d);
1071
- const y = e.SUBSTITUTE(...c);
1072
- return y instanceof Error ? r(y) : y;
1162
+ SUBSTITUTE: (i, l, c, s) => {
1163
+ const d = [ne(V(i)), ne(V(l)), ne(V(c))];
1164
+ s !== void 0 && d.push(V(s));
1165
+ const a = q(d);
1166
+ a && r(a);
1167
+ const g = e.SUBSTITUTE(...d);
1168
+ return g instanceof Error ? r(g) : g;
1073
1169
  },
1074
- TEXTJOIN: (i, l, ...a) => {
1075
- const s = te(M(i)), c = M(l), d = a.flatMap(Ce).map(te), y = Y([s, c]);
1076
- y && r(y);
1077
- const p = e.TEXTJOIN(s, c, d);
1078
- return p instanceof Error ? r(p) : p;
1170
+ TEXTJOIN: (i, l, ...c) => {
1171
+ const s = ne(V(i)), d = V(l), a = c.flatMap(Ce).map(ne), g = q([s, d]);
1172
+ g && r(g);
1173
+ const f = e.TEXTJOIN(s, d, a);
1174
+ return f instanceof Error ? r(f) : f;
1079
1175
  },
1080
1176
  UPPER: u(e.UPPER),
1081
1177
  // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
@@ -1084,10 +1180,10 @@ function Bt(e, t) {
1084
1180
  MONTH: u(e.MONTH),
1085
1181
  DAY: u(e.DAY),
1086
1182
  WEEKDAY: (i, l) => {
1087
- const a = M(i), s = M(l), c = Y([a]);
1088
- c && r(c);
1089
- const d = e.WEEKDAY(a, s);
1090
- return d instanceof Error ? r(d) : d;
1183
+ const c = V(i), s = V(l), d = q([c]);
1184
+ d && r(d);
1185
+ const a = e.WEEKDAY(c, s);
1186
+ return a instanceof Error ? r(a) : a;
1091
1187
  },
1092
1188
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1093
1189
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1099,53 +1195,53 @@ function Bt(e, t) {
1099
1195
  // separator, matching Excel's own range-argument behavior — the native
1100
1196
  // implementation instead inserts stray commas for a whole-range argument.
1101
1197
  CONCATENATE: (...i) => {
1102
- const l = i.flatMap(Ce), a = Y(l);
1103
- a && r(a);
1104
- const s = e.CONCATENATE(...l.map(te));
1198
+ const l = i.flatMap(Ce), c = q(l);
1199
+ c && r(c);
1200
+ const s = e.CONCATENATE(...l.map(ne));
1105
1201
  return s instanceof Error ? r(s) : s;
1106
1202
  },
1107
1203
  CONCAT: (...i) => {
1108
- const l = i.flatMap(Ce), a = Y(l);
1109
- a && r(a);
1110
- const s = e.CONCAT(...l.map(te));
1204
+ const l = i.flatMap(Ce), c = q(l);
1205
+ c && r(c);
1206
+ const s = e.CONCAT(...l.map(ne));
1111
1207
  return s instanceof Error ? r(s) : s;
1112
1208
  },
1113
1209
  LEN: u(e.LEN, { toText: !0 }),
1114
1210
  TRIM: u(e.TRIM, { toText: !0 }),
1115
1211
  LOWER: u(e.LOWER, { toText: !0 }),
1116
1212
  LEFT: (i, l) => {
1117
- const a = M(i), s = _e(l), c = Y([a]);
1118
- c && r(c);
1119
- const d = e.LEFT(te(a), s);
1120
- return d instanceof Error ? r(d) : d;
1213
+ const c = V(i), s = Pe(l), d = q([c]);
1214
+ d && r(d);
1215
+ const a = e.LEFT(ne(c), s);
1216
+ return a instanceof Error ? r(a) : a;
1121
1217
  },
1122
1218
  RIGHT: (i, l) => {
1123
- const a = M(i), s = _e(l), c = Y([a]);
1124
- c && r(c);
1125
- const d = e.RIGHT(te(a), s);
1126
- return d instanceof Error ? r(d) : d;
1219
+ const c = V(i), s = Pe(l), d = q([c]);
1220
+ d && r(d);
1221
+ const a = e.RIGHT(ne(c), s);
1222
+ return a instanceof Error ? r(a) : a;
1127
1223
  },
1128
- MID: (i, l, a) => {
1129
- const s = M(i), c = M(l), d = M(a), y = Y([s, c, d]);
1130
- y && r(y);
1131
- const p = e.MID(te(s), c, d);
1132
- return p instanceof Error ? r(p) : p;
1224
+ MID: (i, l, c) => {
1225
+ const s = V(i), d = V(l), a = V(c), g = q([s, d, a]);
1226
+ g && r(g);
1227
+ const f = e.MID(ne(s), d, a);
1228
+ return f instanceof Error ? r(f) : f;
1133
1229
  },
1134
- FIND: (i, l, a) => {
1135
- const s = M(i), c = M(l), d = _e(a), y = Y([s, c]);
1136
- y && r(y);
1137
- const p = e.FIND(te(s), te(c), d);
1138
- return p instanceof Error ? r(p) : p;
1230
+ FIND: (i, l, c) => {
1231
+ const s = V(i), d = V(l), a = Pe(c), g = q([s, d]);
1232
+ g && r(g);
1233
+ const f = e.FIND(ne(s), ne(d), a);
1234
+ return f instanceof Error ? r(f) : f;
1139
1235
  },
1140
- SEARCH: (i, l, a) => {
1141
- const s = M(i), c = M(l), d = _e(a), y = Y([s, c]);
1142
- y && r(y);
1143
- const p = e.SEARCH(te(s), te(c), d);
1144
- return p instanceof Error ? r(p) : p;
1236
+ SEARCH: (i, l, c) => {
1237
+ const s = V(i), d = V(l), a = Pe(c), g = q([s, d]);
1238
+ g && r(g);
1239
+ const f = e.SEARCH(ne(s), ne(d), a);
1240
+ return f instanceof Error ? r(f) : f;
1145
1241
  }
1146
1242
  };
1147
1243
  }
1148
- const jt = {
1244
+ const Jt = {
1149
1245
  "#REF!": "REF",
1150
1246
  "#VALUE!": "VALUE",
1151
1247
  "#DIV/0!": "DIV0",
@@ -1154,100 +1250,100 @@ const jt = {
1154
1250
  "#NUM!": "NUM",
1155
1251
  "#NULL!": "NULL"
1156
1252
  };
1157
- function rr(e) {
1158
- return jt[e.error] ?? "ERROR";
1253
+ function ir(e) {
1254
+ return Jt[e.error] ?? "ERROR";
1159
1255
  }
1160
- function tr(e, t) {
1161
- if (e instanceof ne) return e;
1256
+ function lr(e, t) {
1257
+ if (e instanceof oe) return e;
1162
1258
  if (e instanceof t) {
1163
1259
  const r = e.details;
1164
- return r instanceof ne ? r : r instanceof t ? new ne(rr(r), r.message) : new ne(rr(e), e.message);
1260
+ return r instanceof oe ? r : r instanceof t ? new oe(ir(r), r.message) : new oe(ir(e), e.message);
1165
1261
  }
1166
- return new ne("ERROR", e instanceof Error ? e.message : void 0);
1262
+ return new oe("ERROR", e instanceof Error ? e.message : void 0);
1167
1263
  }
1168
- function Kt(e) {
1264
+ function Zt(e) {
1169
1265
  return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
1170
1266
  }
1171
- function Gt(e) {
1267
+ function qt(e) {
1172
1268
  return (t) => {
1173
1269
  const r = e[t.row - 1];
1174
1270
  if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
1175
- throw new ne("REF");
1271
+ throw new oe("REF");
1176
1272
  const o = r[t.col - 1];
1177
1273
  return o == null || o === "" ? null : o;
1178
1274
  };
1179
1275
  }
1180
- function Yt(e) {
1276
+ function Qt(e) {
1181
1277
  return (t) => {
1182
- const r = Math.min(t.from.row, t.to.row), o = Math.min(t.from.col, t.to.col), u = Math.max(t.from.row, t.to.row), i = Math.max(t.from.col, t.to.col), l = Kt(e);
1278
+ const r = Math.min(t.from.row, t.to.row), o = Math.min(t.from.col, t.to.col), u = Math.max(t.from.row, t.to.row), i = Math.max(t.from.col, t.to.col), l = Zt(e);
1183
1279
  if (r > e.length || o > l)
1184
- throw new ne("REF");
1185
- const a = Math.min(u, e.length), s = [];
1186
- for (let c = r; c <= a; c++) {
1187
- const d = e[c - 1], y = [];
1188
- if (d != null) {
1189
- const p = Math.min(i, d.length);
1190
- for (let m = o; m <= p; m++) {
1191
- const v = d[m - 1];
1192
- y.push(v == null || v === "" ? null : v);
1280
+ throw new oe("REF");
1281
+ const c = Math.min(u, e.length), s = [];
1282
+ for (let d = r; d <= c; d++) {
1283
+ const a = e[d - 1], g = [];
1284
+ if (a != null) {
1285
+ const f = Math.min(i, a.length);
1286
+ for (let y = o; y <= f; y++) {
1287
+ const w = a[y - 1];
1288
+ g.push(w == null || w === "" ? null : w);
1193
1289
  }
1194
1290
  }
1195
- s.push(y);
1291
+ s.push(g);
1196
1292
  }
1197
1293
  return s;
1198
1294
  };
1199
1295
  }
1200
- function Jt(e) {
1296
+ function en(e) {
1201
1297
  if (e == null || e === "") return null;
1202
1298
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1203
1299
  return e;
1204
- throw new ne("VALUE");
1300
+ throw new oe("VALUE");
1205
1301
  }
1206
- async function br(e, t) {
1207
- if (typeof e != "string") throw new ne("ERROR");
1302
+ async function xr(e, t) {
1303
+ if (typeof e != "string") throw new oe("ERROR");
1208
1304
  const r = e.trim();
1209
- if (r === "") throw new ne("ERROR");
1305
+ if (r === "") throw new oe("ERROR");
1210
1306
  const o = r.startsWith("=") ? r.slice(1) : r;
1211
- Ht(o);
1307
+ Xt(o);
1212
1308
  const [u, i] = await Promise.all([
1213
1309
  import("fast-formula-parser"),
1214
1310
  import("@formulajs/formulajs")
1215
- ]), l = u.default ?? u, a = l.FormulaError, s = new l({
1311
+ ]), l = u.default ?? u, c = l.FormulaError, s = new l({
1216
1312
  ...t,
1217
1313
  // 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.
1218
- functions: Bt(i, a)
1314
+ functions: Yt(i, c)
1219
1315
  });
1220
- let c;
1316
+ let d;
1221
1317
  try {
1222
- c = s.parse(o, { row: 1, col: 1, sheet: "Sheet1" });
1223
- } catch (d) {
1224
- throw tr(d, a);
1318
+ d = s.parse(o, { row: 1, col: 1, sheet: "Sheet1" });
1319
+ } catch (a) {
1320
+ throw lr(a, c);
1225
1321
  }
1226
- if (c instanceof a)
1227
- throw tr(c, a);
1228
- return Jt(c);
1322
+ if (d instanceof c)
1323
+ throw lr(d, c);
1324
+ return en(d);
1229
1325
  }
1230
- async function qt(e, t) {
1231
- return br(t, { onCell: Gt(e), onRange: Yt(e) });
1326
+ async function rn(e, t) {
1327
+ return xr(t, { onCell: qt(e), onRange: Qt(e) });
1232
1328
  }
1233
- const nr = -1;
1234
- async function wr(e, t) {
1329
+ const sr = -1;
1330
+ async function Nr(e, t) {
1235
1331
  const r = Object.keys(e);
1236
- return br(t, {
1332
+ return xr(t, {
1237
1333
  onVariable: (o) => {
1238
1334
  const u = r.indexOf(o);
1239
- return u === -1 ? null : { row: nr, col: u + 1 };
1335
+ return u === -1 ? null : { row: sr, col: u + 1 };
1240
1336
  },
1241
1337
  onCell: (o) => {
1242
- if (o.row === nr) return e[r[o.col - 1]] ?? null;
1243
- throw new ne("REF");
1338
+ if (o.row === sr) return e[r[o.col - 1]] ?? null;
1339
+ throw new oe("REF");
1244
1340
  },
1245
1341
  onRange: () => {
1246
- throw new ne("REF");
1342
+ throw new oe("REF");
1247
1343
  }
1248
1344
  });
1249
1345
  }
1250
- const Er = {
1346
+ const Ir = {
1251
1347
  REF: "#REF!",
1252
1348
  VALUE: "#VALUE!",
1253
1349
  DIV0: "#DIV/0!",
@@ -1258,21 +1354,21 @@ const Er = {
1258
1354
  NULL: "#NULL!"
1259
1355
  };
1260
1356
  function qe(e) {
1261
- const t = e instanceof ne ? e.code : "ERROR";
1262
- return Er[t];
1357
+ const t = e instanceof oe ? e.code : "ERROR";
1358
+ return Ir[t];
1263
1359
  }
1264
- async function Zt(e, t) {
1360
+ async function tn(e, t) {
1265
1361
  return e.length === 0 ? t.map((r) => ({
1266
1362
  id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1267
1363
  label: (r == null ? void 0 : r.label) ?? "(unknown)",
1268
1364
  value: null,
1269
- error: Er.ERROR
1365
+ error: Ir.ERROR
1270
1366
  })) : Promise.all(
1271
1367
  t.map(async (r) => {
1272
1368
  try {
1273
1369
  if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
1274
- throw new ne("ERROR");
1275
- return { id: r.id, label: r.label, value: await qt(e, r.expression) };
1370
+ throw new oe("ERROR");
1371
+ return { id: r.id, label: r.label, value: await rn(e, r.expression) };
1276
1372
  } catch (o) {
1277
1373
  return {
1278
1374
  id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
@@ -1284,115 +1380,133 @@ async function Zt(e, t) {
1284
1380
  })
1285
1381
  );
1286
1382
  }
1287
- function Qt(e, t = {}) {
1288
- if (t.columnHeader && t.rowHeader)
1289
- throw new Error(
1290
- "x-spreadsheet: columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape."
1291
- );
1292
- return t.columnHeader ? en(e) : t.rowHeader ? rn(e) : e;
1383
+ function cr(e) {
1384
+ const t = /* @__PURE__ */ new Set();
1385
+ for (const { id: r } of e) {
1386
+ if (t.has(r)) return r;
1387
+ t.add(r);
1388
+ }
1389
+ return null;
1293
1390
  }
1294
- function Rr(e) {
1295
- return e == null || e === "" ? null : e instanceof Date ? e.toISOString() : String(e);
1391
+ function kr(e) {
1392
+ const { columnHeader: t, rowHeader: r, columns: o, rows: u } = e;
1393
+ if (o !== void 0 && !Array.isArray(o))
1394
+ return "columns must be an array of { id, label } objects.";
1395
+ if (u !== void 0 && !Array.isArray(u))
1396
+ return "rows must be an array of { id, label } objects.";
1397
+ if (o !== void 0 && o.length === 0)
1398
+ return "columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1399
+ if (u !== void 0 && u.length === 0)
1400
+ return "rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
1401
+ const i = (a) => !!a && typeof a.id == "string" && a.id !== "" && typeof a.label == "string" && a.label !== "", l = o == null ? void 0 : o.findIndex((a) => !i(a));
1402
+ if (l != null && l !== -1)
1403
+ return `columns[${l}] must be a { id, label } object with non-empty string fields.`;
1404
+ const c = u == null ? void 0 : u.findIndex((a) => !i(a));
1405
+ if (c != null && c !== -1)
1406
+ return `rows[${c}] must be a { id, label } object with non-empty string fields.`;
1407
+ const s = !!o && o.length > 0, d = !!u && u.length > 0;
1408
+ if (s) {
1409
+ const a = cr(o);
1410
+ if (a) return `duplicate column id "${a}" — every declared column id must be unique.`;
1411
+ }
1412
+ if (d) {
1413
+ const a = cr(u);
1414
+ if (a) return `duplicate row id "${a}" — every declared row id must be unique.`;
1415
+ }
1416
+ return t && r ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : s && d ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : t && !s ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : r && !d ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
1296
1417
  }
1297
- function Tr(e, t) {
1298
- const r = /* @__PURE__ */ new Set();
1299
- for (const o of e)
1300
- if (o != null) {
1301
- if (r.has(o))
1302
- throw new Error(
1303
- `x-spreadsheet: duplicate ${t} value "${o}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
1304
- );
1305
- r.add(o);
1306
- }
1418
+ function ar(e, t = {}) {
1419
+ const r = kr(t);
1420
+ if (r) throw new Error(`x-spreadsheet: ${r}`);
1421
+ const { columnHeader: o, rowHeader: u, columns: i, rows: l } = t;
1422
+ return i && i.length > 0 ? nn(e, i, o === !0) : l && l.length > 0 ? on(e, l, u === !0) : e;
1307
1423
  }
1308
- function en(e) {
1309
- const [t, ...r] = e;
1310
- if (!t) return [];
1311
- const o = t.map(Rr);
1312
- return Tr(o, "columnHeader"), r.map((u) => {
1424
+ function nn(e, t, r) {
1425
+ return (r ? e.slice(1) : e).map((u) => {
1313
1426
  const i = /* @__PURE__ */ Object.create(null);
1314
- return o.forEach((l, a) => {
1315
- l != null && (i[l] = u[a] ?? null);
1427
+ return t.forEach((l, c) => {
1428
+ i[l.id] = u[c] ?? null;
1316
1429
  }), i;
1317
1430
  });
1318
1431
  }
1319
- function rn(e) {
1320
- const t = e.map((u) => Rr(u[0]));
1321
- Tr(t, "rowHeader");
1322
- const r = Math.max(0, ...e.map((u) => u.length)), o = Math.max(0, r - 1);
1323
- return Array.from({ length: o }, (u, i) => {
1324
- const l = i + 1, a = /* @__PURE__ */ Object.create(null);
1325
- return t.forEach((s, c) => {
1326
- s != null && (a[s] = e[c][l] ?? null);
1327
- }), a;
1432
+ function on(e, t, r) {
1433
+ const o = r ? 1 : 0, u = Math.max(0, ...e.map((l) => l.length)), i = Math.max(0, u - o);
1434
+ return Array.from({ length: i }, (l, c) => {
1435
+ const s = o + c, d = /* @__PURE__ */ Object.create(null);
1436
+ return t.forEach((a, g) => {
1437
+ var f;
1438
+ d[a.id] = ((f = e[g]) == null ? void 0 : f[s]) ?? null;
1439
+ }), d;
1328
1440
  });
1329
1441
  }
1330
- function tn(e) {
1442
+ function ln(e) {
1331
1443
  return !Array.isArray(e[0]);
1332
1444
  }
1333
- function nn(e) {
1445
+ function sn(e) {
1334
1446
  const t = /* @__PURE__ */ Object.create(null);
1335
1447
  for (const { id: r, label: o, value: u, error: i } of e)
1336
1448
  t[r] = i === void 0 ? { label: o, value: u } : { label: o, value: u, error: i };
1337
1449
  return t;
1338
1450
  }
1339
- function Ge(e, t) {
1451
+ function Ye(e, t) {
1340
1452
  const r = (o) => o instanceof Date ? o.toISOString() : o ?? null;
1341
1453
  return r(e) === r(t);
1342
1454
  }
1343
- function on(e, t) {
1455
+ function cn(e, t) {
1344
1456
  const r = e ?? {}, o = t ?? {}, u = Object.keys(r);
1345
1457
  return u.length !== Object.keys(o).length ? !1 : u.every((i) => {
1346
1458
  if (!Object.prototype.hasOwnProperty.call(o, i)) return !1;
1347
- const l = r[i], a = o[i];
1348
- return l.label === a.label && l.error === a.error && Ge(l.value, a.value);
1459
+ const l = r[i], c = o[i];
1460
+ return l.label === c.label && l.error === c.error && Ye(l.value, c.value);
1349
1461
  });
1350
1462
  }
1351
- function ln(e, t) {
1463
+ function an(e, t) {
1352
1464
  if (e == null || t == null) return e === t;
1353
1465
  const r = Array.isArray(e);
1354
1466
  if (r !== Array.isArray(t)) return !1;
1355
1467
  if (r) {
1356
- const l = e, a = t;
1357
- return l.length === a.length && l.every((s, c) => Ge(s, a[c]));
1468
+ const l = e, c = t;
1469
+ return l.length === c.length && l.every((s, d) => Ye(s, c[d]));
1358
1470
  }
1359
1471
  const o = e, u = t, i = Object.keys(o);
1360
- return i.length !== Object.keys(u).length ? !1 : i.every((l) => Object.prototype.hasOwnProperty.call(u, l) && Ge(o[l], u[l]));
1472
+ return i.length !== Object.keys(u).length ? !1 : i.every((l) => Object.prototype.hasOwnProperty.call(u, l) && Ye(o[l], u[l]));
1361
1473
  }
1362
- function sn(e, t) {
1474
+ function un(e, t) {
1363
1475
  if (e === t) return !0;
1364
1476
  if (e == null || t == null) return !1;
1365
1477
  const r = e, o = t;
1366
- return r.length !== o.length ? !1 : r.every((u, i) => ln(u, o[i]));
1478
+ return r.length !== o.length ? !1 : r.every((u, i) => an(u, o[i]));
1367
1479
  }
1368
- function cn(e) {
1480
+ function dn(e) {
1369
1481
  return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
1370
1482
  }
1371
- function an(e) {
1483
+ function fn(e, t) {
1372
1484
  if (e.length === 0) return [];
1373
- const t = [], r = /* @__PURE__ */ new Set();
1374
- for (const u of e)
1375
- for (const i of Object.keys(u))
1376
- r.has(i) || (r.add(i), t.push(i));
1377
- if (t.length === 0) return [];
1378
- const o = e.map(
1379
- (u) => t.map((i) => {
1380
- if (!Object.prototype.hasOwnProperty.call(u, i)) return null;
1381
- const l = u[i];
1382
- return cn(l) ? l : null;
1485
+ const r = [], o = /* @__PURE__ */ new Set();
1486
+ for (const i of t ?? [])
1487
+ o.has(i) || (o.add(i), r.push(i));
1488
+ for (const i of e)
1489
+ for (const l of Object.keys(i))
1490
+ o.has(l) || (o.add(l), r.push(l));
1491
+ if (r.length === 0) return [];
1492
+ const u = e.map(
1493
+ (i) => r.map((l) => {
1494
+ if (!Object.prototype.hasOwnProperty.call(i, l)) return null;
1495
+ const c = i[l];
1496
+ return dn(c) ? c : null;
1383
1497
  })
1384
1498
  );
1385
- return [t, ...o];
1499
+ return [r, ...u];
1386
1500
  }
1387
- function un(e) {
1501
+ function hn(e) {
1388
1502
  const t = Math.max(0, ...e.map((r) => r.length));
1389
1503
  return Array.from({ length: t }, (r, o) => e.map((u) => u[o] ?? null));
1390
1504
  }
1391
- const dn = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", fn = 10 * 1024 * 1024, Xe = 200, hn = 50, pn = [];
1392
- function Ve(e) {
1505
+ const pn = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", mn = 10 * 1024 * 1024, Be = 200, gn = 50, yn = [];
1506
+ function ur(e) {
1393
1507
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1394
1508
  }
1395
- const mn = ({
1509
+ const vn = ({
1396
1510
  data: e,
1397
1511
  handleChange: t,
1398
1512
  path: r,
@@ -1400,249 +1514,264 @@ const mn = ({
1400
1514
  required: u,
1401
1515
  schema: i,
1402
1516
  enabled: l,
1403
- readonly: a,
1517
+ readonly: c,
1404
1518
  errors: s,
1405
- visible: c = !0
1519
+ visible: d = !0
1406
1520
  }) => {
1407
- be(c, r, t, null);
1408
- const d = !s || s.length === 0, y = yr(l, a), p = (i == null ? void 0 : i["x-spreadsheet"]) ?? {}, m = (i == null ? void 0 : i["x-evaluate"]) ?? pn, v = p.accept ?? dn, I = p.maxSize ?? fn, A = p.columnHeader === !0, b = p.rowHeader === !0, k = p.showSheet !== !1, F = p.sheetName, z = p.persistSheet !== !1, w = e ?? null, [_, V] = $(
1409
- () => w != null && w.sheet || Object.keys((w == null ? void 0 : w.derivations) ?? {}).length > 0 ? "ready" : "empty"
1410
- ), [O, C] = $(null), [H, B] = $(!1), [W, j] = $(null), [ee, re] = $(null), le = pe(null), oe = pe(null), se = (w == null ? void 0 : w.sheet) ?? null, de = ke(
1411
- (E) => {
1412
- if (!tn(E)) return E;
1413
- const L = an(E);
1414
- return b ? un(L) : L;
1521
+ ge(d, r, t);
1522
+ const a = !s || s.length === 0, g = Sr(l, c), f = (i == null ? void 0 : i["x-spreadsheet"]) ?? {}, y = (i == null ? void 0 : i["x-evaluate"]) ?? yn, w = f.accept ?? pn, L = f.maxSize ?? mn, O = f.columnHeader === !0, R = f.rowHeader === !0, T = f.columns, S = f.rows, N = Array.isArray(T) && T.length > 0, D = Array.isArray(S) && S.length > 0, $ = kr({ columnHeader: O, rowHeader: R, columns: T, rows: S }), W = f.showSheet !== !1, z = f.sheetName, E = f.persistSheet !== !1, b = e ?? null, [K, G] = H(
1523
+ () => b != null && b.sheet || Object.keys((b == null ? void 0 : b.derivations) ?? {}).length > 0 ? "ready" : "empty"
1524
+ ), [j, Y] = H(null), [C, Z] = H(!1), [J, he] = H(null), [ie, ye] = H(null), h = le(null), x = le(null), B = (b == null ? void 0 : b.sheet) ?? null, M = Ne(
1525
+ (A) => {
1526
+ if (!ln(A)) return A;
1527
+ const v = D ? S : N ? T : void 0, X = fn(
1528
+ A,
1529
+ v == null ? void 0 : v.map((F) => F.id)
1530
+ );
1531
+ return D ? hn(X) : X;
1415
1532
  },
1416
- [b]
1417
- ), G = Be(() => W ?? (se ? de(se) : null), [W, se, de]), f = ((ee == null ? void 0 : ee.matrix) === G ? ee.derivations : null) ?? (w == null ? void 0 : w.derivations) ?? {}, T = G != null || w != null, K = Be(() => {
1418
- const E = A ? 1 : 0, L = b ? 1 : 0, ue = G ? G.slice(E) : [], X = ue.slice(0, Xe), P = Math.min(
1419
- hn,
1420
- Math.max(0, ...X.map((Q) => Math.max(0, Q.length - L)))
1421
- ), Ee = Array.from({ length: P }, (Q, ae) => ae + L), R = "", ce = b && !A;
1422
- return /* @__PURE__ */ n(he, { children: G && k && /* @__PURE__ */ g(x, { mt: "3", children: [
1423
- /* @__PURE__ */ n(x, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(Re.Root, { variant: "surface", size: "1", children: [
1424
- !ce && /* @__PURE__ */ n(Re.Header, { children: /* @__PURE__ */ g(Re.Row, { children: [
1425
- /* @__PURE__ */ n(Re.ColumnHeaderCell, { children: R }),
1426
- Ee.map((Q) => {
1427
- var ae;
1533
+ [N, D, T, S]
1534
+ ), P = Xe(() => J ?? (B ? M(B) : null), [J, B, M]), Q = ((ie == null ? void 0 : ie.matrix) === P ? ie.derivations : null) ?? (b == null ? void 0 : b.derivations) ?? {}, ee = P != null || b != null, re = Xe(() => {
1535
+ const A = N ? 1 : 0, v = D ? 1 : 0, X = P ? P.slice(A) : [], F = X.slice(0, Be), U = Math.min(
1536
+ gn,
1537
+ Math.max(0, ...F.map((we) => Math.max(0, we.length - v)))
1538
+ ), se = Array.from({ length: U }, (we, Ae) => Ae + v), Re = "", je = D && !N;
1539
+ return /* @__PURE__ */ n(ae, { children: P && W && /* @__PURE__ */ m(I, { mt: "3", children: [
1540
+ /* @__PURE__ */ n(I, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ m(ve.Root, { variant: "surface", size: "1", children: [
1541
+ !je && /* @__PURE__ */ n(ve.Header, { children: /* @__PURE__ */ m(ve.Row, { children: [
1542
+ /* @__PURE__ */ n(ve.ColumnHeaderCell, { children: Re }),
1543
+ se.map((we) => {
1544
+ var Ae;
1428
1545
  return (
1429
- // This row only renders when rowHeader isn't the sole
1546
+ // This row only renders when hasRows isn't the sole
1430
1547
  // flag set (see suppressColumnHeaderRow) — so reaching
1431
- // here, either columnHeader is true (real labels) or
1432
- // both are false (columnLetter fallback).
1433
- /* @__PURE__ */ n(Re.ColumnHeaderCell, { children: A ? Ve((ae = G[0]) == null ? void 0 : ae[Q]) : zt(Q) }, Q)
1548
+ // here, either hasColumns is true (declared labels,
1549
+ // looked up positionally — never read from the matrix
1550
+ // cell itself, which only ever holds the id) or both
1551
+ // are false (columnLetter fallback).
1552
+ /* @__PURE__ */ n(ve.ColumnHeaderCell, { children: N ? ((Ae = T == null ? void 0 : T[we]) == null ? void 0 : Ae.label) ?? "" : Pt(we) }, we)
1434
1553
  );
1435
1554
  })
1436
1555
  ] }) }),
1437
- /* @__PURE__ */ n(Re.Body, { children: X.map((Q, ae) => {
1438
- var Ie;
1439
- const Ae = E + ae;
1440
- return /* @__PURE__ */ g(Re.Row, { children: [
1556
+ /* @__PURE__ */ n(ve.Body, { children: F.map((we, Ae) => {
1557
+ var er;
1558
+ const Qe = A + Ae;
1559
+ return /* @__PURE__ */ m(ve.Row, { children: [
1441
1560
  /* @__PURE__ */ n(
1442
- Re.RowHeaderCell,
1561
+ ve.RowHeaderCell,
1443
1562
  {
1444
- style: b ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1445
- children: b ? Ve((Ie = G[Ae]) == null ? void 0 : Ie[0]) : A ? "" : Ae + 1
1563
+ style: D ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1564
+ children: D ? ((er = S == null ? void 0 : S[Qe]) == null ? void 0 : er.label) ?? "" : N ? "" : Qe + 1
1446
1565
  }
1447
1566
  ),
1448
- Ee.map((Ue) => /* @__PURE__ */ n(Re.Cell, { children: Ve(Q[Ue]) }, Ue))
1449
- ] }, ae);
1567
+ se.map((rr) => /* @__PURE__ */ n(ve.Cell, { children: ur(we[rr]) }, rr))
1568
+ ] }, Ae);
1450
1569
  }) })
1451
1570
  ] }) }),
1452
- ue.length > Xe && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1571
+ X.length > Be && /* @__PURE__ */ m(p, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1453
1572
  "Showing first ",
1454
- Xe,
1573
+ Be,
1455
1574
  " of ",
1456
- ue.length,
1575
+ X.length,
1457
1576
  " rows"
1458
1577
  ] })
1459
1578
  ] }) });
1460
- }, [G, k, A, b]), N = ke(
1461
- async (E) => {
1462
- if (C(null), E.size > I) {
1463
- C(`File exceeds the ${ye(I)} limit.`);
1579
+ }, [P, W, N, D, T, S]), _ = Ne(
1580
+ async (A) => {
1581
+ if (Y(null), A.size > L) {
1582
+ Y(`File exceeds the ${pe(L)} limit.`);
1464
1583
  return;
1465
1584
  }
1466
- if (!v.split(",").map((P) => P.trim()).some((P) => P === "*" || P === "*/*" ? !0 : P.endsWith("/*") ? E.type.startsWith(P.slice(0, -1)) : P.startsWith(".") ? E.name.toLowerCase().endsWith(P.toLowerCase()) : E.type === P)) {
1467
- C(`Invalid type. Accepted: ${ve(v)}`);
1585
+ if (!w.split(",").map((U) => U.trim()).some((U) => U === "*" || U === "*/*" ? !0 : U.endsWith("/*") ? A.type.startsWith(U.slice(0, -1)) : U.startsWith(".") ? A.name.toLowerCase().endsWith(U.toLowerCase()) : A.type === U)) {
1586
+ Y(`Invalid type. Accepted: ${me(w)}`);
1468
1587
  return;
1469
1588
  }
1470
- V("parsing");
1471
- let X;
1589
+ G("parsing");
1590
+ let F;
1472
1591
  try {
1473
- const P = await E.arrayBuffer();
1474
- X = Mt(P, F).matrix;
1475
- } catch (P) {
1476
- V("error"), C(
1477
- P instanceof Ke ? P.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1592
+ const U = await A.arrayBuffer();
1593
+ F = (await Ut(U, z)).matrix;
1594
+ } catch (U) {
1595
+ G("error"), Y(
1596
+ U instanceof Ge ? U.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1478
1597
  );
1479
1598
  return;
1480
1599
  }
1481
- oe.current = (e == null ? void 0 : e.sheet) ?? null, j(X), V("ready");
1600
+ if (N || D)
1601
+ try {
1602
+ F = M(ar(F, { columnHeader: O, rowHeader: R, columns: T, rows: S }));
1603
+ } catch (U) {
1604
+ G("error"), Y(U instanceof Error ? U.message : "Failed to process this sheet.");
1605
+ return;
1606
+ }
1607
+ x.current = (e == null ? void 0 : e.sheet) ?? null, he(F), G("ready");
1482
1608
  },
1483
- [v, I, F, e]
1609
+ [w, L, z, e, O, R, T, S, N, D, M]
1484
1610
  );
1485
- if (ge(() => {
1486
- W != null && se != null && se !== oe.current && j(null);
1487
- }, [W, se]), ge(() => {
1488
- if (m.length === 0 && !z) return;
1489
- let E = !1;
1490
- const L = (X) => {
1491
- y && (on(w == null ? void 0 : w.derivations, X == null ? void 0 : X.derivations) && sn(w == null ? void 0 : w.sheet, X == null ? void 0 : X.sheet) || (oe.current = (X == null ? void 0 : X.sheet) ?? null, t(r, X)));
1492
- }, ue = G ?? [];
1493
- if (ue.length === 0) {
1494
- w != null && L(void 0);
1611
+ if (ue(() => {
1612
+ J != null && B != null && B !== x.current && he(null);
1613
+ }, [J, B]), ue(() => {
1614
+ if ($ || y.length === 0 && !E) return;
1615
+ let A = !1;
1616
+ const v = (F) => {
1617
+ g && (cn(b == null ? void 0 : b.derivations, F == null ? void 0 : F.derivations) && un(b == null ? void 0 : b.sheet, F == null ? void 0 : F.sheet) || (x.current = (F == null ? void 0 : F.sheet) ?? null, t(r, F)));
1618
+ }, X = P ?? [];
1619
+ if (X.length === 0) {
1620
+ b != null && v(void 0);
1495
1621
  return;
1496
1622
  }
1497
- return Zt(ue, m).then((X) => {
1498
- if (E) return;
1499
- let P;
1500
- if (W != null) {
1501
- if (z)
1623
+ return tn(X, y).then((F) => {
1624
+ if (A) return;
1625
+ let U;
1626
+ if (J != null) {
1627
+ if (E)
1502
1628
  try {
1503
- P = Qt(ue, { columnHeader: A, rowHeader: b });
1504
- } catch (R) {
1505
- C(R instanceof Error ? R.message : "Failed to process this sheet.");
1629
+ U = ar(X, { columnHeader: N, rowHeader: D, columns: T, rows: S });
1630
+ } catch (Re) {
1631
+ Y(Re instanceof Error ? Re.message : "Failed to process this sheet.");
1506
1632
  return;
1507
1633
  }
1508
1634
  } else
1509
- P = w == null ? void 0 : w.sheet;
1510
- C(null);
1511
- const Ee = nn(X);
1512
- re({ matrix: ue, derivations: Ee }), L(P === void 0 ? { derivations: Ee } : { sheet: P, derivations: Ee });
1635
+ U = b == null ? void 0 : b.sheet;
1636
+ Y(null);
1637
+ const se = sn(F);
1638
+ ye({ matrix: X, derivations: se }), v(U === void 0 ? { derivations: se } : { sheet: U, derivations: se });
1513
1639
  }), () => {
1514
- E = !0;
1640
+ A = !0;
1515
1641
  };
1516
- }, [G, W, m, y, z, A, b]), c === !1)
1642
+ }, [P, J, y, g, E, N, D, T, S, $]), d === !1)
1517
1643
  return null;
1518
- if (A && b)
1519
- return /* @__PURE__ */ g(x, { mb: "4", children: [
1520
- /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: o }),
1521
- /* @__PURE__ */ n(h, { size: "2", color: "red", style: { display: "block" }, children: "Invalid x-spreadsheet config: columnHeader and rowHeader cannot both be true — pick one orientation." })
1644
+ if ($)
1645
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1646
+ /* @__PURE__ */ n(p, { as: "label", size: "2", weight: "bold", children: o }),
1647
+ /* @__PURE__ */ m(p, { size: "2", color: "red", style: { display: "block" }, children: [
1648
+ "Invalid x-spreadsheet config: ",
1649
+ $
1650
+ ] })
1522
1651
  ] });
1523
- if (!y && !T) return null;
1524
- const U = (E) => {
1525
- E.preventDefault(), E.stopPropagation(), y && B(E.type === "dragenter" || E.type === "dragover");
1526
- }, Z = (E) => {
1527
- var L;
1528
- E.preventDefault(), E.stopPropagation(), B(!1), y && (L = E.dataTransfer.files) != null && L[0] && N(E.dataTransfer.files[0]);
1529
- }, ie = (E) => {
1530
- var L;
1531
- (L = E.target.files) != null && L[0] && (N(E.target.files[0]), E.target.value = "");
1532
- }, J = () => {
1533
- y && (j(null), re(null), oe.current = null, C(null), V("empty"), t(r, null));
1534
- }, D = k && G == null && w != null;
1535
- return /* @__PURE__ */ g(x, { mb: "4", children: [
1536
- /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
1537
- /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
1538
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1652
+ if (!g && !ee) return null;
1653
+ const Se = (A) => {
1654
+ A.preventDefault(), A.stopPropagation(), g && Z(A.type === "dragenter" || A.type === "dragover");
1655
+ }, Ve = (A) => {
1656
+ var v;
1657
+ A.preventDefault(), A.stopPropagation(), Z(!1), g && (v = A.dataTransfer.files) != null && v[0] && _(A.dataTransfer.files[0]);
1658
+ }, Le = (A) => {
1659
+ var v;
1660
+ (v = A.target.files) != null && v[0] && (_(A.target.files[0]), A.target.value = "");
1661
+ }, He = () => {
1662
+ g && (he(null), ye(null), x.current = null, Y(null), G("empty"), t(r, void 0));
1663
+ }, We = W && P == null && b != null;
1664
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1665
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
1666
+ /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
1667
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
1539
1668
  o,
1540
- u && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1669
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
1541
1670
  ] }),
1542
- T && y && /* @__PURE__ */ g(he, { children: [
1543
- /* @__PURE__ */ n(He, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1544
- Me,
1671
+ ee && g && /* @__PURE__ */ m(ae, { children: [
1672
+ /* @__PURE__ */ n($e, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1673
+ ke,
1545
1674
  {
1546
1675
  variant: "ghost",
1547
1676
  size: "1",
1548
1677
  onClick: () => {
1549
- var E;
1550
- return (E = le.current) == null ? void 0 : E.click();
1678
+ var A;
1679
+ return (A = h.current) == null ? void 0 : A.click();
1551
1680
  },
1552
1681
  "aria-label": "Replace spreadsheet",
1553
- children: /* @__PURE__ */ n(Ne, {})
1682
+ children: /* @__PURE__ */ n(Oe, {})
1554
1683
  }
1555
1684
  ) }),
1556
- /* @__PURE__ */ n(He, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1557
- Me,
1685
+ /* @__PURE__ */ n($e, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1686
+ ke,
1558
1687
  {
1559
1688
  variant: "ghost",
1560
1689
  size: "1",
1561
1690
  color: "gray",
1562
- onClick: J,
1691
+ onClick: He,
1563
1692
  "aria-label": "Remove spreadsheet",
1564
- children: /* @__PURE__ */ n(Ye, {})
1693
+ children: /* @__PURE__ */ n(Je, {})
1565
1694
  }
1566
1695
  ) })
1567
1696
  ] })
1568
1697
  ] }),
1569
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1570
- ye(I),
1698
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
1699
+ pe(L),
1571
1700
  " max · ",
1572
- ve(v)
1701
+ me(w)
1573
1702
  ] })
1574
1703
  ] }),
1575
- T && O && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: O }),
1576
- /* @__PURE__ */ n("input", { ref: le, type: "file", style: { display: "none" }, accept: v, onChange: ie }),
1577
- y && !T && /* @__PURE__ */ n(
1704
+ ee && j && /* @__PURE__ */ n(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: j }),
1705
+ /* @__PURE__ */ n("input", { ref: h, type: "file", style: { display: "none" }, accept: w, onChange: Le }),
1706
+ g && !ee && /* @__PURE__ */ n(
1578
1707
  "div",
1579
1708
  {
1580
1709
  role: "button",
1581
1710
  tabIndex: 0,
1582
1711
  onClick: () => {
1583
- var E;
1584
- return (E = le.current) == null ? void 0 : E.click();
1712
+ var A;
1713
+ return (A = h.current) == null ? void 0 : A.click();
1585
1714
  },
1586
- onKeyDown: (E) => {
1587
- var L;
1588
- (E.key === "Enter" || E.key === " ") && (E.preventDefault(), (L = le.current) == null || L.click());
1715
+ onKeyDown: (A) => {
1716
+ var v;
1717
+ (A.key === "Enter" || A.key === " ") && (A.preventDefault(), (v = h.current) == null || v.click());
1589
1718
  },
1590
- onDragEnter: U,
1591
- onDragLeave: U,
1592
- onDragOver: U,
1593
- onDrop: Z,
1719
+ onDragEnter: Se,
1720
+ onDragLeave: Se,
1721
+ onDragOver: Se,
1722
+ onDrop: Ve,
1594
1723
  style: { cursor: "pointer" },
1595
1724
  className: [
1596
1725
  "border-2 border-dashed rounded-lg p-6 text-center",
1597
1726
  "transition-all duration-200 ease-in-out",
1598
- H ? "border-blue-500 bg-blue-50" : O ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1727
+ C ? "border-blue-500 bg-blue-50" : j ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1599
1728
  ].join(" "),
1600
- children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: _ === "parsing" ? /* @__PURE__ */ g(he, { children: [
1729
+ children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: K === "parsing" ? /* @__PURE__ */ m(ae, { children: [
1601
1730
  /* @__PURE__ */ n(xe, { size: "3" }),
1602
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1603
- ] }) : O ? /* @__PURE__ */ g(he, { children: [
1604
- /* @__PURE__ */ n(Je, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1605
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: O }),
1606
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1607
- ] }) : /* @__PURE__ */ g(he, { children: [
1608
- /* @__PURE__ */ n(Ne, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1609
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1610
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1611
- ye(I),
1731
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1732
+ ] }) : j ? /* @__PURE__ */ m(ae, { children: [
1733
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1734
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: j }),
1735
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
1736
+ ] }) : /* @__PURE__ */ m(ae, { children: [
1737
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1738
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1739
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
1740
+ pe(L),
1612
1741
  " max · ",
1613
- ve(v)
1742
+ me(w)
1614
1743
  ] })
1615
1744
  ] }) })
1616
1745
  }
1617
1746
  ),
1618
- K,
1619
- D && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1620
- Object.keys(f).length > 0 && /* @__PURE__ */ g(x, { mt: "3", children: [
1621
- /* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1622
- /* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(f).map(([E, L]) => /* @__PURE__ */ g(S, { justify: "between", children: [
1623
- /* @__PURE__ */ n(h, { size: "2", children: L.label }),
1624
- L.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: L.error }) : (
1747
+ re,
1748
+ We && /* @__PURE__ */ n(p, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
1749
+ Object.keys(Q).length > 0 && /* @__PURE__ */ m(I, { mt: "3", children: [
1750
+ /* @__PURE__ */ n(p, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1751
+ /* @__PURE__ */ n(k, { direction: "column", gap: "1", children: Object.entries(Q).map(([A, v]) => /* @__PURE__ */ m(k, { justify: "between", children: [
1752
+ /* @__PURE__ */ n(p, { size: "2", children: v.label }),
1753
+ v.error ? /* @__PURE__ */ n(p, { size: "2", color: "red", children: v.error }) : (
1625
1754
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1626
1755
  // possible results anymore — INDEX/CONCATENATE can return a
1627
1756
  // string, a bare comparison can return a boolean, etc.), so
1628
1757
  // `.toLocaleString()` would throw for e.g. a boolean result.
1629
1758
  // Reuse the same formatCell used for the sheet-preview grid.
1630
- /* @__PURE__ */ n(h, { size: "2", children: Ve(L.value) })
1759
+ /* @__PURE__ */ n(p, { size: "2", children: ur(v.value) })
1631
1760
  )
1632
- ] }, E)) })
1761
+ ] }, A)) })
1633
1762
  ] }),
1634
- !d && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(s, o) })
1763
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
1635
1764
  ] });
1636
- }, gn = me(mn), yn = q(
1765
+ }, bn = fe(vn), wn = te(
1637
1766
  10,
1638
1767
  // matches FileControlTester's rank — beats the default object/Group renderer
1639
- ze(
1768
+ De(
1640
1769
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1641
1770
  )
1642
1771
  );
1643
- class Te extends Error {
1772
+ class Ee extends Error {
1644
1773
  }
1645
- const or = 5e6, vn = 1024, bn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, wn = {
1774
+ const dr = 5e6, En = 1024, Rn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, An = {
1646
1775
  // Default is true, which would silently drop what in many formats is most of
1647
1776
  // the payload.
1648
1777
  ignoreAttributes: !1,
@@ -1689,7 +1818,7 @@ const or = 5e6, vn = 1024, bn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["'
1689
1818
  maxNestedTags: 100,
1690
1819
  strictReservedNames: !0
1691
1820
  };
1692
- function En(e) {
1821
+ function Cn(e) {
1693
1822
  const t = new Set(e);
1694
1823
  return t.size === 0 ? () => !1 : (r, o) => (
1695
1824
  // A string while the library's own `jPath` option is true (the default) and
@@ -1697,98 +1826,98 @@ function En(e) {
1697
1826
  t.has(typeof o == "string" ? o : o.toString()) || t.has(r)
1698
1827
  );
1699
1828
  }
1700
- function Rn(e) {
1829
+ function Tn(e) {
1701
1830
  const t = e instanceof Error ? e.message : "";
1702
1831
  return t.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." : t === "External entities are not supported" || t === "Parameter entities are not supported" ? `${t}. Please remove the DOCTYPE entity declarations and try again.` : t.startsWith("Maximum nested tags exceeded") ? "This document is nested too deeply to parse." : t.startsWith("Entity count") || t.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.";
1703
1832
  }
1704
- async function Tn(e, t = {}) {
1705
- var c;
1706
- if (typeof e != "string") throw new Te("This file could not be read as text.");
1833
+ async function Sn(e, t = {}) {
1834
+ var d;
1835
+ if (typeof e != "string") throw new Ee("This file could not be read as text.");
1707
1836
  const r = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
1708
- if (r.trim() === "") throw new Te("This file is empty.");
1709
- if (r.length > or)
1710
- throw new Te(
1711
- `This document is too large to parse (over ${or / 1e6} million characters).`
1837
+ if (r.trim() === "") throw new Ee("This file is empty.");
1838
+ if (r.length > dr)
1839
+ throw new Ee(
1840
+ `This document is too large to parse (over ${dr / 1e6} million characters).`
1712
1841
  );
1713
- const o = (c = bn.exec(r.slice(0, vn))) == null ? void 0 : c[1];
1842
+ const o = (d = Rn.exec(r.slice(0, En))) == null ? void 0 : d[1];
1714
1843
  if (o && !/^utf-?8$/i.test(o))
1715
- throw new Te(
1844
+ throw new Ee(
1716
1845
  `This document declares the unsupported encoding "${o}". Only UTF-8 is supported.`
1717
1846
  );
1718
1847
  const { XMLParser: u, XMLValidator: i } = await import("fast-xml-parser"), l = i.validate(r, { allowBooleanAttributes: !1 });
1719
1848
  if (l !== !0) {
1720
- const { msg: d, line: y, col: p } = l.err;
1721
- throw new Te(`Invalid XML at line ${y}, column ${p}: ${d}`);
1849
+ const { msg: a, line: g, col: f } = l.err;
1850
+ throw new Ee(`Invalid XML at line ${g}, column ${f}: ${a}`);
1722
1851
  }
1723
- const a = new u({
1724
- ...wn,
1852
+ const c = new u({
1853
+ ...An,
1725
1854
  removeNSPrefix: t.removeNamespaces === !0,
1726
- isArray: En(t.arrayPaths ?? [])
1855
+ isArray: Cn(t.arrayPaths ?? [])
1727
1856
  });
1728
1857
  let s;
1729
1858
  try {
1730
- s = a.parse(r);
1731
- } catch (d) {
1732
- throw new Te(Rn(d));
1859
+ s = c.parse(r);
1860
+ } catch (a) {
1861
+ throw new Ee(Tn(a));
1733
1862
  }
1734
1863
  if (s == null || typeof s != "object" || Array.isArray(s))
1735
- throw new Te("This document has no root element.");
1864
+ throw new Ee("This document has no root element.");
1736
1865
  return s;
1737
1866
  }
1738
- const Oe = { found: !1 }, fe = (e) => ({ found: !0, value: e });
1739
- function ir(e) {
1740
- return e == null || e === "" ? Oe : Array.isArray(e) || e instanceof Date ? fe(e) : typeof e == "object" ? Oe : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? fe(e) : Oe;
1867
+ const Te = { found: !1 }, ce = (e) => ({ found: !0, value: e });
1868
+ function fr(e) {
1869
+ return e == null || e === "" ? Te : Array.isArray(e) || e instanceof Date ? ce(e) : typeof e == "object" ? Te : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? ce(e) : Te;
1741
1870
  }
1742
- const An = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), Cn = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
1743
- async function Sn(e, t) {
1871
+ const On = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), xn = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
1872
+ async function Nn(e, t) {
1744
1873
  switch (t.as) {
1745
1874
  case void 0:
1746
- return fe(e);
1875
+ return ce(e);
1747
1876
  case "string":
1748
- return fe(e instanceof Date ? e.toISOString() : String(e));
1877
+ return ce(e instanceof Date ? e.toISOString() : String(e));
1749
1878
  case "number": {
1750
1879
  const r = e instanceof Date ? e.getTime() : Number(e);
1751
- return Number.isFinite(r) ? fe(r) : Oe;
1880
+ return Number.isFinite(r) ? ce(r) : Te;
1752
1881
  }
1753
1882
  case "boolean": {
1754
1883
  const r = String(e).trim().toLowerCase();
1755
- return An.has(r) ? fe(!0) : Cn.has(r) ? fe(!1) : Oe;
1884
+ return On.has(r) ? ce(!0) : xn.has(r) ? ce(!1) : Te;
1756
1885
  }
1757
1886
  case "date": {
1758
1887
  const { default: r } = await import("dayjs"), { default: o } = await import("./customParseFormat-D14EWdSX.js").then((l) => l.c);
1759
1888
  r.extend(o);
1760
1889
  const u = e instanceof Date ? e.toISOString() : String(e), i = t.format ? r(u, t.format, !0) : r(u);
1761
- return i.isValid() ? fe(i.format("YYYY-MM-DD")) : Oe;
1890
+ return i.isValid() ? ce(i.format("YYYY-MM-DD")) : Te;
1762
1891
  }
1763
1892
  }
1764
1893
  }
1765
- async function On(e, t) {
1894
+ async function In(e, t) {
1766
1895
  if (t.formula !== void 0) {
1767
1896
  const r = {};
1768
1897
  for (const [o, u] of Object.entries(t.inputs ?? {})) {
1769
- const i = ir(je.data(e, u));
1770
- if (!i.found || Array.isArray(i.value)) return Oe;
1898
+ const i = fr(Ke.data(e, u));
1899
+ if (!i.found || Array.isArray(i.value)) return Te;
1771
1900
  r[o] = i.value;
1772
1901
  }
1773
1902
  try {
1774
- return fe(await wr(r, t.formula));
1903
+ return ce(await Nr(r, t.formula));
1775
1904
  } catch (o) {
1776
1905
  throw new Error(`x-xml.writeTo "${t.to}": ${qe(o)}`);
1777
1906
  }
1778
1907
  }
1779
1908
  if (t.from === void 0) throw new Error(`x-xml.writeTo "${t.to}" needs either "from" or "formula".`);
1780
- return ir(je.data(e, t.from));
1909
+ return fr(Ke.data(e, t.from));
1781
1910
  }
1782
- async function Nn(e, t) {
1911
+ async function kn(e, t) {
1783
1912
  const r = [];
1784
1913
  for (const o of t) {
1785
- let u = await On(e, o);
1914
+ let u = await In(e, o);
1786
1915
  const i = u.found && Array.isArray(u.value);
1787
1916
  if (u.found && !i && o.map) {
1788
1917
  const l = u.value instanceof Date ? u.value.toISOString() : String(u.value);
1789
- Object.prototype.hasOwnProperty.call(o.map, l) && (u = fe(o.map[l]));
1918
+ Object.prototype.hasOwnProperty.call(o.map, l) && (u = ce(o.map[l]));
1790
1919
  }
1791
- if (u.found && !i && (u = await Sn(u.value, o)), !u.found) {
1920
+ if (u.found && !i && (u = await Nn(u.value, o)), !u.found) {
1792
1921
  if (o.default === void 0) continue;
1793
1922
  r.push({ to: o.to, value: o.default });
1794
1923
  continue;
@@ -1797,7 +1926,7 @@ async function Nn(e, t) {
1797
1926
  }
1798
1927
  return r;
1799
1928
  }
1800
- const xn = ".xml,text/xml,application/xml", In = 5 * 1024 * 1024, kn = ({
1929
+ const Dn = ".xml,text/xml,application/xml", Mn = 5 * 1024 * 1024, zn = ({
1801
1930
  data: e,
1802
1931
  handleChange: t,
1803
1932
  path: r,
@@ -1805,222 +1934,222 @@ const xn = ".xml,text/xml,application/xml", In = 5 * 1024 * 1024, kn = ({
1805
1934
  required: u,
1806
1935
  schema: i,
1807
1936
  enabled: l,
1808
- readonly: a,
1937
+ readonly: c,
1809
1938
  errors: s,
1810
- visible: c = !0
1939
+ visible: d = !0
1811
1940
  }) => {
1812
- be(c, r, t);
1813
- const d = !s || s.length === 0, y = yr(l, a), p = (i == null ? void 0 : i["x-xml"]) ?? {}, m = p.accept ?? xn, v = p.maxSize ?? In, I = p.arrayPaths, A = p.removeNamespaces === !0, b = p.writeTo, k = p.writeBase ?? "root", F = p.persistDocument !== !1, z = fr(), w = e ?? null, [_, V] = $(() => w ? "ready" : "empty"), [O, C] = $(null), [H, B] = $(!1), W = pe(null), j = pe(0), ee = w != null, re = b !== void 0 && b.length > 0, le = ke(
1814
- async (f) => {
1815
- var J;
1816
- const T = ++j.current;
1817
- if (C(null), f.size > v) {
1818
- C(`File exceeds the ${ye(v)} limit.`);
1941
+ ge(d, r, t);
1942
+ const a = !s || s.length === 0, g = Sr(l, c), f = (i == null ? void 0 : i["x-xml"]) ?? {}, y = f.accept ?? Dn, w = f.maxSize ?? Mn, L = f.arrayPaths, O = f.removeNamespaces === !0, R = f.writeTo, T = f.writeBase ?? "root", S = f.persistDocument !== !1, N = br(), D = e ?? null, [$, W] = H(() => D ? "ready" : "empty"), [z, E] = H(null), [b, K] = H(!1), G = le(null), j = le(0), Y = D != null, C = R !== void 0 && R.length > 0, Z = Ne(
1943
+ async (h) => {
1944
+ var re;
1945
+ const x = ++j.current;
1946
+ if (E(null), h.size > w) {
1947
+ E(`File exceeds the ${pe(w)} limit.`);
1819
1948
  return;
1820
1949
  }
1821
- if (!m.split(",").map((D) => D.trim()).some((D) => D === "*" || D === "*/*" ? !0 : D.endsWith("/*") ? f.type.startsWith(D.slice(0, -1)) : D.startsWith(".") ? f.name.toLowerCase().endsWith(D.toLowerCase()) : f.type === D)) {
1822
- C(`Invalid type. Accepted: ${ve(m)}`);
1950
+ if (!y.split(",").map((_) => _.trim()).some((_) => _ === "*" || _ === "*/*" ? !0 : _.endsWith("/*") ? h.type.startsWith(_.slice(0, -1)) : _.startsWith(".") ? h.name.toLowerCase().endsWith(_.toLowerCase()) : h.type === _)) {
1951
+ E(`Invalid type. Accepted: ${me(y)}`);
1823
1952
  return;
1824
1953
  }
1825
- V("parsing");
1826
- let U;
1954
+ W("parsing");
1955
+ let P;
1827
1956
  try {
1828
- const D = await f.text();
1829
- U = await Tn(D, { arrayPaths: I, removeNamespaces: A });
1830
- } catch (D) {
1831
- if (T !== j.current) return;
1832
- V("error"), C(
1833
- D instanceof Te ? D.message : "This doesn't look like a valid XML document. Please check the file and try again."
1957
+ const _ = await h.text();
1958
+ P = await Sn(_, { arrayPaths: L, removeNamespaces: O });
1959
+ } catch (_) {
1960
+ if (x !== j.current) return;
1961
+ W("error"), E(
1962
+ _ instanceof Ee ? _.message : "This doesn't look like a valid XML document. Please check the file and try again."
1834
1963
  );
1835
1964
  return;
1836
1965
  }
1837
- let Z = [];
1838
- if (b && b.length > 0)
1966
+ let Q = [];
1967
+ if (R && R.length > 0)
1839
1968
  try {
1840
- Z = await Nn(U, b);
1841
- } catch (D) {
1842
- if (T !== j.current) return;
1843
- V("error"), C(D instanceof Error ? D.message : "This document could not be mapped onto the form.");
1969
+ Q = await kn(P, R);
1970
+ } catch (_) {
1971
+ if (x !== j.current) return;
1972
+ W("error"), E(_ instanceof Error ? _.message : "This document could not be mapped onto the form.");
1844
1973
  return;
1845
1974
  }
1846
- if (T !== j.current) return;
1847
- F && t(r, U);
1848
- const ie = k === "parent" ? r.split(".").slice(0, -1).join(".") : "";
1849
- for (const D of Z) (J = z.dispatch) == null || J.call(z, zr(ie ? `${ie}.${D.to}` : D.to, () => D.value));
1850
- V("ready");
1975
+ if (x !== j.current) return;
1976
+ S && t(r, P);
1977
+ const ee = T === "parent" ? r.split(".").slice(0, -1).join(".") : "";
1978
+ for (const _ of Q) (re = N.dispatch) == null || re.call(N, Hr(ee ? `${ee}.${_.to}` : _.to, () => _.value));
1979
+ W("ready");
1851
1980
  },
1852
- [m, v, I, A, b, k, F, r, t, z]
1981
+ [y, w, L, O, R, T, S, r, t, N]
1853
1982
  );
1854
- if (c === !1 || !y && !ee) return null;
1855
- const oe = (f) => {
1856
- f.preventDefault(), f.stopPropagation(), y && B(f.type === "dragenter" || f.type === "dragover");
1857
- }, se = (f) => {
1858
- var T;
1859
- f.preventDefault(), f.stopPropagation(), B(!1), y && (T = f.dataTransfer.files) != null && T[0] && le(f.dataTransfer.files[0]);
1860
- }, de = (f) => {
1861
- var T;
1862
- (T = f.target.files) != null && T[0] && (le(f.target.files[0]), f.target.value = "");
1983
+ if (d === !1 || !g && !Y) return null;
1984
+ const J = (h) => {
1985
+ h.preventDefault(), h.stopPropagation(), g && K(h.type === "dragenter" || h.type === "dragover");
1986
+ }, he = (h) => {
1987
+ var x;
1988
+ h.preventDefault(), h.stopPropagation(), K(!1), g && (x = h.dataTransfer.files) != null && x[0] && Z(h.dataTransfer.files[0]);
1989
+ }, ie = (h) => {
1990
+ var x;
1991
+ (x = h.target.files) != null && x[0] && (Z(h.target.files[0]), h.target.value = "");
1863
1992
  };
1864
- return /* @__PURE__ */ g(x, { mb: "4", children: [
1865
- /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
1866
- /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
1867
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1993
+ return /* @__PURE__ */ m(I, { mb: "4", children: [
1994
+ /* @__PURE__ */ m(k, { align: "center", justify: "between", mb: "2", children: [
1995
+ /* @__PURE__ */ m(k, { align: "center", gap: "1", children: [
1996
+ /* @__PURE__ */ m(p, { as: "label", size: "2", weight: "bold", children: [
1868
1997
  o,
1869
- u && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1998
+ u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
1870
1999
  ] }),
1871
- !re && ee && y && /* @__PURE__ */ g(he, { children: [
1872
- /* @__PURE__ */ n(He, { content: "Replace document", children: /* @__PURE__ */ n(
1873
- Me,
2000
+ !C && Y && g && /* @__PURE__ */ m(ae, { children: [
2001
+ /* @__PURE__ */ n($e, { content: "Replace document", children: /* @__PURE__ */ n(
2002
+ ke,
1874
2003
  {
1875
2004
  variant: "ghost",
1876
2005
  size: "1",
1877
2006
  onClick: () => {
1878
- var f;
1879
- return (f = W.current) == null ? void 0 : f.click();
2007
+ var h;
2008
+ return (h = G.current) == null ? void 0 : h.click();
1880
2009
  },
1881
2010
  "aria-label": "Replace document",
1882
- children: /* @__PURE__ */ n(Ne, {})
2011
+ children: /* @__PURE__ */ n(Oe, {})
1883
2012
  }
1884
2013
  ) }),
1885
- /* @__PURE__ */ n(He, { content: "Remove document", children: /* @__PURE__ */ n(Me, { variant: "ghost", size: "1", color: "gray", onClick: () => {
1886
- y && (++j.current, C(null), V("empty"), t(r, void 0));
1887
- }, "aria-label": "Remove document", children: /* @__PURE__ */ n(Ye, {}) }) })
2014
+ /* @__PURE__ */ n($e, { content: "Remove document", children: /* @__PURE__ */ n(ke, { variant: "ghost", size: "1", color: "gray", onClick: () => {
2015
+ g && (++j.current, E(null), W("empty"), t(r, void 0));
2016
+ }, "aria-label": "Remove document", children: /* @__PURE__ */ n(Je, {}) }) })
1888
2017
  ] })
1889
2018
  ] }),
1890
- /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
1891
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1892
- ye(v),
2019
+ /* @__PURE__ */ m(k, { align: "center", gap: "2", children: [
2020
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
2021
+ pe(w),
1893
2022
  " max · ",
1894
- ve(m)
2023
+ me(y)
1895
2024
  ] }),
1896
- re && y && /* @__PURE__ */ g(De, { size: "1", variant: "soft", onClick: () => {
1897
- var f;
1898
- return (f = W.current) == null ? void 0 : f.click();
1899
- }, disabled: _ === "parsing", children: [
1900
- _ === "parsing" ? /* @__PURE__ */ n(xe, { size: "1" }) : /* @__PURE__ */ n(Ne, {}),
2025
+ C && g && /* @__PURE__ */ m(Ie, { size: "1", variant: "soft", onClick: () => {
2026
+ var h;
2027
+ return (h = G.current) == null ? void 0 : h.click();
2028
+ }, disabled: $ === "parsing", children: [
2029
+ $ === "parsing" ? /* @__PURE__ */ n(xe, { size: "1" }) : /* @__PURE__ */ n(Oe, {}),
1901
2030
  "Upload"
1902
2031
  ] })
1903
2032
  ] })
1904
2033
  ] }),
1905
- (re || ee) && O && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: O }),
1906
- /* @__PURE__ */ n("input", { ref: W, type: "file", style: { display: "none" }, accept: m, onChange: de }),
1907
- !re && y && !ee && /* @__PURE__ */ n(
2034
+ (C || Y) && z && /* @__PURE__ */ n(p, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: z }),
2035
+ /* @__PURE__ */ n("input", { ref: G, type: "file", style: { display: "none" }, accept: y, onChange: ie }),
2036
+ !C && g && !Y && /* @__PURE__ */ n(
1908
2037
  "div",
1909
2038
  {
1910
2039
  role: "button",
1911
2040
  tabIndex: 0,
1912
2041
  onClick: () => {
1913
- var f;
1914
- return (f = W.current) == null ? void 0 : f.click();
2042
+ var h;
2043
+ return (h = G.current) == null ? void 0 : h.click();
1915
2044
  },
1916
- onKeyDown: (f) => {
1917
- var T;
1918
- (f.key === "Enter" || f.key === " ") && (f.preventDefault(), (T = W.current) == null || T.click());
2045
+ onKeyDown: (h) => {
2046
+ var x;
2047
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = G.current) == null || x.click());
1919
2048
  },
1920
- onDragEnter: oe,
1921
- onDragLeave: oe,
1922
- onDragOver: oe,
1923
- onDrop: se,
2049
+ onDragEnter: J,
2050
+ onDragLeave: J,
2051
+ onDragOver: J,
2052
+ onDrop: he,
1924
2053
  style: { cursor: "pointer" },
1925
2054
  className: [
1926
2055
  "border-2 border-dashed rounded-lg p-6 text-center",
1927
2056
  "transition-all duration-200 ease-in-out",
1928
- H ? "border-blue-500 bg-blue-50" : O ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
2057
+ b ? "border-blue-500 bg-blue-50" : z ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1929
2058
  ].join(" "),
1930
- children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: _ === "parsing" ? /* @__PURE__ */ g(he, { children: [
2059
+ children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: $ === "parsing" ? /* @__PURE__ */ m(ae, { children: [
1931
2060
  /* @__PURE__ */ n(xe, { size: "3" }),
1932
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing document…" })
1933
- ] }) : O ? /* @__PURE__ */ g(he, { children: [
1934
- /* @__PURE__ */ n(Je, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1935
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: O }),
1936
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1937
- ] }) : /* @__PURE__ */ g(he, { children: [
1938
- /* @__PURE__ */ n(Ne, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1939
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1940
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1941
- ye(v),
2061
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Parsing document…" })
2062
+ ] }) : z ? /* @__PURE__ */ m(ae, { children: [
2063
+ /* @__PURE__ */ n(Ze, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
2064
+ /* @__PURE__ */ n(p, { size: "2", color: "red", weight: "medium", children: z }),
2065
+ /* @__PURE__ */ n(p, { size: "1", color: "gray", children: "Click to try again" })
2066
+ ] }) : /* @__PURE__ */ m(ae, { children: [
2067
+ /* @__PURE__ */ n(Oe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
2068
+ /* @__PURE__ */ n(p, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
2069
+ /* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
2070
+ pe(w),
1942
2071
  " max · ",
1943
- ve(m)
2072
+ me(y)
1944
2073
  ] })
1945
2074
  ] }) })
1946
2075
  }
1947
2076
  ),
1948
- !d && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(s, o) })
2077
+ !a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
1949
2078
  ] });
1950
- }, Dn = me(kn), Mn = q(
2079
+ }, Ln = fe(zn), Fn = te(
1951
2080
  10,
1952
- ze((e) => {
2081
+ De((e) => {
1953
2082
  const t = e["x-xml"];
1954
2083
  return e.type === "object" && typeof t == "object" && t !== null;
1955
2084
  })
1956
2085
  );
1957
- function zn(e, t, r) {
2086
+ function Un(e, t, r) {
1958
2087
  const o = {};
1959
2088
  for (const [u, i] of Object.entries(r)) {
1960
- const { path: l, default: a } = typeof i == "string" ? { path: i, default: void 0 } : i, s = t ? `${t}.${l}` : l, c = je.data(e, s);
1961
- if (c == null) {
1962
- if (a === void 0) return;
1963
- o[u] = a;
1964
- } else
2089
+ const { path: l, default: c } = typeof i == "string" ? { path: i, default: void 0 } : i, s = t ? `${t}.${l}` : l, d = Ke.data(e, s);
2090
+ if (d == null) {
2091
+ if (c === void 0) return;
1965
2092
  o[u] = c;
2093
+ } else
2094
+ o[u] = d;
1966
2095
  }
1967
2096
  return o;
1968
2097
  }
1969
- async function Ln(e, t) {
2098
+ async function Pn(e, t) {
1970
2099
  try {
1971
- return { status: "ok", value: await wr(e, t) };
2100
+ return { status: "ok", value: await Nr(e, t) };
1972
2101
  } catch (r) {
1973
2102
  return { status: "error", error: qe(r) };
1974
2103
  }
1975
2104
  }
1976
- function Fn(e, t) {
1977
- return e == null ? "" : typeof e == "number" ? e.toFixed(Un(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
2105
+ function $n(e, t) {
2106
+ return e == null ? "" : typeof e == "number" ? e.toFixed(_n(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
1978
2107
  }
1979
- function Un(e) {
2108
+ function _n(e) {
1980
2109
  return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
1981
2110
  }
1982
- const lr = "{value}", Pn = 2, $n = {}, _n = ({ data: e, handleChange: t, path: r, label: o, schema: u, visible: i = !0 }) => {
1983
- var _;
1984
- be(i, r, t, null);
1985
- const l = u == null ? void 0 : u["x-computed"], a = (l == null ? void 0 : l.inputs) ?? $n, s = (l == null ? void 0 : l.formula) ?? "", c = (l == null ? void 0 : l.format) ?? lr, d = (l == null ? void 0 : l.decimals) ?? Pn, y = fr(), p = r.split(".").slice(0, -1).join("."), m = zn((_ = y.core) == null ? void 0 : _.data, p, a), v = m ? JSON.stringify(m) : null, I = y.readonly === !0, [A, b] = $(() => typeof e == "number" ? "ok" : "unavailable"), [k, F] = $(() => typeof e == "number" ? e : null), [z, w] = $(null);
1986
- return ge(() => {
2111
+ const hr = "{value}", Vn = 2, Hn = {}, Wn = ({ data: e, handleChange: t, path: r, label: o, schema: u, visible: i = !0 }) => {
2112
+ var $;
2113
+ ge(i, r, t);
2114
+ const l = u == null ? void 0 : u["x-computed"], c = (l == null ? void 0 : l.inputs) ?? Hn, s = (l == null ? void 0 : l.formula) ?? "", d = (l == null ? void 0 : l.format) ?? hr, a = (l == null ? void 0 : l.decimals) ?? Vn, g = br(), f = r.split(".").slice(0, -1).join("."), y = Un(($ = g.core) == null ? void 0 : $.data, f, c), w = y ? JSON.stringify(y) : null, L = g.readonly === !0, [O, R] = H(() => typeof e == "number" ? "ok" : "unavailable"), [T, S] = H(() => typeof e == "number" ? e : null), [N, D] = H(null);
2115
+ return ue(() => {
1987
2116
  if (!i) return;
1988
- let V = !1;
1989
- const O = (C) => {
1990
- I || C !== (e ?? null) && t(r, C);
2117
+ let W = !1;
2118
+ const z = (E) => {
2119
+ L || E !== e && t(r, E);
1991
2120
  };
1992
- if (m === void 0) {
1993
- b("unavailable"), w(null), F(null), O(null);
2121
+ if (y === void 0) {
2122
+ R("unavailable"), D(null), S(null), z(void 0);
1994
2123
  return;
1995
2124
  }
1996
- return b((C) => C === "ok" ? C : "loading"), Ln(m, s).then((C) => {
1997
- if (V) return;
1998
- const H = C.status === "ok" && typeof C.value == "number" && Number.isFinite(C.value) ? C.value : null;
1999
- if (H === null) {
2000
- b("error"), w(
2001
- C.status === "error" ? C.error ?? "Unable to compute value." : "Computed value must be a number."
2002
- ), F(null), O(null);
2125
+ return R((E) => E === "ok" ? E : "loading"), Pn(y, s).then((E) => {
2126
+ if (W) return;
2127
+ const b = E.status === "ok" && typeof E.value == "number" && Number.isFinite(E.value) ? E.value : null;
2128
+ if (b === null) {
2129
+ R("error"), D(
2130
+ E.status === "error" ? E.error ?? "Unable to compute value." : "Computed value must be a number."
2131
+ ), S(null), z(void 0);
2003
2132
  return;
2004
2133
  }
2005
- b("ok"), w(null), F(H), O(H);
2134
+ R("ok"), D(null), S(b), z(b);
2006
2135
  }), () => {
2007
- V = !0;
2136
+ W = !0;
2008
2137
  };
2009
- }, [v, s, i, I]), i === !1 ? null : /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
2010
- /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: o }),
2011
- A === "unavailable" ? /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Not yet available." }) : A === "loading" ? /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
2138
+ }, [w, s, i, L]), i === !1 ? null : /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ m(k, { direction: "column", gap: "1", children: [
2139
+ /* @__PURE__ */ n(p, { as: "label", size: "2", weight: "bold", children: o }),
2140
+ O === "unavailable" ? /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Not yet available." }) : O === "loading" ? /* @__PURE__ */ m(k, { align: "center", gap: "2", children: [
2012
2141
  /* @__PURE__ */ n(xe, { size: "1" }),
2013
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Computing…" })
2014
- ] }) : A === "error" ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: z }) : /* @__PURE__ */ n(h, { size: "2", children: c.split(lr).join(Fn(k, d)) }),
2015
- u.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: u.description })
2142
+ /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "Computing…" })
2143
+ ] }) : O === "error" ? /* @__PURE__ */ n(p, { size: "2", color: "red", children: N }) : /* @__PURE__ */ n(p, { size: "2", children: d.split(hr).join($n(T, a)) }),
2144
+ u.description && /* @__PURE__ */ n(p, { size: "1", color: "gray", children: u.description })
2016
2145
  ] }) });
2017
- }, Vn = me(_n), Hn = q(
2146
+ }, jn = fe(Wn), Bn = te(
2018
2147
  5,
2019
- ze((e) => {
2148
+ De((e) => {
2020
2149
  const t = e["x-computed"];
2021
2150
  return e.type === "number" && typeof t == "object" && t !== null;
2022
2151
  })
2023
- ), Wn = ({
2152
+ ), Xn = ({
2024
2153
  data: e,
2025
2154
  path: t,
2026
2155
  schema: r,
@@ -2028,139 +2157,139 @@ const lr = "{value}", Pn = 2, $n = {}, _n = ({ data: e, handleChange: t, path: r
2028
2157
  enabled: u,
2029
2158
  visible: i,
2030
2159
  addItem: l,
2031
- removeItems: a,
2160
+ removeItems: c,
2032
2161
  rootSchema: s,
2033
- arraySchema: c
2162
+ arraySchema: d
2034
2163
  }) => {
2035
- const d = c ? r : r.items, y = c || r;
2036
- if (i === !1 || !d || typeof d != "object" || Array.isArray(d))
2164
+ const a = d ? r : r.items, g = d || r;
2165
+ if (i === !1 || !a || typeof a != "object" || Array.isArray(a))
2037
2166
  return null;
2038
- const p = d, m = Array.isArray(e) ? e : [], v = y.title || "Array Items", I = o.options ?? {}, A = u && I.addable !== !1, b = u && I.removable !== !1, k = () => {
2039
- const z = Lr(p, s);
2040
- l && l(t, z)();
2041
- }, F = (z) => {
2042
- if (a) {
2043
- const w = a(t, [z]);
2044
- w && w();
2167
+ const f = a, y = Array.isArray(e) ? e : [], w = g.title || "Array Items", L = o.options ?? {}, O = u && L.addable !== !1, R = u && L.removable !== !1, T = () => {
2168
+ const N = Wr(f, s);
2169
+ l && l(t, N)();
2170
+ }, S = (N) => {
2171
+ if (c) {
2172
+ const D = c(t, [N]);
2173
+ D && D();
2045
2174
  }
2046
2175
  };
2047
- return /* @__PURE__ */ n(x, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
2048
- /* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
2049
- m.length === 0 && /* @__PURE__ */ n(x, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2050
- m.map((z, w) => {
2051
- var V;
2052
- const _ = `${t}.${w}`;
2053
- return /* @__PURE__ */ n(pr, { size: "3", variant: "surface", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
2054
- /* @__PURE__ */ g(S, { justify: "between", align: "center", children: [
2055
- /* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
2176
+ return /* @__PURE__ */ n(I, { mb: "6", children: /* @__PURE__ */ m(k, { direction: "column", gap: "4", children: [
2177
+ /* @__PURE__ */ n(p, { as: "div", size: "4", weight: "bold", children: w }),
2178
+ y.length === 0 && /* @__PURE__ */ n(I, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(p, { size: "2", color: "gray", children: "No items have been added yet." }) }),
2179
+ y.map((N, D) => {
2180
+ var W;
2181
+ const $ = `${t}.${D}`;
2182
+ return /* @__PURE__ */ n(Rr, { size: "3", variant: "surface", children: /* @__PURE__ */ m(k, { direction: "column", gap: "4", children: [
2183
+ /* @__PURE__ */ m(k, { justify: "between", align: "center", children: [
2184
+ /* @__PURE__ */ m(p, { size: "3", weight: "bold", children: [
2056
2185
  "Item ",
2057
- w + 1
2186
+ D + 1
2058
2187
  ] }),
2059
- b && /* @__PURE__ */ g(
2060
- De,
2188
+ R && /* @__PURE__ */ m(
2189
+ Ie,
2061
2190
  {
2062
2191
  type: "button",
2063
2192
  color: "red",
2064
2193
  variant: "soft",
2065
- onClick: () => F(w),
2194
+ onClick: () => S(D),
2066
2195
  title: "Remove item",
2067
2196
  children: [
2068
- /* @__PURE__ */ n(Xr, {}),
2197
+ /* @__PURE__ */ n(Jr, {}),
2069
2198
  "Remove"
2070
2199
  ]
2071
2200
  }
2072
2201
  )
2073
2202
  ] }),
2074
- /* @__PURE__ */ n(x, { children: /* @__PURE__ */ n(
2075
- Fe,
2203
+ /* @__PURE__ */ n(I, { children: /* @__PURE__ */ n(
2204
+ ze,
2076
2205
  {
2077
- schema: p,
2078
- uischema: ((V = o.options) == null ? void 0 : V.detail) || (p.type === "object" || p.properties ? {
2206
+ schema: f,
2207
+ uischema: ((W = o.options) == null ? void 0 : W.detail) || (f.type === "object" || f.properties ? {
2079
2208
  type: "VerticalLayout",
2080
- elements: Object.keys(p.properties || {}).map((O) => ({
2209
+ elements: Object.keys(f.properties || {}).map((z) => ({
2081
2210
  type: "Control",
2082
- scope: `#/properties/${O}`
2211
+ scope: `#/properties/${z}`
2083
2212
  }))
2084
2213
  } : {
2085
2214
  type: "Control",
2086
2215
  scope: "#"
2087
2216
  }),
2088
- path: _,
2217
+ path: $,
2089
2218
  enabled: u,
2090
2219
  renderers: void 0,
2091
2220
  cells: void 0
2092
2221
  }
2093
2222
  ) })
2094
- ] }) }, _);
2223
+ ] }) }, $);
2095
2224
  }),
2096
- A && /* @__PURE__ */ n(x, { mt: "2", children: /* @__PURE__ */ g(De, { type: "button", variant: "surface", onClick: k, children: [
2097
- /* @__PURE__ */ n(Br, {}),
2225
+ O && /* @__PURE__ */ n(I, { mt: "2", children: /* @__PURE__ */ m(Ie, { type: "button", variant: "surface", onClick: T, children: [
2226
+ /* @__PURE__ */ n(Zr, {}),
2098
2227
  "Add Item"
2099
2228
  ] }) })
2100
2229
  ] }) });
2101
- }, sr = Pr(Wn), Xn = q(3, Fr), Bn = ({ uischema: e, visible: t }) => {
2230
+ }, pr = Xr(Xn), Kn = te(3, jr), Gn = ({ uischema: e, visible: t }) => {
2102
2231
  const r = e;
2103
- return t === !1 ? null : /* @__PURE__ */ n(x, { mb: "4", children: /* @__PURE__ */ n(hr, { size: "4", children: r.text }) });
2104
- }, jn = q(1, Le("Label")), Kn = q(3, Ur), io = [
2105
- { tester: Zr, renderer: Qr },
2106
- { tester: rt, renderer: tt },
2107
- { tester: ot, renderer: it },
2108
- { tester: st, renderer: ct },
2109
- { tester: mt, renderer: pt },
2110
- { tester: ut, renderer: dt },
2111
- { tester: bt, renderer: wt },
2112
- { tester: Rt, renderer: Et },
2113
- { tester: At, renderer: Tt },
2114
- { tester: St, renderer: Ct },
2115
- { tester: Nt, renderer: Ot },
2232
+ return t === !1 ? null : /* @__PURE__ */ n(I, { mb: "4", children: /* @__PURE__ */ n(Er, { size: "4", children: r.text }) });
2233
+ }, Yn = te(1, Me("Label")), Jn = te(3, Br), so = [
2234
+ { tester: tt, renderer: nt },
2235
+ { tester: it, renderer: lt },
2236
+ { tester: ct, renderer: at },
2237
+ { tester: dt, renderer: ft },
2238
+ { tester: bt, renderer: vt },
2239
+ { tester: pt, renderer: mt },
2240
+ { tester: At, renderer: Ct },
2241
+ { tester: St, renderer: Tt },
2242
+ { tester: xt, renderer: Ot },
2243
+ { tester: It, renderer: Nt },
2116
2244
  { tester: Dt, renderer: kt },
2117
- { tester: yn, renderer: gn },
2245
+ { tester: Ft, renderer: Lt },
2246
+ { tester: wn, renderer: bn },
2118
2247
  // After SpreadsheetControl on purpose: both testers rank 10, and a tie is
2119
2248
  // resolved by registration order (see XmlControlTester's comment).
2120
- { tester: Mn, renderer: Dn },
2121
- { tester: Hn, renderer: Vn },
2122
- { tester: Xn, renderer: sr },
2123
- { tester: Kn, renderer: sr },
2124
- { tester: jn, renderer: Bn }
2249
+ { tester: Fn, renderer: Ln },
2250
+ { tester: Bn, renderer: jn },
2251
+ { tester: Kn, renderer: pr },
2252
+ { tester: Jn, renderer: pr },
2253
+ { tester: Yn, renderer: Gn }
2125
2254
  ];
2126
2255
  export {
2127
- sr as ArrayControl,
2128
- Xn as ArrayControlTester,
2129
- nt as BooleanControl,
2130
- ot as BooleanControlTester,
2131
- Ot as CategorizationLayoutRenderer,
2132
- Nt as CategorizationLayoutTester,
2133
- Vn as ComputedControl,
2134
- Hn as ComputedControlTester,
2135
- vt as DateControl,
2136
- bt as DateControlTester,
2137
- kt as FileControl,
2138
- Dt as FileControlTester,
2139
- Ct as GroupLayoutRenderer,
2140
- St as GroupLayoutTester,
2141
- Tt as HorizontalLayoutRenderer,
2142
- At as HorizontalLayoutTester,
2143
- Bn as LabelRenderer,
2144
- jn as LabelTester,
2145
- et as NumberControl,
2146
- rt as NumberControlTester,
2147
- lt as RadioControl,
2148
- st as RadioControlTester,
2149
- pt as SearchSelectControl,
2150
- mt as SearchSelectControlTester,
2151
- oo as SearchServiceProvider,
2152
- at as SelectControl,
2153
- ut as SelectControlTester,
2154
- gn as SpreadsheetControl,
2155
- yn as SpreadsheetControlTester,
2156
- qr as TextControl,
2157
- Zr as TextControlTester,
2158
- no as UploadProvider,
2159
- Et as VerticalLayoutRenderer,
2160
- Rt as VerticalLayoutTester,
2161
- Dn as XmlControl,
2162
- Mn as XmlControlTester,
2163
- io as radixRenderers,
2164
- Jr as useSearchService,
2165
- Yr as useUpload
2256
+ pr as ArrayControl,
2257
+ Kn as ArrayControlTester,
2258
+ st as BooleanControl,
2259
+ ct as BooleanControlTester,
2260
+ kt as CategorizationLayoutRenderer,
2261
+ Dt as CategorizationLayoutTester,
2262
+ jn as ComputedControl,
2263
+ Bn as ComputedControlTester,
2264
+ Rt as DateControl,
2265
+ At as DateControlTester,
2266
+ Lt as FileControl,
2267
+ Ft as FileControlTester,
2268
+ Nt as GroupLayoutRenderer,
2269
+ It as GroupLayoutTester,
2270
+ Ot as HorizontalLayoutRenderer,
2271
+ xt as HorizontalLayoutTester,
2272
+ Gn as LabelRenderer,
2273
+ Yn as LabelTester,
2274
+ ot as NumberControl,
2275
+ it as NumberControlTester,
2276
+ ut as RadioControl,
2277
+ dt as RadioControlTester,
2278
+ vt as SearchSelectControl,
2279
+ bt as SearchSelectControlTester,
2280
+ lo as SearchServiceProvider,
2281
+ ht as SelectControl,
2282
+ pt as SelectControlTester,
2283
+ bn as SpreadsheetControl,
2284
+ wn as SpreadsheetControlTester,
2285
+ rt as TextControl,
2286
+ tt as TextControlTester,
2287
+ io as UploadProvider,
2288
+ Tt as VerticalLayoutRenderer,
2289
+ St as VerticalLayoutTester,
2290
+ Ln as XmlControl,
2291
+ Fn as XmlControlTester,
2292
+ so as radixRenderers,
2293
+ et as useSearchService,
2294
+ Qr as useUpload
2166
2295
  };