import{validateFieldsNatively as r,toNestErrors as e}from"@hookform/resolvers";import{appendErrors as o}from"react-hook-form";import*as s from"zod/v4/core";function n(){return n=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var s in o)({}).hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},n.apply(null,arguments)}function t(r,e){const s={};for(;r.length;){const n=r[0],{code:t,message:a,path:i}=n,c=i.join(".");if(!s[c])if("unionErrors"in n){const r=n.unionErrors[0].errors[0];s[c]={message:r.message,type:r.code}}else s[c]={message:a,type:t};if("unionErrors"in n&&n.unionErrors.forEach(e=>e.errors.forEach(e=>r.push(e))),e){const r=s[c].types,a=r&&r[n.code];s[c]=o(c,e,s,t,a?[].concat(a,n.message):n.message)}r.shift()}return s}function a(r,e){const s={};for(;r.length;){const t=r[0],{code:a,message:i,path:c}=t,f=c.join(".");if(!s[f])if("invalid_union"===t.code&&t.errors.length>0){const r=t.errors[0][0];s[f]={message:r.message,type:r.code}}else s[f]={message:i,type:a};if("invalid_union"===t.code&&t.errors.forEach(e=>e.forEach(e=>r.push(n({},e,{path:[...t.path,...e.path]})))),e){const r=s[f].types,n=r&&r[t.code];s[f]=o(f,e,s,a,n?[].concat(n,t.message):t.message)}r.shift()}return s}function i(o,n,i={}){if((r=>"_def"in r&&"object"==typeof r._def&&"typeName"in r._def)(o))return async(s,a,c)=>{try{const e=await o["sync"===i.mode?"parse":"parseAsync"](s,n);return c.shouldUseNativeValidation&&r({},c),{errors:{},values:i.raw?Object.assign({},s):e}}catch(r){if((r=>Array.isArray(null==r?void 0:r.issues))(r))return{values:{},errors:e(t(r.errors,!c.shouldUseNativeValidation&&"all"===c.criteriaMode),c)};throw r}};if((r=>"_zod"in r&&"object"==typeof r._zod)(o))return async(t,c,f)=>{try{const e="sync"===i.mode?s.parse:s.parseAsync,a=await e(o,t,n);return f.shouldUseNativeValidation&&r({},f),{errors:{},values:i.raw?Object.assign({},t):a}}catch(r){if((r=>r instanceof s.$ZodError)(r))return{values:{},errors:e(a(r.issues,!f.shouldUseNativeValidation&&"all"===f.criteriaMode),f)};throw r}};throw new Error("Invalid input: not a Zod schema")}export{i as zodResolver};
//# sourceMappingURL=zod.modern.mjs.map
