"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9501],{29501:function(e,t,r){r.d(t,{Qr:function(){return U},cI:function(){return eF}});var s=r(2265),a=e=>"checkbox"===e.type,i=e=>e instanceof Date,l=e=>null==e;let u=e=>"object"==typeof e;var n=e=>!l(e)&&!Array.isArray(e)&&u(e)&&!i(e),o=e=>n(e)&&e.target?a(e.target)?e.target.checked:e.target.value:e,d=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,f=(e,t)=>e.has(d(t)),c=e=>{let t=e.constructor&&e.constructor.prototype;return n(t)&&t.hasOwnProperty("isPrototypeOf")},y="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function m(e){let t;let r=Array.isArray(e),s="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else if(e instanceof Set)t=new Set(e);else if(!(!(y&&(e instanceof Blob||s))&&(r||n(e))))return e;else if(t=r?[]:{},r||c(e))for(let r in e)e.hasOwnProperty(r)&&(t[r]=m(e[r]));else t=e;return t}var v=e=>Array.isArray(e)?e.filter(Boolean):[],h=e=>void 0===e,g=(e,t,r)=>{if(!t||!n(e))return r;let s=v(t.split(/[,[\].]+?/)).reduce((e,t)=>l(e)?e:e[t],e);return h(s)||s===e?h(e[t])?r:e[t]:s},b=e=>"boolean"==typeof e,p=e=>/^\w*$/.test(e),_=e=>v(e.replace(/["|']|\]/g,"").split(/\.|\[/)),V=(e,t,r)=>{let s=-1,a=p(t)?[t]:_(t),i=a.length,l=i-1;for(;++ss.useContext(S);var k=(e,t,r,s=!0)=>{let a={defaultValues:t._defaultValues};for(let i in e)Object.defineProperty(a,i,{get:()=>(t._proxyFormState[i]!==A.all&&(t._proxyFormState[i]=!s||A.all),r&&(r[i]=!0),e[i])});return a},D=e=>n(e)&&!Object.keys(e).length,E=(e,t,r,s)=>{r(e);let{name:a,...i}=e;return D(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(e=>t[e]===(!s||A.all))},O=e=>Array.isArray(e)?e:[e],C=(e,t,r)=>!e||!t||e===t||O(e).some(e=>e&&(r?e===t:e.startsWith(t)||t.startsWith(e)));function j(e){let t=s.useRef(e);t.current=e,s.useEffect(()=>{let r=!e.disabled&&t.current.subject&&t.current.subject.subscribe({next:t.current.next});return()=>{r&&r.unsubscribe()}},[e.disabled])}var L=e=>"string"==typeof e,T=(e,t,r,s,a)=>L(e)?(s&&t.watch.add(e),g(r,e,a)):Array.isArray(e)?e.map(e=>(s&&t.watch.add(e),g(r,e))):(s&&(t.watchAll=!0),r);let U=e=>e.render(function(e){let t=x(),{name:r,disabled:a,control:i=t.control,shouldUnregister:l}=e,u=f(i._names.array,r),n=function(e){let t=x(),{control:r=t.control,name:a,defaultValue:i,disabled:l,exact:u}=e||{},n=s.useRef(a);n.current=a,j({disabled:l,subject:r._subjects.values,next:e=>{C(n.current,e.name,u)&&d(m(T(n.current,r._names,e.values||r._formValues,!1,i)))}});let[o,d]=s.useState(r._getWatch(a,i));return s.useEffect(()=>r._removeUnmounted()),o}({control:i,name:r,defaultValue:g(i._formValues,r,g(i._defaultValues,r,e.defaultValue)),exact:!0}),d=function(e){let t=x(),{control:r=t.control,disabled:a,name:i,exact:l}=e||{},[u,n]=s.useState(r._formState),o=s.useRef(!0),d=s.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1}),f=s.useRef(i);return f.current=i,j({disabled:a,next:e=>o.current&&C(f.current,e.name,l)&&E(e,d.current,r._updateFormState)&&n({...r._formState,...e}),subject:r._subjects.state}),s.useEffect(()=>(o.current=!0,d.current.isValid&&r._updateValid(!0),()=>{o.current=!1}),[r]),s.useMemo(()=>k(u,r,d.current,!1),[u,r])}({control:i,name:r,exact:!0}),c=s.useRef(i.register(r,{...e.rules,value:n,...b(e.disabled)?{disabled:e.disabled}:{}})),y=s.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!g(d.errors,r)},isDirty:{enumerable:!0,get:()=>!!g(d.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!g(d.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!g(d.validatingFields,r)},error:{enumerable:!0,get:()=>g(d.errors,r)}}),[d,r]),v=s.useMemo(()=>({name:r,value:n,...b(a)||d.disabled?{disabled:d.disabled||a}:{},onChange:e=>c.current.onChange({target:{value:o(e),name:r},type:F.CHANGE}),onBlur:()=>c.current.onBlur({target:{value:g(i._formValues,r),name:r},type:F.BLUR}),ref:e=>{let t=g(i._fields,r);t&&e&&(t._f.ref={focus:()=>e.focus(),select:()=>e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})}}),[r,i._formValues,a,d.disabled,n,i._fields]);return s.useEffect(()=>{let e=i._options.shouldUnregister||l,t=(e,t)=>{let r=g(i._fields,e);r&&r._f&&(r._f.mount=t)};if(t(r,!0),e){let e=m(g(i._options.defaultValues,r));V(i._defaultValues,r,e),h(g(i._formValues,r))&&V(i._formValues,r,e)}return u||i.register(r),()=>{(u?e&&!i._state.action:e)?i.unregister(r):t(r,!1)}},[r,i,u,l]),s.useEffect(()=>{i._updateDisabledField({disabled:a,fields:i._fields,name:r})},[a,r,i]),s.useMemo(()=>({field:v,formState:d,fieldState:y}),[v,d,y])}(e));var B=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},N=e=>({isOnSubmit:!e||e===A.onSubmit,isOnBlur:e===A.onBlur,isOnChange:e===A.onChange,isOnAll:e===A.all,isOnTouch:e===A.onTouched}),M=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));let R=(e,t,r,s)=>{for(let a of r||Object.keys(e)){let r=g(e,a);if(r){let{_f:e,...i}=r;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],a)&&!s||e.ref&&t(e.ref,e.name)&&!s)return!0;if(R(i,t))break}else if(n(i)&&R(i,t))break}}};var q=(e,t,r)=>{let s=O(g(e,r));return V(s,"root",t[r]),V(e,r,s),e},P=e=>"file"===e.type,I=e=>"function"==typeof e,H=e=>{if(!y)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},W=e=>L(e),$=e=>"radio"===e.type,G=e=>e instanceof RegExp;let z={value:!1,isValid:!1},Q={value:!0,isValid:!0};var J=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!h(e[0].attributes.value)?h(e[0].value)||""===e[0].value?Q:{value:e[0].value,isValid:!0}:Q:z}return z};let K={isValid:!1,value:null};var X=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,K):K;function Y(e,t,r="validate"){if(W(e)||Array.isArray(e)&&e.every(W)||b(e)&&!e)return{type:r,message:W(e)?e:"",ref:t}}var Z=e=>n(e)&&!G(e)?e:{value:e,message:""},ee=async(e,t,r,s,i,u)=>{let{ref:o,refs:d,required:f,maxLength:c,minLength:y,min:m,max:v,pattern:p,validate:_,name:V,valueAsNumber:F,mount:A}=e._f,S=g(r,V);if(!A||t.has(V))return{};let x=d?d[0]:o,k=e=>{i&&x.reportValidity&&(x.setCustomValidity(b(e)?"":e||""),x.reportValidity())},E={},O=$(o),C=a(o),j=(F||P(o))&&h(o.value)&&h(S)||H(o)&&""===o.value||""===S||Array.isArray(S)&&!S.length,T=B.bind(null,V,s,E),U=(e,t,r,s=w.maxLength,a=w.minLength)=>{let i=e?t:r;E[V]={type:e?s:a,message:i,ref:o,...T(e?s:a,i)}};if(u?!Array.isArray(S)||!S.length:f&&(!(O||C)&&(j||l(S))||b(S)&&!S||C&&!J(d).isValid||O&&!X(d).isValid)){let{value:e,message:t}=W(f)?{value:!!f,message:f}:Z(f);if(e&&(E[V]={type:w.required,message:t,ref:x,...T(w.required,t)},!s))return k(t),E}if(!j&&(!l(m)||!l(v))){let e,t;let r=Z(v),a=Z(m);if(l(S)||isNaN(S)){let s=o.valueAsDate||new Date(S),i=e=>new Date(new Date().toDateString()+" "+e),l="time"==o.type,u="week"==o.type;L(r.value)&&S&&(e=l?i(S)>i(r.value):u?S>r.value:s>new Date(r.value)),L(a.value)&&S&&(t=l?i(S)r.value),l(a.value)||(t=s+e.value,a=!l(t.value)&&S.length<+t.value;if((r||a)&&(U(r,e.message,t.message),!s))return k(E[V].message),E}if(p&&!j&&L(S)){let{value:e,message:t}=Z(p);if(G(e)&&!S.match(e)&&(E[V]={type:w.pattern,message:t,ref:o,...T(w.pattern,t)},!s))return k(t),E}if(_){if(I(_)){let e=Y(await _(S,r),x);if(e&&(E[V]={...e,...T(w.validate,e.message)},!s))return k(e.message),E}else if(n(_)){let e={};for(let t in _){if(!D(e)&&!s)break;let a=Y(await _[t](S,r),x,t);a&&(e={...a,...T(t,a.message)},k(a.message),s&&(E[V]=e))}if(!D(e)&&(E[V]={ref:x,...e},!s))return E}}return k(!0),E};function et(e,t){let r=Array.isArray(t)?t:p(t)?[t]:_(t),s=1===r.length?e:function(e,t){let r=t.slice(0,-1).length,s=0;for(;s{let e=[];return{get observers(){return e},next:t=>{for(let r of e)r.next&&r.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},es=e=>l(e)||!u(e);function ea(e,t){if(es(e)||es(t))return e===t;if(i(e)&&i(t))return e.getTime()===t.getTime();let r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(let a of r){let r=e[a];if(!s.includes(a))return!1;if("ref"!==a){let e=t[a];if(i(r)&&i(e)||n(r)&&n(e)||Array.isArray(r)&&Array.isArray(e)?!ea(r,e):r!==e)return!1}}return!0}var ei=e=>"select-multiple"===e.type,el=e=>$(e)||a(e),eu=e=>H(e)&&e.isConnected,en=e=>{for(let t in e)if(I(e[t]))return!0;return!1};function eo(e,t={}){let r=Array.isArray(e);if(n(e)||r)for(let r in e)Array.isArray(e[r])||n(e[r])&&!en(e[r])?(t[r]=Array.isArray(e[r])?[]:{},eo(e[r],t[r])):l(e[r])||(t[r]=!0);return t}var ed=(e,t)=>(function e(t,r,s){let a=Array.isArray(t);if(n(t)||a)for(let a in t)Array.isArray(t[a])||n(t[a])&&!en(t[a])?h(r)||es(s[a])?s[a]=Array.isArray(t[a])?eo(t[a],[]):{...eo(t[a])}:e(t[a],l(r)?{}:r[a],s[a]):s[a]=!ea(t[a],r[a]);return s})(e,t,eo(t)),ef=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>h(e)?e:t?""===e?NaN:e?+e:e:r&&L(e)?new Date(e):s?s(e):e;function ec(e){let t=e.ref;return P(t)?t.files:$(t)?X(e.refs).value:ei(t)?[...t.selectedOptions].map(({value:e})=>e):a(t)?J(e.refs).value:ef(h(t.value)?e.ref.value:t.value,e)}var ey=(e,t,r,s)=>{let a={};for(let r of e){let e=g(t,r);e&&V(a,r,e._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}},em=e=>h(e)?e:G(e)?e.source:n(e)?G(e.value)?e.value.source:e.value:e;let ev="AsyncFunction";var eh=e=>!!e&&!!e.validate&&!!(I(e.validate)&&e.validate.constructor.name===ev||n(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===ev)),eg=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function eb(e,t,r){let s=g(e,r);if(s||p(r))return{error:s,name:r};let a=r.split(".");for(;a.length;){let s=a.join("."),i=g(t,s),l=g(e,s);if(i&&!Array.isArray(i)&&r!==s)break;if(l&&l.type)return{name:s,error:l};a.pop()}return{name:r}}var ep=(e,t,r,s,a)=>!a.isOnAll&&(!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:(r?!s.isOnChange:!a.isOnChange)||e),e_=(e,t)=>!v(g(e,t)).length&&et(e,t);let eV={mode:A.onSubmit,reValidateMode:A.onChange,shouldFocusError:!0};function eF(e={}){let t=s.useRef(void 0),r=s.useRef(void 0),[u,d]=s.useState({isDirty:!1,isValidating:!1,isLoading:I(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,defaultValues:I(e.defaultValues)?void 0:e.defaultValues});t.current||(t.current={...function(e={}){let t,r={...eV,...e},s={submitCount:0,isDirty:!1,isLoading:I(r.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:r.errors||{},disabled:r.disabled||!1},u={},d=(n(r.defaultValues)||n(r.values))&&m(r.defaultValues||r.values)||{},c=r.shouldUnregister?{}:m(d),p={action:!1,mount:!1,watch:!1},_={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},w=0,S={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={values:er(),array:er(),state:er()},k=N(r.mode),E=N(r.reValidateMode),C=r.criteriaMode===A.all,j=e=>t=>{clearTimeout(w),w=setTimeout(e,t)},U=async e=>{if(!r.disabled&&(S.isValid||e)){let e=r.resolver?D((await Q()).errors):await K(u,!0);e!==s.isValid&&x.state.next({isValid:e})}},B=(e,t)=>{!r.disabled&&(S.isValidating||S.validatingFields)&&((e||Array.from(_.mount)).forEach(e=>{e&&(t?V(s.validatingFields,e,t):et(s.validatingFields,e))}),x.state.next({validatingFields:s.validatingFields,isValidating:!D(s.validatingFields)}))},W=(e,t)=>{V(s.errors,e,t),x.state.next({errors:s.errors})},$=(e,t,r,s)=>{let a=g(u,e);if(a){let i=g(c,e,h(r)?g(d,e):r);h(i)||s&&s.defaultChecked||t?V(c,e,t?i:ec(a._f)):Z(e,i),p.mount&&U()}},G=(e,t,a,i,l)=>{let n=!1,o=!1,f={name:e};if(!r.disabled){let r=!!(g(u,e)&&g(u,e)._f&&g(u,e)._f.disabled);if(!a||i){S.isDirty&&(o=s.isDirty,s.isDirty=f.isDirty=X(),n=o!==f.isDirty);let a=r||ea(g(d,e),t);o=!!(!r&&g(s.dirtyFields,e)),a||r?et(s.dirtyFields,e):V(s.dirtyFields,e,!0),f.dirtyFields=s.dirtyFields,n=n||S.dirtyFields&&!a!==o}if(a){let t=g(s.touchedFields,e);t||(V(s.touchedFields,e,a),f.touchedFields=s.touchedFields,n=n||S.touchedFields&&t!==a)}n&&l&&x.state.next(f)}return n?f:{}},z=(e,a,i,l)=>{let u=g(s.errors,e),n=S.isValid&&b(a)&&s.isValid!==a;if(r.delayError&&i?(t=j(()=>W(e,i)))(r.delayError):(clearTimeout(w),t=null,i?V(s.errors,e,i):et(s.errors,e)),(i?!ea(u,i):u)||!D(l)||n){let t={...l,...n&&b(a)?{isValid:a}:{},errors:s.errors,name:e};s={...s,...t},x.state.next(t)}},Q=async e=>{B(e,!0);let t=await r.resolver(c,r.context,ey(e||_.mount,u,r.criteriaMode,r.shouldUseNativeValidation));return B(e),t},J=async e=>{let{errors:t}=await Q(e);if(e)for(let r of e){let e=g(t,r);e?V(s.errors,r,e):et(s.errors,r)}else s.errors=t;return t},K=async(e,t,a={valid:!0})=>{for(let i in e){let l=e[i];if(l){let{_f:e,...u}=l;if(e){let u=_.array.has(e.name),n=l._f&&eh(l._f);n&&S.validatingFields&&B([i],!0);let o=await ee(l,_.disabled,c,C,r.shouldUseNativeValidation&&!t,u);if(n&&S.validatingFields&&B([i]),o[e.name]&&(a.valid=!1,t))break;t||(g(o,e.name)?u?q(s.errors,o,e.name):V(s.errors,e.name,o[e.name]):et(s.errors,e.name))}D(u)||await K(u,t,a)}}return a.valid},X=(e,t)=>!r.disabled&&(e&&t&&V(c,e,t),!ea(eA(),d)),Y=(e,t,r)=>T(e,_,{...p.mount?c:h(t)?d:L(e)?{[e]:t}:t},r,t),Z=(e,t,r={})=>{let s=g(u,e),i=t;if(s){let r=s._f;r&&(r.disabled||V(c,e,ef(t,r)),i=H(r.ref)&&l(t)?"":t,ei(r.ref)?[...r.ref.options].forEach(e=>e.selected=i.includes(e.value)):r.refs?a(r.ref)?r.refs.length>1?r.refs.forEach(e=>(!e.defaultChecked||!e.disabled)&&(e.checked=Array.isArray(i)?!!i.find(t=>t===e.value):i===e.value)):r.refs[0]&&(r.refs[0].checked=!!i):r.refs.forEach(e=>e.checked=e.value===i):P(r.ref)?r.ref.value="":(r.ref.value=i,r.ref.type||x.values.next({name:e,values:{...c}})))}(r.shouldDirty||r.shouldTouch)&&G(e,i,r.shouldTouch,r.shouldDirty,!0),r.shouldValidate&&eF(e)},es=(e,t,r)=>{for(let s in t){let a=t[s],l=`${e}.${s}`,o=g(u,l);(_.array.has(e)||n(a)||o&&!o._f)&&!i(a)?es(l,a,r):Z(l,a,r)}},en=(e,t,r={})=>{let a=g(u,e),i=_.array.has(e),n=m(t);V(c,e,n),i?(x.array.next({name:e,values:{...c}}),(S.isDirty||S.dirtyFields)&&r.shouldDirty&&x.state.next({name:e,dirtyFields:ed(d,c),isDirty:X(e,n)})):!a||a._f||l(n)?Z(e,n,r):es(e,n,r),M(e,_)&&x.state.next({...s}),x.values.next({name:p.mount?e:void 0,values:{...c}})},eo=async e=>{p.mount=!0;let a=e.target,l=a.name,n=!0,d=g(u,l),f=e=>{n=Number.isNaN(e)||i(e)&&isNaN(e.getTime())||ea(e,g(c,l,e))};if(d){let i,y;let m=a.type?ec(d._f):o(e),v=e.type===F.BLUR||e.type===F.FOCUS_OUT,h=!eg(d._f)&&!r.resolver&&!g(s.errors,l)&&!d._f.deps||ep(v,g(s.touchedFields,l),s.isSubmitted,E,k),b=M(l,_,v);V(c,l,m),v?(d._f.onBlur&&d._f.onBlur(e),t&&t(0)):d._f.onChange&&d._f.onChange(e);let p=G(l,m,v,!1),A=!D(p)||b;if(v||x.values.next({name:l,type:e.type,values:{...c}}),h)return S.isValid&&("onBlur"===r.mode&&v?U():v||U()),A&&x.state.next({name:l,...b?{}:p});if(!v&&b&&x.state.next({...s}),r.resolver){let{errors:e}=await Q([l]);if(f(m),n){let t=eb(s.errors,u,l),r=eb(e,u,t.name||l);i=r.error,l=r.name,y=D(e)}}else B([l],!0),i=(await ee(d,_.disabled,c,C,r.shouldUseNativeValidation))[l],B([l]),f(m),n&&(i?y=!1:S.isValid&&(y=await K(u,!0)));n&&(d._f.deps&&eF(d._f.deps),z(l,y,i,p))}},ev=(e,t)=>{if(g(s.errors,t)&&e.focus)return e.focus(),1},eF=async(e,t={})=>{let a,i;let l=O(e);if(r.resolver){let t=await J(h(e)?e:l);a=D(t),i=e?!l.some(e=>g(t,e)):a}else e?((i=(await Promise.all(l.map(async e=>{let t=g(u,e);return await K(t&&t._f?{[e]:t}:t)}))).every(Boolean))||s.isValid)&&U():i=a=await K(u);return x.state.next({...!L(e)||S.isValid&&a!==s.isValid?{}:{name:e},...r.resolver||!e?{isValid:a}:{},errors:s.errors}),t.shouldFocus&&!i&&R(u,ev,e?l:_.mount),i},eA=e=>{let t={...p.mount?c:d};return h(e)?t:L(e)?g(t,e):e.map(e=>g(t,e))},ew=(e,t)=>({invalid:!!g((t||s).errors,e),isDirty:!!g((t||s).dirtyFields,e),error:g((t||s).errors,e),isValidating:!!g(s.validatingFields,e),isTouched:!!g((t||s).touchedFields,e)}),eS=(e,t,r)=>{let a=(g(u,e,{_f:{}})._f||{}).ref,{ref:i,message:l,type:n,...o}=g(s.errors,e)||{};V(s.errors,e,{...o,...t,ref:a}),x.state.next({name:e,errors:s.errors,isValid:!1}),r&&r.shouldFocus&&a&&a.focus&&a.focus()},ex=(e,t={})=>{for(let a of e?O(e):_.mount)_.mount.delete(a),_.array.delete(a),t.keepValue||(et(u,a),et(c,a)),t.keepError||et(s.errors,a),t.keepDirty||et(s.dirtyFields,a),t.keepTouched||et(s.touchedFields,a),t.keepIsValidating||et(s.validatingFields,a),r.shouldUnregister||t.keepDefaultValue||et(d,a);x.values.next({values:{...c}}),x.state.next({...s,...t.keepDirty?{isDirty:X()}:{}}),t.keepIsValid||U()},ek=({disabled:e,name:t,field:r,fields:s})=>{(b(e)&&p.mount||e||_.disabled.has(t))&&(e?_.disabled.add(t):_.disabled.delete(t),G(t,ec(r?r._f:g(s,t)._f),!1,!1,!0))},eD=(e,t={})=>{let s=g(u,e),a=b(t.disabled)||b(r.disabled);return V(u,e,{...s||{},_f:{...s&&s._f?s._f:{ref:{name:e}},name:e,mount:!0,...t}}),_.mount.add(e),s?ek({field:s,disabled:b(t.disabled)?t.disabled:r.disabled,name:e}):$(e,!0,t.value),{...a?{disabled:t.disabled||r.disabled}:{},...r.progressive?{required:!!t.required,min:em(t.min),max:em(t.max),minLength:em(t.minLength),maxLength:em(t.maxLength),pattern:em(t.pattern)}:{},name:e,onChange:eo,onBlur:eo,ref:a=>{if(a){eD(e,t),s=g(u,e);let r=h(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,i=el(r),l=s._f.refs||[];(i?l.find(e=>e===r):r===s._f.ref)||(V(u,e,{_f:{...s._f,...i?{refs:[...l.filter(eu),r,...Array.isArray(g(d,e))?[{}]:[]],ref:{type:r.type,name:e}}:{ref:r}}}),$(e,!1,void 0,r))}else(s=g(u,e,{}))._f&&(s._f.mount=!1),(r.shouldUnregister||t.shouldUnregister)&&!(f(_.array,e)&&p.action)&&_.unMount.add(e)}}},eE=()=>r.shouldFocusError&&R(u,ev,_.mount),eO=(e,t)=>async a=>{let i;a&&(a.preventDefault&&a.preventDefault(),a.persist&&a.persist());let l=m(c);if(_.disabled.size)for(let e of _.disabled)V(l,e,void 0);if(x.state.next({isSubmitting:!0}),r.resolver){let{errors:e,values:t}=await Q();s.errors=e,l=t}else await K(u);if(et(s.errors,"root"),D(s.errors)){x.state.next({errors:{}});try{await e(l,a)}catch(e){i=e}}else t&&await t({...s.errors},a),eE(),setTimeout(eE);if(x.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:D(s.errors)&&!i,submitCount:s.submitCount+1,errors:s.errors}),i)throw i},eC=(e,t={})=>{let a=e?m(e):d,i=m(a),l=D(e),n=l?d:i;if(t.keepDefaultValues||(d=a),!t.keepValues){if(t.keepDirtyValues)for(let e of Array.from(new Set([..._.mount,...Object.keys(ed(d,c))])))g(s.dirtyFields,e)?V(n,e,g(c,e)):en(e,g(n,e));else{if(y&&h(e))for(let e of _.mount){let t=g(u,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(H(e)){let t=e.closest("form");if(t){t.reset();break}}}}u={}}c=r.shouldUnregister?t.keepDefaultValues?m(d):{}:m(n),x.array.next({values:{...n}}),x.values.next({values:{...n}})}_={mount:t.keepDirtyValues?_.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},p.mount=!S.isValid||!!t.keepIsValid||!!t.keepDirtyValues,p.watch=!!r.shouldUnregister,x.state.next({submitCount:t.keepSubmitCount?s.submitCount:0,isDirty:!l&&(t.keepDirty?s.isDirty:!!(t.keepDefaultValues&&!ea(e,d))),isSubmitted:!!t.keepIsSubmitted&&s.isSubmitted,dirtyFields:l?{}:t.keepDirtyValues?t.keepDefaultValues&&c?ed(d,c):s.dirtyFields:t.keepDefaultValues&&e?ed(d,e):t.keepDirty?s.dirtyFields:{},touchedFields:t.keepTouched?s.touchedFields:{},errors:t.keepErrors?s.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&s.isSubmitSuccessful,isSubmitting:!1})},ej=(e,t)=>eC(I(e)?e(c):e,t);return{control:{register:eD,unregister:ex,getFieldState:ew,handleSubmit:eO,setError:eS,_executeSchema:Q,_getWatch:Y,_getDirty:X,_updateValid:U,_removeUnmounted:()=>{for(let e of _.unMount){let t=g(u,e);t&&(t._f.refs?t._f.refs.every(e=>!eu(e)):!eu(t._f.ref))&&ex(e)}_.unMount=new Set},_updateFieldArray:(e,t=[],a,i,l=!0,n=!0)=>{if(i&&a&&!r.disabled){if(p.action=!0,n&&Array.isArray(g(u,e))){let t=a(g(u,e),i.argA,i.argB);l&&V(u,e,t)}if(n&&Array.isArray(g(s.errors,e))){let t=a(g(s.errors,e),i.argA,i.argB);l&&V(s.errors,e,t),e_(s.errors,e)}if(S.touchedFields&&n&&Array.isArray(g(s.touchedFields,e))){let t=a(g(s.touchedFields,e),i.argA,i.argB);l&&V(s.touchedFields,e,t)}S.dirtyFields&&(s.dirtyFields=ed(d,c)),x.state.next({name:e,isDirty:X(e,t),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else V(c,e,t)},_updateDisabledField:ek,_getFieldArray:e=>v(g(p.mount?c:d,e,r.shouldUnregister?g(d,e,[]):[])),_reset:eC,_resetDefaultValues:()=>I(r.defaultValues)&&r.defaultValues().then(e=>{ej(e,r.resetOptions),x.state.next({isLoading:!1})}),_updateFormState:e=>{s={...s,...e}},_disableForm:e=>{b(e)&&(x.state.next({disabled:e}),R(u,(t,r)=>{let s=g(u,r);s&&(t.disabled=s._f.disabled||e,Array.isArray(s._f.refs)&&s._f.refs.forEach(t=>{t.disabled=s._f.disabled||e}))},0,!1))},_subjects:x,_proxyFormState:S,_setErrors:e=>{s.errors=e,x.state.next({errors:s.errors,isValid:!1})},get _fields(){return u},get _formValues(){return c},get _state(){return p},set _state(value){p=value},get _defaultValues(){return d},get _names(){return _},set _names(value){_=value},get _formState(){return s},set _formState(value){s=value},get _options(){return r},set _options(value){r={...r,...value}}},trigger:eF,register:eD,handleSubmit:eO,watch:(e,t)=>I(e)?x.values.subscribe({next:r=>e(Y(void 0,t),r)}):Y(e,t,!0),setValue:en,getValues:eA,reset:ej,resetField:(e,t={})=>{g(u,e)&&(h(t.defaultValue)?en(e,m(g(d,e))):(en(e,t.defaultValue),V(d,e,m(t.defaultValue))),t.keepTouched||et(s.touchedFields,e),t.keepDirty||(et(s.dirtyFields,e),s.isDirty=t.defaultValue?X(e,m(g(d,e))):X()),!t.keepError&&(et(s.errors,e),S.isValid&&U()),x.state.next({...s}))},clearErrors:e=>{e&&O(e).forEach(e=>et(s.errors,e)),x.state.next({errors:e?s.errors:{}})},unregister:ex,setError:eS,setFocus:(e,t={})=>{let r=g(u,e),s=r&&r._f;if(s){let e=s.refs?s.refs[0]:s.ref;e.focus&&(e.focus(),t.shouldSelect&&I(e.select)&&e.select())}},getFieldState:ew}}(e),formState:u});let c=t.current.control;return c._options=e,j({subject:c._subjects.state,next:e=>{E(e,c._proxyFormState,c._updateFormState,!0)&&d({...c._formState})}}),s.useEffect(()=>c._disableForm(e.disabled),[c,e.disabled]),s.useEffect(()=>{if(c._proxyFormState.isDirty){let e=c._getDirty();e!==u.isDirty&&c._subjects.state.next({isDirty:e})}},[c,u.isDirty]),s.useEffect(()=>{e.values&&!ea(e.values,r.current)?(c._reset(e.values,c._options.resetOptions),r.current=e.values,d(e=>({...e}))):c._resetDefaultValues()},[e.values,c]),s.useEffect(()=>{e.errors&&c._setErrors(e.errors)},[e.errors,c]),s.useEffect(()=>{c._state.mount||(c._updateValid(),c._state.mount=!0),c._state.watch&&(c._state.watch=!1,c._subjects.state.next({...c._formState})),c._removeUnmounted()}),s.useEffect(()=>{e.shouldUnregister&&c._subjects.values.next({values:c._getWatch()})},[e.shouldUnregister,c]),t.current.formState=k(u,c),t.current}}}]);