@overmap-ai/forms 1.0.4-conditional-arrows-2.6 → 1.0.4-conditional-arrows-2.8

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,16 +1,16 @@
1
- var jt = Object.defineProperty;
2
- var Ut = (s, i, e) => i in s ? jt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
- var m = (s, i, e) => (Ut(s, typeof i != "symbol" ? i + "" : i, e), e);
1
+ var Gt = Object.defineProperty;
2
+ var Kt = (s, i, e) => i in s ? Gt(s, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[i] = e;
3
+ var m = (s, i, e) => (Kt(s, typeof i != "symbol" ? i + "" : i, e), e);
4
4
  import { jsx as r, jsxs as g, Fragment as Je } from "react/jsx-runtime";
5
- import { Flex as y, Text as $, useSeverityColor as me, Checkbox as Gt, CheckCircledIcon as Kt, TextField as ae, FontFamilyIcon as Yt, CalendarIcon as Zt, InputIcon as Xt, TextArea as Qt, RowsIcon as Jt, Select as vt, Box as ge, IconButton as ce, PlusIcon as Oe, Badge as Ue, Cross1Icon as xt, ListBulletIcon as ei, DropdownMenuIcon as ti, MultiSelect as ii, CheckboxIcon as ni, Card as we, Heading as Me, Button as G, UploadIcon as It, ButtonList as Re, divButtonProps as ri, StarFilledIcon as oi, StarIcon as si, QuestionMarkCircledIcon as li, PersonIcon as ai, Tooltip as ci, Avatar as di, Separator as ui, Dialog as fi, Pencil1Icon as mi, TrashIcon as hi, CopyIcon as pi, DragHandleDots2Icon as gi, DropdownMenu as bi, DotsVerticalIcon as yi, useThemeContext as wi, useAlertDialog as vi, Em as xi, Strong as ft, useToast as Ii, Tabs as Q } from "@overmap-ai/blocks";
6
- import { useField as et, useFormikContext as he, useFormik as tt, FormikProvider as it } from "formik";
7
- import Ci, { useMemo as x, memo as S, useCallback as T, useState as de, useEffect as ve, useRef as Fi, forwardRef as xe, useReducer as Ti } from "react";
8
- import { DragDropContext as Ct, Droppable as nt, Draggable as rt } from "@hello-pangea/dnd";
9
- import { slugify as Si, useAppSelector as O, selectFormRevision as Ft, useSDK as Tt, selectSubmissionAttachments as zi, selectFilteredUserForms as Ei, selectUserFormMapping as Ai, selectOrganization as St, selectUser as ot, selectNumberOfUserForms as Li, selectCurrentUser as zt, classNames as Et, isToday as Pi, getLocalDateString as ki, selectLatestFormRevision as $i, useFileSrc as Vi, selectSubmissionsForForm as Di } from "@overmap-ai/core";
5
+ import { Flex as y, Text as $, useSeverityColor as me, Checkbox as Yt, CheckCircledIcon as Zt, TextField as ae, FontFamilyIcon as Xt, CalendarIcon as Qt, InputIcon as Jt, TextArea as ei, RowsIcon as ti, Select as It, Box as ge, IconButton as ce, PlusIcon as Oe, Badge as Ue, Cross1Icon as Ct, ListBulletIcon as ii, DropdownMenuIcon as ni, MultiSelect as ri, CheckboxIcon as oi, Card as we, Heading as Me, Button as G, UploadIcon as Ft, ButtonList as Re, divButtonProps as si, StarFilledIcon as li, StarIcon as ai, QuestionMarkCircledIcon as ci, PersonIcon as di, Tooltip as ui, Avatar as fi, Separator as mi, Dialog as pi, Pencil1Icon as hi, TrashIcon as gi, CopyIcon as bi, DragHandleDots2Icon as yi, DropdownMenu as wi, DotsVerticalIcon as vi, useAlertDialog as xi, Em as Ii, Strong as pt, useToast as Ci, Tabs as Q } from "@overmap-ai/blocks";
6
+ import { useField as et, useFormikContext as pe, useFormik as tt, FormikProvider as it } from "formik";
7
+ import Fi, { useMemo as x, memo as z, useCallback as S, useState as de, useEffect as ve, useRef as Ti, forwardRef as xe, useReducer as Si } from "react";
8
+ import { DragDropContext as Tt, Droppable as nt, Draggable as rt } from "@hello-pangea/dnd";
9
+ import { slugify as zi, useAppSelector as _, selectFormRevision as St, useSDK as zt, selectSubmissionAttachments as Ei, selectFilteredUserForms as Ai, selectUserFormMapping as Li, selectOrganization as Et, selectUser as ot, selectNumberOfUserForms as Pi, selectCurrentUser as At, classNames as Lt, isToday as ki, getLocalDateString as $i, selectLatestFormRevision as Vi, useFileSrc as Di, selectSubmissionsForForm as _i, selectAppearance as Oi } from "@overmap-ai/core";
10
10
  import ue from "lodash.get";
11
11
  import st from "lodash.set";
12
- import mt from "react-xarrows";
13
- class At {
12
+ import ht from "react-xarrows";
13
+ class Pt {
14
14
  constructor(i) {
15
15
  m(this, "type");
16
16
  m(this, "identifier");
@@ -34,7 +34,7 @@ class At {
34
34
  };
35
35
  }
36
36
  }
37
- class M extends At {
37
+ class M extends Pt {
38
38
  constructor(e) {
39
39
  const { label: t, required: n, fieldValidators: o = [], formValidators: a = [], ...c } = e;
40
40
  super(c);
@@ -91,8 +91,8 @@ class M extends At {
91
91
  }
92
92
  }
93
93
  m(M, "fieldTypeName"), m(M, "fieldTypeDescription");
94
- const _i = "_description_17zed_1", Ne = {
95
- description: _i
94
+ const Mi = "_description_17zed_1", Ne = {
95
+ description: Mi
96
96
  }, q = (s) => {
97
97
  const { label: i, children: e, severity: t, inputId: n, labelId: o, flexProps: a } = s;
98
98
  return /* @__PURE__ */ r(y, { direction: "column", gap: "1", asChild: !0, ...a, children: /* @__PURE__ */ g("label", { htmlFor: n, children: [
@@ -106,7 +106,7 @@ const _i = "_description_17zed_1", Ne = {
106
106
  /* @__PURE__ */ r(y, { direction: "column", children: /* @__PURE__ */ r($, { size: "1", severity: t, className: Ne.description, children: i }) })
107
107
  ] });
108
108
  }, H = (s) => {
109
- const { id: i, field: e, formId: t, ...n } = s, [o, a, c] = et(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`, p = e.required ? `${e.label} *` : e.label, b = x(() => ({
109
+ const { id: i, field: e, formId: t, ...n } = s, [o, a, c] = et(e.getId()), { touched: l } = a, f = a.error ?? e.description, d = a.error ? "danger" : void 0, u = i ?? `${t}-${e.getId()}-input`, p = `${u}-label`, h = e.required ? `${e.label} *` : e.label, b = x(() => ({
110
110
  ...o,
111
111
  onChange: (C) => {
112
112
  const w = e.getValueFromChangeEvent(C);
@@ -121,16 +121,16 @@ const _i = "_description_17zed_1", Ne = {
121
121
  helpText: f,
122
122
  severity: d,
123
123
  inputId: u,
124
- labelId: h,
125
- label: p,
124
+ labelId: p,
125
+ label: h,
126
126
  fieldProps: b,
127
127
  helpers: c,
128
128
  field: e
129
129
  },
130
- { ...n, "aria-labelledby": h }
130
+ { ...n, "aria-labelledby": p }
131
131
  ];
132
- }, Oi = [!0, "true"], Mi = S(function(i) {
133
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = Oi.includes(c.value);
132
+ }, Ri = [!0, "true"], Ni = z(function(i) {
133
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = Ri.includes(c.value);
134
134
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(
135
135
  q,
136
136
  {
@@ -140,7 +140,7 @@ const _i = "_description_17zed_1", Ne = {
140
140
  label: a,
141
141
  flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
142
142
  children: /* @__PURE__ */ r(
143
- Gt,
143
+ Yt,
144
144
  {
145
145
  ...l,
146
146
  ...c,
@@ -176,12 +176,12 @@ const _i = "_description_17zed_1", Ne = {
176
176
  return new J(e);
177
177
  }
178
178
  getInput(e) {
179
- return /* @__PURE__ */ r(Mi, { ...e, field: this });
179
+ return /* @__PURE__ */ r(Ni, { ...e, field: this });
180
180
  }
181
181
  };
182
- m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon", Kt);
182
+ m(J, "fieldTypeName", "Checkbox"), m(J, "fieldTypeDescription", "Perfect for both optional and required yes/no questions."), m(J, "Icon", Zt);
183
183
  let fe = J;
184
- const Ri = S(function(i) {
184
+ const Bi = z(function(i) {
185
185
  const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
186
186
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
187
187
  ae.Input,
@@ -267,12 +267,12 @@ const Ri = S(function(i) {
267
267
  return new B(e);
268
268
  }
269
269
  getInput(e) {
270
- return /* @__PURE__ */ r(Ri, { field: this, ...e });
270
+ return /* @__PURE__ */ r(Bi, { field: this, ...e });
271
271
  }
272
272
  };
273
- m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", Yt), m(B, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(B, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
273
+ m(B, "fieldTypeName", "Number"), m(B, "fieldTypeDescription", "Allows specifying a number within a given range."), m(B, "Icon", Xt), m(B, "_validateMin", (e, t) => typeof t.maximum == "number" && typeof e == "number" && t.maximum < e ? "Minimum cannot be greater than minimum." : null), m(B, "_validateMax", (e, t) => typeof t.minimum == "number" && typeof e == "number" && t.minimum > e ? "Maximum cannot be less than minimum." : null);
274
274
  let Y = B;
275
- const Ni = S(function(i) {
275
+ const qi = z(function(i) {
276
276
  const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = c.value ? c.value.split("T")[0] : "";
277
277
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ae.Input, { ...l, ...c, type: "date", id: e, color: f, value: d }) }) });
278
278
  }), ee = class ee extends M {
@@ -292,10 +292,10 @@ const Ni = S(function(i) {
292
292
  return new ee(e);
293
293
  }
294
294
  getInput(e) {
295
- return /* @__PURE__ */ r(Ni, { field: this, ...e });
295
+ return /* @__PURE__ */ r(qi, { field: this, ...e });
296
296
  }
297
297
  };
298
- m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon", Zt);
298
+ m(ee, "fieldTypeName", "Date"), m(ee, "fieldTypeDescription", "Allows specifying a date."), m(ee, "Icon", Qt);
299
299
  let Ge = ee;
300
300
  class Ee extends M {
301
301
  constructor(e) {
@@ -366,7 +366,7 @@ m(Ee, "_validateMax", (e, t) => {
366
366
  const { minimum_length: n } = t;
367
367
  return typeof n != "number" ? null : n > e ? "Maximum cannot be less than minimum." : null;
368
368
  });
369
- const Bi = S(function(i) {
369
+ const Wi = z(function(i) {
370
370
  const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), d = me(n);
371
371
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ae.Input, { ...f, ...c, type: l.inputType, id: e, color: d }) }) });
372
372
  }), te = class te extends Ee {
@@ -386,14 +386,14 @@ const Bi = S(function(i) {
386
386
  return new te({ ...a, maxLength: t, minLength: n, inputType: o });
387
387
  }
388
388
  getInput(e) {
389
- return /* @__PURE__ */ r(Bi, { field: this, ...e });
389
+ return /* @__PURE__ */ r(Wi, { field: this, ...e });
390
390
  }
391
391
  };
392
- m(te, "fieldTypeName", "Short Text"), m(te, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(te, "Icon", Xt);
392
+ m(te, "fieldTypeName", "Short Text"), m(te, "fieldTypeDescription", "Short text fields can hold up to 500 characters on a single line."), m(te, "Icon", Jt);
393
393
  let be = te;
394
- const qi = S(function(i) {
394
+ const Hi = z(function(i) {
395
395
  const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i);
396
- return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(Qt, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
396
+ return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(ei, { ...l, ...c, resize: "vertical", id: e, severity: n }) }) });
397
397
  }), ie = class ie extends Ee {
398
398
  constructor(i) {
399
399
  const e = i.maxLength ? Math.min(5e3, i.maxLength) : 5e3, t = i.minLength ? Math.min(i.minLength, e) : void 0;
@@ -409,27 +409,27 @@ const qi = S(function(i) {
409
409
  return new ie({ ...n, maxLength: e, minLength: t });
410
410
  }
411
411
  getInput(i) {
412
- return /* @__PURE__ */ r(qi, { field: this, ...i });
412
+ return /* @__PURE__ */ r(Hi, { field: this, ...i });
413
413
  }
414
414
  };
415
- m(ie, "fieldTypeName", "Paragraph"), m(ie, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ie, "Icon", Jt);
415
+ m(ie, "fieldTypeName", "Paragraph"), m(ie, "fieldTypeDescription", "Paragraph fields can hold up to 5000 characters and can have multiple lines."), m(ie, "Icon", ti);
416
416
  let ye = ie;
417
- const Wi = S(function(i) {
418
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, h = x(
417
+ const ji = z(function(i) {
418
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, p = x(
419
419
  () => l.options.map((b) => ({ value: b.value, itemContent: b.label })),
420
420
  [l.options]
421
- ), p = T(
421
+ ), h = S(
422
422
  (b) => {
423
423
  d(b), u(b);
424
424
  },
425
425
  [d, u]
426
426
  );
427
427
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
428
- vt,
428
+ It,
429
429
  {
430
- items: h,
430
+ items: p,
431
431
  ...c,
432
- onValueChange: p,
432
+ onValueChange: h,
433
433
  placeholder: "Select one...",
434
434
  id: e,
435
435
  severity: n,
@@ -443,7 +443,7 @@ const Wi = S(function(i) {
443
443
  label: null,
444
444
  condition: null,
445
445
  conditional: !1
446
- }), Hi = (s) => {
446
+ }), Ui = (s) => {
447
447
  if (!s)
448
448
  return;
449
449
  const i = s.fields;
@@ -459,11 +459,11 @@ function Ke(s, i, e) {
459
459
  throw new Error("Could not find field to reorder.");
460
460
  return t.splice(e, 0, n), t;
461
461
  }
462
- function ji(s, i, e) {
462
+ function Gi(s, i, e) {
463
463
  const t = Array.from(s);
464
464
  return t[i] = e, t;
465
465
  }
466
- function Lt(s, i, e) {
466
+ function kt(s, i, e) {
467
467
  const t = Array.from(s ?? []);
468
468
  return t.splice(i, 0, e), t;
469
469
  }
@@ -471,58 +471,58 @@ function Le(s, i) {
471
471
  const e = Array.from(s);
472
472
  return e.splice(i, 1), e;
473
473
  }
474
- const Pt = (s, i) => {
474
+ const $t = (s, i) => {
475
475
  if (typeof s == "string" && s.length > 0)
476
476
  return s;
477
477
  const e = /* @__PURE__ */ new Date();
478
- return `${Si(i)}-${e.getTime()}`;
479
- }, kt = (s, i) => {
478
+ return `${zi(i)}-${e.getTime()}`;
479
+ }, Vt = (s, i) => {
480
480
  if (!i)
481
481
  return null;
482
482
  for (const e of s)
483
483
  if (e.type === "section") {
484
- const t = kt(e.fields, i);
484
+ const t = Vt(e.fields, i);
485
485
  if (t)
486
486
  return t;
487
487
  } else if (e.identifier === i)
488
488
  return e;
489
489
  return null;
490
- }, ze = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), $t = (s) => s.flatMap(
490
+ }, ze = (s, i) => s.filter((e, t) => t < i).flatMap((e) => e.fields), Dt = (s) => s.flatMap(
491
491
  (i) => i.type === "section" ? [...i.fields.map((e) => e.label), i.label] : i.label
492
492
  ).filter((i) => i !== null), Ye = (s, i) => {
493
493
  let e = 1, t = `${s} (${e})`;
494
494
  for (; i.includes(t); )
495
495
  t = `${s} (${++e})`;
496
496
  return t;
497
- }, Ui = S(function(i) {
498
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = x(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: h } = c, p = `${e}-droppable`, { disabled: b } = l, [z, I] = de(""), [C, w] = de(""), V = C || o, L = C ? "red" : f, v = T(
497
+ }, Ki = z(function(i) {
498
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c }, l] = H(i), f = me(n), d = x(() => Array.isArray(c.value) ? c.value : [], [c.value]), { onChange: u, onBlur: p } = c, h = `${e}-droppable`, { disabled: b } = l, [E, I] = de(""), [C, w] = de(""), V = C || o, L = C ? "red" : f, v = S(
499
499
  (A) => {
500
- u(A), h(A);
500
+ u(A), p(A);
501
501
  },
502
- [u, h]
503
- ), P = T(
502
+ [u, p]
503
+ ), P = S(
504
504
  (A) => {
505
505
  d.findIndex((N) => N.value === A.target.value.trim()) >= 0 ? w("All options must be unique") : A.target.value ? w("") : w("Option cannot be empty"), I(A.target.value);
506
506
  },
507
507
  [I, d]
508
- ), R = T(() => {
508
+ ), R = S(() => {
509
509
  if (C)
510
510
  return;
511
- if (!z.trim())
511
+ if (!E.trim())
512
512
  return w("Option cannot be empty");
513
- const A = z.trim();
513
+ const A = E.trim();
514
514
  v([...d, { value: A, label: A }]), I("");
515
- }, [z, C, v, d]), X = T(
515
+ }, [E, C, v, d]), X = S(
516
516
  (A) => {
517
517
  A.key === "Enter" && (A.preventDefault(), R());
518
518
  },
519
519
  [R]
520
- ), j = T(
520
+ ), j = S(
521
521
  (A) => {
522
522
  v(Le(d, A));
523
523
  },
524
524
  [d, v]
525
- ), U = T(
525
+ ), U = S(
526
526
  (A) => {
527
527
  if (!A.destination)
528
528
  return;
@@ -531,7 +531,7 @@ const Pt = (s, i) => {
531
531
  },
532
532
  [v, d]
533
533
  );
534
- return /* @__PURE__ */ r(Ct, { onDragEnd: U, children: /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
534
+ return /* @__PURE__ */ r(Tt, { onDragEnd: U, children: /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
535
535
  /* @__PURE__ */ r(W, { helpText: V, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: (!b || d.length === 0) && /* @__PURE__ */ g(y, { gap: "2", children: [
536
536
  /* @__PURE__ */ r(ge, { grow: "1", children: /* @__PURE__ */ r(
537
537
  ae.Input,
@@ -539,7 +539,7 @@ const Pt = (s, i) => {
539
539
  placeholder: "Press enter to add a new option",
540
540
  ...l,
541
541
  ...c,
542
- value: z,
542
+ value: E,
543
543
  onChange: P,
544
544
  onKeyDown: X,
545
545
  id: e,
@@ -558,7 +558,7 @@ const Pt = (s, i) => {
558
558
  }
559
559
  )
560
560
  ] }) }) }),
561
- /* @__PURE__ */ r(nt, { droppableId: p, children: (A) => /* @__PURE__ */ g(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
561
+ /* @__PURE__ */ r(nt, { droppableId: h, children: (A) => /* @__PURE__ */ g(y, { ...A.droppableProps, ref: A.innerRef, direction: "column", children: [
562
562
  d.map((N, K) => /* @__PURE__ */ r(
563
563
  rt,
564
564
  {
@@ -588,7 +588,7 @@ const Pt = (s, i) => {
588
588
  severity: "info",
589
589
  disabled: b,
590
590
  onClick: () => j(K),
591
- children: /* @__PURE__ */ r(xt, {})
591
+ children: /* @__PURE__ */ r(Ct, {})
592
592
  }
593
593
  )
594
594
  ] })
@@ -615,7 +615,7 @@ const Pt = (s, i) => {
615
615
  throw new Error("Expected an array.");
616
616
  }
617
617
  getInput(e) {
618
- return /* @__PURE__ */ r(Ui, { field: this, ...e });
618
+ return /* @__PURE__ */ r(Ki, { field: this, ...e });
619
619
  }
620
620
  serialize() {
621
621
  return { ...super._serialize(), minimum_length: this.minLength, maximum_length: this.maxLength };
@@ -639,9 +639,9 @@ const Pt = (s, i) => {
639
639
  return new ne(e);
640
640
  }
641
641
  };
642
- m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon", ei);
642
+ m(ne, "fieldTypeName", "Multi-string"), m(ne, "fieldTypeDescription", "Allows the user to provide multiple unique strings."), m(ne, "Icon", ii);
643
643
  let Pe = ne;
644
- class Vt extends M {
644
+ class _t extends M {
645
645
  constructor(e) {
646
646
  super(e);
647
647
  m(this, "options");
@@ -671,7 +671,7 @@ class Vt extends M {
671
671
  ];
672
672
  }
673
673
  }
674
- const re = class re extends Vt {
674
+ const re = class re extends _t {
675
675
  constructor(i) {
676
676
  super({ ...i, type: "select" });
677
677
  }
@@ -687,23 +687,23 @@ const re = class re extends Vt {
687
687
  return new re(i);
688
688
  }
689
689
  getInput(i) {
690
- return /* @__PURE__ */ r(Wi, { field: this, ...i });
690
+ return /* @__PURE__ */ r(ji, { field: this, ...i });
691
691
  }
692
692
  };
693
- m(re, "fieldTypeName", "Dropdown"), m(re, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(re, "Icon", ti);
693
+ m(re, "fieldTypeName", "Dropdown"), m(re, "fieldTypeDescription", "Allows the user to select a single option from a list of options."), m(re, "Icon", ni);
694
694
  let ke = re;
695
- const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = S(function(i) {
696
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, h = x(() => Gi(c.value), [c.value]), p = T(
695
+ const Yi = (s) => s ? Array.isArray(s) ? s : [s] : [], Zi = z(function(i) {
696
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d, onBlur: u } = c, p = x(() => Yi(c.value), [c.value]), h = S(
697
697
  (b) => {
698
698
  d(b), u(b);
699
699
  },
700
700
  [d, u]
701
701
  );
702
702
  return /* @__PURE__ */ r(W, { helpText: o, severity: n, children: /* @__PURE__ */ r(q, { severity: n, inputId: e, labelId: t, label: a, children: /* @__PURE__ */ r(
703
- ii,
703
+ ri,
704
704
  {
705
- value: h,
706
- onValueChange: p,
705
+ value: p,
706
+ onValueChange: h,
707
707
  options: l.options,
708
708
  name: c.name,
709
709
  placeholder: "Select one or more...",
@@ -712,7 +712,7 @@ const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = S(function(i) {
712
712
  ...f
713
713
  }
714
714
  ) }) });
715
- }), oe = class oe extends Vt {
715
+ }), oe = class oe extends _t {
716
716
  constructor(i) {
717
717
  super({ ...i, type: "multi-select" });
718
718
  }
@@ -733,12 +733,12 @@ const Gi = (s) => s ? Array.isArray(s) ? s : [s] : [], Ki = S(function(i) {
733
733
  return new oe(i);
734
734
  }
735
735
  getInput(i) {
736
- return /* @__PURE__ */ r(Ki, { field: this, ...i });
736
+ return /* @__PURE__ */ r(Zi, { field: this, ...i });
737
737
  }
738
738
  };
739
- m(oe, "fieldTypeName", "Multi-select"), m(oe, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(oe, "Icon", ni);
739
+ m(oe, "fieldTypeName", "Multi-select"), m(oe, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options."), m(oe, "Icon", oi);
740
740
  let $e = oe;
741
- const Yi = S(function({ field: i, ...e }) {
741
+ const Xi = z(function({ field: i, ...e }) {
742
742
  const [{ value: t }] = et(i.options.clonedFieldIdentifier), n = x(() => {
743
743
  const o = i.options.getFieldToClone(t);
744
744
  return o ? Be(o) : null;
@@ -762,27 +762,27 @@ class Ve extends M {
762
762
  }
763
763
  }
764
764
  m(Ve, "fieldTypeName", "Custom"), m(Ve, "fieldTypeDescription", "Allows re-rendering of field already in the form");
765
- class Zi extends Ve {
765
+ class Qi extends Ve {
766
766
  constructor(i) {
767
- super(i, Yi);
767
+ super(i, Xi);
768
768
  }
769
769
  }
770
- const Xi = S(function(i) {
771
- const { field: e, ...t } = i, { label: n, description: o, fields: a, condition: c } = e, { values: l, setFieldValue: f } = he(), d = c != null && c.identifier ? ue(l, c.identifier) : void 0, u = x(() => Ot(c, d), [c, d]);
770
+ const Ji = 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 = x(() => Rt(c, d), [c, d]);
772
772
  ve(() => {
773
773
  if (!u)
774
- for (const p of a)
775
- f(p.getId(), "").then();
774
+ for (const h of a)
775
+ f(h.getId(), "").then();
776
776
  }, [u, a, f]);
777
- const h = Mt(a, t);
777
+ const p = Nt(a, t);
778
778
  return u ? n ? /* @__PURE__ */ r(we, { children: /* @__PURE__ */ g(y, { direction: "column", gap: "3", children: [
779
779
  /* @__PURE__ */ g(y, { direction: "column", children: [
780
780
  /* @__PURE__ */ r(Me, { as: "h3", size: "3", children: n }),
781
781
  /* @__PURE__ */ r($, { className: Ne.description, children: o })
782
782
  ] }),
783
- h
784
- ] }) }) : h : null;
785
- }), se = class se extends At {
783
+ p
784
+ ] }) }) : p : null;
785
+ }), se = class se extends Pt {
786
786
  constructor(e) {
787
787
  const { label: t = null, fields: n, condition: o = null, conditional: a, ...c } = e;
788
788
  super({ ...c, type: "section" });
@@ -829,7 +829,7 @@ const Xi = S(function(i) {
829
829
  // Declare a custom field that will be used to input a value for the condition. The value of the
830
830
  // conditional field selected in the previous step must be equal to the value the user inputs into
831
831
  // this field for the section to be rendered.
832
- new Zi({
832
+ new Qi({
833
833
  label: "Value",
834
834
  identifier: "condition.value",
835
835
  required: !0,
@@ -856,7 +856,7 @@ const Xi = S(function(i) {
856
856
  var n;
857
857
  if (e.type !== "section")
858
858
  throw new Error("Invalid type");
859
- const t = ((n = e.fields) == null ? void 0 : n.map(Dt)) ?? [];
859
+ const t = ((n = e.fields) == null ? void 0 : n.map(Ot)) ?? [];
860
860
  return new se({ ...e, fields: t });
861
861
  }
862
862
  conditional() {
@@ -880,35 +880,35 @@ const Xi = S(function(i) {
880
880
  return t;
881
881
  }
882
882
  getInput(e) {
883
- return /* @__PURE__ */ r(Xi, { field: this, ...e });
883
+ return /* @__PURE__ */ r(Ji, { field: this, ...e });
884
884
  }
885
885
  };
886
886
  m(se, "fieldTypeName", "Section"), m(se, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
887
887
  let Z = se;
888
- const Qi = "_previewImage_1ig84_1", Ji = {
889
- previewImage: Qi
888
+ const en = "_previewImage_1ig84_1", tn = {
889
+ previewImage: en
890
890
  }, lt = (s) => {
891
891
  const i = ["byte", "kilobyte", "megabyte"];
892
892
  let e = s, t = 0;
893
893
  for (; e > 1024 && t < i.length - 1; )
894
894
  e /= 1024, t++;
895
895
  return new Intl.NumberFormat([], { maximumFractionDigits: 2, style: "unit", unit: i[t] }).format(e);
896
- }, en = S(function(i) {
896
+ }, nn = z(function(i) {
897
897
  var L;
898
- const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d } = c, u = me(n), h = Fi(null), { value: p } = c, b = x(() => o || (l.maxFileSize ? `Maximum file size: ${lt(l.maxFileSize)}` : null), [l.maxFileSize, o]), z = T(() => {
898
+ const [{ inputId: e, labelId: t, severity: n, helpText: o, label: a, fieldProps: c, field: l }, f] = H(i), { onChange: d } = c, u = me(n), p = Ti(null), { value: h } = c, b = x(() => o || (l.maxFileSize ? `Maximum file size: ${lt(l.maxFileSize)}` : null), [l.maxFileSize, o]), E = S(() => {
899
899
  var v;
900
- (v = h.current) == null || v.click();
901
- }, []), I = T(
900
+ (v = p.current) == null || v.click();
901
+ }, []), I = S(
902
902
  (v) => {
903
- const P = [...p];
903
+ const P = [...h];
904
904
  P.splice(v, 1), d({ target: { files: P } });
905
905
  },
906
- [p, d]
907
- ), C = p ? "Select new files" : "Select files", w = p ? "Select new file" : "Select a file", V = l.maxFiles > 1 ? C : w;
906
+ [h, d]
907
+ ), C = h ? "Select new files" : "Select files", w = h ? "Select new file" : "Select a file", V = l.maxFiles > 1 ? C : w;
908
908
  return /* @__PURE__ */ g(y, { direction: "column", gap: "2", children: [
909
909
  /* @__PURE__ */ r(W, { helpText: b, severity: n, children: /* @__PURE__ */ g(q, { severity: n, inputId: e, labelId: t, label: a, children: [
910
- /* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(ge, { width: "max-content", asChild: !0, children: /* @__PURE__ */ g(G, { ...f, onClick: z, children: [
911
- /* @__PURE__ */ r(It, {}),
910
+ /* @__PURE__ */ r(y, { direction: "row", gap: "2", children: /* @__PURE__ */ r(ge, { width: "max-content", asChild: !0, children: /* @__PURE__ */ g(G, { ...f, onClick: E, children: [
911
+ /* @__PURE__ */ r(Ft, {}),
912
912
  " ",
913
913
  V
914
914
  ] }) }) }),
@@ -917,7 +917,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
917
917
  {
918
918
  ...f,
919
919
  type: "file",
920
- ref: h,
920
+ ref: p,
921
921
  id: e,
922
922
  accept: (L = l.extensions) == null ? void 0 : L.join(","),
923
923
  multiple: l.maxFiles > 1,
@@ -928,8 +928,8 @@ const Qi = "_previewImage_1ig84_1", Ji = {
928
928
  }
929
929
  )
930
930
  ] }) }),
931
- Array.isArray(p) && p.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: p.map((v, P) => /* @__PURE__ */ r(
932
- tn,
931
+ Array.isArray(h) && h.length > 0 && /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: h.map((v, P) => /* @__PURE__ */ r(
932
+ rn,
933
933
  {
934
934
  field: l,
935
935
  file: v,
@@ -939,10 +939,10 @@ const Qi = "_previewImage_1ig84_1", Ji = {
939
939
  P
940
940
  )) })
941
941
  ] });
942
- }), tn = S(function({ file: i, field: e, onRemove: t, disabled: n }) {
942
+ }), rn = z(function({ file: i, field: e, onRemove: t, disabled: n }) {
943
943
  const [o, a] = de(null), c = x(() => o && e.getError([o]), [e, o]), { url: l, name: f, size: d } = x(() => {
944
- let u = null, h, p;
945
- return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (h = o.name, p = lt(o.size)) : (h = "Downloading...", p = "..."), { url: u, name: h, size: p };
944
+ let u = null, p, h;
945
+ return o != null && o.type.startsWith("image/") && (u = URL.createObjectURL(o)), o ? (p = o.name, h = lt(o.size)) : (p = "Downloading...", h = "..."), { url: u, name: p, size: h };
946
946
  }, [o]);
947
947
  return ve(() => {
948
948
  i instanceof Promise ? i.then(a) : a(i);
@@ -956,7 +956,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
956
956
  "aria-label": `Remove ${f}`,
957
957
  disabled: n,
958
958
  onClick: t,
959
- children: /* @__PURE__ */ r(xt, {})
959
+ children: /* @__PURE__ */ r(Ct, {})
960
960
  }
961
961
  ),
962
962
  /* @__PURE__ */ g(y, { direction: "column", gap: "1", children: [
@@ -965,9 +965,9 @@ const Qi = "_previewImage_1ig84_1", Ji = {
965
965
  c && /* @__PURE__ */ r($, { size: "1", severity: "danger", children: c })
966
966
  ] })
967
967
  ] }),
968
- l && /* @__PURE__ */ r("img", { className: Ji.previewImage, src: l, alt: f })
968
+ l && /* @__PURE__ */ r("img", { className: tn.previewImage, src: l, alt: f })
969
969
  ] }) });
970
- }), ht = 50 * 1024 * 1024, le = class le extends M {
970
+ }), gt = 50 * 1024 * 1024, le = class le extends M {
971
971
  constructor(e) {
972
972
  const { extensions: t, maximum_files: n, maximum_size: o, ...a } = e;
973
973
  super({ ...a, type: "upload" });
@@ -999,7 +999,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
999
999
  required: !1,
1000
1000
  identifier: "maximum_size",
1001
1001
  minimum: 1,
1002
- maximum: ht,
1002
+ maximum: gt,
1003
1003
  integers: !0
1004
1004
  }),
1005
1005
  new $e({
@@ -1033,7 +1033,7 @@ const Qi = "_previewImage_1ig84_1", Ji = {
1033
1033
  ];
1034
1034
  }
1035
1035
  getFieldValidators() {
1036
- const e = super.getFieldValidators(), t = this.maxFileSize ?? ht, n = this.maxFiles ?? 1;
1036
+ const e = super.getFieldValidators(), t = this.maxFileSize ?? gt, n = this.maxFiles ?? 1;
1037
1037
  return e.push((o) => {
1038
1038
  if (o && o.some((a) => a.size > t))
1039
1039
  return `Files must be at most ${lt(t)}.`;
@@ -1056,10 +1056,10 @@ const Qi = "_previewImage_1ig84_1", Ji = {
1056
1056
  return new le(e);
1057
1057
  }
1058
1058
  getInput(e) {
1059
- return /* @__PURE__ */ r(en, { field: this, ...e });
1059
+ return /* @__PURE__ */ r(nn, { field: this, ...e });
1060
1060
  }
1061
1061
  };
1062
- m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon", It);
1062
+ m(le, "fieldTypeName", "Upload"), m(le, "fieldTypeDescription", "Allows a file to be uploaded."), m(le, "Icon", Ft);
1063
1063
  let Ze = le;
1064
1064
  const at = {
1065
1065
  date: Ge,
@@ -1073,11 +1073,11 @@ const at = {
1073
1073
  // TODO: Underscore
1074
1074
  "multi-string": Pe,
1075
1075
  "multi-select": $e
1076
- }, Dt = (s) => {
1076
+ }, Ot = (s) => {
1077
1077
  const i = s.type;
1078
1078
  return at[i].deserialize(s);
1079
- }, Be = (s) => s.type === "section" ? Z.deserialize(s) : Dt(s);
1080
- function _t(s, i = {}) {
1079
+ }, Be = (s) => s.type === "section" ? Z.deserialize(s) : Ot(s);
1080
+ function Mt(s, i = {}) {
1081
1081
  const { readonly: e = !1 } = i;
1082
1082
  return {
1083
1083
  title: s.title,
@@ -1089,7 +1089,7 @@ function _t(s, i = {}) {
1089
1089
  function Xe(s) {
1090
1090
  return !!(Array.isArray(s) && s.some((i) => i instanceof File || i instanceof Promise));
1091
1091
  }
1092
- function Ot(s, i) {
1092
+ function Rt(s, i) {
1093
1093
  if (!s)
1094
1094
  return !0;
1095
1095
  if (Xe(i) || Xe(s.value))
@@ -1103,16 +1103,16 @@ function Ot(s, i) {
1103
1103
  }
1104
1104
  return t === i;
1105
1105
  }
1106
- const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s, i) => {
1106
+ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Nt = (s, i) => {
1107
1107
  const e = x(() => s.map((t) => /* @__PURE__ */ r("div", { children: t.getInput(i) }, t.getId())), [s, i]);
1108
1108
  return /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: e });
1109
- }, _e = (s) => Object.keys(s).length > 0, Rt = async (s, i) => {
1109
+ }, _e = (s) => Object.keys(s).length > 0, Bt = async (s, i) => {
1110
1110
  const e = {};
1111
1111
  for (const t of s.fields)
1112
1112
  if (t instanceof Z) {
1113
1113
  if (t.condition) {
1114
1114
  const { identifier: n } = t.condition;
1115
- if (!Ot(t.condition, ue(i, n)))
1115
+ if (!Rt(t.condition, ue(i, n)))
1116
1116
  continue;
1117
1117
  }
1118
1118
  Object.assign(e, t.getErrors(i));
@@ -1124,14 +1124,14 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1124
1124
  }
1125
1125
  if (_e(e))
1126
1126
  return e;
1127
- }, nn = [null, void 0], ct = (s, i) => s.reduce((e, t) => t instanceof Z ? { ...e, ...ct(t.fields, i) } : (nn.includes(ue(e, t.getId())) && st(e, t.getId(), ""), e), i), rn = () => {
1127
+ }, on = [null, void 0], ct = (s, i) => s.reduce((e, t) => t instanceof Z ? { ...e, ...ct(t.fields, i) } : (on.includes(ue(e, t.getId())) && st(e, t.getId(), ""), e), i), sn = () => {
1128
1128
  throw new Error("onSubmit must be provided if form is not readonly.");
1129
- }, dt = S(
1129
+ }, dt = z(
1130
1130
  xe((s, i) => {
1131
1131
  const {
1132
1132
  schema: e,
1133
1133
  values: t = {},
1134
- onSubmit: n = rn,
1134
+ onSubmit: n = sn,
1135
1135
  submitText: o = "Submit",
1136
1136
  cancelText: a,
1137
1137
  onCancel: c,
@@ -1140,50 +1140,50 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1140
1140
  hideTitle: f = !e.title,
1141
1141
  hideDescription: d,
1142
1142
  className: u
1143
- } = s, { readonly: h } = e.meta, p = x(() => crypto.randomUUID(), []), b = tt({
1143
+ } = s, { readonly: p } = e.meta, h = x(() => crypto.randomUUID(), []), b = tt({
1144
1144
  initialValues: ct(e.fields, t),
1145
1145
  onSubmit: n,
1146
- validate: (V) => Rt(e, V),
1146
+ validate: (V) => Bt(e, V),
1147
1147
  // only validate the entire form on submit
1148
1148
  validateOnBlur: !1,
1149
1149
  validateOnChange: !1
1150
- }), { dirty: z } = b, I = x(
1150
+ }), { dirty: E } = b, I = x(
1151
1151
  () => typeof e.title == "string" ? /* @__PURE__ */ r(Me, { children: e.title }) : e.title,
1152
1152
  [e.title]
1153
1153
  ), C = x(
1154
1154
  () => typeof e.description == "string" ? /* @__PURE__ */ r($, { className: Ne.description, children: e.description }) : e.description,
1155
1155
  [e.description]
1156
- ), w = Mt(e.fields, { formId: p, disabled: h });
1156
+ ), w = Nt(e.fields, { formId: h, disabled: p });
1157
1157
  return ve(() => {
1158
- z && l && l();
1159
- }, [z, l]), /* @__PURE__ */ r(it, { value: b, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ g("form", { id: p, onSubmit: b.handleSubmit, children: [
1158
+ E && l && l();
1159
+ }, [E, l]), /* @__PURE__ */ r(it, { value: b, children: /* @__PURE__ */ r(y, { ref: i, direction: "column", gap: "2", className: u, asChild: !0, children: /* @__PURE__ */ g("form", { id: h, onSubmit: b.handleSubmit, children: [
1160
1160
  !f && /* @__PURE__ */ r(we, { children: /* @__PURE__ */ g(y, { direction: "column", gap: "1", children: [
1161
1161
  I,
1162
1162
  !d && C
1163
1163
  ] }) }),
1164
1164
  w,
1165
- !h && /* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
1165
+ !p && /* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
1166
1166
  a && /* @__PURE__ */ r(G, { type: "button", variant: "soft", onClick: c, children: a }),
1167
1167
  /* @__PURE__ */ r(G, { type: "submit", disabled: !b.isValid, children: o })
1168
1168
  ] })
1169
1169
  ] }) }) });
1170
1170
  })
1171
- ), Mn = S(
1171
+ ), Nn = z(
1172
1172
  xe((s, i) => {
1173
- const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = O(Ft(e.form_revision)), { sdk: a } = Tt();
1173
+ const { submission: e, showFormDescription: t = !1, showFormTitle: n = !0 } = s, o = _(St(e.form_revision)), { sdk: a } = zt();
1174
1174
  if (!o)
1175
1175
  throw new Error(
1176
1176
  `Could not find revision ${e.form_revision} for submission ${e.offline_id}.`
1177
1177
  );
1178
- const c = x(() => _t(o, { readonly: !0 }), [o]), l = x(() => {
1179
- const f = zi(e.offline_id)(a.store.getState()) ?? [], d = {};
1178
+ const c = x(() => Mt(o, { readonly: !0 }), [o]), l = x(() => {
1179
+ const f = Ei(e.offline_id)(a.store.getState()) ?? [], d = {};
1180
1180
  for (const u of f) {
1181
- const h = a.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((b) => {
1181
+ const p = a.files.fetchFileFromUrl(u.file, u.file_sha1, u.file_name).then((b) => {
1182
1182
  if (!b.success)
1183
1183
  throw new Error(`Failed to download attachment ${u.file_name}.`);
1184
1184
  return b.body;
1185
- }), p = d[u.field_identifier];
1186
- p ? p.push(h) : d[u.field_identifier] = [h];
1185
+ }), h = d[u.field_identifier];
1186
+ h ? h.push(p) : d[u.field_identifier] = [p];
1187
1187
  }
1188
1188
  return { ...e.values, ...d };
1189
1189
  }, [a.files, a.store, e.offline_id, e.values]);
@@ -1198,38 +1198,38 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1198
1198
  }
1199
1199
  );
1200
1200
  })
1201
- ), on = "_favoriteIcon_1bixi_1", sn = "_regularIcon_1bixi_9", pt = {
1202
- favoriteIcon: on,
1203
- regularIcon: sn
1204
- }, He = "organization:", je = "user:", Rn = S(
1201
+ ), ln = "_favoriteIcon_1bixi_1", an = "_regularIcon_1bixi_9", bt = {
1202
+ favoriteIcon: ln,
1203
+ regularIcon: an
1204
+ }, He = "organization:", je = "user:", Bn = z(
1205
1205
  xe((s, i) => {
1206
- const { maxResults: e = 20, ...t } = s, [n, o] = de(""), [a, c] = de(""), { sdk: l } = Tt(), f = x(() => {
1206
+ const { maxResults: e = 20, ...t } = s, [n, o] = de(""), [a, c] = de(""), { sdk: l } = zt(), f = x(() => {
1207
1207
  const w = { maxResults: e, searchTerm: n };
1208
1208
  return a && (a.startsWith(He) ? w.owner_organization = parseInt(a.slice(He.length)) : a.startsWith(je) && (w.owner_user = parseInt(a.slice(je.length)))), w;
1209
- }, [n, e, a]), d = O(Ei(f)) ?? [], u = O(Ai), h = T(
1209
+ }, [n, e, a]), d = _(Ai(f)) ?? [], u = _(Li), p = S(
1210
1210
  (w) => {
1211
1211
  w.favorite ? l.userForms.unfavorite(w.offline_id).then() : l.userForms.favorite(w.offline_id).then();
1212
1212
  },
1213
1213
  [l]
1214
- ), p = x(() => {
1214
+ ), h = x(() => {
1215
1215
  const w = l.store.getState(), V = {};
1216
1216
  for (const L of Object.values(u)) {
1217
- const v = St(L.owner_organization || -1)(w);
1217
+ const v = Et(L.owner_organization || -1)(w);
1218
1218
  v && (V[`${He}${v.id}`] = v.name);
1219
1219
  const P = ot(L.owner_user || -1)(w);
1220
1220
  P && (V[`${je}${P.id}`] = P.username);
1221
1221
  }
1222
1222
  return Object.entries(V).map(([L, v]) => ({ itemContent: v, value: L }));
1223
- }, [u, l.store]), b = T((w) => {
1223
+ }, [u, l.store]), b = S((w) => {
1224
1224
  o(w.currentTarget.value);
1225
- }, []), I = (O(Li) || 0) - d.length, C = d.length == e && I > 0 ? `Only the first ${e} results are shown (${I} hidden)` : I > 0 && `${I} hidden forms`;
1225
+ }, []), I = (_(Pi) || 0) - d.length, C = d.length == e && I > 0 ? `Only the first ${e} results are shown (${I} hidden)` : I > 0 && `${I} hidden forms`;
1226
1226
  return /* @__PURE__ */ g(y, { ref: i, direction: "column", gap: "2", children: [
1227
1227
  /* @__PURE__ */ g(y, { gap: "2", grow: "1", children: [
1228
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: b }) }) }),
1229
1229
  /* @__PURE__ */ r(
1230
- vt,
1230
+ It,
1231
1231
  {
1232
- items: p,
1232
+ items: h,
1233
1233
  value: a,
1234
1234
  onValueChange: c,
1235
1235
  placeholder: "Owner",
@@ -1238,70 +1238,70 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1238
1238
  )
1239
1239
  ] }),
1240
1240
  d.length > 0 && /* @__PURE__ */ r(Re.Root, { children: d.map((w) => /* @__PURE__ */ r(
1241
- ln,
1241
+ cn,
1242
1242
  {
1243
1243
  ...t,
1244
1244
  form: w,
1245
- handleToggleFavorite: () => h(w)
1245
+ handleToggleFavorite: () => p(w)
1246
1246
  },
1247
1247
  w.offline_id
1248
1248
  )) }),
1249
1249
  /* @__PURE__ */ r(ge, { px: "3", children: /* @__PURE__ */ r($, { size: "2", severity: "info", children: C }) })
1250
1250
  ] });
1251
1251
  })
1252
- ), ln = (s) => {
1253
- var h;
1254
- const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (h = O(St(i.owner_organization || -1))) == null ? void 0 : h.name, a = O(ot(i.owner_user || -1)), c = O(zt).id, l = !!a && a.id === c, f = o ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", d = T(
1255
- (p) => {
1256
- p.stopPropagation(), n();
1252
+ ), cn = (s) => {
1253
+ var p;
1254
+ const { form: i, onSelectForm: e, isFavoriteEditable: t, handleToggleFavorite: n } = s, o = (p = _(Et(i.owner_organization || -1))) == null ? void 0 : p.name, a = _(ot(i.owner_user || -1)), c = _(At).id, l = !!a && a.id === c, f = o ?? (l ? "You" : a == null ? void 0 : a.username) ?? "Unknown", d = S(
1255
+ (h) => {
1256
+ h.stopPropagation(), n();
1257
1257
  },
1258
1258
  [n]
1259
- ), u = /* @__PURE__ */ r(Re.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ g(y, { justify: "between", gap: "2", py: "2", px: "3", ...ri, children: [
1259
+ ), u = /* @__PURE__ */ r(Re.Item, { onClick: () => e(i), asChild: !0, children: /* @__PURE__ */ g(y, { justify: "between", gap: "2", py: "2", px: "3", ...si, children: [
1260
1260
  /* @__PURE__ */ g(y, { grow: "1", align: "center", gap: "2", children: [
1261
1261
  /* @__PURE__ */ r(
1262
1262
  ce,
1263
1263
  {
1264
- className: Et(i.favorite ? pt.favoriteIcon : pt.regularIcon),
1264
+ className: Lt(i.favorite ? bt.favoriteIcon : bt.regularIcon),
1265
1265
  variant: "ghost",
1266
1266
  onClick: d,
1267
1267
  "aria-label": i.favorite ? "Favorite form" : "Standard form",
1268
1268
  disabled: !t,
1269
- children: i.favorite ? /* @__PURE__ */ r(oi, {}) : /* @__PURE__ */ r(si, {})
1269
+ children: i.favorite ? /* @__PURE__ */ r(li, {}) : /* @__PURE__ */ r(ai, {})
1270
1270
  }
1271
1271
  ),
1272
1272
  /* @__PURE__ */ r($, { noWrap: !0, children: i.latestRevision.title }),
1273
- i.latestRevision.description && /* @__PURE__ */ r(li, {})
1273
+ i.latestRevision.description && /* @__PURE__ */ r(ci, {})
1274
1274
  ] }),
1275
1275
  f && /* @__PURE__ */ g(y, { align: "center", gap: "2", children: [
1276
- /* @__PURE__ */ r(ai, {}),
1276
+ /* @__PURE__ */ r(di, {}),
1277
1277
  " ",
1278
1278
  f
1279
1279
  ] })
1280
1280
  ] }) });
1281
- return i.latestRevision.description ? /* @__PURE__ */ r(ci, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1282
- }, an = "_submissionsContainer_9iirt_1", cn = "_stopHorizontalOverflow_9iirt_6", Nt = {
1283
- submissionsContainer: an,
1284
- stopHorizontalOverflow: cn
1285
- }, dn = S(function(i) {
1281
+ return i.latestRevision.description ? /* @__PURE__ */ r(ui, { content: i.latestRevision.description, children: u }, i.offline_id) : u;
1282
+ }, dn = "_submissionsContainer_9iirt_1", un = "_stopHorizontalOverflow_9iirt_6", qt = {
1283
+ submissionsContainer: dn,
1284
+ stopHorizontalOverflow: un
1285
+ }, fn = z(function(i) {
1286
1286
  var w;
1287
- const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c = O(zt), l = O(ot("created_by" in e ? e.created_by : c.id)), f = Qe(e), d = Pi(f) ? f.toLocaleTimeString([], {
1287
+ const { submission: e, onSubmissionClick: t, compact: n, labelType: o, rowDecorator: a } = i, c = _(At), l = _(ot("created_by" in e ? e.created_by : c.id)), f = Qe(e), d = ki(f) ? f.toLocaleTimeString([], {
1288
1288
  hour: "2-digit",
1289
1289
  minute: "2-digit"
1290
- }) : ki(f), u = O(Ft(e.form_revision));
1290
+ }) : $i(f), u = _(St(e.form_revision));
1291
1291
  if (!u)
1292
1292
  throw new Error(`Could not find revision ${e.form_revision} for submission ${e.offline_id}.`);
1293
- const h = (w = O($i(u.form))) == null ? void 0 : w.revision, p = Vi({
1293
+ const p = (w = _(Vi(u.form))) == null ? void 0 : w.revision, h = Di({
1294
1294
  file: (l == null ? void 0 : l.profile.file) ?? null,
1295
1295
  fileSha1: (l == null ? void 0 : l.profile.file_sha1) ?? null
1296
- }), b = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", z = u.revision === h, I = Ci.useCallback(() => {
1296
+ }), b = (l == null ? void 0 : l.username.charAt(0).toUpperCase()) ?? "?", E = u.revision === p, I = Fi.useCallback(() => {
1297
1297
  t && t({ submission: e });
1298
1298
  }, [e, t]), C = /* @__PURE__ */ r(Re.Item, { onClick: I, asChild: !0, children: /* @__PURE__ */ g(y, { grow: "1", width: "100%", p: "2", gap: "2", justify: "between", children: [
1299
- /* @__PURE__ */ g(y, { gap: "2", align: "center", className: Nt.stopHorizontalOverflow, children: [
1300
- /* @__PURE__ */ r(di, { src: p, size: "1", fallback: b }),
1299
+ /* @__PURE__ */ g(y, { gap: "2", align: "center", className: qt.stopHorizontalOverflow, children: [
1300
+ /* @__PURE__ */ r(fi, { src: h, size: "1", fallback: b }),
1301
1301
  /* @__PURE__ */ r($, { size: "2", noWrap: !0, children: o === "creator" ? (l || c).username : u.title })
1302
1302
  ] }),
1303
1303
  /* @__PURE__ */ g(y, { gap: "2", align: "center", children: [
1304
- !n && (u.revision ? /* @__PURE__ */ r(Ue, { variant: "soft", severity: z ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!h && /* @__PURE__ */ r(Ue, { children: "Original" })),
1304
+ !n && (u.revision ? /* @__PURE__ */ r(Ue, { variant: "soft", severity: E ? "primary" : "info", children: n ? u.revision.toString() : `Revision #${u.revision}` }) : !!p && /* @__PURE__ */ r(Ue, { children: "Original" })),
1305
1305
  /* @__PURE__ */ r($, { size: "2", noWrap: !0, children: d })
1306
1306
  ] })
1307
1307
  ] }) });
@@ -1309,7 +1309,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1309
1309
  }), Qe = (s) => {
1310
1310
  const i = "created_at" in s ? s.created_at : s.submitted_at;
1311
1311
  return new Date(i);
1312
- }, Nn = S(function(i) {
1312
+ }, qn = z(function(i) {
1313
1313
  const {
1314
1314
  formId: e,
1315
1315
  submissions: t,
@@ -1321,16 +1321,16 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1321
1321
  } = i;
1322
1322
  if (!!e == !!t)
1323
1323
  throw new Error("Either formId or submissions must be provided, but not both.");
1324
- const f = O(
1325
- t ? () => t : Di(e)
1324
+ const f = _(
1325
+ t ? () => t : _i(e)
1326
1326
  ), d = x(
1327
- () => f == null ? void 0 : f.sort((u, h) => Qe(h).getTime() - Qe(u).getTime()),
1327
+ () => f == null ? void 0 : f.sort((u, p) => Qe(p).getTime() - Qe(u).getTime()),
1328
1328
  [f]
1329
1329
  );
1330
1330
  return /* @__PURE__ */ r(
1331
1331
  Re.Root,
1332
1332
  {
1333
- className: Et(Nt.submissionsContainer, o),
1333
+ className: Lt(qt.submissionsContainer, o),
1334
1334
  size: "small",
1335
1335
  variant: c,
1336
1336
  before: !n && /* @__PURE__ */ g($, { severity: "info", children: [
@@ -1339,19 +1339,19 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1339
1339
  " submissions of this form."
1340
1340
  ] }),
1341
1341
  after: a,
1342
- children: d == null ? void 0 : d.map((u, h) => /* @__PURE__ */ r(
1343
- dn,
1342
+ children: d == null ? void 0 : d.map((u, p) => /* @__PURE__ */ r(
1343
+ fn,
1344
1344
  {
1345
1345
  submission: u,
1346
1346
  compact: n,
1347
1347
  ...l
1348
1348
  },
1349
- h
1349
+ p
1350
1350
  ))
1351
1351
  }
1352
1352
  );
1353
- }), Bn = S(function(i) {
1354
- const { name: e, render: t } = i, { submitForm: n } = he(), [o, a, c] = et(e);
1353
+ }), Wn = z(function(i) {
1354
+ const { name: e, render: t } = i, { submitForm: n } = pe(), [o, a, c] = et(e);
1355
1355
  return x(() => {
1356
1356
  const l = (f) => c.setValue(f, !1);
1357
1357
  return t({
@@ -1360,22 +1360,22 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1360
1360
  patchValue: n
1361
1361
  });
1362
1362
  }, [n, c, o.value, t]);
1363
- }), qn = S(
1363
+ }), Hn = z(
1364
1364
  xe((s, i) => {
1365
- const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() => ct(t.fields, n), [t.fields, n]), f = T(
1365
+ const { children: e, schema: t, values: n, onPatch: o, onError: a, ...c } = s, l = x(() => ct(t.fields, n), [t.fields, n]), f = S(
1366
1366
  (b) => {
1367
- const z = {};
1367
+ const E = {};
1368
1368
  for (const I in b) {
1369
1369
  const C = b[I];
1370
- C !== l[I] && C !== void 0 && (z[I] = C);
1370
+ C !== l[I] && C !== void 0 && (E[I] = C);
1371
1371
  }
1372
- _e(z) && o(z);
1372
+ _e(E) && o(E);
1373
1373
  },
1374
1374
  [l, o]
1375
- ), d = T(
1375
+ ), d = S(
1376
1376
  async (b) => {
1377
- const z = await Rt(t, b);
1378
- return z && a(z), z;
1377
+ const E = await Bt(t, b);
1378
+ return E && a(E), E;
1379
1379
  },
1380
1380
  [t, a]
1381
1381
  ), u = tt({
@@ -1385,15 +1385,15 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1385
1385
  // only validate the entire form on submit
1386
1386
  validateOnBlur: !1,
1387
1387
  validateOnChange: !1
1388
- }), { errors: h, resetForm: p } = u;
1388
+ }), { errors: p, resetForm: h } = u;
1389
1389
  return ve(() => {
1390
- _e(h) && p({ values: l, errors: {} });
1391
- }, [h, l, p]), /* @__PURE__ */ r(it, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1390
+ _e(p) && h({ values: l, errors: {} });
1391
+ }, [p, l, h]), /* @__PURE__ */ r(it, { value: u, children: /* @__PURE__ */ r("form", { ...c, ref: i, onSubmit: u.handleSubmit, children: e }) });
1392
1392
  })
1393
- ), Bt = {
1393
+ ), Wt = {
1394
1394
  ...at,
1395
1395
  section: Z
1396
- }, un = S(function(i) {
1396
+ }, mn = z(function(i) {
1397
1397
  const { field: e, setFieldType: t } = i, n = e.fieldTypeName, o = e.fieldTypeDescription, a = e.Icon;
1398
1398
  return /* @__PURE__ */ g(y, { gap: "4", align: "center", children: [
1399
1399
  /* @__PURE__ */ r(G, { type: "button", variant: "surface", onClick: t, style: { width: "135px" }, children: /* @__PURE__ */ g(y, { gap: "3", align: "center", grow: "1", children: [
@@ -1402,34 +1402,34 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1402
1402
  ] }) }),
1403
1403
  /* @__PURE__ */ r($, { children: o })
1404
1404
  ] });
1405
- }), qt = [
1405
+ }), Ht = [
1406
1406
  ["string", "text"],
1407
1407
  ["select", "multi-select", "upload"],
1408
1408
  ["boolean", "date", "number", "multi-string"]
1409
- ], fn = qt.length - 1, mn = S(function(i) {
1409
+ ], pn = Ht.length - 1, hn = z(function(i) {
1410
1410
  const { setFieldType: e } = i;
1411
- return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: qt.map((t, n) => /* @__PURE__ */ g(y, { direction: "column", gap: "3", children: [
1411
+ return /* @__PURE__ */ r(y, { direction: "column", gap: "3", children: Ht.map((t, n) => /* @__PURE__ */ g(y, { direction: "column", gap: "3", children: [
1412
1412
  /* @__PURE__ */ r(y, { direction: "column", gap: "2", children: t.map((o) => /* @__PURE__ */ r(
1413
- un,
1413
+ mn,
1414
1414
  {
1415
1415
  field: at[o],
1416
1416
  setFieldType: () => e(o)
1417
1417
  },
1418
1418
  o
1419
1419
  )) }),
1420
- n < fn && /* @__PURE__ */ r(ui, { size: "4" })
1420
+ n < pn && /* @__PURE__ */ r(mi, { size: "4" })
1421
1421
  ] }, n)) });
1422
- }), hn = (s) => (i) => {
1422
+ }), gn = (s) => (i) => {
1423
1423
  if (!(!i || typeof i != "string") && s.includes(i.trim()))
1424
1424
  return "This name is already taken.";
1425
- }, pn = (s, i) => {
1425
+ }, bn = (s, i) => {
1426
1426
  const e = [
1427
1427
  new be({
1428
1428
  label: "Label",
1429
1429
  required: !0,
1430
1430
  maxLength: 200,
1431
1431
  identifier: "label",
1432
- fieldValidators: [hn(s)]
1432
+ fieldValidators: [gn(s)]
1433
1433
  }),
1434
1434
  new ye({
1435
1435
  label: "Description",
@@ -1442,10 +1442,10 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1442
1442
  ...e,
1443
1443
  new fe({ label: "Required", description: null, required: !1, identifier: "required" })
1444
1444
  ];
1445
- }, gn = S(function(i) {
1446
- const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c = Bt[e], l = he(), f = x(() => {
1447
- const d = $t(l.values.fields).filter((h) => h !== (o == null ? void 0 : o.label));
1448
- let u = pn(d, e);
1445
+ }, yn = z(function(i) {
1446
+ const { fieldType: e, handleCancel: t, handleCreateField: n, defaultField: o, conditionalSourceFields: a } = i, c = Wt[e], l = pe(), f = x(() => {
1447
+ const d = Dt(l.values.fields).filter((p) => p !== (o == null ? void 0 : o.label));
1448
+ let u = bn(d, e);
1449
1449
  if (c === Z) {
1450
1450
  if (a === void 0)
1451
1451
  throw new Error("Conditional source fields must be provided when changing sections.");
@@ -1472,13 +1472,13 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1472
1472
  onCancel: t
1473
1473
  }
1474
1474
  );
1475
- }), pe = S(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 ? Bt[d].fieldTypeName : void 0, { setFieldValue: h, values: p } = he();
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 ? Wt[d].fieldTypeName : void 0, { setFieldValue: p, values: h } = pe();
1477
1477
  if (a && !o)
1478
1478
  throw new Error("Initial field must be provided if editing is true.");
1479
- const b = !d && !a && !o, z = b ? "Choose a field type" : `${u} settings`, I = b ? "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.`, C = T(() => f(void 0), []), w = T((v) => {
1479
+ const b = !d && !a && !o, E = b ? "Choose a field type" : `${u} settings`, I = b ? "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.`, C = S(() => f(void 0), []), w = S((v) => {
1480
1480
  f(void 0), v();
1481
- }, []), V = T(
1481
+ }, []), V = S(
1482
1482
  (v, P) => {
1483
1483
  const { label: R } = v;
1484
1484
  if (!d)
@@ -1488,19 +1488,19 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1488
1488
  const X = Be({
1489
1489
  type: d,
1490
1490
  ...v,
1491
- identifier: Pt(v.identifier, R)
1492
- }).serialize(), j = ue(p, e);
1491
+ identifier: $t(v.identifier, R)
1492
+ }).serialize(), j = ue(h, e);
1493
1493
  if (j === void 0)
1494
1494
  throw new Error("Parent path must point to an existing field.");
1495
1495
  let U;
1496
1496
  if (!Array.isArray(j))
1497
1497
  throw new Error("Parent path must point to an array.");
1498
- a ? U = ji(j, t, X) : U = Lt(j, t, X), h(e, U).then(), P();
1498
+ a ? U = Gi(j, t, X) : U = kt(j, t, X), p(e, U).then(), P();
1499
1499
  },
1500
- [a, d, p, e, h, t]
1501
- ), L = T(
1502
- (v) => b ? /* @__PURE__ */ r(mn, { setFieldType: f }) : /* @__PURE__ */ r(
1503
- gn,
1500
+ [a, d, h, e, p, t]
1501
+ ), L = S(
1502
+ (v) => b ? /* @__PURE__ */ r(hn, { setFieldType: f }) : /* @__PURE__ */ r(
1503
+ yn,
1504
1504
  {
1505
1505
  conditionalSourceFields: c,
1506
1506
  handleCancel: C,
@@ -1511,34 +1511,34 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1511
1511
  ),
1512
1512
  [c, C, V, o, b, d]
1513
1513
  );
1514
- return /* @__PURE__ */ r(fi, { onCloseInterrupt: w, title: z, description: I, content: L, children: n });
1515
- }), gt = ({ children: s }) => /* @__PURE__ */ r(Je, { children: s }), bt = (s, i) => ({
1514
+ return /* @__PURE__ */ r(pi, { onCloseInterrupt: w, title: E, description: I, content: L, children: n });
1515
+ }), yt = ({ children: s }) => /* @__PURE__ */ r(Je, { children: s }), wt = (s, i) => ({
1516
1516
  initial: s ? i : "none",
1517
1517
  sm: s ? "none" : i
1518
- }), Wt = S(function(i) {
1518
+ }), jt = z(function(i) {
1519
1519
  const { remove: e, dragHandleProps: t, editProps: n, insertAfterProps: o, duplicateProps: a } = i, c = x(
1520
1520
  () => [
1521
1521
  {
1522
- Wrapper: pe,
1522
+ Wrapper: he,
1523
1523
  wrapperProps: n,
1524
- Icon: mi,
1524
+ Icon: hi,
1525
1525
  text: "Edit"
1526
1526
  },
1527
1527
  {
1528
- Icon: hi,
1528
+ Icon: gi,
1529
1529
  buttonProps: {
1530
1530
  onClick: e
1531
1531
  },
1532
1532
  text: "Delete"
1533
1533
  },
1534
1534
  {
1535
- Wrapper: pe,
1535
+ Wrapper: he,
1536
1536
  wrapperProps: a,
1537
- Icon: pi,
1537
+ Icon: bi,
1538
1538
  text: "Duplicate"
1539
1539
  },
1540
1540
  {
1541
- Wrapper: pe,
1541
+ Wrapper: he,
1542
1542
  wrapperProps: o,
1543
1543
  Icon: Oe,
1544
1544
  text: "Add after"
@@ -1547,7 +1547,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1547
1547
  // Wrapping icon in a div so that the asChild turns the button into a div
1548
1548
  // so that the drag handle props are not applied to the icon
1549
1549
  // Note: b/c the <button> does not handle the space-press event correctly
1550
- Icon: (l) => /* @__PURE__ */ r("div", { ...l, children: /* @__PURE__ */ r(gi, {}) }),
1550
+ Icon: (l) => /* @__PURE__ */ r("div", { ...l, children: /* @__PURE__ */ r(yi, {}) }),
1551
1551
  text: "Reorder",
1552
1552
  disableOnMobile: !0,
1553
1553
  buttonProps: { ...t, asChild: !0 }
@@ -1556,20 +1556,20 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1556
1556
  [t, a, n, o, e]
1557
1557
  );
1558
1558
  return /* @__PURE__ */ g(Je, { children: [
1559
- /* @__PURE__ */ r(y, { gap: "4", display: bt(!1, "flex"), children: c.map((l) => {
1560
- const f = l.Wrapper ?? gt;
1559
+ /* @__PURE__ */ r(y, { gap: "4", display: wt(!1, "flex"), children: c.map((l) => {
1560
+ const f = l.Wrapper ?? yt;
1561
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);
1562
1562
  }) }),
1563
- /* @__PURE__ */ r(ge, { display: bt(!0, "block"), children: /* @__PURE__ */ r(
1564
- bi,
1563
+ /* @__PURE__ */ r(ge, { display: wt(!0, "block"), children: /* @__PURE__ */ r(
1564
+ wi,
1565
1565
  {
1566
- trigger: /* @__PURE__ */ r(ce, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(yi, {}) }),
1566
+ trigger: /* @__PURE__ */ r(ce, { variant: "ghost", "aria-label": "Actions menu", children: /* @__PURE__ */ r(vi, {}) }),
1567
1567
  closeOnSelect: !1,
1568
1568
  items: c.map((l) => {
1569
1569
  var d;
1570
1570
  if (l.disableOnMobile)
1571
1571
  return null;
1572
- const f = l.Wrapper ?? gt;
1572
+ const f = l.Wrapper ?? yt;
1573
1573
  return {
1574
1574
  ...l.buttonProps,
1575
1575
  onSelect: (d = l.buttonProps) == null ? void 0 : d.onClick,
@@ -1582,12 +1582,12 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1582
1582
  }
1583
1583
  ) })
1584
1584
  ] });
1585
- }), qe = "form-builder", bn = S(function(i) {
1586
- const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a } = i, c = x(() => Be(e), [e]), l = De(c, { formId: qe, disabled: !0 }), f = T(
1587
- (p) => {
1588
- if (p.label === null)
1589
- throw new Error(`Expected a label for field ${p.identifier}`);
1590
- return { ...p, label: Ye(p.label, o), identifier: "" };
1585
+ }), qe = "form-builder", wn = z(function(i) {
1586
+ const { field: e, index: t, sectionIndex: n, takenLabels: o, remove: a } = i, c = x(() => Be(e), [e]), l = De(c, { formId: qe, disabled: !0 }), f = S(
1587
+ (h) => {
1588
+ if (h.label === null)
1589
+ throw new Error(`Expected a label for field ${h.identifier}`);
1590
+ return { ...h, label: Ye(h.label, o), identifier: "" };
1591
1591
  },
1592
1592
  [o]
1593
1593
  ), d = x(
@@ -1605,7 +1605,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1605
1605
  initial: f(e)
1606
1606
  }),
1607
1607
  [f, e, t, n]
1608
- ), h = x(
1608
+ ), p = x(
1609
1609
  () => ({
1610
1610
  parentPath: `fields.${n}.fields`,
1611
1611
  index: t + 1,
@@ -1613,109 +1613,109 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1613
1613
  }),
1614
1614
  [t, n]
1615
1615
  );
1616
- return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (p) => /* @__PURE__ */ r(
1616
+ return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (h) => /* @__PURE__ */ r(
1617
1617
  we,
1618
1618
  {
1619
- ref: p.innerRef,
1620
- ...p.draggableProps,
1621
- ...p.dragHandleProps,
1619
+ ref: h.innerRef,
1620
+ ...h.draggableProps,
1621
+ ...h.dragHandleProps,
1622
1622
  id: `${e.identifier}-card`,
1623
1623
  mb: "4",
1624
1624
  children: /* @__PURE__ */ g(y, { gap: "4", justify: "between", align: "center", children: [
1625
1625
  l,
1626
1626
  /* @__PURE__ */ r(
1627
- Wt,
1627
+ jt,
1628
1628
  {
1629
1629
  remove: a,
1630
1630
  editProps: d,
1631
1631
  duplicateProps: u,
1632
- insertAfterProps: h,
1633
- dragHandleProps: p.dragHandleProps
1632
+ insertAfterProps: p,
1633
+ dragHandleProps: h.dragHandleProps
1634
1634
  }
1635
1635
  )
1636
1636
  ] })
1637
1637
  }
1638
1638
  ) });
1639
- }), yn = S(function(i) {
1640
- var U, A, N, K, Ie, Ce, Fe;
1641
- const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (U = n[e.identifier]) == null ? void 0 : U.disabled, { appearance: c } = wi(), { setFieldValue: l, values: f } = he(), d = vi(), u = $t(f.fields), h = T(
1642
- (E, F) => {
1643
- for (const D of E) {
1644
- const k = F.indexOf(D);
1639
+ }), vn = z(function(i) {
1640
+ var U, A, N, K, Ie, Ce, Fe, ut, ft;
1641
+ const { field: e, index: t, dropState: n, conditionalFieldCounts: o } = i, a = (U = n[e.identifier]) == null ? void 0 : U.disabled, c = _(Oi), { setFieldValue: l, values: f } = pe(), d = xi(), u = Dt(f.fields), p = S(
1642
+ (F, T) => {
1643
+ for (const D of F) {
1644
+ const k = T.indexOf(D);
1645
1645
  l(`fields.${k}.condition`, null).then(), l(`fields.${k}.conditional`, !1).then();
1646
1646
  }
1647
1647
  },
1648
1648
  [l]
1649
- ), p = T(
1650
- (E) => {
1649
+ ), h = S(
1650
+ (F) => {
1651
1651
  var k;
1652
- const F = e.fields[E];
1653
- if (!F)
1652
+ const T = e.fields[F];
1653
+ if (!T)
1654
1654
  throw new Error("Could not find field to remove.");
1655
1655
  const D = [];
1656
- for (const _ of f.fields)
1657
- ((k = _.condition) == null ? void 0 : k.identifier) === F.identifier && D.push(_);
1656
+ for (const O of f.fields)
1657
+ ((k = O.condition) == null ? void 0 : k.identifier) === T.identifier && D.push(O);
1658
1658
  return {
1659
- removing: F,
1659
+ removing: T,
1660
1660
  affectedSections: D,
1661
- action: () => l(`fields.${t}.fields`, Le(e.fields, E))
1661
+ action: () => l(`fields.${t}.fields`, Le(e.fields, F))
1662
1662
  };
1663
1663
  },
1664
1664
  [e.fields, f.fields, l, t]
1665
- ), b = T(
1666
- (E) => {
1667
- const { affectedSections: F, action: D, removing: k } = p(E), _ = () => {
1668
- D().then(), h(F, f.fields);
1665
+ ), b = S(
1666
+ (F) => {
1667
+ const { affectedSections: T, action: D, removing: k } = h(F), O = () => {
1668
+ D().then(), p(T, f.fields);
1669
1669
  };
1670
- if (F.length > 0) {
1671
- const We = F.map((Te) => Te.label).join(", ");
1670
+ if (T.length > 0) {
1671
+ const We = T.map((Te) => Te.label).join(", ");
1672
1672
  return d({
1673
1673
  title: "Remove condition?",
1674
1674
  description: `${k.label} is being used as a condition, deleting it will remove the condition from the ${We} section(s).`,
1675
1675
  severity: "danger",
1676
1676
  actionText: "Remove",
1677
- onAction: _
1677
+ onAction: O
1678
1678
  });
1679
1679
  }
1680
- _();
1680
+ O();
1681
1681
  },
1682
- [p, h, f.fields, d]
1683
- ), z = T(() => {
1684
- const F = e.fields.map((Se, Ht) => p(Ht)).flatMap((Se) => Se.affectedSections), D = F.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, _ = F.map((Se) => Se.label).join(", "), We = F.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${_}` : `Deleting this section will remove the ${k} field(s) it contains.`, Te = Le(f.fields, t), ut = () => l("fields", Te);
1685
- if (F.length > 0)
1682
+ [h, p, f.fields, d]
1683
+ ), E = S(() => {
1684
+ const T = e.fields.map((Se, Ut) => h(Ut)).flatMap((Se) => Se.affectedSections), D = T.length ? "Remove fields and conditions?" : "Remove fields?", k = e.fields.length, O = T.map((Se) => Se.label).join(", "), We = T.length ? `Deleting this section will remove the ${k} field(s) it contains and will remove the conditions from following sections: ${O}` : `Deleting this section will remove the ${k} field(s) it contains.`, Te = Le(f.fields, t), mt = () => l("fields", Te);
1685
+ if (T.length > 0)
1686
1686
  return d({
1687
1687
  title: D,
1688
1688
  description: We,
1689
1689
  severity: "danger",
1690
1690
  actionText: "Remove",
1691
1691
  onAction: () => {
1692
- ut().then(() => {
1693
- h(F, Te);
1692
+ mt().then(() => {
1693
+ p(T, Te);
1694
1694
  });
1695
1695
  }
1696
1696
  });
1697
- ut().then();
1697
+ mt().then();
1698
1698
  }, [
1699
1699
  e.fields,
1700
1700
  f.fields,
1701
1701
  t,
1702
- p,
1702
+ h,
1703
1703
  l,
1704
1704
  d,
1705
- h
1706
- ]), I = T(
1707
- (E) => {
1708
- if (E.label === null)
1709
- throw new Error(`Expected a label for field ${E.identifier}`);
1710
- const F = Ye(E.label, u), D = E.fields.map((k) => {
1711
- const _ = Ye(k.label, u);
1705
+ p
1706
+ ]), I = S(
1707
+ (F) => {
1708
+ if (F.label === null)
1709
+ throw new Error(`Expected a label for field ${F.identifier}`);
1710
+ const T = Ye(F.label, u), D = F.fields.map((k) => {
1711
+ const O = Ye(k.label, u);
1712
1712
  return {
1713
1713
  ...k,
1714
- label: _,
1715
- identifier: Pt(void 0, _)
1714
+ label: O,
1715
+ identifier: $t(void 0, O)
1716
1716
  };
1717
1717
  });
1718
- return { ...E, label: F, fields: D, identifier: "" };
1718
+ return { ...F, label: T, fields: D, identifier: "" };
1719
1719
  },
1720
1720
  [u]
1721
1721
  ), C = x(
@@ -1752,139 +1752,136 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1752
1752
  [I, e, t, f.fields]
1753
1753
  ), v = x(
1754
1754
  () => {
1755
- var E, F;
1756
- return (F = kt(f.fields, (E = e.condition) == null ? void 0 : E.identifier)) == null ? void 0 : F.label;
1755
+ var F, T;
1756
+ return (T = Vt(f.fields, (F = e.condition) == null ? void 0 : F.identifier)) == null ? void 0 : T.label;
1757
1757
  },
1758
1758
  [(A = e.condition) == null ? void 0 : A.identifier, f.fields]
1759
1759
  ), P = Array.isArray((N = e.condition) == null ? void 0 : N.value) ? "contains all of" : "equals";
1760
1760
  if (Xe((K = e.condition) == null ? void 0 : K.value))
1761
1761
  throw new Error("File values are not supported for conditions.");
1762
- const R = Array.isArray((Ie = e.condition) == null ? void 0 : Ie.value) ? (Ce = e.condition) == null ? void 0 : Ce.value.map((E) => typeof E == "string" ? E : E.label).join(", ") : (Fe = e.condition) == null ? void 0 : Fe.value.toString(), X = () => {
1763
- const F = o.filter((_) => _ !== null).length, D = o[t] ?? 0, k = 6 / F * D;
1762
+ const R = Array.isArray((Ie = e.condition) == null ? void 0 : Ie.value) ? (Fe = (Ce = e.condition) == null ? void 0 : Ce.value) == null ? void 0 : Fe.map((F) => typeof F == "string" ? F : F.label).join(", ") : (ft = (ut = e.condition) == null ? void 0 : ut.value) == null ? void 0 : ft.toString(), X = () => {
1763
+ const T = o.filter((O) => O !== null).length, D = o[t] ?? 0, k = 6 / T * D;
1764
1764
  return /* @__PURE__ */ r(
1765
1765
  "div",
1766
1766
  {
1767
1767
  id: `${e.identifier}-floating-point`,
1768
1768
  style: {
1769
1769
  width: `${6 - k}%`,
1770
- marginRight: `${k}%`,
1771
- height: "100%"
1770
+ marginRight: `${k}%`
1772
1771
  }
1773
1772
  }
1774
1773
  );
1775
- }, j = () => e.condition ? (console.log(c), /* @__PURE__ */ g(Je, { children: [
1776
- /* @__PURE__ */ r(
1777
- mt,
1778
- {
1779
- start: `${e.identifier}-card`,
1780
- end: `${e.identifier}-floating-point`,
1781
- startAnchor: "left",
1782
- endAnchor: "right",
1783
- color: c === "light" ? "white" : "black",
1784
- strokeWidth: 2,
1785
- path: "straight",
1786
- showHead: !1
1787
- }
1788
- ),
1789
- /* @__PURE__ */ r(
1790
- mt,
1791
- {
1792
- start: `${e.identifier}-floating-point`,
1793
- end: `${e.condition.identifier}-card`,
1794
- startAnchor: "right",
1795
- endAnchor: "left",
1796
- color: c === "light" ? "white" : "black",
1797
- strokeWidth: 2,
1798
- path: "grid",
1799
- gridBreak: "0"
1800
- }
1801
- )
1802
- ] })) : null;
1803
- return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (E) => /* @__PURE__ */ g(
1774
+ }, j = () => {
1775
+ if (!e.condition)
1776
+ return null;
1777
+ const F = c === "light" ? "black" : "white";
1778
+ return /* @__PURE__ */ g(Je, { children: [
1779
+ /* @__PURE__ */ r(
1780
+ ht,
1781
+ {
1782
+ start: `${e.identifier}-card`,
1783
+ end: `${e.identifier}-floating-point`,
1784
+ startAnchor: "left",
1785
+ endAnchor: "right",
1786
+ color: F,
1787
+ strokeWidth: 2,
1788
+ path: "straight",
1789
+ showHead: !1
1790
+ }
1791
+ ),
1792
+ /* @__PURE__ */ r(
1793
+ ht,
1794
+ {
1795
+ start: `${e.identifier}-floating-point`,
1796
+ end: `${e.condition.identifier}-card`,
1797
+ startAnchor: "right",
1798
+ endAnchor: "left",
1799
+ color: F,
1800
+ strokeWidth: 2,
1801
+ path: "grid",
1802
+ gridBreak: "0"
1803
+ }
1804
+ )
1805
+ ] });
1806
+ };
1807
+ return /* @__PURE__ */ r(rt, { draggableId: e.identifier, index: t, children: (F) => /* @__PURE__ */ g(
1804
1808
  y,
1805
1809
  {
1806
- ref: E.innerRef,
1807
- ...E.draggableProps,
1808
- ...E.dragHandleProps,
1810
+ ref: F.innerRef,
1811
+ ...F.draggableProps,
1812
+ ...F.dragHandleProps,
1809
1813
  direction: "row",
1810
1814
  justify: "center",
1811
1815
  align: "center",
1816
+ mb: "4",
1812
1817
  children: [
1813
- o.some((F) => F !== null) && X(),
1818
+ o.some((T) => T !== null) && X(),
1814
1819
  e.condition && j(),
1815
- /* @__PURE__ */ r(
1816
- we,
1817
- {
1818
- id: `${e.identifier}-card`,
1819
- mb: "4",
1820
- style: { flexGrow: "1" },
1821
- children: /* @__PURE__ */ g(y, { gap: "3", justify: "between", align: "center", children: [
1822
- /* @__PURE__ */ g(y, { direction: "column", gap: "2", grow: "1", children: [
1823
- /* @__PURE__ */ g(y, { direction: "column", children: [
1824
- /* @__PURE__ */ r(Me, { as: "h3", size: "3", children: e.label }),
1825
- /* @__PURE__ */ r($, { className: Ne.description, children: e.description })
1826
- ] }),
1827
- e.condition && /* @__PURE__ */ r($, { size: "1", children: /* @__PURE__ */ g(xi, { children: [
1828
- "Display only if ",
1829
- /* @__PURE__ */ r(ft, { children: v }),
1830
- " ",
1831
- P,
1832
- " ",
1833
- /* @__PURE__ */ r(ft, { children: R })
1834
- ] }) }),
1835
- /* @__PURE__ */ r(
1836
- nt,
1820
+ /* @__PURE__ */ r(we, { id: `${e.identifier}-card`, style: { flexGrow: "1" }, children: /* @__PURE__ */ g(y, { gap: "3", justify: "between", align: "center", children: [
1821
+ /* @__PURE__ */ g(y, { direction: "column", gap: "2", grow: "1", children: [
1822
+ /* @__PURE__ */ g(y, { direction: "column", children: [
1823
+ /* @__PURE__ */ r(Me, { as: "h3", size: "3", children: e.label }),
1824
+ /* @__PURE__ */ r($, { className: Ne.description, children: e.description })
1825
+ ] }),
1826
+ e.condition && /* @__PURE__ */ r($, { size: "1", children: /* @__PURE__ */ g(Ii, { children: [
1827
+ "Display only if ",
1828
+ /* @__PURE__ */ r(pt, { children: v }),
1829
+ " ",
1830
+ P,
1831
+ " ",
1832
+ /* @__PURE__ */ r(pt, { children: R })
1833
+ ] }) }),
1834
+ /* @__PURE__ */ r(
1835
+ nt,
1836
+ {
1837
+ droppableId: e.identifier,
1838
+ type: "SECTION",
1839
+ isDropDisabled: a,
1840
+ children: (T) => /* @__PURE__ */ g(
1841
+ y,
1837
1842
  {
1838
- droppableId: e.identifier,
1839
- type: "SECTION",
1840
- isDropDisabled: a,
1841
- children: (F) => /* @__PURE__ */ g(
1842
- y,
1843
- {
1844
- ref: F.innerRef,
1845
- ...F.droppableProps,
1846
- direction: "column",
1847
- gap: "0",
1848
- children: [
1849
- e.fields.map((D, k) => /* @__PURE__ */ r(
1850
- bn,
1851
- {
1852
- field: D,
1853
- index: k,
1854
- sectionIndex: t,
1855
- remove: () => b(k),
1856
- takenLabels: u
1857
- },
1858
- D.identifier
1859
- )),
1860
- F.placeholder,
1861
- /* @__PURE__ */ r(pe, { ...V, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
1862
- /* @__PURE__ */ r(Oe, {}),
1863
- " Add a field"
1864
- ] }) })
1865
- ]
1866
- }
1867
- )
1843
+ ref: T.innerRef,
1844
+ ...T.droppableProps,
1845
+ direction: "column",
1846
+ gap: "0",
1847
+ children: [
1848
+ e.fields.map((D, k) => /* @__PURE__ */ r(
1849
+ wn,
1850
+ {
1851
+ field: D,
1852
+ index: k,
1853
+ sectionIndex: t,
1854
+ remove: () => b(k),
1855
+ takenLabels: u
1856
+ },
1857
+ D.identifier
1858
+ )),
1859
+ T.placeholder,
1860
+ /* @__PURE__ */ r(he, { ...V, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
1861
+ /* @__PURE__ */ r(Oe, {}),
1862
+ " Add a field"
1863
+ ] }) })
1864
+ ]
1868
1865
  }
1869
1866
  )
1870
- ] }),
1871
- /* @__PURE__ */ r(
1872
- Wt,
1873
- {
1874
- remove: z,
1875
- insertAfterProps: w,
1876
- dragHandleProps: E.dragHandleProps,
1877
- editProps: C,
1878
- duplicateProps: L
1879
- }
1880
- )
1881
- ] })
1882
- }
1883
- )
1867
+ }
1868
+ )
1869
+ ] }),
1870
+ /* @__PURE__ */ r(
1871
+ jt,
1872
+ {
1873
+ remove: E,
1874
+ insertAfterProps: w,
1875
+ dragHandleProps: F.dragHandleProps,
1876
+ editProps: C,
1877
+ duplicateProps: L
1878
+ }
1879
+ )
1880
+ ] }) })
1884
1881
  ]
1885
1882
  }
1886
1883
  ) });
1887
- }), wn = (s, i) => {
1884
+ }), xn = (s, i) => {
1888
1885
  var t;
1889
1886
  const e = { ...s };
1890
1887
  switch (i.type) {
@@ -1899,7 +1896,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1899
1896
  case "update":
1900
1897
  return i.state;
1901
1898
  }
1902
- }, vn = (s, i) => {
1899
+ }, In = (s, i) => {
1903
1900
  if (i)
1904
1901
  for (let e = 0; e < s.length; e++) {
1905
1902
  const t = s[e];
@@ -1909,7 +1906,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1909
1906
  return e;
1910
1907
  }
1911
1908
  }
1912
- }, yt = (s) => {
1909
+ }, vt = (s) => {
1913
1910
  var e, t, n;
1914
1911
  const i = {};
1915
1912
  for (let o = 0; o < s.length; o++) {
@@ -1920,52 +1917,52 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1920
1917
  (t = a.condition) != null && t.identifier && l.add(a.condition.identifier), i[a.identifier] = {
1921
1918
  disabled: !1,
1922
1919
  conditionFields: l,
1923
- conditionIndex: vn(s, (n = a.condition) == null ? void 0 : n.identifier),
1920
+ conditionIndex: In(s, (n = a.condition) == null ? void 0 : n.identifier),
1924
1921
  index: o,
1925
1922
  label: a.label
1926
1923
  };
1927
1924
  }
1928
1925
  return i;
1929
- }, wt = (s, i) => {
1926
+ }, xt = (s, i) => {
1930
1927
  for (const [e, t] of Object.entries(s))
1931
1928
  if (t.identifier === i)
1932
1929
  return [t, e];
1933
- }, xn = S(function() {
1934
- const { values: i, setFieldValue: e } = he(), [t, n] = Ti(wn, i.fields, yt), { showInfo: o } = Ii();
1930
+ }, Cn = z(function() {
1931
+ const { values: i, setFieldValue: e } = pe(), [t, n] = Si(xn, i.fields, vt), { showInfo: o } = Ci();
1935
1932
  ve(() => {
1936
- n({ type: "update", state: yt(i.fields) });
1933
+ n({ type: "update", state: vt(i.fields) });
1937
1934
  }, [n, i.fields]);
1938
- const a = T((d) => {
1935
+ const a = S((d) => {
1939
1936
  d.type === "SECTION" && n({ type: "hold", fieldId: d.draggableId });
1940
- }, []), c = T(
1937
+ }, []), c = S(
1941
1938
  (d) => {
1942
- const { source: u, destination: h, type: p, reason: b, draggableId: z } = d;
1943
- if (n({ type: "release" }), !h || b === "CANCEL")
1939
+ const { source: u, destination: p, type: h, reason: b, draggableId: E } = d;
1940
+ if (n({ type: "release" }), !p || b === "CANCEL")
1944
1941
  return;
1945
- if (p === "ROOT") {
1946
- const L = t[z];
1942
+ if (h === "ROOT") {
1943
+ const L = t[E];
1947
1944
  if (!L)
1948
1945
  throw new Error("Could not find section context.");
1949
1946
  let v = typeof L.conditionIndex < "u" ? (
1950
1947
  // cannot move a section with a condition before the condition's field
1951
- Math.max(L.conditionIndex + 1, h.index)
1952
- ) : h.index;
1948
+ Math.max(L.conditionIndex + 1, p.index)
1949
+ ) : p.index;
1953
1950
  for (const P of Object.values(t))
1954
1951
  P.conditionIndex === u.index && (v = Math.min(v, P.index - 1));
1955
- return v != h.index && o({
1952
+ return v != p.index && o({
1956
1953
  title: "Reordered sections",
1957
1954
  description: "Sections with conditions must be below the fields they reference."
1958
1955
  }), e("fields", Ke(i.fields, u.index, v));
1959
1956
  }
1960
- if (p !== "SECTION")
1957
+ if (h !== "SECTION")
1961
1958
  throw new Error("Unexpected droppable type.");
1962
- const [I, C] = wt(i.fields, u.droppableId) ?? [], [w, V] = wt(i.fields, h.droppableId) ?? [];
1959
+ const [I, C] = xt(i.fields, u.droppableId) ?? [], [w, V] = xt(i.fields, p.droppableId) ?? [];
1963
1960
  if (!(I != null && I.fields) || !w)
1964
1961
  throw new Error("Could not find section with fields.");
1965
1962
  if (I.identifier === w.identifier)
1966
1963
  e(
1967
1964
  `fields.${C}.fields`,
1968
- Ke(I.fields, u.index, h.index)
1965
+ Ke(I.fields, u.index, p.index)
1969
1966
  ).then();
1970
1967
  else {
1971
1968
  const L = I.fields[u.index];
@@ -1973,7 +1970,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1973
1970
  throw new Error("Could not find field to reorder.");
1974
1971
  e(`fields.${C}.fields`, Le(I.fields, u.index)).then(), e(
1975
1972
  `fields.${V}.fields`,
1976
- Lt(w.fields, h.index, L)
1973
+ kt(w.fields, p.index, L)
1977
1974
  ).then();
1978
1975
  }
1979
1976
  },
@@ -1990,7 +1987,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1990
1987
  let d = 1;
1991
1988
  return i.fields.map((u) => u.conditional ? d++ : null);
1992
1989
  };
1993
- return /* @__PURE__ */ r(Ct, { onDragStart: a, onDragEnd: c, children: /* @__PURE__ */ r(nt, { droppableId: "droppable", type: "ROOT", children: (d) => /* @__PURE__ */ g(
1990
+ return /* @__PURE__ */ r(Tt, { onDragStart: a, onDragEnd: c, children: /* @__PURE__ */ r(nt, { droppableId: "droppable", type: "ROOT", children: (d) => /* @__PURE__ */ g(
1994
1991
  y,
1995
1992
  {
1996
1993
  ref: d.innerRef,
@@ -1998,56 +1995,56 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
1998
1995
  direction: "column",
1999
1996
  gap: "0",
2000
1997
  children: [
2001
- i.fields.map((u, h) => /* @__PURE__ */ r(
2002
- yn,
1998
+ i.fields.map((u, p) => /* @__PURE__ */ r(
1999
+ vn,
2003
2000
  {
2004
2001
  field: u,
2005
- index: h,
2002
+ index: p,
2006
2003
  dropState: t,
2007
2004
  conditionalFieldCounts: f()
2008
2005
  },
2009
2006
  u.label
2010
2007
  )),
2011
2008
  d.placeholder,
2012
- /* @__PURE__ */ r(pe, { ...l, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
2009
+ /* @__PURE__ */ r(he, { ...l, children: /* @__PURE__ */ g(G, { type: "button", variant: "outline", children: [
2013
2010
  /* @__PURE__ */ r(Oe, {}),
2014
2011
  " Add a section"
2015
2012
  ] }) })
2016
2013
  ]
2017
2014
  }
2018
2015
  ) }) });
2019
- }), In = {
2016
+ }), Fn = {
2020
2017
  title: "",
2021
2018
  description: "",
2022
2019
  fields: []
2023
- }, Cn = new be({
2020
+ }, Tn = new be({
2024
2021
  label: "Title",
2025
2022
  minLength: 0,
2026
2023
  maxLength: 100,
2027
2024
  required: !0,
2028
2025
  identifier: "title"
2029
- }), Fn = { formId: qe, placeholder: "Give your form a title." }, Tn = new ye({
2026
+ }), Sn = { formId: qe, placeholder: "Give your form a title." }, zn = new ye({
2030
2027
  label: "Description",
2031
2028
  minLength: 0,
2032
2029
  maxLength: 1e3,
2033
2030
  required: !1,
2034
2031
  identifier: "description"
2035
- }), Sn = { formId: qe, placeholder: "Explain the purpose of this form." }, zn = () => {
2032
+ }), En = { formId: qe, placeholder: "Explain the purpose of this form." }, An = () => {
2036
2033
  alert("This is a form preview, your data will not be saved.");
2037
- }, Wn = S(
2034
+ }, jn = z(
2038
2035
  xe((s, i) => {
2039
- const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = T((p) => {
2036
+ const { onCancel: e, onSave: t, revision: n } = s, o = n ? "Edit form" : "Create a new form", { heading: a = o } = s, c = S((h) => {
2040
2037
  const b = {};
2041
- if (p.title || (b.title = "Title is required."), (!p.fields || p.fields.length === 0) && (b.fields = "At least one field is required."), _e(b))
2038
+ if (h.title || (b.title = "Title is required."), (!h.fields || h.fields.length === 0) && (b.fields = "At least one field is required."), _e(b))
2042
2039
  return b;
2043
2040
  }, []), l = tt({
2044
- initialValues: Hi(n) ?? In,
2041
+ initialValues: Ui(n) ?? Fn,
2045
2042
  validate: c,
2046
- onSubmit: (p) => t(p),
2043
+ onSubmit: (h) => t(h),
2047
2044
  // only validate the entire for on submit
2048
2045
  validateOnChange: !1,
2049
2046
  validateOnBlur: !1
2050
- }), f = x(() => _t(l.values), [l.values]), d = De(Cn, Fn), u = De(Tn, Sn), h = x(
2047
+ }), f = x(() => Mt(l.values), [l.values]), d = De(Tn, Sn), u = De(zn, En), p = x(
2051
2048
  () => typeof a == "object" ? a : /* @__PURE__ */ r(Me, { children: a }),
2052
2049
  [a]
2053
2050
  );
@@ -2057,7 +2054,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
2057
2054
  /* @__PURE__ */ r(Q.Trigger, { value: "preview", children: "Preview" })
2058
2055
  ] }),
2059
2056
  /* @__PURE__ */ g(Q.Content, { value: "edit", children: [
2060
- h,
2057
+ p,
2061
2058
  /* @__PURE__ */ g($, { children: [
2062
2059
  "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",
2063
2060
  " ",
@@ -2070,7 +2067,7 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
2070
2067
  /* @__PURE__ */ g(it, { value: l, children: [
2071
2068
  d,
2072
2069
  u,
2073
- /* @__PURE__ */ r(xn, {}),
2070
+ /* @__PURE__ */ r(Cn, {}),
2074
2071
  /* @__PURE__ */ r($, { severity: "danger", size: "1", children: typeof l.errors.fields == "string" && l.errors.fields })
2075
2072
  ] }),
2076
2073
  /* @__PURE__ */ g(y, { justify: "end", gap: "2", children: [
@@ -2079,40 +2076,40 @@ const De = (s, i) => x(() => !i || !s ? null : s.getInput(i), [s, i]), Mt = (s,
2079
2076
  ] })
2080
2077
  ] }) })
2081
2078
  ] }),
2082
- /* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(dt, { schema: f, onSubmit: zn }) })
2079
+ /* @__PURE__ */ r(Q.Content, { value: "preview", children: /* @__PURE__ */ r(dt, { schema: f, onSubmit: An }) })
2083
2080
  ] }) });
2084
2081
  })
2085
2082
  );
2086
2083
  export {
2087
2084
  fe as BooleanField,
2088
- Mi as BooleanInput,
2085
+ Ni as BooleanInput,
2089
2086
  Ge as DateField,
2090
- Ni as DateInput,
2087
+ qi as DateInput,
2091
2088
  Z as FieldSection,
2092
- Rn as FormBrowser,
2093
- Wn as FormBuilder,
2089
+ Bn as FormBrowser,
2090
+ jn as FormBuilder,
2094
2091
  dt as FormRenderer,
2095
- Nn as FormSubmissionBrowser,
2096
- Mn as FormSubmissionViewer,
2092
+ qn as FormSubmissionBrowser,
2093
+ Nn as FormSubmissionViewer,
2097
2094
  $e as MultiSelectField,
2098
- Ki as MultiSelectInput,
2095
+ Zi as MultiSelectInput,
2099
2096
  Pe as MultiStringField,
2100
- Ui as MultiStringInput,
2097
+ Ki as MultiStringInput,
2101
2098
  Y as NumberField,
2102
- Ri as NumberInput,
2103
- Bn as PatchField,
2104
- qn as PatchFormProvider,
2099
+ Bi as NumberInput,
2100
+ Wn as PatchField,
2101
+ Hn as PatchFormProvider,
2105
2102
  ke as SelectField,
2106
- Wi as SelectInput,
2103
+ ji as SelectInput,
2107
2104
  be as StringField,
2108
- Bi as StringInput,
2105
+ Wi as StringInput,
2109
2106
  ye as TextField,
2110
- qi as TextInput,
2107
+ Hi as TextInput,
2111
2108
  Be as deserialize,
2112
- Dt as deserializeField,
2113
- _t as formRevisionToSchema,
2114
- Ot as isConditionMet,
2109
+ Ot as deserializeField,
2110
+ Mt as formRevisionToSchema,
2111
+ Rt as isConditionMet,
2115
2112
  De as useFieldInput,
2116
- Mt as useFieldInputs,
2113
+ Nt as useFieldInputs,
2117
2114
  Xe as valueIsFile
2118
2115
  };