@middag-io/react 0.28.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 (117) hide show
  1. package/dist-lib/{DateField-CU9qDJwH.js → DateField-CcRD2r-Z.js} +5 -5
  2. package/dist-lib/{DateRangeField-CvU7wiyr.js → DateRangeField-DKZMfKB2.js} +199 -198
  3. package/dist-lib/{DocumentField-COJZZV5_.js → DocumentField-DjnK9T7o.js} +3 -3
  4. package/dist-lib/FormPanelBlock-BW2oi2_O.js +1816 -0
  5. package/dist-lib/{MarkdownContent-DZf86c3J.js → MarkdownContent-C-X2QGA2.js} +18 -17
  6. package/dist-lib/MarkdownContent-D5FIjx_W.js +2 -0
  7. package/dist-lib/{PhoneField-fFUyYj--.js → PhoneField-D_djeYhK.js} +80 -75
  8. package/dist-lib/app/providers/index.d.ts +2 -4
  9. package/dist-lib/app/providers/index.d.ts.map +1 -1
  10. package/dist-lib/app/providers/inertia-error-reporter.d.ts.map +1 -1
  11. package/dist-lib/base/blocks/ActionGridBlock.d.ts.map +1 -1
  12. package/dist-lib/base/blocks/ActivityTimelineBlock.d.ts.map +1 -1
  13. package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
  14. package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
  15. package/dist-lib/base/blocks/DetailPanelBlock.d.ts.map +1 -1
  16. package/dist-lib/base/blocks/EmptyStateBlock.d.ts.map +1 -1
  17. package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
  18. package/dist-lib/base/blocks/MarkdownPanelBlock.d.ts.map +1 -1
  19. package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
  20. package/dist-lib/base/blocks/StatusStripBlock.d.ts.map +1 -1
  21. package/dist-lib/base/blocks/TabbedPanelBlock.d.ts.map +1 -1
  22. package/dist-lib/base/blocks/WorkflowProgressBlock.d.ts.map +1 -1
  23. package/dist-lib/base/form/FormField.d.ts +2 -1
  24. package/dist-lib/base/form/FormField.d.ts.map +1 -1
  25. package/dist-lib/base/form/fields/DateRangeField.d.ts +1 -1
  26. package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
  27. package/dist-lib/base/form/fields/FileUploadField.d.ts +2 -2
  28. package/dist-lib/base/form/fields/FileUploadField.d.ts.map +1 -1
  29. package/dist-lib/base/form/fields/MultiSelectField.d.ts.map +1 -1
  30. package/dist-lib/base/form/fields/NativeSelectField.d.ts.map +1 -1
  31. package/dist-lib/base/form/fields/RatingField.d.ts +1 -1
  32. package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
  33. package/dist-lib/base/form/fields/SlugField.d.ts.map +1 -1
  34. package/dist-lib/base/form/form-schema-builder.d.ts +2 -1
  35. package/dist-lib/base/form/form-schema-builder.d.ts.map +1 -1
  36. package/dist-lib/base/form/form-utils.d.ts +15 -0
  37. package/dist-lib/base/form/form-utils.d.ts.map +1 -1
  38. package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
  39. package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
  40. package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
  41. package/dist-lib/base/partials/FormSection/index.d.ts.map +1 -1
  42. package/dist-lib/base/partials/StatusBar/index.d.ts.map +1 -1
  43. package/dist-lib/base/partials/StatusIndicator/index.d.ts.map +1 -1
  44. package/dist-lib/base/shell/BasicShell.d.ts.map +1 -1
  45. package/dist-lib/base/shell/ImmersiveShell.d.ts.map +1 -1
  46. package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
  47. package/dist-lib/base/utils/time.d.ts.map +1 -1
  48. package/dist-lib/{button-Ba1PcsOx.js → button-Bm0X9WO5.js} +1 -1
  49. package/dist-lib/{calendar-DnlbmjNu.js → calendar-CucaItjm.js} +51 -50
  50. package/dist-lib/{chevron-right-Casn6MFU.js → chevron-right-DY3SdwdB.js} +1 -1
  51. package/dist-lib/chunk-DeC0fbbY.js +22 -0
  52. package/dist-lib/{combobox-BbYGWCFO.js → combobox-yfHHEi6f.js} +1518 -1602
  53. package/dist-lib/components/reui/data-grid/data-grid-table-virtual.d.ts.map +1 -1
  54. package/dist-lib/contracts/block-data/actions.d.ts +2 -1
  55. package/dist-lib/contracts/block-data/actions.d.ts.map +1 -1
  56. package/dist-lib/contracts/block-data/form.d.ts +74 -194
  57. package/dist-lib/contracts/block-data/form.d.ts.map +1 -1
  58. package/dist-lib/contracts/block-data/shared.d.ts +1 -16
  59. package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
  60. package/dist-lib/contracts/generated/contract-schema.d.ts +2 -1
  61. package/dist-lib/contracts/generated/contract-schema.d.ts.map +1 -1
  62. package/dist-lib/contracts/generated/contract-types.d.ts +239 -4
  63. package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
  64. package/dist-lib/contracts/generated/index.d.ts +1 -1
  65. package/dist-lib/contracts/page-contract-schema.d.ts +1 -0
  66. package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
  67. package/dist-lib/contracts/page-contract.d.ts +0 -2
  68. package/dist-lib/contracts/page-contract.d.ts.map +1 -1
  69. package/dist-lib/contracts/shared-props.d.ts +4 -0
  70. package/dist-lib/contracts/shared-props.d.ts.map +1 -1
  71. package/dist-lib/{dist-B-MyAb3x.js → dist-B7gC4peV.js} +1 -1
  72. package/dist-lib/{dist-7c0PXlrb.js → dist-Bbnbom8g.js} +2 -2
  73. package/dist-lib/{dist-DuO9WodV.js → dist-DdgpZG8v.js} +3 -3
  74. package/dist-lib/{document-validation-YgxIqb8k.js → document-validation-DX0fB9cu.js} +2 -2
  75. package/dist-lib/i18n/I18nProvider.d.ts +15 -0
  76. package/dist-lib/i18n/I18nProvider.d.ts.map +1 -0
  77. package/dist-lib/i18n/host-resolver.d.ts +11 -0
  78. package/dist-lib/i18n/host-resolver.d.ts.map +1 -0
  79. package/dist-lib/i18n/instance.d.ts +13 -0
  80. package/dist-lib/i18n/instance.d.ts.map +1 -0
  81. package/dist-lib/i18n/register-strings.d.ts +4 -0
  82. package/dist-lib/i18n/register-strings.d.ts.map +1 -0
  83. package/dist-lib/i18n/render-label.d.ts +14 -0
  84. package/dist-lib/i18n/render-label.d.ts.map +1 -0
  85. package/dist-lib/i18n/resolve-field-error.d.ts +9 -0
  86. package/dist-lib/i18n/resolve-field-error.d.ts.map +1 -0
  87. package/dist-lib/i18n/useHostString.d.ts +2 -0
  88. package/dist-lib/i18n/useHostString.d.ts.map +1 -0
  89. package/dist-lib/i18n/useTranslation.d.ts +12 -0
  90. package/dist-lib/i18n/useTranslation.d.ts.map +1 -0
  91. package/dist-lib/index.d.ts +9 -4
  92. package/dist-lib/index.d.ts.map +1 -1
  93. package/dist-lib/{input-CdUVNe54.js → input-BC9whKEm.js} +1 -1
  94. package/dist-lib/middag-react.css +1 -1
  95. package/dist-lib/middag-react.js +5961 -3980
  96. package/dist-lib/{popover-Bxsp1hlN.js → popover-BaiQ-JSz.js} +29 -29
  97. package/dist-lib/{FormSection-B6Tcbwrf.js → resolve-field-error-dbUy6DeX.js} +2172 -2076
  98. package/dist-lib/{scroll-area-B9TZ05bl.js → scroll-area-D94_a2-1.js} +57 -57
  99. package/dist-lib/{skeleton-HpnbVVji.js → skeleton-xL_Hzxj-.js} +1 -1
  100. package/dist-lib/{use-mobile-Kp3Dy8mh.js → use-mobile-CBJJLRL8.js} +36 -36
  101. package/dist-lib/useTranslation-BuyMWJ9T.js +321 -0
  102. package/dist-lib/{utils-Yj2czlvU.js → utils-CpaZ5_iF.js} +517 -538
  103. package/package.json +2 -1
  104. package/dist-lib/FormPanelBlock-Cd_uiDze.js +0 -1736
  105. package/dist-lib/MarkdownContent-BeNHDP09.js +0 -2
  106. package/dist-lib/app/providers/i18n-defaults.d.ts +0 -19
  107. package/dist-lib/app/providers/i18n-defaults.d.ts.map +0 -1
  108. package/dist-lib/app/providers/i18n.d.ts +0 -55
  109. package/dist-lib/app/providers/i18n.d.ts.map +0 -1
  110. package/dist-lib/app/providers/locales/pt-BR.d.ts +0 -15
  111. package/dist-lib/app/providers/locales/pt-BR.d.ts.map +0 -1
  112. package/dist-lib/i18n-D5Nt1tut.js +0 -326
  113. package/dist-lib/lib/i18n/render-label.d.ts +0 -31
  114. package/dist-lib/lib/i18n/render-label.d.ts.map +0 -1
  115. /package/dist-lib/{dist-CmB86BdM.js → dist-3F0-lo64.js} +0 -0
  116. /package/dist-lib/{dist-axU0pUop.js → dist-DdfRh_k3.js} +0 -0
  117. /package/dist-lib/{floating-ui.react-dom-BnOzLaz1.js → floating-ui.react-dom-CNntavPo.js} +0 -0
@@ -0,0 +1,1816 @@
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";
9
+ //#region node_modules/react-hook-form/dist/index.esm.mjs
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) => {
11
+ let t = e.constructor && e.constructor.prototype;
12
+ return B(t) && t.hasOwnProperty("isPrototypeOf");
13
+ }, Ae = typeof window < "u" && window.HTMLElement !== void 0 && typeof document < "u";
14
+ function V(e) {
15
+ if (e instanceof Date) return new Date(e);
16
+ let t = typeof FileList < "u" && e instanceof FileList;
17
+ if (Ae && (e instanceof Blob || t)) return e;
18
+ let n = Array.isArray(e);
19
+ if (!n && !(B(e) && ke(e))) return e;
20
+ let r = n ? [] : Object.create(Object.getPrototypeOf(e));
21
+ for (let t in e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = V(e[t]));
22
+ return r;
23
+ }
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) => {
25
+ if (!t || !B(e)) return n;
26
+ let r = (je(t) ? [t] : Ne(t)).reduce((e, t) => z(e) ? void 0 : e[t], e);
27
+ return H(r) || r === e ? H(e[t]) ? n : e[t] : r;
28
+ }, W = (e) => typeof e == "boolean", G = (e) => typeof e == "function", K = (e, t, n) => {
29
+ let r = -1, i = je(t) ? [t] : Ne(t), a = i.length, o = a - 1;
30
+ for (; ++r < a;) {
31
+ let t = i[r], a = n;
32
+ if (r !== o) {
33
+ let n = e[t];
34
+ a = B(n) || Array.isArray(n) ? n : isNaN(+i[r + 1]) ? {} : [];
35
+ }
36
+ if (t === "__proto__" || t === "constructor" || t === "prototype") return;
37
+ e[t] = a, e = e[t];
38
+ }
39
+ }, Pe = {
40
+ BLUR: "blur",
41
+ FOCUS_OUT: "focusout",
42
+ CHANGE: "change",
43
+ SUBMIT: "submit",
44
+ TRIGGER: "trigger",
45
+ VALID: "valid"
46
+ }, q = {
47
+ onBlur: "onBlur",
48
+ onChange: "onChange",
49
+ onSubmit: "onSubmit",
50
+ onTouched: "onTouched",
51
+ all: "all"
52
+ }, J = {
53
+ max: "max",
54
+ min: "min",
55
+ maxLength: "maxLength",
56
+ minLength: "minLength",
57
+ pattern: "pattern",
58
+ required: "required",
59
+ validate: "validate"
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) => {
63
+ let i = {};
64
+ for (let a in e) Object.defineProperty(i, a, { get: () => {
65
+ let i = a;
66
+ return t._proxyFormState[i] !== q.all && (t._proxyFormState[i] = !r || q.all), n && (n[i] = !0), e[i];
67
+ } });
68
+ return i;
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()) {
71
+ if (e === t) return !0;
72
+ if (He(e) || He(t)) return Object.is(e, t);
73
+ if (R(e) && R(t)) return Object.is(e.getTime(), t.getTime());
74
+ let r = Object.keys(e), i = Object.keys(t);
75
+ if (r.length !== i.length) return !1;
76
+ if (n.has(e) || n.has(t)) return !0;
77
+ n.add(e), n.add(t);
78
+ for (let i of r) {
79
+ let r = e[i];
80
+ if (!(i in t)) return !1;
81
+ if (i !== "ref") {
82
+ let e = t[i];
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;
84
+ }
85
+ }
86
+ return !0;
87
+ }
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);
90
+ l.current = s;
91
+ let [p, m] = P.useState(() => {
92
+ let e = n._getWatch(r, c.current);
93
+ return l.current ? l.current(e) : e;
94
+ }), h = P.useCallback((e) => {
95
+ let t = Ve(r, n._names, e || n._formValues, !1, c.current);
96
+ return l.current ? l.current(t) : t;
97
+ }, [
98
+ n._formValues,
99
+ n._names,
100
+ r
101
+ ]), g = P.useCallback((e) => {
102
+ if (!a) {
103
+ let t = Ve(r, n._names, e || n._formValues, !1, c.current);
104
+ if (l.current) {
105
+ let e = l.current(t);
106
+ X(e, u.current) || (m(e), u.current = e);
107
+ } else m(t);
108
+ }
109
+ }, [
110
+ n._formValues,
111
+ n._names,
112
+ a,
113
+ r
114
+ ]);
115
+ Be(() => ((d.current !== n || !X(f.current, r)) && (d.current = n, f.current = r, g()), n._subscribe({
116
+ name: r,
117
+ formState: { values: !0 },
118
+ exact: o,
119
+ callback: (e) => {
120
+ g(e.values);
121
+ }
122
+ })), [
123
+ n,
124
+ o,
125
+ r,
126
+ g
127
+ ]), P.useEffect(() => n._removeUnmounted());
128
+ let _ = d.current !== n, v = f.current, y = P.useMemo(() => {
129
+ if (a) return null;
130
+ let e = !_ && !X(v, r);
131
+ return _ || e ? h() : null;
132
+ }, [
133
+ a,
134
+ _,
135
+ r,
136
+ v,
137
+ h
138
+ ]);
139
+ return y === null ? p : y;
140
+ }
141
+ var We = P.createContext(null);
142
+ We.displayName = "HookFormContext";
143
+ var Ge = (e, t, n, r, i) => t ? {
144
+ ...n[e],
145
+ types: {
146
+ ...n[e] && n[e].types ? n[e].types : {},
147
+ [r]: i || !0
148
+ }
149
+ } : {}, Ke = (e) => Array.isArray(e) ? e : [e], qe = () => {
150
+ let e = [];
151
+ return {
152
+ get observers() {
153
+ return e;
154
+ },
155
+ next: (t) => {
156
+ for (let n of e) n.next && n.next(t);
157
+ },
158
+ subscribe: (t) => (e.push(t), { unsubscribe: () => {
159
+ e = e.filter((e) => e !== t);
160
+ } }),
161
+ unsubscribe: () => {
162
+ e = [];
163
+ }
164
+ };
165
+ };
166
+ function Je(e, t) {
167
+ let n = {};
168
+ for (let r in e) if (e.hasOwnProperty(r)) {
169
+ let i = e[r], a = t[r];
170
+ if (i && B(i) && a) {
171
+ let e = Je(i, a);
172
+ B(e) && (n[r] = e);
173
+ } else e[r] && (n[r] = a);
174
+ }
175
+ return n;
176
+ }
177
+ var Z = (e) => B(e) && !Object.keys(e).length, Ye = (e) => e.type === "file", Xe = (e) => {
178
+ if (!Ae) return !1;
179
+ let t = e ? e.ownerDocument : 0;
180
+ return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
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) {
183
+ let n = t.slice(0, -1).length, r = 0;
184
+ for (; r < n;) {
185
+ if (z(e)) {
186
+ e = void 0;
187
+ break;
188
+ }
189
+ e = e[t[r]], r++;
190
+ }
191
+ return e;
192
+ }
193
+ function nt(e) {
194
+ for (let t in e) if (e.hasOwnProperty(t) && !H(e[t])) return !1;
195
+ return !0;
196
+ }
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;
201
+ }
202
+ var rt = (e) => {
203
+ for (let t in e) if (G(e[t])) return !0;
204
+ return !1;
205
+ };
206
+ function it(e) {
207
+ return Array.isArray(e) || B(e) && !rt(e);
208
+ }
209
+ function at(e, t = {}) {
210
+ for (let n in e) {
211
+ let r = e[n];
212
+ it(r) ? (t[n] = Array.isArray(r) ? [] : {}, at(r, t[n])) : H(r) || (t[n] = !0);
213
+ }
214
+ return t;
215
+ }
216
+ function ot(e) {
217
+ if (e !== !1) {
218
+ if (e === !0) return !0;
219
+ if (Array.isArray(e)) {
220
+ let t = e.map((e) => ot(e));
221
+ return t.some((e) => e !== void 0) ? t : void 0;
222
+ }
223
+ if (B(e)) {
224
+ let t = {};
225
+ for (let n in e) {
226
+ let r = ot(e[n]);
227
+ H(r) || (t[n] = r);
228
+ }
229
+ return Object.keys(t).length ? t : void 0;
230
+ }
231
+ }
232
+ }
233
+ function st(e, t, n) {
234
+ n ||= at(t);
235
+ for (let r in e) {
236
+ let i = e[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]);
238
+ else {
239
+ let e = t[r];
240
+ n[r] = !X(i, e);
241
+ }
242
+ }
243
+ return ot(n) || {};
244
+ }
245
+ var ct = {
246
+ value: !1,
247
+ isValid: !1
248
+ }, lt = {
249
+ value: !0,
250
+ isValid: !0
251
+ }, ut = (e) => {
252
+ if (Array.isArray(e)) {
253
+ if (e.length > 1) {
254
+ let t = e.filter((e) => e && e.checked && !e.disabled).map((e) => e.value);
255
+ return {
256
+ value: t,
257
+ isValid: !!t.length
258
+ };
259
+ }
260
+ return e[0].checked && !e[0].disabled ? e[0].attributes && !H(e[0].attributes.value) ? H(e[0].value) || e[0].value === "" ? lt : {
261
+ value: e[0].value,
262
+ isValid: !0
263
+ } : lt : ct;
264
+ }
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 = {
267
+ isValid: !1,
268
+ value: null
269
+ }, pt = (e) => Array.isArray(e) ? e.reduce((e, t) => t && t.checked && !t.disabled ? {
270
+ isValid: !0,
271
+ value: t.value
272
+ } : e, ft) : ft;
273
+ function mt(e) {
274
+ let t = e.ref;
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);
276
+ }
277
+ var ht = (e, t, n, r) => {
278
+ let i = {};
279
+ for (let n of e) {
280
+ let e = U(t, n);
281
+ e && K(i, n, e._f);
282
+ }
283
+ return {
284
+ criteriaMode: n,
285
+ names: [...e],
286
+ fields: i,
287
+ shouldUseNativeValidation: r
288
+ };
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) => {
296
+ for (let i of n || Object.keys(e)) {
297
+ let n = U(e, i);
298
+ if (n) {
299
+ let { _f: e, ...a } = n;
300
+ if (e) {
301
+ if (e.refs && e.refs[0] && t(e.refs[0], i) && !r || e.ref && t(e.ref, e.name) && !r) return !0;
302
+ if (Ct(a, t)) break;
303
+ } else if (B(a) && Ct(a, t)) break;
304
+ }
305
+ }
306
+ };
307
+ function wt(e, t, n) {
308
+ let r = U(e, n);
309
+ if (r || je(n)) return {
310
+ error: r,
311
+ name: n
312
+ };
313
+ let i = n.split(".");
314
+ for (; i.length;) {
315
+ let r = i.join("."), a = U(t, r), o = U(e, r);
316
+ if (a && !Array.isArray(a) && n !== r) return { name: n };
317
+ if (o && o.type) return {
318
+ name: r,
319
+ error: o
320
+ };
321
+ if (o && o.root && o.root.type) return {
322
+ name: `${r}.root`,
323
+ error: o.root
324
+ };
325
+ i.pop();
326
+ }
327
+ return { name: n };
328
+ }
329
+ var Tt = (e, t, n, r) => {
330
+ n(e);
331
+ let { name: i, ...a } = 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;
336
+ };
337
+ function At(e, t, n = "validate") {
338
+ if (Y(e) || Array.isArray(e) && e.every(Y) || W(e) && !e) return {
339
+ type: n,
340
+ message: Y(e) ? e : "",
341
+ ref: t
342
+ };
343
+ }
344
+ var $ = (e) => B(e) && !gt(e) ? e : {
345
+ value: e,
346
+ message: ""
347
+ }, jt = async (e, t, n, r, i, a) => {
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);
349
+ if (!_ || t.has(h)) return {};
350
+ let y = s ? s[0] : o, b = (e) => {
351
+ i && y.reportValidity && (y.setCustomValidity(W(e) ? "" : e || ""), y.reportValidity());
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) => {
353
+ let a = e ? t : n;
354
+ x[h] = {
355
+ type: e ? r : i,
356
+ message: a,
357
+ ref: o,
358
+ ...E(e ? r : i, a)
359
+ };
360
+ };
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) ? {
363
+ value: !!c,
364
+ message: c
365
+ } : $(c);
366
+ if (e && (x[h] = {
367
+ type: J.required,
368
+ message: t,
369
+ ref: y,
370
+ ...E(J.required, t)
371
+ }, !r)) return b(t), x;
372
+ }
373
+ if (!T && (!z(d) || !z(f))) {
374
+ let e, t, n = $(f), i = $(d);
375
+ if (!z(v) && !isNaN(v)) {
376
+ let r = o.valueAsNumber || v && +v;
377
+ z(n.value) || (e = r > n.value), z(i.value) || (t = r < i.value);
378
+ } else {
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";
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));
381
+ }
382
+ if ((e || t) && (D(!!e, n.message, i.message, J.max, J.min), !r)) return b(x[h].message), x;
383
+ }
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;
387
+ }
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,
392
+ message: t,
393
+ ref: o,
394
+ ...E(J.pattern, t)
395
+ }, !r)) return b(t), x;
396
+ }
397
+ if (m) {
398
+ if (G(m)) {
399
+ let e = At(await m(v, n), y);
400
+ if (e && (x[h] = {
401
+ ...e,
402
+ ...E(J.validate, e.message)
403
+ }, !r)) return b(e.message), x;
404
+ } else if (B(m)) {
405
+ let e = {};
406
+ for (let t in m) {
407
+ if (!Z(e) && !r) break;
408
+ let i = At(await m[t](v, n), y, t);
409
+ i && (e = {
410
+ ...i,
411
+ ...E(t, i.message)
412
+ }, b(i.message), r && (x[h] = e));
413
+ }
414
+ if (!Z(e) && (x[h] = {
415
+ ref: y,
416
+ ...e
417
+ }, !r)) return x;
418
+ }
419
+ }
420
+ return b(!0), x;
421
+ }, Mt = {
422
+ mode: q.onSubmit,
423
+ reValidateMode: q.onChange,
424
+ shouldFocusError: !0
425
+ }, Nt = {
426
+ submitCount: 0,
427
+ isDirty: !1,
428
+ isReady: !1,
429
+ isValidating: !1,
430
+ isSubmitted: !1,
431
+ isSubmitting: !1,
432
+ isSubmitSuccessful: !1,
433
+ isValid: !1,
434
+ touchedFields: {},
435
+ dirtyFields: {},
436
+ validatingFields: {}
437
+ };
438
+ function Pt(e = {}) {
439
+ let t = {
440
+ ...Mt,
441
+ ...e
442
+ }, n = {
443
+ ...V(Nt),
444
+ isLoading: G(t.defaultValues),
445
+ errors: t.errors || {},
446
+ disabled: t.disabled || !1
447
+ }, r = {}, i = (B(t.defaultValues) || B(t.values)) && V(t.defaultValues || t.values) || {}, a = t.shouldUnregister ? {} : V(i), o = {
448
+ action: !1,
449
+ mount: !1,
450
+ watch: !1,
451
+ keepIsValid: !1
452
+ }, s = {
453
+ mount: /* @__PURE__ */ new Set(),
454
+ disabled: /* @__PURE__ */ new Set(),
455
+ unMount: /* @__PURE__ */ new Set(),
456
+ array: /* @__PURE__ */ new Set(),
457
+ watch: /* @__PURE__ */ new Set(),
458
+ registerName: /* @__PURE__ */ new Set()
459
+ }, c, l = 0, u = {
460
+ isDirty: !1,
461
+ dirtyFields: !1,
462
+ validatingFields: !1,
463
+ touchedFields: !1,
464
+ isValidating: !1,
465
+ isValid: !1,
466
+ errors: !1
467
+ }, d = { ...u }, f = { ...d }, p = {
468
+ array: qe(),
469
+ state: qe()
470
+ }, m = t.criteriaMode === q.all, h = (e) => (t) => {
471
+ clearTimeout(l), l = setTimeout(e, t);
472
+ }, g = async (e) => {
473
+ if (!o.keepIsValid && !t.disabled && (d.isValid || f.isValid || e)) {
474
+ let e;
475
+ t.resolver ? (e = Z((await T()).errors), _()) : e = await O({
476
+ fields: r,
477
+ onlyCheckValid: !0,
478
+ eventType: Pe.VALID
479
+ }), e !== n.isValid && p.state.next({ isValid: e });
480
+ }
481
+ }, _ = (e, r) => {
482
+ !t.disabled && (d.isValidating || d.validatingFields || f.isValidating || f.validatingFields) && ((e || Array.from(s.mount)).forEach((e) => {
483
+ e && (r ? K(n.validatingFields, e, r) : Q(n.validatingFields, e));
484
+ }), p.state.next({
485
+ validatingFields: n.validatingFields,
486
+ isValidating: !Z(n.validatingFields)
487
+ }));
488
+ }, v = () => {
489
+ n.dirtyFields = st(i, a);
490
+ }, y = (e, i = [], s, c, l = !0, u = !0) => {
491
+ if (c && s && !t.disabled) {
492
+ if (o.action = !0, u && Array.isArray(U(r, e))) {
493
+ let t = s(U(r, e), c.argA, c.argB);
494
+ l && K(r, e, t);
495
+ }
496
+ if (u && Array.isArray(U(n.errors, e))) {
497
+ let t = s(U(n.errors, e), c.argA, c.argB);
498
+ l && K(n.errors, e, t), Ot(n.errors, e);
499
+ }
500
+ if ((d.touchedFields || f.touchedFields) && u && Array.isArray(U(n.touchedFields, e))) {
501
+ let t = s(U(n.touchedFields, e), c.argA, c.argB);
502
+ l && K(n.touchedFields, e, t);
503
+ }
504
+ (d.dirtyFields || f.dirtyFields) && v(), p.state.next({
505
+ name: e,
506
+ isDirty: A(e, i),
507
+ dirtyFields: n.dirtyFields,
508
+ errors: n.errors,
509
+ isValid: n.isValid
510
+ });
511
+ } else K(a, e, i);
512
+ }, b = (e, t) => {
513
+ K(n.errors, e, t), p.state.next({ errors: n.errors });
514
+ }, x = (e) => {
515
+ n.errors = e, p.state.next({
516
+ errors: n.errors,
517
+ isValid: !1
518
+ });
519
+ }, S = (e, t, s, c) => {
520
+ let l = U(r, e);
521
+ if (l) {
522
+ let r = H(U(a, e)), u = U(a, e, H(s) ? U(i, e) : s);
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 }))));
524
+ }
525
+ }, C = (e, r, a, o, s) => {
526
+ let c = !1, l = !1, u = { name: e };
527
+ if (!t.disabled) {
528
+ if (!a || o) {
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;
532
+ }
533
+ if (a) {
534
+ let t = U(n.touchedFields, e);
535
+ t || (K(n.touchedFields, e, a), u.touchedFields = n.touchedFields, c ||= (d.touchedFields || f.touchedFields) && t !== a);
536
+ }
537
+ c && s && p.state.next(u);
538
+ }
539
+ return c ? u : {};
540
+ }, w = (e, r, i, a) => {
541
+ let o = U(n.errors, e), s = (d.isValid || f.isValid) && W(r) && n.isValid !== r;
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) {
543
+ let t = {
544
+ ...a,
545
+ ...s && W(r) ? { isValid: r } : {},
546
+ errors: n.errors,
547
+ name: e
548
+ };
549
+ n = {
550
+ ...n,
551
+ ...t
552
+ }, p.state.next(t);
553
+ }
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);
556
+ if (_(e), e) for (let r of e) {
557
+ let e = U(t, r);
558
+ e ? K(n.errors, r, e) : Q(n.errors, r);
559
+ }
560
+ else n.errors = t;
561
+ return t;
562
+ }, D = async ({ name: t, eventType: r }) => {
563
+ if (e.validate) {
564
+ let i = await e.validate({
565
+ formValues: a,
566
+ formState: n,
567
+ name: t,
568
+ eventType: r
569
+ });
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
573
+ });
574
+ else Y(i) || !i ? le(Fe, {
575
+ message: i || "",
576
+ type: J.validate
577
+ }) : ce(Fe);
578
+ return i;
579
+ }
580
+ return !0;
581
+ }, O = async ({ fields: r, onlyCheckValid: i, name: o, eventType: c, context: l = {
582
+ valid: !0,
583
+ runRootValidation: !1
584
+ } }) => {
585
+ if (e.validate && (l.runRootValidation = !0, !await D({
586
+ name: o,
587
+ eventType: c
588
+ }) && (l.valid = !1, i))) return l.valid;
589
+ for (let o in r) {
590
+ let u = r[o];
591
+ if (u) {
592
+ let { _f: r, ...f } = u;
593
+ if (r) {
594
+ let o = s.array.has(r.name), c = u._f && bt(u._f);
595
+ c && d.validatingFields && _([r.name], !0);
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;
598
+ }
599
+ !Z(f) && await O({
600
+ context: l,
601
+ onlyCheckValid: i,
602
+ fields: f,
603
+ name: o,
604
+ eventType: c
605
+ });
606
+ }
607
+ }
608
+ return l.valid;
609
+ }, k = () => {
610
+ for (let e of s.unMount) {
611
+ let t = U(r, e);
612
+ t && (t._f.refs ? t._f.refs.every((e) => !et(e)) : !et(t._f.ref)) && pe(e);
613
+ }
614
+ s.unMount = /* @__PURE__ */ new Set();
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 = {}) => {
616
+ let i = U(r, e), o = t;
617
+ if (i) {
618
+ let n = i._f;
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) => {
620
+ (!e.defaultChecked || !e.disabled) && (Array.isArray(o) ? e.checked = !!o.find((t) => t === e.value) : e.checked = o === e.value || !!o);
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({
622
+ name: e,
623
+ values: V(a)
624
+ })));
625
+ }
626
+ (n.shouldDirty || n.shouldTouch) && C(e, o, n.shouldTouch, n.shouldDirty, !0), n.shouldValidate && oe(e);
627
+ }, ne = (e, t, n) => {
628
+ for (let i in t) {
629
+ if (!t.hasOwnProperty(i)) return;
630
+ let a = t[i], o = e + "." + i, c = U(r, o);
631
+ (s.array.has(e) || B(a) || c && !c._f) && !R(a) ? ne(o, a, n) : te(o, a, n);
632
+ }
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);
635
+ if (K(a, e, u), l) p.array.next({
636
+ name: e,
637
+ values: V(a)
638
+ }), (d.isDirty || d.dirtyFields || f.isDirty || f.dirtyFields) && i.shouldDirty && (v(), p.state.next({
639
+ name: e,
640
+ dirtyFields: n.dirtyFields,
641
+ isDirty: A(e, u)
642
+ }));
643
+ else {
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);
646
+ }
647
+ if (!m) {
648
+ let t = St(e, s);
649
+ p.state.next({
650
+ ...t && n,
651
+ name: o.mount || t ? e : void 0,
652
+ values: V(a)
653
+ });
654
+ }
655
+ }, ie = (e) => {
656
+ let t = G(e) ? e(a) : e;
657
+ X(a, t) || (a = {
658
+ ...a,
659
+ ...t
660
+ }, p.state.next({
661
+ ...n,
662
+ values: a
663
+ }));
664
+ }, ae = async (i) => {
665
+ o.mount = !0;
666
+ let l = i.target, u = l.name, h = !0, v = U(r, u), y = (e) => {
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);
669
+ if (v) {
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({
674
+ name: u,
675
+ type: i.type,
676
+ values: V(a)
677
+ }), A) return (d.isValid || f.isValid) && (t.mode === "onBlur" ? k && g() : k || g()), te && p.state.next({
678
+ name: u,
679
+ ...j ? {} : ee
680
+ });
681
+ if (!t.resolver && e.validate && await D({
682
+ name: u,
683
+ eventType: i.type
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);
689
+ }
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({
691
+ fields: r,
692
+ onlyCheckValid: !0,
693
+ name: u,
694
+ eventType: i.type
695
+ })));
696
+ h && (v._f.deps && (!Array.isArray(v._f.deps) || v._f.deps.length > 0) && oe(v._f.deps), w(u, S, o, ee));
697
+ }
698
+ }, M = (e, t) => {
699
+ if (U(n.errors, t) && e.focus) return e.focus(), 1;
700
+ }, oe = async (e, i = {}) => {
701
+ let a, o, c = Ke(e);
702
+ if (t.resolver) {
703
+ let t = await E(H(e) ? e : c);
704
+ a = Z(t), o = e ? !c.some((e) => U(t, e)) : a;
705
+ } else e ? (o = (await Promise.all(c.map(async (e) => {
706
+ let t = U(r, e);
707
+ return await O({
708
+ fields: t && t._f ? { [e]: t } : t,
709
+ eventType: Pe.TRIGGER
710
+ });
711
+ }))).every(Boolean), !(!o && !n.isValid) && g()) : o = a = await O({
712
+ fields: r,
713
+ name: e,
714
+ eventType: Pe.TRIGGER
715
+ });
716
+ return p.state.next({
717
+ ...!Y(e) || (d.isValid || f.isValid) && a !== n.isValid ? {} : { name: e },
718
+ ...t.resolver || !e ? { isValid: a } : {},
719
+ errors: n.errors
720
+ }), i.shouldFocus && !o && Ct(r, M, e ? c : s.mount), o;
721
+ }, se = (e, t) => {
722
+ let r = { ...o.mount ? a : i };
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) => ({
725
+ invalid: !!U((t || n).errors, e),
726
+ isDirty: !!U((t || n).dirtyFields, e),
727
+ error: U((t || n).errors, e),
728
+ isValidating: !!U(n.validatingFields, e),
729
+ isTouched: !!U((t || n).touchedFields, e)
730
+ }), ce = (e) => {
731
+ let t = e ? Ke(e) : void 0;
732
+ t?.forEach((e) => Q(n.errors, e)), t ? t.forEach((e) => {
733
+ p.state.next({
734
+ name: e,
735
+ errors: n.errors
736
+ });
737
+ }) : p.state.next({ errors: {} });
738
+ }, le = (e, t, i) => {
739
+ let a = (U(r, e, { _f: {} })._f || {}).ref, { ref: o, message: s, type: c, ...l } = U(n.errors, e) || {};
740
+ K(n.errors, e, {
741
+ ...l,
742
+ ...t,
743
+ ref: a
744
+ }), p.state.next({
745
+ name: e,
746
+ errors: n.errors,
747
+ isValid: !1
748
+ }), i && i.shouldFocus && a && a.focus && a.focus();
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)) {
751
+ let r = { ...a };
752
+ e.callback({
753
+ values: r,
754
+ ...n,
755
+ ...t,
756
+ defaultValues: i
757
+ });
758
+ }
759
+ } }).unsubscribe, fe = (e) => (o.mount = !0, f = {
760
+ ...f,
761
+ ...e.formState
762
+ }, de({
763
+ ...e,
764
+ formState: {
765
+ ...u,
766
+ ...e.formState
767
+ }
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);
770
+ p.state.next({ values: V(a) }), p.state.next({
771
+ ...n,
772
+ ...o.keepDirty ? { isDirty: A() } : {}
773
+ }), !o.keepIsValid && g();
774
+ }, me = ({ disabled: e, name: t }) => {
775
+ if (W(e) && o.mount || e || s.disabled.has(t)) {
776
+ let n = s.disabled.has(t) !== !!e;
777
+ e ? s.disabled.add(t) : s.disabled.delete(t), n && o.mount && !o.action && g();
778
+ }
779
+ }, he = (e, n = {}) => {
780
+ let a = U(r, e), c = W(n.disabled) || W(t.disabled), l = !s.registerName.has(e) && a && a._f && !a._f.mount;
781
+ return K(r, e, {
782
+ ...a || {},
783
+ _f: {
784
+ ...a && a._f ? a._f : { ref: { name: e } },
785
+ name: e,
786
+ mount: !0,
787
+ ...n
788
+ }
789
+ }), s.mount.add(e), a && !l ? me({
790
+ disabled: W(n.disabled) ? n.disabled : t.disabled,
791
+ name: e
792
+ }) : S(e, !0, n.value), {
793
+ ...c ? { disabled: n.disabled || t.disabled } : {},
794
+ ...t.progressive ? {
795
+ required: !!n.required,
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)
801
+ } : {},
802
+ name: e,
803
+ onChange: ae,
804
+ onBlur: ae,
805
+ ref: (c) => {
806
+ if (c) {
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 || [];
809
+ if (o ? l.find((e) => e === t) : t === a._f.ref) return;
810
+ K(r, e, { _f: {
811
+ ...a._f,
812
+ ...o ? {
813
+ refs: [
814
+ ...l.filter(et),
815
+ t,
816
+ ...Array.isArray(U(i, e)) ? [{}] : []
817
+ ],
818
+ ref: {
819
+ type: t.type,
820
+ name: e
821
+ }
822
+ } : { ref: t }
823
+ } }), S(e, !1, void 0, t);
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);
825
+ }
826
+ };
827
+ }, P = () => t.shouldFocusError && Ct(r, M, s.mount), ge = (e) => {
828
+ W(e) && (p.state.next({ disabled: e }), Ct(r, (t, n) => {
829
+ let i = U(r, n);
830
+ i && (t.disabled = i._f.disabled || e, Array.isArray(i._f.refs) && i._f.refs.forEach((t) => {
831
+ t.disabled = i._f.disabled || e;
832
+ }));
833
+ }, 0, !1));
834
+ }, _e = (e, i) => async (o) => {
835
+ let c;
836
+ o && (o.preventDefault && o.preventDefault(), o.persist && o.persist());
837
+ let l = V(a);
838
+ if (p.state.next({ isSubmitting: !0 }), t.resolver) {
839
+ let { errors: e, values: t } = await T();
840
+ _(), n.errors = e, l = V(t);
841
+ } else await O({
842
+ fields: r,
843
+ eventType: Pe.SUBMIT
844
+ });
845
+ if (s.disabled.size) for (let e of s.disabled) Q(l, e);
846
+ if (Q(n.errors, Ie), Z(n.errors)) {
847
+ p.state.next({ errors: {} });
848
+ try {
849
+ await e(l, o);
850
+ } catch (e) {
851
+ c = e;
852
+ }
853
+ } else i && await i({ ...n.errors }, o), P(), setTimeout(P);
854
+ if (p.state.next({
855
+ isSubmitted: !0,
856
+ isSubmitting: !1,
857
+ isSubmitSuccessful: Z(n.errors) && !c,
858
+ submitCount: n.submitCount + 1,
859
+ errors: n.errors
860
+ }), c) throw c;
861
+ }, ve = (e, t = {}) => {
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;
865
+ if (c.keepDefaultValues || (i = l), !c.keepValues) {
866
+ if (c.keepDirtyValues) {
867
+ let e = new Set([...s.mount, ...Object.keys(st(i, a))]);
868
+ for (let t of Array.from(e)) {
869
+ let e = U(n.dirtyFields, t), r = U(a, t), i = U(m, t);
870
+ e && !H(r) ? K(m, t, r) : !e && !H(i) && re(t, i);
871
+ }
872
+ } else {
873
+ if (Ae && H(e)) for (let e of s.mount) {
874
+ let t = U(r, e);
875
+ if (t && t._f) {
876
+ let e = Array.isArray(t._f.refs) ? t._f.refs[0] : t._f.ref;
877
+ if (Xe(e)) {
878
+ let t = e.closest("form");
879
+ if (t) {
880
+ t.reset();
881
+ break;
882
+ }
883
+ }
884
+ }
885
+ }
886
+ if (c.keepFieldsRef) for (let e of s.mount) re(e, U(m, e));
887
+ else r = {};
888
+ }
889
+ a = t.shouldUnregister ? c.keepDefaultValues ? V(i) : {} : V(m), p.array.next({ values: { ...m } }), p.state.next({ values: { ...m } });
890
+ }
891
+ s = {
892
+ mount: c.keepDirtyValues ? s.mount : /* @__PURE__ */ new Set(),
893
+ unMount: /* @__PURE__ */ new Set(),
894
+ array: /* @__PURE__ */ new Set(),
895
+ registerName: /* @__PURE__ */ new Set(),
896
+ disabled: /* @__PURE__ */ new Set(),
897
+ watch: /* @__PURE__ */ new Set(),
898
+ watchAll: !1,
899
+ focus: ""
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({
901
+ submitCount: c.keepSubmitCount ? n.submitCount : 0,
902
+ isDirty: f ? !1 : c.keepDirty ? n.isDirty : !!(c.keepDefaultValues && !X(e, i)),
903
+ isSubmitted: c.keepIsSubmitted ? n.isSubmitted : !1,
904
+ dirtyFields: f ? {} : c.keepDirtyValues ? c.keepDefaultValues && a ? st(i, a) : n.dirtyFields : c.keepDefaultValues && e ? st(i, e) : c.keepDirty ? n.dirtyFields : {},
905
+ touchedFields: c.keepTouched ? n.touchedFields : {},
906
+ errors: c.keepErrors ? n.errors : {},
907
+ isSubmitSuccessful: c.keepIsSubmitSuccessful ? n.isSubmitSuccessful : !1,
908
+ isSubmitting: !1,
909
+ defaultValues: i
910
+ });
911
+ }, be = (e, n) => ye(G(e) ? e(a) : e, {
912
+ ...t.resetOptions,
913
+ ...n
914
+ }), F = (e, t = {}) => {
915
+ let n = U(r, e), i = n && n._f;
916
+ if (i) {
917
+ let e = i.refs ? i.refs[0] : i.ref;
918
+ e.focus && setTimeout(() => {
919
+ e.focus(), t.shouldSelect && G(e.select) && e.select();
920
+ });
921
+ }
922
+ }, xe = (e) => {
923
+ n = {
924
+ ...n,
925
+ ...e
926
+ };
927
+ }, Se = {
928
+ control: {
929
+ register: he,
930
+ unregister: pe,
931
+ getFieldState: N,
932
+ handleSubmit: _e,
933
+ setError: le,
934
+ _subscribe: de,
935
+ _runSchema: T,
936
+ _updateIsValidating: _,
937
+ _focusError: P,
938
+ _getWatch: j,
939
+ _getDirty: A,
940
+ _setValid: g,
941
+ _setFieldArray: y,
942
+ _setDisabledField: me,
943
+ _setErrors: x,
944
+ _getFieldArray: ee,
945
+ _reset: ye,
946
+ _resetDefaultValues: () => G(t.defaultValues) && t.defaultValues().then((e) => {
947
+ be(e, t.resetOptions), p.state.next({ isLoading: !1 });
948
+ }),
949
+ _removeUnmounted: k,
950
+ _disableForm: ge,
951
+ _subjects: p,
952
+ _proxyFormState: d,
953
+ get _fields() {
954
+ return r;
955
+ },
956
+ get _formValues() {
957
+ return a;
958
+ },
959
+ get _state() {
960
+ return o;
961
+ },
962
+ set _state(e) {
963
+ o = e;
964
+ },
965
+ get _defaultValues() {
966
+ return i;
967
+ },
968
+ get _names() {
969
+ return s;
970
+ },
971
+ set _names(e) {
972
+ s = e;
973
+ },
974
+ get _formState() {
975
+ return n;
976
+ },
977
+ get _options() {
978
+ return t;
979
+ },
980
+ set _options(e) {
981
+ t = {
982
+ ...t,
983
+ ...e
984
+ };
985
+ }
986
+ },
987
+ subscribe: fe,
988
+ trigger: oe,
989
+ register: he,
990
+ handleSubmit: _e,
991
+ watch: ue,
992
+ setValue: re,
993
+ setValues: ie,
994
+ getValues: se,
995
+ reset: be,
996
+ resetField: ve,
997
+ clearErrors: ce,
998
+ unregister: pe,
999
+ setError: le,
1000
+ setFocus: F,
1001
+ getFieldState: N
1002
+ };
1003
+ return {
1004
+ ...Se,
1005
+ formControl: Se
1006
+ };
1007
+ }
1008
+ function Ft(e = {}) {
1009
+ let t = P.useRef(void 0), n = P.useRef(void 0), [r, i] = P.useState(() => ({
1010
+ ...V(Nt),
1011
+ isLoading: G(e.defaultValues),
1012
+ errors: e.errors || {},
1013
+ disabled: e.disabled || !1,
1014
+ defaultValues: G(e.defaultValues) ? void 0 : e.defaultValues
1015
+ }));
1016
+ if (!t.current) if (e.formControl) t.current = {
1017
+ ...e.formControl,
1018
+ formState: r
1019
+ }, e.defaultValues && !G(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1020
+ else {
1021
+ let { formControl: n, ...i } = Pt(e);
1022
+ t.current = {
1023
+ ...i,
1024
+ formState: r
1025
+ };
1026
+ }
1027
+ let a = t.current.control;
1028
+ return a._options = e, Be(() => {
1029
+ let e = a._subscribe({
1030
+ formState: a._proxyFormState,
1031
+ callback: () => i({ ...a._formState }),
1032
+ reRenderRoot: !0
1033
+ });
1034
+ return i((e) => ({
1035
+ ...e,
1036
+ isReady: !0
1037
+ })), a._formState.isReady = !0, e;
1038
+ }, [a]), P.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), P.useEffect(() => {
1039
+ e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
1040
+ }, [
1041
+ a,
1042
+ e.mode,
1043
+ e.reValidateMode
1044
+ ]), P.useEffect(() => {
1045
+ e.errors && (a._setErrors(e.errors), a._focusError());
1046
+ }, [a, e.errors]), P.useEffect(() => {
1047
+ e.shouldUnregister && a._subjects.state.next({ values: a._getWatch() });
1048
+ }, [a, e.shouldUnregister]), P.useEffect(() => {
1049
+ if (a._proxyFormState.isDirty) {
1050
+ let e = a._getDirty();
1051
+ e !== r.isDirty && a._subjects.state.next({ isDirty: e });
1052
+ }
1053
+ }, [a, r.isDirty]), P.useEffect(() => {
1054
+ e.values && !X(e.values, n.current) ? (a._reset(e.values, {
1055
+ keepFieldsRef: !0,
1056
+ ...a._options.resetOptions
1057
+ }), a._options.resetOptions?.keepIsValid || a._setValid(), n.current = e.values, i((e) => ({ ...e }))) : a._resetDefaultValues();
1058
+ }, [a, e.values]), P.useEffect(() => {
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();
1060
+ }), t.current.formState = P.useMemo(() => ze(r, a), [a, r]), t.current;
1061
+ }
1062
+ //#endregion
1063
+ //#region node_modules/@hookform/resolvers/dist/resolvers.mjs
1064
+ var It = (e, t, n) => {
1065
+ if (e && "reportValidity" in e) {
1066
+ let r = U(n, t);
1067
+ e.setCustomValidity(r && r.message || ""), e.reportValidity();
1068
+ }
1069
+ }, Lt = (e, t) => {
1070
+ for (let n in t.fields) {
1071
+ let r = t.fields[n];
1072
+ r && r.ref && "reportValidity" in r.ref ? It(r.ref, n, e) : r && r.refs && r.refs.forEach((t) => It(t, n, e));
1073
+ }
1074
+ }, Rt = (e, t) => {
1075
+ t.shouldUseNativeValidation && Lt(e, t);
1076
+ let n = {};
1077
+ for (let r in e) {
1078
+ let i = U(t.fields, r), a = Object.assign(e[r] || {}, { ref: i && i.ref });
1079
+ if (zt(t.names || Object.keys(e), r)) {
1080
+ let e = Object.assign({}, U(n, r));
1081
+ K(e, "root", a), K(n, r, e);
1082
+ } else K(n, r, a);
1083
+ }
1084
+ return n;
1085
+ }, zt = (e, t) => {
1086
+ let n = Bt(t);
1087
+ return e.some((e) => Bt(e).match(`^${n}\\.\\d+`));
1088
+ };
1089
+ function Bt(e) {
1090
+ return e.replace(/\]|\[/g, "");
1091
+ }
1092
+ //#endregion
1093
+ //#region node_modules/@hookform/resolvers/zod/dist/zod.mjs
1094
+ function Vt(e, t) {
1095
+ try {
1096
+ var n = e();
1097
+ } catch (e) {
1098
+ return t(e);
1099
+ }
1100
+ return n && n.then ? n.then(void 0, t) : n;
1101
+ }
1102
+ function Ht(e, t) {
1103
+ for (var n = {}; e.length;) {
1104
+ var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
1105
+ if (!n[o]) if ("unionErrors" in r) {
1106
+ var s = r.unionErrors[0].errors[0];
1107
+ n[o] = {
1108
+ message: s.message,
1109
+ type: s.code
1110
+ };
1111
+ } else n[o] = {
1112
+ message: a,
1113
+ type: i
1114
+ };
1115
+ if ("unionErrors" in r && r.unionErrors.forEach(function(t) {
1116
+ return t.errors.forEach(function(t) {
1117
+ return e.push(t);
1118
+ });
1119
+ }), t) {
1120
+ var c = n[o].types, l = c && c[r.code];
1121
+ n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1122
+ }
1123
+ e.shift();
1124
+ }
1125
+ return n;
1126
+ }
1127
+ function Ut(e, t) {
1128
+ for (var n = {}; e.length;) {
1129
+ var r = e[0], i = r.code, a = r.message, o = r.path.join(".");
1130
+ if (!n[o]) if (r.code === "invalid_union" && r.errors.length > 0) {
1131
+ var s = r.errors[0][0];
1132
+ n[o] = {
1133
+ message: s.message,
1134
+ type: s.code
1135
+ };
1136
+ } else n[o] = {
1137
+ message: a,
1138
+ type: i
1139
+ };
1140
+ if (r.code === "invalid_union" && r.errors.forEach(function(t) {
1141
+ return t.forEach(function(t) {
1142
+ return e.push(t);
1143
+ });
1144
+ }), t) {
1145
+ var c = n[o].types, l = c && c[r.code];
1146
+ n[o] = Ge(o, t, n, i, l ? [].concat(l, r.message) : r.message);
1147
+ }
1148
+ e.shift();
1149
+ }
1150
+ return n;
1151
+ }
1152
+ function Wt(e, t, n) {
1153
+ if (n === void 0 && (n = {}), function(e) {
1154
+ return "_def" in e && typeof e._def == "object" && "typeName" in e._def;
1155
+ }(e)) return function(r, i, a) {
1156
+ try {
1157
+ return Promise.resolve(Vt(function() {
1158
+ return Promise.resolve(e[n.mode === "sync" ? "parse" : "parseAsync"](r, t)).then(function(e) {
1159
+ return a.shouldUseNativeValidation && Lt({}, a), {
1160
+ errors: {},
1161
+ values: n.raw ? Object.assign({}, r) : e
1162
+ };
1163
+ });
1164
+ }, function(e) {
1165
+ if (function(e) {
1166
+ return Array.isArray(e?.issues);
1167
+ }(e)) return {
1168
+ values: {},
1169
+ errors: Rt(Ht(e.errors, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1170
+ };
1171
+ throw e;
1172
+ }));
1173
+ } catch (e) {
1174
+ return Promise.reject(e);
1175
+ }
1176
+ };
1177
+ if (function(e) {
1178
+ return "_zod" in e && typeof e._zod == "object";
1179
+ }(e)) return function(r, i, a) {
1180
+ try {
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), {
1184
+ errors: {},
1185
+ values: n.raw ? Object.assign({}, r) : e
1186
+ };
1187
+ });
1188
+ }, function(e) {
1189
+ if (function(e) {
1190
+ return e instanceof l;
1191
+ }(e)) return {
1192
+ values: {},
1193
+ errors: Rt(Ut(e.issues, !a.shouldUseNativeValidation && a.criteriaMode === "all"), a)
1194
+ };
1195
+ throw e;
1196
+ }));
1197
+ } catch (e) {
1198
+ return Promise.reject(e);
1199
+ }
1200
+ };
1201
+ throw Error("Invalid input: not a Zod schema");
1202
+ }
1203
+ //#endregion
1204
+ //#region src/base/form/form-utils.ts
1205
+ function Gt(e) {
1206
+ let t = [];
1207
+ for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...Gt(n.children));
1208
+ return t;
1209
+ }
1210
+ function Kt(e, n) {
1211
+ if (e.component === "header") return !0;
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));
1224
+ }
1225
+ //#endregion
1226
+ //#region src/base/form/form-schema-builder.ts
1227
+ function Yt(e, t, n) {
1228
+ let { component: r, props: i } = e, a = i.validation, o = n;
1229
+ switch (r) {
1230
+ case "text":
1231
+ case "textarea":
1232
+ case "password":
1233
+ case "slug":
1234
+ case "color": {
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(""));
1237
+ }
1238
+ case "email": {
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(""));
1242
+ return e;
1243
+ }
1244
+ case "url": {
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(""));
1248
+ return e;
1249
+ }
1250
+ case "int": {
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();
1253
+ }
1254
+ case "float": {
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();
1257
+ }
1258
+ case "currency": {
1259
+ let e = T();
1260
+ return o ? e : e.nullable();
1261
+ }
1262
+ case "select":
1263
+ case "radio":
1264
+ case "entity_picker": {
1265
+ let e = N();
1266
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1267
+ }
1268
+ case "multiselect":
1269
+ case "tags": {
1270
+ let e = x(N());
1271
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1272
+ }
1273
+ case "checkbox":
1274
+ case "switch": return ne();
1275
+ case "date":
1276
+ case "datetime": {
1277
+ let e = N();
1278
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1279
+ }
1280
+ case "phone": {
1281
+ let e = N();
1282
+ return o ? e.min(1, t("middag.ui.validation.required")) : e;
1283
+ }
1284
+ case "document": {
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"));
1290
+ }
1291
+ default: return y();
1292
+ }
1293
+ }
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);
1298
+ }
1299
+ //#endregion
1300
+ //#region src/base/form/FormField.tsx
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" });
1304
+ }
1305
+ function nn({ label: e }) {
1306
+ return /* @__PURE__ */ I("div", {
1307
+ className: "pt-4 pb-1",
1308
+ children: /* @__PURE__ */ I("h4", {
1309
+ className: "text-foreground text-sm font-semibold",
1310
+ children: e
1311
+ })
1312
+ });
1313
+ }
1314
+ function rn({ id: e, value: t }) {
1315
+ return /* @__PURE__ */ I("input", {
1316
+ type: "hidden",
1317
+ id: e,
1318
+ value: String(t ?? "")
1319
+ });
1320
+ }
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,
1326
+ value: t
1327
+ });
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);
1329
+ return /* @__PURE__ */ L("div", {
1330
+ className: "space-y-1.5",
1331
+ children: [
1332
+ !h && /* @__PURE__ */ L(n, {
1333
+ htmlFor: c,
1334
+ children: [f.label, m && /* @__PURE__ */ I("span", {
1335
+ className: "text-destructive ml-0.5",
1336
+ children: "*"
1337
+ })]
1338
+ }),
1339
+ f.helpText && /* @__PURE__ */ I("p", {
1340
+ id: l,
1341
+ className: "text-muted-foreground text-xs",
1342
+ children: f.helpText
1343
+ }),
1344
+ g,
1345
+ i && /* @__PURE__ */ I("p", {
1346
+ id: u,
1347
+ className: "text-destructive text-xs",
1348
+ "aria-live": "polite",
1349
+ children: i
1350
+ })
1351
+ ]
1352
+ });
1353
+ }
1354
+ function on(t, n, r, i, a, o, s, c, l, d, f, p) {
1355
+ let g = {
1356
+ id: n,
1357
+ error: o,
1358
+ helpTextId: s,
1359
+ errorId: c,
1360
+ disabled: f,
1361
+ required: p
1362
+ };
1363
+ switch (t) {
1364
+ case "text": return /* @__PURE__ */ I(ie, {
1365
+ ...g,
1366
+ type: "text",
1367
+ value: r,
1368
+ onChange: i,
1369
+ placeholder: a.placeholder,
1370
+ readOnly: a.readOnly
1371
+ });
1372
+ case "email": return /* @__PURE__ */ I(ie, {
1373
+ ...g,
1374
+ type: "email",
1375
+ value: r,
1376
+ onChange: i,
1377
+ placeholder: a.placeholder,
1378
+ readOnly: a.readOnly
1379
+ });
1380
+ case "url": return /* @__PURE__ */ I(ie, {
1381
+ ...g,
1382
+ type: "url",
1383
+ value: r,
1384
+ onChange: i,
1385
+ placeholder: a.placeholder,
1386
+ readOnly: a.readOnly
1387
+ });
1388
+ case "textarea": return /* @__PURE__ */ I(E, {
1389
+ ...g,
1390
+ value: r,
1391
+ onChange: i,
1392
+ placeholder: a.placeholder,
1393
+ rows: a.rows,
1394
+ readOnly: a.readOnly
1395
+ });
1396
+ case "password": return /* @__PURE__ */ I(te, {
1397
+ ...g,
1398
+ value: r,
1399
+ onChange: i,
1400
+ placeholder: a.placeholder
1401
+ });
1402
+ case "otp": return /* @__PURE__ */ I(k, {
1403
+ ...g,
1404
+ value: r,
1405
+ onChange: i,
1406
+ maxLength: a.maxLength,
1407
+ pattern: a.pattern,
1408
+ groupSize: a.groupSize
1409
+ });
1410
+ case "select": return /* @__PURE__ */ I(oe, {
1411
+ ...g,
1412
+ value: r,
1413
+ onChange: i,
1414
+ options: a.options ?? [],
1415
+ placeholder: a.placeholder
1416
+ });
1417
+ case "native_select": return /* @__PURE__ */ I(S, {
1418
+ ...g,
1419
+ value: r,
1420
+ onChange: i,
1421
+ options: a.options ?? [],
1422
+ placeholder: a.placeholder
1423
+ });
1424
+ case "multiselect": return /* @__PURE__ */ I(m, {
1425
+ ...g,
1426
+ value: r,
1427
+ onChange: i,
1428
+ options: a.options ?? [],
1429
+ placeholder: a.placeholder
1430
+ });
1431
+ case "radio": return /* @__PURE__ */ I(b, {
1432
+ ...g,
1433
+ value: r,
1434
+ onChange: i,
1435
+ options: a.options ?? []
1436
+ });
1437
+ case "int": return /* @__PURE__ */ I(w, {
1438
+ ...g,
1439
+ value: r,
1440
+ onChange: i,
1441
+ min: a.min,
1442
+ max: a.max,
1443
+ step: 1
1444
+ });
1445
+ case "float": return /* @__PURE__ */ I(w, {
1446
+ ...g,
1447
+ value: r,
1448
+ onChange: i,
1449
+ min: a.min,
1450
+ max: a.max,
1451
+ step: a.step ?? .1
1452
+ });
1453
+ case "slider": return /* @__PURE__ */ I(O, {
1454
+ ...g,
1455
+ value: r,
1456
+ onChange: i,
1457
+ min: a.min,
1458
+ max: a.max,
1459
+ step: a.step,
1460
+ multiple: a.multiple
1461
+ });
1462
+ case "checkbox": return /* @__PURE__ */ I(u, {
1463
+ ...g,
1464
+ value: r,
1465
+ onChange: i,
1466
+ label: a.label
1467
+ });
1468
+ case "switch": return /* @__PURE__ */ I(ee, {
1469
+ ...g,
1470
+ value: r,
1471
+ onChange: i,
1472
+ label: a.label
1473
+ });
1474
+ case "date": return /* @__PURE__ */ I(ge, {
1475
+ fallback: /* @__PURE__ */ I(tn, {}),
1476
+ children: /* @__PURE__ */ I(Qt, {
1477
+ ...g,
1478
+ mode: "date",
1479
+ value: r,
1480
+ onChange: i,
1481
+ placeholder: a.placeholder
1482
+ })
1483
+ });
1484
+ case "datetime": return /* @__PURE__ */ I(ge, {
1485
+ fallback: /* @__PURE__ */ I(tn, {}),
1486
+ children: /* @__PURE__ */ I(Qt, {
1487
+ ...g,
1488
+ mode: "datetime",
1489
+ value: r,
1490
+ onChange: i,
1491
+ placeholder: a.placeholder
1492
+ })
1493
+ });
1494
+ case "file": return /* @__PURE__ */ I(se, {
1495
+ ...g,
1496
+ value: r,
1497
+ onChange: i,
1498
+ accept: a.accept,
1499
+ multiple: a.multiple,
1500
+ maxFiles: a.maxFiles,
1501
+ maxSize: a.maxSize
1502
+ });
1503
+ case "entity_picker": return /* @__PURE__ */ I(ue, {
1504
+ ...g,
1505
+ value: r,
1506
+ onChange: i,
1507
+ options: a.options,
1508
+ autocompleteHref: a.autocompleteHref,
1509
+ autocompleteMinChars: a.autocompleteMinChars,
1510
+ initialOption: a.initialOption,
1511
+ entityAvatarField: a.entityAvatarField,
1512
+ entitySubtitleField: a.entitySubtitleField,
1513
+ placeholder: a.placeholder
1514
+ });
1515
+ case "static": return /* @__PURE__ */ I(ae, {
1516
+ id: n,
1517
+ value: r
1518
+ });
1519
+ case "phone": return /* @__PURE__ */ I(ge, {
1520
+ fallback: /* @__PURE__ */ I(tn, {}),
1521
+ children: /* @__PURE__ */ I(Zt, {
1522
+ ...g,
1523
+ value: r,
1524
+ onChange: i,
1525
+ placeholder: a.placeholder,
1526
+ defaultCountry: a.defaultCountry,
1527
+ fixedCountry: a.fixedCountry
1528
+ })
1529
+ });
1530
+ case "document": return /* @__PURE__ */ I(ge, {
1531
+ fallback: /* @__PURE__ */ I(tn, {}),
1532
+ children: /* @__PURE__ */ I($t, {
1533
+ ...g,
1534
+ value: r,
1535
+ onChange: i,
1536
+ documentType: a.documentType,
1537
+ documentScope: a.documentScope,
1538
+ documentMasks: a.documentMasks,
1539
+ placeholder: a.placeholder
1540
+ })
1541
+ });
1542
+ case "currency": return /* @__PURE__ */ I(e, {
1543
+ ...g,
1544
+ value: r,
1545
+ onChange: i,
1546
+ currency: a.currency,
1547
+ placeholder: a.placeholder,
1548
+ min: a.min,
1549
+ max: a.max
1550
+ });
1551
+ case "color": return /* @__PURE__ */ I(ce, {
1552
+ ...g,
1553
+ value: r,
1554
+ onChange: i,
1555
+ placeholder: a.placeholder
1556
+ });
1557
+ case "slug": return /* @__PURE__ */ I(_, {
1558
+ ...g,
1559
+ value: r,
1560
+ onChange: i,
1561
+ sourceValue: a.sourceField === void 0 ? void 0 : String(d[a.sourceField] ?? ""),
1562
+ prefix: a.prefix,
1563
+ placeholder: a.placeholder
1564
+ });
1565
+ case "tags": return /* @__PURE__ */ I(h, {
1566
+ ...g,
1567
+ value: r,
1568
+ onChange: i,
1569
+ placeholder: a.placeholder,
1570
+ maxTags: a.maxTags
1571
+ });
1572
+ case "date_range": return /* @__PURE__ */ I(ge, {
1573
+ fallback: /* @__PURE__ */ I(tn, {}),
1574
+ children: /* @__PURE__ */ I(en, {
1575
+ ...g,
1576
+ value: r,
1577
+ onChange: i,
1578
+ operator: a.operator
1579
+ })
1580
+ });
1581
+ case "rating": return /* @__PURE__ */ I(v, {
1582
+ ...g,
1583
+ value: r,
1584
+ onChange: i,
1585
+ maxRating: a.maxRating
1586
+ });
1587
+ default: return /* @__PURE__ */ L("p", {
1588
+ className: "text-destructive text-xs",
1589
+ children: ["Unknown field component: ", t]
1590
+ });
1591
+ }
1592
+ }
1593
+ //#endregion
1594
+ //#region src/base/blocks/FormPanelBlock.tsx
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
1636
+ })
1637
+ }, e.id);
1638
+ case "group": return /* @__PURE__ */ I("div", {
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
1646
+ })
1647
+ }, e.id);
1648
+ case "header": return /* @__PURE__ */ L("div", {
1649
+ className: "space-y-2",
1650
+ children: [/* @__PURE__ */ I(D, {}), /* @__PURE__ */ I("h4", {
1651
+ className: "text-foreground text-base font-semibold",
1652
+ children: e.label
1653
+ })]
1654
+ }, `header-${a}`);
1655
+ default: return null;
1656
+ }
1657
+ }) });
1658
+ }
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,
1662
+ mode: "onTouched",
1663
+ resolver: F(() => {
1664
+ if (m) return async (e, t, n) => g.current ? Wt(g.current)(e, t, n) : {
1665
+ values: e,
1666
+ errors: {}
1667
+ };
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));
1672
+ }, [
1673
+ m,
1674
+ n.schema,
1675
+ t,
1676
+ y
1677
+ ]);
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, {
1686
+ type: "server",
1687
+ message: M(r, t)
1688
+ });
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;
1698
+ let e = (e) => {
1699
+ e.preventDefault();
1700
+ };
1701
+ return window.addEventListener("beforeunload", e), () => window.removeEventListener("beforeunload", e);
1702
+ }, [O]);
1703
+ let A = ve((e, t) => {
1704
+ _.setValue(e, t, {
1705
+ shouldDirty: !0,
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,
1713
+ onProgress: (e) => {
1714
+ e && typeof e.percentage == "number" && C(Math.round(e.percentage));
1715
+ },
1716
+ onError: (e) => {
1717
+ let n = {};
1718
+ for (let [r, i] of Object.entries(e)) u.has(r) ? _.setError(r, {
1719
+ type: "server",
1720
+ message: M(i, t)
1721
+ }) : n[r] = i;
1722
+ Object.keys(n).length > 0 && T((e) => ({
1723
+ ...e,
1724
+ ...n
1725
+ }));
1726
+ },
1727
+ onFinish: () => C(null)
1728
+ });
1729
+ }, [
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(() => {
1738
+ let e = {};
1739
+ for (let [t, n] of Object.entries(_.formState.errors)) n?.message && (e[t] = n.message);
1740
+ return e;
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, {
1760
+ variant: "inline",
1761
+ title: t("middag.ui.form.no_fields")
1762
+ }) : /* @__PURE__ */ L(we, { children: [/* @__PURE__ */ L("form", {
1763
+ onSubmit: _.handleSubmit(j),
1764
+ className: "mx-auto max-w-[720px] space-y-6",
1765
+ noValidate: !0,
1766
+ role: "form",
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, {
1803
+ variant: "outline",
1804
+ onClick: () => x(!1),
1805
+ children: t("middag.ui.cancel")
1806
+ }), /* @__PURE__ */ I(fe, {
1807
+ variant: "destructive",
1808
+ onClick: () => {
1809
+ x(!1), n.meta.cancelHref ? Ce.visit(n.meta.cancelHref) : window.history.back();
1810
+ },
1811
+ children: t("middag.ui.form.dirty_leave")
1812
+ })] })] })
1813
+ })] });
1814
+ }
1815
+ //#endregion
1816
+ export { un as FormPanelBlock };