@overmap-ai/forms 1.0.3-form-improvements.3 → 1.0.3-form-improvements.5

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.
package/dist/forms.js CHANGED
@@ -1,15 +1,15 @@
1
- var _t = Object.defineProperty;
2
- var $t = (s, i, e) => i in s ? _t(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
- var m = (s, i, e) => ($t(s, typeof i != "symbol" ? i + "" : i, e), e);
4
- import { jsx as r, jsxs as b, Fragment as ut } from "react/jsx-runtime";
5
- import { Flex as y, Text as V, useSeverityColor as de, Checkbox as Mt, CheckCircledIcon as Ot, TextField as oe, FontFamilyIcon as Rt, CalendarIcon as Nt, InputIcon as Bt, TextArea as qt, RowsIcon as Wt, Select as ft, Box as pe, IconButton as se, PlusIcon as Ve, Badge as Ne, Cross1Icon as mt, ListBulletIcon as jt, DropdownMenuIcon as Ht, MultiSelect as Ut, CheckboxIcon as Gt, Card as be, Heading as De, Button as H, UploadIcon as pt, ButtonList as ke, divButtonProps as Kt, StarFilledIcon as Yt, StarIcon as Qt, QuestionMarkCircledIcon as Xt, PersonIcon as Jt, Tooltip as Zt, Avatar as ei, Separator as ti, Dialog as ii, Pencil1Icon as ni, TrashIcon as ri, CopyIcon as oi, DragHandleDots2Icon as si, DropdownMenu as li, DotsVerticalIcon as ai, useAlertDialog as ci, Em as di, Strong as rt, useToast as ui, Tabs as Y } from "@overmap-ai/blocks";
6
- import { useField as Ue, useFormikContext as ue, useFormik as Ge, FormikProvider as Ke } from "formik";
7
- import fi, { useMemo as x, memo as S, useCallback as E, useState as le, useEffect as ye, useRef as mi, forwardRef as ve, useReducer as pi } from "react";
8
- import { DragDropContext as ht, Droppable as Ye, Draggable as Qe } from "@hello-pangea/dnd";
9
- import { slugify as hi, useAppSelector as _, selectFormRevision as gt, useSDK as bt, selectSubmissionAttachments as gi, selectFilteredUserForms as bi, selectUserFormMapping as yi, selectOrganization as yt, selectUser as Xe, selectNumberOfUserForms as vi, selectCurrentUser as vt, classNames as wt, isToday as wi, getLocalDateString as xi, selectLatestFormRevision as Ii, useFileSrc as Ci, selectSubmissionsForForm as Fi } from "@overmap-ai/core";
10
- import ae from "lodash.get";
11
- import Je from "lodash.set";
12
- class xt {
1
+ var Nt = Object.defineProperty;
2
+ var Bt = (s, i, e) => i in s ? Nt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var m = (s, i, e) => (Bt(s, typeof i != "symbol" ? i + "" : i, e), e);
4
+ import { jsx as r, jsxs as b, Fragment as pt } from "react/jsx-runtime";
5
+ import { Flex as y, Text as D, useSeverityColor as fe, Checkbox as qt, CheckCircledIcon as Wt, TextField as le, FontFamilyIcon as jt, CalendarIcon as Ht, InputIcon as Ut, TextArea as Gt, RowsIcon as Kt, Select as ht, Box as he, IconButton as ae, PlusIcon as ke, Badge as qe, Cross1Icon as gt, ListBulletIcon as Yt, DropdownMenuIcon as Qt, MultiSelect as Xt, CheckboxIcon as Jt, Card as ye, Heading as De, Button as G, UploadIcon as bt, ButtonList as _e, divButtonProps as Zt, StarFilledIcon as ei, StarIcon as ti, QuestionMarkCircledIcon as ii, PersonIcon as ni, Tooltip as ri, Avatar as oi, Separator as si, Dialog as li, Pencil1Icon as ai, TrashIcon as ci, CopyIcon as di, DragHandleDots2Icon as ui, DropdownMenu as fi, DotsVerticalIcon as mi, useAlertDialog as pi, Em as hi, Strong as lt, useToast as gi, Tabs as X } from "@overmap-ai/blocks";
6
+ import { useField as Ye, useFormikContext as me, useFormik as Qe, FormikProvider as Xe } from "formik";
7
+ import bi, { useMemo as w, memo as T, useCallback as S, useState as ce, useEffect as ve, useRef as yi, forwardRef as we, useReducer as vi } from "react";
8
+ import { DragDropContext as yt, Droppable as Je, Draggable as Ze } from "@hello-pangea/dnd";
9
+ import { slugify as wi, useAppSelector as $, selectFormRevision as vt, useSDK as wt, selectSubmissionAttachments as xi, selectFilteredUserForms as Ii, selectUserFormMapping as Fi, selectOrganization as xt, selectUser as et, selectNumberOfUserForms as Ci, selectCurrentUser as It, classNames as Ft, isToday as Ti, getLocalDateString as Si, selectLatestFormRevision as zi, useFileSrc as Ei, selectSubmissionsForForm as Ai } from "@overmap-ai/core";
10
+ import de from "lodash.get";
11
+ import tt from "lodash.set";
12
+ class Ct {
13
13
  constructor(i) {
14
14
  m(this, "type");
15
15
  m(this, "identifier");
@@ -33,7 +33,7 @@ class xt {
33
33
  };
34
34
  }
35
35
  }
36
- class $ extends xt {
36
+ class M extends Ct {
37
37
  constructor(e) {
38
38
  const { label: t, required: n, fieldValidators: o = [], formValidators: l = [], ...c } = e;
39
39
  super(c);
@@ -89,27 +89,27 @@ class $ extends xt {
89
89
  return [...this.formValidators];
90
90
  }
91
91
  }
92
- m($, "fieldTypeName"), m($, "fieldTypeDescription");
93
- const Ti = "_description_17zed_1", _e = {
94
- description: Ti
95
- }, B = (s) => {
92
+ m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
93
+ const Pi = "_description_17zed_1", $e = {
94
+ description: Pi
95
+ }, W = (s) => {
96
96
  const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: l } = s;
97
97
  return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...l, children: /* @__PURE__ */ b("label", { htmlFor: n, children: [
98
- /* @__PURE__ */ r(V, { severity: t, id: o, children: i }),
98
+ /* @__PURE__ */ r(D, { severity: t, id: o, children: i }),
99
99
  e
100
100
  ] }) });
101
- }, q = (s) => {
101
+ }, j = (s) => {
102
102
  const { helpText: i, children: e, severity: t } = s;
103
103
  return /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
104
104
  e,
105
- /* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(V, { size: "1", severity: t, className: _e.description, children: i }) })
105
+ /* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r(D, { size: "1", severity: t, className: $e.description, children: i }) })
106
106
  ] });
107
- }, W = (s) => {
108
- const { id: i, field: e, formId: t, ...n } = s, [o, l, c] = Ue(e.getId()), { touched: a } = l, f = l.error ?? e.description, d = l.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, g = x(() => ({
107
+ }, H = (s) => {
108
+ const { id: i, field: e, formId: t, ...n } = s, [o, l, c] = Ye(e.getId()), { touched: a } = l, f = l.error ?? e.description, d = l.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, g = w(() => ({
109
109
  ...o,
110
110
  onChange: (F) => {
111
- const w = e.getValueFromChangeEvent(F);
112
- c.setValue(w, !1).then(), (a || !e.onlyValidateAfterTouched) && c.setError(e.getError(w));
111
+ const v = e.getValueFromChangeEvent(F);
112
+ c.setValue(v, !1).then(), (a || !e.onlyValidateAfterTouched) && c.setError(e.getError(v));
113
113
  },
114
114
  onBlur: (F) => {
115
115
  c.setTouched(!0, !1).then(), c.setError(e.getError(e.getValueFromChangeEvent(F)));
@@ -128,10 +128,10 @@ const Ti = "_description_17zed_1", _e = {
128
128
  },
129
129
  { ...n, "aria-labelledby": p }
130
130
  ];
131
- }, Si = [!0, "true"], zi = S(function(i) {
132
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = W(i), f = de(n), d = Si.includes(c.value);
133
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(
134
- B,
131
+ }, Li = [!0, "true"], Vi = T(function(i) {
132
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = Li.includes(c.value);
133
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(
134
+ W,
135
135
  {
136
136
  severity: n,
137
137
  inputId: e,
@@ -139,7 +139,7 @@ const Ti = "_description_17zed_1", _e = {
139
139
  label: l,
140
140
  flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
141
141
  children: /* @__PURE__ */ r(
142
- Mt,
142
+ qt,
143
143
  {
144
144
  ...a,
145
145
  ...c,
@@ -154,7 +154,7 @@ const Ti = "_description_17zed_1", _e = {
154
154
  )
155
155
  }
156
156
  ) });
157
- }), Q = class Q extends $ {
157
+ }), J = class J extends M {
158
158
  constructor(e) {
159
159
  super({ ...e, type: "boolean" });
160
160
  m(this, "onlyValidateAfterTouched", !1);
@@ -172,18 +172,18 @@ const Ti = "_description_17zed_1", _e = {
172
172
  static deserialize(e) {
173
173
  if (e.type !== "boolean")
174
174
  throw new Error("Type mismatch.");
175
- return new Q(e);
175
+ return new J(e);
176
176
  }
177
177
  getInput(e) {
178
- return /* @__PURE__ */ r(zi, { ...e, field: this });
178
+ return /* @__PURE__ */ r(Vi, { ...e, field: this });
179
179
  }
180
180
  };
181
- m(Q, "fieldTypeName", "Checkbox"), m(Q, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(Q, "Icon", Ot);
182
- let ce = Q;
183
- const Ei = S(function(i) {
184
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = W(i), d = de(n);
185
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
186
- oe.Input,
181
+ m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon", Wt);
182
+ let ue = J;
183
+ const ki = T(function(i) {
184
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
185
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
186
+ le.Input,
187
187
  {
188
188
  ...f,
189
189
  ...c,
@@ -195,7 +195,7 @@ const Ei = S(function(i) {
195
195
  color: d
196
196
  }
197
197
  ) }) });
198
- }), O = class O extends $ {
198
+ }), B = class B extends M {
199
199
  constructor(e) {
200
200
  const {
201
201
  minimum: t = Number.MIN_SAFE_INTEGER,
@@ -215,7 +215,7 @@ const Ei = S(function(i) {
215
215
  }
216
216
  static getFieldCreationSchema() {
217
217
  return [
218
- new O({
218
+ new B({
219
219
  label: "Minimum",
220
220
  description: "Minimum value",
221
221
  integers: !0,
@@ -223,7 +223,7 @@ const Ei = S(function(i) {
223
223
  identifier: "minimum",
224
224
  formValidators: [this._validateMin]
225
225
  }),
226
- new O({
226
+ new B({
227
227
  label: "Maximum",
228
228
  description: "Maximum value",
229
229
  integers: !0,
@@ -231,7 +231,7 @@ const Ei = S(function(i) {
231
231
  identifier: "maximum",
232
232
  formValidators: [this._validateMax]
233
233
  }),
234
- new ce({
234
+ new ue({
235
235
  label: "Integers",
236
236
  description: "Whole numbers only",
237
237
  required: !1,
@@ -263,18 +263,18 @@ const Ei = S(function(i) {
263
263
  static deserialize(e) {
264
264
  if (e.type !== "number")
265
265
  throw new Error("Type mismatch.");
266
- return new O(e);
266
+ return new B(e);
267
267
  }
268
268
  getInput(e) {
269
- return /* @__PURE__ */ r(Ei, { field: this, ...e });
269
+ return /* @__PURE__ */ r(ki, { field: this, ...e });
270
270
  }
271
271
  };
272
- m(O, "fieldTypeName", "Number"), m(O, "fieldTypeDescription", "Allows specifying a number within a given range."), m(O, "Icon", Rt), m(O, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(O, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
273
- let G = O;
274
- const Ai = S(function(i) {
275
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = W(i), f = de(n), d = c.value ? c.value.split("T")[0] : "";
276
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(oe.Input, { ...a, ...c, type: "date", id: e, color: f, value: d }) }) });
277
- }), X = class X extends $ {
272
+ m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", jt), m(B, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(B, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
273
+ let Q = B;
274
+ const Di = T(function(i) {
275
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = c.value ? c.value.split("T")[0] : "";
276
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(le.Input, { ...a, ...c, type: "date", id: e, color: f, value: d }) }) });
277
+ }), Z = class Z extends M {
278
278
  constructor(e) {
279
279
  super({ ...e, type: "date" });
280
280
  m(this, "onlyValidateAfterTouched", !1);
@@ -288,15 +288,15 @@ const Ai = S(function(i) {
288
288
  static deserialize(e) {
289
289
  if (e.type !== "date")
290
290
  throw new Error("Type mismatch.");
291
- return new X(e);
291
+ return new Z(e);
292
292
  }
293
293
  getInput(e) {
294
- return /* @__PURE__ */ r(Ai, { field: this, ...e });
294
+ return /* @__PURE__ */ r(Di, { field: this, ...e });
295
295
  }
296
296
  };
297
- m(X, "fieldTypeName", "Date"), m(X, "fieldTypeDescription", "Allows specifying a date."), m(X, "Icon", Nt);
298
- let Be = X;
299
- class Ce extends $ {
297
+ m(Z, "fieldTypeName", "Date"), m(Z, "fieldTypeDescription", "Allows specifying a date."), m(Z, "Icon", Ht);
298
+ let We = Z;
299
+ class Ce extends M {
300
300
  constructor(e) {
301
301
  const { minLength: t, maxLength: n = 5e3, ...o } = e;
302
302
  super(o);
@@ -307,7 +307,7 @@ class Ce extends $ {
307
307
  static getFieldCreationSchema() {
308
308
  return [
309
309
  // min, max
310
- new G({
310
+ new Q({
311
311
  label: "Minimum length",
312
312
  description: "Minimum number of characters",
313
313
  required: !1,
@@ -317,7 +317,7 @@ class Ce extends $ {
317
317
  formValidators: [this._validateMin],
318
318
  integers: !0
319
319
  }),
320
- new G({
320
+ new Q({
321
321
  label: "Maximum length",
322
322
  description: "Maximum number of characters",
323
323
  required: !1,
@@ -365,10 +365,10 @@ m(Ce, "_validateMax", (e, t) => {
365
365
  const { minimum_length: n } = t;
366
366
  return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
367
367
  });
368
- const Pi = S(function(i) {
369
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = W(i), d = de(n);
370
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(oe.Input, { ...f, ...c, type: a.inputType, id: e, color: d }) }) });
371
- }), J = class J extends Ce {
368
+ const _i = T(function(i) {
369
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), d = fe(n);
370
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(le.Input, { ...f, ...c, type: a.inputType, id: e, color: d }) }) });
371
+ }), ee = class ee extends Ce {
372
372
  constructor(e) {
373
373
  const { inputType: t = "text", ...n } = e, o = e.maxLength ? Math.min(500, e.maxLength) : 500, l = e.minLength ? Math.min(e.minLength, o) : void 0;
374
374
  super({ ...n, maxLength: o, minLength: l, type: "string" });
@@ -382,18 +382,18 @@ const Pi = S(function(i) {
382
382
  if (e.type !== "string")
383
383
  throw new Error("Type mismatch.");
384
384
  const { maximum_length: t, minimum_length: n, input_type: o, ...l } = e;
385
- return new J({ ...l, maxLength: t, minLength: n, inputType: o });
385
+ return new ee({ ...l, maxLength: t, minLength: n, inputType: o });
386
386
  }
387
387
  getInput(e) {
388
- return /* @__PURE__ */ r(Pi, { field: this, ...e });
388
+ return /* @__PURE__ */ r(_i, { field: this, ...e });
389
389
  }
390
390
  };
391
- m(J, "fieldTypeName", "Short Text"), m(J, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(J, "Icon", Bt);
392
- let he = J;
393
- const Li = S(function(i) {
394
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = W(i);
395
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(qt, { ...a, ...c, resize: "vertical", id: e, severity: n }) }) });
396
- }), Z = class Z extends Ce {
391
+ m(ee, "fieldTypeName", "Short Text"), m(ee, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(ee, "Icon", Ut);
392
+ let ge = ee;
393
+ const $i = T(function(i) {
394
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i);
395
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(Gt, { ...a, ...c, resize: "vertical", id: e, severity: n }) }) });
396
+ }), te = class te extends Ce {
397
397
  constructor(i) {
398
398
  const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
399
399
  super({ ...i, maxLength: e, minLength: t, type: "text" });
@@ -405,26 +405,26 @@ const Li = S(function(i) {
405
405
  if (i.type !== "text")
406
406
  throw new Error("Type mismatch.");
407
407
  const { maximum_length: e, minimum_length: t, ...n } = i;
408
- return new Z({ ...n, maxLength: e, minLength: t });
408
+ return new te({ ...n, maxLength: e, minLength: t });
409
409
  }
410
410
  getInput(i) {
411
- return /* @__PURE__ */ r(Li, { field: this, ...i });
411
+ return /* @__PURE__ */ r($i, { field: this, ...i });
412
412
  }
413
413
  };
414
- m(Z, "fieldTypeName", "Paragraph"), m(Z, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(Z, "Icon", Wt);
415
- let ge = Z;
416
- const Vi = S(function(i) {
417
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = W(i), { onChange: d, onBlur: u } = c, p = x(
414
+ m(te, "fieldTypeName", "Paragraph"), m(te, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(te, "Icon", Kt);
415
+ let be = te;
416
+ const Mi = T(function(i) {
417
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c, p = w(
418
418
  () => a.options.map((g) => ({ value: g.value, itemContent: g.label })),
419
419
  [a.options]
420
- ), h = E(
420
+ ), h = S(
421
421
  (g) => {
422
422
  d(g), u(g);
423
423
  },
424
424
  [d, u]
425
425
  );
426
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
427
- ft,
426
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
427
+ ht,
428
428
  {
429
429
  items: p,
430
430
  ...c,
@@ -435,143 +435,150 @@ const Vi = S(function(i) {
435
435
  ...f
436
436
  }
437
437
  ) }) });
438
- }), Fe = (s = "", i = []) => ({
438
+ }), Te = (s = "", i = []) => ({
439
439
  type: "section",
440
440
  fields: i,
441
441
  identifier: s,
442
442
  label: null,
443
443
  condition: null,
444
444
  conditional: !1
445
- }), Di = (s) => {
445
+ }), Oi = (s) => {
446
446
  if (!s)
447
447
  return;
448
448
  const i = s.fields;
449
449
  let e = [];
450
450
  const t = [];
451
451
  for (const n of i)
452
- n.type === "section" ? (e.length > 0 && (t.push(Fe(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
453
- return e.length > 0 && t.push(Fe("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
452
+ n.type === "section" ? (e.length > 0 && (t.push(Te(`AUTO_section-${i.indexOf(n)}`, e)), e = []), t.push(n)) : e.push(n);
453
+ return e.length > 0 && t.push(Te("AUTO_section-last", e)), { ...s, fields: t, description: s.description ?? "" };
454
454
  };
455
- function qe(s, i, e) {
455
+ function je(s, i, e) {
456
456
  const t = Array.from(s), [n] = t.splice(i, 1);
457
457
  if (!n)
458
458
  throw new Error("Could not find field to reorder.");
459
459
  return t.splice(e, 0, n), t;
460
460
  }
461
- function ki(s, i, e) {
461
+ function Ri(s, i, e) {
462
462
  const t = Array.from(s);
463
463
  return t[i] = e, t;
464
464
  }
465
- function It(s, i, e) {
465
+ function Tt(s, i, e) {
466
466
  const t = Array.from(s ?? []);
467
467
  return t.splice(i, 0, e), t;
468
468
  }
469
- function Te(s, i) {
469
+ function Se(s, i) {
470
470
  const e = Array.from(s);
471
471
  return e.splice(i, 1), e;
472
472
  }
473
- const _i = (s, i) => {
473
+ const St = (s, i) => {
474
474
  if (typeof s == "string" && s.length > 0)
475
475
  return s;
476
476
  const e = /* @__PURE__ */ new Date();
477
- return `${hi(i)}-${e.getTime()}`;
478
- }, Ct = (s, i) => {
477
+ return `${wi(i)}-${e.getTime()}`;
478
+ }, zt = (s, i) => {
479
479
  if (!i)
480
480
  return null;
481
481
  for (const e of s)
482
482
  if (e.type === "section") {
483
- const t = Ct(e.fields, i);
483
+ const t = zt(e.fields, i);
484
484
  if (t)
485
485
  return t;
486
486
  } else if (e.identifier === i)
487
487
  return e;
488
488
  return null;
489
- }, Ie = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), $i = S(function(i) {
490
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = W(i), f = de(n), d = x(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: g } = a, [C, z] = le(""), [F, w] = le(""), A = F || o, P = F ? "red" : f, I = E(
491
- (v) => {
492
- u(v), p(v);
489
+ }, Fe = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Et = (s) => s.flatMap(
490
+ (i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
491
+ ).filter((i) => i !== null), He = (s, i) => {
492
+ let e = 1, t = `${s} (${e})`;
493
+ for (; i.includes(t); )
494
+ t = `${s} (${++e})`;
495
+ return t;
496
+ }, Ni = T(function(i) {
497
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c }, a] = H(i), f = fe(n), d = w(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: g } = a, [x, z] = ce(""), [F, v] = ce(""), P = F || o, L = F ? "red" : f, I = S(
498
+ (A) => {
499
+ u(A), p(A);
493
500
  },
494
501
  [u, p]
495
- ), L = E(
496
- (v) => {
497
- d.findIndex((T) => T.value === v.target.value.trim()) >= 0 ? w("All options must be unique") : v.target.value ? w("") : w("Option cannot be empty"), z(v.target.value);
502
+ ), V = S(
503
+ (A) => {
504
+ d.findIndex((R) => R.value === A.target.value.trim()) >= 0 ? v("All options must be unique") : A.target.value ? v("") : v("Option cannot be empty"), z(A.target.value);
498
505
  },
499
506
  [z, d]
500
- ), M = E(() => {
507
+ ), O = S(() => {
501
508
  if (F)
502
509
  return;
503
- if (!C.trim())
504
- return w("Option cannot be empty");
505
- const v = C.trim();
506
- I([...d, { value: v, label: v }]), z("");
507
- }, [C, F, I, d]), U = E(
508
- (v) => {
509
- v.key === "Enter" && (v.preventDefault(), M());
510
+ if (!x.trim())
511
+ return v("Option cannot be empty");
512
+ const A = x.trim();
513
+ I([...d, { value: A, label: A }]), z("");
514
+ }, [x, F, I, d]), Y = S(
515
+ (A) => {
516
+ A.key === "Enter" && (A.preventDefault(), O());
510
517
  },
511
- [M]
512
- ), R = E(
513
- (v) => {
514
- I(Te(d, v));
518
+ [O]
519
+ ), q = S(
520
+ (A) => {
521
+ I(Se(d, A));
515
522
  },
516
523
  [d, I]
517
- ), j = E(
518
- (v) => {
519
- if (!v.destination)
524
+ ), U = S(
525
+ (A) => {
526
+ if (!A.destination)
520
527
  return;
521
- const T = v.source.index, D = v.destination.index;
522
- I(qe(d, T, D));
528
+ const R = A.source.index, C = A.destination.index;
529
+ I(je(d, R, C));
523
530
  },
524
531
  [I, d]
525
532
  );
526
- return /* @__PURE__ */ r(ht, { onDragEnd: j, children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
527
- /* @__PURE__ */ r(q, { helpText: A, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: (!g || d.length === 0) && /* @__PURE__ */ b(y, { gap: "2", children: [
528
- /* @__PURE__ */ r(pe, { grow: "1", children: /* @__PURE__ */ r(
529
- oe.Input,
533
+ return /* @__PURE__ */ r(yt, { onDragEnd: U, children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
534
+ /* @__PURE__ */ r(j, { helpText: P, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: (!g || d.length === 0) && /* @__PURE__ */ b(y, { gap: "2", children: [
535
+ /* @__PURE__ */ r(he, { grow: "1", children: /* @__PURE__ */ r(
536
+ le.Input,
530
537
  {
531
538
  placeholder: "Press enter to add a new option",
532
539
  ...a,
533
540
  ...c,
534
- value: C,
535
- onChange: L,
536
- onKeyDown: U,
541
+ value: x,
542
+ onChange: V,
543
+ onKeyDown: Y,
537
544
  id: e,
538
- color: P,
545
+ color: L,
539
546
  onBlur: void 0
540
547
  }
541
548
  ) }),
542
549
  /* @__PURE__ */ r(
543
- se,
550
+ ae,
544
551
  {
545
552
  type: "button",
546
553
  "aria-label": "Add option",
547
554
  disabled: !!F || g,
548
- onClick: M,
549
- children: /* @__PURE__ */ r(Ve, {})
555
+ onClick: O,
556
+ children: /* @__PURE__ */ r(ke, {})
550
557
  }
551
558
  )
552
559
  ] }) }) }),
553
- /* @__PURE__ */ r(Ye, { droppableId: h, children: (v) => /* @__PURE__ */ b(y, { ...v.droppableProps, ref: v.innerRef, direction: "column", children: [
554
- d.map((T, D) => /* @__PURE__ */ r(
555
- Qe,
560
+ /* @__PURE__ */ r(Je, { droppableId: h, children: (A) => /* @__PURE__ */ b(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
561
+ d.map((R, C) => /* @__PURE__ */ r(
562
+ Ze,
556
563
  {
557
- draggableId: `${T.value}-draggable`,
558
- index: D,
564
+ draggableId: `${R.value}-draggable`,
565
+ index: C,
559
566
  isDragDisabled: g,
560
- children: ({ draggableProps: k, dragHandleProps: N, innerRef: fe }) => /* @__PURE__ */ r(
567
+ children: ({ draggableProps: E, dragHandleProps: _, innerRef: k }) => /* @__PURE__ */ r(
561
568
  y,
562
569
  {
563
- ...N,
564
- ...k,
565
- ref: fe,
570
+ ..._,
571
+ ...E,
572
+ ref: k,
566
573
  gap: "2",
567
574
  align: "center",
568
575
  justify: "between",
569
576
  mb: "1",
570
577
  asChild: !0,
571
- children: /* @__PURE__ */ b(Ne, { color: "gray", size: "2", children: [
572
- /* @__PURE__ */ r("span", { children: T.label }),
578
+ children: /* @__PURE__ */ b(qe, { color: "gray", size: "2", children: [
579
+ /* @__PURE__ */ r("span", { children: R.label }),
573
580
  /* @__PURE__ */ r(
574
- se,
581
+ ae,
575
582
  {
576
583
  size: "small",
577
584
  variant: "ghost",
@@ -579,20 +586,20 @@ const _i = (s, i) => {
579
586
  "aria-label": "Delete option",
580
587
  severity: "info",
581
588
  disabled: g,
582
- onClick: () => R(D),
583
- children: /* @__PURE__ */ r(mt, {})
589
+ onClick: () => q(C),
590
+ children: /* @__PURE__ */ r(gt, {})
584
591
  }
585
592
  )
586
593
  ] })
587
594
  }
588
595
  )
589
596
  },
590
- T.value
597
+ R.value
591
598
  )),
592
- v.placeholder
599
+ A.placeholder
593
600
  ] }) })
594
601
  ] }) });
595
- }), ee = class ee extends $ {
602
+ }), ie = class ie extends M {
596
603
  constructor(e) {
597
604
  const { minimum_length: t, maximum_length: n, ...o } = e;
598
605
  super({ ...o, type: "multi-string" });
@@ -607,7 +614,7 @@ const _i = (s, i) => {
607
614
  throw new Error("Expected an array.");
608
615
  }
609
616
  getInput(e) {
610
- return /* @__PURE__ */ r($i, { field: this, ...e });
617
+ return /* @__PURE__ */ r(Ni, { field: this, ...e });
611
618
  }
612
619
  serialize() {
613
620
  return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
@@ -628,12 +635,12 @@ const _i = (s, i) => {
628
635
  static deserialize(e) {
629
636
  if (e.type !== "multi-string")
630
637
  throw new Error("Type mismatch.");
631
- return new ee(e);
638
+ return new ie(e);
632
639
  }
633
640
  };
634
- m(ee, "fieldTypeName", "Multi-string"), m(ee, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ee, "Icon", jt);
635
- let Se = ee;
636
- class Ft extends $ {
641
+ m(ie, "fieldTypeName", "Multi-string"), m(ie, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ie, "Icon", Yt);
642
+ let ze = ie;
643
+ class At extends M {
637
644
  constructor(e) {
638
645
  super(e);
639
646
  m(this, "options");
@@ -652,7 +659,7 @@ class Ft extends $ {
652
659
  }
653
660
  static getFieldCreationSchema() {
654
661
  return [
655
- new Se({
662
+ new ze({
656
663
  label: "Options",
657
664
  description: "List possible options for the user to select from.",
658
665
  required: !0,
@@ -663,7 +670,7 @@ class Ft extends $ {
663
670
  ];
664
671
  }
665
672
  }
666
- const te = class te extends Ft {
673
+ const ne = class ne extends At {
667
674
  constructor(i) {
668
675
  super({ ...i, type: "select" });
669
676
  }
@@ -676,23 +683,23 @@ const te = class te extends Ft {
676
683
  static deserialize(i) {
677
684
  if (i.type !== "select")
678
685
  throw new Error("Type mismatch.");
679
- return new te(i);
686
+ return new ne(i);
680
687
  }
681
688
  getInput(i) {
682
- return /* @__PURE__ */ r(Vi, { field: this, ...i });
689
+ return /* @__PURE__ */ r(Mi, { field: this, ...i });
683
690
  }
684
691
  };
685
- m(te, "fieldTypeName", "Dropdown"), m(te, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(te, "Icon", Ht);
686
- let ze = te;
687
- const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [], Oi = S(function(i) {
688
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = W(i), { onChange: d, onBlur: u } = c, p = x(() => Mi(c.value), [c.value]), h = E(
692
+ m(ne, "fieldTypeName", "Dropdown"), m(ne, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(ne, "Icon", Qt);
693
+ let Ee = ne;
694
+ const Bi = (s) => s ? Array.isArray(s) ? s : [s] : [], qi = T(function(i) {
695
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d, onBlur: u } = c, p = w(() => Bi(c.value), [c.value]), h = S(
689
696
  (g) => {
690
697
  d(g), u(g);
691
698
  },
692
699
  [d, u]
693
700
  );
694
- return /* @__PURE__ */ r(q, { helpText: o, severity: n, children: /* @__PURE__ */ r(B, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
695
- Ut,
701
+ return /* @__PURE__ */ r(j, { helpText: o, severity: n, children: /* @__PURE__ */ r(W, { severity: n, inputId: e, labelId: t, label: l, children: /* @__PURE__ */ r(
702
+ Xt,
696
703
  {
697
704
  value: p,
698
705
  onValueChange: h,
@@ -704,7 +711,7 @@ const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [], Oi = S(function(i) {
704
711
  ...f
705
712
  }
706
713
  ) }) });
707
- }), ie = class ie extends Ft {
714
+ }), re = class re extends At {
708
715
  constructor(i) {
709
716
  super({ ...i, type: "multi-select" });
710
717
  }
@@ -722,22 +729,22 @@ const Mi = (s) => s ? Array.isArray(s) ? s : [s] : [], Oi = S(function(i) {
722
729
  static deserialize(i) {
723
730
  if (i.type !== "multi-select")
724
731
  throw new Error("Type mismatch.");
725
- return new ie(i);
732
+ return new re(i);
726
733
  }
727
734
  getInput(i) {
728
- return /* @__PURE__ */ r(Oi, { field: this, ...i });
735
+ return /* @__PURE__ */ r(qi, { field: this, ...i });
729
736
  }
730
737
  };
731
- m(ie, "fieldTypeName", "Multi-select"), m(ie, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(ie, "Icon", Gt);
732
- let Ee = ie;
733
- const Ri = S(function({ field: i, ...e }) {
734
- const [{ value: t }] = Ue(i.options.clonedFieldIdentifier), n = x(() => {
738
+ m(re, "fieldTypeName", "Multi-select"), m(re, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(re, "Icon", Jt);
739
+ let Ae = re;
740
+ const Wi = T(function({ field: i, ...e }) {
741
+ const [{ value: t }] = Ye(i.options.clonedFieldIdentifier), n = w(() => {
735
742
  const o = i.options.getFieldToClone(t);
736
- return o ? $e(o) : null;
743
+ return o ? Me(o) : null;
737
744
  }, [i.options, t]);
738
- return Pe(n, e);
745
+ return Le(n, e);
739
746
  });
740
- class Ae extends $ {
747
+ class Pe extends M {
741
748
  constructor(e, t) {
742
749
  super({ ...e, type: "custom" });
743
750
  m(this, "Component");
@@ -753,28 +760,28 @@ class Ae extends $ {
753
760
  return /* @__PURE__ */ r(t, { field: this, ...e });
754
761
  }
755
762
  }
756
- m(Ae, "fieldTypeName", "Custom"), m(Ae, "fieldTypeDescription", "Allows re-rendering of field already in the form");
757
- class Ni extends Ae {
763
+ m(Pe, "fieldTypeName", "Custom"), m(Pe, "fieldTypeDescription", "Allows re-rendering of field already in the form");
764
+ class ji extends Pe {
758
765
  constructor(i) {
759
- super(i, Ri);
766
+ super(i, Wi);
760
767
  }
761
768
  }
762
- const Bi = S(function(i) {
763
- const { field: e, ...t } = i, { label: n, description: o, fields: l, condition: c } = e, { values: a, setFieldValue: f } = ue(), d = c != null && c.identifier ? ae(a, c.identifier) : void 0, u = x(() => zt(c, d), [c, d]);
764
- ye(() => {
769
+ const Hi = T(function(i) {
770
+ const { field: e, ...t } = i, { label: n, description: o, fields: l, condition: c } = e, { values: a, setFieldValue: f } = me(), d = c != null && c.identifier ? de(a, c.identifier) : void 0, u = w(() => Vt(c, d), [c, d]);
771
+ ve(() => {
765
772
  if (!u)
766
773
  for (const h of l)
767
774
  f(h.getId(), "").then();
768
775
  }, [u, l, f]);
769
- const p = Et(l, t);
770
- return u ? n ? /* @__PURE__ */ r(be, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
776
+ const p = kt(l, t);
777
+ return u ? n ? /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
771
778
  /* @__PURE__ */ b(y, { direction: "column", children: [
772
779
  /* @__PURE__ */ r(De, { as: "h3", size: "3", children: n }),
773
- /* @__PURE__ */ r(V, { className: _e.description, children: o })
780
+ /* @__PURE__ */ r(D, { className: $e.description, children: o })
774
781
  ] }),
775
782
  p
776
783
  ] }) }) : p : null;
777
- }), ne = class ne extends xt {
784
+ }), oe = class oe extends Ct {
778
785
  constructor(e) {
779
786
  const { label: t = null, fields: n, condition: o = null, conditional: l, ...c } = e;
780
787
  super({ ...c, type: "section" });
@@ -785,14 +792,14 @@ const Bi = S(function(i) {
785
792
  }
786
793
  static getFieldCreationSchema(e) {
787
794
  return e.length === 0 ? [] : [
788
- new ce({
795
+ new ue({
789
796
  label: "Conditional",
790
797
  description: "Conditionally show or hide this section.",
791
798
  identifier: "conditional",
792
799
  required: !1
793
800
  }),
794
801
  // Declare a section that will hold options for the condition (if any).
795
- new ne({
802
+ new oe({
796
803
  label: "Conditional settings",
797
804
  identifier: "conditional-settings",
798
805
  // This section will only be rendered if the above "Conditional" field is checked.
@@ -804,7 +811,7 @@ const Bi = S(function(i) {
804
811
  fields: [
805
812
  // Declare a select field that will be used to select the field against which we will check the
806
813
  // condition. This must be selected before the next field is rendered.
807
- new ze({
814
+ new Ee({
808
815
  label: "Field",
809
816
  description: "The field to use for the condition.",
810
817
  // The options (for the field against which we will check the condition) are all the labels of
@@ -821,7 +828,7 @@ const Bi = S(function(i) {
821
828
  // Declare a custom field that will be used to input a value for the condition. The value of the
822
829
  // conditional field selected in the previous step must be equal to the value the user inputs into
823
830
  // this field for the section to be rendered.
824
- new Ni({
831
+ new ji({
825
832
  label: "Value",
826
833
  identifier: "condition.value",
827
834
  required: !0,
@@ -848,8 +855,8 @@ const Bi = S(function(i) {
848
855
  var n;
849
856
  if (e.type !== "section")
850
857
  throw new Error("Invalid type");
851
- const t = ((n = e.fields) == null ? void 0 : n.map(Tt)) ?? [];
852
- return new ne({ ...e, fields: t });
858
+ const t = ((n = e.fields) == null ? void 0 : n.map(Pt)) ?? [];
859
+ return new oe({ ...e, fields: t });
853
860
  }
854
861
  conditional() {
855
862
  return this.condition !== null;
@@ -866,43 +873,43 @@ const Bi = S(function(i) {
866
873
  getErrors(e) {
867
874
  const t = {};
868
875
  for (const n of this.fields) {
869
- const o = n.getId(), l = n.getError(ae(e, o), e);
870
- l && Je(t, n.getId(), l);
876
+ const o = n.getId(), l = n.getError(de(e, o), e);
877
+ l && tt(t, n.getId(), l);
871
878
  }
872
879
  return t;
873
880
  }
874
881
  getInput(e) {
875
- return /* @__PURE__ */ r(Bi, { field: this, ...e });
882
+ return /* @__PURE__ */ r(Hi, { field: this, ...e });
876
883
  }
877
884
  };
878
- m(ne, "fieldTypeName", "Section"), m(ne, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
879
- let K = ne;
880
- const qi = "_previewImage_1ig84_1", Wi = {
881
- previewImage: qi
882
- }, Ze = (s) => {
885
+ m(oe, "fieldTypeName", "Section"), m(oe, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
886
+ let K = oe;
887
+ const Ui = "_previewImage_1ig84_1", Gi = {
888
+ previewImage: Ui
889
+ }, it = (s) => {
883
890
  const i = ["byte", "kilobyte", "megabyte"];
884
891
  let e = s, t = 0;
885
892
  for (; e > 1024 && t < i.length - 1; )
886
893
  e /= 1024, t++;
887
894
  return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
888
- }, ji = S(function(i) {
889
- var P;
890
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = W(i), { onChange: d } = c, u = de(n), p = mi(null), { value: h } = c, g = x(() => o || (a.maxFileSize ? `Maximum file size: ${Ze(a.maxFileSize)}` : null), [a.maxFileSize, o]), C = E(() => {
895
+ }, Ki = T(function(i) {
896
+ var L;
897
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: l, fieldProps: c, field: a }, f] = H(i), { onChange: d } = c, u = fe(n), p = yi(null), { value: h } = c, g = w(() => o || (a.maxFileSize ? `Maximum file size: ${it(a.maxFileSize)}` : null), [a.maxFileSize, o]), x = S(() => {
891
898
  var I;
892
899
  (I = p.current) == null || I.click();
893
- }, []), z = E(
900
+ }, []), z = S(
894
901
  (I) => {
895
- const L = [...h];
896
- L.splice(I, 1), d({ target: { files: L } });
902
+ const V = [...h];
903
+ V.splice(I, 1), d({ target: { files: V } });
897
904
  },
898
905
  [h, d]
899
- ), F = h ? "Select new files" : "Select files", w = h ? "Select new file" : "Select a file", A = a.maxFiles > 1 ? F : w;
906
+ ), F = h ? "Select new files" : "Select files", v = h ? "Select new file" : "Select a file", P = a.maxFiles > 1 ? F : v;
900
907
  return /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
901
- /* @__PURE__ */ r(q, { helpText: g, severity: n, children: /* @__PURE__ */ b(B, { severity: n, inputId: e, labelId: t, label: l, children: [
902
- /* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(pe, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(H, { ...f, onClick: C, children: [
903
- /* @__PURE__ */ r(pt, {}),
908
+ /* @__PURE__ */ r(j, { helpText: g, severity: n, children: /* @__PURE__ */ b(W, { severity: n, inputId: e, labelId: t, label: l, children: [
909
+ /* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(he, { width: "max-content", asChild: !0, children: /* @__PURE__ */ b(G, { ...f, onClick: x, children: [
910
+ /* @__PURE__ */ r(bt, {}),
904
911
  " ",
905
- A
912
+ P
906
913
  ] }) }) }),
907
914
  /* @__PURE__ */ r(
908
915
  "input",
@@ -911,7 +918,7 @@ const qi = "_previewImage_1ig84_1", Wi = {
911
918
  type: "file",
912
919
  ref: p,
913
920
  id: e,
914
- accept: (P = a.extensions) == null ? void 0 : P.join(","),
921
+ accept: (L = a.extensions) == null ? void 0 : L.join(","),
915
922
  multiple: a.maxFiles > 1,
916
923
  color: u,
917
924
  style: { display: "none" },
@@ -920,46 +927,46 @@ const qi = "_previewImage_1ig84_1", Wi = {
920
927
  }
921
928
  )
922
929
  ] }) }),
923
- Array.isArray(h) && h.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: h.map((I, L) => /* @__PURE__ */ r(
924
- Hi,
930
+ Array.isArray(h) && h.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: h.map((I, V) => /* @__PURE__ */ r(
931
+ Yi,
925
932
  {
926
933
  field: a,
927
934
  file: I,
928
- onRemove: () => z(L),
935
+ onRemove: () => z(V),
929
936
  disabled: f.disabled
930
937
  },
931
- L
938
+ V
932
939
  )) })
933
940
  ] });
934
- }), Hi = S(function({ file: i, field: e, onRemove: t, disabled: n }) {
935
- const [o, l] = le(null), c = x(() => o && e.getError([o]), [e, o]), { url: a, name: f, size: d } = x(() => {
941
+ }), Yi = T(function({ file: i, field: e, onRemove: t, disabled: n }) {
942
+ const [o, l] = ce(null), c = w(() => o && e.getError([o]), [e, o]), { url: a, name: f, size: d } = w(() => {
936
943
  let u = null, p, h;
937
- return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (p = o.name, h = Ze(o.size)) : (p = "Downloading...", h = "..."), { url: u, name: p, size: h };
944
+ return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (p = o.name, h = it(o.size)) : (p = "Downloading...", h = "..."), { url: u, name: p, size: h };
938
945
  }, [o]);
939
- return ye(() => {
946
+ return ve(() => {
940
947
  i instanceof Promise ? i.then(l) : l(i);
941
- }, [i]), /* @__PURE__ */ r(be, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
948
+ }, [i]), /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: { initial: "column", sm: "row" }, gap: "3", justify: "between", children: [
942
949
  /* @__PURE__ */ b(y, { direction: "row", gap: "3", align: "center", grow: "1", shrink: "0", children: [
943
950
  /* @__PURE__ */ r(
944
- se,
951
+ ae,
945
952
  {
946
953
  severity: "info",
947
954
  variant: "outline",
948
955
  "aria-label": `Remove ${f}`,
949
956
  disabled: n,
950
957
  onClick: t,
951
- children: /* @__PURE__ */ r(mt, {})
958
+ children: /* @__PURE__ */ r(gt, {})
952
959
  }
953
960
  ),
954
961
  /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
955
- /* @__PURE__ */ r(V, { children: f }),
956
- /* @__PURE__ */ r(V, { size: "1", children: d }),
957
- c && /* @__PURE__ */ r(V, { size: "1", severity: "danger", children: c })
962
+ /* @__PURE__ */ r(D, { children: f }),
963
+ /* @__PURE__ */ r(D, { size: "1", children: d }),
964
+ c && /* @__PURE__ */ r(D, { size: "1", severity: "danger", children: c })
958
965
  ] })
959
966
  ] }),
960
- a && /* @__PURE__ */ r("img", { className: Wi.previewImage, src: a, alt: f })
967
+ a && /* @__PURE__ */ r("img", { className: Gi.previewImage, src: a, alt: f })
961
968
  ] }) });
962
- }), ot = 50 * 1024 * 1024, re = class re extends $ {
969
+ }), at = 50 * 1024 * 1024, se = class se extends M {
963
970
  constructor(e) {
964
971
  const { extensions: t, maximum_files: n, maximum_size: o, ...l } = e;
965
972
  super({ ...l, type: "upload" });
@@ -977,7 +984,7 @@ const qi = "_previewImage_1ig84_1", Wi = {
977
984
  }
978
985
  static getFieldCreationSchema() {
979
986
  return [
980
- new G({
987
+ new Q({
981
988
  label: "How many files can be uploaded?",
982
989
  description: "By default, only one file can be uploaded.",
983
990
  required: !1,
@@ -985,16 +992,16 @@ const qi = "_previewImage_1ig84_1", Wi = {
985
992
  maximum: 10,
986
993
  identifier: "maximum_files"
987
994
  }),
988
- new G({
995
+ new Q({
989
996
  label: "What is the maximum size of each file?",
990
997
  description: "Maximum file size in bytes.",
991
998
  required: !1,
992
999
  identifier: "maximum_size",
993
1000
  minimum: 1,
994
- maximum: ot,
1001
+ maximum: at,
995
1002
  integers: !0
996
1003
  }),
997
- new Ee({
1004
+ new Ae({
998
1005
  label: "Accepted file types",
999
1006
  description: "Types of allowed files to upload. If left blank, all files will be accepted.",
1000
1007
  required: !1,
@@ -1025,10 +1032,10 @@ const qi = "_previewImage_1ig84_1", Wi = {
1025
1032
  ];
1026
1033
  }
1027
1034
  getFieldValidators() {
1028
- const e = super.getFieldValidators(), t = this.maxFileSize ?? ot, n = this.maxFiles ?? 1;
1035
+ const e = super.getFieldValidators(), t = this.maxFileSize ?? at, n = this.maxFiles ?? 1;
1029
1036
  return e.push((o) => {
1030
1037
  if (o && o.some((l) => l.size > t))
1031
- return `Files must be at most ${Ze(t)}.`;
1038
+ return `Files must be at most ${it(t)}.`;
1032
1039
  }), e.push((o) => {
1033
1040
  if (o && o.length > n)
1034
1041
  return `You can only upload ${n} files.`;
@@ -1045,46 +1052,46 @@ const qi = "_previewImage_1ig84_1", Wi = {
1045
1052
  static deserialize(e) {
1046
1053
  if (e.type !== "upload")
1047
1054
  throw new Error("Type mismatch.");
1048
- return new re(e);
1055
+ return new se(e);
1049
1056
  }
1050
1057
  getInput(e) {
1051
- return /* @__PURE__ */ r(ji, { field: this, ...e });
1058
+ return /* @__PURE__ */ r(Ki, { field: this, ...e });
1052
1059
  }
1053
1060
  };
1054
- m(re, "fieldTypeName", "Upload"), m(re, "fieldTypeDescription", "Allows a file to be uploaded."), m(re, "Icon", pt);
1055
- let We = re;
1056
- const et = {
1057
- date: Be,
1058
- number: G,
1059
- boolean: ce,
1060
- select: ze,
1061
- string: he,
1062
- text: ge,
1063
- custom: Ae,
1064
- upload: We,
1061
+ m(se, "fieldTypeName", "Upload"), m(se, "fieldTypeDescription", "Allows a file to be uploaded."), m(se, "Icon", bt);
1062
+ let Ue = se;
1063
+ const nt = {
1064
+ date: We,
1065
+ number: Q,
1066
+ boolean: ue,
1067
+ select: Ee,
1068
+ string: ge,
1069
+ text: be,
1070
+ custom: Pe,
1071
+ upload: Ue,
1065
1072
  // TODO: Underscore
1066
- "multi-string": Se,
1067
- "multi-select": Ee
1068
- }, Tt = (s) => {
1073
+ "multi-string": ze,
1074
+ "multi-select": Ae
1075
+ }, Pt = (s) => {
1069
1076
  const i = s.type;
1070
- return et[i].deserialize(s);
1071
- }, $e = (s) => s.type === "section" ? K.deserialize(s) : Tt(s);
1072
- function St(s, i = {}) {
1077
+ return nt[i].deserialize(s);
1078
+ }, Me = (s) => s.type === "section" ? K.deserialize(s) : Pt(s);
1079
+ function Lt(s, i = {}) {
1073
1080
  const { readonly: e = !1 } = i;
1074
1081
  return {
1075
1082
  title: s.title,
1076
1083
  description: s.description,
1077
- fields: s.fields.map((t) => $e(t)),
1084
+ fields: s.fields.map((t) => Me(t)),
1078
1085
  meta: { readonly: e }
1079
1086
  };
1080
1087
  }
1081
- function je(s) {
1088
+ function Ge(s) {
1082
1089
  return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
1083
1090
  }
1084
- function zt(s, i) {
1091
+ function Vt(s, i) {
1085
1092
  if (!s)
1086
1093
  return !0;
1087
- if (je(i) || je(s.value))
1094
+ if (Ge(i) || Ge(s.value))
1088
1095
  throw new Error("Conditions do not support file uploads");
1089
1096
  const e = Array.isArray(i) ? i.map((n) => typeof n == "string" ? n : n.value) : i, t = Array.isArray(s.value) ? s.value.map((n) => typeof n == "string" ? n : n.value) : s.value;
1090
1097
  if (Array.isArray(t) && Array.isArray(e)) {
@@ -1095,35 +1102,35 @@ function zt(s, i) {
1095
1102
  }
1096
1103
  return t === i;
1097
1104
  }
1098
- const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s, i) => {
1099
- const e = x(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
1105
+ const Le = (s, i) => w(() => !i || !s ? null : s.getInput(i), [s, i]), kt = (s, i) => {
1106
+ const e = w(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
1100
1107
  return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
1101
- }, Le = (s) => Object.keys(s).length > 0, At = async (s, i) => {
1108
+ }, Ve = (s) => Object.keys(s).length > 0, Dt = async (s, i) => {
1102
1109
  const e = {};
1103
1110
  for (const t of s.fields)
1104
1111
  if (t instanceof K) {
1105
1112
  if (t.condition) {
1106
1113
  const { identifier: n } = t.condition;
1107
- if (!zt(t.condition, ae(i, n)))
1114
+ if (!Vt(t.condition, de(i, n)))
1108
1115
  continue;
1109
1116
  }
1110
1117
  Object.assign(e, t.getErrors(i));
1111
1118
  } else {
1112
- if (!(t instanceof $))
1119
+ if (!(t instanceof M))
1113
1120
  throw new Error("Invalid field type");
1114
- const n = t.getId(), o = t.getError(ae(i, n), i);
1115
- o && Je(e, n, o);
1121
+ const n = t.getId(), o = t.getError(de(i, n), i);
1122
+ o && tt(e, n, o);
1116
1123
  }
1117
- if (Le(e))
1124
+ if (Ve(e))
1118
1125
  return e;
1119
- }, Ui = [null, void 0], tt = (s, i) => s.reduce((e, t) => t instanceof K ? { ...e, ...tt(t.fields, i) } : (Ui.includes(ae(e, t.getId())) && Je(e, t.getId(), ""), e), i), Gi = () => {
1126
+ }, Qi = [null, void 0], rt = (s, i) => s.reduce((e, t) => t instanceof K ? { ...e, ...rt(t.fields, i) } : (Qi.includes(de(e, t.getId())) && tt(e, t.getId(), ""), e), i), Xi = () => {
1120
1127
  throw new Error("onSubmit must be provided if form is not readonly.");
1121
- }, it = S(
1122
- ve((s, i) => {
1128
+ }, ot = T(
1129
+ we((s, i) => {
1123
1130
  const {
1124
1131
  schema: e,
1125
1132
  values: t = {},
1126
- onSubmit: n = Gi,
1133
+ onSubmit: n = Xi,
1127
1134
  submitText: o = "Submit",
1128
1135
  cancelText: l,
1129
1136
  onCancel: c,
@@ -1132,43 +1139,43 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1132
1139
  hideTitle: f = !e.title,
1133
1140
  hideDescription: d,
1134
1141
  className: u
1135
- } = s, { readonly: p } = e.meta, h = x(() => crypto.randomUUID(), []), g = Ge({
1136
- initialValues: tt(e.fields, t),
1142
+ } = s, { readonly: p } = e.meta, h = w(() => crypto.randomUUID(), []), g = Qe({
1143
+ initialValues: rt(e.fields, t),
1137
1144
  onSubmit: n,
1138
- validate: (A) => At(e, A),
1145
+ validate: (P) => Dt(e, P),
1139
1146
  // only validate the entire form on submit
1140
1147
  validateOnBlur: !1,
1141
1148
  validateOnChange: !1
1142
- }), { dirty: C } = g, z = x(
1149
+ }), { dirty: x } = g, z = w(
1143
1150
  () => typeof e.title == "string" ? /* @__PURE__ */ r(De, { children: e.title }) : e.title,
1144
1151
  [e.title]
1145
- ), F = x(
1146
- () => typeof e.description == "string" ? /* @__PURE__ */ r(V, { className: _e.description, children: e.description }) : e.description,
1152
+ ), F = w(
1153
+ () => typeof e.description == "string" ? /* @__PURE__ */ r(D, { className: $e.description, children: e.description }) : e.description,
1147
1154
  [e.description]
1148
- ), w = Et(e.fields, { formId: h, disabled: p });
1149
- return ye(() => {
1150
- C && a && a();
1151
- }, [C, a]), /* @__PURE__ */ r(Ke, { value: g, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: h, onSubmit: g.handleSubmit, children: [
1152
- !f && /* @__PURE__ */ r(be, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
1155
+ ), v = kt(e.fields, { formId: h, disabled: p });
1156
+ return ve(() => {
1157
+ x && a && a();
1158
+ }, [x, a]), /* @__PURE__ */ r(Xe, { value: g, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ b("form", { id: h, onSubmit: g.handleSubmit, children: [
1159
+ !f && /* @__PURE__ */ r(ye, { children: /* @__PURE__ */ b(y, { direction: "column", gap: "1", children: [
1153
1160
  z,
1154
1161
  !d && F
1155
1162
  ] }) }),
1156
- w,
1163
+ v,
1157
1164
  !p && /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
1158
- l && /* @__PURE__ */ r(H, { type: "button", variant: "soft", onClick: c, children: l }),
1159
- /* @__PURE__ */ r(H, { type: "submit", disabled: !g.isValid, children: o })
1165
+ l && /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: c, children: l }),
1166
+ /* @__PURE__ */ r(G, { type: "submit", disabled: !g.isValid, children: o })
1160
1167
  ] })
1161
1168
  ] }) }) });
1162
1169
  })
1163
- ), zn = S(
1164
- ve((s, i) => {
1165
- const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = _(gt(e.form_revision)), { sdk: l } = bt();
1170
+ ), Ln = T(
1171
+ we((s, i) => {
1172
+ const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = $(vt(e.form_revision)), { sdk: l } = wt();
1166
1173
  if (!o)
1167
1174
  throw new Error(
1168
1175
  `Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
1169
1176
  );
1170
- const c = x(() => St(o, { readonly: !0 }), [o]), a = x(() => {
1171
- const f = gi(e.offline_id)(l.store.getState()) ?? [], d = {};
1177
+ const c = w(() => Lt(o, { readonly: !0 }), [o]), a = w(() => {
1178
+ const f = xi(e.offline_id)(l.store.getState()) ?? [], d = {};
1172
1179
  for (const u of f) {
1173
1180
  const p = l.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((g) => {
1174
1181
  if (!g.success)
@@ -1180,7 +1187,7 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1180
1187
  return { ...e.values, ...d };
1181
1188
  }, [l.files, l.store, e.offline_id, e.values]);
1182
1189
  return /* @__PURE__ */ r(
1183
- it,
1190
+ ot,
1184
1191
  {
1185
1192
  ref: i,
1186
1193
  schema: c,
@@ -1190,36 +1197,36 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1190
1197
  }
1191
1198
  );
1192
1199
  })
1193
- ), Ki = "_favoriteIcon_1bixi_1", Yi = "_regularIcon_1bixi_9", st = {
1194
- favoriteIcon: Ki,
1195
- regularIcon: Yi
1196
- }, Oe = "organization:", Re = "user:", En = S(
1197
- ve((s, i) => {
1198
- const { maxResults: e = 20, ...t } = s, [n, o] = le(""), [l, c] = le(""), { sdk: a } = bt(), f = x(() => {
1199
- const w = { maxResults: e, searchTerm: n };
1200
- return l && (l.startsWith(Oe) ? w.owner_organization = parseInt(l.slice(Oe.length)) : l.startsWith(Re) && (w.owner_user = parseInt(l.slice(Re.length)))), w;
1201
- }, [n, e, l]), d = _(bi(f)) ?? [], u = _(yi), p = E(
1202
- (w) => {
1203
- w.favorite ? a.userForms.unfavorite(w.offline_id).then() : a.userForms.favorite(w.offline_id).then();
1200
+ ), Ji = "_favoriteIcon_1bixi_1", Zi = "_regularIcon_1bixi_9", ct = {
1201
+ favoriteIcon: Ji,
1202
+ regularIcon: Zi
1203
+ }, Ne = "organization:", Be = "user:", Vn = T(
1204
+ we((s, i) => {
1205
+ const { maxResults: e = 20, ...t } = s, [n, o] = ce(""), [l, c] = ce(""), { sdk: a } = wt(), f = w(() => {
1206
+ const v = { maxResults: e, searchTerm: n };
1207
+ return l && (l.startsWith(Ne) ? v.owner_organization = parseInt(l.slice(Ne.length)) : l.startsWith(Be) && (v.owner_user = parseInt(l.slice(Be.length)))), v;
1208
+ }, [n, e, l]), d = $(Ii(f)) ?? [], u = $(Fi), p = S(
1209
+ (v) => {
1210
+ v.favorite ? a.userForms.unfavorite(v.offline_id).then() : a.userForms.favorite(v.offline_id).then();
1204
1211
  },
1205
1212
  [a]
1206
- ), h = x(() => {
1207
- const w = a.store.getState(), A = {};
1208
- for (const P of Object.values(u)) {
1209
- const I = yt(P.owner_organization || -1)(w);
1210
- I && (A[`${Oe}${I.id}`] = I.name);
1211
- const L = Xe(P.owner_user || -1)(w);
1212
- L && (A[`${Re}${L.id}`] = L.username);
1213
+ ), h = w(() => {
1214
+ const v = a.store.getState(), P = {};
1215
+ for (const L of Object.values(u)) {
1216
+ const I = xt(L.owner_organization || -1)(v);
1217
+ I && (P[`${Ne}${I.id}`] = I.name);
1218
+ const V = et(L.owner_user || -1)(v);
1219
+ V && (P[`${Be}${V.id}`] = V.username);
1213
1220
  }
1214
- return Object.entries(A).map(([P, I]) => ({ itemContent: I, value: P }));
1215
- }, [u, a.store]), g = E((w) => {
1216
- o(w.currentTarget.value);
1217
- }, []), z = (_(vi) || 0) - d.length, F = d.length == e && z > 0 ? `Only the first ${e} results are shown (${z} hidden)` : z > 0 && `${z} hidden forms`;
1221
+ return Object.entries(P).map(([L, I]) => ({ itemContent: I, value: L }));
1222
+ }, [u, a.store]), g = S((v) => {
1223
+ o(v.currentTarget.value);
1224
+ }, []), z = ($(Ci) || 0) - d.length, F = d.length == e && z > 0 ? `Only the first ${e} results are shown (${z} hidden)` : z > 0 && `${z} hidden forms`;
1218
1225
  return /* @__PURE__ */ b(y, { ref: i, direction: "column", gap: "2", children: [
1219
1226
  /* @__PURE__ */ b(y, { gap: "2", grow: "1", children: [
1220
- /* @__PURE__ */ r(pe, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(oe.Root, { size: "3", children: /* @__PURE__ */ r(oe.Input, { placeholder: "Filter", value: n, onChange: g }) }) }),
1227
+ /* @__PURE__ */ r(he, { grow: "1", asChild: !0, children: /* @__PURE__ */ r(le.Root, { size: "3", children: /* @__PURE__ */ r(le.Input, { placeholder: "Filter", value: n, onChange: g }) }) }),
1221
1228
  /* @__PURE__ */ r(
1222
- ft,
1229
+ ht,
1223
1230
  {
1224
1231
  items: h,
1225
1232
  value: l,
@@ -1229,79 +1236,79 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1229
1236
  }
1230
1237
  )
1231
1238
  ] }),
1232
- d.length > 0 && /* @__PURE__ */ r(ke.Root, { children: d.map((w) => /* @__PURE__ */ r(
1233
- Qi,
1239
+ d.length > 0 && /* @__PURE__ */ r(_e.Root, { children: d.map((v) => /* @__PURE__ */ r(
1240
+ en,
1234
1241
  {
1235
1242
  ...t,
1236
- form: w,
1237
- handleToggleFavorite: () => p(w)
1243
+ form: v,
1244
+ handleToggleFavorite: () => p(v)
1238
1245
  },
1239
- w.offline_id
1246
+ v.offline_id
1240
1247
  )) }),
1241
- /* @__PURE__ */ r(pe, { px: "3", children: /* @__PURE__ */ r(V, { size: "2", severity: "info", children: F }) })
1248
+ /* @__PURE__ */ r(he, { px: "3", children: /* @__PURE__ */ r(D, { size: "2", severity: "info", children: F }) })
1242
1249
  ] });
1243
1250
  })
1244
- ), Qi = (s) => {
1251
+ ), en = (s) => {
1245
1252
  var p;
1246
- const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (p = _(yt(i.owner_organization || -1))) == null ? void 0 : p.name, l = _(Xe(i.owner_user || -1)), c = _(vt).id, a = !!l && l.id === c, f = o ?? (a ? "You" : l == null ? void 0 : l.username) ?? "Unknown", d = E(
1253
+ const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (p = $(xt(i.owner_organization || -1))) == null ? void 0 : p.name, l = $(et(i.owner_user || -1)), c = $(It).id, a = !!l && l.id === c, f = o ?? (a ? "You" : l == null ? void 0 : l.username) ?? "Unknown", d = S(
1247
1254
  (h) => {
1248
1255
  h.stopPropagation(), n();
1249
1256
  },
1250
1257
  [n]
1251
- ), u = /* @__PURE__ */ r(ke.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...Kt, children: [
1258
+ ), u = /* @__PURE__ */ r(_e.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ b(y, { justify: "between", gap: "2", py: "2", px: "3", ...Zt, children: [
1252
1259
  /* @__PURE__ */ b(y, { grow: "1", align: "center", gap: "2", children: [
1253
1260
  /* @__PURE__ */ r(
1254
- se,
1261
+ ae,
1255
1262
  {
1256
- className: wt(i.favorite ? st.favoriteIcon : st.regularIcon),
1263
+ className: Ft(i.favorite ? ct.favoriteIcon : ct.regularIcon),
1257
1264
  variant: "ghost",
1258
1265
  onClick: d,
1259
1266
  "aria-label": i.favorite ? "Favorite form" : "Standard form",
1260
1267
  disabled: !t,
1261
- children: i.favorite ? /* @__PURE__ */ r(Yt, {}) : /* @__PURE__ */ r(Qt, {})
1268
+ children: i.favorite ? /* @__PURE__ */ r(ei, {}) : /* @__PURE__ */ r(ti, {})
1262
1269
  }
1263
1270
  ),
1264
- /* @__PURE__ */ r(V, { noWrap: !0, children: i.latestRevision.title }),
1265
- i.latestRevision.description && /* @__PURE__ */ r(Xt, {})
1271
+ /* @__PURE__ */ r(D, { noWrap: !0, children: i.latestRevision.title }),
1272
+ i.latestRevision.description && /* @__PURE__ */ r(ii, {})
1266
1273
  ] }),
1267
1274
  f && /* @__PURE__ */ b(y, { align: "center", gap: "2", children: [
1268
- /* @__PURE__ */ r(Jt, {}),
1275
+ /* @__PURE__ */ r(ni, {}),
1269
1276
  " ",
1270
1277
  f
1271
1278
  ] })
1272
1279
  ] }) });
1273
- return i.latestRevision.description ? /* @__PURE__ */ r(Zt, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1274
- }, Xi = "_submissionsContainer_9iirt_1", Ji = "_stopHorizontalOverflow_9iirt_6", Pt = {
1275
- submissionsContainer: Xi,
1276
- stopHorizontalOverflow: Ji
1277
- }, Zi = S(function(i) {
1278
- var w;
1279
- const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, c = _(vt), a = _(Xe("created_by" in e ? e.created_by : c.id)), f = He(e), d = wi(f) ? f.toLocaleTimeString([], {
1280
+ return i.latestRevision.description ? /* @__PURE__ */ r(ri, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1281
+ }, tn = "_submissionsContainer_9iirt_1", nn = "_stopHorizontalOverflow_9iirt_6", _t = {
1282
+ submissionsContainer: tn,
1283
+ stopHorizontalOverflow: nn
1284
+ }, rn = T(function(i) {
1285
+ var v;
1286
+ const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: l } = i, c = $(It), a = $(et("created_by" in e ? e.created_by : c.id)), f = Ke(e), d = Ti(f) ? f.toLocaleTimeString([], {
1280
1287
  hour: "2-digit",
1281
1288
  minute: "2-digit"
1282
- }) : xi(f), u = _(gt(e.form_revision));
1289
+ }) : Si(f), u = $(vt(e.form_revision));
1283
1290
  if (!u)
1284
1291
  throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
1285
- const p = (w = _(Ii(u.form))) == null ? void 0 : w.revision, h = Ci({
1292
+ const p = (v = $(zi(u.form))) == null ? void 0 : v.revision, h = Ei({
1286
1293
  file: (a == null ? void 0 : a.profile.file) ?? null,
1287
1294
  fileSha1: (a == null ? void 0 : a.profile.file_sha1) ?? null
1288
- }), g = (a == null ? void 0 : a.username.charAt(0).toUpperCase()) ?? "?", C = u.revision === p, z = fi.useCallback(() => {
1295
+ }), g = (a == null ? void 0 : a.username.charAt(0).toUpperCase()) ?? "?", x = u.revision === p, z = bi.useCallback(() => {
1289
1296
  t && t({ submission: e });
1290
- }, [e, t]), F = /* @__PURE__ */ r(ke.Item, { onClick: z, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
1291
- /* @__PURE__ */ b(y, { gap: "2", align: "center", className: Pt.stopHorizontalOverflow, children: [
1292
- /* @__PURE__ */ r(ei, { src: h, size: "1", fallback: g }),
1293
- /* @__PURE__ */ r(V, { size: "2", noWrap: !0, children: o === "creator" ? (a || c).username : u.title })
1297
+ }, [e, t]), F = /* @__PURE__ */ r(_e.Item, { onClick: z, asChild: !0, children: /* @__PURE__ */ b(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
1298
+ /* @__PURE__ */ b(y, { gap: "2", align: "center", className: _t.stopHorizontalOverflow, children: [
1299
+ /* @__PURE__ */ r(oi, { src: h, size: "1", fallback: g }),
1300
+ /* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: o === "creator" ? (a || c).username : u.title })
1294
1301
  ] }),
1295
1302
  /* @__PURE__ */ b(y, { gap: "2", align: "center", children: [
1296
- !n && (u.revision ? /* @__PURE__ */ r(Ne, { variant: "soft", severity: C ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!p && /* @__PURE__ */ r(Ne, { children: "Original" })),
1297
- /* @__PURE__ */ r(V, { size: "2", noWrap: !0, children: d })
1303
+ !n && (u.revision ? /* @__PURE__ */ r(qe, { variant: "soft", severity: x ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!p && /* @__PURE__ */ r(qe, { children: "Original" })),
1304
+ /* @__PURE__ */ r(D, { size: "2", noWrap: !0, children: d })
1298
1305
  ] })
1299
1306
  ] }) });
1300
1307
  return l ? l(e, F) : F;
1301
- }), He = (s) => {
1308
+ }), Ke = (s) => {
1302
1309
  const i = "created_at" in s ? s.created_at : s.submitted_at;
1303
1310
  return new Date(i);
1304
- }, An = S(function(i) {
1311
+ }, kn = T(function(i) {
1305
1312
  const {
1306
1313
  formId: e,
1307
1314
  submissions: t,
@@ -1313,26 +1320,26 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1313
1320
  } = i;
1314
1321
  if (!!e == !!t)
1315
1322
  throw new Error("Either formId or submissions must be provided, but not both.");
1316
- const f = _(
1317
- t ? () => t : Fi(e)
1318
- ), d = x(
1319
- () => f == null ? void 0 : f.sort((u, p) => He(p).getTime() - He(u).getTime()),
1323
+ const f = $(
1324
+ t ? () => t : Ai(e)
1325
+ ), d = w(
1326
+ () => f == null ? void 0 : f.sort((u, p) => Ke(p).getTime() - Ke(u).getTime()),
1320
1327
  [f]
1321
1328
  );
1322
1329
  return /* @__PURE__ */ r(
1323
- ke.Root,
1330
+ _e.Root,
1324
1331
  {
1325
- className: wt(Pt.submissionsContainer, o),
1332
+ className: Ft(_t.submissionsContainer, o),
1326
1333
  size: "small",
1327
1334
  variant: c,
1328
- before: !n && /* @__PURE__ */ b(V, { severity: "info", children: [
1335
+ before: !n && /* @__PURE__ */ b(D, { severity: "info", children: [
1329
1336
  "There are ",
1330
1337
  ((f == null ? void 0 : f.length) || 0).toString(),
1331
1338
  " submissions of this form."
1332
1339
  ] }),
1333
1340
  after: l,
1334
1341
  children: d == null ? void 0 : d.map((u, p) => /* @__PURE__ */ r(
1335
- Zi,
1342
+ rn,
1336
1343
  {
1337
1344
  submission: u,
1338
1345
  compact: n,
@@ -1342,9 +1349,9 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1342
1349
  ))
1343
1350
  }
1344
1351
  );
1345
- }), Pn = S(function(i) {
1346
- const { name: e, render: t } = i, { submitForm: n } = ue(), [o, l, c] = Ue(e);
1347
- return x(() => {
1352
+ }), Dn = T(function(i) {
1353
+ const { name: e, render: t } = i, { submitForm: n } = me(), [o, l, c] = Ye(e);
1354
+ return w(() => {
1348
1355
  const a = (f) => c.setValue(f, !1);
1349
1356
  return t({
1350
1357
  value: o.value,
@@ -1352,25 +1359,25 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1352
1359
  patchValue: n
1353
1360
  });
1354
1361
  }, [n, c, o.value, t]);
1355
- }), Ln = S(
1356
- ve((s, i) => {
1357
- const { children: e, schema: t, values: n, onPatch: o, onError: l, ...c } = s, a = x(() => tt(t.fields, n), [t.fields, n]), f = E(
1362
+ }), _n = T(
1363
+ we((s, i) => {
1364
+ const { children: e, schema: t, values: n, onPatch: o, onError: l, ...c } = s, a = w(() => rt(t.fields, n), [t.fields, n]), f = S(
1358
1365
  (g) => {
1359
- const C = {};
1366
+ const x = {};
1360
1367
  for (const z in g) {
1361
1368
  const F = g[z];
1362
- F !== a[z] && F !== void 0 && (C[z] = F);
1369
+ F !== a[z] && F !== void 0 && (x[z] = F);
1363
1370
  }
1364
- Le(C) && o(C);
1371
+ Ve(x) && o(x);
1365
1372
  },
1366
1373
  [a, o]
1367
- ), d = E(
1374
+ ), d = S(
1368
1375
  async (g) => {
1369
- const C = await At(t, g);
1370
- return C && l(C), C;
1376
+ const x = await Dt(t, g);
1377
+ return x && l(x), x;
1371
1378
  },
1372
1379
  [t, l]
1373
- ), u = Ge({
1380
+ ), u = Qe({
1374
1381
  initialValues: a,
1375
1382
  onSubmit: f,
1376
1383
  validate: d,
@@ -1378,52 +1385,52 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1378
1385
  validateOnBlur: !1,
1379
1386
  validateOnChange: !1
1380
1387
  }), { errors: p, resetForm: h } = u;
1381
- return ye(() => {
1382
- Le(p) && h({ values: a, errors: {} });
1383
- }, [p, a, h]), /* @__PURE__ */ r(Ke, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1388
+ return ve(() => {
1389
+ Ve(p) && h({ values: a, errors: {} });
1390
+ }, [p, a, h]), /* @__PURE__ */ r(Xe, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1384
1391
  })
1385
- ), Lt = {
1386
- ...et,
1392
+ ), $t = {
1393
+ ...nt,
1387
1394
  section: K
1388
- }, en = S(function(i) {
1395
+ }, on = T(function(i) {
1389
1396
  const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, l = e.Icon;
1390
1397
  return /* @__PURE__ */ b(y, { gap: "4", align: "center", children: [
1391
- /* @__PURE__ */ r(H, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
1398
+ /* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ b(y, { gap: "3", align: "center", grow: "1", children: [
1392
1399
  /* @__PURE__ */ r(l, {}),
1393
1400
  n
1394
1401
  ] }) }),
1395
- /* @__PURE__ */ r(V, { children: o })
1402
+ /* @__PURE__ */ r(D, { children: o })
1396
1403
  ] });
1397
- }), Vt = [
1404
+ }), Mt = [
1398
1405
  ["string", "text"],
1399
1406
  ["select", "multi-select", "upload"],
1400
1407
  ["boolean", "date", "number", "multi-string"]
1401
- ], tn = Vt.length - 1, nn = S(function(i) {
1408
+ ], sn = Mt.length - 1, ln = T(function(i) {
1402
1409
  const { setFieldType: e } = i;
1403
- return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Vt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
1410
+ return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Mt.map((t, n) => /* @__PURE__ */ b(y, { direction: "column", gap: "3", children: [
1404
1411
  /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
1405
- en,
1412
+ on,
1406
1413
  {
1407
- field: et[o],
1414
+ field: nt[o],
1408
1415
  setFieldType: () => e(o)
1409
1416
  },
1410
1417
  o
1411
1418
  )) }),
1412
- n < tn && /* @__PURE__ */ r(ti, { size: "4" })
1419
+ n < sn && /* @__PURE__ */ r(si, { size: "4" })
1413
1420
  ] }, n)) });
1414
- }), rn = (s) => (i) => {
1421
+ }), an = (s) => (i) => {
1415
1422
  if (console.log("in validate", s, i), !(!i || typeof i != "string") && s.includes(i.trim()))
1416
1423
  return "This name is already taken.";
1417
- }, on = (s, i) => {
1424
+ }, cn = (s, i) => {
1418
1425
  const e = [
1419
- new he({
1426
+ new ge({
1420
1427
  label: "Label",
1421
1428
  required: !0,
1422
1429
  maxLength: 200,
1423
1430
  identifier: "label",
1424
- fieldValidators: [rn(s)]
1431
+ fieldValidators: [an(s)]
1425
1432
  }),
1426
- new ge({
1433
+ new be({
1427
1434
  label: "Description",
1428
1435
  required: !1,
1429
1436
  maxLength: 1e3,
@@ -1432,119 +1439,116 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1432
1439
  ];
1433
1440
  return i === "section" ? e : [
1434
1441
  ...e,
1435
- new ce({ label: "Required", description: null, required: !1, identifier: "required" })
1442
+ new ue({ label: "Required", description: null, required: !1, identifier: "required" })
1436
1443
  ];
1437
- }, sn = S(function(i) {
1438
- const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l, editing: c } = i, a = Lt[e];
1444
+ }, dn = T(function(i) {
1445
+ const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: l } = i, c = $t[e];
1439
1446
  console.log("default field", o);
1440
- const f = ue(), d = x(() => {
1441
- const u = f.values.fields.flatMap(
1442
- (h) => h.type === "section" ? [...h.fields.map((g) => g.label), h.label] : h.label
1443
- ).filter((h) => !c || h !== (o == null ? void 0 : o.label) && h !== null);
1444
- let p = on(u, e);
1445
- if (console.log(u, p), a === K) {
1447
+ const a = me(), f = w(() => {
1448
+ const d = Et(a.values.fields).filter((p) => p !== (o == null ? void 0 : o.label));
1449
+ let u = cn(d, e);
1450
+ if (console.log("first set of errors", c, K, l), c === K) {
1446
1451
  if (l === void 0)
1447
1452
  throw new Error("Conditional source fields must be provided when changing sections.");
1448
- p = p.concat(a.getFieldCreationSchema(l));
1453
+ u = u.concat(c.getFieldCreationSchema(l));
1449
1454
  } else {
1450
- if (!(a.prototype instanceof $))
1451
- throw new Error(`Field must be an instance of BaseField. Got ${a}.`);
1452
- p = [...p, ...a.getFieldCreationSchema()];
1455
+ if (!(c.prototype instanceof M))
1456
+ throw console.log("badinstance"), new Error(`Field must be an instance of BaseField. Got ${c}.`);
1457
+ u = [...u, ...c.getFieldCreationSchema()];
1453
1458
  }
1454
1459
  return {
1455
- fields: p,
1460
+ fields: u,
1456
1461
  meta: { readonly: !1 },
1457
1462
  // using the dialog title as the form title
1458
1463
  title: null
1459
1464
  };
1460
- }, [f.values.fields, e, a, c, o == null ? void 0 : o.label, l]);
1465
+ }, [a.values.fields, e, c, o == null ? void 0 : o.label, l]);
1461
1466
  return /* @__PURE__ */ r(
1462
- it,
1467
+ ot,
1463
1468
  {
1464
- schema: d,
1469
+ schema: f,
1465
1470
  values: o,
1466
1471
  onSubmit: n,
1467
1472
  cancelText: o ? void 0 : "Back",
1468
1473
  onCancel: t
1469
1474
  }
1470
1475
  );
1471
- }), me = S(function(i) {
1472
- const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: c } = i, [a, f] = le(), d = (o == null ? void 0 : o.type) ?? a, u = d ? Lt[d].fieldTypeName : void 0, { setFieldValue: p, values: h } = ue();
1476
+ }), pe = T(function(i) {
1477
+ const { parentPath: e, index: t, children: n, initial: o, editing: l, conditionalSourceFields: c } = i, [a, f] = ce(), d = (o == null ? void 0 : o.type) ?? a, u = d ? $t[d].fieldTypeName : void 0, { setFieldValue: p, values: h } = me();
1473
1478
  if (l && !o)
1474
1479
  throw new Error("Initial field must be provided if editing is true.");
1475
- const g = !d && !l && !o, C = g ? "Choose a field type" : `${u} settings`, z = g ? "Select a field type to add to this section." : (u == null ? void 0 : u.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${u == null ? void 0 : u.toLowerCase()} field.`, F = E(() => f(void 0), []), w = E((I) => {
1480
+ const g = !d && !l && !o, x = g ? "Choose a field type" : `${u} settings`, z = g ? "Select a field type to add to this section." : (u == null ? void 0 : u.toLowerCase()) === "section" ? "Customize your section" : `Customize your ${u == null ? void 0 : u.toLowerCase()} field.`, F = S(() => f(void 0), []), v = S((I) => {
1476
1481
  f(void 0), I();
1477
- }, []), A = E(
1478
- (I, L) => {
1479
- const { label: M } = I;
1482
+ }, []), P = S(
1483
+ (I, V) => {
1484
+ const { label: O } = I;
1480
1485
  if (!d)
1481
1486
  throw new Error("Field type must be selected before creating a field.");
1482
- if (!M || typeof M != "string")
1487
+ if (!O || typeof O != "string")
1483
1488
  throw new Error("Label must be provided before creating a field.");
1484
- const U = $e({
1489
+ const Y = Me({
1485
1490
  type: d,
1486
1491
  ...I,
1487
- identifier: _i(I.identifier, M)
1488
- }).serialize(), R = ae(h, e);
1489
- if (R === void 0)
1492
+ identifier: St(I.identifier, O)
1493
+ }).serialize(), q = de(h, e);
1494
+ if (q === void 0)
1490
1495
  throw new Error("Parent path must point to an existing field.");
1491
- let j;
1492
- if (!Array.isArray(R))
1496
+ let U;
1497
+ if (!Array.isArray(q))
1493
1498
  throw new Error("Parent path must point to an array.");
1494
- l ? j = ki(R, t, U) : j = It(R, t, U), p(e, j).then(), L();
1499
+ l ? U = Ri(q, t, Y) : U = Tt(q, t, Y), p(e, U).then(), V();
1495
1500
  },
1496
1501
  [l, d, h, e, p, t]
1497
- ), P = E(
1498
- (I) => g ? /* @__PURE__ */ r(nn, { setFieldType: f }) : /* @__PURE__ */ r(
1499
- sn,
1502
+ ), L = S(
1503
+ (I) => g ? /* @__PURE__ */ r(ln, { setFieldType: f }) : /* @__PURE__ */ r(
1504
+ dn,
1500
1505
  {
1501
1506
  conditionalSourceFields: c,
1502
1507
  handleCancel: F,
1503
- handleCreateField: (L) => A(L, I),
1508
+ handleCreateField: (V) => P(V, I),
1504
1509
  fieldType: d,
1505
- defaultField: o,
1506
- editing: l
1510
+ defaultField: o
1507
1511
  }
1508
1512
  ),
1509
- [c, l, F, A, o, g, d]
1513
+ [c, F, P, o, g, d]
1510
1514
  );
1511
- return /* @__PURE__ */ r(ii, { onCloseInterrupt: w, title: C, description: z, content: P, children: n });
1512
- }), lt = ({ children: s }) => /* @__PURE__ */ r(ut, { children: s }), at = (s, i) => ({
1515
+ return /* @__PURE__ */ r(li, { onCloseInterrupt: v, title: x, description: z, content: L, children: n });
1516
+ }), dt = ({ children: s }) => /* @__PURE__ */ r(pt, { children: s }), ut = (s, i) => ({
1513
1517
  initial: s ? i : "none",
1514
1518
  sm: s ? "none" : i
1515
- }), Dt = S(function(i) {
1516
- const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: l } = i, c = x(
1519
+ }), Ot = T(function(i) {
1520
+ const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: l } = i, c = w(
1517
1521
  () => [
1518
1522
  {
1519
- Wrapper: me,
1523
+ Wrapper: pe,
1520
1524
  wrapperProps: n,
1521
- Icon: ni,
1525
+ Icon: ai,
1522
1526
  text: "Edit"
1523
1527
  },
1524
1528
  {
1525
- Icon: ri,
1529
+ Icon: ci,
1526
1530
  buttonProps: {
1527
1531
  onClick: e
1528
1532
  },
1529
1533
  text: "Delete"
1530
1534
  },
1531
1535
  {
1532
- Wrapper: me,
1536
+ Wrapper: pe,
1533
1537
  wrapperProps: l,
1534
- Icon: oi,
1538
+ Icon: di,
1535
1539
  text: "Duplicate"
1536
1540
  },
1537
1541
  {
1538
- Wrapper: me,
1542
+ Wrapper: pe,
1539
1543
  wrapperProps: o,
1540
- Icon: Ve,
1544
+ Icon: ke,
1541
1545
  text: "Add after"
1542
1546
  },
1543
1547
  {
1544
1548
  // Wrapping icon in a div so that the asChild turns the button into a div
1545
1549
  // so that the drag handle props are not applied to the icon
1546
1550
  // Note: b/c the <button> does not handle the space-press event correctly
1547
- Icon: (a) => /* @__PURE__ */ r("div", { ...a, children: /* @__PURE__ */ r(si, {}) }),
1551
+ Icon: (a) => /* @__PURE__ */ r("div", { ...a, children: /* @__PURE__ */ r(ui, {}) }),
1548
1552
  text: "Reorder",
1549
1553
  disableOnMobile: !0,
1550
1554
  buttonProps: { ...t, asChild: !0 }
@@ -1552,21 +1556,21 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1552
1556
  ],
1553
1557
  [t, l, n, o, e]
1554
1558
  );
1555
- return /* @__PURE__ */ b(ut, { children: [
1556
- /* @__PURE__ */ r(y, { gap: "4", display: at(!1, "flex"), children: c.map((a) => {
1557
- const f = a.Wrapper ?? lt;
1558
- return /* @__PURE__ */ r(f, { ...a.wrapperProps, children: /* @__PURE__ */ r(se, { type: "button", variant: "ghost", "aria-label": a.text, ...a.buttonProps, children: /* @__PURE__ */ r(a.Icon, {}) }) }, a.text);
1559
+ return /* @__PURE__ */ b(pt, { children: [
1560
+ /* @__PURE__ */ r(y, { gap: "4", display: ut(!1, "flex"), children: c.map((a) => {
1561
+ const f = a.Wrapper ?? dt;
1562
+ return /* @__PURE__ */ r(f, { ...a.wrapperProps, children: /* @__PURE__ */ r(ae, { type: "button", variant: "ghost", "aria-label": a.text, ...a.buttonProps, children: /* @__PURE__ */ r(a.Icon, {}) }) }, a.text);
1559
1563
  }) }),
1560
- /* @__PURE__ */ r(pe, { display: at(!0, "block"), children: /* @__PURE__ */ r(
1561
- li,
1564
+ /* @__PURE__ */ r(he, { display: ut(!0, "block"), children: /* @__PURE__ */ r(
1565
+ fi,
1562
1566
  {
1563
- trigger: /* @__PURE__ */ r(se, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(ai, {}) }),
1567
+ trigger: /* @__PURE__ */ r(ae, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(mi, {}) }),
1564
1568
  closeOnSelect: !1,
1565
1569
  items: c.map((a) => {
1566
1570
  var d;
1567
1571
  if (a.disableOnMobile)
1568
1572
  return null;
1569
- const f = a.Wrapper ?? lt;
1573
+ const f = a.Wrapper ?? dt;
1570
1574
  return {
1571
1575
  ...a.buttonProps,
1572
1576
  onSelect: (d = a.buttonProps) == null ? void 0 : d.onClick,
@@ -1579,10 +1583,10 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1579
1583
  }
1580
1584
  ) })
1581
1585
  ] });
1582
- }), Me = "form-builder", ln = S(function(i) {
1583
- const { field: e, index: t, sectionIndex: n, remove: o } = i, l = x(() => $e(e), [e]), c = Pe(l, { formId: Me, disabled: !0 });
1584
- console.log(e, t, n, l);
1585
- const a = x(
1586
+ }), Oe = "form-builder", un = T(function(i) {
1587
+ const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: l } = i, c = w(() => Me(e), [e]), a = Le(c, { formId: Oe, disabled: !0 });
1588
+ console.log(e, t, n, c);
1589
+ const f = w(
1586
1590
  () => ({
1587
1591
  index: t,
1588
1592
  parentPath: `fields.${n}.fields`,
@@ -1590,14 +1594,14 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1590
1594
  editing: !0
1591
1595
  }),
1592
1596
  [e, t, n]
1593
- ), f = x(
1597
+ ), d = w(
1594
1598
  () => ({
1595
1599
  parentPath: `fields.${n}.fields`,
1596
1600
  index: t + 1,
1597
- initial: { ...e, identifier: "" }
1601
+ initial: { ...e, label: He(e.label ?? "", o), identifier: "" }
1598
1602
  }),
1599
- [e, t, n]
1600
- ), d = x(
1603
+ [e, t, n, o]
1604
+ ), u = w(
1601
1605
  () => ({
1602
1606
  parentPath: `fields.${n}.fields`,
1603
1607
  index: t + 1,
@@ -1605,66 +1609,66 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1605
1609
  }),
1606
1610
  [t, n]
1607
1611
  );
1608
- return /* @__PURE__ */ r(Qe, { draggableId: e.identifier, index: t, children: (u) => /* @__PURE__ */ r(
1609
- be,
1612
+ return /* @__PURE__ */ r(Ze, { draggableId: e.identifier, index: t, children: (p) => /* @__PURE__ */ r(
1613
+ ye,
1610
1614
  {
1611
- ref: u.innerRef,
1612
- ...u.draggableProps,
1613
- ...u.dragHandleProps,
1615
+ ref: p.innerRef,
1616
+ ...p.draggableProps,
1617
+ ...p.dragHandleProps,
1614
1618
  mb: "4",
1615
1619
  children: /* @__PURE__ */ b(y, { gap: "4", justify: "between", align: "center", children: [
1616
- c,
1620
+ a,
1617
1621
  /* @__PURE__ */ r(
1618
- Dt,
1622
+ Ot,
1619
1623
  {
1620
- remove: o,
1621
- editProps: a,
1622
- duplicateProps: f,
1623
- insertAfterProps: d,
1624
- dragHandleProps: u.dragHandleProps
1624
+ remove: l,
1625
+ editProps: f,
1626
+ duplicateProps: d,
1627
+ insertAfterProps: u,
1628
+ dragHandleProps: p.dragHandleProps
1625
1629
  }
1626
1630
  )
1627
1631
  ] })
1628
1632
  }
1629
1633
  ) });
1630
- }), an = S(function(i) {
1631
- var P, I, L, M, U, R, j;
1632
- const { field: e, index: t, dropState: n } = i, o = (P = n[e.identifier]) == null ? void 0 : P.disabled, { setFieldValue: l, values: c } = ue(), a = ci();
1634
+ }), fn = T(function(i) {
1635
+ var V, O, Y, q, U, A, R;
1636
+ const { field: e, index: t, dropState: n } = i, o = (V = n[e.identifier]) == null ? void 0 : V.disabled, { setFieldValue: l, values: c } = me(), a = pi(), f = Et(c.fields);
1633
1637
  console.log("field section", e, t, c);
1634
- const f = E(
1635
- (v, T) => {
1636
- for (const D of v) {
1637
- const k = T.indexOf(D);
1638
+ const d = S(
1639
+ (C, E) => {
1640
+ for (const _ of C) {
1641
+ const k = E.indexOf(_);
1638
1642
  l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
1639
1643
  }
1640
1644
  },
1641
1645
  [l]
1642
- ), d = E(
1643
- (v) => {
1646
+ ), u = S(
1647
+ (C) => {
1644
1648
  var k;
1645
- const T = e.fields[v];
1646
- if (!T)
1649
+ const E = e.fields[C];
1650
+ if (!E)
1647
1651
  throw new Error("Could not find field to remove.");
1648
- const D = [];
1652
+ const _ = [];
1649
1653
  for (const N of c.fields)
1650
- ((k = N.condition) == null ? void 0 : k.identifier) === T.identifier && D.push(N);
1654
+ ((k = N.condition) == null ? void 0 : k.identifier) === E.identifier && _.push(N);
1651
1655
  return {
1652
- removing: T,
1653
- affectedSections: D,
1654
- action: () => l(`fields.${t}.fields`, Te(e.fields, v))
1656
+ removing: E,
1657
+ affectedSections: _,
1658
+ action: () => l(`fields.${t}.fields`, Se(e.fields, C))
1655
1659
  };
1656
1660
  },
1657
1661
  [e.fields, c.fields, l, t]
1658
- ), u = E(
1659
- (v) => {
1660
- const { affectedSections: T, action: D, removing: k } = d(v), N = () => {
1661
- D().then(), f(T, c.fields);
1662
+ ), p = S(
1663
+ (C) => {
1664
+ const { affectedSections: E, action: _, removing: k } = u(C), N = () => {
1665
+ _().then(), d(E, c.fields);
1662
1666
  };
1663
- if (T.length > 0) {
1664
- const fe = T.map((we) => we.label).join(", ");
1667
+ if (E.length > 0) {
1668
+ const Re = E.map((xe) => xe.label).join(", ");
1665
1669
  return a({
1666
1670
  title: "Remove condition?",
1667
- description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${fe} section(s).`,
1671
+ description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${Re} section(s).`,
1668
1672
  severity: "danger",
1669
1673
  actionText: "Remove",
1670
1674
  onAction: N
@@ -1672,114 +1676,128 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1672
1676
  }
1673
1677
  N();
1674
1678
  },
1675
- [d, f, c.fields, a]
1676
- ), p = E(() => {
1677
- const T = e.fields.map((xe, kt) => d(kt)).flatMap((xe) => xe.affectedSections), D = T.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, N = T.map((xe) => xe.label).join(", "), fe = T.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${N}` : `Deleting this section will remove the ${k} field(s) it contains.`, we = Te(c.fields, t), nt = () => l("fields", we);
1678
- if (T.length > 0)
1679
+ [u, d, c.fields, a]
1680
+ ), h = S(() => {
1681
+ const E = e.fields.map((Ie, Rt) => u(Rt)).flatMap((Ie) => Ie.affectedSections), _ = E.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, N = E.map((Ie) => Ie.label).join(", "), Re = E.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${N}` : `Deleting this section will remove the ${k} field(s) it contains.`, xe = Se(c.fields, t), st = () => l("fields", xe);
1682
+ if (E.length > 0)
1679
1683
  return a({
1680
- title: D,
1681
- description: fe,
1684
+ title: _,
1685
+ description: Re,
1682
1686
  severity: "danger",
1683
1687
  actionText: "Remove",
1684
1688
  onAction: () => {
1685
- nt().then(() => {
1686
- f(T, we);
1689
+ st().then(() => {
1690
+ d(E, xe);
1687
1691
  });
1688
1692
  }
1689
1693
  });
1690
- nt().then();
1694
+ st().then();
1691
1695
  }, [
1692
1696
  e.fields,
1693
1697
  c.fields,
1694
1698
  t,
1695
- d,
1699
+ u,
1696
1700
  l,
1697
1701
  a,
1698
- f
1699
- ]), h = x(
1702
+ d
1703
+ ]), g = S(
1704
+ (C) => {
1705
+ const E = He(C.label ?? "", f), _ = C.fields.map((k) => {
1706
+ const N = He(k.label, f);
1707
+ return {
1708
+ ...k,
1709
+ label: N,
1710
+ identifier: St(void 0, N)
1711
+ };
1712
+ });
1713
+ return { ...C, label: E, fields: _, identifier: "" };
1714
+ },
1715
+ [f]
1716
+ ), x = w(
1700
1717
  () => ({
1701
1718
  index: t,
1702
1719
  parentPath: "fields",
1703
1720
  initial: e,
1704
1721
  editing: !0,
1705
- conditionalSourceFields: Ie(c.fields, t)
1722
+ conditionalSourceFields: Fe(c.fields, t)
1706
1723
  }),
1707
1724
  [e, t, c.fields]
1708
- ), g = x(
1725
+ ), z = w(
1709
1726
  () => ({
1710
1727
  index: t + 1,
1711
1728
  parentPath: "fields",
1712
- initial: Fe(),
1713
- conditionalSourceFields: Ie(c.fields, t + 1)
1729
+ initial: Te(),
1730
+ conditionalSourceFields: Fe(c.fields, t + 1)
1714
1731
  }),
1715
1732
  [t, c.fields]
1716
- ), C = x(
1733
+ ), F = w(
1717
1734
  () => ({
1718
1735
  parentPath: `fields.${t}.fields`,
1719
1736
  index: e.fields.length,
1720
1737
  initial: void 0
1721
1738
  }),
1722
1739
  [e.fields.length, t]
1723
- ), z = x(
1740
+ ), v = w(
1724
1741
  () => ({
1725
1742
  index: t + 1,
1726
1743
  parentPath: "fields",
1727
- initial: { ...e, identifier: "" },
1728
- conditionalSourceFields: Ie(c.fields, t + 1)
1744
+ initial: g(e),
1745
+ conditionalSourceFields: Fe(c.fields, t + 1)
1729
1746
  }),
1730
- [e, t, c.fields]
1731
- ), F = x(
1747
+ [g, e, t, c.fields]
1748
+ ), P = w(
1732
1749
  () => {
1733
- var v, T;
1734
- return (T = Ct(c.fields, (v = e.condition) == null ? void 0 : v.identifier)) == null ? void 0 : T.label;
1750
+ var C, E;
1751
+ return (E = zt(c.fields, (C = e.condition) == null ? void 0 : C.identifier)) == null ? void 0 : E.label;
1735
1752
  },
1736
- [(I = e.condition) == null ? void 0 : I.identifier, c.fields]
1737
- ), w = Array.isArray((L = e.condition) == null ? void 0 : L.value) ? "contains all of" : "equals";
1738
- if (je((M = e.condition) == null ? void 0 : M.value))
1753
+ [(O = e.condition) == null ? void 0 : O.identifier, c.fields]
1754
+ ), L = Array.isArray((Y = e.condition) == null ? void 0 : Y.value) ? "contains all of" : "equals";
1755
+ if (Ge((q = e.condition) == null ? void 0 : q.value))
1739
1756
  throw new Error("File values are not supported for conditions.");
1740
- const A = Array.isArray((U = e.condition) == null ? void 0 : U.value) ? (R = e.condition) == null ? void 0 : R.value.map((v) => typeof v == "string" ? v : v.label).join(", ") : (j = e.condition) == null ? void 0 : j.value.toString();
1741
- return /* @__PURE__ */ r(Qe, { draggableId: e.identifier, index: t, children: (v) => /* @__PURE__ */ r(
1742
- be,
1757
+ const I = Array.isArray((U = e.condition) == null ? void 0 : U.value) ? (A = e.condition) == null ? void 0 : A.value.map((C) => typeof C == "string" ? C : C.label).join(", ") : (R = e.condition) == null ? void 0 : R.value.toString();
1758
+ return /* @__PURE__ */ r(Ze, { draggableId: e.identifier, index: t, children: (C) => /* @__PURE__ */ r(
1759
+ ye,
1743
1760
  {
1744
- ref: v.innerRef,
1745
- ...v.draggableProps,
1746
- ...v.dragHandleProps,
1761
+ ref: C.innerRef,
1762
+ ...C.draggableProps,
1763
+ ...C.dragHandleProps,
1747
1764
  mb: "4",
1748
1765
  children: /* @__PURE__ */ b(y, { gap: "3", justify: "between", align: "center", children: [
1749
1766
  /* @__PURE__ */ b(y, { direction: "column", gap: "2", grow: "1", children: [
1750
1767
  /* @__PURE__ */ b(y, { direction: "column", children: [
1751
1768
  /* @__PURE__ */ r(De, { as: "h3", size: "3", children: e.label }),
1752
- /* @__PURE__ */ r(V, { className: _e.description, children: e.description })
1769
+ /* @__PURE__ */ r(D, { className: $e.description, children: e.description })
1753
1770
  ] }),
1754
- e.condition && /* @__PURE__ */ r(V, { size: "1", children: /* @__PURE__ */ b(di, { children: [
1771
+ e.condition && /* @__PURE__ */ r(D, { size: "1", children: /* @__PURE__ */ b(hi, { children: [
1755
1772
  "Display only if ",
1756
- /* @__PURE__ */ r(rt, { children: F }),
1773
+ /* @__PURE__ */ r(lt, { children: P }),
1757
1774
  " ",
1758
- w,
1775
+ L,
1759
1776
  " ",
1760
- /* @__PURE__ */ r(rt, { children: A })
1777
+ /* @__PURE__ */ r(lt, { children: I })
1761
1778
  ] }) }),
1762
- /* @__PURE__ */ r(Ye, { droppableId: e.identifier, type: "SECTION", isDropDisabled: o, children: (T) => /* @__PURE__ */ b(
1779
+ /* @__PURE__ */ r(Je, { droppableId: e.identifier, type: "SECTION", isDropDisabled: o, children: (E) => /* @__PURE__ */ b(
1763
1780
  y,
1764
1781
  {
1765
- ref: T.innerRef,
1766
- ...T.droppableProps,
1782
+ ref: E.innerRef,
1783
+ ...E.droppableProps,
1767
1784
  direction: "column",
1768
1785
  gap: "0",
1769
1786
  children: [
1770
- e.fields.map((D, k) => /* @__PURE__ */ r(
1771
- ln,
1787
+ e.fields.map((_, k) => /* @__PURE__ */ r(
1788
+ un,
1772
1789
  {
1773
- field: D,
1790
+ field: _,
1774
1791
  index: k,
1775
1792
  sectionIndex: t,
1776
- remove: () => u(k)
1793
+ remove: () => p(k),
1794
+ takenLabels: f
1777
1795
  },
1778
- D.identifier
1796
+ _.identifier
1779
1797
  )),
1780
- T.placeholder,
1781
- /* @__PURE__ */ r(me, { ...C, children: /* @__PURE__ */ b(H, { type: "button", variant: "outline", children: [
1782
- /* @__PURE__ */ r(Ve, {}),
1798
+ E.placeholder,
1799
+ /* @__PURE__ */ r(pe, { ...F, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
1800
+ /* @__PURE__ */ r(ke, {}),
1783
1801
  " Add a field"
1784
1802
  ] }) })
1785
1803
  ]
@@ -1787,19 +1805,19 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1787
1805
  ) })
1788
1806
  ] }),
1789
1807
  /* @__PURE__ */ r(
1790
- Dt,
1808
+ Ot,
1791
1809
  {
1792
- remove: p,
1793
- insertAfterProps: g,
1794
- dragHandleProps: v.dragHandleProps,
1795
- editProps: h,
1796
- duplicateProps: z
1810
+ remove: h,
1811
+ insertAfterProps: z,
1812
+ dragHandleProps: C.dragHandleProps,
1813
+ editProps: x,
1814
+ duplicateProps: v
1797
1815
  }
1798
1816
  )
1799
1817
  ] })
1800
1818
  }
1801
1819
  ) });
1802
- }), cn = (s, i) => {
1820
+ }), mn = (s, i) => {
1803
1821
  var t;
1804
1822
  const e = { ...s };
1805
1823
  switch (i.type) {
@@ -1814,7 +1832,7 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1814
1832
  case "update":
1815
1833
  return i.state;
1816
1834
  }
1817
- }, dn = (s, i) => {
1835
+ }, pn = (s, i) => {
1818
1836
  if (i)
1819
1837
  for (let e = 0; e < s.length; e++) {
1820
1838
  const t = s[e];
@@ -1824,7 +1842,7 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1824
1842
  return e;
1825
1843
  }
1826
1844
  }
1827
- }, ct = (s) => {
1845
+ }, ft = (s) => {
1828
1846
  var e, t, n;
1829
1847
  const i = {};
1830
1848
  for (let o = 0; o < s.length; o++) {
@@ -1835,74 +1853,74 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1835
1853
  (t = l.condition) != null && t.identifier && a.add(l.condition.identifier), i[l.identifier] = {
1836
1854
  disabled: !1,
1837
1855
  conditionFields: a,
1838
- conditionIndex: dn(s, (n = l.condition) == null ? void 0 : n.identifier),
1856
+ conditionIndex: pn(s, (n = l.condition) == null ? void 0 : n.identifier),
1839
1857
  index: o,
1840
1858
  label: l.label
1841
1859
  };
1842
1860
  }
1843
1861
  return i;
1844
- }, dt = (s, i) => {
1862
+ }, mt = (s, i) => {
1845
1863
  for (const [e, t] of Object.entries(s))
1846
1864
  if (t.identifier === i)
1847
1865
  return [t, e];
1848
- }, un = S(function() {
1849
- const { values: i, setFieldValue: e } = ue(), [t, n] = pi(cn, i.fields, ct), { showInfo: o } = ui();
1850
- ye(() => {
1851
- n({ type: "update", state: ct(i.fields) });
1866
+ }, hn = T(function() {
1867
+ const { values: i, setFieldValue: e } = me(), [t, n] = vi(mn, i.fields, ft), { showInfo: o } = gi();
1868
+ ve(() => {
1869
+ n({ type: "update", state: ft(i.fields) });
1852
1870
  }, [n, i.fields]);
1853
- const l = E((f) => {
1871
+ const l = S((f) => {
1854
1872
  f.type === "SECTION" && n({ type: "hold", fieldId: f.draggableId });
1855
- }, []), c = E(
1873
+ }, []), c = S(
1856
1874
  (f) => {
1857
1875
  const { source: d, destination: u, type: p, reason: h, draggableId: g } = f;
1858
1876
  if (n({ type: "release" }), !u || h === "CANCEL")
1859
1877
  return;
1860
1878
  if (p === "ROOT") {
1861
- const A = t[g];
1862
- if (!A)
1879
+ const P = t[g];
1880
+ if (!P)
1863
1881
  throw new Error("Could not find section context.");
1864
- let P = typeof A.conditionIndex < "u" ? (
1882
+ let L = typeof P.conditionIndex < "u" ? (
1865
1883
  // cannot move a section with a condition before the condition's field
1866
- Math.max(A.conditionIndex + 1, u.index)
1884
+ Math.max(P.conditionIndex + 1, u.index)
1867
1885
  ) : u.index;
1868
1886
  for (const I of Object.values(t))
1869
- I.conditionIndex === d.index && (P = Math.min(P, I.index - 1));
1870
- return P != u.index && o({
1887
+ I.conditionIndex === d.index && (L = Math.min(L, I.index - 1));
1888
+ return L != u.index && o({
1871
1889
  title: "Reordered sections",
1872
1890
  description: "Sections with conditions must be below the fields they reference."
1873
- }), e("fields", qe(i.fields, d.index, P));
1891
+ }), e("fields", je(i.fields, d.index, L));
1874
1892
  }
1875
1893
  if (p !== "SECTION")
1876
1894
  throw new Error("Unexpected droppable type.");
1877
- const [C, z] = dt(i.fields, d.droppableId) ?? [], [F, w] = dt(i.fields, u.droppableId) ?? [];
1878
- if (!(C != null && C.fields) || !F)
1895
+ const [x, z] = mt(i.fields, d.droppableId) ?? [], [F, v] = mt(i.fields, u.droppableId) ?? [];
1896
+ if (!(x != null && x.fields) || !F)
1879
1897
  throw new Error("Could not find section with fields.");
1880
- if (C.identifier === F.identifier)
1898
+ if (x.identifier === F.identifier)
1881
1899
  e(
1882
1900
  `fields.${z}.fields`,
1883
- qe(C.fields, d.index, u.index)
1901
+ je(x.fields, d.index, u.index)
1884
1902
  ).then();
1885
1903
  else {
1886
- const A = C.fields[d.index];
1887
- if (!A)
1904
+ const P = x.fields[d.index];
1905
+ if (!P)
1888
1906
  throw new Error("Could not find field to reorder.");
1889
- e(`fields.${z}.fields`, Te(C.fields, d.index)).then(), e(
1890
- `fields.${w}.fields`,
1891
- It(F.fields, u.index, A)
1907
+ e(`fields.${z}.fields`, Se(x.fields, d.index)).then(), e(
1908
+ `fields.${v}.fields`,
1909
+ Tt(F.fields, u.index, P)
1892
1910
  ).then();
1893
1911
  }
1894
1912
  },
1895
1913
  [i.fields, e, t, o]
1896
- ), a = x(
1914
+ ), a = w(
1897
1915
  () => ({
1898
1916
  index: i.fields.length,
1899
1917
  parentPath: "fields",
1900
- initial: Fe(),
1901
- conditionalSourceFields: Ie(i.fields, i.fields.length)
1918
+ initial: Te(),
1919
+ conditionalSourceFields: Fe(i.fields, i.fields.length)
1902
1920
  }),
1903
1921
  [i.fields]
1904
1922
  );
1905
- return /* @__PURE__ */ r(ht, { onDragStart: l, onDragEnd: c, children: /* @__PURE__ */ r(Ye, { droppableId: "droppable", type: "ROOT", children: (f) => /* @__PURE__ */ b(
1923
+ return /* @__PURE__ */ r(yt, { onDragStart: l, onDragEnd: c, children: /* @__PURE__ */ r(Je, { droppableId: "droppable", type: "ROOT", children: (f) => /* @__PURE__ */ b(
1906
1924
  y,
1907
1925
  {
1908
1926
  ref: f.innerRef,
@@ -1911,7 +1929,7 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1911
1929
  gap: "0",
1912
1930
  children: [
1913
1931
  i.fields.map((d, u) => /* @__PURE__ */ r(
1914
- an,
1932
+ fn,
1915
1933
  {
1916
1934
  field: d,
1917
1935
  index: u,
@@ -1920,56 +1938,56 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1920
1938
  d.label
1921
1939
  )),
1922
1940
  f.placeholder,
1923
- /* @__PURE__ */ r(me, { ...a, children: /* @__PURE__ */ b(H, { type: "button", variant: "outline", children: [
1924
- /* @__PURE__ */ r(Ve, {}),
1941
+ /* @__PURE__ */ r(pe, { ...a, children: /* @__PURE__ */ b(G, { type: "button", variant: "outline", children: [
1942
+ /* @__PURE__ */ r(ke, {}),
1925
1943
  " Add a section"
1926
1944
  ] }) })
1927
1945
  ]
1928
1946
  }
1929
1947
  ) }) });
1930
- }), fn = {
1948
+ }), gn = {
1931
1949
  title: "",
1932
1950
  description: "",
1933
1951
  fields: []
1934
- }, mn = new he({
1952
+ }, bn = new ge({
1935
1953
  label: "Title",
1936
1954
  minLength: 0,
1937
1955
  maxLength: 100,
1938
1956
  required: !0,
1939
1957
  identifier: "title"
1940
- }), pn = { formId: Me, placeholder: "Give your form a title." }, hn = new ge({
1958
+ }), yn = { formId: Oe, placeholder: "Give your form a title." }, vn = new be({
1941
1959
  label: "Description",
1942
1960
  minLength: 0,
1943
1961
  maxLength: 1e3,
1944
1962
  required: !1,
1945
1963
  identifier: "description"
1946
- }), gn = { formId: Me, placeholder: "Explain the purpose of this form." }, bn = () => {
1964
+ }), wn = { formId: Oe, placeholder: "Explain the purpose of this form." }, xn = () => {
1947
1965
  alert("This is a form preview, your data will not be saved.");
1948
- }, Vn = S(
1949
- ve((s, i) => {
1950
- const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, c = E((h) => {
1966
+ }, $n = T(
1967
+ we((s, i) => {
1968
+ const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: l = o } = s, c = S((h) => {
1951
1969
  const g = {};
1952
- if (h.title || (g.title = "Title is required."), (!h.fields || h.fields.length === 0) && (g.fields = "At least one field is required."), Le(g))
1970
+ if (h.title || (g.title = "Title is required."), (!h.fields || h.fields.length === 0) && (g.fields = "At least one field is required."), Ve(g))
1953
1971
  return g;
1954
- }, []), a = Ge({
1955
- initialValues: Di(n) ?? fn,
1972
+ }, []), a = Qe({
1973
+ initialValues: Oi(n) ?? gn,
1956
1974
  validate: c,
1957
1975
  onSubmit: (h) => t(h),
1958
1976
  // only validate the entire for on submit
1959
1977
  validateOnChange: !1,
1960
1978
  validateOnBlur: !1
1961
- }), f = x(() => St(a.values), [a.values]), d = Pe(mn, pn), u = Pe(hn, gn), p = x(
1979
+ }), f = w(() => Lt(a.values), [a.values]), d = Le(bn, yn), u = Le(vn, wn), p = w(
1962
1980
  () => typeof l == "object" ? l : /* @__PURE__ */ r(De, { children: l }),
1963
1981
  [l]
1964
1982
  );
1965
- return /* @__PURE__ */ r(Y.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
1966
- /* @__PURE__ */ b(Y.List, { children: [
1967
- /* @__PURE__ */ r(Y.Trigger, { value: "edit", children: "Edit" }),
1968
- /* @__PURE__ */ r(Y.Trigger, { value: "preview", children: "Preview" })
1983
+ return /* @__PURE__ */ r(X.Root, { ref: i, defaultValue: "edit", children: /* @__PURE__ */ b(y, { direction: "column", gap: "2", children: [
1984
+ /* @__PURE__ */ b(X.List, { children: [
1985
+ /* @__PURE__ */ r(X.Trigger, { value: "edit", children: "Edit" }),
1986
+ /* @__PURE__ */ r(X.Trigger, { value: "preview", children: "Preview" })
1969
1987
  ] }),
1970
- /* @__PURE__ */ b(Y.Content, { value: "edit", children: [
1988
+ /* @__PURE__ */ b(X.Content, { value: "edit", children: [
1971
1989
  p,
1972
- /* @__PURE__ */ b(V, { children: [
1990
+ /* @__PURE__ */ b(D, { children: [
1973
1991
  "Add a new form field by clicking a + button. Specify options for each field, then drag and drop to rearrange them. You can see what a submitted form might look like in the",
1974
1992
  " ",
1975
1993
  /* @__PURE__ */ r("em", { children: "Preview" }),
@@ -1977,53 +1995,53 @@ const Pe = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Et = (s,
1977
1995
  " ",
1978
1996
  /* @__PURE__ */ r("strong", { children: "field values entered on this page will not be saved." })
1979
1997
  ] }),
1980
- /* @__PURE__ */ r(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ b("form", { id: Me, onSubmit: a.handleSubmit, children: [
1981
- /* @__PURE__ */ b(Ke, { value: a, children: [
1998
+ /* @__PURE__ */ r(y, { asChild: !0, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ b("form", { id: Oe, onSubmit: a.handleSubmit, children: [
1999
+ /* @__PURE__ */ b(Xe, { value: a, children: [
1982
2000
  d,
1983
2001
  u,
1984
- /* @__PURE__ */ r(un, {}),
1985
- /* @__PURE__ */ r(V, { severity: "danger", size: "1", children: typeof a.errors.fields == "string" && a.errors.fields })
2002
+ /* @__PURE__ */ r(hn, {}),
2003
+ /* @__PURE__ */ r(D, { severity: "danger", size: "1", children: typeof a.errors.fields == "string" && a.errors.fields })
1986
2004
  ] }),
1987
2005
  /* @__PURE__ */ b(y, { justify: "end", gap: "2", children: [
1988
- /* @__PURE__ */ r(H, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
1989
- /* @__PURE__ */ r(H, { type: "submit", disabled: !a.isValid, children: "Save" })
2006
+ /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: e, children: "Cancel" }),
2007
+ /* @__PURE__ */ r(G, { type: "submit", disabled: !a.isValid, children: "Save" })
1990
2008
  ] })
1991
2009
  ] }) })
1992
2010
  ] }),
1993
- /* @__PURE__ */ r(Y.Content, { value: "preview", children: /* @__PURE__ */ r(it, { schema: f, onSubmit: bn }) })
2011
+ /* @__PURE__ */ r(X.Content, { value: "preview", children: /* @__PURE__ */ r(ot, { schema: f, onSubmit: xn }) })
1994
2012
  ] }) });
1995
2013
  })
1996
2014
  );
1997
2015
  export {
1998
- ce as BooleanField,
1999
- zi as BooleanInput,
2000
- Be as DateField,
2001
- Ai as DateInput,
2016
+ ue as BooleanField,
2017
+ Vi as BooleanInput,
2018
+ We as DateField,
2019
+ Di as DateInput,
2002
2020
  K as FieldSection,
2003
- En as FormBrowser,
2004
- Vn as FormBuilder,
2005
- it as FormRenderer,
2006
- An as FormSubmissionBrowser,
2007
- zn as FormSubmissionViewer,
2008
- Ee as MultiSelectField,
2009
- Oi as MultiSelectInput,
2010
- Se as MultiStringField,
2011
- $i as MultiStringInput,
2012
- G as NumberField,
2013
- Ei as NumberInput,
2014
- Pn as PatchField,
2015
- Ln as PatchFormProvider,
2016
- ze as SelectField,
2017
- Vi as SelectInput,
2018
- he as StringField,
2019
- Pi as StringInput,
2020
- ge as TextField,
2021
- Li as TextInput,
2022
- $e as deserialize,
2023
- Tt as deserializeField,
2024
- St as formRevisionToSchema,
2025
- zt as isConditionMet,
2026
- Pe as useFieldInput,
2027
- Et as useFieldInputs,
2028
- je as valueIsFile
2021
+ Vn as FormBrowser,
2022
+ $n as FormBuilder,
2023
+ ot as FormRenderer,
2024
+ kn as FormSubmissionBrowser,
2025
+ Ln as FormSubmissionViewer,
2026
+ Ae as MultiSelectField,
2027
+ qi as MultiSelectInput,
2028
+ ze as MultiStringField,
2029
+ Ni as MultiStringInput,
2030
+ Q as NumberField,
2031
+ ki as NumberInput,
2032
+ Dn as PatchField,
2033
+ _n as PatchFormProvider,
2034
+ Ee as SelectField,
2035
+ Mi as SelectInput,
2036
+ ge as StringField,
2037
+ _i as StringInput,
2038
+ be as TextField,
2039
+ $i as TextInput,
2040
+ Me as deserialize,
2041
+ Pt as deserializeField,
2042
+ Lt as formRevisionToSchema,
2043
+ Vt as isConditionMet,
2044
+ Le as useFieldInput,
2045
+ kt as useFieldInputs,
2046
+ Ge as valueIsFile
2029
2047
  };