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