import{g as v,s as l,d as m}from"./index.esm-CAGtek53.js";var h=function(r,e,t){if(r&&"reportValidity"in r){var n=v(t,e);r.setCustomValidity(n&&n.message||""),r.reportValidity()}},y=function(r,e){var t=function(f){var i=e.fields[f];i&&i.ref&&"reportValidity"in i.ref?h(i.ref,f,r):i.refs&&i.refs.forEach(function(a){return h(a,f,r)})};for(var n in e.fields)t(n)},g=function(r,e){e.shouldUseNativeValidation&&y(r,e);var t={};for(var n in r){var f=v(e.fields,n),i=Object.assign(r[n]||{},{ref:f&&f.ref});if(V(e.names||Object.keys(r),n)){var a=Object.assign({},v(t,n));l(a,"root",i),l(t,n,a)}else l(t,n,i)}return t},V=function(r,e){return r.some(function(t){return t.startsWith(e+".")})};function j(r,e,t){return e===void 0&&(e={}),t===void 0&&(t={}),function(n,f,i){try{return Promise.resolve((function(a,c){try{var u=(e.context,Promise.resolve(r[t.mode==="sync"?"validateSync":"validate"](n,Object.assign({abortEarly:!1},e,{context:f}))).then(function(s){return i.shouldUseNativeValidation&&y({},i),{values:t.raw?n:s,errors:{}}}))}catch(s){return c(s)}return u&&u.then?u.then(void 0,c):u})(0,function(a){if(!a.inner)throw a;return{values:{},errors:g((c=a,u=!i.shouldUseNativeValidation&&i.criteriaMode==="all",(c.inner||[]).reduce(function(s,o){if(s[o.path]||(s[o.path]={message:o.message,type:o.type}),u){var d=s[o.path].types,p=d&&d[o.type];s[o.path]=m(o.path,u,s,o.type,p?[].concat(p,o.message):o.message)}return s},{})),i)};var c,u}))}catch(a){return Promise.reject(a)}}}export{j as o};
