(n)};`),s)?t.write(`
        if (${i}.issues.length) {
          if (${o} in input) {
            payload.issues = payload.issues.concat(${i}.issues.map(iss => ({
              ...iss,
              path: iss.path ? [${o}, ...iss.path] : [${o}]
            })));
          }
        }
        
        if (${i}.value === undefined) {
          if (${o} in input) {
            newResult[${o}] = undefined;
          }
        } else {
          newResult[${o}] = ${i}.value;
        }
        
      `):t.write(`
        if (${i}.issues.length) {
          payload.issues = payload.issues.concat(${i}.issues.map(iss => ({
            ...iss,
            path: iss.path ? [${o}, ...iss.path] : [${o}]
          })));
        }
        
        if (${i}.value === undefined) {
          if (${o} in input) {
            newResult[${o}] = undefined;
          }
        } else {
          newResult[${o}] = ${i}.value;
        }
        
      `)}t.write("payload.value = newResult;"),t.write("return payload;");let s=t.compile();return(t,i)=>s(e,t,i)})(t.shape)),l=r(l,d),s)?ns([],c,l,d,u,e):l:i(l,d):(l.issues.push({expected:"object",code:"invalid_type",input:c,inst:e}),l)}});function nd(e,t,i,n){for(let i of e)if(0===i.issues.length)return t.value=i.value,t;let r=e.filter(e=>!em(e));return 1===r.length?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:i,errors:e.map(e=>e.issues.map(e=>ev(e,n,h())))}),t)}var nc=m("$ZodUnion",(e,t)=>{ik.init(e,t),D(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),D(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),D(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),D(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>O(e.source)).join("|")})$`)}});let i=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(r,a)=>{if(i)return n(r,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>nd(t,r,e,a)):nd(s,r,e,a)}});function nm(e,t,i,n){let r=e.filter(e=>0===e.issues.length);return 1===r.length?t.value=r[0].value:0===r.length?t.issues.push({code:"invalid_union",input:t.value,inst:i,errors:e.map(e=>e.issues.map(e=>ev(e,n,h())))}):t.issues.push({code:"invalid_union",input:t.value,inst:i,errors:[],inclusive:!1}),t}var nf=m("$ZodXor",(e,t)=>{nc.init(e,t),t.inclusive=!1;let i=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(r,a)=>{if(i)return n(r,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},a);t instanceof Promise?(s.push(t),o=!0):s.push(t)}return o?Promise.all(s).then(t=>nm(t,r,e,a)):nm(s,r,e,a)}}),np=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,nc.init(e,t);let i=e._zod.parse;D(e._zod,"propValues",()=>{let e={};for(let i of t.options){let n=i._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[t,i]of Object.entries(n))for(let n of(e[t]||(e[t]=new Set),i))e[t].add(n)}return e});let n=z(()=>{let e=t.options,i=new Map;for(let n of e){let e=n._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let t of e){if(i.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);i.set(t,n)}}return i});e._zod.parse=(r,a)=>{let o=r.value;if(!F(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),r;let s=n.value.get(o?.[t.discriminator]);return s?s._zod.run(r,a):t.unionFallback?i(r,a):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),r)}}),nv=m("$ZodIntersection",(e,t)=>{ik.init(e,t),e._zod.parse=(e,i)=>{let n=e.value,r=t.left._zod.run({value:n,issues:[]},i),a=t.right._zod.run({value:n,issues:[]},i);return r instanceof Promise||a instanceof Promise?Promise.all([r,a]).then(([t,i])=>ng(e,t,i)):ng(e,r,a)}});function ng(e,t,i){let n=new Map,r;for(let i of t.issues)if("unrecognized_keys"===i.code)for(let e of(r??(r=i),i.keys))n.has(e)||n.set(e,{}),n.get(e).l=!0;else e.issues.push(i);for(let t of i.issues)if("unrecognized_keys"===t.code)for(let e of t.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(t);let a=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&r&&e.issues.push({...r,keys:a}),em(e))return e;let o=function e(t,i){if(t===i||t instanceof Date&&i instanceof Date&&+t==+i)return{valid:!0,data:t};if(q(t)&&q(i)){let n=Object.keys(i),r=Object.keys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...i};for(let n of r){let r=e(t[n],i[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};a[n]=r.data}return{valid:!0,data:a}}if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<t.length;r++){let a=e(t[r],i[r]);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}(t.value,i.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var nh=m("$ZodTuple",(e,t)=>{ik.init(e,t);let i=t.items;e._zod.parse=(n,r)=>{let a=n.value;if(!Array.isArray(a))return n.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let o=[],s=[...i].reverse().findIndex(e=>"optional"!==e._zod.optin),u=-1===s?0:i.length-s;if(!t.rest){let t=a.length>i.length,r=a.length<u-1;if(t||r)return n.issues.push({...t?{code:"too_big",maximum:i.length,inclusive:!0}:{code:"too_small",minimum:i.length},input:a,inst:e,origin:"array"}),n}let l=-1;for(let e of i){if(++l>=a.length&&l>=u)continue;let t=e._zod.run({value:a[l],issues:[]},r);t instanceof Promise?o.push(t.then(e=>n$(e,n,l))):n$(t,n,l)}if(t.rest)for(let e of a.slice(i.length)){l++;let i=t.rest._zod.run({value:e,issues:[]},r);i instanceof Promise?o.push(i.then(e=>n$(e,n,l))):n$(i,n,l)}return o.length?Promise.all(o).then(()=>n):n}});function n$(e,t,i){e.issues.length&&t.issues.push(...ef(i,e.issues)),t.value[i]=e.value}var nb=m("$ZodRecord",(e,t)=>{ik.init(e,t),e._zod.parse=(i,n)=>{let r=i.value;if(!q(r))return i.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),i;let a=[],o=t.keyType._zod.values;if(o){let s;i.value={};let u=new Set;for(let e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){u.add("number"==typeof e?e.toString():e);let o=t.valueType._zod.run({value:r[e],issues:[]},n);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&i.issues.push(...ef(e,t.issues)),i.value[e]=t.value})):(o.issues.length&&i.issues.push(...ef(e,o.issues)),i.value[e]=o.value)}for(let e in r)u.has(e)||(s=s??[]).push(e);s&&s.length>0&&i.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:s})}else for(let o of(i.value={},Reflect.ownKeys(r))){if("__proto__"===o)continue;let s=t.keyType._zod.run({value:o,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof o&&tE.test(o)&&s.issues.length&&s.issues.some(e=>"invalid_type"===e.code&&"number"===e.expected)){let e=t.keyType._zod.run({value:Number(o),issues:[]},n);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(s=e)}if(s.issues.length){"loose"===t.mode?i.value[o]=r[o]:i.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>ev(e,n,h())),input:o,path:[o],inst:e});continue}let u=t.valueType._zod.run({value:r[o],issues:[]},n);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&i.issues.push(...ef(o,e.issues)),i.value[s.value]=e.value})):(u.issues.length&&i.issues.push(...ef(o,u.issues)),i.value[s.value]=u.value)}return a.length?Promise.all(a).then(()=>i):i}}),ny=m("$ZodMap",(e,t)=>{ik.init(e,t),e._zod.parse=(i,n)=>{let r=i.value;if(!(r instanceof Map))return i.issues.push({expected:"map",code:"invalid_type",input:r,inst:e}),i;let a=[];for(let[o,s]of(i.value=new Map,r)){let u=t.keyType._zod.run({value:o,issues:[]},n),l=t.valueType._zod.run({value:s,issues:[]},n);u instanceof Promise||l instanceof Promise?a.push(Promise.all([u,l]).then(([t,a])=>{n_(t,a,i,o,r,e,n)})):n_(u,l,i,o,r,e,n)}return a.length?Promise.all(a).then(()=>i):i}});function n_(e,t,i,n,r,a,o){e.issues.length&&(B.has(typeof n)?i.issues.push(...ef(n,e.issues)):i.issues.push({code:"invalid_key",origin:"map",input:r,inst:a,issues:e.issues.map(e=>ev(e,o,h()))})),t.issues.length&&(B.has(typeof n)?i.issues.push(...ef(n,t.issues)):i.issues.push({origin:"map",code:"invalid_element",input:r,inst:a,key:n,issues:t.issues.map(e=>ev(e,o,h()))})),i.value.set(e.value,t.value)}var nx=m("$ZodSet",(e,t)=>{ik.init(e,t),e._zod.parse=(i,n)=>{let r=i.value;if(!(r instanceof Set))return i.issues.push({input:r,inst:e,expected:"set",code:"invalid_type"}),i;let a=[];for(let e of(i.value=new Set,r)){let r=t.valueType._zod.run({value:e,issues:[]},n);r instanceof Promise?a.push(r.then(e=>nk(e,i))):nk(r,i)}return a.length?Promise.all(a).then(()=>i):i}});function nk(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var nI=m("$ZodEnum",(e,t)=>{ik.init(e,t);let i=I(t.entries),n=new Set(i);e._zod.values=n,e._zod.pattern=RegExp(`^(${i.filter(e=>B.has(typeof e)).map(e=>"string"==typeof e?H(e):e.toString()).join("|")})$`),e._zod.parse=(t,r)=>{let a=t.value;return n.has(a)||t.issues.push({code:"invalid_value",values:i,input:a,inst:e}),t}}),nw=m("$ZodLiteral",(e,t)=>{if(ik.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");let i=new Set(t.values);e._zod.values=i,e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?H(e):e?H(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,r)=>{let a=n.value;return i.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),nS=m("$ZodFile",(e,t)=>{ik.init(e,t),e._zod.parse=(t,i)=>{let n=t.value;return n instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),t}}),nz=m("$ZodTransform",(e,t)=>{ik.init(e,t),e._zod.parse=(i,n)=>{if("backward"===n.direction)throw new v(e.constructor.name);let r=t.transform(i.value,i);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(e=>(i.value=e,i));if(r instanceof Promise)throw new p;return i.value=r,i}});function nU(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}var nO=m("$ZodOptional",(e,t)=>{ik.init(e,t),e._zod.optin="optional",e._zod.optout="optional",D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${O(e.source)})?$`):void 0}),e._zod.parse=(e,i)=>{if("optional"===t.innerType._zod.optin){let n=t.innerType._zod.run(e,i);return n instanceof Promise?n.then(t=>nU(t,e.value)):nU(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,i)}}),nj=m("$ZodExactOptional",(e,t)=>{nO.init(e,t),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,i)=>t.innerType._zod.run(e,i)}),nZ=m("$ZodNullable",(e,t)=>{ik.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${O(e.source)}|null)$`):void 0}),D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,i)=>null===e.value?e:t.innerType._zod.run(e,i)}),nD=m("$ZodDefault",(e,t)=>{ik.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,i)=>{if("backward"===i.direction)return t.innerType._zod.run(e,i);if(void 0===e.value)return e.value=t.defaultValue,e;let n=t.innerType._zod.run(e,i);return n instanceof Promise?n.then(e=>nN(e,t)):nN(n,t)}});function nN(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var nP=m("$ZodPrefault",(e,t)=>{ik.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,i)=>("backward"===i.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,i))}),nE=m("$ZodNonOptional",(e,t)=>{ik.init(e,t),D(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(i,n)=>{let r=t.innerType._zod.run(i,n);return r instanceof Promise?r.then(t=>nT(t,e)):nT(r,e)}});function nT(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var nA=m("$ZodSuccess",(e,t)=>{ik.init(e,t),e._zod.parse=(e,i)=>{if("backward"===i.direction)throw new v("ZodSuccess");let n=t.innerType._zod.run(e,i);return n instanceof Promise?n.then(t=>(e.value=0===t.issues.length,e)):(e.value=0===n.issues.length,e)}}),nC=m("$ZodCatch",(e,t)=>{ik.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,i)=>{if("backward"===i.direction)return t.innerType._zod.run(e,i);let n=t.innerType._zod.run(e,i);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>ev(e,i,h()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>ev(e,i,h()))},input:e.value}),e.issues=[]),e)}}),nR=m("$ZodNaN",(e,t)=>{ik.init(e,t),e._zod.parse=(t,i)=>("number"==typeof t.value&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:"nan",code:"invalid_type"}),t)}),nL=m("$ZodPipe",(e,t)=>{ik.init(e,t),D(e._zod,"values",()=>t.in._zod.values),D(e._zod,"optin",()=>t.in._zod.optin),D(e._zod,"optout",()=>t.out._zod.optout),D(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,i)=>{if("backward"===i.direction){let n=t.out._zod.run(e,i);return n instanceof Promise?n.then(e=>nJ(e,t.in,i)):nJ(n,t.in,i)}let n=t.in._zod.run(e,i);return n instanceof Promise?n.then(e=>nJ(e,t.out,i)):nJ(n,t.out,i)}});function nJ(e,t,i){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},i)}var nM=m("$ZodCodec",(e,t)=>{ik.init(e,t),D(e._zod,"values",()=>t.in._zod.values),D(e._zod,"optin",()=>t.in._zod.optin),D(e._zod,"optout",()=>t.out._zod.optout),D(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,i)=>{if("forward"===(i.direction||"forward")){let n=t.in._zod.run(e,i);return n instanceof Promise?n.then(e=>nF(e,t,i)):nF(n,t,i)}{let n=t.out._zod.run(e,i);return n instanceof Promise?n.then(e=>nF(e,t,i)):nF(n,t,i)}}});function nF(e,t,i){if(e.issues.length)return e.aborted=!0,e;if("forward"===(i.direction||"forward")){let n=t.transform(e.value,e);return n instanceof Promise?n.then(n=>nW(e,n,t.out,i)):nW(e,n,t.out,i)}{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(n=>nW(e,n,t.in,i)):nW(e,n,t.in,i)}}function nW(e,t,i,n){return e.issues.length?(e.aborted=!0,e):i._zod.run({value:t,issues:e.issues},n)}var nq=m("$ZodReadonly",(e,t)=>{ik.init(e,t),D(e._zod,"propValues",()=>t.innerType._zod.propValues),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"optin",()=>t.innerType?._zod?.optin),D(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,i)=>{if("backward"===i.direction)return t.innerType._zod.run(e,i);let n=t.innerType._zod.run(e,i);return n instanceof Promise?n.then(