@tutim/headless
Version:
form infrastructure for web applications
1,481 lines (1,478 loc) • 73.1 kB
JavaScript
import E from "react";
var wr = {}, $t = {
get exports() {
return wr;
},
set exports(e) {
wr = e;
}
}, $e = {};
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var qr;
function Wt() {
if (qr)
return $e;
qr = 1;
var e = E, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, s = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, a = { key: !0, ref: !0, __self: !0, __source: !0 };
function u(l, d, g) {
var _, w = {}, b = null, F = null;
g !== void 0 && (b = "" + g), d.key !== void 0 && (b = "" + d.key), d.ref !== void 0 && (F = d.ref);
for (_ in d)
n.call(d, _) && !a.hasOwnProperty(_) && (w[_] = d[_]);
if (l && l.defaultProps)
for (_ in d = l.defaultProps, d)
w[_] === void 0 && (w[_] = d[_]);
return { $$typeof: t, type: l, key: b, ref: F, props: w, _owner: s.current };
}
return $e.Fragment = r, $e.jsx = u, $e.jsxs = u, $e;
}
var We = {};
/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Gr;
function Bt() {
return Gr || (Gr = 1, process.env.NODE_ENV !== "production" && function() {
var e = E, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), a = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), l = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), _ = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), F = Symbol.for("react.offscreen"), I = Symbol.iterator, q = "@@iterator";
function G(i) {
if (i === null || typeof i != "object")
return null;
var y = I && i[I] || i[q];
return typeof y == "function" ? y : null;
}
var Y = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
function k(i) {
{
for (var y = arguments.length, p = new Array(y > 1 ? y - 1 : 0), R = 1; R < y; R++)
p[R - 1] = arguments[R];
K("error", i, p);
}
}
function K(i, y, p) {
{
var R = Y.ReactDebugCurrentFrame, L = R.getStackAddendum();
L !== "" && (y += "%s", p = p.concat([L]));
var U = p.map(function(P) {
return String(P);
});
U.unshift("Warning: " + y), Function.prototype.apply.call(console[i], console, U);
}
}
var M = !1, S = !1, C = !1, O = !1, $ = !1, X;
X = Symbol.for("react.module.reference");
function he(i) {
return !!(typeof i == "string" || typeof i == "function" || i === n || i === a || $ || i === s || i === g || i === _ || O || i === F || M || S || C || typeof i == "object" && i !== null && (i.$$typeof === b || i.$$typeof === w || i.$$typeof === u || i.$$typeof === l || i.$$typeof === d || // This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
// we don't know which Flight build this will end up being used
// with.
i.$$typeof === X || i.getModuleId !== void 0));
}
function V(i, y, p) {
var R = i.displayName;
if (R)
return R;
var L = y.displayName || y.name || "";
return L !== "" ? p + "(" + L + ")" : p;
}
function j(i) {
return i.displayName || "Context";
}
function T(i) {
if (i == null)
return null;
if (typeof i.tag == "number" && k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof i == "function")
return i.displayName || i.name || null;
if (typeof i == "string")
return i;
switch (i) {
case n:
return "Fragment";
case r:
return "Portal";
case a:
return "Profiler";
case s:
return "StrictMode";
case g:
return "Suspense";
case _:
return "SuspenseList";
}
if (typeof i == "object")
switch (i.$$typeof) {
case l:
var y = i;
return j(y) + ".Consumer";
case u:
var p = i;
return j(p._context) + ".Provider";
case d:
return V(i, i.render, "ForwardRef");
case w:
var R = i.displayName || null;
return R !== null ? R : T(i.type) || "Memo";
case b: {
var L = i, U = L._payload, P = L._init;
try {
return T(P(U));
} catch {
return null;
}
}
}
return null;
}
var B = Object.assign, ee = 0, ne, pe, fe, be, we, je, Le;
function qe() {
}
qe.__reactDisabledLog = !0;
function nr() {
{
if (ee === 0) {
ne = console.log, pe = console.info, fe = console.warn, be = console.error, we = console.group, je = console.groupCollapsed, Le = console.groupEnd;
var i = {
configurable: !0,
enumerable: !0,
value: qe,
writable: !0
};
Object.defineProperties(console, {
info: i,
log: i,
warn: i,
error: i,
group: i,
groupCollapsed: i,
groupEnd: i
});
}
ee++;
}
}
function ir() {
{
if (ee--, ee === 0) {
var i = {
configurable: !0,
enumerable: !0,
writable: !0
};
Object.defineProperties(console, {
log: B({}, i, {
value: ne
}),
info: B({}, i, {
value: pe
}),
warn: B({}, i, {
value: fe
}),
error: B({}, i, {
value: be
}),
group: B({}, i, {
value: we
}),
groupCollapsed: B({}, i, {
value: je
}),
groupEnd: B({}, i, {
value: Le
})
});
}
ee < 0 && k("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
}
}
var Fe = Y.ReactCurrentDispatcher, Ae;
function Ee(i, y, p) {
{
if (Ae === void 0)
try {
throw Error();
} catch (L) {
var R = L.stack.trim().match(/\n( *(at )?)/);
Ae = R && R[1] || "";
}
return `
` + Ae + i;
}
}
var Ie = !1, Se;
{
var Ge = typeof WeakMap == "function" ? WeakMap : Map;
Se = new Ge();
}
function Me(i, y) {
if (!i || Ie)
return "";
{
var p = Se.get(i);
if (p !== void 0)
return p;
}
var R;
Ie = !0;
var L = Error.prepareStackTrace;
Error.prepareStackTrace = void 0;
var U;
U = Fe.current, Fe.current = null, nr();
try {
if (y) {
var P = function() {
throw Error();
};
if (Object.defineProperty(P.prototype, "props", {
set: function() {
throw Error();
}
}), typeof Reflect == "object" && Reflect.construct) {
try {
Reflect.construct(P, []);
} catch (ge) {
R = ge;
}
Reflect.construct(i, [], P);
} else {
try {
P.call();
} catch (ge) {
R = ge;
}
i.call(P.prototype);
}
} else {
try {
throw Error();
} catch (ge) {
R = ge;
}
i();
}
} catch (ge) {
if (ge && R && typeof ge.stack == "string") {
for (var D = ge.stack.split(`
`), te = R.stack.split(`
`), J = D.length - 1, Q = te.length - 1; J >= 1 && Q >= 0 && D[J] !== te[Q]; )
Q--;
for (; J >= 1 && Q >= 0; J--, Q--)
if (D[J] !== te[Q]) {
if (J !== 1 || Q !== 1)
do
if (J--, Q--, Q < 0 || D[J] !== te[Q]) {
var ue = `
` + D[J].replace(" at new ", " at ");
return i.displayName && ue.includes("<anonymous>") && (ue = ue.replace("<anonymous>", i.displayName)), typeof i == "function" && Se.set(i, ue), ue;
}
while (J >= 1 && Q >= 0);
break;
}
}
} finally {
Ie = !1, Fe.current = U, ir(), Error.prepareStackTrace = L;
}
var ke = i ? i.displayName || i.name : "", zr = ke ? Ee(ke) : "";
return typeof i == "function" && Se.set(i, zr), zr;
}
function or(i, y, p) {
return Me(i, !1);
}
function o(i) {
var y = i.prototype;
return !!(y && y.isReactComponent);
}
function c(i, y, p) {
if (i == null)
return "";
if (typeof i == "function")
return Me(i, o(i));
if (typeof i == "string")
return Ee(i);
switch (i) {
case g:
return Ee("Suspense");
case _:
return Ee("SuspenseList");
}
if (typeof i == "object")
switch (i.$$typeof) {
case d:
return or(i.render);
case w:
return c(i.type, y, p);
case b: {
var R = i, L = R._payload, U = R._init;
try {
return c(U(L), y, p);
} catch {
}
}
}
return "";
}
var f = Object.prototype.hasOwnProperty, m = {}, A = Y.ReactDebugCurrentFrame;
function h(i) {
if (i) {
var y = i._owner, p = c(i.type, i._source, y ? y.type : null);
A.setExtraStackFrame(p);
} else
A.setExtraStackFrame(null);
}
function x(i, y, p, R, L) {
{
var U = Function.call.bind(f);
for (var P in i)
if (U(i, P)) {
var D = void 0;
try {
if (typeof i[P] != "function") {
var te = Error((R || "React class") + ": " + p + " type `" + P + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof i[P] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
throw te.name = "Invariant Violation", te;
}
D = i[P](y, P, R, p, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
} catch (J) {
D = J;
}
D && !(D instanceof Error) && (h(L), k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", R || "React class", p, P, typeof D), h(null)), D instanceof Error && !(D.message in m) && (m[D.message] = !0, h(L), k("Failed %s type: %s", p, D.message), h(null));
}
}
}
var H = Array.isArray;
function N(i) {
return H(i);
}
function ar(i) {
{
var y = typeof Symbol == "function" && Symbol.toStringTag, p = y && i[Symbol.toStringTag] || i.constructor.name || "Object";
return p;
}
}
function Ue(i) {
try {
return Ce(i), !1;
} catch {
return !0;
}
}
function Ce(i) {
return "" + i;
}
function Ye(i) {
if (Ue(i))
return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ar(i)), Ce(i);
}
var me = Y.ReactCurrentOwner, ur = {
key: !0,
ref: !0,
__self: !0,
__source: !0
}, Ne, Ir, lr;
lr = {};
function St(i) {
if (f.call(i, "ref")) {
var y = Object.getOwnPropertyDescriptor(i, "ref").get;
if (y && y.isReactWarning)
return !1;
}
return i.ref !== void 0;
}
function Ct(i) {
if (f.call(i, "key")) {
var y = Object.getOwnPropertyDescriptor(i, "key").get;
if (y && y.isReactWarning)
return !1;
}
return i.key !== void 0;
}
function Rt(i, y) {
if (typeof i.ref == "string" && me.current && y && me.current.stateNode !== y) {
var p = T(me.current.type);
lr[p] || (k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', T(me.current.type), i.ref), lr[p] = !0);
}
}
function kt(i, y) {
{
var p = function() {
Ne || (Ne = !0, k("%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://reactjs.org/link/special-props)", y));
};
p.isReactWarning = !0, Object.defineProperty(i, "key", {
get: p,
configurable: !0
});
}
}
function Vt(i, y) {
{
var p = function() {
Ir || (Ir = !0, k("%s: `ref` 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://reactjs.org/link/special-props)", y));
};
p.isReactWarning = !0, Object.defineProperty(i, "ref", {
get: p,
configurable: !0
});
}
}
var Ot = function(i, y, p, R, L, U, P) {
var D = {
// This tag allows us to uniquely identify this as a React Element
$$typeof: t,
// Built-in properties that belong on the element
type: i,
key: y,
ref: p,
props: P,
// Record the component responsible for creating this element.
_owner: U
};
return D._store = {}, Object.defineProperty(D._store, "validated", {
configurable: !1,
enumerable: !1,
writable: !0,
value: !1
}), Object.defineProperty(D, "_self", {
configurable: !1,
enumerable: !1,
writable: !1,
value: R
}), Object.defineProperty(D, "_source", {
configurable: !1,
enumerable: !1,
writable: !1,
value: L
}), Object.freeze && (Object.freeze(D.props), Object.freeze(D)), D;
};
function Dt(i, y, p, R, L) {
{
var U, P = {}, D = null, te = null;
p !== void 0 && (Ye(p), D = "" + p), Ct(y) && (Ye(y.key), D = "" + y.key), St(y) && (te = y.ref, Rt(y, L));
for (U in y)
f.call(y, U) && !ur.hasOwnProperty(U) && (P[U] = y[U]);
if (i && i.defaultProps) {
var J = i.defaultProps;
for (U in J)
P[U] === void 0 && (P[U] = J[U]);
}
if (D || te) {
var Q = typeof i == "function" ? i.displayName || i.name || "Unknown" : i;
D && kt(P, Q), te && Vt(P, Q);
}
return Ot(i, D, te, L, R, me.current, P);
}
}
var cr = Y.ReactCurrentOwner, Mr = Y.ReactDebugCurrentFrame;
function Re(i) {
if (i) {
var y = i._owner, p = c(i.type, i._source, y ? y.type : null);
Mr.setExtraStackFrame(p);
} else
Mr.setExtraStackFrame(null);
}
var fr;
fr = !1;
function dr(i) {
return typeof i == "object" && i !== null && i.$$typeof === t;
}
function Ur() {
{
if (cr.current) {
var i = T(cr.current.type);
if (i)
return `
Check the render method of \`` + i + "`.";
}
return "";
}
}
function Tt(i) {
{
if (i !== void 0) {
var y = i.fileName.replace(/^.*[\\\/]/, ""), p = i.lineNumber;
return `
Check your code at ` + y + ":" + p + ".";
}
return "";
}
}
var Nr = {};
function Pt(i) {
{
var y = Ur();
if (!y) {
var p = typeof i == "string" ? i : i.displayName || i.name;
p && (y = `
Check the top-level render call using <` + p + ">.");
}
return y;
}
}
function $r(i, y) {
{
if (!i._store || i._store.validated || i.key != null)
return;
i._store.validated = !0;
var p = Pt(y);
if (Nr[p])
return;
Nr[p] = !0;
var R = "";
i && i._owner && i._owner !== cr.current && (R = " It was passed a child from " + T(i._owner.type) + "."), Re(i), k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', p, R), Re(null);
}
}
function Wr(i, y) {
{
if (typeof i != "object")
return;
if (N(i))
for (var p = 0; p < i.length; p++) {
var R = i[p];
dr(R) && $r(R, y);
}
else if (dr(i))
i._store && (i._store.validated = !0);
else if (i) {
var L = G(i);
if (typeof L == "function" && L !== i.entries)
for (var U = L.call(i), P; !(P = U.next()).done; )
dr(P.value) && $r(P.value, y);
}
}
}
function jt(i) {
{
var y = i.type;
if (y == null || typeof y == "string")
return;
var p;
if (typeof y == "function")
p = y.propTypes;
else if (typeof y == "object" && (y.$$typeof === d || // Note: Memo only checks outer props here.
// Inner props are checked in the reconciler.
y.$$typeof === w))
p = y.propTypes;
else
return;
if (p) {
var R = T(y);
x(p, i.props, "prop", R, i);
} else if (y.PropTypes !== void 0 && !fr) {
fr = !0;
var L = T(y);
k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", L || "Unknown");
}
typeof y.getDefaultProps == "function" && !y.getDefaultProps.isReactClassApproved && k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
}
}
function Lt(i) {
{
for (var y = Object.keys(i.props), p = 0; p < y.length; p++) {
var R = y[p];
if (R !== "children" && R !== "key") {
Re(i), k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", R), Re(null);
break;
}
}
i.ref !== null && (Re(i), k("Invalid attribute `ref` supplied to `React.Fragment`."), Re(null));
}
}
function Br(i, y, p, R, L, U) {
{
var P = he(i);
if (!P) {
var D = "";
(i === void 0 || typeof i == "object" && i !== null && Object.keys(i).length === 0) && (D += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
var te = Tt(L);
te ? D += te : D += Ur();
var J;
i === null ? J = "null" : N(i) ? J = "array" : i !== void 0 && i.$$typeof === t ? (J = "<" + (T(i.type) || "Unknown") + " />", D = " Did you accidentally export a JSX literal instead of a component?") : J = typeof i, k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", J, D);
}
var Q = Dt(i, y, p, L, U);
if (Q == null)
return Q;
if (P) {
var ue = y.children;
if (ue !== void 0)
if (R)
if (N(ue)) {
for (var ke = 0; ke < ue.length; ke++)
Wr(ue[ke], i);
Object.freeze && Object.freeze(ue);
} else
k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
else
Wr(ue, i);
}
return i === n ? Lt(Q) : jt(Q), Q;
}
}
function It(i, y, p) {
return Br(i, y, p, !0);
}
function Mt(i, y, p) {
return Br(i, y, p, !1);
}
var Ut = Mt, Nt = It;
We.Fragment = n, We.jsx = Ut, We.jsxs = Nt;
}()), We;
}
(function(e) {
process.env.NODE_ENV === "production" ? e.exports = Wt() : e.exports = Bt();
})($t);
const ce = wr.jsx;
var ze = (e) => e.type === "checkbox", Oe = (e) => e instanceof Date, se = (e) => e == null;
const Zr = (e) => typeof e == "object";
var Z = (e) => !se(e) && !Array.isArray(e) && Zr(e) && !Oe(e), et = (e) => Z(e) && e.target ? ze(e.target) ? e.target.checked : e.target.value : e, zt = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, rt = (e, t) => e.has(zt(t)), Pe = (e) => Array.isArray(e) ? e.filter(Boolean) : [], z = (e) => e === void 0, v = (e, t, r) => {
if (!t || !Z(e))
return r;
const n = Pe(t.split(/[,[\].]+?/)).reduce((s, a) => se(s) ? s : s[a], e);
return z(n) || n === e ? z(e[t]) ? r : e[t] : n;
};
const He = {
BLUR: "blur",
FOCUS_OUT: "focusout",
CHANGE: "change"
}, le = {
onBlur: "onBlur",
onChange: "onChange",
onSubmit: "onSubmit",
onTouched: "onTouched",
all: "all"
}, ve = {
max: "max",
min: "min",
maxLength: "maxLength",
minLength: "minLength",
pattern: "pattern",
required: "required",
validate: "validate"
}, qt = E.createContext(null), tr = () => E.useContext(qt);
var tt = (e, t, r, n = !0) => {
const s = {
defaultValues: t._defaultValues
};
for (const a in e)
Object.defineProperty(s, a, {
get: () => {
const u = a;
return t._proxyFormState[u] !== le.all && (t._proxyFormState[u] = !n || le.all), r && (r[u] = !0), e[u];
}
});
return s;
}, ie = (e) => Z(e) && !Object.keys(e).length, st = (e, t, r) => {
const { name: n, ...s } = e;
return ie(s) || Object.keys(s).length >= Object.keys(t).length || Object.keys(s).find((a) => t[a] === (!r || le.all));
}, ae = (e) => Array.isArray(e) ? e : [e], nt = (e, t, r) => r && t ? e === t : !e || !t || e === t || ae(e).some((n) => n && (n.startsWith(t) || t.startsWith(n)));
function sr(e) {
const t = E.useRef(e);
t.current = e, E.useEffect(() => {
const r = !e.disabled && t.current.subject.subscribe({
next: t.current.next
});
return () => {
r && r.unsubscribe();
};
}, [e.disabled]);
}
function Gt(e) {
const t = tr(), { control: r = t.control, disabled: n, name: s, exact: a } = e || {}, [u, l] = E.useState(r._formState), d = E.useRef(!0), g = E.useRef({
isDirty: !1,
isLoading: !1,
dirtyFields: !1,
touchedFields: !1,
isValidating: !1,
isValid: !1,
errors: !1
}), _ = E.useRef(s);
return _.current = s, sr({
disabled: n,
next: (w) => d.current && nt(_.current, w.name, a) && st(w, g.current) && l({
...r._formState,
...w
}),
subject: r._subjects.state
}), E.useEffect(() => {
d.current = !0;
const w = r._proxyFormState.isDirty && r._getDirty();
return w !== r._formState.isDirty && r._subjects.state.next({
isDirty: w
}), r._updateValid(), () => {
d.current = !1;
};
}, [r]), tt(u, r, g.current, !1);
}
var de = (e) => typeof e == "string", it = (e, t, r, n, s) => de(e) ? (n && t.watch.add(e), v(r, e, s)) : Array.isArray(e) ? e.map((a) => (n && t.watch.add(a), v(r, a))) : (n && (t.watchAll = !0), r), Yt = (e) => {
const t = e.constructor && e.constructor.prototype;
return Z(t) && t.hasOwnProperty("isPrototypeOf");
}, Dr = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
function oe(e) {
let t;
const r = Array.isArray(e);
if (e instanceof Date)
t = new Date(e);
else if (e instanceof Set)
t = new Set(e);
else if (!(Dr && (e instanceof Blob || e instanceof FileList)) && (r || Z(e)))
if (t = r ? [] : {}, !Array.isArray(e) && !Yt(e))
t = e;
else
for (const n in e)
t[n] = oe(e[n]);
else
return e;
return t;
}
function ot(e) {
const t = tr(), { control: r = t.control, name: n, defaultValue: s, disabled: a, exact: u } = e || {}, l = E.useRef(n);
l.current = n, sr({
disabled: a,
subject: r._subjects.watch,
next: (_) => {
nt(l.current, _.name, u) && g(oe(it(l.current, r._names, _.values || r._formValues, !1, s)));
}
});
const [d, g] = E.useState(r._getWatch(n, s));
return E.useEffect(() => r._removeUnmounted()), d;
}
function Kt(e) {
const t = tr(), { name: r, control: n = t.control, shouldUnregister: s } = e, a = rt(n._names.array, r), u = ot({
control: n,
name: r,
defaultValue: v(n._formValues, r, v(n._defaultValues, r, e.defaultValue)),
exact: !0
}), l = Gt({
control: n,
name: r
}), d = E.useRef(n.register(r, {
...e.rules,
value: u
}));
return E.useEffect(() => {
const g = (_, w) => {
const b = v(n._fields, _);
b && (b._f.mount = w);
};
return g(r, !0), () => {
const _ = n._options.shouldUnregister || s;
(a ? _ && !n._stateFlags.action : _) ? n.unregister(r) : g(r, !1);
};
}, [r, n, a, s]), {
field: {
name: r,
value: u,
onChange: E.useCallback((g) => d.current.onChange({
target: {
value: et(g),
name: r
},
type: He.CHANGE
}), [r]),
onBlur: E.useCallback(() => d.current.onBlur({
target: {
value: v(n._formValues, r),
name: r
},
type: He.BLUR
}), [r, n]),
ref: (g) => {
const _ = v(n._fields, r);
_ && g && (_._f.ref = {
focus: () => g.focus(),
select: () => g.select(),
setCustomValidity: (w) => g.setCustomValidity(w),
reportValidity: () => g.reportValidity()
});
}
},
formState: l,
fieldState: Object.defineProperties({}, {
invalid: {
enumerable: !0,
get: () => !!v(l.errors, r)
},
isDirty: {
enumerable: !0,
get: () => !!v(l.dirtyFields, r)
},
isTouched: {
enumerable: !0,
get: () => !!v(l.touchedFields, r)
},
error: {
enumerable: !0,
get: () => v(l.errors, r)
}
})
};
}
const Ht = (e) => e.render(Kt(e));
var Jt = (e, t, r, n, s) => t ? {
...r[e],
types: {
...r[e] && r[e].types ? r[e].types : {},
[n]: s || !0
}
} : {}, Tr = (e) => /^\w*$/.test(e), at = (e) => Pe(e.replace(/["|']|\]/g, "").split(/\.|\[/));
function W(e, t, r) {
let n = -1;
const s = Tr(t) ? [t] : at(t), a = s.length, u = a - 1;
for (; ++n < a; ) {
const l = s[n];
let d = r;
if (n !== u) {
const g = e[l];
d = Z(g) || Array.isArray(g) ? g : isNaN(+s[n + 1]) ? {} : [];
}
e[l] = d, e = e[l];
}
return e;
}
const Je = (e, t, r) => {
for (const n of r || Object.keys(e)) {
const s = v(e, n);
if (s) {
const { _f: a, ...u } = s;
if (a && t(a.name)) {
if (a.ref.focus) {
a.ref.focus();
break;
} else if (a.refs && a.refs[0].focus) {
a.refs[0].focus();
break;
}
} else
Z(u) && Je(u, t);
}
}
};
var _e = () => {
const e = typeof performance > "u" ? Date.now() : performance.now() * 1e3;
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
const r = (Math.random() * 16 + e) % 16 | 0;
return (t == "x" ? r : r & 3 | 8).toString(16);
});
}, yr = (e, t, r = {}) => r.shouldFocus || z(r.shouldFocus) ? r.focusName || `${e}.${z(r.focusIndex) ? t : r.focusIndex}.` : "", Sr = (e) => ({
isOnSubmit: !e || e === le.onSubmit,
isOnBlur: e === le.onBlur,
isOnChange: e === le.onChange,
isOnAll: e === le.all,
isOnTouch: e === le.onTouched
}), Cr = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length)))), ut = (e, t, r) => {
const n = Pe(v(e, r));
return W(n, "root", t[r]), W(e, r, n), e;
}, De = (e) => typeof e == "boolean", Pr = (e) => e.type === "file", Te = (e) => typeof e == "function", Xe = (e) => {
if (!Dr)
return !1;
const t = e ? e.ownerDocument : 0;
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
}, Ke = (e) => de(e) || E.isValidElement(e), jr = (e) => e.type === "radio", Qe = (e) => e instanceof RegExp;
const Yr = {
value: !1,
isValid: !1
}, Kr = { value: !0, isValid: !0 };
var lt = (e) => {
if (Array.isArray(e)) {
if (e.length > 1) {
const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
return { value: t, isValid: !!t.length };
}
return e[0].checked && !e[0].disabled ? (
// @ts-expect-error expected to work in the browser
e[0].attributes && !z(e[0].attributes.value) ? z(e[0].value) || e[0].value === "" ? Kr : { value: e[0].value, isValid: !0 } : Kr
) : Yr;
}
return Yr;
};
const Hr = {
isValid: !1,
value: null
};
var ct = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
isValid: !0,
value: r.value
} : t, Hr) : Hr;
function Jr(e, t, r = "validate") {
if (Ke(e) || Array.isArray(e) && e.every(Ke) || De(e) && !e)
return {
type: r,
message: Ke(e) ? e : "",
ref: t
};
}
var Ve = (e) => Z(e) && !Qe(e) ? e : {
value: e,
message: ""
}, Rr = async (e, t, r, n, s) => {
const { ref: a, refs: u, required: l, maxLength: d, minLength: g, min: _, max: w, pattern: b, validate: F, name: I, valueAsNumber: q, mount: G, disabled: Y } = e._f;
if (!G || Y)
return {};
const k = u ? u[0] : a, K = (V) => {
n && k.reportValidity && (k.setCustomValidity(De(V) ? "" : V || ""), k.reportValidity());
}, M = {}, S = jr(a), C = ze(a), O = S || C, $ = (q || Pr(a)) && z(a.value) && z(t) || Xe(a) && a.value === "" || t === "" || Array.isArray(t) && !t.length, X = Jt.bind(null, I, r, M), he = (V, j, T, B = ve.maxLength, ee = ve.minLength) => {
const ne = V ? j : T;
M[I] = {
type: V ? B : ee,
message: ne,
ref: a,
...X(V ? B : ee, ne)
};
};
if (s ? !Array.isArray(t) || !t.length : l && (!O && ($ || se(t)) || De(t) && !t || C && !lt(u).isValid || S && !ct(u).isValid)) {
const { value: V, message: j } = Ke(l) ? { value: !!l, message: l } : Ve(l);
if (V && (M[I] = {
type: ve.required,
message: j,
ref: k,
...X(ve.required, j)
}, !r))
return K(j), M;
}
if (!$ && (!se(_) || !se(w))) {
let V, j;
const T = Ve(w), B = Ve(_);
if (!se(t) && !isNaN(t)) {
const ee = a.valueAsNumber || t && +t;
se(T.value) || (V = ee > T.value), se(B.value) || (j = ee < B.value);
} else {
const ee = a.valueAsDate || new Date(t), ne = (be) => new Date(new Date().toDateString() + " " + be), pe = a.type == "time", fe = a.type == "week";
de(T.value) && t && (V = pe ? ne(t) > ne(T.value) : fe ? t > T.value : ee > new Date(T.value)), de(B.value) && t && (j = pe ? ne(t) < ne(B.value) : fe ? t < B.value : ee < new Date(B.value));
}
if ((V || j) && (he(!!V, T.message, B.message, ve.max, ve.min), !r))
return K(M[I].message), M;
}
if ((d || g) && !$ && (de(t) || s && Array.isArray(t))) {
const V = Ve(d), j = Ve(g), T = !se(V.value) && t.length > V.value, B = !se(j.value) && t.length < j.value;
if ((T || B) && (he(T, V.message, j.message), !r))
return K(M[I].message), M;
}
if (b && !$ && de(t)) {
const { value: V, message: j } = Ve(b);
if (Qe(V) && !t.match(V) && (M[I] = {
type: ve.pattern,
message: j,
ref: a,
...X(ve.pattern, j)
}, !r))
return K(j), M;
}
if (F) {
if (Te(F)) {
const V = await F(t), j = Jr(V, k);
if (j && (M[I] = {
...j,
...X(ve.validate, j.message)
}, !r))
return K(j.message), M;
} else if (Z(F)) {
let V = {};
for (const j in F) {
if (!ie(V) && !r)
break;
const T = Jr(await F[j](t), k, j);
T && (V = {
...T,
...X(j, T.message)
}, K(T.message), r && (M[I] = V));
}
if (!ie(V) && (M[I] = {
ref: k,
...V
}, !r))
return M;
}
}
return K(!0), M;
};
function hr(e, t) {
return [...e, ...ae(t)];
}
var gr = (e) => Array.isArray(e) ? e.map(() => {
}) : void 0;
function vr(e, t, r) {
return [
...e.slice(0, t),
...ae(r),
...e.slice(t)
];
}
var pr = (e, t, r) => Array.isArray(e) ? (z(e[r]) && (e[r] = void 0), e.splice(r, 0, e.splice(t, 1)[0]), e) : [];
function mr(e, t) {
return [...ae(t), ...ae(e)];
}
function Xt(e, t) {
let r = 0;
const n = [...e];
for (const s of t)
n.splice(s - r, 1), r++;
return Pe(n).length ? n : [];
}
var _r = (e, t) => z(t) ? [] : Xt(e, ae(t).sort((r, n) => r - n)), br = (e, t, r) => {
e[t] = [e[r], e[r] = e[t]][0];
};
function Qt(e, t) {
const r = t.slice(0, -1).length;
let n = 0;
for (; n < r; )
e = z(e) ? n++ : e[t[n++]];
return e;
}
function Zt(e) {
for (const t in e)
if (!z(e[t]))
return !1;
return !0;
}
function re(e, t) {
const r = Tr(t) ? [t] : at(t), n = r.length == 1 ? e : Qt(e, r), s = r[r.length - 1];
let a;
n && delete n[s];
for (let u = 0; u < r.slice(0, -1).length; u++) {
let l = -1, d;
const g = r.slice(0, -(u + 1)), _ = g.length - 1;
for (u > 0 && (a = e); ++l < g.length; ) {
const w = g[l];
d = d ? d[w] : e[w], _ === l && (Z(d) && ie(d) || Array.isArray(d) && Zt(d)) && (a ? delete a[w] : delete e[w]), a = d;
}
}
return e;
}
var Xr = (e, t, r) => (e[t] = r, e);
function es(e) {
const t = tr(), { control: r = t.control, name: n, keyName: s = "id", shouldUnregister: a } = e, [u, l] = E.useState(r._getFieldArray(n)), d = E.useRef(r._getFieldArray(n).map(_e)), g = E.useRef(u), _ = E.useRef(n), w = E.useRef(!1);
_.current = n, g.current = u, r._names.array.add(n), e.rules && r.register(n, e.rules), sr({
next: ({ values: S, name: C }) => {
if (C === _.current || !C) {
const O = v(S, _.current);
Array.isArray(O) && (l(O), d.current = O.map(_e));
}
},
subject: r._subjects.array
});
const b = E.useCallback((S) => {
w.current = !0, r._updateFieldArray(n, S);
}, [r, n]), F = (S, C) => {
const O = ae(oe(S)), $ = hr(r._getFieldArray(n), O);
r._names.focus = yr(n, $.length - 1, C), d.current = hr(d.current, O.map(_e)), b($), l($), r._updateFieldArray(n, $, hr, {
argA: gr(S)
});
}, I = (S, C) => {
const O = ae(oe(S)), $ = mr(r._getFieldArray(n), O);
r._names.focus = yr(n, 0, C), d.current = mr(d.current, O.map(_e)), b($), l($), r._updateFieldArray(n, $, mr, {
argA: gr(S)
});
}, q = (S) => {
const C = _r(r._getFieldArray(n), S);
d.current = _r(d.current, S), b(C), l(C), r._updateFieldArray(n, C, _r, {
argA: S
});
}, G = (S, C, O) => {
const $ = ae(oe(C)), X = vr(r._getFieldArray(n), S, $);
r._names.focus = yr(n, S, O), d.current = vr(d.current, S, $.map(_e)), b(X), l(X), r._updateFieldArray(n, X, vr, {
argA: S,
argB: gr(C)
});
}, Y = (S, C) => {
const O = r._getFieldArray(n);
br(O, S, C), br(d.current, S, C), b(O), l(O), r._updateFieldArray(n, O, br, {
argA: S,
argB: C
}, !1);
}, k = (S, C) => {
const O = r._getFieldArray(n);
pr(O, S, C), pr(d.current, S, C), b(O), l(O), r._updateFieldArray(n, O, pr, {
argA: S,
argB: C
}, !1);
}, K = (S, C) => {
const O = oe(C), $ = Xr(r._getFieldArray(n), S, O);
d.current = [...$].map((X, he) => !X || he === S ? _e() : d.current[he]), b($), l([...$]), r._updateFieldArray(n, $, Xr, {
argA: S,
argB: O
}, !0, !1);
}, M = (S) => {
const C = ae(oe(S));
d.current = C.map(_e), b([...C]), l([...C]), r._updateFieldArray(n, [...C], (O) => O, {}, !0, !1);
};
return E.useEffect(() => {
if (r._stateFlags.action = !1, Cr(n, r._names) && r._subjects.state.next({}), w.current && (!Sr(r._options.mode).isOnSubmit || r._formState.isSubmitted))
if (r._options.resolver)
r._executeSchema([n]).then((S) => {
const C = v(S.errors, n), O = v(r._formState.errors, n);
(O ? !C && O.type : C && C.type) && (C ? W(r._formState.errors, n, C) : re(r._formState.errors, n), r._subjects.state.next({
errors: r._formState.errors
}));
});
else {
const S = v(r._fields, n);
S && S._f && Rr(S, v(r._formValues, n), r._options.criteriaMode === le.all, r._options.shouldUseNativeValidation, !0).then((C) => !ie(C) && r._subjects.state.next({
errors: ut(r._formState.errors, C, n)
}));
}
r._subjects.watch.next({
name: n,
values: r._formValues
}), r._names.focus && Je(r._fields, (S) => !!S && S.startsWith(r._names.focus || "")), r._names.focus = "", r._proxyFormState.isValid && r._updateValid();
}, [u, n, r]), E.useEffect(() => (!v(r._formValues, n) && r._updateFieldArray(n), () => {
(r._options.shouldUnregister || a) && r.unregister(n);
}), [n, r, s, a]), {
swap: E.useCallback(Y, [b, n, r]),
move: E.useCallback(k, [b, n, r]),
prepend: E.useCallback(I, [b, n, r]),
append: E.useCallback(F, [b, n, r]),
remove: E.useCallback(q, [b, n, r]),
insert: E.useCallback(G, [b, n, r]),
update: E.useCallback(K, [b, n, r]),
replace: E.useCallback(M, [b, n, r]),
fields: E.useMemo(() => u.map((S, C) => ({
...S,
[s]: d.current[C] || _e()
})), [u, s])
};
}
function Fr() {
let e = [];
return {
get observers() {
return e;
},
next: (s) => {
for (const a of e)
a.next(s);
},
subscribe: (s) => (e.push(s), {
unsubscribe: () => {
e = e.filter((a) => a !== s);
}
}),
unsubscribe: () => {
e = [];
}
};
}
var Ze = (e) => se(e) || !Zr(e);
function xe(e, t) {
if (Ze(e) || Ze(t))
return e === t;
if (Oe(e) && Oe(t))
return e.getTime() === t.getTime();
const r = Object.keys(e), n = Object.keys(t);
if (r.length !== n.length)
return !1;
for (const s of r) {
const a = e[s];
if (!n.includes(s))
return !1;
if (s !== "ref") {
const u = t[s];
if (Oe(a) && Oe(u) || Z(a) && Z(u) || Array.isArray(a) && Array.isArray(u) ? !xe(a, u) : a !== u)
return !1;
}
}
return !0;
}
var ft = (e) => e.type === "select-multiple", rs = (e) => jr(e) || ze(e), Ar = (e) => Xe(e) && e.isConnected, dt = (e) => {
for (const t in e)
if (Te(e[t]))
return !0;
return !1;
};
function er(e, t = {}) {
const r = Array.isArray(e);
if (Z(e) || r)
for (const n in e)
Array.isArray(e[n]) || Z(e[n]) && !dt(e[n]) ? (t[n] = Array.isArray(e[n]) ? [] : {}, er(e[n], t[n])) : se(e[n]) || (t[n] = !0);
return t;
}
function yt(e, t, r) {
const n = Array.isArray(e);
if (Z(e) || n)
for (const s in e)
Array.isArray(e[s]) || Z(e[s]) && !dt(e[s]) ? z(t) || Ze(r[s]) ? r[s] = Array.isArray(e[s]) ? er(e[s], []) : { ...er(e[s]) } : yt(e[s], se(t) ? {} : t[s], r[s]) : xe(e[s], t[s]) ? delete r[s] : r[s] = !0;
return r;
}
var Er = (e, t) => yt(e, t, er(t)), ht = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: n }) => z(e) ? e : t ? e === "" ? NaN : e && +e : r && de(e) ? new Date(e) : n ? n(e) : e;
function xr(e) {
const t = e.ref;
if (!(e.refs ? e.refs.every((r) => r.disabled) : t.disabled))
return Pr(t) ? t.files : jr(t) ? ct(e.refs).value : ft(t) ? [...t.selectedOptions].map(({ value: r }) => r) : ze(t) ? lt(e.refs).value : ht(z(t.value) ? e.ref.value : t.value, e);
}
var ts = (e, t, r, n) => {
const s = {};
for (const a of e) {
const u = v(t, a);
u && W(s, a, u._f);
}
return {
criteriaMode: r,
names: [...e],
fields: s,
shouldUseNativeValidation: n
};
}, Be = (e) => z(e) ? e : Qe(e) ? e.source : Z(e) ? Qe(e.value) ? e.value.source : e.value : e, ss = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
function Qr(e, t, r) {
const n = v(e, r);
if (n || Tr(r))
return {
error: n,
name: r
};
const s = r.split(".");
for (; s.length; ) {
const a = s.join("."), u = v(t, a), l = v(e, a);
if (u && !Array.isArray(u) && r !== a)
return { name: r };
if (l && l.type)
return {
name: a,
error: l
};
s.pop();
}
return {
name: r
};
}
var ns = (e, t, r, n, s) => s.isOnAll ? !1 : !r && s.isOnTouch ? !(t || e) : (r ? n.isOnBlur : s.isOnBlur) ? !e : (r ? n.isOnChange : s.isOnChange) ? e : !0, is = (e, t) => !Pe(v(e, t)).length && re(e, t);
const os = {
mode: le.onSubmit,
reValidateMode: le.onChange,
shouldFocusError: !0
};
function as(e = {}, t) {
let r = {
...os,
...e
};
const n = e.resetOptions && e.resetOptions.keepDirtyValues;
let s = {
submitCount: 0,
isDirty: !1,
isLoading: !0,
isValidating: !1,
isSubmitted: !1,
isSubmitting: !1,
isSubmitSuccessful: !1,
isValid: !1,
touchedFields: {},
dirtyFields: {},
errors: {}
}, a = {}, u = Z(r.defaultValues) ? oe(r.defaultValues) || {} : {}, l = r.shouldUnregister ? {} : oe(u), d = {
action: !1,
mount: !1,
watch: !1
}, g = {
mount: /* @__PURE__ */ new Set(),
unMount: /* @__PURE__ */ new Set(),
array: /* @__PURE__ */ new Set(),
watch: /* @__PURE__ */ new Set()
}, _, w = 0;
const b = {
isDirty: !1,
dirtyFields: !1,
touchedFields: !1,
isValidating: !1,
isValid: !1,
errors: !1
}, F = {
watch: Fr(),
array: Fr(),
state: Fr()
}, I = Sr(r.mode), q = Sr(r.reValidateMode), G = r.criteriaMode === le.all, Y = (o) => (c) => {
clearTimeout(w), w = window.setTimeout(o, c);
}, k = async () => {
if (b.isValid) {
const o = r.resolver ? ie((await X()).errors) : await V(a, !0);
o !== s.isValid && (s.isValid = o, F.state.next({
isValid: o
}));
}
}, K = (o) => b.isValidating && F.state.next({
isValidating: o
}), M = (o, c = [], f, m, A = !0, h = !0) => {
if (m && f) {
if (d.action = !0, h && Array.isArray(v(a, o))) {
const x = f(v(a, o), m.argA, m.argB);
A && W(a, o, x);
}
if (h && Array.isArray(v(s.errors, o))) {
const x = f(v(s.errors, o), m.argA, m.argB);
A && W(s.errors, o, x), is(s.errors, o);
}
if (b.touchedFields && h && Array.isArray(v(s.touchedFields, o))) {
const x = f(v(s.touchedFields, o), m.argA, m.argB);
A && W(s.touchedFields, o, x);
}
b.dirtyFields && (s.dirtyFields = Er(u, l)), F.state.next({
name: o,
isDirty: T(o, c),
dirtyFields: s.dirtyFields,
errors: s.errors,
isValid: s.isValid
});
} else
W(l, o, c);
}, S = (o, c) => {
W(s.errors, o, c), F.state.next({
errors: s.errors
});
}, C = (o, c, f, m) => {
const A = v(a, o);
if (A) {
const h = v(l, o, z(f) ? v(u, o) : f);
z(h) || m && m.defaultChecked || c ? W(l, o, c ? h : xr(A._f)) : ne(o, h), d.mount && k();
}
}, O = (o, c, f, m, A) => {
let h = !1, x = !1;
const H = {
name: o
};
if (!f || m) {
b.isDirty && (x = s.isDirty, s.isDirty = H.isDirty = T(), h = x !== H.isDirty);
const N = xe(v(u, o), c);
x = v(s.dirtyFields, o), N ? re(s.dirtyFields, o) : W(s.dirtyFields, o, !0), H.dirtyFields = s.dirtyFields, h = h || b.dirtyFields && x !== !N;
}
if (f) {
const N = v(s.touchedFields, o);
N || (W(s.touchedFields, o, f), H.touchedFields = s.touchedFields, h = h || b.touchedFields && N !== f);
}
return h && A && F.state.next(H), h ? H : {};
}, $ = (o, c, f, m) => {
const A = v(s.errors, o), h = b.isValid && De(c) && s.isValid !== c;
if (e.delayError && f ? (_ = Y(() => S(o, f)), _(e.delayError)) : (clearTimeout(w), _ = null, f ? W(s.errors, o, f) : re(s.errors, o)), (f ? !xe(A, f) : A) || !ie(m) || h) {
const x = {
...m,
...h && De(c) ? { isValid: c } : {},
errors: s.errors,
name: o
};
s = {
...s,
...x
}, F.state.next(x);
}
K(!1);
}, X = async (o) => await r.resolver(l, r.context, ts(o || g.mount, a, r.criteriaMode, r.shouldUseNativeValidation)), he = async (o) => {
const { errors: c } = await X();
if (o)
for (const f of o) {
const m = v(c, f);
m ? W(s.errors, f, m) : re(s.errors, f);
}
else
s.errors = c;
return c;
}, V = async (o, c, f = {
valid: !0
}) => {
for (const m in o) {
const A = o[m];
if (A) {
const { _f: h, ...x } = A;
if (h) {
const H = g.array.has(h.name), N = await Rr(A, v(l, h.name), G, r.shouldUseNativeValidation, H);
if (N[h.name] && (f.valid = !1, c))
break;
!c && (v(N, h.name) ? H ? ut(s.errors, N, h.name) : W(s.errors, h.name, N[h.name]) : re(s.errors, h.name));
}
x && await V(x, c, f);
}
}
return f.valid;
}, j = () => {
for (const o of g.unMount) {
const c = v(a, o);
c && (c._f.refs ? c._f.refs.every((f) => !Ar(f)) : !Ar(c._f.ref)) && Fe(o);
}
g.unMount = /* @__PURE__ */ new Set();
}, T = (o, c) => (o && c && W(l, o, c), !xe(je(), u)), B = (o, c, f) => it(o, g, {
...d.mount ? l : z(c) ? u : de(o) ? { [o]: c } : c
}, f, c), ee = (o) => Pe(v(d.mount ? l : u, o, e.shouldUnregister ? v(u, o, []) : [])), ne = (o, c, f = {}) => {
const m = v(a, o);
let A = c;
if (m) {
const h = m._f;
h && (!h.disabled && W(l, o, ht(c, h)), A = Xe(h.ref) && se(c) ? "" : c, ft(h.ref) ? [...h.ref.options].forEach((x) => x.selected = A.includes(x.value)) : h.refs ? ze(h.ref) ? h.refs.length > 1 ? h.refs.forEach((x) => (!x.defaultChecked || !x.disabled) && (x.checked = Array.isArray(A) ? !!A.find((H) => H === x.value) : A === x.value)) : h.refs[0] && (h.refs[0].checked = !!A) : h.refs.forEach((x) => x.checked = x.value === A) : Pr(h.ref) ? h.ref.value = "" : (h.ref.value = A, h.ref.type || F.watch.next({
name: o
})));
}
(f.shouldDirty || f.shouldTouch) && O(o, A, f.shouldTouch, f.shouldDirty, !0), f.shouldValidate && we(o);
}, pe = (o, c, f) => {
for (const m in c) {
const A = c[m], h = `${o}.${m}`, x = v(a, h);
(g.array.has(o) || !Ze(A) || x && !x._f) && !Oe(A) ? pe(h, A, f) : ne(h, A, f);
}
}, fe = (o, c, f = {}) => {
const m = v(a, o), A = g.array.has(o), h = oe(c);
W(l, o, h), A ? (F.array.next({
name: o,
values: l
}), (b.isDirty || b.dirtyFields) && f.shouldDirty && (s.dirtyFields = Er(u, l), F.state.next({
name: o,
dirtyFields: s.dirtyFields,
isDirty: T(o, h)
}))) : m && !m._f && !se(h) ? pe(o, h, f) : ne(o, h, f), Cr(o, g) && F.state.next({}), F.watch.next({
name: o
}), !d.mount && t();
}, be = async (o) => {
const c = o.target;
let f = c.name;
const m = v(a, f), A = () => c.type ? xr(m._f) : et(o);
if (m) {
let h, x;
const H = A(), N = o.type === He.BLUR || o.type === He.FOCUS_OUT, ar = !ss(m._f) && !r.resolver && !v(s.errors, f) && !m._f.deps || ns(N, v(s.touchedFields, f), s.isSubmitted, q, I), Ue = Cr(f, g, N);
W(l, f, H), N ? (m._f.onBlur && m._f.onBlur(o), _ && _(0)) : m._f.onChange && m._f.onChange(o);
const Ce = O(f, H, N, !1), Ye = !ie(Ce) || Ue;
if (!N && F.watch.next({
name: f,
type: o.type
}), ar)
return b.isValid && k(), Ye && F.state.next({ name: f, ...Ue ? {} : Ce });
if (!N && Ue && F.state.next({}), K(!0), r.resolver) {
const { errors: me } = await X([f]), ur = Qr(s.errors, a, f), Ne = Qr(me, a, ur.name || f);
h = Ne.error, f = Ne.name, x = ie(me);
} else
h = (await Rr(m, v(l, f), G, r.shouldUseNativeValidation))[f], h ? x = !1 : b.isValid && (x = await V(a, !0));
m._f.deps && we(m._f.deps), $(f, x, h, Ce);
}
}, we = async (o, c = {}) => {
let f, m;
const A = ae(o);
if (K(!0), r.resolver) {
const h = await he(z(o) ? o : A);
f = ie(h), m = o ? !A.some((x) => v(h, x)) : f;
} else
o ? (m = (await Promise.all(A.map(async (h) => {
const x = v(a, h);
return await V(x && x._f ? { [h]: x } : x);
}))).every(Boolean), !(!m && !s.isValid) && k()) : m = f = await V(a);
return F.state.next({
...!de(o) || b.isValid && f !== s.isValid ? {} : { name: o },
...r.resolver || !o ? { isValid: f } : {},
errors: s.errors,
isValidating: !1
}), c.shouldFocus && !m && Je(a, (h) => h && v(s.errors, h), o ? A : g.mount), m;
}, je = (o) => {
const c = {
...u,
...d.mount ? l : {}
};
return z(o) ? c : de(o) ? v(c, o) : o.map((f) => v(c, f));
}, Le = (o, c) => ({
invalid: !!v((c || s).errors, o),
isDirty: !!v((c || s).dirtyFields, o),
isTouched: !!v((c || s).touchedFields, o),
error: v((c || s).errors, o)
}), qe = (o) => {
o ? ae(o).forEach((c) => re(s.errors, c)) : s.errors = {}, F.state.next