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