var r=require("@hookform/resolvers"),e=require("react-hook-form");function n(){return n=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(r[o]=n[o])}return r},n.apply(null,arguments)}function o(r,e){try{var n=r()}catch(r){return e(r)}return n&&n.then?n.then(void 0,e):n}function t(r,n){for(var o={};r.length;){var t=r[0],s=t.code,i=t.message,a=t.path.join(".");if(!o[a])if("unionErrors"in t){var u,l,c=t.unionErrors.reduce(function(r,e){return e.errors.length<r.errors.length?e:r}).errors[0];o[a]={message:null!=(u=null==c?void 0:c.message)?u:i,type:null!=(l=null==c?void 0:c.code)?l:s}}else o[a]={message:i,type:s};if("unionErrors"in t&&t.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return r.push(e)})}),n){var f=o[a].types,d=f&&f[t.code];o[a]=e.appendErrors(a,n,o,s,d?[].concat(d,t.message):t.message)}r.shift()}return o}function s(r,o){for(var t={},s=function(){var s=r[0],i=s.code,a=s.message,u=s.path.join(".");if(!t[u])if("invalid_union"===s.code&&s.errors.length>0){var l,c,f=s.errors.reduce(function(r,e){return e.length<r.length?e:r})[0];t[u]={message:null!=(l=null==f?void 0:f.message)?l:a,type:null!=(c=null==f?void 0:f.code)?c:i}}else t[u]={message:a,type:i};if("invalid_union"===s.code&&s.errors.forEach(function(e){return e.forEach(function(e){return r.push(n({},e,{path:[].concat(s.path,e.path)}))})}),o){var d=t[u].types,v=d&&d[s.code];t[u]=e.appendErrors(u,o,t,i,v?[].concat(v,s.message):s.message)}r.shift()};r.length;)s();return t}exports.zodResolver=function(e,n,i){if(void 0===i&&(i={}),function(r){return"_zod"in r&&"object"==typeof r._zod}(e))return function(t,a,u){try{return Promise.resolve(o(function(){function o(e){return u.shouldUseNativeValidation&&r.validateFieldsNatively({},u),{errors:{},values:i.raw?Object.assign({},t):e}}var s=e;return"sync"===i.mode?o(s.parse(t,n)):Promise.resolve(s.parseAsync(t,n)).then(o)},function(e){if(function(r){var e;return!(null==r||null==(e=r._zod)||null==(e=e.traits)||!e.has("$ZodError"))}(e))return{values:{},errors:r.toNestErrors(s(e.issues,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw e}))}catch(r){return Promise.reject(r)}};if(function(r){return"_def"in r&&"object"==typeof r._def}(e))return function(s,a,u){try{return Promise.resolve(o(function(){return Promise.resolve(e["sync"===i.mode?"parse":"parseAsync"](s,n)).then(function(e){return u.shouldUseNativeValidation&&r.validateFieldsNatively({},u),{errors:{},values:i.raw?Object.assign({},s):e}})},function(e){if(function(r){return Array.isArray(null==r?void 0:r.issues)}(e))return{values:{},errors:r.toNestErrors(t(e.errors,!u.shouldUseNativeValidation&&"all"===u.criteriaMode),u)};throw e}))}catch(r){return Promise.reject(r)}};throw new Error("Invalid input: not a Zod schema")};
//# sourceMappingURL=zod.js.map
