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