import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{TypeCheck as o}from"@sinclair/typebox/compiler";import{Value as t}from"@sinclair/typebox/value";import{appendErrors as s}from"react-hook-form";function a(r,e){const o=Object.create(null);for(;r.length;){const t=r[0],{type:a,message:i,path:n}=t,c=n.substring(1).replace(/\//g,".");if(o[c]||(o[c]={message:i,type:""+a}),e){const r=o[c].types,i=r&&r[""+a];o[c]=s(c,e,o,""+a,i?[].concat(i,t.message):t.message)}r.shift()}return o}function i(s){return async(i,n,c)=>{const l=Array.from(s instanceof o?s.Errors(i):t.Errors(s,i));return c.shouldUseNativeValidation&&r({},c),l.length?{values:{},errors:e(a(l,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)}:{errors:{},values:i}}}export{i as typeboxResolver};
//# sourceMappingURL=typebox.modern.mjs.map
