import{c as e,l as t,u as n}from"./form-CVrsvflM.js";import{E as r,T as i,w as a}from"./schemas-DQQutaZ2.js";var o=(e,n,r)=>{if(e&&`reportValidity`in e){let i=t(r,n);e.setCustomValidity(i&&i.message||``),e.reportValidity()}},s=(e,t)=>{for(let n in t.fields){let r=t.fields[n];r&&r.ref&&`reportValidity`in r.ref?o(r.ref,n,e):r&&r.refs&&r.refs.forEach(t=>o(t,n,e))}},c=(e,r)=>{r.shouldUseNativeValidation&&s(e,r);let i={};for(let a in e){let o=t(r.fields,a),s=Object.assign(e[a]||{},{ref:o&&o.ref});if(l(r.names||Object.keys(e),a)){let e=Object.assign({},t(i,a));n(e,`root`,s),n(i,a,e)}else n(i,a,s)}return i},l=(e,t)=>{let n=u(t);return e.some(e=>u(e).match(`^${n}\\.\\d+`))};function u(e){return e.replace(/\]|\[/g,``)}function d(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}function f(t,n){for(var r={};t.length;){var i=t[0],a=i.code,o=i.message,s=i.path.join(`.`);if(!r[s])if(`unionErrors`in i){var c=i.unionErrors[0].errors[0];r[s]={message:c.message,type:c.code}}else r[s]={message:o,type:a};if(`unionErrors`in i&&i.unionErrors.forEach(function(e){return e.errors.forEach(function(e){return t.push(e)})}),n){var l=r[s].types,u=l&&l[i.code];r[s]=e(s,n,r,a,u?[].concat(u,i.message):i.message)}t.shift()}return r}function p(t,n){for(var r={};t.length;){var i=t[0],a=i.code,o=i.message,s=i.path.join(`.`);if(!r[s])if(i.code===`invalid_union`&&i.errors.length>0){var c=i.errors[0][0];r[s]={message:c.message,type:c.code}}else r[s]={message:o,type:a};if(i.code===`invalid_union`&&i.errors.forEach(function(e){return e.forEach(function(e){return t.push(e)})}),n){var l=r[s].types,u=l&&l[i.code];r[s]=e(s,n,r,a,u?[].concat(u,i.message):i.message)}t.shift()}return r}function m(e,t,n){if(n===void 0&&(n={}),function(e){return`_def`in e&&typeof e._def==`object`&&`typeName`in e._def}(e))return function(r,i,a){try{return Promise.resolve(d(function(){return Promise.resolve(e[n.mode===`sync`?`parse`:`parseAsync`](r,t)).then(function(e){return a.shouldUseNativeValidation&&s({},a),{errors:{},values:n.raw?Object.assign({},r):e}})},function(e){if(function(e){return Array.isArray(e?.issues)}(e))return{values:{},errors:c(f(e.errors,!a.shouldUseNativeValidation&&a.criteriaMode===`all`),a)};throw e}))}catch(e){return Promise.reject(e)}};if(function(e){return`_zod`in e&&typeof e._zod==`object`}(e))return function(o,l,u){try{return Promise.resolve(d(function(){return Promise.resolve((n.mode===`sync`?a:i)(e,o,t)).then(function(e){return u.shouldUseNativeValidation&&s({},u),{errors:{},values:n.raw?Object.assign({},o):e}})},function(e){if(function(e){return e instanceof r}(e))return{values:{},errors:c(p(e.issues,!u.shouldUseNativeValidation&&u.criteriaMode===`all`),u)};throw e}))}catch(e){return Promise.reject(e)}};throw Error(`Invalid input: not a Zod schema`)}export{m as t};