@middag-io/react 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist-lib/{DateField-BCCidKwl.js → DateField-CcRD2r-Z.js} +5 -5
  2. package/dist-lib/{DateRangeField-CvU7wiyr.js → DateRangeField-DKZMfKB2.js} +199 -198
  3. package/dist-lib/{DocumentField-5uXJyXlL.js → DocumentField-DjnK9T7o.js} +3 -3
  4. package/dist-lib/{FormPanelBlock-DJ0T69X7.js → FormPanelBlock-BW2oi2_O.js} +635 -556
  5. package/dist-lib/{MarkdownContent-aIIUC0Fl.js → MarkdownContent-C-X2QGA2.js} +18 -17
  6. package/dist-lib/MarkdownContent-D5FIjx_W.js +2 -0
  7. package/dist-lib/{PhoneField-DpHb6FQE.js → PhoneField-D_djeYhK.js} +38 -37
  8. package/dist-lib/base/blocks/ActionGridBlock.d.ts.map +1 -1
  9. package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
  10. package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
  11. package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
  12. package/dist-lib/base/blocks/StatusStripBlock.d.ts.map +1 -1
  13. package/dist-lib/base/blocks/TabbedPanelBlock.d.ts.map +1 -1
  14. package/dist-lib/base/blocks/WorkflowProgressBlock.d.ts.map +1 -1
  15. package/dist-lib/base/form/FormField.d.ts +2 -1
  16. package/dist-lib/base/form/FormField.d.ts.map +1 -1
  17. package/dist-lib/base/form/fields/DateRangeField.d.ts +1 -1
  18. package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
  19. package/dist-lib/base/form/fields/FileUploadField.d.ts +2 -2
  20. package/dist-lib/base/form/fields/FileUploadField.d.ts.map +1 -1
  21. package/dist-lib/base/form/fields/NativeSelectField.d.ts.map +1 -1
  22. package/dist-lib/base/form/fields/RatingField.d.ts +1 -1
  23. package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
  24. package/dist-lib/base/form/fields/SlugField.d.ts.map +1 -1
  25. package/dist-lib/base/form/form-schema-builder.d.ts.map +1 -1
  26. package/dist-lib/base/form/form-utils.d.ts +15 -0
  27. package/dist-lib/base/form/form-utils.d.ts.map +1 -1
  28. package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
  29. package/dist-lib/base/partials/StatusBar/index.d.ts.map +1 -1
  30. package/dist-lib/base/partials/StatusIndicator/index.d.ts.map +1 -1
  31. package/dist-lib/base/utils/time.d.ts.map +1 -1
  32. package/dist-lib/{button-Ba1PcsOx.js → button-Bm0X9WO5.js} +1 -1
  33. package/dist-lib/{calendar-DnlbmjNu.js → calendar-CucaItjm.js} +51 -50
  34. package/dist-lib/{chevron-right-Casn6MFU.js → chevron-right-DY3SdwdB.js} +1 -1
  35. package/dist-lib/chunk-DeC0fbbY.js +22 -0
  36. package/dist-lib/{combobox-DZ_qm1VH.js → combobox-yfHHEi6f.js} +65 -64
  37. package/dist-lib/contracts/block-data/form.d.ts +64 -197
  38. package/dist-lib/contracts/block-data/form.d.ts.map +1 -1
  39. package/dist-lib/contracts/block-data/shared.d.ts +1 -16
  40. package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
  41. package/dist-lib/contracts/generated/contract-schema.d.ts +2 -1
  42. package/dist-lib/contracts/generated/contract-schema.d.ts.map +1 -1
  43. package/dist-lib/contracts/generated/contract-types.d.ts +239 -4
  44. package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
  45. package/dist-lib/contracts/generated/index.d.ts +1 -1
  46. package/dist-lib/contracts/page-contract-schema.d.ts +1 -0
  47. package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
  48. package/dist-lib/contracts/page-contract.d.ts +0 -2
  49. package/dist-lib/contracts/page-contract.d.ts.map +1 -1
  50. package/dist-lib/contracts/shared-props.d.ts +4 -0
  51. package/dist-lib/contracts/shared-props.d.ts.map +1 -1
  52. package/dist-lib/{dist-B-MyAb3x.js → dist-B7gC4peV.js} +1 -1
  53. package/dist-lib/{dist-7c0PXlrb.js → dist-Bbnbom8g.js} +2 -2
  54. package/dist-lib/{dist-DuO9WodV.js → dist-DdgpZG8v.js} +3 -3
  55. package/dist-lib/{document-validation-YgxIqb8k.js → document-validation-DX0fB9cu.js} +2 -2
  56. package/dist-lib/i18n/resolve-field-error.d.ts +2 -2
  57. package/dist-lib/i18n/resolve-field-error.d.ts.map +1 -1
  58. package/dist-lib/index.d.ts +1 -1
  59. package/dist-lib/index.d.ts.map +1 -1
  60. package/dist-lib/{input-CdUVNe54.js → input-BC9whKEm.js} +1 -1
  61. package/dist-lib/middag-react.js +3274 -3217
  62. package/dist-lib/{popover-Bxsp1hlN.js → popover-BaiQ-JSz.js} +29 -29
  63. package/dist-lib/{resolve-field-error-bG2_dMOY.js → resolve-field-error-dbUy6DeX.js} +2155 -2069
  64. package/dist-lib/{scroll-area-B9TZ05bl.js → scroll-area-D94_a2-1.js} +57 -57
  65. package/dist-lib/{skeleton-HpnbVVji.js → skeleton-xL_Hzxj-.js} +1 -1
  66. package/dist-lib/{use-mobile-Kp3Dy8mh.js → use-mobile-CBJJLRL8.js} +36 -36
  67. package/dist-lib/{useTranslation-CHN-BFba.js → useTranslation-BuyMWJ9T.js} +1 -1
  68. package/dist-lib/{utils-Yj2czlvU.js → utils-CpaZ5_iF.js} +517 -538
  69. package/package.json +1 -1
  70. package/dist-lib/MarkdownContent-CN-ZN_69.js +0 -2
  71. /package/dist-lib/{dist-CmB86BdM.js → dist-3F0-lo64.js} +0 -0
  72. /package/dist-lib/{dist-axU0pUop.js → dist-DdfRh_k3.js} +0 -0
  73. /package/dist-lib/{floating-ui.react-dom-BnOzLaz1.js → floating-ui.react-dom-CNntavPo.js} +0 -0
@@ -1,33 +1,32 @@
1
- import { t as e } from "./utils-Yj2czlvU.js";
2
- import { B as t, C as n, D as r, E as i, F as a, G as o, H as s, L as c, T as l, U as u, V as d, W as f, _ as p, _t as m, a as h, c as g, ct as _, d as v, dt as y, f as b, ft as x, g as S, gt as C, h as ee, i as w, k as T, l as E, lt as D, m as O, mt as k, n as A, o as te, p as ne, r as re, s as ie, st as ae, t as oe, u as se, ut as j, v as ce, vt as le, w as ue, y as de } from "./resolve-field-error-bG2_dMOY.js";
3
- import { t as fe } from "./button-Ba1PcsOx.js";
4
- import { t as pe } from "./useTranslation-CHN-BFba.js";
5
- import { t as me } from "./skeleton-HpnbVVji.js";
6
- import { t as he } from "./document-validation-YgxIqb8k.js";
7
- import M, { Suspense as N, lazy as P, useCallback as ge, useEffect as _e, useId as ve, useMemo as F, useRef as ye, useState as be } from "react";
8
- import { router as xe } from "@inertiajs/core";
9
- import { Fragment as Se, jsx as I, jsxs as L } from "react/jsx-runtime";
1
+ import { C as e, D as t, E as n, F as r, G as i, H as a, J as o, K as s, L as c, St as l, T as u, V as d, W as f, Y as p, _ as m, a as h, bt as g, c as _, d as v, dt as y, f as b, ft as x, g as S, gt as C, h as w, ht as T, i as E, k as D, l as O, m as k, mt as A, n as j, o as ee, p as te, pt as ne, q as re, r as ie, s as ae, t as M, u as oe, v as se, vt as N, w as ce, xt as le, y as ue, z as de } from "./resolve-field-error-dbUy6DeX.js";
2
+ import { t as fe } from "./button-Bm0X9WO5.js";
3
+ import { t as pe } from "./useTranslation-BuyMWJ9T.js";
4
+ import { t as me } from "./utils-CpaZ5_iF.js";
5
+ import { t as he } from "./skeleton-xL_Hzxj-.js";
6
+ import P, { Suspense as ge, lazy as _e, useCallback as ve, useEffect as ye, useId as be, useMemo as F, useRef as xe, useState as Se } from "react";
7
+ import { router as Ce } from "@inertiajs/core";
8
+ import { Fragment as we, jsx as I, jsxs as L } from "react/jsx-runtime";
10
9
  //#region node_modules/react-hook-form/dist/index.esm.mjs
11
- var Ce = (e) => e.type === "checkbox", R = (e) => e instanceof Date, z = (e) => e == null, we = (e) => typeof e == "object", B = (e) => !z(e) && !Array.isArray(e) && we(e) && !R(e), Te = (e) => B(e) && e.target ? Ce(e.target) ? e.target.checked : e.target.value : e, Ee = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), De = (e) => {
10
+ var Te = (e) => e.type === "checkbox", R = (e) => e instanceof Date, z = (e) => e == null, Ee = (e) => typeof e == "object", B = (e) => !z(e) && !Array.isArray(e) && Ee(e) && !R(e), De = (e) => B(e) && e.target ? Te(e.target) ? e.target.checked : e.target.value : e, Oe = (e, t) => t.split(".").some((t, n, r) => !isNaN(Number(t)) && e.has(r.slice(0, n).join("."))), ke = (e) => {
12
11
  let t = e.constructor && e.constructor.prototype;
13
12
  return B(t) && t.hasOwnProperty("isPrototypeOf");
14
- }, Oe = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
13
+ }, Ae = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
15
14
  function V(e) {
16
15
  if (e instanceof Date) return new Date(e);
17
16
  let t = typeof FileList < "u" && e instanceof FileList;
18
- if (Oe && (e instanceof Blob || t)) return e;
17
+ if (Ae && (e instanceof Blob || t)) return e;
19
18
  let n = Array.isArray(e);
20
- if (!n && !(B(e) && De(e))) return e;
19
+ if (!n && !(B(e) && ke(e))) return e;
21
20
  let r = n ? [] : Object.create(Object.getPrototypeOf(e));
22
21
  for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = V(e[t]));
23
22
  return r;
24
23
  }
25
- var ke = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Ae = (e) => Array.isArray(e) ? e.filter(Boolean) : [], je = (e) => Ae(e.replace(/["|']|\]/g, "").split(/\.|\[/)), U = (e, t, n) => {
24
+ var je = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Me = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Ne = (e) => Me(e.replace(/["|']|\]/g, "").split(/\.|\[/)), U = (e, t, n) => {
26
25
  if (!t || !B(e)) return n;
27
- let r = (ke(t) ? [t] : je(t)).reduce((e, t) => z(e) ? void 0 : e[t], e);
26
+ let r = (je(t) ? [t] : Ne(t)).reduce((e, t) => z(e) ? void 0 : e[t], e);
28
27
  return H(r) || r === e ? H(e[t]) ? n : e[t] : r;
29
28
  }, W = (e) => typeof e == "boolean", G = (e) => typeof e == "function", K = (e, t, n) => {
30
- let r = -1, i = ke(t) ? [t] : je(t), a = i.length, o = a - 1;
29
+ let r = -1, i = je(t) ? [t] : Ne(t), a = i.length, o = a - 1;
31
30
  for (; ++r < a;) {
32
31
  let t = i[r], a = n;
33
32
  if (r !== o) {
@@ -37,20 +36,20 @@ var ke = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Ae = (e) => Array.isAr
37
36
  if (t === "__proto__" || t === "constructor" || t === "prototype") return;
38
37
  e[t] = a, e = e[t];
39
38
  }
40
- }, q = {
39
+ }, Pe = {
41
40
  BLUR: "blur",
42
41
  FOCUS_OUT: "focusout",
43
42
  CHANGE: "change",
44
43
  SUBMIT: "submit",
45
44
  TRIGGER: "trigger",
46
45
  VALID: "valid"
47
- }, J = {
46
+ }, q = {
48
47
  onBlur: "onBlur",
49
48
  onChange: "onChange",
50
49
  onSubmit: "onSubmit",
51
50
  onTouched: "onTouched",
52
51
  all: "all"
53
- }, Y = {
52
+ }, J = {
54
53
  max: "max",
55
54
  min: "min",
56
55
  maxLength: "maxLength",
@@ -58,19 +57,19 @@ var ke = (e) => /^\w*$/.test(e), H = (e) => e === void 0, Ae = (e) => Array.isAr
58
57
  pattern: "pattern",
59
58
  required: "required",
60
59
  validate: "validate"
61
- }, Me = "form", Ne = "root", Pe = M.createContext(null);
62
- Pe.displayName = "HookFormControlContext";
63
- var Fe = () => M.useContext(Pe), Ie = (e, t, n, r = !0) => {
60
+ }, Fe = "form", Ie = "root", Le = P.createContext(null);
61
+ Le.displayName = "HookFormControlContext";
62
+ var Re = () => P.useContext(Le), ze = (e, t, n, r = !0) => {
64
63
  let i = {};
65
64
  for (let a in e) Object.defineProperty(i, a, { get: () => {
66
65
  let i = a;
67
- return t._proxyFormState[i] !== J.all && (t._proxyFormState[i] = !r || J.all), n && (n[i] = !0), e[i];
66
+ return t._proxyFormState[i] !== q.all && (t._proxyFormState[i] = !r || q.all), n && (n[i] = !0), e[i];
68
67
  } });
69
68
  return i;
70
- }, Le = typeof window < "u" ? M.useLayoutEffect : M.useEffect, X = (e) => typeof e == "string", Re = (e, t, n, r, i) => X(e) ? (r && t.watch.add(e), U(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), U(n, e))) : (r && (t.watchAll = !0), n), ze = (e) => z(e) || !we(e);
71
- function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
69
+ }, Be = typeof window < "u" ? P.useLayoutEffect : P.useEffect, Y = (e) => typeof e == "string", Ve = (e, t, n, r, i) => Y(e) ? (r && t.watch.add(e), U(n, e, i)) : Array.isArray(e) ? e.map((e) => (r && t.watch.add(e), U(n, e))) : (r && (t.watchAll = !0), n), He = (e) => z(e) || !Ee(e);
70
+ function X(e, t, n = /* @__PURE__ */ new WeakSet()) {
72
71
  if (e === t) return !0;
73
- if (ze(e) || ze(t)) return Object.is(e, t);
72
+ if (He(e) || He(t)) return Object.is(e, t);
74
73
  if (R(e) && R(t)) return Object.is(e.getTime(), t.getTime());
75
74
  let r = Object.keys(e), i = Object.keys(t);
76
75
  if (r.length !== i.length) return !1;
@@ -81,30 +80,30 @@ function Z(e, t, n = /* @__PURE__ */ new WeakSet()) {
81
80
  if (!(i in t)) return !1;
82
81
  if (i !== "ref") {
83
82
  let e = t[i];
84
- if (R(r) && R(e) || (B(r) || Array.isArray(r)) && (B(e) || Array.isArray(e)) ? !Z(r, e, n) : !Object.is(r, e)) return !1;
83
+ if (R(r) && R(e) || (B(r) || Array.isArray(r)) && (B(e) || Array.isArray(e)) ? !X(r, e, n) : !Object.is(r, e)) return !1;
85
84
  }
86
85
  }
87
86
  return !0;
88
87
  }
89
- function Be(e) {
90
- let t = Fe(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = M.useRef(i), l = M.useRef(s), u = M.useRef(void 0), d = M.useRef(n), f = M.useRef(r);
88
+ function Ue(e) {
89
+ let t = Re(), { control: n = t, name: r, defaultValue: i, disabled: a, exact: o, compute: s } = e || {}, c = P.useRef(i), l = P.useRef(s), u = P.useRef(void 0), d = P.useRef(n), f = P.useRef(r);
91
90
  l.current = s;
92
- let [p, m] = M.useState(() => {
91
+ let [p, m] = P.useState(() => {
93
92
  let e = n._getWatch(r, c.current);
94
93
  return l.current ? l.current(e) : e;
95
- }), h = M.useCallback((e) => {
96
- let t = Re(r, n._names, e || n._formValues, !1, c.current);
94
+ }), h = P.useCallback((e) => {
95
+ let t = Ve(r, n._names, e || n._formValues, !1, c.current);
97
96
  return l.current ? l.current(t) : t;
98
97
  }, [
99
98
  n._formValues,
100
99
  n._names,
101
100
  r
102
- ]), g = M.useCallback((e) => {
101
+ ]), g = P.useCallback((e) => {
103
102
  if (!a) {
104
- let t = Re(r, n._names, e || n._formValues, !1, c.current);
103
+ let t = Ve(r, n._names, e || n._formValues, !1, c.current);
105
104
  if (l.current) {
106
105
  let e = l.current(t);
107
- Z(e, u.current) || (m(e), u.current = e);
106
+ X(e, u.current) || (m(e), u.current = e);
108
107
  } else m(t);
109
108
  }
110
109
  }, [
@@ -113,7 +112,7 @@ function Be(e) {
113
112
  a,
114
113
  r
115
114
  ]);
116
- Le(() => ((d.current !== n || !Z(f.current, r)) && (d.current = n, f.current = r, g()), n._subscribe({
115
+ Be(() => ((d.current !== n || !X(f.current, r)) && (d.current = n, f.current = r, g()), n._subscribe({
117
116
  name: r,
118
117
  formState: { values: !0 },
119
118
  exact: o,
@@ -125,10 +124,10 @@ function Be(e) {
125
124
  o,
126
125
  r,
127
126
  g
128
- ]), M.useEffect(() => n._removeUnmounted());
129
- let _ = d.current !== n, v = f.current, y = M.useMemo(() => {
127
+ ]), P.useEffect(() => n._removeUnmounted());
128
+ let _ = d.current !== n, v = f.current, y = P.useMemo(() => {
130
129
  if (a) return null;
131
- let e = !_ && !Z(v, r);
130
+ let e = !_ && !X(v, r);
132
131
  return _ || e ? h() : null;
133
132
  }, [
134
133
  a,
@@ -139,15 +138,15 @@ function Be(e) {
139
138
  ]);
140
139
  return y === null ? p : y;
141
140
  }
142
- var Ve = M.createContext(null);
143
- Ve.displayName = "HookFormContext";
144
- var He = (e, t, n, r, i) => t ? {
141
+ var We = P.createContext(null);
142
+ We.displayName = "HookFormContext";
143
+ var Ge = (e, t, n, r, i) => t ? {
145
144
  ...n[e],
146
145
  types: {
147
146
  ...n[e] && n[e].types ? n[e].types : {},
148
147
  [r]: i || !0
149
148
  }
150
- } : {}, Ue = (e) => Array.isArray(e) ? e : [e], We = () => {
149
+ } : {}, Ke = (e) => Array.isArray(e) ? e : [e], qe = () => {
151
150
  let e = [];
152
151
  return {
153
152
  get observers() {
@@ -164,23 +163,23 @@ var He = (e, t, n, r, i) => t ? {
164
163
  }
165
164
  };
166
165
  };
167
- function Ge(e, t) {
166
+ function Je(e, t) {
168
167
  let n = {};
169
168
  for (let r in e) if (e.hasOwnProperty(r)) {
170
169
  let i = e[r], a = t[r];
171
170
  if (i && B(i) && a) {
172
- let e = Ge(i, a);
171
+ let e = Je(i, a);
173
172
  B(e) && (n[r] = e);
174
173
  } else e[r] && (n[r] = a);
175
174
  }
176
175
  return n;
177
176
  }
178
- var Q = (e) => B(e) && !Object.keys(e).length, Ke = (e) => e.type === "file", qe = (e) => {
179
- if (!Oe) return !1;
177
+ var Z = (e) => B(e) && !Object.keys(e).length, Ye = (e) => e.type === "file", Xe = (e) => {
178
+ if (!Ae) return !1;
180
179
  let t = e ? e.ownerDocument : 0;
181
180
  return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
182
- }, Je = (e) => e.type === "select-multiple", Ye = (e) => e.type === "radio", Xe = (e) => Ye(e) || Ce(e), Ze = (e) => qe(e) && e.isConnected;
183
- function Qe(e, t) {
181
+ }, Ze = (e) => e.type === "select-multiple", Qe = (e) => e.type === "radio", $e = (e) => Qe(e) || Te(e), et = (e) => Xe(e) && e.isConnected;
182
+ function tt(e, t) {
184
183
  let n = t.slice(0, -1).length, r = 0;
185
184
  for (; r < n;) {
186
185
  if (z(e)) {
@@ -191,65 +190,65 @@ function Qe(e, t) {
191
190
  }
192
191
  return e;
193
192
  }
194
- function $e(e) {
193
+ function nt(e) {
195
194
  for (let t in e) if (e.hasOwnProperty(t) && !H(e[t])) return !1;
196
195
  return !0;
197
196
  }
198
- function $(e, t) {
199
- if (X(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
200
- let n = Array.isArray(t) ? t : ke(t) ? [t] : je(t), r = n.length === 1 ? e : Qe(e, n), i = n.length - 1, a = n[i];
201
- return r && delete r[a], i !== 0 && (B(r) && Q(r) || Array.isArray(r) && $e(r)) && $(e, n.slice(0, -1)), e;
197
+ function Q(e, t) {
198
+ if (Y(t) && Object.prototype.hasOwnProperty.call(e, t)) return delete e[t], e;
199
+ let n = Array.isArray(t) ? t : je(t) ? [t] : Ne(t), r = n.length === 1 ? e : tt(e, n), i = n.length - 1, a = n[i];
200
+ return r && delete r[a], i !== 0 && (B(r) && Z(r) || Array.isArray(r) && nt(r)) && Q(e, n.slice(0, -1)), e;
202
201
  }
203
- var et = (e) => {
202
+ var rt = (e) => {
204
203
  for (let t in e) if (G(e[t])) return !0;
205
204
  return !1;
206
205
  };
207
- function tt(e) {
208
- return Array.isArray(e) || B(e) && !et(e);
206
+ function it(e) {
207
+ return Array.isArray(e) || B(e) && !rt(e);
209
208
  }
210
- function nt(e, t = {}) {
209
+ function at(e, t = {}) {
211
210
  for (let n in e) {
212
211
  let r = e[n];
213
- tt(r) ? (t[n] = Array.isArray(r) ? [] : {}, nt(r, t[n])) : H(r) || (t[n] = !0);
212
+ it(r) ? (t[n] = Array.isArray(r) ? [] : {}, at(r, t[n])) : H(r) || (t[n] = !0);
214
213
  }
215
214
  return t;
216
215
  }
217
- function rt(e) {
216
+ function ot(e) {
218
217
  if (e !== !1) {
219
218
  if (e === !0) return !0;
220
219
  if (Array.isArray(e)) {
221
- let t = e.map((e) => rt(e));
220
+ let t = e.map((e) => ot(e));
222
221
  return t.some((e) => e !== void 0) ? t : void 0;
223
222
  }
224
223
  if (B(e)) {
225
224
  let t = {};
226
225
  for (let n in e) {
227
- let r = rt(e[n]);
226
+ let r = ot(e[n]);
228
227
  H(r) || (t[n] = r);
229
228
  }
230
229
  return Object.keys(t).length ? t : void 0;
231
230
  }
232
231
  }
233
232
  }
234
- function it(e, t, n) {
235
- n ||= nt(t);
233
+ function st(e, t, n) {
234
+ n ||= at(t);
236
235
  for (let r in e) {
237
236
  let i = e[r];
238
- if (tt(i)) H(t) || ze(n[r]) ? n[r] = nt(i, Array.isArray(i) ? [] : {}) : it(i, z(t) ? {} : t[r], n[r]);
237
+ if (it(i)) H(t) || He(n[r]) ? n[r] = at(i, Array.isArray(i) ? [] : {}) : st(i, z(t) ? {} : t[r], n[r]);
239
238
  else {
240
239
  let e = t[r];
241
- n[r] = !Z(i, e);
240
+ n[r] = !X(i, e);
242
241
  }
243
242
  }
244
- return rt(n) || {};
243
+ return ot(n) || {};
245
244
  }
246
- var at = {
245
+ var ct = {
247
246
  value: !1,
248
247
  isValid: !1
249
- }, ot = {
248
+ }, lt = {
250
249
  value: !0,
251
250
  isValid: !0
252
- }, st = (e) => {
251
+ }, ut = (e) => {
253
252
  if (Array.isArray(e)) {
254
253
  if (e.length > 1) {
255
254
  let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
@@ -258,24 +257,24 @@ var at = {
258
257
  isValid: !!t.length
259
258
  };
260
259
  }
261
- return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ? ot : {
260
+ return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ? lt : {
262
261
  value: e[0].value,
263
262
  isValid: !0
264
- } : ot : at;
263
+ } : lt : ct;
265
264
  }
266
- return at;
267
- }, ct = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => H(e) ? e : t ? e === "" ? NaN : e && +e : n && X(e) ? new Date(e) : r ? r(e) : e, lt = {
265
+ return ct;
266
+ }, dt = (e, { valueAsNumber: t, valueAsDate: n, setValueAs: r }) => H(e) ? e : t ? e === "" ? NaN : e && +e : n && Y(e) ? new Date(e) : r ? r(e) : e, ft = {
268
267
  isValid: !1,
269
268
  value: null
270
- }, ut = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
269
+ }, pt = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
271
270
  isValid: !0,
272
271
  value: t.value
273
- } : e, lt) : lt;
274
- function dt(e) {
272
+ } : e, ft) : ft;
273
+ function mt(e) {
275
274
  let t = e.ref;
276
- return Ke(t) ? t.files : Ye(t) ? ut(e.refs).value : Je(t) ? [...t.selectedOptions].map(({ value: e }) => e) : Ce(t) ? st(e.refs).value : ct(H(t.value) ? e.ref.value : t.value, e);
275
+ return Ye(t) ? t.files : Qe(t) ? pt(e.refs).value : Ze(t) ? [...t.selectedOptions].map(({ value: e }) => e) : Te(t) ? ut(e.refs).value : dt(H(t.value) ? e.ref.value : t.value, e);
277
276
  }
278
- var ft = (e, t, n, r) => {
277
+ var ht = (e, t, n, r) => {
279
278
  let i = {};
280
279
  for (let n of e) {
281
280
  let e = U(t, n);
@@ -287,27 +286,27 @@ var ft = (e, t, n, r) => {
287
286
  fields: i,
288
287
  shouldUseNativeValidation: r
289
288
  };
290
- }, pt = (e) => e instanceof RegExp, mt = (e) => H(e) ? e : pt(e) ? e.source : B(e) ? pt(e.value) ? e.value.source : e.value : e, ht = (e) => ({
291
- isOnSubmit: !e || e === J.onSubmit,
292
- isOnBlur: e === J.onBlur,
293
- isOnChange: e === J.onChange,
294
- isOnAll: e === J.all,
295
- isOnTouch: e === J.onTouched
296
- }), gt = "AsyncFunction", _t = (e) => !!e && !!e.validate && !!(G(e.validate) && e.validate.constructor.name === gt || B(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === gt)), vt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), yt = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), bt = (e, t, n, r) => {
289
+ }, gt = (e) => e instanceof RegExp, _t = (e) => H(e) ? e : gt(e) ? e.source : B(e) ? gt(e.value) ? e.value.source : e.value : e, vt = (e) => ({
290
+ isOnSubmit: !e || e === q.onSubmit,
291
+ isOnBlur: e === q.onBlur,
292
+ isOnChange: e === q.onChange,
293
+ isOnAll: e === q.all,
294
+ isOnTouch: e === q.onTouched
295
+ }), yt = "AsyncFunction", bt = (e) => !!e && !!e.validate && !!(G(e.validate) && e.validate.constructor.name === yt || B(e.validate) && Object.values(e.validate).find((e) => e.constructor.name === yt)), xt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), St = (e, t, n) => !n && (t.watchAll || t.watch.has(e) || [...t.watch].some((t) => e.startsWith(t) && /^\.\w+/.test(e.slice(t.length)))), Ct = (e, t, n, r) => {
297
296
  for (let i of n || Object.keys(e)) {
298
297
  let n = U(e, i);
299
298
  if (n) {
300
299
  let { _f: e, ...a } = n;
301
300
  if (e) {
302
301
  if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
303
- if (bt(a, t)) break;
304
- } else if (B(a) && bt(a, t)) break;
302
+ if (Ct(a, t)) break;
303
+ } else if (B(a) && Ct(a, t)) break;
305
304
  }
306
305
  }
307
306
  };
308
- function xt(e, t, n) {
307
+ function wt(e, t, n) {
309
308
  let r = U(e, n);
310
- if (r || ke(n)) return {
309
+ if (r || je(n)) return {
311
310
  error: r,
312
311
  name: n
313
312
  };
@@ -327,103 +326,103 @@ function xt(e, t, n) {
327
326
  }
328
327
  return { name: n };
329
328
  }
330
- var St = (e, t, n, r) => {
329
+ var Tt = (e, t, n, r) => {
331
330
  n(e);
332
331
  let { name: i, ...a } = e;
333
- return Q(a) || r && Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || J.all));
334
- }, Ct = (e, t, n) => !e || !t || e === t || Ue(e).some((e) => e && (n ? e === t : e.startsWith(t) || t.startsWith(e))), wt = (e, t, n, r, i) => i.isOnAll ? !1 : !n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : (n ? r.isOnChange : i.isOnChange) ? e : !0, Tt = (e, t) => !Ae(U(e, t)).length && $(e, t), Et = (e, t, n) => {
335
- let r = Ue(U(e, n));
336
- return K(r, Ne, t[n]), K(e, n, r), e;
332
+ return Z(a) || r && Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((e) => t[e] === (!r || q.all));
333
+ }, Et = (e, t, n) => !e || !t || e === t || Ke(e).some((e) => e && (n ? e === t : e.startsWith(t) || t.startsWith(e))), Dt = (e, t, n, r, i) => i.isOnAll ? !1 : !n && i.isOnTouch ? !(t || e) : (n ? r.isOnBlur : i.isOnBlur) ? !e : (n ? r.isOnChange : i.isOnChange) ? e : !0, Ot = (e, t) => !Me(U(e, t)).length && Q(e, t), kt = (e, t, n) => {
334
+ let r = Ke(U(e, n));
335
+ return K(r, Ie, t[n]), K(e, n, r), e;
337
336
  };
338
- function Dt(e, t, n = "validate") {
339
- if (X(e) || Array.isArray(e) && e.every(X) || W(e) && !e) return {
337
+ function At(e, t, n = "validate") {
338
+ if (Y(e) || Array.isArray(e) && e.every(Y) || W(e) && !e) return {
340
339
  type: n,
341
- message: X(e) ? e : "",
340
+ message: Y(e) ? e : "",
342
341
  ref: t
343
342
  };
344
343
  }
345
- var Ot = (e) => B(e) && !pt(e) ? e : {
344
+ var $ = (e) => B(e) && !gt(e) ? e : {
346
345
  value: e,
347
346
  message: ""
348
- }, kt = async (e, t, n, r, i, a) => {
347
+ }, jt = async (e, t, n, r, i, a) => {
349
348
  let { ref: o, refs: s, required: c, maxLength: l, minLength: u, min: d, max: f, pattern: p, validate: m, name: h, valueAsNumber: g, mount: _ } = e._f, v = U(n, h);
350
349
  if (!_ || t.has(h)) return {};
351
350
  let y = s ? s[0] : o, b = (e) => {
352
351
  i && y.reportValidity && (y.setCustomValidity(W(e) ? "" : e || ""), y.reportValidity());
353
- }, x = {}, S = Ye(o), C = Ce(o), ee = S || C, w = (g || Ke(o)) && H(o.value) && H(v) || qe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), T = He.bind(null, h, r, x), E = (e, t, n, r = Y.maxLength, i = Y.minLength) => {
352
+ }, x = {}, S = Qe(o), C = Te(o), w = S || C, T = (g || Ye(o)) && H(o.value) && H(v) || Xe(o) && o.value === "" || v === "" || Array.isArray(v) && !v.length || g && typeof v == "number" && isNaN(v), E = Ge.bind(null, h, r, x), D = (e, t, n, r = J.maxLength, i = J.minLength) => {
354
353
  let a = e ? t : n;
355
354
  x[h] = {
356
355
  type: e ? r : i,
357
356
  message: a,
358
357
  ref: o,
359
- ...T(e ? r : i, a)
358
+ ...E(e ? r : i, a)
360
359
  };
361
360
  };
362
- if (a ? !Array.isArray(v) || !v.length : c && (!ee && (w || z(v)) || W(v) && !v || C && !st(s).isValid || S && !ut(s).isValid)) {
363
- let { value: e, message: t } = X(c) ? {
361
+ if (a ? !Array.isArray(v) || !v.length : c && (!w && (T || z(v)) || W(v) && !v || C && !ut(s).isValid || S && !pt(s).isValid)) {
362
+ let { value: e, message: t } = Y(c) ? {
364
363
  value: !!c,
365
364
  message: c
366
- } : Ot(c);
365
+ } : $(c);
367
366
  if (e && (x[h] = {
368
- type: Y.required,
367
+ type: J.required,
369
368
  message: t,
370
369
  ref: y,
371
- ...T(Y.required, t)
370
+ ...E(J.required, t)
372
371
  }, !r)) return b(t), x;
373
372
  }
374
- if (!w && (!z(d) || !z(f))) {
375
- let e, t, n = Ot(f), i = Ot(d);
373
+ if (!T && (!z(d) || !z(f))) {
374
+ let e, t, n = $(f), i = $(d);
376
375
  if (!z(v) && !isNaN(v)) {
377
376
  let r = o.valueAsNumber || v && +v;
378
377
  z(n.value) || (e = r > n.value), z(i.value) || (t = r < i.value);
379
378
  } else {
380
379
  let r = o.valueAsDate || new Date(v), a = (e) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + e), s = o.type == "time", c = o.type == "week";
381
- X(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), X(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
380
+ Y(n.value) && v && (e = s ? a(v) > a(n.value) : c ? v > n.value : r > new Date(n.value)), Y(i.value) && v && (t = s ? a(v) < a(i.value) : c ? v < i.value : r < new Date(i.value));
382
381
  }
383
- if ((e || t) && (E(!!e, n.message, i.message, Y.max, Y.min), !r)) return b(x[h].message), x;
382
+ if ((e || t) && (D(!!e, n.message, i.message, J.max, J.min), !r)) return b(x[h].message), x;
384
383
  }
385
- if ((l || u) && !w && (X(v) || a && Array.isArray(v))) {
386
- let e = Ot(l), t = Ot(u), n = !z(e.value) && v.length > +e.value, i = !z(t.value) && v.length < +t.value;
387
- if ((n || i) && (E(n, e.message, t.message), !r)) return b(x[h].message), x;
384
+ if ((l || u) && !T && (Y(v) || a && Array.isArray(v))) {
385
+ let e = $(l), t = $(u), n = !z(e.value) && v.length > +e.value, i = !z(t.value) && v.length < +t.value;
386
+ if ((n || i) && (D(n, e.message, t.message), !r)) return b(x[h].message), x;
388
387
  }
389
- if (p && !w && X(v)) {
390
- let { value: e, message: t } = Ot(p);
391
- if (pt(e) && !v.match(e) && (x[h] = {
392
- type: Y.pattern,
388
+ if (p && !T && Y(v)) {
389
+ let { value: e, message: t } = $(p);
390
+ if (gt(e) && !v.match(e) && (x[h] = {
391
+ type: J.pattern,
393
392
  message: t,
394
393
  ref: o,
395
- ...T(Y.pattern, t)
394
+ ...E(J.pattern, t)
396
395
  }, !r)) return b(t), x;
397
396
  }
398
397
  if (m) {
399
398
  if (G(m)) {
400
- let e = Dt(await m(v, n), y);
399
+ let e = At(await m(v, n), y);
401
400
  if (e && (x[h] = {
402
401
  ...e,
403
- ...T(Y.validate, e.message)
402
+ ...E(J.validate, e.message)
404
403
  }, !r)) return b(e.message), x;
405
404
  } else if (B(m)) {
406
405
  let e = {};
407
406
  for (let t in m) {
408
- if (!Q(e) && !r) break;
409
- let i = Dt(await m[t](v, n), y, t);
407
+ if (!Z(e) && !r) break;
408
+ let i = At(await m[t](v, n), y, t);
410
409
  i && (e = {
411
410
  ...i,
412
- ...T(t, i.message)
411
+ ...E(t, i.message)
413
412
  }, b(i.message), r && (x[h] = e));
414
413
  }
415
- if (!Q(e) && (x[h] = {
414
+ if (!Z(e) && (x[h] = {
416
415
  ref: y,
417
416
  ...e
418
417
  }, !r)) return x;
419
418
  }
420
419
  }
421
420
  return b(!0), x;
422
- }, At = {
423
- mode: J.onSubmit,
424
- reValidateMode: J.onChange,
421
+ }, Mt = {
422
+ mode: q.onSubmit,
423
+ reValidateMode: q.onChange,
425
424
  shouldFocusError: !0
426
- }, jt = {
425
+ }, Nt = {
427
426
  submitCount: 0,
428
427
  isDirty: !1,
429
428
  isReady: !1,
@@ -436,12 +435,12 @@ var Ot = (e) => B(e) && !pt(e) ? e : {
436
435
  dirtyFields: {},
437
436
  validatingFields: {}
438
437
  };
439
- function Mt(e = {}) {
438
+ function Pt(e = {}) {
440
439
  let t = {
441
- ...At,
440
+ ...Mt,
442
441
  ...e
443
442
  }, n = {
444
- ...V(jt),
443
+ ...V(Nt),
445
444
  isLoading: G(t.defaultValues),
446
445
  errors: t.errors || {},
447
446
  disabled: t.disabled || !1
@@ -466,28 +465,28 @@ function Mt(e = {}) {
466
465
  isValid: !1,
467
466
  errors: !1
468
467
  }, d = { ...u }, f = { ...d }, p = {
469
- array: We(),
470
- state: We()
471
- }, m = t.criteriaMode === J.all, h = (e) => (t) => {
468
+ array: qe(),
469
+ state: qe()
470
+ }, m = t.criteriaMode === q.all, h = (e) => (t) => {
472
471
  clearTimeout(l), l = setTimeout(e, t);
473
472
  }, g = async (e) => {
474
473
  if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
475
474
  let e;
476
- t.resolver ? (e = Q((await w()).errors), _()) : e = await D({
475
+ t.resolver ? (e = Z((await T()).errors), _()) : e = await O({
477
476
  fields: r,
478
477
  onlyCheckValid: !0,
479
- eventType: q.VALID
478
+ eventType: Pe.VALID
480
479
  }), e !== n.isValid && p.state.next({ isValid: e });
481
480
  }
482
481
  }, _ = (e, r) => {
483
482
  !t.disabled && (d.isValidating || d.validatingFields || f.isValidating || f.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
484
- e && (r ? K(n.validatingFields, e, r) : $(n.validatingFields, e));
483
+ e && (r ? K(n.validatingFields, e, r) : Q(n.validatingFields, e));
485
484
  }), p.state.next({
486
485
  validatingFields: n.validatingFields,
487
- isValidating: !Q(n.validatingFields)
486
+ isValidating: !Z(n.validatingFields)
488
487
  }));
489
488
  }, v = () => {
490
- n.dirtyFields = it(i, a);
489
+ n.dirtyFields = st(i, a);
491
490
  }, y = (e, i = [], s, c, l = !0, u = !0) => {
492
491
  if (c && s && !t.disabled) {
493
492
  if (o.action = !0, u && Array.isArray(U(r, e))) {
@@ -496,7 +495,7 @@ function Mt(e = {}) {
496
495
  }
497
496
  if (u && Array.isArray(U(n.errors, e))) {
498
497
  let t = s(U(n.errors, e), c.argA, c.argB);
499
- l && K(n.errors, e, t), Tt(n.errors, e);
498
+ l && K(n.errors, e, t), Ot(n.errors, e);
500
499
  }
501
500
  if ((d.touchedFields || f.touchedFields) && u && Array.isArray(U(n.touchedFields, e))) {
502
501
  let t = s(U(n.touchedFields, e), c.argA, c.argB);
@@ -504,7 +503,7 @@ function Mt(e = {}) {
504
503
  }
505
504
  (d.dirtyFields || f.dirtyFields) && v(), p.state.next({
506
505
  name: e,
507
- isDirty: k(e, i),
506
+ isDirty: A(e, i),
508
507
  dirtyFields: n.dirtyFields,
509
508
  errors: n.errors,
510
509
  isValid: n.isValid
@@ -521,15 +520,15 @@ function Mt(e = {}) {
521
520
  let l = U(r, e);
522
521
  if (l) {
523
522
  let r = H(U(a, e)), u = U(a, e, H(s) ? U(i, e) : s);
524
- H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : dt(l._f)) : ne(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (k() || (n.isDirty = !1, p.state.next({ ...n }))));
523
+ H(u) || c && c.defaultChecked || t ? K(a, e, t ? u : mt(l._f)) : te(e, u), o.mount && !o.action && (g(), r && n.isDirty && (d.isDirty || f.isDirty) && (A() || (n.isDirty = !1, p.state.next({ ...n }))));
525
524
  }
526
525
  }, C = (e, r, a, o, s) => {
527
526
  let c = !1, l = !1, u = { name: e };
528
527
  if (!t.disabled) {
529
528
  if (!a || o) {
530
- (d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = k(), c = l !== u.isDirty);
531
- let t = Z(U(i, e), r);
532
- l = !!U(n.dirtyFields, e), t ? $(n.dirtyFields, e) : K(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
529
+ (d.isDirty || f.isDirty) && (l = n.isDirty, n.isDirty = u.isDirty = A(), c = l !== u.isDirty);
530
+ let t = X(U(i, e), r);
531
+ l = !!U(n.dirtyFields, e), t ? Q(n.dirtyFields, e) : K(n.dirtyFields, e, !0), u.dirtyFields = n.dirtyFields, c ||= (d.dirtyFields || f.dirtyFields) && l !== !t;
533
532
  }
534
533
  if (a) {
535
534
  let t = U(n.touchedFields, e);
@@ -538,9 +537,9 @@ function Mt(e = {}) {
538
537
  c && s && p.state.next(u);
539
538
  }
540
539
  return c ? u : {};
541
- }, ee = (e, r, i, a) => {
540
+ }, w = (e, r, i, a) => {
542
541
  let o = U(n.errors, e), s = (d.isValid || f.isValid) && W(r) && n.isValid !== r;
543
- if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) : $(n.errors, e)), (i ? !Z(o, i) : o) || !Q(a) || s) {
542
+ if (t.delayError && i ? (c = h(() => b(e, i)), c(t.delayError)) : (clearTimeout(l), c = null, i ? K(n.errors, e, i) : Q(n.errors, e)), (i ? !X(o, i) : o) || !Z(a) || s) {
544
543
  let t = {
545
544
  ...a,
546
545
  ...s && W(r) ? { isValid: r } : {},
@@ -552,15 +551,15 @@ function Mt(e = {}) {
552
551
  ...t
553
552
  }, p.state.next(t);
554
553
  }
555
- }, w = async (e) => (_(e, !0), await t.resolver(a, t.context, ft(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), T = async (e) => {
556
- let { errors: t } = await w(e);
554
+ }, T = async (e) => (_(e, !0), await t.resolver(a, t.context, ht(e || s.mount, r, t.criteriaMode, t.shouldUseNativeValidation))), E = async (e) => {
555
+ let { errors: t } = await T(e);
557
556
  if (_(e), e) for (let r of e) {
558
557
  let e = U(t, r);
559
- e ? K(n.errors, r, e) : $(n.errors, r);
558
+ e ? K(n.errors, r, e) : Q(n.errors, r);
560
559
  }
561
560
  else n.errors = t;
562
561
  return t;
563
- }, E = async ({ name: t, eventType: r }) => {
562
+ }, D = async ({ name: t, eventType: r }) => {
564
563
  if (e.validate) {
565
564
  let i = await e.validate({
566
565
  formValues: a,
@@ -568,22 +567,22 @@ function Mt(e = {}) {
568
567
  name: t,
569
568
  eventType: r
570
569
  });
571
- if (B(i)) for (let e in i) i[e] && de(`${Me}.${e}`, {
572
- message: X(i.message) ? i.message : "",
573
- type: Y.validate
570
+ if (B(i)) for (let e in i) i[e] && le(`${Fe}.${e}`, {
571
+ message: Y(i.message) ? i.message : "",
572
+ type: J.validate
574
573
  });
575
- else X(i) || !i ? de(Me, {
574
+ else Y(i) || !i ? le(Fe, {
576
575
  message: i || "",
577
- type: Y.validate
578
- }) : ue(Me);
576
+ type: J.validate
577
+ }) : ce(Fe);
579
578
  return i;
580
579
  }
581
580
  return !0;
582
- }, D = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
581
+ }, O = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
583
582
  valid: !0,
584
583
  runRootValidation: !1
585
584
  } }) => {
586
- if (e.validate && (l.runRootValidation = !0, !await E({
585
+ if (e.validate && (l.runRootValidation = !0, !await D({
587
586
  name: o,
588
587
  eventType: c
589
588
  }) && (l.valid = !1, i))) return l.valid;
@@ -592,12 +591,12 @@ function Mt(e = {}) {
592
591
  if (u) {
593
592
  let { _f: r, ...f } = u;
594
593
  if (r) {
595
- let o = s.array.has(r.name), c = u._f && _t(u._f);
594
+ let o = s.array.has(r.name), c = u._f && bt(u._f);
596
595
  c && d.validatingFields && _([r.name], !0);
597
- let f = await kt(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
598
- if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ? Et(n.errors, f, r.name) : K(n.errors, r.name, f[r.name]) : $(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
596
+ let f = await jt(u, s.disabled, a, m, t.shouldUseNativeValidation && !i, o);
597
+ if (c && d.validatingFields && _([r.name]), f[r.name] && (l.valid = !1, i) || (!i && (U(f, r.name) ? o ? kt(n.errors, f, r.name) : K(n.errors, r.name, f[r.name]) : Q(n.errors, r.name)), e.shouldUseNativeValidation && f[r.name])) break;
599
598
  }
600
- !Q(f) && await D({
599
+ !Z(f) && await O({
601
600
  context: l,
602
601
  onlyCheckValid: i,
603
602
  fields: f,
@@ -607,136 +606,136 @@ function Mt(e = {}) {
607
606
  }
608
607
  }
609
608
  return l.valid;
610
- }, O = () => {
609
+ }, k = () => {
611
610
  for (let e of s.unMount) {
612
611
  let t = U(r, e);
613
- t && (t._f.refs ? t._f.refs.every((e) => !Ze(e)) : !Ze(t._f.ref)) && he(e);
612
+ t && (t._f.refs ? t._f.refs.every((e) => !et(e)) : !et(t._f.ref)) && pe(e);
614
613
  }
615
614
  s.unMount = /* @__PURE__ */ new Set();
616
- }, k = (e, n) => !t.disabled && (e && n && K(a, e, n), !Z(ce(), i)), A = (e, t, n) => Re(e, s, { ...o.mount ? a : H(t) ? i : X(e) ? { [e]: t } : t }, n, t), te = (e) => Ae(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), ne = (e, t, n = {}) => {
615
+ }, A = (e, n) => !t.disabled && (e && n && K(a, e, n), !X(se(), i)), j = (e, t, n) => Ve(e, s, { ...o.mount ? a : H(t) ? i : Y(e) ? { [e]: t } : t }, n, t), ee = (e) => Me(U(o.mount ? a : i, e, t.shouldUnregister ? U(i, e, []) : [])), te = (e, t, n = {}) => {
617
616
  let i = U(r, e), o = t;
618
617
  if (i) {
619
618
  let n = i._f;
620
- n && (!n.disabled && K(a, e, ct(t, n)), o = qe(n.ref) && z(t) ? "" : t, Je(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? Ce(n.ref) ? n.refs.forEach((e) => {
619
+ n && (!n.disabled && K(a, e, dt(t, n)), o = Xe(n.ref) && z(t) ? "" : t, Ze(n.ref) ? [...n.ref.options].forEach((e) => e.selected = o.includes(e.value)) : n.refs ? Te(n.ref) ? n.refs.forEach((e) => {
621
620
  (!e.defaultChecked || !e.disabled) && (Array.isArray(o) ? e.checked = !!o.find((t) => t === e.value) : e.checked = o === e.value || !!o);
622
- }) : n.refs.forEach((e) => e.checked = e.value === o) : Ke(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || p.state.next({
621
+ }) : n.refs.forEach((e) => e.checked = e.value === o) : Ye(n.ref) ? n.ref.value = "" : (n.ref.value = o, n.ref.type || p.state.next({
623
622
  name: e,
624
623
  values: V(a)
625
624
  })));
626
625
  }
627
- (n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && j(e);
628
- }, re = (e, t, n) => {
626
+ (n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && oe(e);
627
+ }, ne = (e, t, n) => {
629
628
  for (let i in t) {
630
629
  if (!t.hasOwnProperty(i)) return;
631
630
  let a = t[i], o = e + "." + i, c = U(r, o);
632
- (s.array.has(e) || B(a) || c && !c._f) && !R(a) ? re(o, a, n) : ne(o, a, n);
631
+ (s.array.has(e) || B(a) || c && !c._f) && !R(a) ? ne(o, a, n) : te(o, a, n);
633
632
  }
634
- }, ie = (e, t, i = {}) => {
635
- let c = U(r, e), l = s.array.has(e), u = V(t), m = Z(U(a, e), u);
633
+ }, re = (e, t, i = {}) => {
634
+ let c = U(r, e), l = s.array.has(e), u = V(t), m = X(U(a, e), u);
636
635
  if (K(a, e, u), l) p.array.next({
637
636
  name: e,
638
637
  values: V(a)
639
638
  }), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
640
639
  name: e,
641
640
  dirtyFields: n.dirtyFields,
642
- isDirty: k(e, u)
641
+ isDirty: A(e, u)
643
642
  }));
644
643
  else {
645
- let t = Array.isArray(u) && !u.length || Q(u);
646
- !c || c._f || z(u) || t ? ne(e, u, i) : re(e, u, i);
644
+ let t = Array.isArray(u) && !u.length || Z(u);
645
+ !c || c._f || z(u) || t ? te(e, u, i) : ne(e, u, i);
647
646
  }
648
647
  if (!m) {
649
- let t = yt(e, s);
648
+ let t = St(e, s);
650
649
  p.state.next({
651
650
  ...t && n,
652
651
  name: o.mount || t ? e : void 0,
653
652
  values: V(a)
654
653
  });
655
654
  }
656
- }, ae = (e) => {
655
+ }, ie = (e) => {
657
656
  let t = G(e) ? e(a) : e;
658
- Z(a, t) || (a = {
657
+ X(a, t) || (a = {
659
658
  ...a,
660
659
  ...t
661
660
  }, p.state.next({
662
661
  ...n,
663
662
  values: a
664
663
  }));
665
- }, oe = async (i) => {
664
+ }, ae = async (i) => {
666
665
  o.mount = !0;
667
666
  let l = i.target, u = l.name, h = !0, v = U(r, u), y = (e) => {
668
- h = Number.isNaN(e) || R(e) && isNaN(e.getTime()) || Z(e, U(a, u, e));
669
- }, b = ht(t.mode), x = ht(t.reValidateMode);
667
+ h = Number.isNaN(e) || R(e) && isNaN(e.getTime()) || X(e, U(a, u, e));
668
+ }, b = vt(t.mode), x = vt(t.reValidateMode);
670
669
  if (v) {
671
- let o, S, T = l.type ? dt(v._f) : Te(i), O = i.type === q.BLUR || i.type === q.FOCUS_OUT, k = !vt(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || wt(O, U(n.touchedFields, u), n.isSubmitted, x, b), A = yt(u, s, O);
672
- K(a, u, T), O ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
673
- let te = C(u, T, O), ne = !Q(te) || A;
674
- if (!O && p.state.next({
670
+ let o, S, E = l.type ? mt(v._f) : De(i), k = i.type === Pe.BLUR || i.type === Pe.FOCUS_OUT, A = !xt(v._f) && !e.validate && !t.resolver && !U(n.errors, u) && !v._f.deps || Dt(k, U(n.touchedFields, u), n.isSubmitted, x, b), j = St(u, s, k);
671
+ K(a, u, E), k ? (!l || !l.readOnly) && (v._f.onBlur && v._f.onBlur(i), c && c(0)) : v._f.onChange && v._f.onChange(i);
672
+ let ee = C(u, E, k), te = !Z(ee) || j;
673
+ if (!k && p.state.next({
675
674
  name: u,
676
675
  type: i.type,
677
676
  values: V(a)
678
- }), k) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? O && g() : O || g()), ne && p.state.next({
677
+ }), A) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? k && g() : k || g()), te && p.state.next({
679
678
  name: u,
680
- ...A ? {} : te
679
+ ...j ? {} : ee
681
680
  });
682
- if (!t.resolver && e.validate && await E({
681
+ if (!t.resolver && e.validate && await D({
683
682
  name: u,
684
683
  eventType: i.type
685
- }), !O && A && p.state.next({ ...n }), t.resolver) {
686
- let { errors: e } = await w([u]);
687
- if (_([u]), y(T), h) {
688
- let t = xt(n.errors, r, u), i = xt(e, r, t.name || u);
689
- o = i.error, u = i.name, S = Q(e);
684
+ }), !k && j && p.state.next({ ...n }), t.resolver) {
685
+ let { errors: e } = await T([u]);
686
+ if (_([u]), y(E), h) {
687
+ let t = wt(n.errors, r, u), i = wt(e, r, t.name || u);
688
+ o = i.error, u = i.name, S = Z(e);
690
689
  }
691
- } else _([u], !0), o = (await kt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(T), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await D({
690
+ } else _([u], !0), o = (await jt(v, s.disabled, a, m, t.shouldUseNativeValidation))[u], _([u]), y(E), h && (o ? S = !1 : (d.isValid || f.isValid) && (S = await O({
692
691
  fields: r,
693
692
  onlyCheckValid: !0,
694
693
  name: u,
695
694
  eventType: i.type
696
695
  })));
697
- h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && j(v._f.deps), ee(u, S, o, te));
696
+ h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && oe(v._f.deps), w(u, S, o, ee));
698
697
  }
699
- }, se = (e, t) => {
698
+ }, M = (e, t) => {
700
699
  if (U(n.errors, t) && e.focus) return e.focus(), 1;
701
- }, j = async (e, i = {}) => {
702
- let a, o, c = Ue(e);
700
+ }, oe = async (e, i = {}) => {
701
+ let a, o, c = Ke(e);
703
702
  if (t.resolver) {
704
- let t = await T(H(e) ? e : c);
705
- a = Q(t), o = e ? !c.some((e) => U(t, e)) : a;
703
+ let t = await E(H(e) ? e : c);
704
+ a = Z(t), o = e ? !c.some((e) => U(t, e)) : a;
706
705
  } else e ? (o = (await Promise.all(c.map(async (e) => {
707
706
  let t = U(r, e);
708
- return await D({
707
+ return await O({
709
708
  fields: t && t._f ? { [e]: t } : t,
710
- eventType: q.TRIGGER
709
+ eventType: Pe.TRIGGER
711
710
  });
712
- }))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await D({
711
+ }))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await O({
713
712
  fields: r,
714
713
  name: e,
715
- eventType: q.TRIGGER
714
+ eventType: Pe.TRIGGER
716
715
  });
717
716
  return p.state.next({
718
- ...!X(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
717
+ ...!Y(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
719
718
  ...t.resolver || !e ? { isValid: a } : {},
720
719
  errors: n.errors
721
- }), i.shouldFocus && !o && bt(r, se, e ? c : s.mount), o;
722
- }, ce = (e, t) => {
720
+ }), i.shouldFocus && !o && Ct(r, M, e ? c : s.mount), o;
721
+ }, se = (e, t) => {
723
722
  let r = { ...o.mount ? a : i };
724
- return t && (r = Ge(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), H(e) ? r : X(e) ? U(r, e) : e.map((e) => U(r, e));
725
- }, le = (e, t) => ({
723
+ return t && (r = Je(t.dirtyFields ? n.dirtyFields : n.touchedFields, r)), H(e) ? r : Y(e) ? U(r, e) : e.map((e) => U(r, e));
724
+ }, N = (e, t) => ({
726
725
  invalid: !!U((t || n).errors, e),
727
726
  isDirty: !!U((t || n).dirtyFields, e),
728
727
  error: U((t || n).errors, e),
729
728
  isValidating: !!U(n.validatingFields, e),
730
729
  isTouched: !!U((t || n).touchedFields, e)
731
- }), ue = (e) => {
732
- let t = e ? Ue(e) : void 0;
733
- t?.forEach((e) => $(n.errors, e)), t ? t.forEach((e) => {
730
+ }), ce = (e) => {
731
+ let t = e ? Ke(e) : void 0;
732
+ t?.forEach((e) => Q(n.errors, e)), t ? t.forEach((e) => {
734
733
  p.state.next({
735
734
  name: e,
736
735
  errors: n.errors
737
736
  });
738
737
  }) : p.state.next({ errors: {} });
739
- }, de = (e, t, i) => {
738
+ }, le = (e, t, i) => {
740
739
  let a = (U(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = U(n.errors, e) || {};
741
740
  K(n.errors, e, {
742
741
  ...l,
@@ -747,8 +746,8 @@ function Mt(e = {}) {
747
746
  errors: n.errors,
748
747
  isValid: !1
749
748
  }), i && i.shouldFocus && a && a.focus && a.focus();
750
- }, fe = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || A(void 0, t), n) }) : A(e, t, !0), pe = (e) => p.state.subscribe({ next: (t) => {
751
- if (Ct(e.name, t.name, e.exact) && St(t, e.formState || d, xe, e.reRenderRoot)) {
749
+ }, ue = (e, t) => G(e) ? p.state.subscribe({ next: (n) => "values" in n && e(n.values || j(void 0, t), n) }) : j(e, t, !0), de = (e) => p.state.subscribe({ next: (t) => {
750
+ if (Et(e.name, t.name, e.exact) && Tt(t, e.formState || d, xe, e.reRenderRoot)) {
752
751
  let r = { ...a };
753
752
  e.callback({
754
753
  values: r,
@@ -757,27 +756,27 @@ function Mt(e = {}) {
757
756
  defaultValues: i
758
757
  });
759
758
  }
760
- } }).unsubscribe, me = (e) => (o.mount = !0, f = {
759
+ } }).unsubscribe, fe = (e) => (o.mount = !0, f = {
761
760
  ...f,
762
761
  ...e.formState
763
- }, pe({
762
+ }, de({
764
763
  ...e,
765
764
  formState: {
766
765
  ...u,
767
766
  ...e.formState
768
767
  }
769
- })), he = (e, o = {}) => {
770
- for (let c of e ? Ue(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || ($(r, c), $(a, c)), !o.keepError && $(n.errors, c), !o.keepDirty && $(n.dirtyFields, c), !o.keepTouched && $(n.touchedFields, c), !o.keepIsValidating && $(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && $(i, c);
768
+ })), pe = (e, o = {}) => {
769
+ for (let c of e ? Ke(e) : s.mount) s.mount.delete(c), s.array.delete(c), o.keepValue || (Q(r, c), Q(a, c)), !o.keepError && Q(n.errors, c), !o.keepDirty && Q(n.dirtyFields, c), !o.keepTouched && Q(n.touchedFields, c), !o.keepIsValidating && Q(n.validatingFields, c), !t.shouldUnregister && !o.keepDefaultValue && Q(i, c);
771
770
  p.state.next({ values: V(a) }), p.state.next({
772
771
  ...n,
773
- ...o.keepDirty ? { isDirty: k() } : {}
772
+ ...o.keepDirty ? { isDirty: A() } : {}
774
773
  }), !o.keepIsValid && g();
775
- }, M = ({ disabled: e, name: t }) => {
774
+ }, me = ({ disabled: e, name: t }) => {
776
775
  if (W(e) && o.mount || e || s.disabled.has(t)) {
777
776
  let n = s.disabled.has(t) !== !!e;
778
777
  e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
779
778
  }
780
- }, N = (e, n = {}) => {
779
+ }, he = (e, n = {}) => {
781
780
  let a = U(r, e), c = W(n.disabled) || W(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
782
781
  return K(r, e, {
783
782
  ...a || {},
@@ -787,32 +786,32 @@ function Mt(e = {}) {
787
786
  mount: !0,
788
787
  ...n
789
788
  }
790
- }), s.mount.add(e), a && !l ? M({
789
+ }), s.mount.add(e), a && !l ? me({
791
790
  disabled: W(n.disabled) ? n.disabled : t.disabled,
792
791
  name: e
793
792
  }) : S(e, !0, n.value), {
794
793
  ...c ? { disabled: n.disabled || t.disabled } : {},
795
794
  ...t.progressive ? {
796
795
  required: !!n.required,
797
- min: mt(n.min),
798
- max: mt(n.max),
799
- minLength: mt(n.minLength),
800
- maxLength: mt(n.maxLength),
801
- pattern: mt(n.pattern)
796
+ min: _t(n.min),
797
+ max: _t(n.max),
798
+ minLength: _t(n.minLength),
799
+ maxLength: _t(n.maxLength),
800
+ pattern: _t(n.pattern)
802
801
  } : {},
803
802
  name: e,
804
- onChange: oe,
805
- onBlur: oe,
803
+ onChange: ae,
804
+ onBlur: ae,
806
805
  ref: (c) => {
807
806
  if (c) {
808
- s.registerName.add(e), N(e, n), s.registerName.delete(e), a = U(r, e);
809
- let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = Xe(t), l = a._f.refs || [];
807
+ s.registerName.add(e), he(e, n), s.registerName.delete(e), a = U(r, e);
808
+ let t = H(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, o = $e(t), l = a._f.refs || [];
810
809
  if (o ? l.find((e) => e === t) : t === a._f.ref) return;
811
810
  K(r, e, { _f: {
812
811
  ...a._f,
813
812
  ...o ? {
814
813
  refs: [
815
- ...l.filter(Ze),
814
+ ...l.filter(et),
816
815
  t,
817
816
  ...Array.isArray(U(i, e)) ? [{}] : []
818
817
  ],
@@ -822,11 +821,11 @@ function Mt(e = {}) {
822
821
  }
823
822
  } : { ref: t }
824
823
  } }), S(e, !1, void 0, t);
825
- } else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(Ee(s.array, e) && o.action) && s.unMount.add(e);
824
+ } else a = U(r, e, {}), a._f && (a._f.mount = !1), (t.shouldUnregister || n.shouldUnregister) && !(Oe(s.array, e) && o.action) && s.unMount.add(e);
826
825
  }
827
826
  };
828
- }, P = () => t.shouldFocusError && bt(r, se, s.mount), ge = (e) => {
829
- W(e) && (p.state.next({ disabled: e }), bt(r, (t, n) => {
827
+ }, P = () => t.shouldFocusError && Ct(r, M, s.mount), ge = (e) => {
828
+ W(e) && (p.state.next({ disabled: e }), Ct(r, (t, n) => {
830
829
  let i = U(r, n);
831
830
  i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
832
831
  t.disabled = i._f.disabled || e;
@@ -837,14 +836,14 @@ function Mt(e = {}) {
837
836
  o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
838
837
  let l = V(a);
839
838
  if (p.state.next({ isSubmitting: !0 }), t.resolver) {
840
- let { errors: e, values: t } = await w();
839
+ let { errors: e, values: t } = await T();
841
840
  _(), n.errors = e, l = V(t);
842
- } else await D({
841
+ } else await O({
843
842
  fields: r,
844
- eventType: q.SUBMIT
843
+ eventType: Pe.SUBMIT
845
844
  });
846
- if (s.disabled.size) for (let e of s.disabled) $(l, e);
847
- if ($(n.errors, Ne), Q(n.errors)) {
845
+ if (s.disabled.size) for (let e of s.disabled) Q(l, e);
846
+ if (Q(n.errors, Ie), Z(n.errors)) {
848
847
  p.state.next({ errors: {} });
849
848
  try {
850
849
  await e(l, o);
@@ -855,27 +854,27 @@ function Mt(e = {}) {
855
854
  if (p.state.next({
856
855
  isSubmitted: !0,
857
856
  isSubmitting: !1,
858
- isSubmitSuccessful: Q(n.errors) && !c,
857
+ isSubmitSuccessful: Z(n.errors) && !c,
859
858
  submitCount: n.submitCount + 1,
860
859
  errors: n.errors
861
860
  }), c) throw c;
862
861
  }, ve = (e, t = {}) => {
863
- U(r, e) && (H(t.defaultValue) ? ie(e, V(U(i, e))) : (ie(e, t.defaultValue), K(i, e, V(t.defaultValue))), t.keepTouched || $(n.touchedFields, e), t.keepDirty || ($(n.dirtyFields, e), n.isDirty = t.defaultValue ? k(e, V(U(i, e))) : k()), t.keepError || ($(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
864
- }, F = (e, c = {}) => {
865
- let l = e ? V(e) : i, u = V(l), f = Q(e), m = f ? i : u;
862
+ U(r, e) && (H(t.defaultValue) ? re(e, V(U(i, e))) : (re(e, t.defaultValue), K(i, e, V(t.defaultValue))), t.keepTouched || Q(n.touchedFields, e), t.keepDirty || (Q(n.dirtyFields, e), n.isDirty = t.defaultValue ? A(e, V(U(i, e))) : A()), t.keepError || (Q(n.errors, e), d.isValid && g()), p.state.next({ ...n }));
863
+ }, ye = (e, c = {}) => {
864
+ let l = e ? V(e) : i, u = V(l), f = Z(e), m = f ? i : u;
866
865
  if (c.keepDefaultValues || (i = l), !c.keepValues) {
867
866
  if (c.keepDirtyValues) {
868
- let e = new Set([...s.mount, ...Object.keys(it(i, a))]);
867
+ let e = new Set([...s.mount, ...Object.keys(st(i, a))]);
869
868
  for (let t of Array.from(e)) {
870
869
  let e = U(n.dirtyFields, t), r = U(a, t), i = U(m, t);
871
- e && !H(r) ? K(m, t, r) : !e && !H(i) && ie(t, i);
870
+ e && !H(r) ? K(m, t, r) : !e && !H(i) && re(t, i);
872
871
  }
873
872
  } else {
874
- if (Oe && H(e)) for (let e of s.mount) {
873
+ if (Ae && H(e)) for (let e of s.mount) {
875
874
  let t = U(r, e);
876
875
  if (t && t._f) {
877
876
  let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
878
- if (qe(e)) {
877
+ if (Xe(e)) {
879
878
  let t = e.closest("form");
880
879
  if (t) {
881
880
  t.reset();
@@ -884,7 +883,7 @@ function Mt(e = {}) {
884
883
  }
885
884
  }
886
885
  }
887
- if (c.keepFieldsRef) for (let e of s.mount) ie(e, U(m, e));
886
+ if (c.keepFieldsRef) for (let e of s.mount) re(e, U(m, e));
888
887
  else r = {};
889
888
  }
890
889
  a = t.shouldUnregister ? c.keepDefaultValues ? V(i) : {} : V(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
@@ -898,21 +897,21 @@ function Mt(e = {}) {
898
897
  watch: /* @__PURE__ */ new Set(),
899
898
  watchAll: !1,
900
899
  focus: ""
901
- }, o.mount = !d.isValid || !!c.keepIsValid || !!c.keepDirtyValues || !t.shouldUnregister && !Q(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!c.keepIsValid, o.action = !1, c.keepErrors || (n.errors = {}), p.state.next({
900
+ }, o.mount = !d.isValid || !!c.keepIsValid || !!c.keepDirtyValues || !t.shouldUnregister && !Z(m), o.watch = !!t.shouldUnregister, o.keepIsValid = !!c.keepIsValid, o.action = !1, c.keepErrors || (n.errors = {}), p.state.next({
902
901
  submitCount: c.keepSubmitCount ? n.submitCount : 0,
903
- isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !Z(e, i)),
902
+ isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !X(e, i)),
904
903
  isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
905
- dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? it(i, a) : n.dirtyFields : c.keepDefaultValues && e ? it(i, e) : c.keepDirty ? n.dirtyFields : {},
904
+ dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? st(i, a) : n.dirtyFields : c.keepDefaultValues && e ? st(i, e) : c.keepDirty ? n.dirtyFields : {},
906
905
  touchedFields: c.keepTouched ? n.touchedFields : {},
907
906
  errors: c.keepErrors ? n.errors : {},
908
907
  isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
909
908
  isSubmitting: !1,
910
909
  defaultValues: i
911
910
  });
912
- }, ye = (e, n) => F(G(e) ? e(a) : e, {
911
+ }, be = (e, n) => ye(G(e) ? e(a) : e, {
913
912
  ...t.resetOptions,
914
913
  ...n
915
- }), be = (e, t = {}) => {
914
+ }), F = (e, t = {}) => {
916
915
  let n = U(r, e), i = n && n._f;
917
916
  if (i) {
918
917
  let e = i.refs ? i.refs[0] : i.ref;
@@ -927,27 +926,27 @@ function Mt(e = {}) {
927
926
  };
928
927
  }, Se = {
929
928
  control: {
930
- register: N,
931
- unregister: he,
932
- getFieldState: le,
929
+ register: he,
930
+ unregister: pe,
931
+ getFieldState: N,
933
932
  handleSubmit: _e,
934
- setError: de,
935
- _subscribe: pe,
936
- _runSchema: w,
933
+ setError: le,
934
+ _subscribe: de,
935
+ _runSchema: T,
937
936
  _updateIsValidating: _,
938
937
  _focusError: P,
939
- _getWatch: A,
940
- _getDirty: k,
938
+ _getWatch: j,
939
+ _getDirty: A,
941
940
  _setValid: g,
942
941
  _setFieldArray: y,
943
- _setDisabledField: M,
942
+ _setDisabledField: me,
944
943
  _setErrors: x,
945
- _getFieldArray: te,
946
- _reset: F,
944
+ _getFieldArray: ee,
945
+ _reset: ye,
947
946
  _resetDefaultValues: () => G(t.defaultValues) && t.defaultValues().then((e) => {
948
- ye(e, t.resetOptions), p.state.next({ isLoading: !1 });
947
+ be(e, t.resetOptions), p.state.next({ isLoading: !1 });
949
948
  }),
950
- _removeUnmounted: O,
949
+ _removeUnmounted: k,
951
950
  _disableForm: ge,
952
951
  _subjects: p,
953
952
  _proxyFormState: d,
@@ -985,30 +984,30 @@ function Mt(e = {}) {
985
984
  };
986
985
  }
987
986
  },
988
- subscribe: me,
989
- trigger: j,
990
- register: N,
987
+ subscribe: fe,
988
+ trigger: oe,
989
+ register: he,
991
990
  handleSubmit: _e,
992
- watch: fe,
993
- setValue: ie,
994
- setValues: ae,
995
- getValues: ce,
996
- reset: ye,
991
+ watch: ue,
992
+ setValue: re,
993
+ setValues: ie,
994
+ getValues: se,
995
+ reset: be,
997
996
  resetField: ve,
998
- clearErrors: ue,
999
- unregister: he,
1000
- setError: de,
1001
- setFocus: be,
1002
- getFieldState: le
997
+ clearErrors: ce,
998
+ unregister: pe,
999
+ setError: le,
1000
+ setFocus: F,
1001
+ getFieldState: N
1003
1002
  };
1004
1003
  return {
1005
1004
  ...Se,
1006
1005
  formControl: Se
1007
1006
  };
1008
1007
  }
1009
- function Nt(e = {}) {
1010
- let t = M.useRef(void 0), n = M.useRef(void 0), [r, i] = M.useState(() => ({
1011
- ...V(jt),
1008
+ function Ft(e = {}) {
1009
+ let t = P.useRef(void 0), n = P.useRef(void 0), [r, i] = P.useState(() => ({
1010
+ ...V(Nt),
1012
1011
  isLoading: G(e.defaultValues),
1013
1012
  errors: e.errors || {},
1014
1013
  disabled: e.disabled || !1,
@@ -1019,14 +1018,14 @@ function Nt(e = {}) {
1019
1018
  formState: r
1020
1019
  }, e.defaultValues && !G(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1021
1020
  else {
1022
- let { formControl: n, ...i } = Mt(e);
1021
+ let { formControl: n, ...i } = Pt(e);
1023
1022
  t.current = {
1024
1023
  ...i,
1025
1024
  formState: r
1026
1025
  };
1027
1026
  }
1028
1027
  let a = t.current.control;
1029
- return a._options = e, Le(() => {
1028
+ return a._options = e, Be(() => {
1030
1029
  let e = a._subscribe({
1031
1030
  formState: a._proxyFormState,
1032
1031
  callback: () => i({ ...a._formState }),
@@ -1036,63 +1035,63 @@ function Nt(e = {}) {
1036
1035
  ...e,
1037
1036
  isReady: !0
1038
1037
  })), a._formState.isReady = !0, e;
1039
- }, [a]), M.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), M.useEffect(() => {
1038
+ }, [a]), P.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), P.useEffect(() => {
1040
1039
  e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
1041
1040
  }, [
1042
1041
  a,
1043
1042
  e.mode,
1044
1043
  e.reValidateMode
1045
- ]), M.useEffect(() => {
1044
+ ]), P.useEffect(() => {
1046
1045
  e.errors && (a._setErrors(e.errors), a._focusError());
1047
- }, [a, e.errors]), M.useEffect(() => {
1046
+ }, [a, e.errors]), P.useEffect(() => {
1048
1047
  e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
1049
- }, [a, e.shouldUnregister]), M.useEffect(() => {
1048
+ }, [a, e.shouldUnregister]), P.useEffect(() => {
1050
1049
  if (a._proxyFormState.isDirty) {
1051
1050
  let e = a._getDirty();
1052
1051
  e !== r.isDirty && a._subjects.state.next({ isDirty: e });
1053
1052
  }
1054
- }, [a, r.isDirty]), M.useEffect(() => {
1055
- e.values && !Z(e.values, n.current) ? (a._reset(e.values, {
1053
+ }, [a, r.isDirty]), P.useEffect(() => {
1054
+ e.values && !X(e.values, n.current) ? (a._reset(e.values, {
1056
1055
  keepFieldsRef: !0,
1057
1056
  ...a._options.resetOptions
1058
1057
  }), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
1059
- }, [a, e.values]), M.useEffect(() => {
1058
+ }, [a, e.values]), P.useEffect(() => {
1060
1059
  a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
1061
- }), t.current.formState = M.useMemo(() => Ie(r, a), [a, r]), t.current;
1060
+ }), t.current.formState = P.useMemo(() => ze(r, a), [a, r]), t.current;
1062
1061
  }
1063
1062
  //#endregion
1064
1063
  //#region node_modules/@hookform/resolvers/dist/resolvers.mjs
1065
- var Pt = (e, t, n) => {
1064
+ var It = (e, t, n) => {
1066
1065
  if (e && "reportValidity" in e) {
1067
1066
  let r = U(n, t);
1068
1067
  e.setCustomValidity(r && r.message || ""), e.reportValidity();
1069
1068
  }
1070
- }, Ft = (e, t) => {
1069
+ }, Lt = (e, t) => {
1071
1070
  for (let n in t.fields) {
1072
1071
  let r = t.fields[n];
1073
- r && r.ref && "reportValidity" in r.ref ? Pt(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => Pt(t, n, e));
1072
+ r && r.ref && "reportValidity" in r.ref ? It(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => It(t, n, e));
1074
1073
  }
1075
- }, It = (e, t) => {
1076
- t.shouldUseNativeValidation && Ft(e, t);
1074
+ }, Rt = (e, t) => {
1075
+ t.shouldUseNativeValidation && Lt(e, t);
1077
1076
  let n = {};
1078
1077
  for (let r in e) {
1079
1078
  let i = U(t.fields, r), a = Object.assign(e[r] || {}, { ref: i && i.ref });
1080
- if (Lt(t.names || Object.keys(e), r)) {
1079
+ if (zt(t.names || Object.keys(e), r)) {
1081
1080
  let e = Object.assign({}, U(n, r));
1082
1081
  K(e, "root", a), K(n, r, e);
1083
1082
  } else K(n, r, a);
1084
1083
  }
1085
1084
  return n;
1086
- }, Lt = (e, t) => {
1087
- let n = Rt(t);
1088
- return e.some((e) => Rt(e).match(`^${n}\\.\\d+`));
1085
+ }, zt = (e, t) => {
1086
+ let n = Bt(t);
1087
+ return e.some((e) => Bt(e).match(`^${n}\\.\\d+`));
1089
1088
  };
1090
- function Rt(e) {
1089
+ function Bt(e) {
1091
1090
  return e.replace(/\]|\[/g, "");
1092
1091
  }
1093
1092
  //#endregion
1094
1093
  //#region node_modules/@hookform/resolvers/zod/dist/zod.mjs
1095
- function zt(e, t) {
1094
+ function Vt(e, t) {
1096
1095
  try {
1097
1096
  var n = e();
1098
1097
  } catch (e) {
@@ -1100,7 +1099,7 @@ function zt(e, t) {
1100
1099
  }
1101
1100
  return n && n.then ? n.then(void 0, t) : n;
1102
1101
  }
1103
- function Bt(e, t) {
1102
+ function Ht(e, t) {
1104
1103
  for (var n = {}; e.length;) {
1105
1104
  var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
1106
1105
  if (!n[o]) if ("unionErrors" in r) {
@@ -1119,13 +1118,13 @@ function Bt(e, t) {
1119
1118
  });
1120
1119
  }), t) {
1121
1120
  var c = n[o].types, l = c && c[r.code];
1122
- n[o] = He(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1121
+ n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1123
1122
  }
1124
1123
  e.shift();
1125
1124
  }
1126
1125
  return n;
1127
1126
  }
1128
- function Vt(e, t) {
1127
+ function Ut(e, t) {
1129
1128
  for (var n = {}; e.length;) {
1130
1129
  var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
1131
1130
  if (!n[o]) if (r.code === "invalid_union" && r.errors.length > 0) {
@@ -1144,20 +1143,20 @@ function Vt(e, t) {
1144
1143
  });
1145
1144
  }), t) {
1146
1145
  var c = n[o].types, l = c && c[r.code];
1147
- n[o] = He(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1146
+ n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1148
1147
  }
1149
1148
  e.shift();
1150
1149
  }
1151
1150
  return n;
1152
1151
  }
1153
- function Ht(e, t, n) {
1152
+ function Wt(e, t, n) {
1154
1153
  if (n === void 0 && (n = {}), function(e) {
1155
1154
  return "_def" in e && typeof e._def == "object" && "typeName" in e._def;
1156
1155
  }(e)) return function(r, i, a) {
1157
1156
  try {
1158
- return Promise.resolve(zt(function() {
1157
+ return Promise.resolve(Vt(function() {
1159
1158
  return Promise.resolve(e[n.mode === "sync" ? "parse" : "parseAsync"](r, t)).then(function(e) {
1160
- return a.shouldUseNativeValidation && Ft({}, a), {
1159
+ return a.shouldUseNativeValidation && Lt({}, a), {
1161
1160
  errors: {},
1162
1161
  values: n.raw ? Object.assign({}, r) : e
1163
1162
  };
@@ -1167,7 +1166,7 @@ function Ht(e, t, n) {
1167
1166
  return Array.isArray(e?.issues);
1168
1167
  }(e)) return {
1169
1168
  values: {},
1170
- errors: It(Bt(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1169
+ errors: Rt(Ht(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1171
1170
  };
1172
1171
  throw e;
1173
1172
  }));
@@ -1179,19 +1178,19 @@ function Ht(e, t, n) {
1179
1178
  return "_zod" in e && typeof e._zod == "object";
1180
1179
  }(e)) return function(r, i, a) {
1181
1180
  try {
1182
- return Promise.resolve(zt(function() {
1183
- return Promise.resolve((n.mode === "sync" ? C : m)(e, r, t)).then(function(e) {
1184
- return a.shouldUseNativeValidation && Ft({}, a), {
1181
+ return Promise.resolve(Vt(function() {
1182
+ return Promise.resolve((n.mode === "sync" ? g : le)(e, r, t)).then(function(e) {
1183
+ return a.shouldUseNativeValidation && Lt({}, a), {
1185
1184
  errors: {},
1186
1185
  values: n.raw ? Object.assign({}, r) : e
1187
1186
  };
1188
1187
  });
1189
1188
  }, function(e) {
1190
1189
  if (function(e) {
1191
- return e instanceof le;
1190
+ return e instanceof l;
1192
1191
  }(e)) return {
1193
1192
  values: {},
1194
- errors: It(Vt(e.issues, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1193
+ errors: Rt(Ut(e.issues, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1195
1194
  };
1196
1195
  throw e;
1197
1196
  }));
@@ -1203,94 +1202,107 @@ function Ht(e, t, n) {
1203
1202
  }
1204
1203
  //#endregion
1205
1204
  //#region src/base/form/form-utils.ts
1206
- function Ut(e) {
1205
+ function Gt(e) {
1207
1206
  let t = [];
1208
- for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...Ut(n.children));
1207
+ for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...Gt(n.children));
1209
1208
  return t;
1210
1209
  }
1211
- function Wt(e, t) {
1210
+ function Kt(e, n) {
1212
1211
  if (e.component === "header") return !0;
1213
- let { props: n } = e;
1214
- return !(n.hidden_when && r(n.hidden_when, t) || n.visible_when && !r(n.visible_when, t));
1212
+ let { props: r } = e;
1213
+ return !(r.hidden_when && t(r.hidden_when, n) || r.visible_when && !t(r.visible_when, n));
1214
+ }
1215
+ function qt(e, n) {
1216
+ if (e.component === "header") return !1;
1217
+ let { props: r } = e;
1218
+ return !!(r.disabled || r.disabled_when && t(r.disabled_when, n));
1219
+ }
1220
+ function Jt(e, n) {
1221
+ if (e.component === "header" || qt(e, n)) return !1;
1222
+ let { props: r } = e;
1223
+ return !!(r.required || r.required_when && t(r.required_when, n));
1215
1224
  }
1216
1225
  //#endregion
1217
1226
  //#region src/base/form/form-schema-builder.ts
1218
- function Gt(e, t) {
1219
- let { component: n, props: r } = e, i = r.validation, a = r.required;
1220
- switch (n) {
1227
+ function Yt(e, t, n) {
1228
+ let { component: r, props: i } = e, a = i.validation, o = n;
1229
+ switch (r) {
1221
1230
  case "text":
1222
1231
  case "textarea":
1223
1232
  case "password":
1224
1233
  case "slug":
1225
1234
  case "color": {
1226
- let e = k();
1227
- return a && (e = e.min(1, t("middag.ui.validation.required"))), i?.minLength && (e = e.min(i.minLength, t("middag.ui.validation.min_length", { min: i.minLength }))), i?.maxLength && (e = e.max(i.maxLength, t("middag.ui.validation.max_length", { max: i.maxLength }))), i?.pattern && (e = e.regex(new RegExp(i.pattern), i.patternMessage ?? t("middag.ui.validation.pattern"))), a ? e : e.or(j(""));
1235
+ let e = N();
1236
+ return o && (e = e.min(1, t("middag.ui.validation.required"))), a?.minLength && (e = e.min(a.minLength, t("middag.ui.validation.min_length", { min: a.minLength }))), a?.maxLength && (e = e.max(a.maxLength, t("middag.ui.validation.max_length", { max: a.maxLength }))), a?.pattern && (e = e.regex(new RegExp(a.pattern), a.patternMessage ?? t("middag.ui.validation.pattern"))), o ? e : e.or(A(""));
1228
1237
  }
1229
1238
  case "email": {
1230
- let e = k();
1231
- if (a) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
1232
- else return e.email(t("middag.ui.validation.email")).or(j(""));
1239
+ let e = N();
1240
+ if (o) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
1241
+ else return e.email(t("middag.ui.validation.email")).or(A(""));
1233
1242
  return e;
1234
1243
  }
1235
1244
  case "url": {
1236
- let e = k();
1237
- if (a) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
1238
- else return e.url(t("middag.ui.validation.url")).or(j(""));
1245
+ let e = N();
1246
+ if (o) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
1247
+ else return e.url(t("middag.ui.validation.url")).or(A(""));
1239
1248
  return e;
1240
1249
  }
1241
1250
  case "int": {
1242
- let e = y({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
1243
- return r.min != null && (e = e.min(r.min, t("middag.ui.validation.min_value", { min: r.min }))), r.max != null && (e = e.max(r.max, t("middag.ui.validation.max_value", { max: r.max }))), a ? e : e.nullable();
1251
+ let e = T({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
1252
+ return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
1244
1253
  }
1245
1254
  case "float": {
1246
- let e = y();
1247
- return r.min != null && (e = e.min(r.min, t("middag.ui.validation.min_value", { min: r.min }))), r.max != null && (e = e.max(r.max, t("middag.ui.validation.max_value", { max: r.max }))), a ? e : e.nullable();
1255
+ let e = T();
1256
+ return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
1248
1257
  }
1249
1258
  case "currency": {
1250
- let e = y();
1251
- return a ? e : e.nullable();
1259
+ let e = T();
1260
+ return o ? e : e.nullable();
1252
1261
  }
1253
1262
  case "select":
1254
1263
  case "radio":
1255
1264
  case "entity_picker": {
1256
- let e = k();
1257
- return a ? e.min(1, t("middag.ui.validation.required")) : e;
1265
+ let e = N();
1266
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1258
1267
  }
1259
1268
  case "multiselect":
1260
1269
  case "tags": {
1261
- let e = _(k());
1262
- return a ? e.min(1, t("middag.ui.validation.required")) : e;
1270
+ let e = x(N());
1271
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1263
1272
  }
1264
1273
  case "checkbox":
1265
- case "switch": return D();
1274
+ case "switch": return ne();
1266
1275
  case "date":
1267
1276
  case "datetime": {
1268
- let e = k();
1269
- return a ? e.min(1, t("middag.ui.validation.required")) : e;
1277
+ let e = N();
1278
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1270
1279
  }
1271
1280
  case "phone": {
1272
- let e = k();
1273
- return a ? e.min(1, t("middag.ui.validation.required")) : e;
1281
+ let e = N();
1282
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1274
1283
  }
1275
1284
  case "document": {
1276
- let e = r.documentType ?? "generic", n = r.documentScope ?? "any", i = k();
1277
- return a ? i.min(1, t("middag.ui.validation.required")).refine((t) => he(t, e, n), t("middag.ui.validation.document_invalid")) : i.refine((t) => t === "" || he(t, e, n), t("middag.ui.validation.document_invalid"));
1285
+ let e = i.documentType ?? "generic", n = i.documentScope ?? "any", r = N(), a = async (t) => {
1286
+ let { isValidDocument: r } = await import("./document-validation-DX0fB9cu.js");
1287
+ return r(t, e, n);
1288
+ };
1289
+ return o ? r.min(1, t("middag.ui.validation.required")).refine(a, t("middag.ui.validation.document_invalid")) : r.refine(async (e) => e === "" || await a(e), t("middag.ui.validation.document_invalid"));
1278
1290
  }
1279
- default: return ae();
1291
+ default: return y();
1280
1292
  }
1281
1293
  }
1282
- function Kt(e, t, n) {
1283
- let r = Ut(e), i = {};
1284
- for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || Wt(e, t) && (i[e.key] = Gt(e, n));
1285
- return x(i);
1294
+ function Xt(e, t, n) {
1295
+ let r = Gt(e), i = {};
1296
+ for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || Kt(e, t) && (i[e.key] = Yt(e, n, Jt(e, t)));
1297
+ return C(i);
1286
1298
  }
1287
1299
  //#endregion
1288
1300
  //#region src/base/form/FormField.tsx
1289
- var qt = P(() => import("./PhoneField-DpHb6FQE.js").then((e) => ({ default: e.PhoneField }))), Jt = P(() => import("./DateField-BCCidKwl.js").then((e) => ({ default: e.DateField }))), Yt = P(() => import("./DocumentField-5uXJyXlL.js").then((e) => ({ default: e.DocumentField }))), Xt = P(() => import("./DateRangeField-CvU7wiyr.js").then((e) => ({ default: e.DateRangeField })));
1290
- function Zt() {
1291
- return /* @__PURE__ */ I(me, { className: "h-9 w-full rounded-md" });
1301
+ var Zt = _e(() => import("./PhoneField-D_djeYhK.js").then((e) => ({ default: e.PhoneField }))), Qt = _e(() => import("./DateField-CcRD2r-Z.js").then((e) => ({ default: e.DateField }))), $t = _e(() => import("./DocumentField-DjnK9T7o.js").then((e) => ({ default: e.DocumentField }))), en = _e(() => import("./DateRangeField-DKZMfKB2.js").then((e) => ({ default: e.DateRangeField })));
1302
+ function tn() {
1303
+ return /* @__PURE__ */ I(he, { className: "h-9 w-full rounded-md" });
1292
1304
  }
1293
- function Qt({ label: e }) {
1305
+ function nn({ label: e }) {
1294
1306
  return /* @__PURE__ */ I("div", {
1295
1307
  className: "pt-4 pb-1",
1296
1308
  children: /* @__PURE__ */ I("h4", {
@@ -1299,147 +1311,147 @@ function Qt({ label: e }) {
1299
1311
  })
1300
1312
  });
1301
1313
  }
1302
- function $t({ id: e, value: t }) {
1314
+ function rn({ id: e, value: t }) {
1303
1315
  return /* @__PURE__ */ I("input", {
1304
1316
  type: "hidden",
1305
1317
  id: e,
1306
1318
  value: String(t ?? "")
1307
1319
  });
1308
1320
  }
1309
- function en({ field: e, value: t, onChange: n, error: r }) {
1310
- let { t: a } = pe(), o = ve(), s = `field-${e.key}-${o}`, c = `${s}-help`, l = `${s}-error`, { component: u, props: d } = e;
1311
- if (u === "header") return /* @__PURE__ */ I(Qt, { label: d.label });
1312
- if (u === "hidden") return /* @__PURE__ */ I($t, {
1313
- id: s,
1321
+ function an({ field: e, value: t, onChange: r, error: i, sourceValues: a = {} }) {
1322
+ let { t: o } = pe(), s = be(), c = `field-${e.key}-${s}`, l = `${c}-help`, u = `${c}-error`, { component: d, props: f } = e;
1323
+ if (d === "header") return /* @__PURE__ */ I(nn, { label: f.label });
1324
+ if (d === "hidden") return /* @__PURE__ */ I(rn, {
1325
+ id: c,
1314
1326
  value: t
1315
1327
  });
1316
- let f = u === "checkbox" || u === "switch", p = tn(u, s, t, n, d, r, c, l, a);
1328
+ let p = qt(e, a), m = Jt(e, a), h = d === "checkbox" || d === "switch", g = on(d, c, t, r, f, i, l, u, o, a, p, m);
1317
1329
  return /* @__PURE__ */ L("div", {
1318
1330
  className: "space-y-1.5",
1319
1331
  children: [
1320
- !f && /* @__PURE__ */ L(i, {
1321
- htmlFor: s,
1322
- children: [d.label, d.required && /* @__PURE__ */ I("span", {
1332
+ !h && /* @__PURE__ */ L(n, {
1333
+ htmlFor: c,
1334
+ children: [f.label, m && /* @__PURE__ */ I("span", {
1323
1335
  className: "text-destructive ml-0.5",
1324
1336
  children: "*"
1325
1337
  })]
1326
1338
  }),
1327
- d.helpText && /* @__PURE__ */ I("p", {
1328
- id: c,
1339
+ f.helpText && /* @__PURE__ */ I("p", {
1340
+ id: l,
1329
1341
  className: "text-muted-foreground text-xs",
1330
- children: d.helpText
1342
+ children: f.helpText
1331
1343
  }),
1332
- p,
1333
- r && /* @__PURE__ */ I("p", {
1334
- id: l,
1344
+ g,
1345
+ i && /* @__PURE__ */ I("p", {
1346
+ id: u,
1335
1347
  className: "text-destructive text-xs",
1336
1348
  "aria-live": "polite",
1337
- children: r
1349
+ children: i
1338
1350
  })
1339
1351
  ]
1340
1352
  });
1341
1353
  }
1342
- function tn(e, t, r, i, a, o, s, c, u) {
1343
- let d = {
1344
- id: t,
1354
+ function on(t, n, r, i, a, o, s, c, l, d, f, p) {
1355
+ let g = {
1356
+ id: n,
1345
1357
  error: o,
1346
1358
  helpTextId: s,
1347
1359
  errorId: c,
1348
- disabled: a.disabled,
1349
- required: a.required
1360
+ disabled: f,
1361
+ required: p
1350
1362
  };
1351
- switch (e) {
1352
- case "text": return /* @__PURE__ */ I(re, {
1353
- ...d,
1363
+ switch (t) {
1364
+ case "text": return /* @__PURE__ */ I(ie, {
1365
+ ...g,
1354
1366
  type: "text",
1355
1367
  value: r,
1356
1368
  onChange: i,
1357
1369
  placeholder: a.placeholder,
1358
1370
  readOnly: a.readOnly
1359
1371
  });
1360
- case "email": return /* @__PURE__ */ I(re, {
1361
- ...d,
1372
+ case "email": return /* @__PURE__ */ I(ie, {
1373
+ ...g,
1362
1374
  type: "email",
1363
1375
  value: r,
1364
1376
  onChange: i,
1365
1377
  placeholder: a.placeholder,
1366
1378
  readOnly: a.readOnly
1367
1379
  });
1368
- case "url": return /* @__PURE__ */ I(re, {
1369
- ...d,
1380
+ case "url": return /* @__PURE__ */ I(ie, {
1381
+ ...g,
1370
1382
  type: "url",
1371
1383
  value: r,
1372
1384
  onChange: i,
1373
1385
  placeholder: a.placeholder,
1374
1386
  readOnly: a.readOnly
1375
1387
  });
1376
- case "textarea": return /* @__PURE__ */ I(w, {
1377
- ...d,
1388
+ case "textarea": return /* @__PURE__ */ I(E, {
1389
+ ...g,
1378
1390
  value: r,
1379
1391
  onChange: i,
1380
1392
  placeholder: a.placeholder,
1381
1393
  rows: a.rows,
1382
1394
  readOnly: a.readOnly
1383
1395
  });
1384
- case "password": return /* @__PURE__ */ I(ne, {
1385
- ...d,
1396
+ case "password": return /* @__PURE__ */ I(te, {
1397
+ ...g,
1386
1398
  value: r,
1387
1399
  onChange: i,
1388
1400
  placeholder: a.placeholder
1389
1401
  });
1390
- case "otp": return /* @__PURE__ */ I(O, {
1391
- ...d,
1402
+ case "otp": return /* @__PURE__ */ I(k, {
1403
+ ...g,
1392
1404
  value: r,
1393
1405
  onChange: i,
1394
1406
  maxLength: a.maxLength,
1395
1407
  pattern: a.pattern,
1396
1408
  groupSize: a.groupSize
1397
1409
  });
1398
- case "select": return /* @__PURE__ */ I(se, {
1399
- ...d,
1410
+ case "select": return /* @__PURE__ */ I(oe, {
1411
+ ...g,
1400
1412
  value: r,
1401
1413
  onChange: i,
1402
1414
  options: a.options ?? [],
1403
1415
  placeholder: a.placeholder
1404
1416
  });
1405
1417
  case "native_select": return /* @__PURE__ */ I(S, {
1406
- ...d,
1418
+ ...g,
1407
1419
  value: r,
1408
1420
  onChange: i,
1409
1421
  options: a.options ?? [],
1410
1422
  placeholder: a.placeholder
1411
1423
  });
1412
- case "multiselect": return /* @__PURE__ */ I(p, {
1413
- ...d,
1424
+ case "multiselect": return /* @__PURE__ */ I(m, {
1425
+ ...g,
1414
1426
  value: r,
1415
1427
  onChange: i,
1416
1428
  options: a.options ?? [],
1417
1429
  placeholder: a.placeholder
1418
1430
  });
1419
1431
  case "radio": return /* @__PURE__ */ I(b, {
1420
- ...d,
1432
+ ...g,
1421
1433
  value: r,
1422
1434
  onChange: i,
1423
1435
  options: a.options ?? []
1424
1436
  });
1425
- case "int": return /* @__PURE__ */ I(ee, {
1426
- ...d,
1437
+ case "int": return /* @__PURE__ */ I(w, {
1438
+ ...g,
1427
1439
  value: r,
1428
1440
  onChange: i,
1429
1441
  min: a.min,
1430
1442
  max: a.max,
1431
1443
  step: 1
1432
1444
  });
1433
- case "float": return /* @__PURE__ */ I(ee, {
1434
- ...d,
1445
+ case "float": return /* @__PURE__ */ I(w, {
1446
+ ...g,
1435
1447
  value: r,
1436
1448
  onChange: i,
1437
1449
  min: a.min,
1438
1450
  max: a.max,
1439
1451
  step: a.step ?? .1
1440
1452
  });
1441
- case "slider": return /* @__PURE__ */ I(E, {
1442
- ...d,
1453
+ case "slider": return /* @__PURE__ */ I(O, {
1454
+ ...g,
1443
1455
  value: r,
1444
1456
  onChange: i,
1445
1457
  min: a.min,
@@ -1447,40 +1459,40 @@ function tn(e, t, r, i, a, o, s, c, u) {
1447
1459
  step: a.step,
1448
1460
  multiple: a.multiple
1449
1461
  });
1450
- case "checkbox": return /* @__PURE__ */ I(l, {
1451
- ...d,
1462
+ case "checkbox": return /* @__PURE__ */ I(u, {
1463
+ ...g,
1452
1464
  value: r,
1453
1465
  onChange: i,
1454
1466
  label: a.label
1455
1467
  });
1456
- case "switch": return /* @__PURE__ */ I(te, {
1457
- ...d,
1468
+ case "switch": return /* @__PURE__ */ I(ee, {
1469
+ ...g,
1458
1470
  value: r,
1459
1471
  onChange: i,
1460
1472
  label: a.label
1461
1473
  });
1462
- case "date": return /* @__PURE__ */ I(N, {
1463
- fallback: /* @__PURE__ */ I(Zt, {}),
1464
- children: /* @__PURE__ */ I(Jt, {
1465
- ...d,
1474
+ case "date": return /* @__PURE__ */ I(ge, {
1475
+ fallback: /* @__PURE__ */ I(tn, {}),
1476
+ children: /* @__PURE__ */ I(Qt, {
1477
+ ...g,
1466
1478
  mode: "date",
1467
1479
  value: r,
1468
1480
  onChange: i,
1469
1481
  placeholder: a.placeholder
1470
1482
  })
1471
1483
  });
1472
- case "datetime": return /* @__PURE__ */ I(N, {
1473
- fallback: /* @__PURE__ */ I(Zt, {}),
1474
- children: /* @__PURE__ */ I(Jt, {
1475
- ...d,
1484
+ case "datetime": return /* @__PURE__ */ I(ge, {
1485
+ fallback: /* @__PURE__ */ I(tn, {}),
1486
+ children: /* @__PURE__ */ I(Qt, {
1487
+ ...g,
1476
1488
  mode: "datetime",
1477
1489
  value: r,
1478
1490
  onChange: i,
1479
1491
  placeholder: a.placeholder
1480
1492
  })
1481
1493
  });
1482
- case "file": return /* @__PURE__ */ I(ce, {
1483
- ...d,
1494
+ case "file": return /* @__PURE__ */ I(se, {
1495
+ ...g,
1484
1496
  value: r,
1485
1497
  onChange: i,
1486
1498
  accept: a.accept,
@@ -1488,8 +1500,8 @@ function tn(e, t, r, i, a, o, s, c, u) {
1488
1500
  maxFiles: a.maxFiles,
1489
1501
  maxSize: a.maxSize
1490
1502
  });
1491
- case "entity_picker": return /* @__PURE__ */ I(de, {
1492
- ...d,
1503
+ case "entity_picker": return /* @__PURE__ */ I(ue, {
1504
+ ...g,
1493
1505
  value: r,
1494
1506
  onChange: i,
1495
1507
  options: a.options,
@@ -1500,14 +1512,14 @@ function tn(e, t, r, i, a, o, s, c, u) {
1500
1512
  entitySubtitleField: a.entitySubtitleField,
1501
1513
  placeholder: a.placeholder
1502
1514
  });
1503
- case "static": return /* @__PURE__ */ I(ie, {
1504
- id: t,
1515
+ case "static": return /* @__PURE__ */ I(ae, {
1516
+ id: n,
1505
1517
  value: r
1506
1518
  });
1507
- case "phone": return /* @__PURE__ */ I(N, {
1508
- fallback: /* @__PURE__ */ I(Zt, {}),
1509
- children: /* @__PURE__ */ I(qt, {
1510
- ...d,
1519
+ case "phone": return /* @__PURE__ */ I(ge, {
1520
+ fallback: /* @__PURE__ */ I(tn, {}),
1521
+ children: /* @__PURE__ */ I(Zt, {
1522
+ ...g,
1511
1523
  value: r,
1512
1524
  onChange: i,
1513
1525
  placeholder: a.placeholder,
@@ -1515,10 +1527,10 @@ function tn(e, t, r, i, a, o, s, c, u) {
1515
1527
  fixedCountry: a.fixedCountry
1516
1528
  })
1517
1529
  });
1518
- case "document": return /* @__PURE__ */ I(N, {
1519
- fallback: /* @__PURE__ */ I(Zt, {}),
1520
- children: /* @__PURE__ */ I(Yt, {
1521
- ...d,
1530
+ case "document": return /* @__PURE__ */ I(ge, {
1531
+ fallback: /* @__PURE__ */ I(tn, {}),
1532
+ children: /* @__PURE__ */ I($t, {
1533
+ ...g,
1522
1534
  value: r,
1523
1535
  onChange: i,
1524
1536
  documentType: a.documentType,
@@ -1527,8 +1539,8 @@ function tn(e, t, r, i, a, o, s, c, u) {
1527
1539
  placeholder: a.placeholder
1528
1540
  })
1529
1541
  });
1530
- case "currency": return /* @__PURE__ */ I(n, {
1531
- ...d,
1542
+ case "currency": return /* @__PURE__ */ I(e, {
1543
+ ...g,
1532
1544
  value: r,
1533
1545
  onChange: i,
1534
1546
  currency: a.currency,
@@ -1536,202 +1548,269 @@ function tn(e, t, r, i, a, o, s, c, u) {
1536
1548
  min: a.min,
1537
1549
  max: a.max
1538
1550
  });
1539
- case "color": return /* @__PURE__ */ I(ue, {
1540
- ...d,
1551
+ case "color": return /* @__PURE__ */ I(ce, {
1552
+ ...g,
1541
1553
  value: r,
1542
1554
  onChange: i,
1543
1555
  placeholder: a.placeholder
1544
1556
  });
1545
- case "slug": return /* @__PURE__ */ I(g, {
1546
- ...d,
1557
+ case "slug": return /* @__PURE__ */ I(_, {
1558
+ ...g,
1547
1559
  value: r,
1548
1560
  onChange: i,
1549
- sourceValue: a.sourceField,
1561
+ sourceValue: a.sourceField === void 0 ? void 0 : String(d[a.sourceField] ?? ""),
1550
1562
  prefix: a.prefix,
1551
1563
  placeholder: a.placeholder
1552
1564
  });
1553
1565
  case "tags": return /* @__PURE__ */ I(h, {
1554
- ...d,
1566
+ ...g,
1555
1567
  value: r,
1556
1568
  onChange: i,
1557
1569
  placeholder: a.placeholder,
1558
1570
  maxTags: a.maxTags
1559
1571
  });
1560
- case "date_range": return /* @__PURE__ */ I(N, {
1561
- fallback: /* @__PURE__ */ I(Zt, {}),
1562
- children: /* @__PURE__ */ I(Xt, {
1563
- ...d,
1572
+ case "date_range": return /* @__PURE__ */ I(ge, {
1573
+ fallback: /* @__PURE__ */ I(tn, {}),
1574
+ children: /* @__PURE__ */ I(en, {
1575
+ ...g,
1564
1576
  value: r,
1565
1577
  onChange: i,
1566
1578
  operator: a.operator
1567
1579
  })
1568
1580
  });
1569
1581
  case "rating": return /* @__PURE__ */ I(v, {
1570
- ...d,
1582
+ ...g,
1571
1583
  value: r,
1572
1584
  onChange: i,
1573
1585
  maxRating: a.maxRating
1574
1586
  });
1575
1587
  default: return /* @__PURE__ */ L("p", {
1576
1588
  className: "text-destructive text-xs",
1577
- children: ["Unknown field component: ", e]
1589
+ children: ["Unknown field component: ", t]
1578
1590
  });
1579
1591
  }
1580
1592
  }
1581
1593
  //#endregion
1582
1594
  //#region src/base/blocks/FormPanelBlock.tsx
1583
- function nn({ nodes: t, values: n, errors: r, onChange: i }) {
1584
- return /* @__PURE__ */ I(Se, { children: t.map((t, a) => {
1585
- switch (t.kind) {
1586
- case "field": return Wt(t, n) ? /* @__PURE__ */ I(en, {
1587
- field: t,
1588
- value: n[t.key] ?? "",
1589
- onChange: (e) => i(t.key, e),
1590
- error: r[t.key]
1591
- }, t.key) : null;
1592
- case "section": return /* @__PURE__ */ I(A, {
1593
- id: t.id,
1594
- title: t.label,
1595
- defaultCollapsed: t.defaultCollapsed,
1596
- hasErrors: t.children.some((e) => e.kind === "field" && !!r[e.key]),
1597
- errorCount: t.children.filter((e) => e.kind === "field" && !!r[e.key]).length,
1598
- children: /* @__PURE__ */ I(nn, {
1599
- nodes: t.children,
1600
- values: n,
1601
- errors: r,
1602
- onChange: i
1595
+ function sn(e, t) {
1596
+ let n = t[e.key];
1597
+ if (n != null) return n;
1598
+ switch (e.component) {
1599
+ case "int":
1600
+ case "float":
1601
+ case "currency":
1602
+ case "slider":
1603
+ case "rating": return null;
1604
+ case "checkbox":
1605
+ case "switch": return !1;
1606
+ case "multiselect":
1607
+ case "tags": return [];
1608
+ default: return "";
1609
+ }
1610
+ }
1611
+ function cn(e, t) {
1612
+ return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : sn(e, t);
1613
+ }
1614
+ function ln({ nodes: e, values: t, errors: n, onChange: r, sourceValues: i }) {
1615
+ return /* @__PURE__ */ I(we, { children: e.map((e, a) => {
1616
+ switch (e.kind) {
1617
+ case "field": return Kt(e, t) ? /* @__PURE__ */ I(an, {
1618
+ field: e,
1619
+ value: cn(e, t),
1620
+ onChange: (t) => r(e.key, t),
1621
+ error: n[e.key],
1622
+ sourceValues: i
1623
+ }, e.key) : null;
1624
+ case "section": return /* @__PURE__ */ I(j, {
1625
+ id: e.id,
1626
+ title: e.label,
1627
+ defaultCollapsed: e.defaultCollapsed,
1628
+ hasErrors: e.children.some((e) => e.kind === "field" && !!n[e.key]),
1629
+ errorCount: e.children.filter((e) => e.kind === "field" && !!n[e.key]).length,
1630
+ children: /* @__PURE__ */ I(ln, {
1631
+ nodes: e.children,
1632
+ values: t,
1633
+ errors: n,
1634
+ onChange: r,
1635
+ sourceValues: i
1603
1636
  })
1604
- }, t.id);
1637
+ }, e.id);
1605
1638
  case "group": return /* @__PURE__ */ I("div", {
1606
- className: e("grid gap-6", t.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
1607
- children: /* @__PURE__ */ I(nn, {
1608
- nodes: t.children,
1609
- values: n,
1610
- errors: r,
1611
- onChange: i
1639
+ className: me("grid gap-6", e.columns === 2 ? "md:grid-cols-2" : "grid-cols-1"),
1640
+ children: /* @__PURE__ */ I(ln, {
1641
+ nodes: e.children,
1642
+ values: t,
1643
+ errors: n,
1644
+ onChange: r,
1645
+ sourceValues: i
1612
1646
  })
1613
- }, t.id);
1647
+ }, e.id);
1614
1648
  case "header": return /* @__PURE__ */ L("div", {
1615
1649
  className: "space-y-2",
1616
- children: [/* @__PURE__ */ I(T, {}), /* @__PURE__ */ I("h4", {
1650
+ children: [/* @__PURE__ */ I(D, {}), /* @__PURE__ */ I("h4", {
1617
1651
  className: "text-foreground text-base font-semibold",
1618
- children: t.label
1652
+ children: e.label
1619
1653
  })]
1620
1654
  }, `header-${a}`);
1621
1655
  default: return null;
1622
1656
  }
1623
1657
  }) });
1624
1658
  }
1625
- function rn({ block: e }) {
1626
- let { t: n } = pe(), { data: r } = e, i = F(() => Ut(r.schema), [r.schema]), l = (r.meta.validation ?? "both") !== "server", p = F(() => Object.fromEntries(i.map((e) => [e.key, r.values[e.key] ?? ""])), [i, r.values]), m = ye(l ? Kt(r.schema, p, n) : null), h = Nt({
1627
- defaultValues: p,
1659
+ function un({ block: e }) {
1660
+ let { t } = pe(), { data: n } = e, l = F(() => Gt(n.schema), [n.schema]), u = F(() => new Set(l.map((e) => e.key)), [l]), m = (n.meta.validation ?? "both") !== "server", h = F(() => Object.fromEntries(l.map((e) => [e.key, sn(e, n.values)])), [l, n.values]), g = xe(m ? Xt(n.schema, h, t) : null), _ = Ft({
1661
+ defaultValues: h,
1628
1662
  mode: "onTouched",
1629
1663
  resolver: F(() => {
1630
- if (l) return async (e, t, n) => m.current ? Ht(m.current)(e, t, n) : {
1664
+ if (m) return async (e, t, n) => g.current ? Wt(g.current)(e, t, n) : {
1631
1665
  values: e,
1632
1666
  errors: {}
1633
1667
  };
1634
- }, [l])
1635
- }), g = Be({ control: h.control }) ?? p, _ = i.map((e) => Wt(e, g) ? "1" : "0").join("");
1636
- _e(() => {
1637
- l && (m.current = Kt(r.schema, g, n));
1668
+ }, [m])
1669
+ }), v = Ue({ control: _.control }) ?? h, y = l.map((e) => `${Kt(e, v) ? "1" : "0"}${Jt(e, v) ? "1" : "0"}`).join("");
1670
+ ye(() => {
1671
+ m && (g.current = Xt(n.schema, v, t));
1638
1672
  }, [
1639
- l,
1640
- r.schema,
1641
- n,
1642
- _
1673
+ m,
1674
+ n.schema,
1675
+ t,
1676
+ y
1643
1677
  ]);
1644
- let [v, y] = be(!1), [b, x] = be(null);
1645
- _e(() => {
1646
- if (Object.keys(r.errors).length > 0) for (let [e, t] of Object.entries(r.errors)) h.setError(e, {
1678
+ let [b, x] = Se(!1), [S, C] = Se(null), [w, T] = Se({}), E = JSON.stringify(n.values), D = xe(!0);
1679
+ ye(() => {
1680
+ if (D.current) {
1681
+ D.current = !1;
1682
+ return;
1683
+ }
1684
+ _.reset(h);
1685
+ for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
1647
1686
  type: "server",
1648
- message: oe(t, n)
1687
+ message: M(r, t)
1649
1688
  });
1650
- }, [JSON.stringify(r.errors)]);
1651
- let { isDirty: S, isSubmitting: C } = h.formState;
1652
- _e(() => {
1653
- if (!S) return;
1689
+ }, [E]), ye(() => {
1690
+ if (Object.keys(n.errors).length > 0) for (let [e, r] of Object.entries(n.errors)) u.has(e) && _.setError(e, {
1691
+ type: "server",
1692
+ message: M(r, t)
1693
+ });
1694
+ }, [JSON.stringify(n.errors)]);
1695
+ let { isDirty: O, isSubmitting: k } = _.formState;
1696
+ ye(() => {
1697
+ if (!O) return;
1654
1698
  let e = (e) => {
1655
1699
  e.preventDefault();
1656
1700
  };
1657
1701
  return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
1658
- }, [S]);
1659
- let ee = ge((e, t) => {
1660
- h.setValue(e, t, {
1702
+ }, [O]);
1703
+ let A = ve((e, t) => {
1704
+ _.setValue(e, t, {
1661
1705
  shouldDirty: !0,
1662
- shouldValidate: h.formState.isSubmitted
1663
- }), h.clearErrors(e);
1664
- }, [h]), w = ge((e) => {
1665
- let t = i.filter((t) => Wt(t, e)), a = Object.fromEntries(t.map((t) => [t.key, e[t.key]])), o = Object.values(a).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
1666
- xe[r.method === "put" ? "put" : r.method === "patch" ? "patch" : "post"](r.action, a, {
1667
- forceFormData: o,
1706
+ shouldValidate: _.formState.isSubmitted
1707
+ }), _.clearErrors(e);
1708
+ }, [_]), j = ve((e) => {
1709
+ T({});
1710
+ let r = l.filter((t) => Kt(t, e)), i = Object.fromEntries(r.map((t) => [t.key, e[t.key]])), a = Object.values(i).some((e) => e instanceof File || Array.isArray(e) && e.some((e) => e instanceof File));
1711
+ Ce[n.method === "put" ? "put" : n.method === "patch" ? "patch" : "post"](n.action, i, {
1712
+ forceFormData: a,
1668
1713
  onProgress: (e) => {
1669
- e && typeof e.percentage == "number" && x(Math.round(e.percentage));
1714
+ e && typeof e.percentage == "number" && C(Math.round(e.percentage));
1670
1715
  },
1671
1716
  onError: (e) => {
1672
- for (let [t, r] of Object.entries(e)) h.setError(t, {
1717
+ let n = {};
1718
+ for (let [r, i] of Object.entries(e)) u.has(r) ? _.setError(r, {
1673
1719
  type: "server",
1674
- message: oe(r, n)
1675
- });
1720
+ message: M(i, t)
1721
+ }) : n[r] = i;
1722
+ Object.keys(n).length > 0 && T((e) => ({
1723
+ ...e,
1724
+ ...n
1725
+ }));
1676
1726
  },
1677
- onFinish: () => x(null)
1727
+ onFinish: () => C(null)
1678
1728
  });
1679
1729
  }, [
1680
- i,
1681
- r,
1682
- h,
1683
- n
1684
- ]), T = ge(() => {
1685
- S ? y(!0) : r.meta.cancelHref ? xe.visit(r.meta.cancelHref) : window.history.back();
1686
- }, [S, r.meta.cancelHref]), E = F(() => {
1730
+ l,
1731
+ n,
1732
+ _,
1733
+ t,
1734
+ u
1735
+ ]), ee = ve(() => {
1736
+ O ? x(!0) : n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
1737
+ }, [O, n.meta.cancelHref]), te = F(() => {
1687
1738
  let e = {};
1688
- for (let [t, n] of Object.entries(h.formState.errors)) n?.message && (e[t] = n.message);
1739
+ for (let [t, n] of Object.entries(_.formState.errors)) n?.message && (e[t] = n.message);
1689
1740
  return e;
1690
- }, [h.formState.errors]);
1691
- return i.filter((e) => Wt(e, g)).length === 0 && r.schema.length === 0 ? /* @__PURE__ */ I(a, {
1741
+ }, [_.formState.errors]), ne = F(() => {
1742
+ let e = /* @__PURE__ */ new Map(), r = (n) => {
1743
+ for (let [r, i] of Object.entries(n)) {
1744
+ if (u.has(r)) continue;
1745
+ let n = M(i, t);
1746
+ n && e.set(r, n);
1747
+ }
1748
+ };
1749
+ return r(n.errors), r(w), Array.from(e, ([e, t]) => ({
1750
+ key: e,
1751
+ message: t
1752
+ }));
1753
+ }, [
1754
+ n.errors,
1755
+ w,
1756
+ u,
1757
+ t
1758
+ ]);
1759
+ return l.filter((e) => Kt(e, v)).length === 0 && n.schema.length === 0 ? /* @__PURE__ */ I(r, {
1692
1760
  variant: "inline",
1693
- title: n("middag.ui.form.no_fields")
1694
- }) : /* @__PURE__ */ L(Se, { children: [/* @__PURE__ */ L("form", {
1695
- onSubmit: h.handleSubmit(w),
1761
+ title: t("middag.ui.form.no_fields")
1762
+ }) : /* @__PURE__ */ L(we, { children: [/* @__PURE__ */ L("form", {
1763
+ onSubmit: _.handleSubmit(j),
1696
1764
  className: "mx-auto max-w-[720px] space-y-6",
1697
1765
  noValidate: !0,
1698
1766
  role: "form",
1699
- "aria-label": c(e.title, n) || n("middag.ui.form.default_title"),
1700
- children: [/* @__PURE__ */ I(nn, {
1701
- nodes: r.schema,
1702
- values: g,
1703
- errors: E,
1704
- onChange: ee
1705
- }), /* @__PURE__ */ L("div", {
1706
- className: "flex gap-3 pt-4",
1707
- children: [/* @__PURE__ */ I(fe, {
1708
- type: "submit",
1709
- disabled: C,
1710
- "aria-disabled": C,
1711
- "aria-busy": C,
1712
- children: C ? b === null ? n("middag.ui.form.saving") : `${n("middag.ui.form.saving")} ${b}%` : r.meta.submitLabel ?? n("middag.ui.form.save")
1713
- }), /* @__PURE__ */ I(fe, {
1714
- type: "button",
1715
- variant: "outline",
1716
- onClick: T,
1717
- children: r.meta.cancelLabel ?? n("middag.ui.cancel")
1718
- })]
1719
- })]
1720
- }), /* @__PURE__ */ I(t, {
1721
- open: v,
1722
- onOpenChange: y,
1723
- children: /* @__PURE__ */ L(d, { children: [/* @__PURE__ */ L(f, { children: [/* @__PURE__ */ I(o, { children: n("middag.ui.form.dirty_title") }), /* @__PURE__ */ I(s, { children: n("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(fe, {
1767
+ "aria-label": c(e.title, t) || t("middag.ui.form.default_title"),
1768
+ children: [
1769
+ ne.length > 0 && /* @__PURE__ */ L(de, {
1770
+ variant: "destructive",
1771
+ children: [/* @__PURE__ */ I(a, { children: t("middag.ui.form.errors_title") }), /* @__PURE__ */ I(d, { children: /* @__PURE__ */ I("ul", {
1772
+ className: "list-disc ps-4",
1773
+ children: ne.map((e) => /* @__PURE__ */ I("li", { children: e.message }, e.key))
1774
+ }) })]
1775
+ }),
1776
+ /* @__PURE__ */ I(ln, {
1777
+ nodes: n.schema,
1778
+ values: v,
1779
+ errors: te,
1780
+ onChange: A,
1781
+ sourceValues: v
1782
+ }),
1783
+ /* @__PURE__ */ L("div", {
1784
+ className: "flex gap-3 pt-4",
1785
+ children: [/* @__PURE__ */ I(fe, {
1786
+ type: "submit",
1787
+ disabled: k,
1788
+ "aria-disabled": k,
1789
+ "aria-busy": k,
1790
+ children: k ? S === null ? t("middag.ui.form.saving") : `${t("middag.ui.form.saving")} ${S}%` : n.meta.submitLabel ?? t("middag.ui.form.save")
1791
+ }), /* @__PURE__ */ I(fe, {
1792
+ type: "button",
1793
+ variant: "outline",
1794
+ onClick: ee,
1795
+ children: n.meta.cancelLabel ?? t("middag.ui.cancel")
1796
+ })]
1797
+ })
1798
+ ]
1799
+ }), /* @__PURE__ */ I(f, {
1800
+ open: b,
1801
+ onOpenChange: x,
1802
+ children: /* @__PURE__ */ L(i, { children: [/* @__PURE__ */ L(o, { children: [/* @__PURE__ */ I(p, { children: t("middag.ui.form.dirty_title") }), /* @__PURE__ */ I(s, { children: t("middag.ui.form.dirty_message") })] }), /* @__PURE__ */ L(re, { children: [/* @__PURE__ */ I(fe, {
1724
1803
  variant: "outline",
1725
- onClick: () => y(!1),
1726
- children: n("middag.ui.cancel")
1804
+ onClick: () => x(!1),
1805
+ children: t("middag.ui.cancel")
1727
1806
  }), /* @__PURE__ */ I(fe, {
1728
1807
  variant: "destructive",
1729
1808
  onClick: () => {
1730
- y(!1), r.meta.cancelHref ? xe.visit(r.meta.cancelHref) : window.history.back();
1809
+ x(!1), n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
1731
1810
  },
1732
- children: n("middag.ui.form.dirty_leave")
1811
+ children: t("middag.ui.form.dirty_leave")
1733
1812
  })] })] })
1734
1813
  })] });
1735
1814
  }
1736
1815
  //#endregion
1737
- export { rn as FormPanelBlock };
1816
+ export { un as FormPanelBlock };