autoforma 2.4.0 → 2.5.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.
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import V, { useMemo as Oe, createContext as Zr, useContext as Qr, useState as Kr, useEffect as Pe, useRef as et, useImperativeHandle as rt } from "react";
2
- var je = { exports: {} }, Re = {};
1
+ import k, { useMemo as he, createContext as Mt, useContext as Bt, useState as $t, useEffect as Ce, useRef as Wt, useImperativeHandle as Yt } from "react";
2
+ var De = { exports: {} }, Ae = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,29 +9,29 @@ var je = { exports: {} }, Re = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var gr;
13
- function tt() {
14
- if (gr) return Re;
15
- gr = 1;
16
- var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
17
- function r(s, o, a) {
18
- var l = null;
19
- if (a !== void 0 && (l = "" + a), o.key !== void 0 && (l = "" + o.key), "key" in o) {
20
- a = {};
21
- for (var d in o)
22
- d !== "key" && (a[d] = o[d]);
23
- } else a = o;
24
- return o = a.ref, {
12
+ var it;
13
+ function qt() {
14
+ if (it) return Ae;
15
+ it = 1;
16
+ var e = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
17
+ function t(n, o, i) {
18
+ var u = null;
19
+ if (i !== void 0 && (u = "" + i), o.key !== void 0 && (u = "" + o.key), "key" in o) {
20
+ i = {};
21
+ for (var f in o)
22
+ f !== "key" && (i[f] = o[f]);
23
+ } else i = o;
24
+ return o = i.ref, {
25
25
  $$typeof: e,
26
- type: s,
27
- key: l,
26
+ type: n,
27
+ key: u,
28
28
  ref: o !== void 0 ? o : null,
29
- props: a
29
+ props: i
30
30
  };
31
31
  }
32
- return Re.Fragment = t, Re.jsx = r, Re.jsxs = r, Re;
32
+ return Ae.Fragment = r, Ae.jsx = t, Ae.jsxs = t, Ae;
33
33
  }
34
- var Se = {};
34
+ var pe = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,126 +41,126 @@ var Se = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var hr;
45
- function st() {
46
- return hr || (hr = 1, process.env.NODE_ENV !== "production" && (function() {
44
+ var at;
45
+ function zt() {
46
+ return at || (at = 1, process.env.NODE_ENV !== "production" && (function() {
47
47
  function e(c) {
48
48
  if (c == null) return null;
49
49
  if (typeof c == "function")
50
- return c.$$typeof === be ? null : c.displayName || c.name || null;
50
+ return c.$$typeof === ge ? null : c.displayName || c.name || null;
51
51
  if (typeof c == "string") return c;
52
52
  switch (c) {
53
- case W:
53
+ case B:
54
54
  return "Fragment";
55
- case w:
55
+ case E:
56
56
  return "Profiler";
57
- case B:
57
+ case $:
58
58
  return "StrictMode";
59
- case F:
59
+ case X:
60
60
  return "Suspense";
61
- case j:
61
+ case ce:
62
62
  return "SuspenseList";
63
- case K:
63
+ case Z:
64
64
  return "Activity";
65
65
  }
66
66
  if (typeof c == "object")
67
67
  switch (typeof c.tag == "number" && console.error(
68
68
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
69
  ), c.$$typeof) {
70
- case $:
70
+ case M:
71
71
  return "Portal";
72
- case _:
73
- return c.displayName || "Context";
74
72
  case D:
73
+ return c.displayName || "Context";
74
+ case H:
75
75
  return (c._context.displayName || "Context") + ".Consumer";
76
- case m:
77
- var E = c.render;
78
- return c = c.displayName, c || (c = E.displayName || E.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
79
- case Q:
80
- return E = c.displayName || null, E !== null ? E : e(c.type) || "Memo";
81
- case se:
82
- E = c._payload, c = c._init;
76
+ case _:
77
+ var g = c.render;
78
+ return c = c.displayName, c || (c = g.displayName || g.name || "", c = c !== "" ? "ForwardRef(" + c + ")" : "ForwardRef"), c;
79
+ case le:
80
+ return g = c.displayName || null, g !== null ? g : e(c.type) || "Memo";
81
+ case ie:
82
+ g = c._payload, c = c._init;
83
83
  try {
84
- return e(c(E));
84
+ return e(c(g));
85
85
  } catch {
86
86
  }
87
87
  }
88
88
  return null;
89
89
  }
90
- function t(c) {
90
+ function r(c) {
91
91
  return "" + c;
92
92
  }
93
- function r(c) {
93
+ function t(c) {
94
94
  try {
95
- t(c);
96
- var E = !1;
95
+ r(c);
96
+ var g = !1;
97
97
  } catch {
98
- E = !0;
98
+ g = !0;
99
99
  }
100
- if (E) {
101
- E = console;
102
- var L = E.error, Y = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
103
- return L.call(
104
- E,
100
+ if (g) {
101
+ g = console;
102
+ var C = g.error, P = typeof Symbol == "function" && Symbol.toStringTag && c[Symbol.toStringTag] || c.constructor.name || "Object";
103
+ return C.call(
104
+ g,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- Y
107
- ), t(c);
106
+ P
107
+ ), r(c);
108
108
  }
109
109
  }
110
- function s(c) {
111
- if (c === W) return "<>";
112
- if (typeof c == "object" && c !== null && c.$$typeof === se)
110
+ function n(c) {
111
+ if (c === B) return "<>";
112
+ if (typeof c == "object" && c !== null && c.$$typeof === ie)
113
113
  return "<...>";
114
114
  try {
115
- var E = e(c);
116
- return E ? "<" + E + ">" : "<...>";
115
+ var g = e(c);
116
+ return g ? "<" + g + ">" : "<...>";
117
117
  } catch {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
121
  function o() {
122
- var c = k.A;
122
+ var c = x.A;
123
123
  return c === null ? null : c.getOwner();
124
124
  }
125
- function a() {
125
+ function i() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function l(c) {
129
- if (S.call(c, "key")) {
130
- var E = Object.getOwnPropertyDescriptor(c, "key").get;
131
- if (E && E.isReactWarning) return !1;
128
+ function u(c) {
129
+ if (R.call(c, "key")) {
130
+ var g = Object.getOwnPropertyDescriptor(c, "key").get;
131
+ if (g && g.isReactWarning) return !1;
132
132
  }
133
133
  return c.key !== void 0;
134
134
  }
135
- function d(c, E) {
136
- function L() {
137
- ee || (ee = !0, console.error(
135
+ function f(c, g) {
136
+ function C() {
137
+ Q || (Q = !0, console.error(
138
138
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
139
- E
139
+ g
140
140
  ));
141
141
  }
142
- L.isReactWarning = !0, Object.defineProperty(c, "key", {
143
- get: L,
142
+ C.isReactWarning = !0, Object.defineProperty(c, "key", {
143
+ get: C,
144
144
  configurable: !0
145
145
  });
146
146
  }
147
- function A() {
147
+ function w() {
148
148
  var c = e(this.type);
149
- return X[c] || (X[c] = !0, console.error(
149
+ return J[c] || (J[c] = !0, console.error(
150
150
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
151
151
  )), c = this.props.ref, c !== void 0 ? c : null;
152
152
  }
153
- function p(c, E, L, Y, xe, pe) {
154
- var z = L.ref;
153
+ function p(c, g, C, P, _e, xe) {
154
+ var L = C.ref;
155
155
  return c = {
156
- $$typeof: M,
156
+ $$typeof: N,
157
157
  type: c,
158
- key: E,
159
- props: L,
160
- _owner: Y
161
- }, (z !== void 0 ? z : null) !== null ? Object.defineProperty(c, "ref", {
158
+ key: g,
159
+ props: C,
160
+ _owner: P
161
+ }, (L !== void 0 ? L : null) !== null ? Object.defineProperty(c, "ref", {
162
162
  enumerable: !1,
163
- get: A
163
+ get: w
164
164
  }) : Object.defineProperty(c, "ref", { enumerable: !1, value: null }), c._store = {}, Object.defineProperty(c._store, "validated", {
165
165
  configurable: !1,
166
166
  enumerable: !1,
@@ -175,157 +175,157 @@ function st() {
175
175
  configurable: !1,
176
176
  enumerable: !1,
177
177
  writable: !0,
178
- value: xe
178
+ value: _e
179
179
  }), Object.defineProperty(c, "_debugTask", {
180
180
  configurable: !1,
181
181
  enumerable: !1,
182
182
  writable: !0,
183
- value: pe
183
+ value: xe
184
184
  }), Object.freeze && (Object.freeze(c.props), Object.freeze(c)), c;
185
185
  }
186
- function C(c, E, L, Y, xe, pe) {
187
- var z = E.children;
188
- if (z !== void 0)
189
- if (Y)
190
- if (q(z)) {
191
- for (Y = 0; Y < z.length; Y++)
192
- x(z[Y]);
193
- Object.freeze && Object.freeze(z);
186
+ function O(c, g, C, P, _e, xe) {
187
+ var L = g.children;
188
+ if (L !== void 0)
189
+ if (P)
190
+ if (I(L)) {
191
+ for (P = 0; P < L.length; P++)
192
+ V(L[P]);
193
+ Object.freeze && Object.freeze(L);
194
194
  } else
195
195
  console.error(
196
196
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
197
197
  );
198
- else x(z);
199
- if (S.call(E, "key")) {
200
- z = e(c);
201
- var le = Object.keys(E).filter(function(ke) {
202
- return ke !== "key";
198
+ else V(L);
199
+ if (R.call(g, "key")) {
200
+ L = e(c);
201
+ var ae = Object.keys(g).filter(function(we) {
202
+ return we !== "key";
203
203
  });
204
- Y = 0 < le.length ? "{key: someKey, " + le.join(": ..., ") + ": ...}" : "{key: someKey}", me[z + Y] || (le = 0 < le.length ? "{" + le.join(": ..., ") + ": ...}" : "{}", console.error(
204
+ P = 0 < ae.length ? "{key: someKey, " + ae.join(": ..., ") + ": ...}" : "{key: someKey}", ye[L + P] || (ae = 0 < ae.length ? "{" + ae.join(": ..., ") + ": ...}" : "{}", console.error(
205
205
  `A props object containing a "key" prop is being spread into JSX:
206
206
  let props = %s;
207
207
  <%s {...props} />
208
208
  React keys must be passed directly to JSX without using spread:
209
209
  let props = %s;
210
210
  <%s key={someKey} {...props} />`,
211
- Y,
212
- z,
213
- le,
214
- z
215
- ), me[z + Y] = !0);
211
+ P,
212
+ L,
213
+ ae,
214
+ L
215
+ ), ye[L + P] = !0);
216
216
  }
217
- if (z = null, L !== void 0 && (r(L), z = "" + L), l(E) && (r(E.key), z = "" + E.key), "key" in E) {
218
- L = {};
219
- for (var Ae in E)
220
- Ae !== "key" && (L[Ae] = E[Ae]);
221
- } else L = E;
222
- return z && d(
223
- L,
217
+ if (L = null, C !== void 0 && (t(C), L = "" + C), u(g) && (t(g.key), L = "" + g.key), "key" in g) {
218
+ C = {};
219
+ for (var Ee in g)
220
+ Ee !== "key" && (C[Ee] = g[Ee]);
221
+ } else C = g;
222
+ return L && f(
223
+ C,
224
224
  typeof c == "function" ? c.displayName || c.name || "Unknown" : c
225
225
  ), p(
226
226
  c,
227
- z,
228
227
  L,
228
+ C,
229
229
  o(),
230
- xe,
231
- pe
230
+ _e,
231
+ xe
232
232
  );
233
233
  }
234
- function x(c) {
235
- R(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === se && (c._payload.status === "fulfilled" ? R(c._payload.value) && c._payload.value._store && (c._payload.value._store.validated = 1) : c._store && (c._store.validated = 1));
234
+ function V(c) {
235
+ A(c) ? c._store && (c._store.validated = 1) : typeof c == "object" && c !== null && c.$$typeof === ie && (c._payload.status === "fulfilled" ? A(c._payload.value) && c._payload.value._store && (c._payload.value._store.validated = 1) : c._store && (c._store.validated = 1));
236
236
  }
237
- function R(c) {
238
- return typeof c == "object" && c !== null && c.$$typeof === M;
237
+ function A(c) {
238
+ return typeof c == "object" && c !== null && c.$$typeof === N;
239
239
  }
240
- var h = V, M = Symbol.for("react.transitional.element"), $ = Symbol.for("react.portal"), W = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), _ = Symbol.for("react.context"), m = Symbol.for("react.forward_ref"), F = Symbol.for("react.suspense"), j = Symbol.for("react.suspense_list"), Q = Symbol.for("react.memo"), se = Symbol.for("react.lazy"), K = Symbol.for("react.activity"), be = Symbol.for("react.client.reference"), k = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, q = Array.isArray, J = console.createTask ? console.createTask : function() {
240
+ var v = k, N = Symbol.for("react.transitional.element"), M = Symbol.for("react.portal"), B = Symbol.for("react.fragment"), $ = Symbol.for("react.strict_mode"), E = Symbol.for("react.profiler"), H = Symbol.for("react.consumer"), D = Symbol.for("react.context"), _ = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), ce = Symbol.for("react.suspense_list"), le = Symbol.for("react.memo"), ie = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), ge = Symbol.for("react.client.reference"), x = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, I = Array.isArray, W = console.createTask ? console.createTask : function() {
241
241
  return null;
242
242
  };
243
- h = {
243
+ v = {
244
244
  react_stack_bottom_frame: function(c) {
245
245
  return c();
246
246
  }
247
247
  };
248
- var ee, X = {}, fe = h.react_stack_bottom_frame.bind(
249
- h,
250
- a
251
- )(), ye = J(s(a)), me = {};
252
- Se.Fragment = W, Se.jsx = function(c, E, L) {
253
- var Y = 1e4 > k.recentlyCreatedOwnerStacks++;
254
- return C(
248
+ var Q, J = {}, fe = v.react_stack_bottom_frame.bind(
249
+ v,
250
+ i
251
+ )(), de = W(n(i)), ye = {};
252
+ pe.Fragment = B, pe.jsx = function(c, g, C) {
253
+ var P = 1e4 > x.recentlyCreatedOwnerStacks++;
254
+ return O(
255
255
  c,
256
- E,
257
- L,
256
+ g,
257
+ C,
258
258
  !1,
259
- Y ? Error("react-stack-top-frame") : fe,
260
- Y ? J(s(c)) : ye
259
+ P ? Error("react-stack-top-frame") : fe,
260
+ P ? W(n(c)) : de
261
261
  );
262
- }, Se.jsxs = function(c, E, L) {
263
- var Y = 1e4 > k.recentlyCreatedOwnerStacks++;
264
- return C(
262
+ }, pe.jsxs = function(c, g, C) {
263
+ var P = 1e4 > x.recentlyCreatedOwnerStacks++;
264
+ return O(
265
265
  c,
266
- E,
267
- L,
266
+ g,
267
+ C,
268
268
  !0,
269
- Y ? Error("react-stack-top-frame") : fe,
270
- Y ? J(s(c)) : ye
269
+ P ? Error("react-stack-top-frame") : fe,
270
+ P ? W(n(c)) : de
271
271
  );
272
272
  };
273
- })()), Se;
273
+ })()), pe;
274
274
  }
275
- var br;
276
- function nt() {
277
- return br || (br = 1, process.env.NODE_ENV === "production" ? je.exports = tt() : je.exports = st()), je.exports;
275
+ var ot;
276
+ function Ht() {
277
+ return ot || (ot = 1, process.env.NODE_ENV === "production" ? De.exports = qt() : De.exports = zt()), De.exports;
278
278
  }
279
- var T = nt(), De = (e) => e.type === "checkbox", he = (e) => e instanceof Date, re = (e) => e == null;
280
- const Tr = (e) => typeof e == "object";
281
- var G = (e) => !re(e) && !Array.isArray(e) && Tr(e) && !he(e), at = (e) => G(e) && e.target ? De(e.target) ? e.target.checked : e.target.value : e, it = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ot = (e, t) => e.has(it(t)), ut = (e) => {
282
- const t = e.constructor && e.constructor.prototype;
283
- return G(t) && t.hasOwnProperty("isPrototypeOf");
284
- }, nr = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
285
- function U(e) {
279
+ var F = Ht(), Te = (e) => e.type === "checkbox", ve = (e) => e instanceof Date, K = (e) => e == null;
280
+ const xt = (e) => typeof e == "object";
281
+ var q = (e) => !K(e) && !Array.isArray(e) && xt(e) && !ve(e), Jt = (e) => q(e) && e.target ? Te(e.target) ? e.target.checked : e.target.value : e, Gt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Xt = (e, r) => e.has(Gt(r)), Zt = (e) => {
282
+ const r = e.constructor && e.constructor.prototype;
283
+ return q(r) && r.hasOwnProperty("isPrototypeOf");
284
+ }, ze = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
285
+ function z(e) {
286
286
  if (e instanceof Date)
287
287
  return new Date(e);
288
- const t = typeof FileList < "u" && e instanceof FileList;
289
- if (nr && (e instanceof Blob || t))
288
+ const r = typeof FileList < "u" && e instanceof FileList;
289
+ if (ze && (e instanceof Blob || r))
290
290
  return e;
291
- const r = Array.isArray(e);
292
- if (!r && !(G(e) && ut(e)))
291
+ const t = Array.isArray(e);
292
+ if (!t && !(q(e) && Zt(e)))
293
293
  return e;
294
- const s = r ? [] : Object.create(Object.getPrototypeOf(e));
294
+ const n = t ? [] : Object.create(Object.getPrototypeOf(e));
295
295
  for (const o in e)
296
- Object.prototype.hasOwnProperty.call(e, o) && (s[o] = U(e[o]));
297
- return s;
296
+ Object.prototype.hasOwnProperty.call(e, o) && (n[o] = z(e[o]));
297
+ return n;
298
298
  }
299
- var Ue = (e) => /^\w*$/.test(e), I = (e) => e === void 0, Me = (e) => Array.isArray(e) ? e.filter(Boolean) : [], ar = (e) => Me(e.replace(/["|']|\]/g, "").split(/\.|\[/)), g = (e, t, r) => {
300
- if (!t || !G(e))
301
- return r;
302
- const s = (Ue(t) ? [t] : ar(t)).reduce((o, a) => re(o) ? o : o[a], e);
303
- return I(s) || s === e ? I(e[t]) ? r : e[t] : s;
304
- }, ce = (e) => typeof e == "boolean", oe = (e) => typeof e == "function", N = (e, t, r) => {
305
- let s = -1;
306
- const o = Ue(t) ? [t] : ar(t), a = o.length, l = a - 1;
307
- for (; ++s < a; ) {
308
- const d = o[s];
309
- let A = r;
310
- if (s !== l) {
311
- const p = e[d];
312
- A = G(p) || Array.isArray(p) ? p : isNaN(+o[s + 1]) ? {} : [];
299
+ var Le = (e) => /^\w*$/.test(e), U = (e) => e === void 0, He = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Je = (e) => He(e.replace(/["|']|\]/g, "").split(/\.|\[/)), h = (e, r, t) => {
300
+ if (!r || !q(e))
301
+ return t;
302
+ const n = (Le(r) ? [r] : Je(r)).reduce((o, i) => K(o) ? o : o[i], e);
303
+ return U(n) || n === e ? U(e[r]) ? t : e[r] : n;
304
+ }, oe = (e) => typeof e == "boolean", re = (e) => typeof e == "function", j = (e, r, t) => {
305
+ let n = -1;
306
+ const o = Le(r) ? [r] : Je(r), i = o.length, u = i - 1;
307
+ for (; ++n < i; ) {
308
+ const f = o[n];
309
+ let w = t;
310
+ if (n !== u) {
311
+ const p = e[f];
312
+ w = q(p) || Array.isArray(p) ? p : isNaN(+o[n + 1]) ? {} : [];
313
313
  }
314
- if (d === "__proto__" || d === "constructor" || d === "prototype")
314
+ if (f === "__proto__" || f === "constructor" || f === "prototype")
315
315
  return;
316
- e[d] = A, e = e[d];
316
+ e[f] = w, e = e[f];
317
317
  }
318
318
  };
319
- const xr = {
319
+ const lt = {
320
320
  BLUR: "blur",
321
321
  FOCUS_OUT: "focusout"
322
- }, ie = {
322
+ }, se = {
323
323
  onBlur: "onBlur",
324
324
  onChange: "onChange",
325
325
  onSubmit: "onSubmit",
326
326
  onTouched: "onTouched",
327
327
  all: "all"
328
- }, de = {
328
+ }, ue = {
329
329
  max: "max",
330
330
  min: "min",
331
331
  maxLength: "maxLength",
@@ -333,106 +333,106 @@ const xr = {
333
333
  pattern: "pattern",
334
334
  required: "required",
335
335
  validate: "validate"
336
- }, ir = V.createContext(null);
337
- ir.displayName = "HookFormContext";
338
- const ge = () => V.useContext(ir), lt = (e) => {
339
- const { children: t, ...r } = e;
340
- return V.createElement(ir.Provider, { value: r }, t);
336
+ }, Ge = k.createContext(null);
337
+ Ge.displayName = "HookFormContext";
338
+ const be = () => k.useContext(Ge), Qt = (e) => {
339
+ const { children: r, ...t } = e;
340
+ return k.createElement(Ge.Provider, { value: t }, r);
341
341
  };
342
- var ct = (e, t, r, s = !0) => {
342
+ var Kt = (e, r, t, n = !0) => {
343
343
  const o = {
344
- defaultValues: t._defaultValues
344
+ defaultValues: r._defaultValues
345
345
  };
346
- for (const a in e)
347
- Object.defineProperty(o, a, {
346
+ for (const i in e)
347
+ Object.defineProperty(o, i, {
348
348
  get: () => {
349
- const l = a;
350
- return t._proxyFormState[l] !== ie.all && (t._proxyFormState[l] = !s || ie.all), e[l];
349
+ const u = i;
350
+ return r._proxyFormState[u] !== se.all && (r._proxyFormState[u] = !n || se.all), e[u];
351
351
  }
352
352
  });
353
353
  return o;
354
354
  };
355
- const or = typeof window < "u" ? V.useLayoutEffect : V.useEffect;
356
- var ne = (e) => typeof e == "string", Ke = (e, t, r, s, o) => ne(e) ? (s && t.watch.add(e), g(r, e, o)) : Array.isArray(e) ? e.map((a) => (s && t.watch.add(a), g(r, a))) : (s && (t.watchAll = !0), r), er = (e) => re(e) || !Tr(e);
357
- function ue(e, t, r = /* @__PURE__ */ new WeakSet()) {
358
- if (er(e) || er(t))
359
- return Object.is(e, t);
360
- if (he(e) && he(t))
361
- return e.getTime() === t.getTime();
362
- const s = Object.keys(e), o = Object.keys(t);
363
- if (s.length !== o.length)
355
+ const Et = typeof window < "u" ? k.useLayoutEffect : k.useEffect;
356
+ var ee = (e) => typeof e == "string", We = (e, r, t, n, o) => ee(e) ? (n && r.watch.add(e), h(t, e, o)) : Array.isArray(e) ? e.map((i) => (n && r.watch.add(i), h(t, i))) : (n && (r.watchAll = !0), t), Ye = (e) => K(e) || !xt(e);
357
+ function ne(e, r, t = /* @__PURE__ */ new WeakSet()) {
358
+ if (Ye(e) || Ye(r))
359
+ return Object.is(e, r);
360
+ if (ve(e) && ve(r))
361
+ return e.getTime() === r.getTime();
362
+ const n = Object.keys(e), o = Object.keys(r);
363
+ if (n.length !== o.length)
364
364
  return !1;
365
- if (r.has(e) || r.has(t))
365
+ if (t.has(e) || t.has(r))
366
366
  return !0;
367
- r.add(e), r.add(t);
368
- for (const a of s) {
369
- const l = e[a];
370
- if (!o.includes(a))
367
+ t.add(e), t.add(r);
368
+ for (const i of n) {
369
+ const u = e[i];
370
+ if (!o.includes(i))
371
371
  return !1;
372
- if (a !== "ref") {
373
- const d = t[a];
374
- if (he(l) && he(d) || G(l) && G(d) || Array.isArray(l) && Array.isArray(d) ? !ue(l, d, r) : !Object.is(l, d))
372
+ if (i !== "ref") {
373
+ const f = r[i];
374
+ if (ve(u) && ve(f) || q(u) && q(f) || Array.isArray(u) && Array.isArray(f) ? !ne(u, f, t) : !Object.is(u, f))
375
375
  return !1;
376
376
  }
377
377
  }
378
378
  return !0;
379
379
  }
380
- function Or(e) {
381
- const t = ge(), { control: r = t.control, name: s, defaultValue: o, disabled: a, exact: l, compute: d } = e || {}, A = V.useRef(o), p = V.useRef(d), C = V.useRef(void 0), x = V.useRef(r), R = V.useRef(s);
382
- p.current = d;
383
- const [h, M] = V.useState(() => {
384
- const _ = r._getWatch(s, A.current);
380
+ function Xe(e) {
381
+ const r = be(), { control: t = r.control, name: n, defaultValue: o, disabled: i, exact: u, compute: f } = e || {}, w = k.useRef(o), p = k.useRef(f), O = k.useRef(void 0), V = k.useRef(t), A = k.useRef(n);
382
+ p.current = f;
383
+ const [v, N] = k.useState(() => {
384
+ const D = t._getWatch(n, w.current);
385
+ return p.current ? p.current(D) : D;
386
+ }), M = k.useCallback((D) => {
387
+ const _ = We(n, t._names, D || t._formValues, !1, w.current);
385
388
  return p.current ? p.current(_) : _;
386
- }), $ = V.useCallback((_) => {
387
- const m = Ke(s, r._names, _ || r._formValues, !1, A.current);
388
- return p.current ? p.current(m) : m;
389
- }, [r._formValues, r._names, s]), W = V.useCallback((_) => {
390
- if (!a) {
391
- const m = Ke(s, r._names, _ || r._formValues, !1, A.current);
389
+ }, [t._formValues, t._names, n]), B = k.useCallback((D) => {
390
+ if (!i) {
391
+ const _ = We(n, t._names, D || t._formValues, !1, w.current);
392
392
  if (p.current) {
393
- const F = p.current(m);
394
- ue(F, C.current) || (M(F), C.current = F);
393
+ const X = p.current(_);
394
+ ne(X, O.current) || (N(X), O.current = X);
395
395
  } else
396
- M(m);
396
+ N(_);
397
397
  }
398
- }, [r._formValues, r._names, a, s]);
399
- or(() => ((x.current !== r || !ue(R.current, s)) && (x.current = r, R.current = s, W()), r._subscribe({
400
- name: s,
398
+ }, [t._formValues, t._names, i, n]);
399
+ Et(() => ((V.current !== t || !ne(A.current, n)) && (V.current = t, A.current = n, B()), t._subscribe({
400
+ name: n,
401
401
  formState: {
402
402
  values: !0
403
403
  },
404
- exact: l,
405
- callback: (_) => {
406
- W(_.values);
404
+ exact: u,
405
+ callback: (D) => {
406
+ B(D.values);
407
407
  }
408
- })), [r, l, s, W]), V.useEffect(() => r._removeUnmounted());
409
- const B = x.current !== r, w = R.current, D = V.useMemo(() => {
410
- if (a)
408
+ })), [t, u, n, B]), k.useEffect(() => t._removeUnmounted());
409
+ const $ = V.current !== t, E = A.current, H = k.useMemo(() => {
410
+ if (i)
411
411
  return null;
412
- const _ = !B && !ue(w, s);
413
- return B || _ ? $() : null;
414
- }, [a, B, s, w, $]);
415
- return D !== null ? D : h;
412
+ const D = !$ && !ne(E, n);
413
+ return $ || D ? M() : null;
414
+ }, [i, $, n, E, M]);
415
+ return H !== null ? H : v;
416
416
  }
417
- var dt = (e, t, r, s, o) => t ? {
418
- ...r[e],
417
+ var er = (e, r, t, n, o) => r ? {
418
+ ...t[e],
419
419
  types: {
420
- ...r[e] && r[e].types ? r[e].types : {},
421
- [s]: o || !0
420
+ ...t[e] && t[e].types ? t[e].types : {},
421
+ [n]: o || !0
422
422
  }
423
- } : {}, te = (e) => Array.isArray(e) ? e : [e], pr = () => {
423
+ } : {}, ke = (e) => Array.isArray(e) ? e : [e], ut = () => {
424
424
  let e = [];
425
425
  return {
426
426
  get observers() {
427
427
  return e;
428
428
  },
429
429
  next: (o) => {
430
- for (const a of e)
431
- a.next && a.next(o);
430
+ for (const i of e)
431
+ i.next && i.next(o);
432
432
  },
433
433
  subscribe: (o) => (e.push(o), {
434
434
  unsubscribe: () => {
435
- e = e.filter((a) => a !== o);
435
+ e = e.filter((i) => i !== o);
436
436
  }
437
437
  }),
438
438
  unsubscribe: () => {
@@ -440,279 +440,279 @@ var dt = (e, t, r, s, o) => t ? {
440
440
  }
441
441
  };
442
442
  };
443
- function Dr(e, t) {
444
- const r = {};
445
- for (const s in e)
446
- if (e.hasOwnProperty(s)) {
447
- const o = e[s], a = t[s];
448
- if (o && G(o) && a) {
449
- const l = Dr(o, a);
450
- G(l) && (r[s] = l);
451
- } else e[s] && (r[s] = a);
443
+ function Vt(e, r) {
444
+ const t = {};
445
+ for (const n in e)
446
+ if (e.hasOwnProperty(n)) {
447
+ const o = e[n], i = r[n];
448
+ if (o && q(o) && i) {
449
+ const u = Vt(o, i);
450
+ q(u) && (t[n] = u);
451
+ } else e[n] && (t[n] = i);
452
452
  }
453
- return r;
453
+ return t;
454
454
  }
455
- var Z = (e) => G(e) && !Object.keys(e).length, ur = (e) => e.type === "file", Ne = (e) => {
456
- if (!nr)
455
+ var G = (e) => q(e) && !Object.keys(e).length, Ze = (e) => e.type === "file", je = (e) => {
456
+ if (!ze)
457
457
  return !1;
458
- const t = e ? e.ownerDocument : 0;
459
- return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
460
- }, Cr = (e) => e.type === "select-multiple", lr = (e) => e.type === "radio", ft = (e) => lr(e) || De(e), Ye = (e) => Ne(e) && e.isConnected;
461
- function yt(e, t) {
462
- const r = t.slice(0, -1).length;
463
- let s = 0;
464
- for (; s < r; )
465
- e = I(e) ? s++ : e[t[s++]];
458
+ const r = e ? e.ownerDocument : 0;
459
+ return e instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
460
+ }, Ft = (e) => e.type === "select-multiple", Qe = (e) => e.type === "radio", tr = (e) => Qe(e) || Te(e), $e = (e) => je(e) && e.isConnected;
461
+ function rr(e, r) {
462
+ const t = r.slice(0, -1).length;
463
+ let n = 0;
464
+ for (; n < t; )
465
+ e = U(e) ? n++ : e[r[n++]];
466
466
  return e;
467
467
  }
468
- function mt(e) {
469
- for (const t in e)
470
- if (e.hasOwnProperty(t) && !I(e[t]))
468
+ function sr(e) {
469
+ for (const r in e)
470
+ if (e.hasOwnProperty(r) && !U(e[r]))
471
471
  return !1;
472
472
  return !0;
473
473
  }
474
- function H(e, t) {
475
- const r = Array.isArray(t) ? t : Ue(t) ? [t] : ar(t), s = r.length === 1 ? e : yt(e, r), o = r.length - 1, a = r[o];
476
- return s && delete s[a], o !== 0 && (G(s) && Z(s) || Array.isArray(s) && mt(s)) && H(e, r.slice(0, -1)), e;
474
+ function Y(e, r) {
475
+ const t = Array.isArray(r) ? r : Le(r) ? [r] : Je(r), n = t.length === 1 ? e : rr(e, t), o = t.length - 1, i = t[o];
476
+ return n && delete n[i], o !== 0 && (q(n) && G(n) || Array.isArray(n) && sr(n)) && Y(e, t.slice(0, -1)), e;
477
477
  }
478
- var _t = (e) => {
479
- for (const t in e)
480
- if (oe(e[t]))
478
+ var nr = (e) => {
479
+ for (const r in e)
480
+ if (re(e[r]))
481
481
  return !0;
482
482
  return !1;
483
483
  };
484
- function jr(e) {
485
- return Array.isArray(e) || G(e) && !_t(e);
484
+ function wt(e) {
485
+ return Array.isArray(e) || q(e) && !nr(e);
486
486
  }
487
- function rr(e, t = {}) {
488
- for (const r in e) {
489
- const s = e[r];
490
- jr(s) ? (t[r] = Array.isArray(s) ? [] : {}, rr(s, t[r])) : I(s) || (t[r] = !0);
487
+ function qe(e, r = {}) {
488
+ for (const t in e) {
489
+ const n = e[t];
490
+ wt(n) ? (r[t] = Array.isArray(n) ? [] : {}, qe(n, r[t])) : U(n) || (r[t] = !0);
491
491
  }
492
- return t;
492
+ return r;
493
493
  }
494
- function Ve(e, t, r) {
495
- r || (r = rr(t));
496
- for (const s in e) {
497
- const o = e[s];
498
- if (jr(o))
499
- I(t) || er(r[s]) ? r[s] = rr(o, Array.isArray(o) ? [] : {}) : Ve(o, re(t) ? {} : t[s], r[s]);
494
+ function Fe(e, r, t) {
495
+ t || (t = qe(r));
496
+ for (const n in e) {
497
+ const o = e[n];
498
+ if (wt(o))
499
+ U(r) || Ye(t[n]) ? t[n] = qe(o, Array.isArray(o) ? [] : {}) : Fe(o, K(r) ? {} : r[n], t[n]);
500
500
  else {
501
- const a = t[s];
502
- r[s] = !ue(o, a);
501
+ const i = r[n];
502
+ t[n] = !ne(o, i);
503
503
  }
504
504
  }
505
- return r;
505
+ return t;
506
506
  }
507
- const Ar = {
507
+ const ct = {
508
508
  value: !1,
509
509
  isValid: !1
510
- }, Fr = { value: !0, isValid: !0 };
511
- var Pr = (e) => {
510
+ }, ft = { value: !0, isValid: !0 };
511
+ var At = (e) => {
512
512
  if (Array.isArray(e)) {
513
513
  if (e.length > 1) {
514
- const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
515
- return { value: t, isValid: !!t.length };
514
+ const r = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
515
+ return { value: r, isValid: !!r.length };
516
516
  }
517
517
  return e[0].checked && !e[0].disabled ? (
518
518
  // @ts-expect-error expected to work in the browser
519
- e[0].attributes && !I(e[0].attributes.value) ? I(e[0].value) || e[0].value === "" ? Fr : { value: e[0].value, isValid: !0 } : Fr
520
- ) : Ar;
519
+ e[0].attributes && !U(e[0].attributes.value) ? U(e[0].value) || e[0].value === "" ? ft : { value: e[0].value, isValid: !0 } : ft
520
+ ) : ct;
521
521
  }
522
- return Ar;
523
- }, Nr = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: s }) => I(e) ? e : t ? e === "" ? NaN : e && +e : r && ne(e) ? new Date(e) : s ? s(e) : e;
524
- const Vr = {
522
+ return ct;
523
+ }, pt = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) => U(e) ? e : r ? e === "" ? NaN : e && +e : t && ee(e) ? new Date(e) : n ? n(e) : e;
524
+ const dt = {
525
525
  isValid: !1,
526
526
  value: null
527
527
  };
528
- var Ir = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
528
+ var Rt = (e) => Array.isArray(e) ? e.reduce((r, t) => t && t.checked && !t.disabled ? {
529
529
  isValid: !0,
530
- value: r.value
531
- } : t, Vr) : Vr;
532
- function Er(e) {
533
- const t = e.ref;
534
- return ur(t) ? t.files : lr(t) ? Ir(e.refs).value : Cr(t) ? [...t.selectedOptions].map(({ value: r }) => r) : De(t) ? Pr(e.refs).value : Nr(I(t.value) ? e.ref.value : t.value, e);
530
+ value: t.value
531
+ } : r, dt) : dt;
532
+ function yt(e) {
533
+ const r = e.ref;
534
+ return Ze(r) ? r.files : Qe(r) ? Rt(e.refs).value : Ft(r) ? [...r.selectedOptions].map(({ value: t }) => t) : Te(r) ? At(e.refs).value : pt(U(r.value) ? e.ref.value : r.value, e);
535
535
  }
536
- var vt = (e, t, r, s) => {
536
+ var ir = (e, r, t, n) => {
537
537
  const o = {};
538
- for (const a of e) {
539
- const l = g(t, a);
540
- l && N(o, a, l._f);
538
+ for (const i of e) {
539
+ const u = h(r, i);
540
+ u && j(o, i, u._f);
541
541
  }
542
542
  return {
543
- criteriaMode: r,
543
+ criteriaMode: t,
544
544
  names: [...e],
545
545
  fields: o,
546
- shouldUseNativeValidation: s
546
+ shouldUseNativeValidation: n
547
547
  };
548
- }, Ie = (e) => e instanceof RegExp, Te = (e) => I(e) ? e : Ie(e) ? e.source : G(e) ? Ie(e.value) ? e.value.source : e.value : e, Ee = (e) => ({
549
- isOnSubmit: !e || e === ie.onSubmit,
550
- isOnBlur: e === ie.onBlur,
551
- isOnChange: e === ie.onChange,
552
- isOnAll: e === ie.all,
553
- isOnTouch: e === ie.onTouched
548
+ }, Pe = (e) => e instanceof RegExp, Re = (e) => U(e) ? e : Pe(e) ? e.source : q(e) ? Pe(e.value) ? e.value.source : e.value : e, mt = (e) => ({
549
+ isOnSubmit: !e || e === se.onSubmit,
550
+ isOnBlur: e === se.onBlur,
551
+ isOnChange: e === se.onChange,
552
+ isOnAll: e === se.all,
553
+ isOnTouch: e === se.onTouched
554
554
  });
555
- const wr = "AsyncFunction";
556
- var gt = (e) => !!e && !!e.validate && !!(oe(e.validate) && e.validate.constructor.name === wr || G(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === wr)), ht = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), tr = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((s) => e.startsWith(s) && /^\.\w+/.test(e.slice(s.length))));
557
- const we = (e, t, r, s) => {
558
- for (const o of r || Object.keys(e)) {
559
- const a = g(e, o);
560
- if (a) {
561
- const { _f: l, ...d } = a;
562
- if (l) {
563
- if (l.refs && l.refs[0] && t(l.refs[0], o) && !s)
555
+ const ht = "AsyncFunction";
556
+ var ar = (e) => !!e && !!e.validate && !!(re(e.validate) && e.validate.constructor.name === ht || q(e.validate) && Object.values(e.validate).find((r) => r.constructor.name === ht)), or = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), vt = (e, r, t) => !t && (r.watchAll || r.watch.has(e) || [...r.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
557
+ const Se = (e, r, t, n) => {
558
+ for (const o of t || Object.keys(e)) {
559
+ const i = h(e, o);
560
+ if (i) {
561
+ const { _f: u, ...f } = i;
562
+ if (u) {
563
+ if (u.refs && u.refs[0] && r(u.refs[0], o) && !n)
564
564
  return !0;
565
- if (l.ref && t(l.ref, l.name) && !s)
565
+ if (u.ref && r(u.ref, u.name) && !n)
566
566
  return !0;
567
- if (we(d, t))
567
+ if (Se(f, r))
568
568
  break;
569
- } else if (G(d) && we(d, t))
569
+ } else if (q(f) && Se(f, r))
570
570
  break;
571
571
  }
572
572
  }
573
573
  };
574
- function kr(e, t, r) {
575
- const s = g(e, r);
576
- if (s || Ue(r))
574
+ function bt(e, r, t) {
575
+ const n = h(e, t);
576
+ if (n || Le(t))
577
577
  return {
578
- error: s,
579
- name: r
578
+ error: n,
579
+ name: t
580
580
  };
581
- const o = r.split(".");
581
+ const o = t.split(".");
582
582
  for (; o.length; ) {
583
- const a = o.join("."), l = g(t, a), d = g(e, a);
584
- if (l && !Array.isArray(l) && r !== a)
585
- return { name: r };
586
- if (d && d.type)
583
+ const i = o.join("."), u = h(r, i), f = h(e, i);
584
+ if (u && !Array.isArray(u) && t !== i)
585
+ return { name: t };
586
+ if (f && f.type)
587
587
  return {
588
- name: a,
589
- error: d
588
+ name: i,
589
+ error: f
590
590
  };
591
- if (d && d.root && d.root.type)
591
+ if (f && f.root && f.root.type)
592
592
  return {
593
- name: `${a}.root`,
594
- error: d.root
593
+ name: `${i}.root`,
594
+ error: f.root
595
595
  };
596
596
  o.pop();
597
597
  }
598
598
  return {
599
- name: r
599
+ name: t
600
600
  };
601
601
  }
602
- var bt = (e, t, r, s) => {
603
- r(e);
604
- const { name: o, ...a } = e;
605
- return Z(a) || Object.keys(a).length >= Object.keys(t).length || Object.keys(a).find((l) => t[l] === (!s || ie.all));
606
- }, xt = (e, t, r) => !e || !t || e === t || te(e).some((s) => s && (r ? s === t : s.startsWith(t) || t.startsWith(s))), pt = (e, t, r, s, o) => o.isOnAll ? !1 : !r && o.isOnTouch ? !(t || e) : (r ? s.isOnBlur : o.isOnBlur) ? !e : (r ? s.isOnChange : o.isOnChange) ? e : !0, At = (e, t) => !Me(g(e, t)).length && H(e, t), Lr = (e, t, r) => {
607
- const s = te(g(e, r));
608
- return N(s, "root", t[r]), N(e, r, s), e;
602
+ var lr = (e, r, t, n) => {
603
+ t(e);
604
+ const { name: o, ...i } = e;
605
+ return G(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((u) => r[u] === (!n || se.all));
606
+ }, ur = (e, r, t) => !e || !r || e === r || ke(e).some((n) => n && (t ? n === r : n.startsWith(r) || r.startsWith(n))), cr = (e, r, t, n, o) => o.isOnAll ? !1 : !t && o.isOnTouch ? !(r || e) : (t ? n.isOnBlur : o.isOnBlur) ? !e : (t ? n.isOnChange : o.isOnChange) ? e : !0, fr = (e, r) => !He(h(e, r)).length && Y(e, r), dr = (e, r, t) => {
607
+ const n = ke(h(e, t));
608
+ return j(n, "root", r[t]), j(e, t, n), e;
609
609
  };
610
- function Rr(e, t, r = "validate") {
611
- if (ne(e) || Array.isArray(e) && e.every(ne) || ce(e) && !e)
610
+ function gt(e, r, t = "validate") {
611
+ if (ee(e) || Array.isArray(e) && e.every(ee) || oe(e) && !e)
612
612
  return {
613
- type: r,
614
- message: ne(e) ? e : "",
615
- ref: t
613
+ type: t,
614
+ message: ee(e) ? e : "",
615
+ ref: r
616
616
  };
617
617
  }
618
- var Fe = (e) => G(e) && !Ie(e) ? e : {
618
+ var Ve = (e) => q(e) && !Pe(e) ? e : {
619
619
  value: e,
620
620
  message: ""
621
- }, sr = async (e, t, r, s, o, a) => {
622
- const { ref: l, refs: d, required: A, maxLength: p, minLength: C, min: x, max: R, pattern: h, validate: M, name: $, valueAsNumber: W, mount: B } = e._f, w = g(r, $);
623
- if (!B || t.has($))
621
+ }, _t = async (e, r, t, n, o, i) => {
622
+ const { ref: u, refs: f, required: w, maxLength: p, minLength: O, min: V, max: A, pattern: v, validate: N, name: M, valueAsNumber: B, mount: $ } = e._f, E = h(t, M);
623
+ if (!$ || r.has(M))
624
624
  return {};
625
- const D = d ? d[0] : l, _ = (k) => {
626
- o && D.reportValidity && (D.setCustomValidity(ce(k) ? "" : k || ""), D.reportValidity());
627
- }, m = {}, F = lr(l), j = De(l), Q = F || j, se = (W || ur(l)) && I(l.value) && I(w) || Ne(l) && l.value === "" || w === "" || Array.isArray(w) && !w.length, K = dt.bind(null, $, s, m), be = (k, S, q, J = de.maxLength, ee = de.minLength) => {
628
- const X = k ? S : q;
629
- m[$] = {
630
- type: k ? J : ee,
631
- message: X,
632
- ref: l,
633
- ...K(k ? J : ee, X)
625
+ const H = f ? f[0] : u, D = (x) => {
626
+ o && H.reportValidity && (H.setCustomValidity(oe(x) ? "" : x || ""), H.reportValidity());
627
+ }, _ = {}, X = Qe(u), ce = Te(u), le = X || ce, ie = (B || Ze(u)) && U(u.value) && U(E) || je(u) && u.value === "" || E === "" || Array.isArray(E) && !E.length, Z = er.bind(null, M, n, _), ge = (x, R, I, W = ue.maxLength, Q = ue.minLength) => {
628
+ const J = x ? R : I;
629
+ _[M] = {
630
+ type: x ? W : Q,
631
+ message: J,
632
+ ref: u,
633
+ ...Z(x ? W : Q, J)
634
634
  };
635
635
  };
636
- if (a ? !Array.isArray(w) || !w.length : A && (!Q && (se || re(w)) || ce(w) && !w || j && !Pr(d).isValid || F && !Ir(d).isValid)) {
637
- const { value: k, message: S } = ne(A) ? { value: !!A, message: A } : Fe(A);
638
- if (k && (m[$] = {
639
- type: de.required,
640
- message: S,
641
- ref: D,
642
- ...K(de.required, S)
643
- }, !s))
644
- return _(S), m;
636
+ if (i ? !Array.isArray(E) || !E.length : w && (!le && (ie || K(E)) || oe(E) && !E || ce && !At(f).isValid || X && !Rt(f).isValid)) {
637
+ const { value: x, message: R } = ee(w) ? { value: !!w, message: w } : Ve(w);
638
+ if (x && (_[M] = {
639
+ type: ue.required,
640
+ message: R,
641
+ ref: H,
642
+ ...Z(ue.required, R)
643
+ }, !n))
644
+ return D(R), _;
645
645
  }
646
- if (!se && (!re(x) || !re(R))) {
647
- let k, S;
648
- const q = Fe(R), J = Fe(x);
649
- if (!re(w) && !isNaN(w)) {
650
- const ee = l.valueAsNumber || w && +w;
651
- re(q.value) || (k = ee > q.value), re(J.value) || (S = ee < J.value);
646
+ if (!ie && (!K(V) || !K(A))) {
647
+ let x, R;
648
+ const I = Ve(A), W = Ve(V);
649
+ if (!K(E) && !isNaN(E)) {
650
+ const Q = u.valueAsNumber || E && +E;
651
+ K(I.value) || (x = Q > I.value), K(W.value) || (R = Q < W.value);
652
652
  } else {
653
- const ee = l.valueAsDate || new Date(w), X = (me) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + me), fe = l.type == "time", ye = l.type == "week";
654
- ne(q.value) && w && (k = fe ? X(w) > X(q.value) : ye ? w > q.value : ee > new Date(q.value)), ne(J.value) && w && (S = fe ? X(w) < X(J.value) : ye ? w < J.value : ee < new Date(J.value));
653
+ const Q = u.valueAsDate || new Date(E), J = (ye) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ye), fe = u.type == "time", de = u.type == "week";
654
+ ee(I.value) && E && (x = fe ? J(E) > J(I.value) : de ? E > I.value : Q > new Date(I.value)), ee(W.value) && E && (R = fe ? J(E) < J(W.value) : de ? E < W.value : Q < new Date(W.value));
655
655
  }
656
- if ((k || S) && (be(!!k, q.message, J.message, de.max, de.min), !s))
657
- return _(m[$].message), m;
656
+ if ((x || R) && (ge(!!x, I.message, W.message, ue.max, ue.min), !n))
657
+ return D(_[M].message), _;
658
658
  }
659
- if ((p || C) && !se && (ne(w) || a && Array.isArray(w))) {
660
- const k = Fe(p), S = Fe(C), q = !re(k.value) && w.length > +k.value, J = !re(S.value) && w.length < +S.value;
661
- if ((q || J) && (be(q, k.message, S.message), !s))
662
- return _(m[$].message), m;
659
+ if ((p || O) && !ie && (ee(E) || i && Array.isArray(E))) {
660
+ const x = Ve(p), R = Ve(O), I = !K(x.value) && E.length > +x.value, W = !K(R.value) && E.length < +R.value;
661
+ if ((I || W) && (ge(I, x.message, R.message), !n))
662
+ return D(_[M].message), _;
663
663
  }
664
- if (h && !se && ne(w)) {
665
- const { value: k, message: S } = Fe(h);
666
- if (Ie(k) && !w.match(k) && (m[$] = {
667
- type: de.pattern,
668
- message: S,
669
- ref: l,
670
- ...K(de.pattern, S)
671
- }, !s))
672
- return _(S), m;
664
+ if (v && !ie && ee(E)) {
665
+ const { value: x, message: R } = Ve(v);
666
+ if (Pe(x) && !E.match(x) && (_[M] = {
667
+ type: ue.pattern,
668
+ message: R,
669
+ ref: u,
670
+ ...Z(ue.pattern, R)
671
+ }, !n))
672
+ return D(R), _;
673
673
  }
674
- if (M) {
675
- if (oe(M)) {
676
- const k = await M(w, r), S = Rr(k, D);
677
- if (S && (m[$] = {
678
- ...S,
679
- ...K(de.validate, S.message)
680
- }, !s))
681
- return _(S.message), m;
682
- } else if (G(M)) {
683
- let k = {};
684
- for (const S in M) {
685
- if (!Z(k) && !s)
674
+ if (N) {
675
+ if (re(N)) {
676
+ const x = await N(E, t), R = gt(x, H);
677
+ if (R && (_[M] = {
678
+ ...R,
679
+ ...Z(ue.validate, R.message)
680
+ }, !n))
681
+ return D(R.message), _;
682
+ } else if (q(N)) {
683
+ let x = {};
684
+ for (const R in N) {
685
+ if (!G(x) && !n)
686
686
  break;
687
- const q = Rr(await M[S](w, r), D, S);
688
- q && (k = {
689
- ...q,
690
- ...K(S, q.message)
691
- }, _(q.message), s && (m[$] = k));
687
+ const I = gt(await N[R](E, t), H, R);
688
+ I && (x = {
689
+ ...I,
690
+ ...Z(R, I.message)
691
+ }, D(I.message), n && (_[M] = x));
692
692
  }
693
- if (!Z(k) && (m[$] = {
694
- ref: D,
695
- ...k
696
- }, !s))
697
- return m;
693
+ if (!G(x) && (_[M] = {
694
+ ref: H,
695
+ ...x
696
+ }, !n))
697
+ return _;
698
698
  }
699
699
  }
700
- return _(!0), m;
700
+ return D(!0), _;
701
701
  };
702
- const Ft = {
703
- mode: ie.onSubmit,
704
- reValidateMode: ie.onChange,
702
+ const yr = {
703
+ mode: se.onSubmit,
704
+ reValidateMode: se.onChange,
705
705
  shouldFocusError: !0
706
706
  };
707
- function Vt(e = {}) {
708
- let t = {
709
- ...Ft,
707
+ function mr(e = {}) {
708
+ let r = {
709
+ ...yr,
710
710
  ...e
711
- }, r = {
711
+ }, t = {
712
712
  submitCount: 0,
713
713
  isDirty: !1,
714
714
  isReady: !1,
715
- isLoading: oe(t.defaultValues),
715
+ isLoading: re(r.defaultValues),
716
716
  isValidating: !1,
717
717
  isSubmitted: !1,
718
718
  isSubmitting: !1,
@@ -721,21 +721,21 @@ function Vt(e = {}) {
721
721
  touchedFields: {},
722
722
  dirtyFields: {},
723
723
  validatingFields: {},
724
- errors: t.errors || {},
725
- disabled: t.disabled || !1
726
- }, s = {}, o = G(t.defaultValues) || G(t.values) ? U(t.defaultValues || t.values) || {} : {}, a = t.shouldUnregister ? {} : U(o), l = {
724
+ errors: r.errors || {},
725
+ disabled: r.disabled || !1
726
+ }, n = {}, o = q(r.defaultValues) || q(r.values) ? z(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : z(o), u = {
727
727
  action: !1,
728
728
  mount: !1,
729
729
  watch: !1,
730
730
  keepIsValid: !1
731
- }, d = {
731
+ }, f = {
732
732
  mount: /* @__PURE__ */ new Set(),
733
733
  disabled: /* @__PURE__ */ new Set(),
734
734
  unMount: /* @__PURE__ */ new Set(),
735
735
  array: /* @__PURE__ */ new Set(),
736
736
  watch: /* @__PURE__ */ new Set()
737
- }, A, p = 0;
738
- const C = {
737
+ }, w, p = 0;
738
+ const O = {
739
739
  isDirty: !1,
740
740
  dirtyFields: !1,
741
741
  validatingFields: !1,
@@ -743,657 +743,522 @@ function Vt(e = {}) {
743
743
  isValidating: !1,
744
744
  isValid: !1,
745
745
  errors: !1
746
- }, x = {
747
- ...C
746
+ }, V = {
747
+ ...O
748
748
  };
749
- let R = {
750
- ...x
749
+ let A = {
750
+ ...V
751
751
  };
752
- const h = {
753
- array: pr(),
754
- state: pr()
755
- }, M = t.criteriaMode === ie.all, $ = (n) => (i) => {
756
- clearTimeout(p), p = setTimeout(n, i);
757
- }, W = async (n) => {
758
- if (!l.keepIsValid && !t.disabled && (x.isValid || R.isValid || n)) {
759
- let i;
760
- t.resolver ? (i = Z((await Q()).errors), B()) : i = await K(s, !0), i !== r.isValid && h.state.next({
761
- isValid: i
752
+ const v = {
753
+ array: ut(),
754
+ state: ut()
755
+ }, N = r.criteriaMode === se.all, M = (s) => (a) => {
756
+ clearTimeout(p), p = setTimeout(s, a);
757
+ }, B = async (s) => {
758
+ if (!u.keepIsValid && !r.disabled && (V.isValid || A.isValid || s)) {
759
+ let a;
760
+ r.resolver ? (a = G((await le()).errors), $()) : a = await Z(n, !0), a !== t.isValid && v.state.next({
761
+ isValid: a
762
762
  });
763
763
  }
764
- }, B = (n, i) => {
765
- !t.disabled && (x.isValidating || x.validatingFields || R.isValidating || R.validatingFields) && ((n || Array.from(d.mount)).forEach((u) => {
766
- u && (i ? N(r.validatingFields, u, i) : H(r.validatingFields, u));
767
- }), h.state.next({
768
- validatingFields: r.validatingFields,
769
- isValidating: !Z(r.validatingFields)
764
+ }, $ = (s, a) => {
765
+ !r.disabled && (V.isValidating || V.validatingFields || A.isValidating || A.validatingFields) && ((s || Array.from(f.mount)).forEach((l) => {
766
+ l && (a ? j(t.validatingFields, l, a) : Y(t.validatingFields, l));
767
+ }), v.state.next({
768
+ validatingFields: t.validatingFields,
769
+ isValidating: !G(t.validatingFields)
770
770
  }));
771
- }, w = (n, i = [], u, v, y = !0, f = !0) => {
772
- if (v && u && !t.disabled) {
773
- if (l.action = !0, f && Array.isArray(g(s, n))) {
774
- const b = u(g(s, n), v.argA, v.argB);
775
- y && N(s, n, b);
771
+ }, E = (s, a = [], l, m, y = !0, d = !0) => {
772
+ if (m && l && !r.disabled) {
773
+ if (u.action = !0, d && Array.isArray(h(n, s))) {
774
+ const b = l(h(n, s), m.argA, m.argB);
775
+ y && j(n, s, b);
776
776
  }
777
- if (f && Array.isArray(g(r.errors, n))) {
778
- const b = u(g(r.errors, n), v.argA, v.argB);
779
- y && N(r.errors, n, b), At(r.errors, n);
777
+ if (d && Array.isArray(h(t.errors, s))) {
778
+ const b = l(h(t.errors, s), m.argA, m.argB);
779
+ y && j(t.errors, s, b), fr(t.errors, s);
780
780
  }
781
- if ((x.touchedFields || R.touchedFields) && f && Array.isArray(g(r.touchedFields, n))) {
782
- const b = u(g(r.touchedFields, n), v.argA, v.argB);
783
- y && N(r.touchedFields, n, b);
781
+ if ((V.touchedFields || A.touchedFields) && d && Array.isArray(h(t.touchedFields, s))) {
782
+ const b = l(h(t.touchedFields, s), m.argA, m.argB);
783
+ y && j(t.touchedFields, s, b);
784
784
  }
785
- (x.dirtyFields || R.dirtyFields) && (r.dirtyFields = Ve(o, a)), h.state.next({
786
- name: n,
787
- isDirty: k(n, i),
788
- dirtyFields: r.dirtyFields,
789
- errors: r.errors,
790
- isValid: r.isValid
785
+ (V.dirtyFields || A.dirtyFields) && (t.dirtyFields = Fe(o, i)), v.state.next({
786
+ name: s,
787
+ isDirty: x(s, a),
788
+ dirtyFields: t.dirtyFields,
789
+ errors: t.errors,
790
+ isValid: t.isValid
791
791
  });
792
792
  } else
793
- N(a, n, i);
794
- }, D = (n, i) => {
795
- N(r.errors, n, i), h.state.next({
796
- errors: r.errors
793
+ j(i, s, a);
794
+ }, H = (s, a) => {
795
+ j(t.errors, s, a), v.state.next({
796
+ errors: t.errors
797
797
  });
798
- }, _ = (n) => {
799
- r.errors = n, h.state.next({
800
- errors: r.errors,
798
+ }, D = (s) => {
799
+ t.errors = s, v.state.next({
800
+ errors: t.errors,
801
801
  isValid: !1
802
802
  });
803
- }, m = (n, i, u, v) => {
804
- const y = g(s, n);
803
+ }, _ = (s, a, l, m) => {
804
+ const y = h(n, s);
805
805
  if (y) {
806
- const f = g(a, n, I(u) ? g(o, n) : u);
807
- I(f) || v && v.defaultChecked || i ? N(a, n, i ? f : Er(y._f)) : J(n, f), l.mount && !l.action && W();
806
+ const d = h(i, s, U(l) ? h(o, s) : l);
807
+ U(d) || m && m.defaultChecked || a ? j(i, s, a ? d : yt(y._f)) : W(s, d), u.mount && !u.action && B();
808
808
  }
809
- }, F = (n, i, u, v, y) => {
810
- let f = !1, b = !1;
811
- const O = {
812
- name: n
809
+ }, X = (s, a, l, m, y) => {
810
+ let d = !1, b = !1;
811
+ const S = {
812
+ name: s
813
813
  };
814
- if (!t.disabled) {
815
- if (!u || v) {
816
- (x.isDirty || R.isDirty) && (b = r.isDirty, r.isDirty = O.isDirty = k(), f = b !== O.isDirty);
817
- const P = ue(g(o, n), i);
818
- b = !!g(r.dirtyFields, n), P ? H(r.dirtyFields, n) : N(r.dirtyFields, n, !0), O.dirtyFields = r.dirtyFields, f = f || (x.dirtyFields || R.dirtyFields) && b !== !P;
814
+ if (!r.disabled) {
815
+ if (!l || m) {
816
+ (V.isDirty || A.isDirty) && (b = t.isDirty, t.isDirty = S.isDirty = x(), d = b !== S.isDirty);
817
+ const T = ne(h(o, s), a);
818
+ b = !!h(t.dirtyFields, s), T ? Y(t.dirtyFields, s) : j(t.dirtyFields, s, !0), S.dirtyFields = t.dirtyFields, d = d || (V.dirtyFields || A.dirtyFields) && b !== !T;
819
819
  }
820
- if (u) {
821
- const P = g(r.touchedFields, n);
822
- P || (N(r.touchedFields, n, u), O.touchedFields = r.touchedFields, f = f || (x.touchedFields || R.touchedFields) && P !== u);
820
+ if (l) {
821
+ const T = h(t.touchedFields, s);
822
+ T || (j(t.touchedFields, s, l), S.touchedFields = t.touchedFields, d = d || (V.touchedFields || A.touchedFields) && T !== l);
823
823
  }
824
- f && y && h.state.next(O);
824
+ d && y && v.state.next(S);
825
825
  }
826
- return f ? O : {};
827
- }, j = (n, i, u, v) => {
828
- const y = g(r.errors, n), f = (x.isValid || R.isValid) && ce(i) && r.isValid !== i;
829
- if (t.delayError && u ? (A = $(() => D(n, u)), A(t.delayError)) : (clearTimeout(p), A = null, u ? N(r.errors, n, u) : H(r.errors, n)), (u ? !ue(y, u) : y) || !Z(v) || f) {
826
+ return d ? S : {};
827
+ }, ce = (s, a, l, m) => {
828
+ const y = h(t.errors, s), d = (V.isValid || A.isValid) && oe(a) && t.isValid !== a;
829
+ if (r.delayError && l ? (w = M(() => H(s, l)), w(r.delayError)) : (clearTimeout(p), w = null, l ? j(t.errors, s, l) : Y(t.errors, s)), (l ? !ne(y, l) : y) || !G(m) || d) {
830
830
  const b = {
831
- ...v,
832
- ...f && ce(i) ? { isValid: i } : {},
833
- errors: r.errors,
834
- name: n
831
+ ...m,
832
+ ...d && oe(a) ? { isValid: a } : {},
833
+ errors: t.errors,
834
+ name: s
835
835
  };
836
- r = {
837
- ...r,
836
+ t = {
837
+ ...t,
838
838
  ...b
839
- }, h.state.next(b);
839
+ }, v.state.next(b);
840
840
  }
841
- }, Q = async (n) => (B(n, !0), await t.resolver(a, t.context, vt(n || d.mount, s, t.criteriaMode, t.shouldUseNativeValidation))), se = async (n) => {
842
- const { errors: i } = await Q(n);
843
- if (B(n), n)
844
- for (const u of n) {
845
- const v = g(i, u);
846
- v ? N(r.errors, u, v) : H(r.errors, u);
841
+ }, le = async (s) => ($(s, !0), await r.resolver(i, r.context, ir(s || f.mount, n, r.criteriaMode, r.shouldUseNativeValidation))), ie = async (s) => {
842
+ const { errors: a } = await le(s);
843
+ if ($(s), s)
844
+ for (const l of s) {
845
+ const m = h(a, l);
846
+ m ? j(t.errors, l, m) : Y(t.errors, l);
847
847
  }
848
848
  else
849
- r.errors = i;
850
- return i;
851
- }, K = async (n, i, u = {
849
+ t.errors = a;
850
+ return a;
851
+ }, Z = async (s, a, l = {
852
852
  valid: !0
853
853
  }) => {
854
- for (const v in n) {
855
- const y = n[v];
854
+ for (const m in s) {
855
+ const y = s[m];
856
856
  if (y) {
857
- const { _f: f, ...b } = y;
858
- if (f) {
859
- const O = d.array.has(f.name), P = y._f && gt(y._f);
860
- P && x.validatingFields && B([f.name], !0);
861
- const ae = await sr(y, d.disabled, a, M, t.shouldUseNativeValidation && !i, O);
862
- if (P && x.validatingFields && B([f.name]), ae[f.name] && (u.valid = !1, i))
857
+ const { _f: d, ...b } = y;
858
+ if (d) {
859
+ const S = f.array.has(d.name), T = y._f && ar(y._f);
860
+ T && V.validatingFields && $([d.name], !0);
861
+ const te = await _t(y, f.disabled, i, N, r.shouldUseNativeValidation && !a, S);
862
+ if (T && V.validatingFields && $([d.name]), te[d.name] && (l.valid = !1, a))
863
863
  break;
864
- !i && (g(ae, f.name) ? O ? Lr(r.errors, ae, f.name) : N(r.errors, f.name, ae[f.name]) : H(r.errors, f.name));
864
+ !a && (h(te, d.name) ? S ? dr(t.errors, te, d.name) : j(t.errors, d.name, te[d.name]) : Y(t.errors, d.name));
865
865
  }
866
- !Z(b) && await K(b, i, u);
866
+ !G(b) && await Z(b, a, l);
867
867
  }
868
868
  }
869
- return u.valid;
870
- }, be = () => {
871
- for (const n of d.unMount) {
872
- const i = g(s, n);
873
- i && (i._f.refs ? i._f.refs.every((u) => !Ye(u)) : !Ye(i._f.ref)) && le(n);
869
+ return l.valid;
870
+ }, ge = () => {
871
+ for (const s of f.unMount) {
872
+ const a = h(n, s);
873
+ a && (a._f.refs ? a._f.refs.every((l) => !$e(l)) : !$e(a._f.ref)) && ae(s);
874
874
  }
875
- d.unMount = /* @__PURE__ */ new Set();
876
- }, k = (n, i) => !t.disabled && (n && i && N(a, n, i), !ue(c(), o)), S = (n, i, u) => Ke(n, d, {
877
- ...l.mount ? a : I(i) ? o : ne(n) ? { [n]: i } : i
878
- }, u, i), q = (n) => Me(g(l.mount ? a : o, n, t.shouldUnregister ? g(o, n, []) : [])), J = (n, i, u = {}) => {
879
- const v = g(s, n);
880
- let y = i;
881
- if (v) {
882
- const f = v._f;
883
- f && (!f.disabled && N(a, n, Nr(i, f)), y = Ne(f.ref) && re(i) ? "" : i, Cr(f.ref) ? [...f.ref.options].forEach((b) => b.selected = y.includes(b.value)) : f.refs ? De(f.ref) ? f.refs.forEach((b) => {
884
- (!b.defaultChecked || !b.disabled) && (Array.isArray(y) ? b.checked = !!y.find((O) => O === b.value) : b.checked = y === b.value || !!y);
885
- }) : f.refs.forEach((b) => b.checked = b.value === y) : ur(f.ref) ? f.ref.value = "" : (f.ref.value = y, f.ref.type || h.state.next({
886
- name: n,
887
- values: U(a)
875
+ f.unMount = /* @__PURE__ */ new Set();
876
+ }, x = (s, a) => !r.disabled && (s && a && j(i, s, a), !ne(c(), o)), R = (s, a, l) => We(s, f, {
877
+ ...u.mount ? i : U(a) ? o : ee(s) ? { [s]: a } : a
878
+ }, l, a), I = (s) => He(h(u.mount ? i : o, s, r.shouldUnregister ? h(o, s, []) : [])), W = (s, a, l = {}) => {
879
+ const m = h(n, s);
880
+ let y = a;
881
+ if (m) {
882
+ const d = m._f;
883
+ d && (!d.disabled && j(i, s, pt(a, d)), y = je(d.ref) && K(a) ? "" : a, Ft(d.ref) ? [...d.ref.options].forEach((b) => b.selected = y.includes(b.value)) : d.refs ? Te(d.ref) ? d.refs.forEach((b) => {
884
+ (!b.defaultChecked || !b.disabled) && (Array.isArray(y) ? b.checked = !!y.find((S) => S === b.value) : b.checked = y === b.value || !!y);
885
+ }) : d.refs.forEach((b) => b.checked = b.value === y) : Ze(d.ref) ? d.ref.value = "" : (d.ref.value = y, d.ref.type || v.state.next({
886
+ name: s,
887
+ values: z(i)
888
888
  })));
889
889
  }
890
- (u.shouldDirty || u.shouldTouch) && F(n, y, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && me(n);
891
- }, ee = (n, i, u) => {
892
- for (const v in i) {
893
- if (!i.hasOwnProperty(v))
890
+ (l.shouldDirty || l.shouldTouch) && X(s, y, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && ye(s);
891
+ }, Q = (s, a, l) => {
892
+ for (const m in a) {
893
+ if (!a.hasOwnProperty(m))
894
894
  return;
895
- const y = i[v], f = n + "." + v, b = g(s, f);
896
- (d.array.has(n) || G(y) || b && !b._f) && !he(y) ? ee(f, y, u) : J(f, y, u);
895
+ const y = a[m], d = s + "." + m, b = h(n, d);
896
+ (f.array.has(s) || q(y) || b && !b._f) && !ve(y) ? Q(d, y, l) : W(d, y, l);
897
897
  }
898
- }, X = (n, i, u = {}) => {
899
- const v = g(s, n), y = d.array.has(n), f = U(i);
900
- N(a, n, f), y ? (h.array.next({
901
- name: n,
902
- values: U(a)
903
- }), (x.isDirty || x.dirtyFields || R.isDirty || R.dirtyFields) && u.shouldDirty && h.state.next({
904
- name: n,
905
- dirtyFields: Ve(o, a),
906
- isDirty: k(n, f)
907
- })) : v && !v._f && !re(f) ? ee(n, f, u) : J(n, f, u), tr(n, d) && h.state.next({ ...r, name: n }), h.state.next({
908
- name: l.mount ? n : void 0,
909
- values: U(a)
898
+ }, J = (s, a, l = {}) => {
899
+ const m = h(n, s), y = f.array.has(s), d = z(a);
900
+ j(i, s, d), y ? (v.array.next({
901
+ name: s,
902
+ values: z(i)
903
+ }), (V.isDirty || V.dirtyFields || A.isDirty || A.dirtyFields) && l.shouldDirty && v.state.next({
904
+ name: s,
905
+ dirtyFields: Fe(o, i),
906
+ isDirty: x(s, d)
907
+ })) : m && !m._f && !K(d) ? Q(s, d, l) : W(s, d, l), vt(s, f) && v.state.next({ ...t, name: s }), v.state.next({
908
+ name: u.mount ? s : void 0,
909
+ values: z(i)
910
910
  });
911
- }, fe = async (n) => {
912
- l.mount = !0;
913
- const i = n.target;
914
- let u = i.name, v = !0;
915
- const y = g(s, u), f = (P) => {
916
- v = Number.isNaN(P) || he(P) && isNaN(P.getTime()) || ue(P, g(a, u, P));
917
- }, b = Ee(t.mode), O = Ee(t.reValidateMode);
911
+ }, fe = async (s) => {
912
+ u.mount = !0;
913
+ const a = s.target;
914
+ let l = a.name, m = !0;
915
+ const y = h(n, l), d = (T) => {
916
+ m = Number.isNaN(T) || ve(T) && isNaN(T.getTime()) || ne(T, h(i, l, T));
917
+ }, b = mt(r.mode), S = mt(r.reValidateMode);
918
918
  if (y) {
919
- let P, ae;
920
- const Ce = i.type ? Er(y._f) : at(n), _e = n.type === xr.BLUR || n.type === xr.FOCUS_OUT, Jr = !ht(y._f) && !t.resolver && !g(r.errors, u) && !y._f.deps || pt(_e, g(r.touchedFields, u), r.isSubmitted, O, b), $e = tr(u, d, _e);
921
- N(a, u, Ce), _e ? (!i || !i.readOnly) && (y._f.onBlur && y._f.onBlur(n), A && A(0)) : y._f.onChange && y._f.onChange(n);
922
- const We = F(u, Ce, _e), Gr = !Z(We) || $e;
923
- if (!_e && h.state.next({
924
- name: u,
925
- type: n.type,
926
- values: U(a)
927
- }), Jr)
928
- return (x.isValid || R.isValid) && (t.mode === "onBlur" ? _e && W() : _e || W()), Gr && h.state.next({ name: u, ...$e ? {} : We });
929
- if (!_e && $e && h.state.next({ ...r }), t.resolver) {
930
- const { errors: _r } = await Q([u]);
931
- if (B([u]), f(Ce), v) {
932
- const Xr = kr(r.errors, s, u), vr = kr(_r, s, Xr.name || u);
933
- P = vr.error, u = vr.name, ae = Z(_r);
919
+ let T, te;
920
+ const Oe = a.type ? yt(y._f) : Jt(s), me = s.type === lt.BLUR || s.type === lt.FOCUS_OUT, It = !or(y._f) && !r.resolver && !h(t.errors, l) && !y._f.deps || cr(me, h(t.touchedFields, l), t.isSubmitted, S, b), Me = vt(l, f, me);
921
+ j(i, l, Oe), me ? (!a || !a.readOnly) && (y._f.onBlur && y._f.onBlur(s), w && w(0)) : y._f.onChange && y._f.onChange(s);
922
+ const Be = X(l, Oe, me), Lt = !G(Be) || Me;
923
+ if (!me && v.state.next({
924
+ name: l,
925
+ type: s.type,
926
+ values: z(i)
927
+ }), It)
928
+ return (V.isValid || A.isValid) && (r.mode === "onBlur" ? me && B() : me || B()), Lt && v.state.next({ name: l, ...Me ? {} : Be });
929
+ if (!me && Me && v.state.next({ ...t }), r.resolver) {
930
+ const { errors: st } = await le([l]);
931
+ if ($([l]), d(Oe), m) {
932
+ const Ut = bt(t.errors, n, l), nt = bt(st, n, Ut.name || l);
933
+ T = nt.error, l = nt.name, te = G(st);
934
934
  }
935
935
  } else
936
- B([u], !0), P = (await sr(y, d.disabled, a, M, t.shouldUseNativeValidation))[u], B([u]), f(Ce), v && (P ? ae = !1 : (x.isValid || R.isValid) && (ae = await K(s, !0)));
937
- v && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && me(y._f.deps), j(u, ae, P, We));
936
+ $([l], !0), T = (await _t(y, f.disabled, i, N, r.shouldUseNativeValidation))[l], $([l]), d(Oe), m && (T ? te = !1 : (V.isValid || A.isValid) && (te = await Z(n, !0)));
937
+ m && (y._f.deps && (!Array.isArray(y._f.deps) || y._f.deps.length > 0) && ye(y._f.deps), ce(l, te, T, Be));
938
938
  }
939
- }, ye = (n, i) => {
940
- if (g(r.errors, i) && n.focus)
941
- return n.focus(), 1;
942
- }, me = async (n, i = {}) => {
943
- let u, v;
944
- const y = te(n);
945
- if (t.resolver) {
946
- const f = await se(I(n) ? n : y);
947
- u = Z(f), v = n ? !y.some((b) => g(f, b)) : u;
948
- } else n ? (v = (await Promise.all(y.map(async (f) => {
949
- const b = g(s, f);
950
- return await K(b && b._f ? { [f]: b } : b);
951
- }))).every(Boolean), !(!v && !r.isValid) && W()) : v = u = await K(s);
952
- return h.state.next({
953
- ...!ne(n) || (x.isValid || R.isValid) && u !== r.isValid ? {} : { name: n },
954
- ...t.resolver || !n ? { isValid: u } : {},
955
- errors: r.errors
956
- }), i.shouldFocus && !v && we(s, ye, n ? y : d.mount), v;
957
- }, c = (n, i) => {
958
- let u = {
959
- ...l.mount ? a : o
939
+ }, de = (s, a) => {
940
+ if (h(t.errors, a) && s.focus)
941
+ return s.focus(), 1;
942
+ }, ye = async (s, a = {}) => {
943
+ let l, m;
944
+ const y = ke(s);
945
+ if (r.resolver) {
946
+ const d = await ie(U(s) ? s : y);
947
+ l = G(d), m = s ? !y.some((b) => h(d, b)) : l;
948
+ } else s ? (m = (await Promise.all(y.map(async (d) => {
949
+ const b = h(n, d);
950
+ return await Z(b && b._f ? { [d]: b } : b);
951
+ }))).every(Boolean), !(!m && !t.isValid) && B()) : m = l = await Z(n);
952
+ return v.state.next({
953
+ ...!ee(s) || (V.isValid || A.isValid) && l !== t.isValid ? {} : { name: s },
954
+ ...r.resolver || !s ? { isValid: l } : {},
955
+ errors: t.errors
956
+ }), a.shouldFocus && !m && Se(n, de, s ? y : f.mount), m;
957
+ }, c = (s, a) => {
958
+ let l = {
959
+ ...u.mount ? i : o
960
960
  };
961
- return i && (u = Dr(i.dirtyFields ? r.dirtyFields : r.touchedFields, u)), I(n) ? u : ne(n) ? g(u, n) : n.map((v) => g(u, v));
962
- }, E = (n, i) => ({
963
- invalid: !!g((i || r).errors, n),
964
- isDirty: !!g((i || r).dirtyFields, n),
965
- error: g((i || r).errors, n),
966
- isValidating: !!g(r.validatingFields, n),
967
- isTouched: !!g((i || r).touchedFields, n)
968
- }), L = (n) => {
969
- n && te(n).forEach((i) => H(r.errors, i)), h.state.next({
970
- errors: n ? r.errors : {}
961
+ return a && (l = Vt(a.dirtyFields ? t.dirtyFields : t.touchedFields, l)), U(s) ? l : ee(s) ? h(l, s) : s.map((m) => h(l, m));
962
+ }, g = (s, a) => ({
963
+ invalid: !!h((a || t).errors, s),
964
+ isDirty: !!h((a || t).dirtyFields, s),
965
+ error: h((a || t).errors, s),
966
+ isValidating: !!h(t.validatingFields, s),
967
+ isTouched: !!h((a || t).touchedFields, s)
968
+ }), C = (s) => {
969
+ s && ke(s).forEach((a) => Y(t.errors, a)), v.state.next({
970
+ errors: s ? t.errors : {}
971
971
  });
972
- }, Y = (n, i, u) => {
973
- const v = (g(s, n, { _f: {} })._f || {}).ref, y = g(r.errors, n) || {}, { ref: f, message: b, type: O, ...P } = y;
974
- N(r.errors, n, {
975
- ...P,
976
- ...i,
977
- ref: v
978
- }), h.state.next({
979
- name: n,
980
- errors: r.errors,
972
+ }, P = (s, a, l) => {
973
+ const m = (h(n, s, { _f: {} })._f || {}).ref, y = h(t.errors, s) || {}, { ref: d, message: b, type: S, ...T } = y;
974
+ j(t.errors, s, {
975
+ ...T,
976
+ ...a,
977
+ ref: m
978
+ }), v.state.next({
979
+ name: s,
980
+ errors: t.errors,
981
981
  isValid: !1
982
- }), u && u.shouldFocus && v && v.focus && v.focus();
983
- }, xe = (n, i) => oe(n) ? h.state.subscribe({
984
- next: (u) => "values" in u && n(S(void 0, i), u)
985
- }) : S(n, i, !0), pe = (n) => h.state.subscribe({
986
- next: (i) => {
987
- xt(n.name, i.name, n.exact) && bt(i, n.formState || x, Hr, n.reRenderRoot) && n.callback({
988
- values: { ...a },
989
- ...r,
990
- ...i,
982
+ }), l && l.shouldFocus && m && m.focus && m.focus();
983
+ }, _e = (s, a) => re(s) ? v.state.subscribe({
984
+ next: (l) => "values" in l && s(R(void 0, a), l)
985
+ }) : R(s, a, !0), xe = (s) => v.state.subscribe({
986
+ next: (a) => {
987
+ ur(s.name, a.name, s.exact) && lr(a, s.formState || V, Nt, s.reRenderRoot) && s.callback({
988
+ values: { ...i },
989
+ ...t,
990
+ ...a,
991
991
  defaultValues: o
992
992
  });
993
993
  }
994
- }).unsubscribe, z = (n) => (l.mount = !0, R = {
995
- ...R,
996
- ...n.formState
997
- }, pe({
998
- ...n,
994
+ }).unsubscribe, L = (s) => (u.mount = !0, A = {
995
+ ...A,
996
+ ...s.formState
997
+ }, xe({
998
+ ...s,
999
999
  formState: {
1000
- ...C,
1001
- ...n.formState
1000
+ ...O,
1001
+ ...s.formState
1002
1002
  }
1003
- })), le = (n, i = {}) => {
1004
- for (const u of n ? te(n) : d.mount)
1005
- d.mount.delete(u), d.array.delete(u), i.keepValue || (H(s, u), H(a, u)), !i.keepError && H(r.errors, u), !i.keepDirty && H(r.dirtyFields, u), !i.keepTouched && H(r.touchedFields, u), !i.keepIsValidating && H(r.validatingFields, u), !t.shouldUnregister && !i.keepDefaultValue && H(o, u);
1006
- h.state.next({
1007
- values: U(a)
1008
- }), h.state.next({
1009
- ...r,
1010
- ...i.keepDirty ? { isDirty: k() } : {}
1011
- }), !i.keepIsValid && W();
1012
- }, Ae = ({ disabled: n, name: i }) => {
1013
- (ce(n) && l.mount || n || d.disabled.has(i)) && (n ? d.disabled.add(i) : d.disabled.delete(i));
1014
- }, ke = (n, i = {}) => {
1015
- let u = g(s, n);
1016
- const v = ce(i.disabled) || ce(t.disabled);
1017
- return N(s, n, {
1018
- ...u || {},
1003
+ })), ae = (s, a = {}) => {
1004
+ for (const l of s ? ke(s) : f.mount)
1005
+ f.mount.delete(l), f.array.delete(l), a.keepValue || (Y(n, l), Y(i, l)), !a.keepError && Y(t.errors, l), !a.keepDirty && Y(t.dirtyFields, l), !a.keepTouched && Y(t.touchedFields, l), !a.keepIsValidating && Y(t.validatingFields, l), !r.shouldUnregister && !a.keepDefaultValue && Y(o, l);
1006
+ v.state.next({
1007
+ values: z(i)
1008
+ }), v.state.next({
1009
+ ...t,
1010
+ ...a.keepDirty ? { isDirty: x() } : {}
1011
+ }), !a.keepIsValid && B();
1012
+ }, Ee = ({ disabled: s, name: a }) => {
1013
+ (oe(s) && u.mount || s || f.disabled.has(a)) && (s ? f.disabled.add(a) : f.disabled.delete(a));
1014
+ }, we = (s, a = {}) => {
1015
+ let l = h(n, s);
1016
+ const m = oe(a.disabled) || oe(r.disabled);
1017
+ return j(n, s, {
1018
+ ...l || {},
1019
1019
  _f: {
1020
- ...u && u._f ? u._f : { ref: { name: n } },
1021
- name: n,
1020
+ ...l && l._f ? l._f : { ref: { name: s } },
1021
+ name: s,
1022
1022
  mount: !0,
1023
- ...i
1023
+ ...a
1024
1024
  }
1025
- }), d.mount.add(n), u ? Ae({
1026
- disabled: ce(i.disabled) ? i.disabled : t.disabled,
1027
- name: n
1028
- }) : m(n, !0, i.value), {
1029
- ...v ? { disabled: i.disabled || t.disabled } : {},
1030
- ...t.progressive ? {
1031
- required: !!i.required,
1032
- min: Te(i.min),
1033
- max: Te(i.max),
1034
- minLength: Te(i.minLength),
1035
- maxLength: Te(i.maxLength),
1036
- pattern: Te(i.pattern)
1025
+ }), f.mount.add(s), l ? Ee({
1026
+ disabled: oe(a.disabled) ? a.disabled : r.disabled,
1027
+ name: s
1028
+ }) : _(s, !0, a.value), {
1029
+ ...m ? { disabled: a.disabled || r.disabled } : {},
1030
+ ...r.progressive ? {
1031
+ required: !!a.required,
1032
+ min: Re(a.min),
1033
+ max: Re(a.max),
1034
+ minLength: Re(a.minLength),
1035
+ maxLength: Re(a.maxLength),
1036
+ pattern: Re(a.pattern)
1037
1037
  } : {},
1038
- name: n,
1038
+ name: s,
1039
1039
  onChange: fe,
1040
1040
  onBlur: fe,
1041
1041
  ref: (y) => {
1042
1042
  if (y) {
1043
- ke(n, i), u = g(s, n);
1044
- const f = I(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, b = ft(f), O = u._f.refs || [];
1045
- if (b ? O.find((P) => P === f) : f === u._f.ref)
1043
+ we(s, a), l = h(n, s);
1044
+ const d = U(y.value) && y.querySelectorAll && y.querySelectorAll("input,select,textarea")[0] || y, b = tr(d), S = l._f.refs || [];
1045
+ if (b ? S.find((T) => T === d) : d === l._f.ref)
1046
1046
  return;
1047
- N(s, n, {
1047
+ j(n, s, {
1048
1048
  _f: {
1049
- ...u._f,
1049
+ ...l._f,
1050
1050
  ...b ? {
1051
1051
  refs: [
1052
- ...O.filter(Ye),
1053
- f,
1054
- ...Array.isArray(g(o, n)) ? [{}] : []
1052
+ ...S.filter($e),
1053
+ d,
1054
+ ...Array.isArray(h(o, s)) ? [{}] : []
1055
1055
  ],
1056
- ref: { type: f.type, name: n }
1057
- } : { ref: f }
1056
+ ref: { type: d.type, name: s }
1057
+ } : { ref: d }
1058
1058
  }
1059
- }), m(n, !1, void 0, f);
1059
+ }), _(s, !1, void 0, d);
1060
1060
  } else
1061
- u = g(s, n, {}), u._f && (u._f.mount = !1), (t.shouldUnregister || i.shouldUnregister) && !(ot(d.array, n) && l.action) && d.unMount.add(n);
1061
+ l = h(n, s, {}), l._f && (l._f.mount = !1), (r.shouldUnregister || a.shouldUnregister) && !(Xt(f.array, s) && u.action) && f.unMount.add(s);
1062
1062
  }
1063
1063
  };
1064
- }, Be = () => t.shouldFocusError && we(s, ye, d.mount), Yr = (n) => {
1065
- ce(n) && (h.state.next({ disabled: n }), we(s, (i, u) => {
1066
- const v = g(s, u);
1067
- v && (i.disabled = v._f.disabled || n, Array.isArray(v._f.refs) && v._f.refs.forEach((y) => {
1068
- y.disabled = v._f.disabled || n;
1064
+ }, Ue = () => r.shouldFocusError && Se(n, de, f.mount), Ct = (s) => {
1065
+ oe(s) && (v.state.next({ disabled: s }), Se(n, (a, l) => {
1066
+ const m = h(n, l);
1067
+ m && (a.disabled = m._f.disabled || s, Array.isArray(m._f.refs) && m._f.refs.forEach((y) => {
1068
+ y.disabled = m._f.disabled || s;
1069
1069
  }));
1070
1070
  }, 0, !1));
1071
- }, dr = (n, i) => async (u) => {
1072
- let v;
1073
- u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
1074
- let y = U(a);
1075
- if (h.state.next({
1071
+ }, Ke = (s, a) => async (l) => {
1072
+ let m;
1073
+ l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
1074
+ let y = z(i);
1075
+ if (v.state.next({
1076
1076
  isSubmitting: !0
1077
- }), t.resolver) {
1078
- const { errors: f, values: b } = await Q();
1079
- B(), r.errors = f, y = U(b);
1077
+ }), r.resolver) {
1078
+ const { errors: d, values: b } = await le();
1079
+ $(), t.errors = d, y = z(b);
1080
1080
  } else
1081
- await K(s);
1082
- if (d.disabled.size)
1083
- for (const f of d.disabled)
1084
- H(y, f);
1085
- if (H(r.errors, "root"), Z(r.errors)) {
1086
- h.state.next({
1081
+ await Z(n);
1082
+ if (f.disabled.size)
1083
+ for (const d of f.disabled)
1084
+ Y(y, d);
1085
+ if (Y(t.errors, "root"), G(t.errors)) {
1086
+ v.state.next({
1087
1087
  errors: {}
1088
1088
  });
1089
1089
  try {
1090
- await n(y, u);
1091
- } catch (f) {
1092
- v = f;
1090
+ await s(y, l);
1091
+ } catch (d) {
1092
+ m = d;
1093
1093
  }
1094
1094
  } else
1095
- i && await i({ ...r.errors }, u), Be(), setTimeout(Be);
1096
- if (h.state.next({
1095
+ a && await a({ ...t.errors }, l), Ue(), setTimeout(Ue);
1096
+ if (v.state.next({
1097
1097
  isSubmitted: !0,
1098
1098
  isSubmitting: !1,
1099
- isSubmitSuccessful: Z(r.errors) && !v,
1100
- submitCount: r.submitCount + 1,
1101
- errors: r.errors
1102
- }), v)
1103
- throw v;
1104
- }, qr = (n, i = {}) => {
1105
- g(s, n) && (I(i.defaultValue) ? X(n, U(g(o, n))) : (X(n, i.defaultValue), N(o, n, U(i.defaultValue))), i.keepTouched || H(r.touchedFields, n), i.keepDirty || (H(r.dirtyFields, n), r.isDirty = i.defaultValue ? k(n, U(g(o, n))) : k()), i.keepError || (H(r.errors, n), x.isValid && W()), h.state.next({ ...r }));
1106
- }, fr = (n, i = {}) => {
1107
- const u = n ? U(n) : o, v = U(u), y = Z(n), f = y ? o : v;
1108
- if (i.keepDefaultValues || (o = u), !i.keepValues) {
1109
- if (i.keepDirtyValues) {
1099
+ isSubmitSuccessful: G(t.errors) && !m,
1100
+ submitCount: t.submitCount + 1,
1101
+ errors: t.errors
1102
+ }), m)
1103
+ throw m;
1104
+ }, jt = (s, a = {}) => {
1105
+ h(n, s) && (U(a.defaultValue) ? J(s, z(h(o, s))) : (J(s, a.defaultValue), j(o, s, z(a.defaultValue))), a.keepTouched || Y(t.touchedFields, s), a.keepDirty || (Y(t.dirtyFields, s), t.isDirty = a.defaultValue ? x(s, z(h(o, s))) : x()), a.keepError || (Y(t.errors, s), V.isValid && B()), v.state.next({ ...t }));
1106
+ }, et = (s, a = {}) => {
1107
+ const l = s ? z(s) : o, m = z(l), y = G(s), d = y ? o : m;
1108
+ if (a.keepDefaultValues || (o = l), !a.keepValues) {
1109
+ if (a.keepDirtyValues) {
1110
1110
  const b = /* @__PURE__ */ new Set([
1111
- ...d.mount,
1112
- ...Object.keys(Ve(o, a))
1111
+ ...f.mount,
1112
+ ...Object.keys(Fe(o, i))
1113
1113
  ]);
1114
- for (const O of Array.from(b))
1115
- g(r.dirtyFields, O) ? N(f, O, g(a, O)) : X(O, g(f, O));
1114
+ for (const S of Array.from(b))
1115
+ h(t.dirtyFields, S) ? j(d, S, h(i, S)) : J(S, h(d, S));
1116
1116
  } else {
1117
- if (nr && I(n))
1118
- for (const b of d.mount) {
1119
- const O = g(s, b);
1120
- if (O && O._f) {
1121
- const P = Array.isArray(O._f.refs) ? O._f.refs[0] : O._f.ref;
1122
- if (Ne(P)) {
1123
- const ae = P.closest("form");
1124
- if (ae) {
1125
- ae.reset();
1117
+ if (ze && U(s))
1118
+ for (const b of f.mount) {
1119
+ const S = h(n, b);
1120
+ if (S && S._f) {
1121
+ const T = Array.isArray(S._f.refs) ? S._f.refs[0] : S._f.ref;
1122
+ if (je(T)) {
1123
+ const te = T.closest("form");
1124
+ if (te) {
1125
+ te.reset();
1126
1126
  break;
1127
1127
  }
1128
1128
  }
1129
1129
  }
1130
1130
  }
1131
- if (i.keepFieldsRef)
1132
- for (const b of d.mount)
1133
- X(b, g(f, b));
1131
+ if (a.keepFieldsRef)
1132
+ for (const b of f.mount)
1133
+ J(b, h(d, b));
1134
1134
  else
1135
- s = {};
1135
+ n = {};
1136
1136
  }
1137
- a = t.shouldUnregister ? i.keepDefaultValues ? U(o) : {} : U(f), h.array.next({
1138
- values: { ...f }
1139
- }), h.state.next({
1140
- values: { ...f }
1137
+ i = r.shouldUnregister ? a.keepDefaultValues ? z(o) : {} : z(d), v.array.next({
1138
+ values: { ...d }
1139
+ }), v.state.next({
1140
+ values: { ...d }
1141
1141
  });
1142
1142
  }
1143
- d = {
1144
- mount: i.keepDirtyValues ? d.mount : /* @__PURE__ */ new Set(),
1143
+ f = {
1144
+ mount: a.keepDirtyValues ? f.mount : /* @__PURE__ */ new Set(),
1145
1145
  unMount: /* @__PURE__ */ new Set(),
1146
1146
  array: /* @__PURE__ */ new Set(),
1147
1147
  disabled: /* @__PURE__ */ new Set(),
1148
1148
  watch: /* @__PURE__ */ new Set(),
1149
1149
  watchAll: !1,
1150
1150
  focus: ""
1151
- }, l.mount = !x.isValid || !!i.keepIsValid || !!i.keepDirtyValues || !t.shouldUnregister && !Z(f), l.watch = !!t.shouldUnregister, l.keepIsValid = !!i.keepIsValid, l.action = !1, i.keepErrors || (r.errors = {}), h.state.next({
1152
- submitCount: i.keepSubmitCount ? r.submitCount : 0,
1153
- isDirty: y ? !1 : i.keepDirty ? r.isDirty : !!(i.keepDefaultValues && !ue(n, o)),
1154
- isSubmitted: i.keepIsSubmitted ? r.isSubmitted : !1,
1155
- dirtyFields: y ? {} : i.keepDirtyValues ? i.keepDefaultValues && a ? Ve(o, a) : r.dirtyFields : i.keepDefaultValues && n ? Ve(o, n) : i.keepDirty ? r.dirtyFields : {},
1156
- touchedFields: i.keepTouched ? r.touchedFields : {},
1157
- errors: i.keepErrors ? r.errors : {},
1158
- isSubmitSuccessful: i.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
1151
+ }, u.mount = !V.isValid || !!a.keepIsValid || !!a.keepDirtyValues || !r.shouldUnregister && !G(d), u.watch = !!r.shouldUnregister, u.keepIsValid = !!a.keepIsValid, u.action = !1, a.keepErrors || (t.errors = {}), v.state.next({
1152
+ submitCount: a.keepSubmitCount ? t.submitCount : 0,
1153
+ isDirty: y ? !1 : a.keepDirty ? t.isDirty : !!(a.keepDefaultValues && !ne(s, o)),
1154
+ isSubmitted: a.keepIsSubmitted ? t.isSubmitted : !1,
1155
+ dirtyFields: y ? {} : a.keepDirtyValues ? a.keepDefaultValues && i ? Fe(o, i) : t.dirtyFields : a.keepDefaultValues && s ? Fe(o, s) : a.keepDirty ? t.dirtyFields : {},
1156
+ touchedFields: a.keepTouched ? t.touchedFields : {},
1157
+ errors: a.keepErrors ? t.errors : {},
1158
+ isSubmitSuccessful: a.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
1159
1159
  isSubmitting: !1,
1160
1160
  defaultValues: o
1161
1161
  });
1162
- }, yr = (n, i) => fr(oe(n) ? n(a) : n, { ...t.resetOptions, ...i }), zr = (n, i = {}) => {
1163
- const u = g(s, n), v = u && u._f;
1164
- if (v) {
1165
- const y = v.refs ? v.refs[0] : v.ref;
1162
+ }, tt = (s, a) => et(re(s) ? s(i) : s, { ...r.resetOptions, ...a }), Pt = (s, a = {}) => {
1163
+ const l = h(n, s), m = l && l._f;
1164
+ if (m) {
1165
+ const y = m.refs ? m.refs[0] : m.ref;
1166
1166
  y.focus && setTimeout(() => {
1167
- y.focus(), i.shouldSelect && oe(y.select) && y.select();
1167
+ y.focus(), a.shouldSelect && re(y.select) && y.select();
1168
1168
  });
1169
1169
  }
1170
- }, Hr = (n) => {
1171
- r = {
1172
- ...r,
1173
- ...n
1170
+ }, Nt = (s) => {
1171
+ t = {
1172
+ ...t,
1173
+ ...s
1174
1174
  };
1175
- }, mr = {
1175
+ }, rt = {
1176
1176
  control: {
1177
- register: ke,
1178
- unregister: le,
1179
- getFieldState: E,
1180
- handleSubmit: dr,
1181
- setError: Y,
1182
- _subscribe: pe,
1183
- _runSchema: Q,
1184
- _updateIsValidating: B,
1185
- _focusError: Be,
1186
- _getWatch: S,
1187
- _getDirty: k,
1188
- _setValid: W,
1189
- _setFieldArray: w,
1190
- _setDisabledField: Ae,
1191
- _setErrors: _,
1192
- _getFieldArray: q,
1193
- _reset: fr,
1194
- _resetDefaultValues: () => oe(t.defaultValues) && t.defaultValues().then((n) => {
1195
- yr(n, t.resetOptions), h.state.next({
1177
+ register: we,
1178
+ unregister: ae,
1179
+ getFieldState: g,
1180
+ handleSubmit: Ke,
1181
+ setError: P,
1182
+ _subscribe: xe,
1183
+ _runSchema: le,
1184
+ _updateIsValidating: $,
1185
+ _focusError: Ue,
1186
+ _getWatch: R,
1187
+ _getDirty: x,
1188
+ _setValid: B,
1189
+ _setFieldArray: E,
1190
+ _setDisabledField: Ee,
1191
+ _setErrors: D,
1192
+ _getFieldArray: I,
1193
+ _reset: et,
1194
+ _resetDefaultValues: () => re(r.defaultValues) && r.defaultValues().then((s) => {
1195
+ tt(s, r.resetOptions), v.state.next({
1196
1196
  isLoading: !1
1197
1197
  });
1198
1198
  }),
1199
- _removeUnmounted: be,
1200
- _disableForm: Yr,
1201
- _subjects: h,
1202
- _proxyFormState: x,
1199
+ _removeUnmounted: ge,
1200
+ _disableForm: Ct,
1201
+ _subjects: v,
1202
+ _proxyFormState: V,
1203
1203
  get _fields() {
1204
- return s;
1204
+ return n;
1205
1205
  },
1206
1206
  get _formValues() {
1207
- return a;
1207
+ return i;
1208
1208
  },
1209
1209
  get _state() {
1210
- return l;
1210
+ return u;
1211
1211
  },
1212
- set _state(n) {
1213
- l = n;
1212
+ set _state(s) {
1213
+ u = s;
1214
1214
  },
1215
1215
  get _defaultValues() {
1216
1216
  return o;
1217
1217
  },
1218
1218
  get _names() {
1219
- return d;
1219
+ return f;
1220
1220
  },
1221
- set _names(n) {
1222
- d = n;
1221
+ set _names(s) {
1222
+ f = s;
1223
1223
  },
1224
1224
  get _formState() {
1225
- return r;
1225
+ return t;
1226
1226
  },
1227
1227
  get _options() {
1228
- return t;
1228
+ return r;
1229
1229
  },
1230
- set _options(n) {
1231
- t = {
1232
- ...t,
1233
- ...n
1230
+ set _options(s) {
1231
+ r = {
1232
+ ...r,
1233
+ ...s
1234
1234
  };
1235
1235
  }
1236
1236
  },
1237
- subscribe: z,
1238
- trigger: me,
1239
- register: ke,
1240
- handleSubmit: dr,
1241
- watch: xe,
1242
- setValue: X,
1237
+ subscribe: L,
1238
+ trigger: ye,
1239
+ register: we,
1240
+ handleSubmit: Ke,
1241
+ watch: _e,
1242
+ setValue: J,
1243
1243
  getValues: c,
1244
- reset: yr,
1245
- resetField: qr,
1246
- clearErrors: L,
1247
- unregister: le,
1248
- setError: Y,
1249
- setFocus: zr,
1250
- getFieldState: E
1244
+ reset: tt,
1245
+ resetField: jt,
1246
+ clearErrors: C,
1247
+ unregister: ae,
1248
+ setError: P,
1249
+ setFocus: Pt,
1250
+ getFieldState: g
1251
1251
  };
1252
1252
  return {
1253
- ...mr,
1254
- formControl: mr
1253
+ ...rt,
1254
+ formControl: rt
1255
1255
  };
1256
1256
  }
1257
- var ve = () => {
1258
- if (typeof crypto < "u" && crypto.randomUUID)
1259
- return crypto.randomUUID();
1260
- const e = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
1261
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
1262
- const r = (Math.random() * 16 + e) % 16 | 0;
1263
- return (t == "x" ? r : r & 3 | 8).toString(16);
1264
- });
1265
- }, qe = (e, t, r = {}) => r.shouldFocus || I(r.shouldFocus) ? r.focusName || `${e}.${I(r.focusIndex) ? t : r.focusIndex}.` : "", ze = (e, t) => [
1266
- ...e,
1267
- ...te(t)
1268
- ], He = (e) => Array.isArray(e) ? e.map(() => {
1269
- }) : void 0;
1270
- function Je(e, t, r) {
1271
- return [
1272
- ...e.slice(0, t),
1273
- ...te(r),
1274
- ...e.slice(t)
1275
- ];
1276
- }
1277
- var Ge = (e, t, r) => Array.isArray(e) ? (I(e[r]) && (e[r] = void 0), e.splice(r, 0, e.splice(t, 1)[0]), e) : [], Xe = (e, t) => [
1278
- ...te(t),
1279
- ...te(e)
1280
- ];
1281
- function Et(e, t) {
1282
- let r = 0;
1283
- const s = [...e];
1284
- for (const o of t)
1285
- s.splice(o - r, 1), r++;
1286
- return Me(s).length ? s : [];
1287
- }
1288
- var Ze = (e, t) => I(t) ? [] : Et(e, te(t).sort((r, s) => r - s)), Qe = (e, t, r) => {
1289
- [e[t], e[r]] = [e[r], e[t]];
1290
- }, Sr = (e, t, r) => (e[t] = r, e);
1291
- function wt(e) {
1292
- const t = ge(), { control: r = t.control, name: s, keyName: o = "id", shouldUnregister: a, rules: l } = e, [d, A] = V.useState(r._getFieldArray(s)), p = V.useRef(r._getFieldArray(s).map(ve)), C = V.useRef(!1);
1293
- r._names.array.add(s), V.useMemo(() => l && d.length >= 0 && r.register(s, l), [r, s, d.length, l]), or(() => r._subjects.array.subscribe({
1294
- next: ({ values: _, name: m }) => {
1295
- if (m === s || !m) {
1296
- const F = g(_, s);
1297
- Array.isArray(F) && (A(F), p.current = F.map(ve));
1298
- }
1299
- }
1300
- }).unsubscribe, [r, s]);
1301
- const x = V.useCallback((_) => {
1302
- C.current = !0, r._setFieldArray(s, _);
1303
- }, [r, s]), R = (_, m) => {
1304
- const F = te(U(_)), j = ze(r._getFieldArray(s), F);
1305
- r._names.focus = qe(s, j.length - 1, m), p.current = ze(p.current, F.map(ve)), x(j), A(j), r._setFieldArray(s, j, ze, {
1306
- argA: He(_)
1307
- });
1308
- }, h = (_, m) => {
1309
- const F = te(U(_)), j = Xe(r._getFieldArray(s), F);
1310
- r._names.focus = qe(s, 0, m), p.current = Xe(p.current, F.map(ve)), x(j), A(j), r._setFieldArray(s, j, Xe, {
1311
- argA: He(_)
1312
- });
1313
- }, M = (_) => {
1314
- const m = Ze(r._getFieldArray(s), _);
1315
- p.current = Ze(p.current, _), x(m), A(m), !Array.isArray(g(r._fields, s)) && N(r._fields, s, void 0), r._setFieldArray(s, m, Ze, {
1316
- argA: _
1317
- });
1318
- }, $ = (_, m, F) => {
1319
- const j = te(U(m)), Q = Je(r._getFieldArray(s), _, j);
1320
- r._names.focus = qe(s, _, F), p.current = Je(p.current, _, j.map(ve)), x(Q), A(Q), r._setFieldArray(s, Q, Je, {
1321
- argA: _,
1322
- argB: He(m)
1323
- });
1324
- }, W = (_, m) => {
1325
- const F = r._getFieldArray(s);
1326
- Qe(F, _, m), Qe(p.current, _, m), x(F), A(F), r._setFieldArray(s, F, Qe, {
1327
- argA: _,
1328
- argB: m
1329
- }, !1);
1330
- }, B = (_, m) => {
1331
- const F = r._getFieldArray(s);
1332
- Ge(F, _, m), Ge(p.current, _, m), x(F), A(F), r._setFieldArray(s, F, Ge, {
1333
- argA: _,
1334
- argB: m
1335
- }, !1);
1336
- }, w = (_, m) => {
1337
- const F = U(m), j = Sr(r._getFieldArray(s), _, F);
1338
- p.current = [...j].map((Q, se) => !Q || se === _ ? ve() : p.current[se]), x(j), A([...j]), r._setFieldArray(s, j, Sr, {
1339
- argA: _,
1340
- argB: F
1341
- }, !0, !1);
1342
- }, D = (_) => {
1343
- const m = te(U(_));
1344
- p.current = m.map(ve), x([...m]), A([...m]), r._setFieldArray(s, [...m], (F) => F, {}, !0, !1);
1345
- };
1346
- return V.useEffect(() => {
1347
- if (r._state.action = !1, tr(s, r._names) && r._subjects.state.next({
1348
- ...r._formState
1349
- }), C.current && (!Ee(r._options.mode).isOnSubmit || r._formState.isSubmitted) && !Ee(r._options.reValidateMode).isOnSubmit)
1350
- if (r._options.resolver)
1351
- r._runSchema([s]).then((_) => {
1352
- r._updateIsValidating([s]);
1353
- const m = g(_.errors, s), F = g(r._formState.errors, s);
1354
- (F ? !m && F.type || m && (F.type !== m.type || F.message !== m.message) : m && m.type) && (m ? N(r._formState.errors, s, m) : H(r._formState.errors, s), r._subjects.state.next({
1355
- errors: r._formState.errors
1356
- }));
1357
- });
1358
- else {
1359
- const _ = g(r._fields, s);
1360
- _ && _._f && !(Ee(r._options.reValidateMode).isOnSubmit && Ee(r._options.mode).isOnSubmit) && sr(_, r._names.disabled, r._formValues, r._options.criteriaMode === ie.all, r._options.shouldUseNativeValidation, !0).then((m) => !Z(m) && r._subjects.state.next({
1361
- errors: Lr(r._formState.errors, m, s)
1362
- }));
1363
- }
1364
- r._subjects.state.next({
1365
- name: s,
1366
- values: U(r._formValues)
1367
- }), r._names.focus && we(r._fields, (_, m) => {
1368
- if (r._names.focus && m.startsWith(r._names.focus) && _.focus)
1369
- return _.focus(), 1;
1370
- }), r._names.focus = "", r._setValid(), C.current = !1;
1371
- }, [d, s, r]), V.useEffect(() => (!g(r._formValues, s) && r._setFieldArray(s), () => {
1372
- const _ = (m, F) => {
1373
- const j = g(r._fields, m);
1374
- j && j._f && (j._f.mount = F);
1375
- };
1376
- r._options.shouldUnregister || a ? r.unregister(s) : _(s, !1);
1377
- }), [s, r, o, a]), {
1378
- swap: V.useCallback(W, [x, s, r]),
1379
- move: V.useCallback(B, [x, s, r]),
1380
- prepend: V.useCallback(h, [x, s, r]),
1381
- append: V.useCallback(R, [x, s, r]),
1382
- remove: V.useCallback(M, [x, s, r]),
1383
- insert: V.useCallback($, [x, s, r]),
1384
- update: V.useCallback(w, [x, s, r]),
1385
- replace: V.useCallback(D, [x, s, r]),
1386
- fields: V.useMemo(() => d.map((_, m) => ({
1387
- ..._,
1388
- [o]: p.current[m] || ve()
1389
- })), [d, o])
1390
- };
1391
- }
1392
- function kt(e = {}) {
1393
- const t = V.useRef(void 0), r = V.useRef(void 0), [s, o] = V.useState({
1257
+ function hr(e = {}) {
1258
+ const r = k.useRef(void 0), t = k.useRef(void 0), [n, o] = k.useState({
1394
1259
  isDirty: !1,
1395
1260
  isValidating: !1,
1396
- isLoading: oe(e.defaultValues),
1261
+ isLoading: re(e.defaultValues),
1397
1262
  isSubmitted: !1,
1398
1263
  isSubmitting: !1,
1399
1264
  isSubmitSuccessful: !1,
@@ -1405,69 +1270,102 @@ function kt(e = {}) {
1405
1270
  errors: e.errors || {},
1406
1271
  disabled: e.disabled || !1,
1407
1272
  isReady: !1,
1408
- defaultValues: oe(e.defaultValues) ? void 0 : e.defaultValues
1273
+ defaultValues: re(e.defaultValues) ? void 0 : e.defaultValues
1409
1274
  });
1410
- if (!t.current)
1275
+ if (!r.current)
1411
1276
  if (e.formControl)
1412
- t.current = {
1277
+ r.current = {
1413
1278
  ...e.formControl,
1414
- formState: s
1415
- }, e.defaultValues && !oe(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1279
+ formState: n
1280
+ }, e.defaultValues && !re(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1416
1281
  else {
1417
- const { formControl: l, ...d } = Vt(e);
1418
- t.current = {
1419
- ...d,
1420
- formState: s
1282
+ const { formControl: u, ...f } = mr(e);
1283
+ r.current = {
1284
+ ...f,
1285
+ formState: n
1421
1286
  };
1422
1287
  }
1423
- const a = t.current.control;
1424
- return a._options = e, or(() => {
1425
- const l = a._subscribe({
1426
- formState: a._proxyFormState,
1427
- callback: () => o({ ...a._formState }),
1288
+ const i = r.current.control;
1289
+ return i._options = e, Et(() => {
1290
+ const u = i._subscribe({
1291
+ formState: i._proxyFormState,
1292
+ callback: () => o({ ...i._formState }),
1428
1293
  reRenderRoot: !0
1429
1294
  });
1430
- return o((d) => ({
1431
- ...d,
1295
+ return o((f) => ({
1296
+ ...f,
1432
1297
  isReady: !0
1433
- })), a._formState.isReady = !0, l;
1434
- }, [a]), V.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), V.useEffect(() => {
1435
- e.mode && (a._options.mode = e.mode), e.reValidateMode && (a._options.reValidateMode = e.reValidateMode);
1436
- }, [a, e.mode, e.reValidateMode]), V.useEffect(() => {
1437
- e.errors && (a._setErrors(e.errors), a._focusError());
1438
- }, [a, e.errors]), V.useEffect(() => {
1439
- e.shouldUnregister && a._subjects.state.next({
1440
- values: a._getWatch()
1298
+ })), i._formState.isReady = !0, u;
1299
+ }, [i]), k.useEffect(() => i._disableForm(e.disabled), [i, e.disabled]), k.useEffect(() => {
1300
+ e.mode && (i._options.mode = e.mode), e.reValidateMode && (i._options.reValidateMode = e.reValidateMode);
1301
+ }, [i, e.mode, e.reValidateMode]), k.useEffect(() => {
1302
+ e.errors && (i._setErrors(e.errors), i._focusError());
1303
+ }, [i, e.errors]), k.useEffect(() => {
1304
+ e.shouldUnregister && i._subjects.state.next({
1305
+ values: i._getWatch()
1441
1306
  });
1442
- }, [a, e.shouldUnregister]), V.useEffect(() => {
1443
- if (a._proxyFormState.isDirty) {
1444
- const l = a._getDirty();
1445
- l !== s.isDirty && a._subjects.state.next({
1446
- isDirty: l
1307
+ }, [i, e.shouldUnregister]), k.useEffect(() => {
1308
+ if (i._proxyFormState.isDirty) {
1309
+ const u = i._getDirty();
1310
+ u !== n.isDirty && i._subjects.state.next({
1311
+ isDirty: u
1447
1312
  });
1448
1313
  }
1449
- }, [a, s.isDirty]), V.useEffect(() => {
1450
- var l;
1451
- e.values && !ue(e.values, r.current) ? (a._reset(e.values, {
1314
+ }, [i, n.isDirty]), k.useEffect(() => {
1315
+ var u;
1316
+ e.values && !ne(e.values, t.current) ? (i._reset(e.values, {
1452
1317
  keepFieldsRef: !0,
1453
- ...a._options.resetOptions
1454
- }), !((l = a._options.resetOptions) === null || l === void 0) && l.keepIsValid || a._setValid(), r.current = e.values, o((d) => ({ ...d }))) : a._resetDefaultValues();
1455
- }, [a, e.values]), V.useEffect(() => {
1456
- a._state.mount || (a._setValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
1457
- }), t.current.formState = ct(s, a), t.current;
1318
+ ...i._options.resetOptions
1319
+ }), !((u = i._options.resetOptions) === null || u === void 0) && u.keepIsValid || i._setValid(), t.current = e.values, o((f) => ({ ...f }))) : i._resetDefaultValues();
1320
+ }, [i, e.values]), k.useEffect(() => {
1321
+ i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
1322
+ }), r.current.formState = Kt(n, i), r.current;
1458
1323
  }
1459
- function Rt(e, t) {
1460
- const r = {};
1461
- return e.forEach((s, o) => {
1462
- const a = s.split(".");
1463
- let l = r;
1464
- a.forEach((d, A) => {
1465
- const p = A === a.length - 1, C = !isNaN(Number(d));
1466
- p ? l[d] = t[o] : (d in l || (l[d] = C ? [] : {}), l = l[d]);
1324
+ const kt = Mt(null), vr = ({
1325
+ children: e,
1326
+ layout: r = "vertical",
1327
+ uiConfig: t,
1328
+ updateFieldSchema: n
1329
+ }) => {
1330
+ const o = he(
1331
+ () => ({
1332
+ layout: r,
1333
+ uiConfig: t,
1334
+ updateFieldSchema: n
1335
+ }),
1336
+ [r, t, n]
1337
+ );
1338
+ return /* @__PURE__ */ F.jsx(kt.Provider, { value: o, children: e });
1339
+ }, St = () => {
1340
+ const e = Bt(kt);
1341
+ if (!e)
1342
+ throw new Error("useAutoFormRenderContext must be used within AutoFormRenderContextProvider");
1343
+ return e;
1344
+ }, br = (e) => {
1345
+ const { fieldSchema: r } = e, { register: t } = be(), n = t(r.name);
1346
+ return /* @__PURE__ */ F.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
1347
+ /* @__PURE__ */ F.jsx("label", { children: r.label }),
1348
+ /* @__PURE__ */ F.jsx("input", { type: r.type, ...n, readOnly: r.readonly })
1349
+ ] });
1350
+ }, gr = (e) => {
1351
+ const { fieldSchema: r } = e, { register: t } = be(), n = t(r.name), o = r.options;
1352
+ return console.log("select"), /* @__PURE__ */ F.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
1353
+ /* @__PURE__ */ F.jsx("label", { children: r.label }),
1354
+ /* @__PURE__ */ F.jsx("select", { ...n, disabled: r.readonly, children: o.map((i) => /* @__PURE__ */ F.jsx("option", { value: i.value, children: i.label }, i.value)) })
1355
+ ] });
1356
+ };
1357
+ function _r(e, r) {
1358
+ const t = {};
1359
+ return e.forEach((n, o) => {
1360
+ const i = n.split(".");
1361
+ let u = t;
1362
+ i.forEach((f, w) => {
1363
+ const p = w === i.length - 1, O = !isNaN(Number(f));
1364
+ p ? u[f] = r[o] : (f in u || (u[f] = O ? [] : {}), u = u[f]);
1467
1365
  });
1468
- }), r;
1366
+ }), t;
1469
1367
  }
1470
- function St(e) {
1368
+ function xr(e) {
1471
1369
  switch (e) {
1472
1370
  case "text":
1473
1371
  return "";
@@ -1491,85 +1389,91 @@ function St(e) {
1491
1389
  return "";
1492
1390
  }
1493
1391
  }
1494
- function Ur(e) {
1392
+ function Tt(e) {
1495
1393
  return e.replace(/\.\d+\./g, ".");
1496
1394
  }
1497
- function Tt(e, t) {
1498
- const r = e.split("."), s = [];
1499
- return r.forEach((o, a) => {
1500
- isNaN(Number(o)) || s.push({ pos: a, value: o });
1501
- }), t.map((o) => {
1502
- const l = [...o.split(".")];
1503
- return s.forEach(({ pos: d, value: A }) => {
1504
- d <= l.length && l.splice(d, 0, A);
1505
- }), l.join(".");
1395
+ function Er(e, r) {
1396
+ const t = e.split("."), n = [];
1397
+ return t.forEach((o, i) => {
1398
+ isNaN(Number(o)) || n.push({ pos: i, value: o });
1399
+ }), r.map((o) => {
1400
+ const u = [...o.split(".")];
1401
+ return n.forEach(({ pos: f, value: w }) => {
1402
+ f <= u.length && u.splice(f, 0, w);
1403
+ }), u.join(".");
1506
1404
  });
1507
1405
  }
1508
- function Le(e, t = {}) {
1509
- const r = {};
1510
- for (const s of e)
1511
- if (s.type === "object") {
1512
- const o = s.fields;
1513
- r[s.name] = Le(
1514
- o,
1515
- t == null ? void 0 : t[s.name]
1516
- );
1406
+ function Ne(e, r = {}) {
1407
+ const t = {};
1408
+ for (const n of e)
1409
+ if (n.type === "object") {
1410
+ const o = n.fields;
1411
+ t[n.name] = Ne(o, r == null ? void 0 : r[n.name]);
1517
1412
  } else
1518
- r[s.name] = (t == null ? void 0 : t[s.name]) ?? s.initialValue ?? St(s.type);
1519
- return r;
1413
+ t[n.name] = (r == null ? void 0 : r[n.name]) ?? n.initialValue ?? xr(n.type);
1414
+ return t;
1520
1415
  }
1521
- const Ot = (e) => {
1522
- const { fieldSchema: t } = e, r = t.fields, { control: s } = ge(), { fields: o, append: a } = wt({
1523
- name: t.name,
1524
- control: s
1525
- }), l = () => {
1526
- a(Le(r));
1527
- };
1528
- return /* @__PURE__ */ T.jsxs("div", { children: [
1529
- o.map((d, A) => {
1530
- const p = r.map((C) => ({
1531
- ...C,
1532
- name: `${t.name}.${A}.${C.name}`
1533
- }));
1534
- return /* @__PURE__ */ T.jsxs(V.Fragment, { children: [
1535
- /* @__PURE__ */ T.jsxs("div", { children: [
1536
- "row ",
1537
- A
1538
- ] }),
1539
- cr(p)
1540
- ] }, d.id);
1541
- }),
1542
- t.readonly !== !0 && /* @__PURE__ */ T.jsx("button", { onClick: l, children: "Add Row" })
1543
- ] });
1544
- }, Mr = Zr(null), Dt = ({
1545
- children: e,
1546
- layout: t = "vertical",
1547
- uiConfig: r,
1548
- updateFieldSchema: s
1549
- }) => {
1550
- const o = Oe(
1551
- () => ({
1552
- layout: t,
1553
- uiConfig: r,
1554
- updateFieldSchema: s
1555
- }),
1556
- [t, r, s]
1416
+ const Vr = (e) => {
1417
+ const { fieldSchema: r } = e;
1418
+ let t = he(
1419
+ () => r.fields.map((n) => ({
1420
+ ...n,
1421
+ name: `${r.name}.${n.name}`
1422
+ })),
1423
+ [r.fields]
1557
1424
  );
1558
- return /* @__PURE__ */ T.jsx(Mr.Provider, { value: o, children: e });
1559
- }, Br = () => {
1560
- const e = Qr(Mr);
1561
- if (!e)
1562
- throw new Error(
1563
- "useAutoFormRenderContext must be used within AutoFormRenderContextProvider"
1564
- );
1565
- return e;
1566
- }, Ct = (e) => {
1567
- const { fieldSchema: t } = e, { register: r } = ge(), s = r(t.name);
1568
- return /* @__PURE__ */ T.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
1569
- /* @__PURE__ */ T.jsx("label", { children: t.label }),
1570
- /* @__PURE__ */ T.jsx("input", { type: t.type, ...s, readOnly: t.readonly })
1425
+ return /* @__PURE__ */ F.jsx(Ie, { schema: t });
1426
+ };
1427
+ function Ot(e) {
1428
+ return e.map((r) => {
1429
+ if (["object", "array"].includes(r.type)) {
1430
+ const t = r.fields;
1431
+ return {
1432
+ ...r,
1433
+ readonly: !0,
1434
+ fields: Ot(t)
1435
+ };
1436
+ }
1437
+ return {
1438
+ ...r,
1439
+ readonly: !0
1440
+ };
1441
+ });
1442
+ }
1443
+ const Fr = k.memo((e) => {
1444
+ const { baseName: r, index: t, fields: n } = e, o = k.useMemo(
1445
+ () => n.map((i) => ({
1446
+ ...i,
1447
+ name: `${r}.${t}.${i.name}`
1448
+ })),
1449
+ [r, t, n]
1450
+ );
1451
+ return /* @__PURE__ */ F.jsxs("div", { children: [
1452
+ /* @__PURE__ */ F.jsxs("div", { children: [
1453
+ "row ",
1454
+ t
1455
+ ] }),
1456
+ /* @__PURE__ */ F.jsx(Ie, { schema: o })
1457
+ ] });
1458
+ }), wr = (e) => {
1459
+ const { fieldSchema: r } = e, { control: t, getValues: n, setValue: o } = be(), u = Xe({
1460
+ control: t,
1461
+ name: r.name
1462
+ }) ?? [], f = () => {
1463
+ const p = n(r.name) || [];
1464
+ o(r.name, [...p, Ne(r.fields)]);
1465
+ }, w = (p) => {
1466
+ const V = (n(r.name) || []).filter((A, v) => v !== p);
1467
+ o(r.name, V);
1468
+ };
1469
+ return /* @__PURE__ */ F.jsxs("div", { children: [
1470
+ u.map((p, O) => /* @__PURE__ */ F.jsxs("div", { children: [
1471
+ /* @__PURE__ */ F.jsx(Fr, { baseName: r.name, index: O, fields: r.fields }),
1472
+ !r.readonly && /* @__PURE__ */ F.jsx("button", { type: "button", onClick: () => w(O), children: "Remove" })
1473
+ ] }, O)),
1474
+ !r.readonly && /* @__PURE__ */ F.jsx("button", { type: "button", onClick: f, children: "Add Row" })
1571
1475
  ] });
1572
- }, jt = [
1476
+ }, Ar = k.memo(wr), pr = [
1573
1477
  "text",
1574
1478
  "number",
1575
1479
  "checkbox",
@@ -1579,201 +1483,150 @@ const Ot = (e) => {
1579
1483
  "time",
1580
1484
  "array",
1581
1485
  "object"
1582
- ], Pt = (e) => {
1583
- const { fieldSchema: t } = e, { register: r } = ge(), s = r(t.name), o = t.options;
1584
- return /* @__PURE__ */ T.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
1585
- /* @__PURE__ */ T.jsx("label", { children: t.label }),
1586
- /* @__PURE__ */ T.jsx("select", { ...s, disabled: t.readonly, children: o.map((a) => /* @__PURE__ */ T.jsx("option", { value: a.value, children: a.label }, a.value)) })
1587
- ] });
1588
- }, $r = ({ fieldSchema: e }) => {
1589
- var p, C;
1590
- const r = Br().uiConfig, { register: s, control: o } = ge(), a = Ur(e.name), l = s(e.name);
1591
- if (e.visible === !1)
1592
- return;
1593
- const d = (p = r == null ? void 0 : r.renderersByName) == null ? void 0 : p[a];
1594
- if (d)
1595
- return /* @__PURE__ */ T.jsx(d, { fieldSchema: e, control: o, register: l });
1596
- const A = (C = r == null ? void 0 : r.renderersByType) == null ? void 0 : C[e.type];
1597
- if (A)
1598
- return /* @__PURE__ */ T.jsx(A, { fieldSchema: e, control: o, register: l });
1599
- if (jt.includes(e.type))
1600
- return e.type === "select" ? /* @__PURE__ */ T.jsx(Pt, { fieldSchema: e }) : /* @__PURE__ */ T.jsx(Ct, { fieldSchema: e });
1486
+ ], Dt = ({ fieldSchema: e }) => {
1487
+ var p, O;
1488
+ const t = St().uiConfig, { register: n, control: o } = be(), i = Tt(e.name), u = n(e.name), f = (p = t == null ? void 0 : t.renderersByName) == null ? void 0 : p[i];
1489
+ if (f)
1490
+ return /* @__PURE__ */ F.jsx(f, { fieldSchema: e, control: o, register: u });
1491
+ const w = (O = t == null ? void 0 : t.renderersByType) == null ? void 0 : O[e.type];
1492
+ if (w)
1493
+ return /* @__PURE__ */ F.jsx(w, { fieldSchema: e, control: o, register: u });
1494
+ if (pr.includes(e.type))
1495
+ return e.type === "select" ? /* @__PURE__ */ F.jsx(gr, { fieldSchema: e }) : e.type === "array" ? /* @__PURE__ */ F.jsx(Ar, { fieldSchema: e }) : e.type === "object" ? /* @__PURE__ */ F.jsx(Vr, { fieldSchema: e }) : /* @__PURE__ */ F.jsx(br, { fieldSchema: e });
1601
1496
  throw new Error(
1602
1497
  `AutoForm: No renderer found for field "${e.name}" with type "${e.type}". If this is a custom field type, make sure to register a renderer via uiConfig.renderersByType.`
1603
1498
  );
1604
- }, Nt = ({ fieldSchema: e }) => /* @__PURE__ */ T.jsx($r, { fieldSchema: e }), It = ({ fieldSchema: e }) => {
1605
- const { control: t } = ge(), r = Br(), s = e.dependsOn ?? [], o = Oe(
1606
- () => Tt(e.name, s),
1607
- [e.name, s]
1608
- ), a = Or({
1609
- control: t,
1499
+ }, Rr = ({ fieldSchema: e }) => /* @__PURE__ */ F.jsx(Dt, { fieldSchema: e }), kr = ({ fieldSchema: e }) => {
1500
+ const { control: r } = be(), t = St(), n = e.dependsOn ?? [], o = he(
1501
+ () => Er(e.name, n),
1502
+ [e.name, n]
1503
+ ), i = Xe({
1504
+ control: r,
1610
1505
  name: o
1611
- }), [l, d] = Kr(e);
1612
- return Pe(() => {
1613
- if (!s.length) return;
1614
- let A = !1;
1506
+ }), [u, f] = $t(e);
1507
+ return Ce(() => {
1508
+ if (!n.length) return;
1509
+ let w = !1;
1615
1510
  return (async () => {
1616
- var M;
1617
- const C = Ur(e.name), x = Rt(
1618
- o,
1619
- a ?? []
1620
- ), R = (M = r == null ? void 0 : r.updateFieldSchema) == null ? void 0 : M[C];
1621
- if (!R) return;
1622
- const h = await R(e.name, e, x);
1623
- !A && h && d({
1511
+ var N;
1512
+ const O = Tt(e.name), V = _r(o, i ?? []), A = (N = t == null ? void 0 : t.updateFieldSchema) == null ? void 0 : N[O];
1513
+ if (!A) return;
1514
+ const v = await A(e.name, e, V);
1515
+ !w && v && f({
1624
1516
  ...e,
1625
- ...h
1517
+ ...v
1626
1518
  });
1627
1519
  })(), () => {
1628
- A = !0;
1520
+ w = !0;
1629
1521
  };
1630
- }, [a]), /* @__PURE__ */ T.jsx($r, { fieldSchema: l });
1631
- }, Lt = (e) => {
1632
- var r;
1633
- const { fieldSchema: t } = e;
1634
- return (r = t.dependsOn) != null && r.length ? /* @__PURE__ */ T.jsx(It, { fieldSchema: t }) : /* @__PURE__ */ T.jsx(Nt, { fieldSchema: t });
1635
- }, Ut = (e) => {
1636
- const { fieldSchema: t } = e;
1637
- return /* @__PURE__ */ T.jsx(Lt, { fieldSchema: t });
1638
- }, Mt = (e) => {
1639
- const { fieldSchema: t } = e;
1640
- let r = Oe(() => t.fields.map((s) => ({
1641
- ...s,
1642
- name: `${t.name}.${s.name}`
1643
- })), [t.fields]);
1644
- return /* @__PURE__ */ T.jsx(T.Fragment, { children: cr(r) });
1645
- };
1646
- function cr(e) {
1647
- return e.map((t) => {
1648
- switch (t.type) {
1649
- case "array":
1650
- return /* @__PURE__ */ T.jsx(
1651
- Ot,
1652
- {
1653
- fieldSchema: t
1654
- },
1655
- t.name
1656
- );
1657
- case "object":
1658
- return /* @__PURE__ */ T.jsx(
1659
- Mt,
1660
- {
1661
- fieldSchema: t
1662
- },
1663
- t.name
1664
- );
1665
- default:
1666
- return /* @__PURE__ */ T.jsx(Ut, { fieldSchema: t }, t.name);
1667
- }
1668
- });
1669
- }
1670
- function Wr(e) {
1671
- return e.map((t) => {
1672
- if (["object", "array"].includes(t.type)) {
1673
- const r = t.fields;
1674
- return {
1675
- ...t,
1676
- readonly: !0,
1677
- fields: Wr(r)
1678
- };
1679
- }
1680
- return {
1681
- ...t,
1682
- readonly: !0
1683
- };
1684
- });
1685
- }
1686
- const Bt = (e) => {
1687
- const { onDirtyChange: t, onValuesChange: r } = e, { formState: s, control: o } = ge(), a = Or({
1522
+ }, [i]), /* @__PURE__ */ F.jsx(Dt, { fieldSchema: u });
1523
+ }, Sr = (e) => {
1524
+ var t;
1525
+ const { fieldSchema: r } = e;
1526
+ return (t = r.dependsOn) != null && t.length ? /* @__PURE__ */ F.jsx(kr, { fieldSchema: r }) : /* @__PURE__ */ F.jsx(Rr, { fieldSchema: r });
1527
+ }, Tr = (e) => {
1528
+ const { fieldSchema: r } = e;
1529
+ if (r.visible !== !1)
1530
+ return /* @__PURE__ */ F.jsx(Sr, { fieldSchema: r });
1531
+ }, Ie = k.memo(
1532
+ (e) => {
1533
+ const { schema: r } = e;
1534
+ return r.map((t) => /* @__PURE__ */ F.jsx(Tr, { fieldSchema: t }, t.name));
1535
+ }
1536
+ ), Or = (e) => {
1537
+ const { onDirtyChange: r, onValuesChange: t } = e, { formState: n, control: o } = be(), i = Xe({
1688
1538
  control: o
1689
1539
  });
1690
- return Pe(() => {
1691
- r(a);
1692
- }, [a]), Pe(() => {
1693
- t(s.isDirty);
1694
- }, [s.isDirty]), null;
1695
- }, $t = ({
1540
+ return Ce(() => {
1541
+ t(i);
1542
+ }, [i]), Ce(() => {
1543
+ r(n.isDirty);
1544
+ }, [n.isDirty]), null;
1545
+ }, Dr = ({
1696
1546
  onValuesChange: e,
1697
- onDirtyChange: t
1698
- }) => (Bt({
1699
- onDirtyChange: t,
1547
+ onDirtyChange: r
1548
+ }) => (Or({
1549
+ onDirtyChange: r,
1700
1550
  onValuesChange: e
1701
- }), null), qt = V.forwardRef(
1702
- (e, t) => {
1551
+ }), null), Pr = k.forwardRef(
1552
+ (e, r) => {
1703
1553
  const {
1704
- schema: r,
1705
- onSubmit: s,
1554
+ schema: t,
1555
+ onSubmit: n,
1706
1556
  uiConfig: o = {
1707
1557
  renderersByName: {},
1708
1558
  renderersByType: {}
1709
1559
  },
1710
- updateFieldSchema: a = {},
1711
- layout: l = "vertical",
1712
- values: d = () => ({}),
1713
- hideSubmit: A = !1,
1560
+ updateFieldSchema: i = {},
1561
+ layout: u = "vertical",
1562
+ values: f = () => ({}),
1563
+ hideSubmit: w = !1,
1714
1564
  onDirtyChange: p = () => {
1715
1565
  },
1716
- onValuesChange: C = () => {
1566
+ onValuesChange: O = () => {
1717
1567
  },
1718
- resolver: x,
1719
- readonly: R
1720
- } = e, h = kt({
1568
+ resolver: V,
1569
+ readonly: A
1570
+ } = e, v = hr({
1721
1571
  reValidateMode: "onSubmit",
1722
1572
  criteriaMode: "all",
1723
- resolver: x
1724
- }), M = et(!1), $ = h.handleSubmit(s), W = Oe(() => {
1725
- let D = r;
1726
- return R && (D = Wr(D)), D;
1727
- }, [R, r]);
1728
- Pe(() => {
1729
- if (M.current) return;
1730
- let D = !1;
1573
+ resolver: V
1574
+ }), N = Wt(!1), M = v.handleSubmit(n);
1575
+ console.log("?");
1576
+ const B = he(() => {
1577
+ let _ = t;
1578
+ return A && (_ = Ot(_)), _;
1579
+ }, [A, t]);
1580
+ Ce(() => {
1581
+ if (N.current) return;
1582
+ let _ = !1;
1731
1583
  return (async () => {
1732
- const m = await d();
1733
- D || (h.reset(Le(r, m)), M.current = !0);
1584
+ const ce = await f();
1585
+ _ || (v.reset(Ne(t, ce)), N.current = !0);
1734
1586
  })(), () => {
1735
- D = !0;
1587
+ _ = !0;
1736
1588
  };
1737
- }, [d, r]), rt(t, () => ({
1589
+ }, [f, t]), Yt(r, () => ({
1738
1590
  submit: async () => {
1739
- await h.handleSubmit(s)();
1591
+ await v.handleSubmit(n)();
1740
1592
  },
1741
- reset: (D) => {
1742
- h.reset(D ? Le(r, D) : void 0);
1593
+ reset: (_) => {
1594
+ v.reset(_ ? Ne(t, _) : void 0);
1743
1595
  },
1744
- getValues: () => h.getValues(),
1745
- setValue: (D, _) => {
1746
- h.setValue(D, _);
1596
+ getValues: () => v.getValues(),
1597
+ setValue: (_, X) => {
1598
+ v.setValue(_, X);
1747
1599
  }
1748
1600
  }));
1749
- const B = Oe(() => cr(W), [W]), w = A || R;
1750
- return /* @__PURE__ */ T.jsxs(lt, { ...h, children: [
1751
- /* @__PURE__ */ T.jsx(
1752
- $t,
1753
- {
1754
- onDirtyChange: p,
1755
- onValuesChange: C
1756
- }
1757
- ),
1758
- /* @__PURE__ */ T.jsxs(
1759
- Dt,
1601
+ const $ = w || A, E = he(() => o, [o]), H = he(() => i, [i]), D = he(
1602
+ () => ({
1603
+ layout: u,
1604
+ uiConfig: o,
1605
+ updateFieldSchema: i
1606
+ }),
1607
+ [u, o, i]
1608
+ );
1609
+ return /* @__PURE__ */ F.jsxs(Qt, { ...v, children: [
1610
+ /* @__PURE__ */ F.jsx(Dr, { onDirtyChange: p, onValuesChange: O }),
1611
+ /* @__PURE__ */ F.jsxs(
1612
+ vr,
1760
1613
  {
1761
- layout: l,
1762
- uiConfig: o,
1763
- updateFieldSchema: a,
1614
+ layout: D.layout,
1615
+ uiConfig: E,
1616
+ updateFieldSchema: H,
1764
1617
  children: [
1765
- ["vertical", "horizontal"].includes(l) && /* @__PURE__ */ T.jsx(
1618
+ ["vertical", "horizontal"].includes(u) && /* @__PURE__ */ F.jsx(
1766
1619
  "div",
1767
1620
  {
1768
1621
  style: {
1769
1622
  display: "flex",
1770
- flexDirection: l === "vertical" ? "column" : "row"
1623
+ flexDirection: u === "vertical" ? "column" : "row"
1771
1624
  },
1772
- children: B
1625
+ children: /* @__PURE__ */ F.jsx(Ie, { schema: B })
1773
1626
  }
1774
1627
  ),
1775
- l === "custom" && B,
1776
- !w && /* @__PURE__ */ T.jsx("button", { style: { marginTop: "1rem" }, onClick: $, children: "Submit" })
1628
+ u === "custom" && /* @__PURE__ */ F.jsx(Ie, { schema: B }),
1629
+ !$ && /* @__PURE__ */ F.jsx("button", { style: { marginTop: "1rem" }, onClick: M, children: "Submit" })
1777
1630
  ]
1778
1631
  }
1779
1632
  )
@@ -1781,5 +1634,5 @@ const Bt = (e) => {
1781
1634
  }
1782
1635
  );
1783
1636
  export {
1784
- qt as AutoForm
1637
+ Pr as AutoForm
1785
1638
  };