@opennsw/jsonforms-renderers 0.5.0 → 0.7.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,65 +1,65 @@
1
- var nr = Object.defineProperty;
2
- var or = (e, t, r) => t in e ? nr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var Ue = (e, t, r) => or(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { jsx as n, jsxs as g, Fragment as Ee } from "react/jsx-runtime";
5
- import { useContext as He, createContext as We, useMemo as lr, useEffect as pe, useState as k, useRef as ue, useCallback as De } from "react";
6
- import { rankWith as W, isStringControl as ir, or as Ne, isNumberControl as sr, isIntegerControl as cr, isBooleanControl as ar, isEnumControl as Be, isOneOfControl as Ke, schemaMatches as Me, isDateControl as dr, isDateTimeControl as ur, isTimeControl as fr, uiTypeIs as we, and as hr, createDefaultValue as pr, isObjectArrayControl as gr, isPrimitiveArrayControl as mr } from "@jsonforms/core";
7
- import { withJsonFormsControlProps as le, JsonFormsDispatch as Re, withJsonFormsArrayControlProps as yr } from "@jsonforms/react";
8
- import { Box as R, Flex as T, Text as h, TextField as ye, Checkbox as vr, RadioGroup as ke, Select as Ce, ScrollArea as br, Spinner as xe, Button as Se, Tabs as Te, Heading as Ge, Card as ze, IconButton as Xe, Table as oe } from "@radix-ui/themes";
9
- import { ChevronDownIcon as Er, FileTextIcon as Ye, CheckCircledIcon as Je, Cross2Icon as Ze, ExclamationTriangleIcon as qe, UploadIcon as Qe, TrashIcon as wr, PlusIcon as Rr } from "@radix-ui/react-icons";
10
- import Cr from "dayjs";
11
- import { read as Tr, utils as Ar } from "@e965/xlsx";
12
- const je = We(null);
13
- function qt({
1
+ var mr = Object.defineProperty;
2
+ var gr = (e, t, r) => t in e ? mr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var Pe = (e, t, r) => gr(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { jsx as n, jsxs as g, Fragment as be } from "react/jsx-runtime";
5
+ import { useContext as Ze, createContext as Qe, useMemo as yr, useEffect as fe, useState as F, useRef as de, useCallback as _e } from "react";
6
+ import { rankWith as W, isStringControl as vr, or as Le, isNumberControl as br, isIntegerControl as wr, isBooleanControl as Er, isEnumControl as er, isOneOfControl as rr, schemaMatches as ze, isDateControl as Rr, isDateTimeControl as Cr, isTimeControl as Tr, uiTypeIs as Te, and as Ar, Resolve as Sr, createDefaultValue as Or, isObjectArrayControl as Nr, isPrimitiveArrayControl as Ir } from "@jsonforms/core";
7
+ import { withJsonFormsControlProps as se, JsonFormsDispatch as Ae, useJsonForms as xr, withJsonFormsArrayControlProps as Mr } from "@jsonforms/react";
8
+ import { Box as C, Flex as S, Text as h, TextField as ye, Checkbox as kr, RadioGroup as Ve, Select as Ne, ScrollArea as Lr, Spinner as Me, Button as ke, Tabs as Ie, Heading as tr, Card as nr, IconButton as Ue, Tooltip as We, Table as $ } from "@radix-ui/themes";
9
+ import { ChevronDownIcon as zr, FileTextIcon as Dr, CheckCircledIcon as Fr, Cross2Icon as or, ExclamationTriangleIcon as lr, UploadIcon as He, TrashIcon as Ur, PlusIcon as Hr } from "@radix-ui/react-icons";
10
+ import $r from "dayjs";
11
+ import { read as _r, utils as Pr } from "@e965/xlsx";
12
+ const ir = Qe(null);
13
+ function Nn({
14
14
  children: e,
15
15
  onUpload: t,
16
16
  getDownloadUrl: r
17
17
  }) {
18
- const d = { onUpload: t, getDownloadUrl: r };
19
- return /* @__PURE__ */ n(je.Provider, { value: d, children: e });
18
+ const i = { onUpload: t, getDownloadUrl: r };
19
+ return /* @__PURE__ */ n(ir.Provider, { value: i, children: e });
20
20
  }
21
- function Sr() {
22
- return He(je);
21
+ function Vr() {
22
+ return Ze(ir);
23
23
  }
24
- const er = We(null);
25
- function Qt({
24
+ const sr = Qe(null);
25
+ function In({
26
26
  children: e,
27
27
  services: t
28
28
  }) {
29
- const r = lr(() => t, [t]);
30
- return /* @__PURE__ */ n(er.Provider, { value: r, children: e });
29
+ const r = yr(() => t, [t]);
30
+ return /* @__PURE__ */ n(sr.Provider, { value: r, children: e });
31
31
  }
32
- function Nr(e) {
33
- const t = He(er);
32
+ function Wr(e) {
33
+ const t = Ze(sr);
34
34
  return !t || !e ? null : t[e] ?? null;
35
35
  }
36
- const fe = (e, t, r, d = void 0) => {
37
- pe(() => {
38
- e === !1 && r(t, d);
39
- }, [e, t, r, d]);
40
- }, ie = (e, t) => e ? e.split(`
36
+ const ce = (e, t, r, i = void 0) => {
37
+ fe(() => {
38
+ e === !1 && r(t, i);
39
+ }, [e, t, r, i]);
40
+ }, ae = (e, t) => e ? e.split(`
41
41
  `).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
42
- `) : "", Or = ({
42
+ `) : "", Br = ({
43
43
  data: e,
44
44
  handleChange: t,
45
45
  path: r,
46
- label: d,
47
- required: m,
48
- errors: a,
49
- uischema: c,
50
- schema: s,
46
+ label: i,
47
+ required: f,
48
+ errors: s,
49
+ uischema: l,
50
+ schema: a,
51
51
  enabled: o,
52
- visible: i = !0
52
+ visible: c = !0
53
53
  }) => {
54
54
  var y;
55
- if (fe(i, r, t), i === !1)
55
+ if (ce(c, r, t), c === !1)
56
56
  return null;
57
- const l = a.length === 0;
58
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
57
+ const u = s.length === 0;
58
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
59
59
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
60
- d,
60
+ i,
61
61
  " ",
62
- m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
62
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
63
63
  ] }),
64
64
  /* @__PURE__ */ n(
65
65
  ye.Root,
@@ -67,129 +67,129 @@ const fe = (e, t, r, d = void 0) => {
67
67
  value: e || "",
68
68
  onChange: (p) => t(r, p.target.value),
69
69
  disabled: !o,
70
- placeholder: (y = c.options) == null ? void 0 : y.placeholder,
71
- color: l ? void 0 : "red",
70
+ placeholder: (y = l.options) == null ? void 0 : y.placeholder,
71
+ color: u ? void 0 : "red",
72
72
  id: r
73
73
  }
74
74
  ),
75
- !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(a, d) }),
76
- s.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: s.description })
75
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
76
+ a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
77
77
  ] }) });
78
- }, Ir = W(1, ir), xr = le(Or), Lr = ({
78
+ }, Kr = W(1, vr), Gr = se(Br), Xr = ({
79
79
  data: e,
80
80
  handleChange: t,
81
81
  path: r,
82
- label: d,
83
- required: m,
84
- errors: a,
85
- uischema: c,
86
- schema: s,
82
+ label: i,
83
+ required: f,
84
+ errors: s,
85
+ uischema: l,
86
+ schema: a,
87
87
  enabled: o,
88
- visible: i = !0
88
+ visible: c = !0
89
89
  }) => {
90
90
  var p;
91
- if (fe(i, r, t), i === !1)
91
+ if (ce(c, r, t), c === !1)
92
92
  return null;
93
- const l = a.length === 0, y = (f) => {
94
- if (f === "") {
93
+ const u = s.length === 0, y = (m) => {
94
+ if (m === "") {
95
95
  t(r, void 0);
96
96
  return;
97
97
  }
98
- const v = Number(f);
98
+ const v = Number(m);
99
99
  isNaN(v) || t(r, v);
100
100
  };
101
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
101
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
102
102
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
103
- d,
103
+ i,
104
104
  " ",
105
- m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
105
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
106
106
  ] }),
107
107
  /* @__PURE__ */ n(
108
108
  ye.Root,
109
109
  {
110
110
  type: "number",
111
111
  value: e ?? "",
112
- onChange: (f) => y(f.target.value),
112
+ onChange: (m) => y(m.target.value),
113
113
  disabled: !o,
114
- placeholder: (p = c.options) == null ? void 0 : p.placeholder,
115
- color: l ? void 0 : "red",
114
+ placeholder: (p = l.options) == null ? void 0 : p.placeholder,
115
+ color: u ? void 0 : "red",
116
116
  id: r
117
117
  }
118
118
  ),
119
- !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(a, d) }),
120
- s.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: s.description })
119
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
120
+ a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
121
121
  ] }) });
122
- }, Dr = W(2, Ne(sr, cr)), Mr = le(Lr), zr = ({
122
+ }, jr = W(2, Le(br, wr)), Yr = se(Xr), Jr = ({
123
123
  data: e,
124
124
  handleChange: t,
125
125
  path: r,
126
- label: d,
127
- required: m,
128
- errors: a,
129
- schema: c,
130
- enabled: s,
126
+ label: i,
127
+ required: f,
128
+ errors: s,
129
+ schema: l,
130
+ enabled: a,
131
131
  visible: o = !0
132
132
  }) => {
133
- if (fe(o, r, t), o === !1)
133
+ if (ce(o, r, t), o === !1)
134
134
  return null;
135
- const i = a.length === 0;
136
- return /* @__PURE__ */ g(R, { mb: "4", children: [
137
- /* @__PURE__ */ g(T, { gap: "2", align: "center", children: [
135
+ const c = s.length === 0;
136
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
137
+ /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
138
138
  /* @__PURE__ */ n(
139
- vr,
139
+ kr,
140
140
  {
141
141
  checked: !!e,
142
- onCheckedChange: (l) => t(r, l === !0),
143
- disabled: !s,
142
+ onCheckedChange: (u) => t(r, u === !0),
143
+ disabled: !a,
144
144
  id: r
145
145
  }
146
146
  ),
147
147
  /* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
148
- d,
148
+ i,
149
149
  " ",
150
- m && "*"
150
+ f && "*"
151
151
  ] })
152
152
  ] }),
153
- !i && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: ie(a, d) }),
154
- c.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: c.description })
153
+ !c && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: ae(s, i) }),
154
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: l.description })
155
155
  ] });
156
- }, Ur = W(2, ar), kr = le(zr), Fr = ({
156
+ }, qr = W(2, Er), Zr = se(Jr), Qr = ({
157
157
  data: e,
158
158
  handleChange: t,
159
159
  path: r,
160
- label: d,
161
- required: m,
162
- errors: a,
163
- schema: c,
164
- enabled: s,
160
+ label: i,
161
+ required: f,
162
+ errors: s,
163
+ schema: l,
164
+ enabled: a,
165
165
  visible: o = !0
166
166
  }) => {
167
- if (fe(o, r, t), o === !1)
167
+ if (ce(o, r, t), o === !1)
168
168
  return null;
169
- const i = a.length === 0;
170
- let l = [];
171
- c.enum ? l = c.enum.map((p) => ({ value: p, label: String(p) })) : c.oneOf && (l = c.oneOf.map((p) => ({
169
+ const c = s.length === 0;
170
+ let u = [];
171
+ l.enum ? u = l.enum.map((p) => ({ value: p, label: String(p) })) : l.oneOf && (u = l.oneOf.map((p) => ({
172
172
  value: p.const,
173
173
  label: p.title || String(p.const)
174
174
  })));
175
175
  const y = e;
176
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
176
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
177
177
  /* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
178
- d,
178
+ i,
179
179
  " ",
180
- m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
180
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
181
181
  ] }),
182
182
  /* @__PURE__ */ n(
183
- ke.Root,
183
+ Ve.Root,
184
184
  {
185
185
  value: y !== void 0 ? String(y) : "",
186
186
  onValueChange: (p) => {
187
- const f = l.find((v) => String(v.value) === p);
188
- f && t(r, f.value);
187
+ const m = u.find((v) => String(v.value) === p);
188
+ m && t(r, m.value);
189
189
  },
190
- disabled: !s,
190
+ disabled: !a,
191
191
  children: /* @__PURE__ */ n(
192
- T,
192
+ S,
193
193
  {
194
194
  direction: "row",
195
195
  style: {
@@ -197,203 +197,210 @@ const fe = (e, t, r, d = void 0) => {
197
197
  columnGap: "clamp(14px, 3vw, 36px)",
198
198
  rowGap: "clamp(8px, 1.6vw, 14px)"
199
199
  },
200
- children: l.map((p) => /* @__PURE__ */ g(T, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
- /* @__PURE__ */ n(ke.Item, { value: String(p.value) }),
202
- /* @__PURE__ */ n(h, { size: "2", color: s ? void 0 : "gray", children: p.label })
200
+ children: u.map((p) => /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
201
+ /* @__PURE__ */ n(Ve.Item, { value: String(p.value) }),
202
+ /* @__PURE__ */ n(h, { size: "2", color: a ? void 0 : "gray", children: p.label })
203
203
  ] }, String(p.value)))
204
204
  }
205
205
  )
206
206
  }
207
207
  ),
208
- !i && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(a, d) }),
209
- c.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: c.description })
208
+ !c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
209
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
210
210
  ] }) });
211
- }, $r = (e, t, r) => {
212
- var m;
213
- return Ne(Be, Ke)(e, t, r) && ((m = e == null ? void 0 : e.options) == null ? void 0 : m.format) === "radio" ? 3 : -1;
214
- }, _r = le(Fr), Pr = ({
211
+ }, et = (e, t, r) => {
212
+ var f;
213
+ return Le(er, rr)(e, t, r) && ((f = e == null ? void 0 : e.options) == null ? void 0 : f.format) === "radio" ? 3 : -1;
214
+ }, rt = se(Qr), tt = ({
215
215
  data: e,
216
216
  handleChange: t,
217
217
  path: r,
218
- label: d,
219
- required: m,
220
- errors: a,
221
- schema: c,
222
- uischema: s,
218
+ label: i,
219
+ required: f,
220
+ errors: s,
221
+ schema: l,
222
+ uischema: a,
223
223
  enabled: o,
224
- visible: i = !0
224
+ visible: c = !0
225
225
  }) => {
226
- var f;
227
- if (fe(i, r, t), i === !1)
226
+ var m;
227
+ if (ce(c, r, t), c === !1)
228
228
  return null;
229
- const l = a.length === 0;
229
+ const u = s.length === 0;
230
230
  let y = [];
231
- c.enum ? y = c.enum.map((v) => ({ value: String(v), label: String(v) })) : c.oneOf && (y = c.oneOf.map((v) => ({
231
+ l.enum ? y = l.enum.map((v) => ({ value: String(v), label: String(v) })) : l.oneOf && (y = l.oneOf.map((v) => ({
232
232
  value: String(v.const),
233
233
  label: v.title || String(v.const)
234
234
  })));
235
235
  const p = e !== void 0 ? String(e) : "";
236
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
236
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
237
237
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
238
- d,
238
+ i,
239
239
  " ",
240
- m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
240
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
241
241
  ] }),
242
- /* @__PURE__ */ g(Ce.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
242
+ /* @__PURE__ */ g(Ne.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
243
243
  /* @__PURE__ */ n(
244
- Ce.Trigger,
244
+ Ne.Trigger,
245
245
  {
246
- placeholder: ((f = s.options) == null ? void 0 : f.placeholder) || "Select an option",
247
- color: l ? void 0 : "red",
246
+ placeholder: ((m = a.options) == null ? void 0 : m.placeholder) || "Select an option",
247
+ color: u ? void 0 : "red",
248
248
  id: r
249
249
  }
250
250
  ),
251
- /* @__PURE__ */ n(Ce.Content, { children: y.map((v) => /* @__PURE__ */ n(Ce.Item, { value: v.value, children: v.label }, v.value)) })
251
+ /* @__PURE__ */ n(Ne.Content, { children: y.map((v) => /* @__PURE__ */ n(Ne.Item, { value: v.value, children: v.label }, v.value)) })
252
252
  ] }),
253
- !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(a, d) }),
254
- c.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: c.description })
253
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
254
+ l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
255
255
  ] }) });
256
- }, Vr = W(2, Ne(Be, Ke)), Hr = le(Pr), Wr = {
256
+ }, nt = W(2, Le(er, rr)), ot = se(tt), lt = {
257
257
  "small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
258
258
  "large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
259
259
  "large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
260
- }, Br = ({
260
+ }, it = ({
261
261
  data: e,
262
262
  handleChange: t,
263
263
  path: r,
264
- label: d,
265
- required: m,
266
- errors: a,
267
- enabled: c,
268
- visible: s = !0,
264
+ label: i,
265
+ required: f,
266
+ errors: s,
267
+ enabled: l,
268
+ visible: a = !0,
269
269
  schema: o,
270
- uischema: i
270
+ uischema: c
271
271
  }) => {
272
- var ve;
273
- const l = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = l.service ?? "", p = l.mode ?? "large-paginated-list", f = Wr[p], v = (f == null ? void 0 : f.fetchOnOpen) ?? !1, S = Nr(y), x = y ? S ? f ? 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.", C = c !== !1, I = !a || a.length === 0, [L, O] = k(!1), [F, $] = k(""), [re, _] = k([]), [se, B] = k(!1), [P, X] = k(!1), [te, D] = k(!1), [ce, G] = k(null), [ae, Y] = k(void 0), q = ue(void 0), ne = ue(null), b = ue(null), N = ue(null), z = ue(void 0);
274
- pe(() => {
275
- if (!e) {
276
- Y(void 0), z.current = void 0;
272
+ var Re;
273
+ const u = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = u.service ?? "", p = u.mode ?? "large-paginated-list", m = lt[p], v = (m == null ? void 0 : m.fetchOnOpen) ?? !1, N = u.params, A = Wr(y), w = o.type === "object", R = w ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, L = w ? R == null ? void 0 : R.value : e, P = R == null ? void 0 : R.label, I = 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.", B = l !== !1, j = !s || s.length === 0, [M, O] = F(!1), [D, V] = F(""), [oe, ee] = F([]), [le, Y] = F(!1), [Z, re] = F(!1), [he, ne] = F(!1), [ue, b] = F(null), [k, U] = F(void 0), T = de(void 0), H = de(null), J = de(null), Q = de(null), K = de(void 0);
274
+ fe(() => {
275
+ var E, q;
276
+ if (!L) {
277
+ U(void 0), K.current = void 0;
278
+ return;
279
+ }
280
+ if (((E = K.current) == null ? void 0 : E.value) === L && ((q = K.current) == null ? void 0 : q.label) === P) return;
281
+ if (K.current = { value: L, label: P }, w && P) {
282
+ U({ id: L, name: P });
277
283
  return;
278
284
  }
279
- if (z.current === e || (z.current = e, Y({ id: e, name: e }), !(S != null && S.resolve))) return;
280
- let u = !1;
281
- return S.resolve(e).then((w) => {
282
- !u && w && Y(w);
285
+ if (U({ id: L, name: P ?? L }), !(A != null && A.resolve)) return;
286
+ let d = !1;
287
+ return A.resolve(L, N).then((te) => {
288
+ !d && te && U(te);
283
289
  }).catch(() => {
284
290
  }), () => {
285
- u = !0;
291
+ d = !0;
286
292
  };
287
- }, [e, S]);
288
- const E = De(
289
- async (u, w = !1) => {
290
- var j;
291
- if (!S) {
292
- G("Search service not configured.");
293
+ }, [L, P, w, A, N]);
294
+ const we = _e(
295
+ async (d, E = !1) => {
296
+ var te;
297
+ if (!A) {
298
+ b("Search service not configured.");
293
299
  return;
294
300
  }
295
- (j = b.current) == null || j.abort();
296
- const de = new AbortController();
297
- b.current = de, w ? D(!0) : (X(!0), D(!1), G(null));
301
+ (te = J.current) == null || te.abort();
302
+ const q = new AbortController();
303
+ J.current = q, E ? ne(!0) : (re(!0), ne(!1), b(null));
298
304
  try {
299
- const ee = await S.search({
300
- query: u,
301
- cursor: w ? q.current : void 0,
302
- signal: de.signal
303
- }), U = ee.options ?? [];
304
- _(w ? (tr) => [...tr, ...U] : U), q.current = ee.nextCursor, B(((f == null ? void 0 : f.paginated) ?? !1) && ee.nextCursor != null);
305
+ const ie = await A.search({
306
+ query: d,
307
+ cursor: E ? T.current : void 0,
308
+ signal: q.signal,
309
+ params: N
310
+ }), z = ie.options ?? [];
311
+ ee(E ? (pr) => [...pr, ...z] : z), T.current = ie.nextCursor, Y(((m == null ? void 0 : m.paginated) ?? !1) && ie.nextCursor != null);
305
312
  } catch {
306
- if (de.signal.aborted) return;
307
- G("Failed to load results. Please try again.");
313
+ if (q.signal.aborted) return;
314
+ b("Failed to load results. Please try again.");
308
315
  } finally {
309
- de.signal.aborted || (w ? D(!1) : X(!1));
316
+ q.signal.aborted || (E ? ne(!1) : re(!1));
310
317
  }
311
318
  },
312
- [S, f == null ? void 0 : f.paginated]
319
+ [A, m == null ? void 0 : m.paginated, N]
313
320
  );
314
- if (pe(() => {
315
- if (!L) return;
316
- const u = (w) => {
317
- N.current && !N.current.contains(w.target) && O(!1);
321
+ if (fe(() => {
322
+ if (!M) return;
323
+ const d = (E) => {
324
+ Q.current && !Q.current.contains(E.target) && O(!1);
318
325
  };
319
- return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
320
- }, [L]), pe(() => {
321
- var u;
322
- L || ((u = b.current) == null || u.abort(), $(""), _([]), B(!1), G(null), X(!1), D(!1), q.current = void 0);
323
- }, [L]), pe(() => {
324
- if (!L) return;
325
- if (!F && !v) {
326
- _([]), B(!1), G(null), q.current = void 0;
326
+ return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
327
+ }, [M]), fe(() => {
328
+ var d;
329
+ M || ((d = J.current) == null || d.abort(), V(""), ee([]), Y(!1), b(null), re(!1), ne(!1), T.current = void 0);
330
+ }, [M]), fe(() => {
331
+ if (!M) return;
332
+ if (!D && !v) {
333
+ ee([]), Y(!1), b(null), T.current = void 0;
327
334
  return;
328
335
  }
329
- ne.current && clearTimeout(ne.current);
330
- const u = F ? 300 : 0;
331
- return ne.current = setTimeout(() => {
332
- _([]), B(!1), q.current = void 0, E(F);
333
- }, u), () => {
334
- ne.current && clearTimeout(ne.current);
336
+ H.current && clearTimeout(H.current);
337
+ const d = D ? 300 : 0;
338
+ return H.current = setTimeout(() => {
339
+ ee([]), Y(!1), T.current = void 0, we(D);
340
+ }, d), () => {
341
+ H.current && clearTimeout(H.current);
335
342
  };
336
- }, [F, L, v, E]), fe(s, r, t, null), s === !1)
343
+ }, [D, M, v, we]), ce(a, r, t, w ? void 0 : null), a === !1)
337
344
  return null;
338
- const V = () => {
339
- $(""), _([]), B(!1), G(null), q.current = void 0, O(!0);
340
- }, J = (u) => {
341
- t(r, u.id), Y(u), z.current = u.id, O(!1);
342
- }, Z = (u) => {
343
- u.stopPropagation(), t(r, null), Y(void 0);
344
- }, Q = (u) => {
345
- (u.key === "Enter" || u.key === " ") && Z(u);
346
- }, Oe = ((ve = i == null ? void 0 : i.options) == null ? void 0 : ve.placeholder) ?? "Select an option";
347
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
345
+ const Ee = () => {
346
+ V(""), ee([]), Y(!1), b(null), T.current = void 0, O(!0);
347
+ }, De = (d) => {
348
+ t(r, w ? { value: d.id, label: d.name } : d.id), U(d), K.current = { value: d.id, label: w ? d.name : void 0 }, O(!1);
349
+ }, Se = (d) => {
350
+ d.stopPropagation(), t(r, w ? void 0 : null), U(void 0);
351
+ }, Fe = (d) => {
352
+ (d.key === "Enter" || d.key === " ") && Se(d);
353
+ }, Oe = ((Re = c == null ? void 0 : c.options) == null ? void 0 : Re.placeholder) ?? "Select an option";
354
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
348
355
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
349
- d,
356
+ i,
350
357
  " ",
351
- m && /* @__PURE__ */ n(h, { color: "red", children: "*" })
358
+ f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
352
359
  ] }),
353
- /* @__PURE__ */ g("div", { ref: N, style: { position: "relative" }, children: [
360
+ /* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
354
361
  /* @__PURE__ */ n(
355
362
  ye.Root,
356
363
  {
357
364
  id: r,
358
- value: L ? F : (ae == null ? void 0 : ae.name) ?? "",
359
- placeholder: L && (f != null && f.searchable) ? "Search..." : Oe,
360
- disabled: !C,
361
- readOnly: L && !(f != null && f.searchable),
362
- style: I ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
363
- onChange: (u) => {
364
- f != null && f.searchable && ($(u.target.value), L || V());
365
+ value: M ? D : (k == null ? void 0 : k.name) ?? "",
366
+ placeholder: M && (m != null && m.searchable) ? "Search..." : Oe,
367
+ disabled: !B,
368
+ readOnly: M && !(m != null && m.searchable),
369
+ style: j ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
370
+ onChange: (d) => {
371
+ m != null && m.searchable && (V(d.target.value), M || Ee());
365
372
  },
366
373
  onFocus: () => {
367
- C && !L && V();
374
+ B && !M && Ee();
368
375
  },
369
- onKeyDown: (u) => {
370
- u.key === "Escape" && O(!1);
376
+ onKeyDown: (d) => {
377
+ d.key === "Escape" && O(!1);
371
378
  },
372
- children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(T, { align: "center", gap: "1", children: [
373
- e && C && /* @__PURE__ */ n(
379
+ children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
380
+ L && B && /* @__PURE__ */ n(
374
381
  "span",
375
382
  {
376
383
  role: "button",
377
384
  tabIndex: 0,
378
- onMouseDown: (u) => u.preventDefault(),
379
- onClick: Z,
380
- onKeyDown: Q,
385
+ onMouseDown: (d) => d.preventDefault(),
386
+ onClick: Se,
387
+ onKeyDown: Fe,
381
388
  style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
382
389
  "aria-label": "Clear selection",
383
390
  children: "×"
384
391
  }
385
392
  ),
386
393
  /* @__PURE__ */ n(
387
- Er,
394
+ zr,
388
395
  {
389
- style: { transform: L ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
396
+ style: { transform: M ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
390
397
  }
391
398
  )
392
399
  ] }) })
393
400
  }
394
401
  ),
395
- L && /* @__PURE__ */ n(
396
- R,
402
+ M && /* @__PURE__ */ n(
403
+ C,
397
404
  {
398
405
  style: {
399
406
  position: "absolute",
@@ -407,111 +414,111 @@ const fe = (e, t, r, d = void 0) => {
407
414
  border: "1px solid var(--gray-a6)",
408
415
  overflow: "hidden"
409
416
  },
410
- children: x ? /* @__PURE__ */ n(R, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: x }) }) : /* @__PURE__ */ n(br, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(R, { p: "1", children: [
411
- P && /* @__PURE__ */ n(T, { justify: "center", p: "4", children: /* @__PURE__ */ n(xe, {}) }),
412
- !P && ce && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: ce }) }),
413
- !P && !ce && re.length === 0 && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: F || v ? "No results found." : "Type to search…" }) }),
414
- re.map((u) => /* @__PURE__ */ n(
415
- R,
417
+ children: I ? /* @__PURE__ */ n(C, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: I }) }) : /* @__PURE__ */ n(Lr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(C, { p: "1", children: [
418
+ Z && /* @__PURE__ */ n(S, { justify: "center", p: "4", children: /* @__PURE__ */ n(Me, {}) }),
419
+ !Z && ue && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: ue }) }),
420
+ !Z && !ue && oe.length === 0 && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: D || v ? "No results found." : "Type to search…" }) }),
421
+ oe.map((d) => /* @__PURE__ */ n(
422
+ C,
416
423
  {
417
424
  px: "3",
418
425
  py: "2",
419
- onMouseDown: (w) => w.preventDefault(),
420
- onClick: () => J(u),
426
+ onMouseDown: (E) => E.preventDefault(),
427
+ onClick: () => De(d),
421
428
  style: {
422
429
  cursor: "pointer",
423
430
  borderRadius: "var(--radius-2)",
424
- backgroundColor: u.id === e ? "var(--accent-3)" : void 0
431
+ backgroundColor: d.id === L ? "var(--accent-3)" : void 0
425
432
  },
426
433
  className: "hover:bg-(--gray-3)",
427
- children: /* @__PURE__ */ n(h, { size: "2", children: u.name })
434
+ children: /* @__PURE__ */ n(h, { size: "2", children: d.name })
428
435
  },
429
- u.id
436
+ d.id
430
437
  )),
431
- (f == null ? void 0 : f.paginated) && se && !te && /* @__PURE__ */ n(R, { px: "3", py: "2", children: /* @__PURE__ */ n(
432
- Se,
438
+ (m == null ? void 0 : m.paginated) && le && !he && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
439
+ ke,
433
440
  {
434
441
  variant: "ghost",
435
442
  size: "1",
436
443
  style: { width: "100%" },
437
- onMouseDown: (u) => u.preventDefault(),
438
- onClick: () => void E(F, !0),
444
+ onMouseDown: (d) => d.preventDefault(),
445
+ onClick: () => void we(D, !0),
439
446
  children: "Load more"
440
447
  }
441
448
  ) }),
442
- te && /* @__PURE__ */ n(T, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
449
+ he && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(Me, {}) })
443
450
  ] }) })
444
451
  }
445
452
  )
446
453
  ] }),
447
- !I && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(a, d) }),
454
+ !j && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
448
455
  o.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: o.description })
449
456
  ] }) });
450
- }, Kr = le(Br), Gr = W(
457
+ }, st = se(it), ct = W(
451
458
  3,
452
- Me((e) => {
459
+ ze((e) => {
453
460
  const t = e["x-search"];
454
- return e.type === "string" && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
461
+ return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
455
462
  })
456
- ), Xr = (e, t) => Cr(`${e}T${t}`).format(), Yr = ({ path: e, label: t, required: r, errors: d, description: m, children: a }) => {
457
- const c = d.length === 0;
458
- return /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ g(T, { direction: "column", gap: "1", children: [
463
+ ), at = (e, t) => $r(`${e}T${t}`).format(), ut = ({ path: e, label: t, required: r, errors: i, description: f, children: s }) => {
464
+ const l = i.length === 0;
465
+ return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
459
466
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
460
467
  t,
461
468
  " ",
462
469
  r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
463
470
  ] }),
464
- a,
465
- !c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ie(d, t) }),
466
- m && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: m })
471
+ s,
472
+ !l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(i, t) }),
473
+ f && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f })
467
474
  ] }) });
468
- }, Jr = ({
475
+ }, dt = ({
469
476
  data: e,
470
477
  handleChange: t,
471
478
  path: r,
472
- label: d,
473
- required: m,
474
- errors: a,
475
- schema: c,
476
- enabled: s,
479
+ label: i,
480
+ required: f,
481
+ errors: s,
482
+ schema: l,
483
+ enabled: a,
477
484
  visible: o = !0
478
485
  }) => {
479
- if (pe(() => {
486
+ if (fe(() => {
480
487
  o === !1 && t(r, void 0);
481
488
  }, [o, r, t]), o === !1)
482
489
  return null;
483
- const i = a.length === 0, l = typeof e == "string" ? e : "", y = (C) => /* @__PURE__ */ n(Yr, { path: r, label: d, required: m, errors: a, description: c.description, children: C });
484
- if (c.format === "time")
490
+ const c = s.length === 0, u = typeof e == "string" ? e : "", y = (w) => /* @__PURE__ */ n(ut, { path: r, label: i, required: f, errors: s, description: l.description, children: w });
491
+ if (l.format === "time")
485
492
  return y(
486
493
  /* @__PURE__ */ n(
487
494
  ye.Root,
488
495
  {
489
496
  type: "time",
490
- value: l,
491
- onChange: (C) => t(r, C.target.value),
492
- disabled: !s,
493
- color: i ? void 0 : "red",
497
+ value: u,
498
+ onChange: (w) => t(r, w.target.value),
499
+ disabled: !a,
500
+ color: c ? void 0 : "red",
494
501
  id: r
495
502
  }
496
503
  )
497
504
  );
498
- const p = c.format === "date-time", [f = "", v = ""] = l.split("T"), S = v.slice(0, 5), x = (C, I) => {
499
- if (!C) {
505
+ const p = l.format === "date-time", [m = "", v = ""] = u.split("T"), N = v.slice(0, 5), A = (w, R) => {
506
+ if (!w) {
500
507
  t(r, void 0);
501
508
  return;
502
509
  }
503
- t(r, p ? Xr(C, I || "00:00") : C);
510
+ t(r, p ? at(w, R || "00:00") : w);
504
511
  };
505
512
  return y(
506
- /* @__PURE__ */ g(T, { gap: "2", align: "center", children: [
513
+ /* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
507
514
  /* @__PURE__ */ n(
508
515
  ye.Root,
509
516
  {
510
517
  type: "date",
511
- value: f,
512
- disabled: !s,
513
- color: i ? void 0 : "red",
514
- onChange: (C) => x(C.target.value, S),
518
+ value: m,
519
+ disabled: !a,
520
+ color: c ? void 0 : "red",
521
+ onChange: (w) => A(w.target.value, N),
515
522
  id: r,
516
523
  style: { flex: 1 }
517
524
  }
@@ -520,116 +527,116 @@ const fe = (e, t, r, d = void 0) => {
520
527
  ye.Root,
521
528
  {
522
529
  type: "time",
523
- value: S,
524
- disabled: !s || !f,
525
- color: i ? void 0 : "red",
526
- onChange: (C) => x(f, C.target.value),
530
+ value: N,
531
+ disabled: !a || !m,
532
+ color: c ? void 0 : "red",
533
+ onChange: (w) => A(m, w.target.value),
527
534
  style: { flex: 1 }
528
535
  }
529
536
  )
530
537
  ] })
531
538
  );
532
- }, Zr = W(2, Ne(dr, ur, fr)), qr = le(Jr), Qr = ({
539
+ }, ft = W(2, Le(Rr, Cr, Tr)), ht = se(dt), pt = ({
533
540
  uischema: e,
534
541
  schema: t,
535
542
  path: r,
536
- renderers: d,
537
- cells: m,
538
- enabled: a,
539
- visible: c = !0
543
+ renderers: i,
544
+ cells: f,
545
+ enabled: s,
546
+ visible: l = !0
540
547
  }) => {
541
548
  const o = e.elements;
542
- return c === !1 ? null : /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(
543
- Re,
549
+ return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
550
+ Ae,
544
551
  {
545
- uischema: i,
552
+ uischema: c,
546
553
  schema: t,
547
554
  path: r,
548
- renderers: d,
549
- cells: m,
550
- enabled: a
555
+ renderers: i,
556
+ cells: f,
557
+ enabled: s
551
558
  },
552
- `${r}-${l}`
559
+ `${r}-${u}`
553
560
  )) });
554
- }, jr = W(1, we("VerticalLayout")), et = ({
561
+ }, mt = W(1, Te("VerticalLayout")), gt = ({
555
562
  uischema: e,
556
563
  schema: t,
557
564
  path: r,
558
- renderers: d,
559
- cells: m,
560
- enabled: a,
561
- visible: c = !0
565
+ renderers: i,
566
+ cells: f,
567
+ enabled: s,
568
+ visible: l = !0
562
569
  }) => {
563
570
  const o = e.elements;
564
- return c === !1 ? null : /* @__PURE__ */ n(T, { direction: "row", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(R, { style: { flex: 1 }, children: /* @__PURE__ */ n(
565
- Re,
571
+ return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "row", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(
572
+ Ae,
566
573
  {
567
- uischema: i,
574
+ uischema: c,
568
575
  schema: t,
569
576
  path: r,
570
- renderers: d,
571
- cells: m,
572
- enabled: a
577
+ renderers: i,
578
+ cells: f,
579
+ enabled: s
573
580
  }
574
- ) }, `${r}-${l}`)) });
575
- }, rt = W(1, we("HorizontalLayout")), tt = ({
581
+ ) }, `${r}-${u}`)) });
582
+ }, yt = W(1, Te("HorizontalLayout")), vt = ({
576
583
  uischema: e,
577
584
  schema: t,
578
585
  path: r,
579
- renderers: d,
580
- cells: m,
581
- enabled: a,
582
- visible: c = !0
586
+ renderers: i,
587
+ cells: f,
588
+ enabled: s,
589
+ visible: l = !0
583
590
  }) => {
584
- const s = e, o = s.elements;
585
- return c === !1 ? null : /* @__PURE__ */ g(R, { mb: "6", children: [
586
- s.label && /* @__PURE__ */ n(Ge, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: s.label }),
587
- /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: o.map((i, l) => /* @__PURE__ */ n(
588
- Re,
591
+ const a = e, o = a.elements;
592
+ return l === !1 ? null : /* @__PURE__ */ g(C, { mb: "6", children: [
593
+ a.label && /* @__PURE__ */ n(tr, { 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: o.map((c, u) => /* @__PURE__ */ n(
595
+ Ae,
589
596
  {
590
- uischema: i,
597
+ uischema: c,
591
598
  schema: t,
592
599
  path: r,
593
- renderers: d,
594
- cells: m,
595
- enabled: a
600
+ renderers: i,
601
+ cells: f,
602
+ enabled: s
596
603
  },
597
- `${r}-${l}`
604
+ `${r}-${u}`
598
605
  )) })
599
606
  ] });
600
- }, nt = W(1, we("Group")), ot = ({
607
+ }, bt = W(1, Te("Group")), wt = ({
601
608
  uischema: e,
602
609
  schema: t,
603
610
  path: r,
604
- renderers: d,
605
- cells: m,
606
- enabled: a,
607
- visible: c = !0
611
+ renderers: i,
612
+ cells: f,
613
+ enabled: s,
614
+ visible: l = !0
608
615
  }) => {
609
616
  var p;
610
- const o = e.elements.filter((f) => f.type === "Category"), [i, l] = k(((p = o[0]) == null ? void 0 : p.label) || "");
611
- if (c === !1 || !o.length) return null;
612
- const y = o.find((f) => f.label === i) ? i : o[0].label;
613
- return /* @__PURE__ */ g(Te.Root, { value: y, onValueChange: l, children: [
614
- /* @__PURE__ */ n(Te.List, { children: o.map((f, v) => /* @__PURE__ */ n(Te.Trigger, { value: f.label, children: f.label }, `${r}-${v}`)) }),
615
- /* @__PURE__ */ n(R, { pt: "3", children: o.map((f, v) => /* @__PURE__ */ n(Te.Content, { value: f.label, children: /* @__PURE__ */ n(T, { direction: "column", gap: "4", children: f.elements.map((S, x) => /* @__PURE__ */ n(
616
- Re,
617
+ const o = e.elements.filter((m) => m.type === "Category"), [c, u] = F(((p = o[0]) == null ? void 0 : p.label) || "");
618
+ if (l === !1 || !o.length) return null;
619
+ const y = o.find((m) => m.label === c) ? c : o[0].label;
620
+ return /* @__PURE__ */ g(Ie.Root, { value: y, onValueChange: u, children: [
621
+ /* @__PURE__ */ n(Ie.List, { children: o.map((m, v) => /* @__PURE__ */ n(Ie.Trigger, { value: m.label, children: m.label }, `${r}-${v}`)) }),
622
+ /* @__PURE__ */ n(C, { pt: "3", children: o.map((m, v) => /* @__PURE__ */ n(Ie.Content, { value: m.label, children: /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: m.elements.map((N, A) => /* @__PURE__ */ n(
623
+ Ae,
617
624
  {
618
- uischema: S,
625
+ uischema: N,
619
626
  schema: t,
620
627
  path: r,
621
- renderers: d,
622
- cells: m,
623
- enabled: a
628
+ renderers: i,
629
+ cells: f,
630
+ enabled: s
624
631
  },
625
- `${r}-${v}-${x}`
632
+ `${r}-${v}-${A}`
626
633
  )) }) }, `${r}-${v}`)) })
627
634
  ] });
628
- }, lt = W(1, we("Categorization"));
629
- function ge(e) {
635
+ }, Et = W(1, Te("Categorization"));
636
+ function me(e) {
630
637
  return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
631
638
  }
632
- function me(e) {
639
+ function ge(e) {
633
640
  return e.split(",").map((t) => {
634
641
  if (t = t.trim(), t.endsWith("/*"))
635
642
  return t.split("/")[0].toUpperCase() + "S";
@@ -639,109 +646,109 @@ function me(e) {
639
646
  return r ? r.toUpperCase() : t;
640
647
  }).join(", ");
641
648
  }
642
- function it(e) {
649
+ function Rt(e) {
643
650
  return e ? Array.isArray(e) ? e : [e] : [];
644
651
  }
645
- const st = ({
652
+ const Ct = ({
646
653
  data: e,
647
654
  handleChange: t,
648
655
  path: r,
649
- label: d,
650
- required: m,
651
- uischema: a,
652
- schema: c,
653
- enabled: s,
656
+ label: i,
657
+ required: f,
658
+ uischema: s,
659
+ schema: l,
660
+ enabled: a,
654
661
  errors: o,
655
- visible: i = !0
662
+ visible: c = !0
656
663
  }) => {
657
- const l = Sr();
658
- fe(i, r, t, null);
659
- const y = !o || o.length === 0, p = (c == null ? void 0 : c["x-file"]) ?? {}, f = (a == null ? void 0 : a.options) ?? {}, v = p.maxFiles ?? f.maxFiles ?? 1, S = p.maxSize ?? f.maxSize ?? 5 * 1024 * 1024, x = p.accept ?? f.accept ?? "image/*,application/pdf", C = v > 1, I = s !== !1, [L, O] = k(!1), [F, $] = k(null), [re, _] = k({}), se = ue(/* @__PURE__ */ new Set()), B = ue(null), P = it(e), X = P.length >= v;
660
- pe(() => () => {
661
- se.current.forEach((b) => URL.revokeObjectURL(b)), se.current.clear();
664
+ const u = Vr();
665
+ ce(c, r, t, null);
666
+ const y = !o || o.length === 0, p = (l == null ? void 0 : l["x-file"]) ?? {}, m = (s == null ? void 0 : s.options) ?? {}, v = p.maxFiles ?? m.maxFiles ?? 1, N = p.maxSize ?? m.maxSize ?? 5 * 1024 * 1024, A = p.accept ?? m.accept ?? "image/*,application/pdf", w = v > 1, R = a !== !1, [L, P] = F(!1), [I, B] = F(null), [j, M] = F({}), O = de(/* @__PURE__ */ new Set()), D = de(null), V = Rt(e), oe = V.length >= v;
667
+ fe(() => () => {
668
+ O.current.forEach((b) => URL.revokeObjectURL(b)), O.current.clear();
662
669
  }, []);
663
- const te = De(
670
+ const ee = _e(
664
671
  async (b) => {
665
- if ($(null), P.length >= v) {
666
- $(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
672
+ if (B(null), V.length >= v) {
673
+ B(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
667
674
  return;
668
675
  }
669
- if (b.size > S) {
670
- $(`File exceeds the ${ge(S)} limit.`);
676
+ if (b.size > N) {
677
+ B(`File exceeds the ${me(N)} limit.`);
671
678
  return;
672
679
  }
673
- if (!x.split(",").map((E) => E.trim()).some((E) => E === "*" || E === "*/*" ? !0 : E.endsWith("/*") ? b.type.startsWith(E.slice(0, -1)) : E.startsWith(".") ? b.name.toLowerCase().endsWith(E.toLowerCase()) : b.type === E)) {
674
- $(`Invalid type. Accepted: ${me(x)}`);
680
+ if (!A.split(",").map((T) => T.trim()).some((T) => T === "*" || T === "*/*" ? !0 : T.endsWith("/*") ? b.type.startsWith(T.slice(0, -1)) : T.startsWith(".") ? b.name.toLowerCase().endsWith(T.toLowerCase()) : b.type === T)) {
681
+ B(`Invalid type. Accepted: ${ge(A)}`);
675
682
  return;
676
683
  }
677
- if (!(l != null && l.onUpload)) {
678
- $("Upload service not configured.");
684
+ if (!(u != null && u.onUpload)) {
685
+ B("Upload service not configured.");
679
686
  return;
680
687
  }
681
688
  try {
682
- const E = await l.onUpload(b), V = URL.createObjectURL(b);
683
- se.current.add(V);
684
- const J = { key: E.key, name: E.name ?? b.name, blobUrl: V };
685
- _((Q) => ({ ...Q, [E.key]: J }));
686
- const Z = [...P, E.key];
687
- t(r, C ? Z : Z[0]);
689
+ const T = await u.onUpload(b), H = URL.createObjectURL(b);
690
+ O.current.add(H);
691
+ const J = { key: T.key, name: T.name ?? b.name, blobUrl: H };
692
+ M((K) => ({ ...K, [T.key]: J }));
693
+ const Q = [...V, T.key];
694
+ t(r, w ? Q : Q[0]);
688
695
  } catch {
689
- $("Upload failed. Please try again."), B.current && (B.current.value = "");
696
+ B("Upload failed. Please try again."), D.current && (D.current.value = "");
690
697
  }
691
698
  },
692
- [P, v, S, x, l, r, t, C]
699
+ [V, v, N, A, u, r, t, w]
693
700
  );
694
- if (i === !1)
701
+ if (c === !1)
695
702
  return null;
696
- const D = (b) => {
697
- b.preventDefault(), b.stopPropagation(), !(!I || X) && O(b.type === "dragenter" || b.type === "dragover");
698
- }, ce = (b) => {
699
- var N;
700
- b.preventDefault(), b.stopPropagation(), O(!1), !(!I || X) && (N = b.dataTransfer.files) != null && N[0] && te(b.dataTransfer.files[0]);
701
- }, G = (b) => {
702
- var N;
703
- (N = b.target.files) != null && N[0] && (te(b.target.files[0]), b.target.value = "");
704
- }, ae = (b) => {
705
- if (!I) return;
706
- _((z) => {
703
+ const le = (b) => {
704
+ b.preventDefault(), b.stopPropagation(), !(!R || oe) && P(b.type === "dragenter" || b.type === "dragover");
705
+ }, Y = (b) => {
706
+ var k;
707
+ b.preventDefault(), b.stopPropagation(), P(!1), !(!R || oe) && (k = b.dataTransfer.files) != null && k[0] && ee(b.dataTransfer.files[0]);
708
+ }, Z = (b) => {
709
+ var k;
710
+ (k = b.target.files) != null && k[0] && (ee(b.target.files[0]), b.target.value = "");
711
+ }, re = (b) => {
712
+ if (!R) return;
713
+ M((U) => {
707
714
  var J;
708
- const E = { ...z }, V = (J = E[b]) == null ? void 0 : J.blobUrl;
709
- return V && (URL.revokeObjectURL(V), se.current.delete(V)), delete E[b], E;
715
+ const T = { ...U }, H = (J = T[b]) == null ? void 0 : J.blobUrl;
716
+ return H && (URL.revokeObjectURL(H), O.current.delete(H)), delete T[b], T;
710
717
  });
711
- const N = P.filter((z) => z !== b);
712
- t(r, C ? N.length > 0 ? N : null : N[0] ?? null);
713
- }, Y = async (b, N) => {
714
- var V, J, Z;
718
+ const k = V.filter((U) => U !== b);
719
+ t(r, w ? k.length > 0 ? k : null : k[0] ?? null);
720
+ }, he = async (b, k) => {
721
+ var H, J, Q;
715
722
  b.preventDefault();
716
- const z = (V = re[N]) == null ? void 0 : V.blobUrl;
717
- if (z) {
718
- (J = window.open(z, "_blank", "noopener,noreferrer")) == null || J.focus();
723
+ const U = (H = j[k]) == null ? void 0 : H.blobUrl;
724
+ if (U) {
725
+ (J = window.open(U, "_blank", "noopener,noreferrer")) == null || J.focus();
719
726
  return;
720
727
  }
721
- const E = window.open("", "_blank");
722
- if (E)
728
+ const T = window.open("", "_blank");
729
+ if (T)
723
730
  try {
724
- const Q = await ((Z = l == null ? void 0 : l.getDownloadUrl) == null ? void 0 : Z.call(l, N));
725
- Q != null && Q.url ? E.location.href = Q.url : E.close();
731
+ const K = await ((Q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : Q.call(u, k));
732
+ K != null && K.url ? T.location.href = K.url : T.close();
726
733
  } catch {
727
- E.close();
734
+ T.close();
728
735
  }
729
736
  };
730
- if (!I && P.length === 0) return null;
731
- const q = v - P.length, ne = I && !X;
732
- return /* @__PURE__ */ g(R, { mb: "4", children: [
733
- /* @__PURE__ */ g(T, { align: "center", justify: "between", mb: "2", children: [
737
+ if (!R && V.length === 0) return null;
738
+ const ne = v - V.length, ue = R && !oe;
739
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
740
+ /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
734
741
  /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
735
- d,
736
- m && /* @__PURE__ */ n(h, { color: "red", children: " *" })
742
+ i,
743
+ f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
737
744
  ] }),
738
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: C ? `Up to ${v} files · ${ge(S)} each · ${me(x)}` : `${ge(S)} · ${me(x)}` })
745
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(N)} each · ${ge(A)}` : `${me(N)} · ${ge(A)}` })
739
746
  ] }),
740
- P.map((b) => {
741
- var N;
742
- return /* @__PURE__ */ n(ze, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(T, { align: "center", gap: "3", children: [
747
+ V.map((b) => {
748
+ var k;
749
+ return /* @__PURE__ */ n(nr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
743
750
  /* @__PURE__ */ n(
744
- R,
751
+ C,
745
752
  {
746
753
  style: {
747
754
  background: "var(--blue-3)",
@@ -750,10 +757,10 @@ const st = ({
750
757
  color: "var(--blue-9)",
751
758
  flexShrink: 0
752
759
  },
753
- children: /* @__PURE__ */ n(Ye, { width: "20", height: "20" })
760
+ children: /* @__PURE__ */ n(Dr, { width: "20", height: "20" })
754
761
  }
755
762
  ),
756
- /* @__PURE__ */ n(R, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
763
+ /* @__PURE__ */ n(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
757
764
  h,
758
765
  {
759
766
  size: "2",
@@ -764,70 +771,70 @@ const st = ({
764
771
  textOverflow: "ellipsis",
765
772
  whiteSpace: "nowrap"
766
773
  },
767
- children: ((N = re[b]) == null ? void 0 : N.name) ?? "Uploaded File"
774
+ children: ((k = j[b]) == null ? void 0 : k.name) ?? "Uploaded File"
768
775
  }
769
776
  ) }),
770
- /* @__PURE__ */ g(T, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
771
- /* @__PURE__ */ n(Se, { variant: "soft", color: "blue", size: "1", onClick: (z) => Y(z, b), children: "View" }),
772
- /* @__PURE__ */ n(Je, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
773
- I && /* @__PURE__ */ n(Xe, { variant: "ghost", color: "gray", onClick: () => ae(b), children: /* @__PURE__ */ n(Ze, {}) })
777
+ /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
778
+ /* @__PURE__ */ n(ke, { variant: "soft", color: "blue", size: "1", onClick: (U) => he(U, b), children: "View" }),
779
+ /* @__PURE__ */ n(Fr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
780
+ R && /* @__PURE__ */ n(Ue, { variant: "ghost", color: "gray", onClick: () => re(b), children: /* @__PURE__ */ n(or, {}) })
774
781
  ] })
775
782
  ] }) }, b);
776
783
  }),
777
- ne && /* @__PURE__ */ g(
784
+ ue && /* @__PURE__ */ g(
778
785
  "div",
779
786
  {
780
787
  role: "button",
781
788
  tabIndex: 0,
782
789
  onClick: () => {
783
790
  var b;
784
- return (b = B.current) == null ? void 0 : b.click();
791
+ return (b = D.current) == null ? void 0 : b.click();
785
792
  },
786
793
  onKeyDown: (b) => {
787
- var N;
788
- (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (N = B.current) == null || N.click());
794
+ var k;
795
+ (b.key === "Enter" || b.key === " ") && (b.preventDefault(), (k = D.current) == null || k.click());
789
796
  },
790
- onDragEnter: D,
791
- onDragLeave: D,
792
- onDragOver: D,
793
- onDrop: ce,
797
+ onDragEnter: le,
798
+ onDragLeave: le,
799
+ onDragOver: le,
800
+ onDrop: Y,
794
801
  style: { cursor: "pointer" },
795
802
  className: [
796
803
  "border-2 border-dashed rounded-lg p-6 text-center",
797
804
  "transition-all duration-200 ease-in-out",
798
- L ? "border-blue-500 bg-blue-50" : F ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
805
+ L ? "border-blue-500 bg-blue-50" : I ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
799
806
  ].join(" "),
800
807
  children: [
801
- /* @__PURE__ */ n("input", { ref: B, type: "file", style: { display: "none" }, accept: x, onChange: G }),
802
- /* @__PURE__ */ n(T, { direction: "column", align: "center", gap: "2", children: F ? /* @__PURE__ */ g(Ee, { children: [
803
- /* @__PURE__ */ n(qe, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
804
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: F }),
808
+ /* @__PURE__ */ n("input", { ref: D, type: "file", style: { display: "none" }, accept: A, onChange: Z }),
809
+ /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: I ? /* @__PURE__ */ g(be, { children: [
810
+ /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
811
+ /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: I }),
805
812
  /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
806
- ] }) : /* @__PURE__ */ g(Ee, { children: [
807
- /* @__PURE__ */ n(Qe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
808
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: P.length > 0 ? `Add another file (${q} remaining)` : "Click to upload or drag and drop" }),
813
+ ] }) : /* @__PURE__ */ g(be, { children: [
814
+ /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
815
+ /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: V.length > 0 ? `Add another file (${ne} remaining)` : "Click to upload or drag and drop" }),
809
816
  /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
810
- ge(S),
817
+ me(N),
811
818
  " max · ",
812
- me(x)
819
+ ge(A)
813
820
  ] })
814
821
  ] }) })
815
822
  ]
816
823
  }
817
824
  ),
818
- I && X && C && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
825
+ R && oe && w && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
819
826
  "Maximum ",
820
827
  v,
821
828
  " files uploaded. Remove one to replace it."
822
829
  ] }),
823
- !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ie(o, d) })
830
+ !y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
824
831
  ] });
825
- }, ct = le(st), at = W(
832
+ }, Tt = se(Ct), At = W(
826
833
  10,
827
834
  // high rank to beat default array renderer
828
- hr(
835
+ Ar(
829
836
  // Match both single-file (type: string) and multi-file (type: array)
830
- Me((e) => {
837
+ ze((e) => {
831
838
  if (e.type === "string" && e.format === "file") return !0;
832
839
  if (e.type === "array") {
833
840
  const t = e.items;
@@ -837,39 +844,42 @@ const st = ({
837
844
  })
838
845
  )
839
846
  );
840
- class Le extends Error {
847
+ function St(e, t) {
848
+ return e !== !1 && t !== !0;
849
+ }
850
+ class $e extends Error {
841
851
  }
842
- function dt(e, t) {
843
- const r = Tr(e, { type: "array", cellDates: !0 });
852
+ function Ot(e, t) {
853
+ const r = _r(e, { type: "array", cellDates: !0 });
844
854
  if (r.SheetNames.length === 0)
845
- throw new Le("This file has no sheets.");
846
- const d = t ?? r.SheetNames[0], m = r.Sheets[d];
847
- if (!m)
848
- throw new Le(`This file doesn't have a sheet named "${d}".`);
849
- const a = Ar.sheet_to_json(m, { header: 1, raw: !0, defval: null });
855
+ throw new $e("This file has no sheets.");
856
+ const i = t ?? r.SheetNames[0], f = r.Sheets[i];
857
+ if (!f)
858
+ throw new $e(`This file doesn't have a sheet named "${i}".`);
859
+ const s = Pr.sheet_to_json(f, { header: 1, raw: !0, defval: null });
850
860
  return {
851
- sheetName: d,
852
- matrix: a,
853
- rowCount: a.length,
854
- colCount: Math.max(0, ...a.map((c) => c.length))
861
+ sheetName: i,
862
+ matrix: s,
863
+ rowCount: s.length,
864
+ colCount: Math.max(0, ...s.map((l) => l.length))
855
865
  };
856
866
  }
857
- function ut(e) {
867
+ function Nt(e) {
858
868
  let t = e + 1, r = "";
859
869
  for (; t > 0; ) {
860
- const d = (t - 1) % 26;
861
- r = String.fromCharCode(65 + d) + r, t = Math.floor((t - 1) / 26);
870
+ const i = (t - 1) % 26;
871
+ r = String.fromCharCode(65 + i) + r, t = Math.floor((t - 1) / 26);
862
872
  }
863
873
  return r;
864
874
  }
865
- class K extends Error {
866
- constructor(r, d) {
867
- super(d ?? r);
868
- Ue(this, "code");
875
+ class X extends Error {
876
+ constructor(r, i) {
877
+ super(i ?? r);
878
+ Pe(this, "code");
869
879
  this.code = r, this.name = "FormulaError";
870
880
  }
871
881
  }
872
- const ft = [
882
+ const It = [
873
883
  // Logical
874
884
  // IF is excluded here even though its native body is real, non-stub code —
875
885
  // see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
@@ -895,7 +905,7 @@ const ft = [
895
905
  // DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
896
906
  "DATE",
897
907
  "TODAY"
898
- ], ht = [
908
+ ], xt = [
899
909
  "MAX",
900
910
  "MIN",
901
911
  "MAXA",
@@ -914,7 +924,7 @@ const ft = [
914
924
  "COUNTA",
915
925
  // not present in fast-formula-parser's function table at all.
916
926
  "UPPER"
917
- ], pt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], gt = ["IF"], mt = [
927
+ ], Mt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], kt = ["IF"], Lt = [
918
928
  "CONCATENATE",
919
929
  "CONCAT",
920
930
  "LEN",
@@ -925,115 +935,115 @@ const ft = [
925
935
  "MID",
926
936
  "FIND",
927
937
  "SEARCH"
928
- ], yt = /* @__PURE__ */ new Set([
929
- ...ft,
930
- ...ht,
931
- ...pt,
932
- ...mt,
933
- ...gt
934
- ]), vt = /"(?:[^"]|"")*"/g, Fe = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
935
- function bt(e) {
936
- const t = e.replace(vt, (d) => " ".repeat(d.length));
937
- Fe.lastIndex = 0;
938
+ ], zt = /* @__PURE__ */ new Set([
939
+ ...It,
940
+ ...xt,
941
+ ...Mt,
942
+ ...Lt,
943
+ ...kt
944
+ ]), Dt = /"(?:[^"]|"")*"/g, Be = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
945
+ function Ft(e) {
946
+ const t = e.replace(Dt, (i) => " ".repeat(i.length));
947
+ Be.lastIndex = 0;
938
948
  let r;
939
- for (; (r = Fe.exec(t)) !== null; ) {
940
- const d = r[1].toUpperCase();
941
- if (!yt.has(d))
942
- throw new K("NAME", `Function ${d} is not allowed.`);
949
+ for (; (r = Be.exec(t)) !== null; ) {
950
+ const i = r[1].toUpperCase();
951
+ if (!zt.has(i))
952
+ throw new X("NAME", `Function ${i} is not allowed.`);
943
953
  }
944
954
  }
945
- function Et(e, t, r) {
946
- let d = e;
947
- if (d == null) throw r.NA;
948
- if (typeof d == "object" && !(d instanceof r) && (d = t.retrieveRef(d)), d instanceof r) throw d;
949
- if (typeof d == "boolean") return d;
950
- if (typeof d == "number") return d !== 0;
955
+ function Ut(e, t, r) {
956
+ let i = e;
957
+ if (i == null) throw r.NA;
958
+ if (typeof i == "object" && !(i instanceof r) && (i = t.retrieveRef(i)), i instanceof r) throw i;
959
+ if (typeof i == "boolean") return i;
960
+ if (typeof i == "number") return i !== 0;
951
961
  throw r.VALUE;
952
962
  }
953
- function rr(e) {
963
+ function cr(e) {
954
964
  return e !== null && typeof e == "object" && "value" in e ? e.value : e;
955
965
  }
956
- function he(e) {
957
- const t = rr(e);
966
+ function pe(e) {
967
+ const t = cr(e);
958
968
  return Array.isArray(t) ? t.flat(1 / 0) : [t];
959
969
  }
960
- function A(e) {
961
- const t = rr(e);
970
+ function x(e) {
971
+ const t = cr(e);
962
972
  return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
963
973
  }
964
- function Ae(e) {
965
- return e === void 0 ? void 0 : A(e);
974
+ function xe(e) {
975
+ return e === void 0 ? void 0 : x(e);
966
976
  }
967
- function H(e) {
977
+ function G(e) {
968
978
  return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
969
979
  }
970
- function wt(e, t) {
980
+ function Ht(e, t) {
971
981
  return e instanceof t ? e : new t(e.message || "#ERROR!");
972
982
  }
973
- function M(e) {
983
+ function _(e) {
974
984
  return e.find((t) => t instanceof Error);
975
985
  }
976
- function Rt(e, t) {
977
- const r = (a) => {
978
- throw wt(a, t);
979
- }, d = (a, { checkArgsForErrors: c = !0 } = {}) => (...s) => {
980
- const o = s.flatMap(he);
981
- if (c) {
982
- const l = M(o);
983
- l && r(l);
986
+ function $t(e, t) {
987
+ const r = (s) => {
988
+ throw Ht(s, t);
989
+ }, i = (s, { checkArgsForErrors: l = !0 } = {}) => (...a) => {
990
+ const o = a.flatMap(pe);
991
+ if (l) {
992
+ const u = _(o);
993
+ u && r(u);
984
994
  }
985
- const i = a(...o);
986
- return i instanceof Error ? r(i) : i;
987
- }, m = (a, { toText: c = !1 } = {}) => (s) => {
988
- const o = A(s), i = M([o]);
989
- i && r(i);
990
- const l = a(c ? H(o) : o);
991
- return l instanceof Error ? r(l) : l;
995
+ const c = s(...o);
996
+ return c instanceof Error ? r(c) : c;
997
+ }, f = (s, { toText: l = !1 } = {}) => (a) => {
998
+ const o = x(a), c = _([o]);
999
+ c && r(c);
1000
+ const u = s(l ? G(o) : o);
1001
+ return u instanceof Error ? r(u) : u;
992
1002
  };
993
1003
  return {
994
1004
  // valueIfTrue/valueIfFalse are passed through unretrieved (not
995
1005
  // dereferenced or type-checked here) — that's what makes
996
1006
  // `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
997
- IF: (a, c, s, o) => {
998
- const i = Et(c, a, t);
999
- if (s == null) throw t.NA;
1000
- return i ? s : o ?? !1;
1007
+ IF: (s, l, a, o) => {
1008
+ const c = Ut(l, s, t);
1009
+ if (a == null) throw t.NA;
1010
+ return c ? a : o ?? !1;
1001
1011
  },
1002
1012
  // Empty input -> 0, matching both the hand-rolled engine this replaces
1003
1013
  // and formulajs's own convention for MAX/MIN.
1004
- MAX: d(e.MAX),
1005
- MIN: d(e.MIN),
1006
- MAXA: d(e.MAXA),
1007
- MINA: d(e.MINA),
1008
- MEDIAN: d(e.MEDIAN),
1014
+ MAX: i(e.MAX),
1015
+ MIN: i(e.MIN),
1016
+ MAXA: i(e.MAXA),
1017
+ MINA: i(e.MINA),
1018
+ MEDIAN: i(e.MEDIAN),
1009
1019
  // COUNTA counts non-blank entries; an error value among the args is
1010
1020
  // itself non-blank and gets counted (matching formulajs's own COUNTA,
1011
1021
  // which never checks for errors), so this skips the error propagation
1012
1022
  // the other aggregates use.
1013
- COUNTA: d(e.COUNTA, { checkArgsForErrors: !1 }),
1014
- LARGE: (a, c) => {
1015
- const s = he(a), o = A(c), i = M([...s, o]);
1016
- i && r(i);
1017
- const l = e.LARGE(s, o);
1018
- return l instanceof Error ? r(l) : l;
1023
+ COUNTA: i(e.COUNTA, { checkArgsForErrors: !1 }),
1024
+ LARGE: (s, l) => {
1025
+ const a = pe(s), o = x(l), c = _([...a, o]);
1026
+ c && r(c);
1027
+ const u = e.LARGE(a, o);
1028
+ return u instanceof Error ? r(u) : u;
1019
1029
  },
1020
- SMALL: (a, c) => {
1021
- const s = he(a), o = A(c), i = M([...s, o]);
1022
- i && r(i);
1023
- const l = e.SMALL(s, o);
1024
- return l instanceof Error ? r(l) : l;
1030
+ SMALL: (s, l) => {
1031
+ const a = pe(s), o = x(l), c = _([...a, o]);
1032
+ c && r(c);
1033
+ const u = e.SMALL(a, o);
1034
+ return u instanceof Error ? r(u) : u;
1025
1035
  },
1026
- PERMUT: (a, c) => {
1027
- const s = [A(a), A(c)], o = M(s);
1036
+ PERMUT: (s, l) => {
1037
+ const a = [x(s), x(l)], o = _(a);
1028
1038
  o && r(o);
1029
- const i = e.PERMUT(s[0], s[1]);
1030
- return i instanceof Error ? r(i) : i;
1039
+ const c = e.PERMUT(a[0], a[1]);
1040
+ return c instanceof Error ? r(c) : c;
1031
1041
  },
1032
- PERMUTATIONA: (a, c) => {
1033
- const s = [A(a), A(c)], o = M(s);
1042
+ PERMUTATIONA: (s, l) => {
1043
+ const a = [x(s), x(l)], o = _(a);
1034
1044
  o && r(o);
1035
- const i = e.PERMUTATIONA(s[0], s[1]);
1036
- return i instanceof Error ? r(i) : i;
1045
+ const c = e.PERMUTATIONA(a[0], a[1]);
1046
+ return c instanceof Error ? r(c) : c;
1037
1047
  },
1038
1048
  // match_type is intentionally ignored and forced to 0 (exact match)
1039
1049
  // regardless of what the formula author supplied — approximate/sorted
@@ -1041,43 +1051,43 @@ function Rt(e, t) {
1041
1051
  // Excel's own default too) risks silently mis-ranking unsorted
1042
1052
  // real-world data. Same scope decision as the hand-rolled engine this
1043
1053
  // replaces, carried forward deliberately rather than dropped.
1044
- MATCH: (a, c) => {
1045
- const s = A(a), o = he(c), i = M([s, ...o]);
1046
- i && r(i);
1047
- const l = e.MATCH(s, o, 0);
1048
- return l instanceof Error ? r(l) : l;
1054
+ MATCH: (s, l) => {
1055
+ const a = x(s), o = pe(l), c = _([a, ...o]);
1056
+ c && r(c);
1057
+ const u = e.MATCH(a, o, 0);
1058
+ return u instanceof Error ? r(u) : u;
1049
1059
  },
1050
- SWITCH: (...a) => {
1051
- const c = a.map(A), s = M(c);
1052
- s && r(s);
1053
- const o = e.SWITCH(...c);
1060
+ SWITCH: (...s) => {
1061
+ const l = s.map(x), a = _(l);
1062
+ a && r(a);
1063
+ const o = e.SWITCH(...l);
1054
1064
  return o instanceof Error ? r(o) : o;
1055
1065
  },
1056
- SUBSTITUTE: (a, c, s, o) => {
1057
- const i = [H(A(a)), H(A(c)), H(A(s))];
1058
- o !== void 0 && i.push(A(o));
1059
- const l = M(i);
1060
- l && r(l);
1061
- const y = e.SUBSTITUTE(...i);
1066
+ SUBSTITUTE: (s, l, a, o) => {
1067
+ const c = [G(x(s)), G(x(l)), G(x(a))];
1068
+ o !== void 0 && c.push(x(o));
1069
+ const u = _(c);
1070
+ u && r(u);
1071
+ const y = e.SUBSTITUTE(...c);
1062
1072
  return y instanceof Error ? r(y) : y;
1063
1073
  },
1064
- TEXTJOIN: (a, c, ...s) => {
1065
- const o = H(A(a)), i = A(c), l = s.flatMap(he).map(H), y = M([o, i]);
1074
+ TEXTJOIN: (s, l, ...a) => {
1075
+ const o = G(x(s)), c = x(l), u = a.flatMap(pe).map(G), y = _([o, c]);
1066
1076
  y && r(y);
1067
- const p = e.TEXTJOIN(o, i, l);
1077
+ const p = e.TEXTJOIN(o, c, u);
1068
1078
  return p instanceof Error ? r(p) : p;
1069
1079
  },
1070
- UPPER: m(e.UPPER),
1080
+ UPPER: f(e.UPPER),
1071
1081
  // See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
1072
1082
  // fast-formula-parser's own (real, but broken-for-Date-cells) versions.
1073
- YEAR: m(e.YEAR),
1074
- MONTH: m(e.MONTH),
1075
- DAY: m(e.DAY),
1076
- WEEKDAY: (a, c) => {
1077
- const s = A(a), o = A(c), i = M([s]);
1078
- i && r(i);
1079
- const l = e.WEEKDAY(s, o);
1080
- return l instanceof Error ? r(l) : l;
1083
+ YEAR: f(e.YEAR),
1084
+ MONTH: f(e.MONTH),
1085
+ DAY: f(e.DAY),
1086
+ WEEKDAY: (s, l) => {
1087
+ const a = x(s), o = x(l), c = _([a]);
1088
+ c && r(c);
1089
+ const u = e.WEEKDAY(a, o);
1090
+ return u instanceof Error ? r(u) : u;
1081
1091
  },
1082
1092
  // See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
1083
1093
  // formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
@@ -1088,54 +1098,54 @@ function Rt(e, t) {
1088
1098
  // Flattens every argument (a whole range included) and joins with no
1089
1099
  // separator, matching Excel's own range-argument behavior — the native
1090
1100
  // implementation instead inserts stray commas for a whole-range argument.
1091
- CONCATENATE: (...a) => {
1092
- const c = a.flatMap(he), s = M(c);
1093
- s && r(s);
1094
- const o = e.CONCATENATE(...c.map(H));
1101
+ CONCATENATE: (...s) => {
1102
+ const l = s.flatMap(pe), a = _(l);
1103
+ a && r(a);
1104
+ const o = e.CONCATENATE(...l.map(G));
1095
1105
  return o instanceof Error ? r(o) : o;
1096
1106
  },
1097
- CONCAT: (...a) => {
1098
- const c = a.flatMap(he), s = M(c);
1099
- s && r(s);
1100
- const o = e.CONCAT(...c.map(H));
1107
+ CONCAT: (...s) => {
1108
+ const l = s.flatMap(pe), a = _(l);
1109
+ a && r(a);
1110
+ const o = e.CONCAT(...l.map(G));
1101
1111
  return o instanceof Error ? r(o) : o;
1102
1112
  },
1103
- LEN: m(e.LEN, { toText: !0 }),
1104
- TRIM: m(e.TRIM, { toText: !0 }),
1105
- LOWER: m(e.LOWER, { toText: !0 }),
1106
- LEFT: (a, c) => {
1107
- const s = A(a), o = Ae(c), i = M([s]);
1108
- i && r(i);
1109
- const l = e.LEFT(H(s), o);
1110
- return l instanceof Error ? r(l) : l;
1113
+ LEN: f(e.LEN, { toText: !0 }),
1114
+ TRIM: f(e.TRIM, { toText: !0 }),
1115
+ LOWER: f(e.LOWER, { toText: !0 }),
1116
+ LEFT: (s, l) => {
1117
+ const a = x(s), o = xe(l), c = _([a]);
1118
+ c && r(c);
1119
+ const u = e.LEFT(G(a), o);
1120
+ return u instanceof Error ? r(u) : u;
1111
1121
  },
1112
- RIGHT: (a, c) => {
1113
- const s = A(a), o = Ae(c), i = M([s]);
1114
- i && r(i);
1115
- const l = e.RIGHT(H(s), o);
1116
- return l instanceof Error ? r(l) : l;
1122
+ RIGHT: (s, l) => {
1123
+ const a = x(s), o = xe(l), c = _([a]);
1124
+ c && r(c);
1125
+ const u = e.RIGHT(G(a), o);
1126
+ return u instanceof Error ? r(u) : u;
1117
1127
  },
1118
- MID: (a, c, s) => {
1119
- const o = A(a), i = A(c), l = A(s), y = M([o, i, l]);
1128
+ MID: (s, l, a) => {
1129
+ const o = x(s), c = x(l), u = x(a), y = _([o, c, u]);
1120
1130
  y && r(y);
1121
- const p = e.MID(H(o), i, l);
1131
+ const p = e.MID(G(o), c, u);
1122
1132
  return p instanceof Error ? r(p) : p;
1123
1133
  },
1124
- FIND: (a, c, s) => {
1125
- const o = A(a), i = A(c), l = Ae(s), y = M([o, i]);
1134
+ FIND: (s, l, a) => {
1135
+ const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
1126
1136
  y && r(y);
1127
- const p = e.FIND(H(o), H(i), l);
1137
+ const p = e.FIND(G(o), G(c), u);
1128
1138
  return p instanceof Error ? r(p) : p;
1129
1139
  },
1130
- SEARCH: (a, c, s) => {
1131
- const o = A(a), i = A(c), l = Ae(s), y = M([o, i]);
1140
+ SEARCH: (s, l, a) => {
1141
+ const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
1132
1142
  y && r(y);
1133
- const p = e.SEARCH(H(o), H(i), l);
1143
+ const p = e.SEARCH(G(o), G(c), u);
1134
1144
  return p instanceof Error ? r(p) : p;
1135
1145
  }
1136
1146
  };
1137
1147
  }
1138
- const Ct = {
1148
+ const _t = {
1139
1149
  "#REF!": "REF",
1140
1150
  "#VALUE!": "VALUE",
1141
1151
  "#DIV/0!": "DIV0",
@@ -1144,41 +1154,41 @@ const Ct = {
1144
1154
  "#NUM!": "NUM",
1145
1155
  "#NULL!": "NULL"
1146
1156
  };
1147
- function $e(e) {
1148
- return Ct[e.error] ?? "ERROR";
1157
+ function Ke(e) {
1158
+ return _t[e.error] ?? "ERROR";
1149
1159
  }
1150
- function _e(e, t) {
1151
- if (e instanceof K) return e;
1160
+ function Ge(e, t) {
1161
+ if (e instanceof X) return e;
1152
1162
  if (e instanceof t) {
1153
1163
  const r = e.details;
1154
- return r instanceof K ? r : r instanceof t ? new K($e(r), r.message) : new K($e(e), e.message);
1164
+ return r instanceof X ? r : r instanceof t ? new X(Ke(r), r.message) : new X(Ke(e), e.message);
1155
1165
  }
1156
- return new K("ERROR", e instanceof Error ? e.message : void 0);
1166
+ return new X("ERROR", e instanceof Error ? e.message : void 0);
1157
1167
  }
1158
- function Tt(e) {
1168
+ function Pt(e) {
1159
1169
  return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
1160
1170
  }
1161
- function At(e) {
1171
+ function Vt(e) {
1162
1172
  return (t) => {
1163
1173
  const r = e[t.row - 1];
1164
1174
  if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
1165
- throw new K("REF");
1166
- const d = r[t.col - 1];
1167
- return d == null || d === "" ? null : d;
1175
+ throw new X("REF");
1176
+ const i = r[t.col - 1];
1177
+ return i == null || i === "" ? null : i;
1168
1178
  };
1169
1179
  }
1170
- function St(e) {
1180
+ function Wt(e) {
1171
1181
  return (t) => {
1172
- const r = Math.min(t.from.row, t.to.row), d = Math.min(t.from.col, t.to.col), m = Math.max(t.from.row, t.to.row), a = Math.max(t.from.col, t.to.col), c = Tt(e);
1173
- if (r > e.length || d > c)
1174
- throw new K("REF");
1175
- const s = Math.min(m, e.length), o = [];
1176
- for (let i = r; i <= s; i++) {
1177
- const l = e[i - 1], y = [];
1178
- if (l != null) {
1179
- const p = Math.min(a, l.length);
1180
- for (let f = d; f <= p; f++) {
1181
- const v = l[f - 1];
1182
+ const r = Math.min(t.from.row, t.to.row), i = Math.min(t.from.col, t.to.col), f = Math.max(t.from.row, t.to.row), s = Math.max(t.from.col, t.to.col), l = Pt(e);
1183
+ if (r > e.length || i > l)
1184
+ throw new X("REF");
1185
+ const a = Math.min(f, e.length), o = [];
1186
+ for (let c = r; c <= a; c++) {
1187
+ const u = e[c - 1], y = [];
1188
+ if (u != null) {
1189
+ const p = Math.min(s, u.length);
1190
+ for (let m = i; m <= p; m++) {
1191
+ const v = u[m - 1];
1182
1192
  y.push(v == null || v === "" ? null : v);
1183
1193
  }
1184
1194
  }
@@ -1187,38 +1197,57 @@ function St(e) {
1187
1197
  return o;
1188
1198
  };
1189
1199
  }
1190
- function Nt(e) {
1200
+ function Bt(e) {
1191
1201
  if (e == null || e === "") return null;
1192
1202
  if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
1193
1203
  return e;
1194
- throw new K("VALUE");
1204
+ throw new X("VALUE");
1195
1205
  }
1196
- async function Ot(e, t) {
1197
- if (typeof t != "string") throw new K("ERROR");
1198
- const r = t.trim();
1199
- if (r === "") throw new K("ERROR");
1200
- const d = r.startsWith("=") ? r.slice(1) : r;
1201
- bt(d);
1202
- const [m, a] = await Promise.all([
1206
+ async function ar(e, t) {
1207
+ if (typeof e != "string") throw new X("ERROR");
1208
+ const r = e.trim();
1209
+ if (r === "") throw new X("ERROR");
1210
+ const i = r.startsWith("=") ? r.slice(1) : r;
1211
+ Ft(i);
1212
+ const [f, s] = await Promise.all([
1203
1213
  import("fast-formula-parser"),
1204
1214
  import("@formulajs/formulajs")
1205
- ]), c = m.default ?? m, s = c.FormulaError, o = new c({
1206
- onCell: At(e),
1207
- onRange: St(e),
1215
+ ]), l = f.default ?? f, a = l.FormulaError, o = new l({
1216
+ ...t,
1208
1217
  // 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.
1209
- functions: Rt(a, s)
1218
+ functions: $t(s, a)
1210
1219
  });
1211
- let i;
1220
+ let c;
1212
1221
  try {
1213
- i = o.parse(d, { row: 1, col: 1, sheet: "Sheet1" });
1214
- } catch (l) {
1215
- throw _e(l, s);
1222
+ c = o.parse(i, { row: 1, col: 1, sheet: "Sheet1" });
1223
+ } catch (u) {
1224
+ throw Ge(u, a);
1216
1225
  }
1217
- if (i instanceof s)
1218
- throw _e(i, s);
1219
- return Nt(i);
1226
+ if (c instanceof a)
1227
+ throw Ge(c, a);
1228
+ return Bt(c);
1229
+ }
1230
+ async function Kt(e, t) {
1231
+ return ar(t, { onCell: Vt(e), onRange: Wt(e) });
1232
+ }
1233
+ const Xe = -1;
1234
+ async function Gt(e, t) {
1235
+ const r = Object.keys(e);
1236
+ return ar(t, {
1237
+ onVariable: (i) => {
1238
+ const f = r.indexOf(i);
1239
+ return f === -1 ? null : { row: Xe, col: f + 1 };
1240
+ },
1241
+ onCell: (i) => {
1242
+ if (i.row === Xe) return e[r[i.col - 1]] ?? null;
1243
+ throw new X("REF");
1244
+ },
1245
+ onRange: () => {
1246
+ throw new X("REF");
1247
+ }
1248
+ });
1220
1249
  }
1221
- const Pe = {
1250
+ const ur = {
1222
1251
  REF: "#REF!",
1223
1252
  VALUE: "#VALUE!",
1224
1253
  DIV0: "#DIV/0!",
@@ -1228,343 +1257,525 @@ const Pe = {
1228
1257
  NUM: "#NUM!",
1229
1258
  NULL: "#NULL!"
1230
1259
  };
1231
- async function It(e, t) {
1232
- return e.length === 0 ? t.map((r) => ({ label: (r == null ? void 0 : r.label) ?? "(unknown)", value: null, error: Pe.ERROR })) : Promise.all(
1260
+ function dr(e) {
1261
+ const t = e instanceof X ? e.code : "ERROR";
1262
+ return ur[t];
1263
+ }
1264
+ async function Xt(e, t) {
1265
+ return e.length === 0 ? t.map((r) => ({
1266
+ id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1267
+ label: (r == null ? void 0 : r.label) ?? "(unknown)",
1268
+ value: null,
1269
+ error: ur.ERROR
1270
+ })) : Promise.all(
1233
1271
  t.map(async (r) => {
1234
1272
  try {
1235
- if (!r || typeof r.label != "string" || typeof r.expression != "string")
1236
- throw new K("ERROR");
1237
- return { label: r.label, value: await Ot(e, r.expression) };
1238
- } catch (d) {
1239
- const m = d instanceof K ? d.code : "ERROR";
1240
- return { label: (r == null ? void 0 : r.label) ?? "(unknown)", value: null, error: Pe[m] };
1273
+ if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
1274
+ throw new X("ERROR");
1275
+ return { id: r.id, label: r.label, value: await Kt(e, r.expression) };
1276
+ } catch (i) {
1277
+ return {
1278
+ id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
1279
+ label: (r == null ? void 0 : r.label) ?? "(unknown)",
1280
+ value: null,
1281
+ error: dr(i)
1282
+ };
1241
1283
  }
1242
1284
  })
1243
1285
  );
1244
1286
  }
1245
- const xt = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Lt = 10 * 1024 * 1024, Ie = 200, Dt = 50, Mt = [];
1246
- function be(e) {
1287
+ function jt(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 ? Yt(e) : t.rowHeader ? Jt(e) : e;
1293
+ }
1294
+ function fr(e) {
1295
+ return e == null || e === "" ? null : e instanceof Date ? e.toISOString() : String(e);
1296
+ }
1297
+ function hr(e, t) {
1298
+ const r = /* @__PURE__ */ new Set();
1299
+ for (const i of e)
1300
+ if (i != null) {
1301
+ if (r.has(i))
1302
+ throw new Error(
1303
+ `x-spreadsheet: duplicate ${t} value "${i}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
1304
+ );
1305
+ r.add(i);
1306
+ }
1307
+ }
1308
+ function Yt(e) {
1309
+ const [t, ...r] = e;
1310
+ if (!t) return [];
1311
+ const i = t.map(fr);
1312
+ return hr(i, "columnHeader"), r.map((f) => {
1313
+ const s = /* @__PURE__ */ Object.create(null);
1314
+ return i.forEach((l, a) => {
1315
+ l != null && (s[l] = f[a] ?? null);
1316
+ }), s;
1317
+ });
1318
+ }
1319
+ function Jt(e) {
1320
+ const t = e.map((f) => fr(f[0]));
1321
+ hr(t, "rowHeader");
1322
+ const r = Math.max(0, ...e.map((f) => f.length)), i = Math.max(0, r - 1);
1323
+ return Array.from({ length: i }, (f, s) => {
1324
+ const l = s + 1, a = /* @__PURE__ */ Object.create(null);
1325
+ return t.forEach((o, c) => {
1326
+ o != null && (a[o] = e[c][l] ?? null);
1327
+ }), a;
1328
+ });
1329
+ }
1330
+ function je(e) {
1331
+ return !Array.isArray(e[0]);
1332
+ }
1333
+ async function qt(e, t, r = {}) {
1334
+ const i = await Xt(e, t), f = /* @__PURE__ */ Object.create(null);
1335
+ for (const { id: s, label: l, value: a, error: o } of i)
1336
+ f[s] = o === void 0 ? { label: l, value: a } : { label: l, value: a, error: o };
1337
+ return r.persistSheet === !1 ? { derivations: f } : { sheet: jt(e, r), derivations: f };
1338
+ }
1339
+ const Zt = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Qt = 10 * 1024 * 1024, ve = 200, Ye = 50, en = [];
1340
+ function Ce(e) {
1247
1341
  return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
1248
1342
  }
1249
- const zt = ({
1343
+ const rn = ({
1250
1344
  data: e,
1251
1345
  handleChange: t,
1252
1346
  path: r,
1253
- label: d,
1254
- required: m,
1255
- schema: a,
1256
- enabled: c,
1257
- errors: s,
1258
- visible: o = !0
1347
+ label: i,
1348
+ required: f,
1349
+ schema: s,
1350
+ enabled: l,
1351
+ readonly: a,
1352
+ errors: o,
1353
+ visible: c = !0
1259
1354
  }) => {
1260
- var ve;
1261
- fe(o, r, t, null);
1262
- const i = !s || s.length === 0, l = c !== !1, y = (a == null ? void 0 : a["x-spreadsheet"]) ?? {}, p = (a == null ? void 0 : a["x-evaluate"]) ?? Mt, f = y.accept ?? xt, v = y.maxSize ?? Lt, S = y.persistSheet !== !1, x = y.columnHeader === !0, C = y.rowHeader === !0, I = y.showSheet !== !1, L = y.sheetName, O = e ?? null, [F, $] = k(
1263
- () => {
1264
- var u;
1265
- return O != null && O.sheet || (((u = O == null ? void 0 : O.derivations) == null ? void 0 : u.length) ?? 0) > 0 ? "ready" : "empty";
1266
- }
1267
- ), [re, _] = k(null), [se, B] = k(!1), [P, X] = k(null), te = ue(null), D = P ?? (O == null ? void 0 : O.sheet) ?? null, ce = (O == null ? void 0 : O.derivations) ?? [], G = D != null || O != null, ae = De(
1268
- async (u) => {
1269
- if (_(null), u.size > v) {
1270
- _(`File exceeds the ${ge(v)} limit.`);
1355
+ ce(c, r, t, null);
1356
+ const u = !o || o.length === 0, y = St(l, a), p = (s == null ? void 0 : s["x-spreadsheet"]) ?? {}, m = (s == null ? void 0 : s["x-evaluate"]) ?? en, v = p.accept ?? Zt, N = p.maxSize ?? Qt, A = p.persistSheet !== !1, w = p.columnHeader === !0, R = p.rowHeader === !0, L = p.showSheet !== !1, P = p.sheetName, I = e ?? null, [B, j] = F(
1357
+ () => I != null && I.sheet || Object.keys((I == null ? void 0 : I.derivations) ?? {}).length > 0 ? "ready" : "empty"
1358
+ ), [M, O] = F(null), [D, V] = F(!1), [oe, ee] = F(null), le = de(null), Y = (I == null ? void 0 : I.sheet) ?? null, Z = oe ?? (Y && !je(Y) ? Y : null), re = oe == null && Y && je(Y) ? Y : null, he = (I == null ? void 0 : I.derivations) ?? {}, ne = Z != null || I != null, ue = _e(
1359
+ async (d) => {
1360
+ if (O(null), d.size > N) {
1361
+ O(`File exceeds the ${me(N)} limit.`);
1271
1362
  return;
1272
1363
  }
1273
- if (!f.split(",").map((U) => U.trim()).some((U) => U === "*" || U === "*/*" ? !0 : U.endsWith("/*") ? u.type.startsWith(U.slice(0, -1)) : U.startsWith(".") ? u.name.toLowerCase().endsWith(U.toLowerCase()) : u.type === U)) {
1274
- _(`Invalid type. Accepted: ${me(f)}`);
1364
+ if (!v.split(",").map((z) => z.trim()).some((z) => z === "*" || z === "*/*" ? !0 : z.endsWith("/*") ? d.type.startsWith(z.slice(0, -1)) : z.startsWith(".") ? d.name.toLowerCase().endsWith(z.toLowerCase()) : d.type === z)) {
1365
+ O(`Invalid type. Accepted: ${ge(v)}`);
1275
1366
  return;
1276
1367
  }
1277
- $("parsing");
1278
- let j;
1368
+ j("parsing");
1369
+ let te;
1279
1370
  try {
1280
- const U = await u.arrayBuffer();
1281
- j = dt(U, L).matrix;
1282
- } catch (U) {
1283
- $("error"), _(
1284
- U instanceof Le ? U.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1371
+ const z = await d.arrayBuffer();
1372
+ te = Ot(z, P).matrix;
1373
+ } catch (z) {
1374
+ j("error"), O(
1375
+ z instanceof $e ? z.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
1285
1376
  );
1286
1377
  return;
1287
1378
  }
1288
- X(j);
1289
- const ee = await It(j, p);
1290
- t(
1291
- r,
1292
- S ? { sheet: j, derivations: ee } : { derivations: ee }
1293
- ), $("ready");
1379
+ ee(te);
1380
+ let ie;
1381
+ try {
1382
+ ie = await qt(te, m, { persistSheet: A, columnHeader: w, rowHeader: R });
1383
+ } catch (z) {
1384
+ j("error"), O(z instanceof Error ? z.message : "Failed to process the uploaded spreadsheet.");
1385
+ return;
1386
+ }
1387
+ t(r, ie), j("ready");
1294
1388
  },
1295
- [f, v, S, L, p, r, t]
1389
+ [v, N, A, w, R, P, m, r, t]
1296
1390
  );
1297
- if (o === !1 || !l && !G) return null;
1298
- const Y = (u) => {
1299
- u.preventDefault(), u.stopPropagation(), l && B(u.type === "dragenter" || u.type === "dragover");
1300
- }, q = (u) => {
1301
- var w;
1302
- u.preventDefault(), u.stopPropagation(), B(!1), l && (w = u.dataTransfer.files) != null && w[0] && ae(u.dataTransfer.files[0]);
1303
- }, ne = (u) => {
1304
- var w;
1305
- (w = u.target.files) != null && w[0] && (ae(u.target.files[0]), u.target.value = "");
1306
- }, b = () => {
1307
- l && (X(null), _(null), $("empty"), t(r, null));
1308
- }, N = x ? 1 : 0, z = C ? 1 : 0, E = D ? D.slice(N) : [], V = E.slice(0, Ie), J = Math.min(
1309
- Dt,
1310
- Math.max(0, ...V.map((u) => Math.max(0, u.length - z)))
1311
- ), Z = Array.from({ length: J }, (u, w) => w + z), Q = I && D == null && O != null, Oe = x && C ? be((ve = D == null ? void 0 : D[0]) == null ? void 0 : ve[0]) : "";
1312
- return /* @__PURE__ */ g(R, { mb: "4", children: [
1313
- /* @__PURE__ */ g(T, { align: "center", justify: "between", mb: "2", children: [
1314
- /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1315
- d,
1316
- m && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1391
+ if (c === !1)
1392
+ return null;
1393
+ if (w && R)
1394
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
1395
+ /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1396
+ /* @__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." })
1397
+ ] });
1398
+ if (!y && !ne) return null;
1399
+ const b = (d) => {
1400
+ d.preventDefault(), d.stopPropagation(), y && V(d.type === "dragenter" || d.type === "dragover");
1401
+ }, k = (d) => {
1402
+ var E;
1403
+ d.preventDefault(), d.stopPropagation(), V(!1), y && (E = d.dataTransfer.files) != null && E[0] && ue(d.dataTransfer.files[0]);
1404
+ }, U = (d) => {
1405
+ var E;
1406
+ (E = d.target.files) != null && E[0] && (ue(d.target.files[0]), d.target.value = "");
1407
+ }, T = () => {
1408
+ y && (ee(null), O(null), j("empty"), t(r, null));
1409
+ }, H = w ? 1 : 0, J = R ? 1 : 0, Q = Z ? Z.slice(H) : [], K = Q.slice(0, ve), we = Math.min(
1410
+ Ye,
1411
+ Math.max(0, ...K.map((d) => Math.max(0, d.length - J)))
1412
+ ), Ee = Array.from({ length: we }, (d, E) => E + J), De = L && Z == null && re == null && I != null, Se = "", Fe = R && !w, Oe = re ? re.slice(0, ve) : [], Re = Array.from(new Set(Oe.flatMap((d) => Object.keys(d)))).slice(0, Ye);
1413
+ return /* @__PURE__ */ g(C, { mb: "4", children: [
1414
+ /* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
1415
+ /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
1416
+ /* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
1417
+ i,
1418
+ f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
1419
+ ] }),
1420
+ ne && y && /* @__PURE__ */ g(be, { children: [
1421
+ /* @__PURE__ */ n(We, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
1422
+ Ue,
1423
+ {
1424
+ variant: "ghost",
1425
+ size: "1",
1426
+ onClick: () => {
1427
+ var d;
1428
+ return (d = le.current) == null ? void 0 : d.click();
1429
+ },
1430
+ "aria-label": "Replace spreadsheet",
1431
+ children: /* @__PURE__ */ n(He, {})
1432
+ }
1433
+ ) }),
1434
+ /* @__PURE__ */ n(We, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
1435
+ Ue,
1436
+ {
1437
+ variant: "ghost",
1438
+ size: "1",
1439
+ color: "gray",
1440
+ onClick: T,
1441
+ "aria-label": "Remove spreadsheet",
1442
+ children: /* @__PURE__ */ n(or, {})
1443
+ }
1444
+ ) })
1445
+ ] })
1317
1446
  ] }),
1318
1447
  /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1319
- ge(v),
1448
+ me(N),
1320
1449
  " max · ",
1321
- me(f)
1450
+ ge(v)
1322
1451
  ] })
1323
1452
  ] }),
1324
- G && /* @__PURE__ */ n(ze, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(T, { align: "center", gap: "3", children: [
1325
- /* @__PURE__ */ n(
1326
- R,
1327
- {
1328
- style: {
1329
- background: "var(--blue-3)",
1330
- padding: 8,
1331
- borderRadius: 6,
1332
- color: "var(--blue-9)",
1333
- flexShrink: 0
1334
- },
1335
- children: /* @__PURE__ */ n(Ye, { width: "20", height: "20" })
1336
- }
1337
- ),
1338
- /* @__PURE__ */ n(R, { style: { flex: 1 }, children: /* @__PURE__ */ n(h, { size: "2", weight: "bold", children: "Spreadsheet uploaded" }) }),
1339
- /* @__PURE__ */ n(Je, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
1340
- l && /* @__PURE__ */ n(Xe, { variant: "ghost", color: "gray", onClick: b, "aria-label": "Remove spreadsheet", children: /* @__PURE__ */ n(Ze, {}) })
1341
- ] }) }),
1342
- l && /* @__PURE__ */ g(
1453
+ ne && M && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: M }),
1454
+ /* @__PURE__ */ n("input", { ref: le, type: "file", style: { display: "none" }, accept: v, onChange: U }),
1455
+ y && !ne && /* @__PURE__ */ n(
1343
1456
  "div",
1344
1457
  {
1345
1458
  role: "button",
1346
1459
  tabIndex: 0,
1347
1460
  onClick: () => {
1348
- var u;
1349
- return (u = te.current) == null ? void 0 : u.click();
1461
+ var d;
1462
+ return (d = le.current) == null ? void 0 : d.click();
1350
1463
  },
1351
- onKeyDown: (u) => {
1352
- var w;
1353
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), (w = te.current) == null || w.click());
1464
+ onKeyDown: (d) => {
1465
+ var E;
1466
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), (E = le.current) == null || E.click());
1354
1467
  },
1355
- onDragEnter: Y,
1356
- onDragLeave: Y,
1357
- onDragOver: Y,
1358
- onDrop: q,
1468
+ onDragEnter: b,
1469
+ onDragLeave: b,
1470
+ onDragOver: b,
1471
+ onDrop: k,
1359
1472
  style: { cursor: "pointer" },
1360
1473
  className: [
1361
1474
  "border-2 border-dashed rounded-lg p-6 text-center",
1362
1475
  "transition-all duration-200 ease-in-out",
1363
- se ? "border-blue-500 bg-blue-50" : re ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1476
+ D ? "border-blue-500 bg-blue-50" : M ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
1364
1477
  ].join(" "),
1365
- children: [
1366
- /* @__PURE__ */ n("input", { ref: te, type: "file", style: { display: "none" }, accept: f, onChange: ne }),
1367
- /* @__PURE__ */ n(T, { direction: "column", align: "center", gap: "2", children: F === "parsing" ? /* @__PURE__ */ g(Ee, { children: [
1368
- /* @__PURE__ */ n(xe, { size: "3" }),
1369
- /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1370
- ] }) : re ? /* @__PURE__ */ g(Ee, { children: [
1371
- /* @__PURE__ */ n(qe, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1372
- /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: re }),
1373
- /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1374
- ] }) : /* @__PURE__ */ g(Ee, { children: [
1375
- /* @__PURE__ */ n(Qe, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1376
- /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: G ? "Click to upload a replacement" : "Click to upload or drag and drop" }),
1377
- /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1378
- ge(v),
1379
- " max · ",
1380
- me(f)
1381
- ] })
1382
- ] }) })
1383
- ]
1478
+ children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: B === "parsing" ? /* @__PURE__ */ g(be, { children: [
1479
+ /* @__PURE__ */ n(Me, { size: "3" }),
1480
+ /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
1481
+ ] }) : M ? /* @__PURE__ */ g(be, { children: [
1482
+ /* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
1483
+ /* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: M }),
1484
+ /* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
1485
+ ] }) : /* @__PURE__ */ g(be, { children: [
1486
+ /* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
1487
+ /* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
1488
+ /* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
1489
+ me(N),
1490
+ " max · ",
1491
+ ge(v)
1492
+ ] })
1493
+ ] }) })
1384
1494
  }
1385
1495
  ),
1386
- D && I && /* @__PURE__ */ g(R, { mt: "3", children: [
1387
- /* @__PURE__ */ n(R, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(oe.Root, { variant: "surface", size: "1", children: [
1388
- /* @__PURE__ */ n(oe.Header, { children: /* @__PURE__ */ g(oe.Row, { children: [
1389
- /* @__PURE__ */ n(oe.ColumnHeaderCell, { children: Oe }),
1390
- Z.map((u) => {
1391
- var w;
1392
- return /* @__PURE__ */ n(oe.ColumnHeaderCell, { children: x ? be((w = D[0]) == null ? void 0 : w[u]) : ut(u) }, u);
1496
+ Z && L && /* @__PURE__ */ g(C, { mt: "3", children: [
1497
+ /* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
1498
+ !Fe && /* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
1499
+ /* @__PURE__ */ n($.ColumnHeaderCell, { children: Se }),
1500
+ Ee.map((d) => {
1501
+ var E;
1502
+ return (
1503
+ // This row only renders when rowHeader isn't the sole
1504
+ // flag set (see suppressColumnHeaderRow) — so reaching
1505
+ // here, either columnHeader is true (real labels) or
1506
+ // both are false (columnLetter fallback).
1507
+ /* @__PURE__ */ n($.ColumnHeaderCell, { children: w ? Ce((E = Z[0]) == null ? void 0 : E[d]) : Nt(d) }, d)
1508
+ );
1393
1509
  })
1394
1510
  ] }) }),
1395
- /* @__PURE__ */ n(oe.Body, { children: V.map((u, w) => {
1396
- var j;
1397
- const de = N + w;
1398
- return /* @__PURE__ */ g(oe.Row, { children: [
1399
- /* @__PURE__ */ n(oe.RowHeaderCell, { children: C ? be((j = D[de]) == null ? void 0 : j[0]) : de + 1 }),
1400
- Z.map((ee) => /* @__PURE__ */ n(oe.Cell, { children: be(u[ee]) }, ee))
1401
- ] }, w);
1511
+ /* @__PURE__ */ n($.Body, { children: K.map((d, E) => {
1512
+ var te;
1513
+ const q = H + E;
1514
+ return /* @__PURE__ */ g($.Row, { children: [
1515
+ /* @__PURE__ */ n(
1516
+ $.RowHeaderCell,
1517
+ {
1518
+ style: R ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
1519
+ children: R ? Ce((te = Z[q]) == null ? void 0 : te[0]) : w ? "" : q + 1
1520
+ }
1521
+ ),
1522
+ Ee.map((ie) => /* @__PURE__ */ n($.Cell, { children: Ce(d[ie]) }, ie))
1523
+ ] }, E);
1402
1524
  }) })
1403
1525
  ] }) }),
1404
- E.length > Ie && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1526
+ Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1405
1527
  "Showing first ",
1406
- Ie,
1528
+ ve,
1407
1529
  " of ",
1408
- E.length,
1530
+ Q.length,
1409
1531
  " rows"
1410
1532
  ] })
1411
1533
  ] }),
1412
- Q && /* @__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." }),
1413
- ce.length > 0 && /* @__PURE__ */ g(R, { mt: "3", children: [
1534
+ re && L && /* @__PURE__ */ g(C, { mt: "3", children: [
1535
+ /* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
1536
+ /* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
1537
+ /* @__PURE__ */ n($.ColumnHeaderCell, {}),
1538
+ Re.map((d) => /* @__PURE__ */ n($.ColumnHeaderCell, { children: d }, d))
1539
+ ] }) }),
1540
+ /* @__PURE__ */ n($.Body, { children: Oe.map((d, E) => /* @__PURE__ */ g($.Row, { children: [
1541
+ /* @__PURE__ */ n($.RowHeaderCell, { children: E + 1 }),
1542
+ Re.map((q) => /* @__PURE__ */ n($.Cell, { children: Ce(d[q]) }, q))
1543
+ ] }, E)) })
1544
+ ] }) }),
1545
+ re.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
1546
+ "Showing first ",
1547
+ ve,
1548
+ " of ",
1549
+ re.length,
1550
+ " rows"
1551
+ ] })
1552
+ ] }),
1553
+ De && /* @__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." }),
1554
+ Object.keys(he).length > 0 && /* @__PURE__ */ g(C, { mt: "3", children: [
1414
1555
  /* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
1415
- /* @__PURE__ */ n(T, { direction: "column", gap: "1", children: ce.map((u, w) => /* @__PURE__ */ g(T, { justify: "between", children: [
1416
- /* @__PURE__ */ n(h, { size: "2", children: u.label }),
1417
- u.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: u.error }) : (
1556
+ /* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(he).map(([d, E]) => /* @__PURE__ */ g(S, { justify: "between", children: [
1557
+ /* @__PURE__ */ n(h, { size: "2", children: E.label }),
1558
+ E.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: E.error }) : (
1418
1559
  // d.value is CellValue | null now (SUM/AVERAGE aren't the only
1419
1560
  // possible results anymore — INDEX/CONCATENATE can return a
1420
1561
  // string, a bare comparison can return a boolean, etc.), so
1421
1562
  // `.toLocaleString()` would throw for e.g. a boolean result.
1422
1563
  // Reuse the same formatCell used for the sheet-preview grid.
1423
- /* @__PURE__ */ n(h, { size: "2", children: be(u.value) })
1564
+ /* @__PURE__ */ n(h, { size: "2", children: Ce(E.value) })
1424
1565
  )
1425
- ] }, w)) })
1566
+ ] }, d)) })
1426
1567
  ] }),
1427
- !i && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ie(s, d) })
1568
+ !u && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
1428
1569
  ] });
1429
- }, Ut = le(zt), kt = W(
1570
+ }, tn = se(rn), nn = W(
1430
1571
  10,
1431
1572
  // matches FileControlTester's rank — beats the default object/Group renderer
1432
- Me(
1573
+ ze(
1433
1574
  (e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
1434
1575
  )
1435
- ), Ft = ({
1576
+ );
1577
+ function on(e, t, r) {
1578
+ const i = {};
1579
+ for (const [f, s] of Object.entries(r)) {
1580
+ const { path: l, default: a } = typeof s == "string" ? { path: s, default: void 0 } : s, o = t ? `${t}.${l}` : l, c = Sr.data(e, o);
1581
+ if (c == null) {
1582
+ if (a === void 0) return;
1583
+ i[f] = a;
1584
+ } else
1585
+ i[f] = c;
1586
+ }
1587
+ return i;
1588
+ }
1589
+ async function ln(e, t) {
1590
+ try {
1591
+ return { status: "ok", value: await Gt(e, t) };
1592
+ } catch (r) {
1593
+ return { status: "error", error: dr(r) };
1594
+ }
1595
+ }
1596
+ function sn(e, t) {
1597
+ return e == null ? "" : typeof e == "number" ? e.toFixed(cn(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
1598
+ }
1599
+ function cn(e) {
1600
+ return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
1601
+ }
1602
+ const Je = "{value}", an = 2, un = {}, dn = ({ data: e, handleChange: t, path: r, label: i, schema: f, visible: s = !0 }) => {
1603
+ var B;
1604
+ ce(s, r, t, null);
1605
+ const l = f == null ? void 0 : f["x-computed"], a = (l == null ? void 0 : l.inputs) ?? un, o = (l == null ? void 0 : l.formula) ?? "", c = (l == null ? void 0 : l.format) ?? Je, u = (l == null ? void 0 : l.decimals) ?? an, y = xr(), p = r.split(".").slice(0, -1).join("."), m = on((B = y.core) == null ? void 0 : B.data, p, a), v = m ? JSON.stringify(m) : null, N = y.readonly === !0, [A, w] = F(() => typeof e == "number" ? "ok" : "unavailable"), [R, L] = F(() => typeof e == "number" ? e : null), [P, I] = F(null);
1606
+ return fe(() => {
1607
+ if (!s) return;
1608
+ let j = !1;
1609
+ const M = (O) => {
1610
+ N || O !== (e ?? null) && t(r, O);
1611
+ };
1612
+ if (m === void 0) {
1613
+ w("unavailable"), I(null), L(null), M(null);
1614
+ return;
1615
+ }
1616
+ return w((O) => O === "ok" ? O : "loading"), ln(m, o).then((O) => {
1617
+ if (j) return;
1618
+ const D = O.status === "ok" && typeof O.value == "number" && Number.isFinite(O.value) ? O.value : null;
1619
+ if (D === null) {
1620
+ w("error"), I(
1621
+ O.status === "error" ? O.error ?? "Unable to compute value." : "Computed value must be a number."
1622
+ ), L(null), M(null);
1623
+ return;
1624
+ }
1625
+ w("ok"), I(null), L(D), M(D);
1626
+ }), () => {
1627
+ j = !0;
1628
+ };
1629
+ }, [v, o, s, N]), s === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
1630
+ /* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
1631
+ A === "unavailable" ? /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Not yet available." }) : A === "loading" ? /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
1632
+ /* @__PURE__ */ n(Me, { size: "1" }),
1633
+ /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Computing…" })
1634
+ ] }) : A === "error" ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: P }) : /* @__PURE__ */ n(h, { size: "2", children: c.split(Je).join(sn(R, u)) }),
1635
+ f.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f.description })
1636
+ ] }) });
1637
+ }, fn = se(dn), hn = W(
1638
+ 5,
1639
+ ze((e) => {
1640
+ const t = e["x-computed"];
1641
+ return e.type === "number" && typeof t == "object" && t !== null;
1642
+ })
1643
+ ), pn = ({
1436
1644
  data: e,
1437
1645
  path: t,
1438
1646
  schema: r,
1439
- uischema: d,
1440
- enabled: m,
1441
- visible: a,
1442
- addItem: c,
1443
- removeItems: s,
1647
+ uischema: i,
1648
+ enabled: f,
1649
+ visible: s,
1650
+ addItem: l,
1651
+ removeItems: a,
1444
1652
  rootSchema: o,
1445
- arraySchema: i
1653
+ arraySchema: c
1446
1654
  }) => {
1447
- const l = i ? r : r.items, y = i || r;
1448
- if (a === !1 || !l || typeof l != "object" || Array.isArray(l))
1655
+ const u = c ? r : r.items, y = c || r;
1656
+ if (s === !1 || !u || typeof u != "object" || Array.isArray(u))
1449
1657
  return null;
1450
- const p = l, f = Array.isArray(e) ? e : [], v = y.title || "Array Items", S = () => {
1451
- const C = pr(p, o);
1452
- c && c(t, C)();
1453
- }, x = (C) => {
1454
- if (s) {
1455
- const I = s(t, [C]);
1456
- I && I();
1658
+ const p = u, m = Array.isArray(e) ? e : [], v = y.title || "Array Items", N = () => {
1659
+ const w = Or(p, o);
1660
+ l && l(t, w)();
1661
+ }, A = (w) => {
1662
+ if (a) {
1663
+ const R = a(t, [w]);
1664
+ R && R();
1457
1665
  }
1458
1666
  };
1459
- return /* @__PURE__ */ n(R, { mb: "6", children: /* @__PURE__ */ g(T, { direction: "column", gap: "4", children: [
1667
+ return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1460
1668
  /* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
1461
- f.length === 0 && /* @__PURE__ */ n(R, { 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." }) }),
1462
- f.map((C, I) => {
1463
- var O;
1464
- const L = `${t}.${I}`;
1465
- return /* @__PURE__ */ n(ze, { size: "3", variant: "surface", children: /* @__PURE__ */ g(T, { direction: "column", gap: "4", children: [
1466
- /* @__PURE__ */ g(T, { justify: "between", align: "center", children: [
1669
+ m.length === 0 && /* @__PURE__ */ n(C, { 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." }) }),
1670
+ m.map((w, R) => {
1671
+ var P;
1672
+ const L = `${t}.${R}`;
1673
+ return /* @__PURE__ */ n(nr, { size: "3", variant: "surface", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
1674
+ /* @__PURE__ */ g(S, { justify: "between", align: "center", children: [
1467
1675
  /* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
1468
1676
  "Item ",
1469
- I + 1
1677
+ R + 1
1470
1678
  ] }),
1471
- m && /* @__PURE__ */ g(
1472
- Se,
1679
+ f && /* @__PURE__ */ g(
1680
+ ke,
1473
1681
  {
1474
1682
  type: "button",
1475
1683
  color: "red",
1476
1684
  variant: "soft",
1477
- onClick: () => x(I),
1685
+ onClick: () => A(R),
1478
1686
  title: "Remove item",
1479
1687
  children: [
1480
- /* @__PURE__ */ n(wr, {}),
1688
+ /* @__PURE__ */ n(Ur, {}),
1481
1689
  "Remove"
1482
1690
  ]
1483
1691
  }
1484
1692
  )
1485
1693
  ] }),
1486
- /* @__PURE__ */ n(R, { children: /* @__PURE__ */ n(
1487
- Re,
1694
+ /* @__PURE__ */ n(C, { children: /* @__PURE__ */ n(
1695
+ Ae,
1488
1696
  {
1489
1697
  schema: p,
1490
- uischema: ((O = d.options) == null ? void 0 : O.detail) || (p.type === "object" || p.properties ? {
1698
+ uischema: ((P = i.options) == null ? void 0 : P.detail) || (p.type === "object" || p.properties ? {
1491
1699
  type: "VerticalLayout",
1492
- elements: Object.keys(p.properties || {}).map((F) => ({
1700
+ elements: Object.keys(p.properties || {}).map((I) => ({
1493
1701
  type: "Control",
1494
- scope: `#/properties/${F}`
1702
+ scope: `#/properties/${I}`
1495
1703
  }))
1496
1704
  } : {
1497
1705
  type: "Control",
1498
1706
  scope: "#"
1499
1707
  }),
1500
1708
  path: L,
1501
- enabled: m,
1709
+ enabled: f,
1502
1710
  renderers: void 0,
1503
1711
  cells: void 0
1504
1712
  }
1505
1713
  ) })
1506
1714
  ] }) }, L);
1507
1715
  }),
1508
- m && /* @__PURE__ */ n(R, { mt: "2", children: /* @__PURE__ */ g(Se, { type: "button", variant: "surface", onClick: S, children: [
1509
- /* @__PURE__ */ n(Rr, {}),
1716
+ f && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ g(ke, { type: "button", variant: "surface", onClick: N, children: [
1717
+ /* @__PURE__ */ n(Hr, {}),
1510
1718
  "Add Item"
1511
1719
  ] }) })
1512
1720
  ] }) });
1513
- }, Ve = yr(Ft), $t = W(3, gr), _t = ({ uischema: e, visible: t }) => {
1721
+ }, qe = Mr(pn), mn = W(3, Nr), gn = ({ uischema: e, visible: t }) => {
1514
1722
  const r = e;
1515
- return t === !1 ? null : /* @__PURE__ */ n(R, { mb: "4", children: /* @__PURE__ */ n(Ge, { size: "4", children: r.text }) });
1516
- }, Pt = W(1, we("Label")), Vt = W(3, mr), jt = [
1517
- { tester: Ir, renderer: xr },
1518
- { tester: Dr, renderer: Mr },
1519
- { tester: Ur, renderer: kr },
1520
- { tester: $r, renderer: _r },
1521
- { tester: Gr, renderer: Kr },
1522
- { tester: Vr, renderer: Hr },
1523
- { tester: Zr, renderer: qr },
1524
- { tester: jr, renderer: Qr },
1525
- { tester: rt, renderer: et },
1526
- { tester: nt, renderer: tt },
1527
- { tester: lt, renderer: ot },
1528
- { tester: at, renderer: ct },
1529
- { tester: kt, renderer: Ut },
1530
- { tester: $t, renderer: Ve },
1531
- { tester: Vt, renderer: Ve },
1532
- { tester: Pt, renderer: _t }
1723
+ return t === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ n(tr, { size: "4", children: r.text }) });
1724
+ }, yn = W(1, Te("Label")), vn = W(3, Ir), xn = [
1725
+ { tester: Kr, renderer: Gr },
1726
+ { tester: jr, renderer: Yr },
1727
+ { tester: qr, renderer: Zr },
1728
+ { tester: et, renderer: rt },
1729
+ { tester: ct, renderer: st },
1730
+ { tester: nt, renderer: ot },
1731
+ { tester: ft, renderer: ht },
1732
+ { tester: mt, renderer: pt },
1733
+ { tester: yt, renderer: gt },
1734
+ { tester: bt, renderer: vt },
1735
+ { tester: Et, renderer: wt },
1736
+ { tester: At, renderer: Tt },
1737
+ { tester: nn, renderer: tn },
1738
+ { tester: hn, renderer: fn },
1739
+ { tester: mn, renderer: qe },
1740
+ { tester: vn, renderer: qe },
1741
+ { tester: yn, renderer: gn }
1533
1742
  ];
1534
1743
  export {
1535
- Ve as ArrayControl,
1536
- $t as ArrayControlTester,
1537
- zr as BooleanControl,
1538
- Ur as BooleanControlTester,
1539
- ot as CategorizationLayoutRenderer,
1540
- lt as CategorizationLayoutTester,
1541
- Jr as DateControl,
1542
- Zr as DateControlTester,
1543
- ct as FileControl,
1544
- at as FileControlTester,
1545
- tt as GroupLayoutRenderer,
1546
- nt as GroupLayoutTester,
1547
- et as HorizontalLayoutRenderer,
1548
- rt as HorizontalLayoutTester,
1549
- _t as LabelRenderer,
1550
- Pt as LabelTester,
1551
- Lr as NumberControl,
1552
- Dr as NumberControlTester,
1553
- Fr as RadioControl,
1554
- $r as RadioControlTester,
1555
- Kr as SearchSelectControl,
1556
- Gr as SearchSelectControlTester,
1557
- Qt as SearchServiceProvider,
1558
- Pr as SelectControl,
1559
- Vr as SelectControlTester,
1560
- Ut as SpreadsheetControl,
1561
- kt as SpreadsheetControlTester,
1562
- Or as TextControl,
1563
- Ir as TextControlTester,
1564
- qt as UploadProvider,
1565
- Qr as VerticalLayoutRenderer,
1566
- jr as VerticalLayoutTester,
1567
- jt as radixRenderers,
1568
- Nr as useSearchService,
1569
- Sr as useUpload
1744
+ qe as ArrayControl,
1745
+ mn as ArrayControlTester,
1746
+ Jr as BooleanControl,
1747
+ qr as BooleanControlTester,
1748
+ wt as CategorizationLayoutRenderer,
1749
+ Et as CategorizationLayoutTester,
1750
+ fn as ComputedControl,
1751
+ hn as ComputedControlTester,
1752
+ dt as DateControl,
1753
+ ft as DateControlTester,
1754
+ Tt as FileControl,
1755
+ At as FileControlTester,
1756
+ vt as GroupLayoutRenderer,
1757
+ bt as GroupLayoutTester,
1758
+ gt as HorizontalLayoutRenderer,
1759
+ yt as HorizontalLayoutTester,
1760
+ gn as LabelRenderer,
1761
+ yn as LabelTester,
1762
+ Xr as NumberControl,
1763
+ jr as NumberControlTester,
1764
+ Qr as RadioControl,
1765
+ et as RadioControlTester,
1766
+ st as SearchSelectControl,
1767
+ ct as SearchSelectControlTester,
1768
+ In as SearchServiceProvider,
1769
+ tt as SelectControl,
1770
+ nt as SelectControlTester,
1771
+ tn as SpreadsheetControl,
1772
+ nn as SpreadsheetControlTester,
1773
+ Br as TextControl,
1774
+ Kr as TextControlTester,
1775
+ Nn as UploadProvider,
1776
+ pt as VerticalLayoutRenderer,
1777
+ mt as VerticalLayoutTester,
1778
+ xn as radixRenderers,
1779
+ Wr as useSearchService,
1780
+ Vr as useUpload
1570
1781
  };