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){for(var o=Object.create(null);r.length;){var t=r[0],a=t.type,i=t.message,n=t.path.substring(1).replace(/\//g,".");if(o[n]||(o[n]={message:i,type:""+a}),e){var l=o[n].types,m=l&&l[""+a];o[n]=s(n,e,o,""+a,m?[].concat(m,t.message):t.message)}r.shift()}return o}function i(s){return function(i,n,l){try{var m=Array.from(s instanceof o?s.Errors(i):t.Errors(s,i));return l.shouldUseNativeValidation&&r({},l),Promise.resolve(m.length?{values:{},errors:e(a(m,!l.shouldUseNativeValidation&&"all"===l.criteriaMode),l)}:{errors:{},values:i})}catch(r){return Promise.reject(r)}}}export{i as typeboxResolver};
//# sourceMappingURL=typebox.module.js.map
