@svazqz/api-contract-kit 0.1.6-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x;(function(s){s.assertEqual=a=>a;function e(a){}s.assertIs=e;function t(a){throw new Error}s.assertNever=t,s.arrayToEnum=a=>{const n={};for(const i of a)n[i]=i;return n},s.getValidEnumValues=a=>{const n=s.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of n)i[o]=a[o];return s.objectValues(i)},s.objectValues=a=>s.objectKeys(a).map(function(n){return a[n]}),s.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const n=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&n.push(i);return n},s.find=(a,n)=>{for(const i of a)if(n(i))return i},s.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,n=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(n)}s.joinValues=r,s.jsonStringifyReplacer=(a,n)=>typeof n=="bigint"?n.toString():n})(x||(x={}));var Se;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Se||(Se={}));const l=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=s=>{switch(typeof s){case"undefined":return l.undefined;case"string":return l.string;case"number":return isNaN(s)?l.nan:l.number;case"boolean":return l.boolean;case"function":return l.function;case"bigint":return l.bigint;case"symbol":return l.symbol;case"object":return Array.isArray(s)?l.array:s===null?l.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?l.promise:typeof Map<"u"&&s instanceof Map?l.map:typeof Set<"u"&&s instanceof Set?l.set:typeof Date<"u"&&s instanceof Date?l.date:l.object;default:return l.unknown}},d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class C extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(n){return n.message},r={_errors:[]},a=n=>{for(const i of n.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return a(this),r}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}C.create=s=>new C(s);const Q=(s,e)=>{let t;switch(s.code){case d.invalid_type:s.received===l.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case d.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case d.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let Ae=Q;function ce(){return Ae}const ue=s=>{const{data:e,path:t,errorMaps:r,issueData:a}=s,n=[...t,...a.path||[]],i={...a,path:n};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...a,path:n,message:a.message||o}};function h(s,e){const t=ue({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,ce(),Q].filter(r=>!!r)});s.common.issues.push(t)}class R{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const a of t){if(a.status==="aborted")return v;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const a of t)r.push({key:await a.key,value:await a.value});return R.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:n,value:i}=a;if(n.status==="aborted"||i.status==="aborted")return v;n.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),n.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(r[n.value]=i.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),Ie=s=>({status:"dirty",value:s}),S=s=>({status:"valid",value:s}),Ce=s=>s.status==="aborted",Ne=s=>s.status==="dirty",X=s=>s.status==="valid",le=s=>typeof Promise<"u"&&s instanceof Promise;var f;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(f||(f={}));class O{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Oe=(s,e)=>{if(X(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new C(s.common.issues);return this._error=t,this._error}}};function y(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:a}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:r??o.defaultError}:{message:t??o.defaultError},description:a}}class _{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(le(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const a={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},n=this._parseSync({data:e,path:a.path,parent:a});return Oe(a,n)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parse({data:e,path:r.path,parent:r}),n=await(le(a)?a:Promise.resolve(a));return Oe(r,n)}refine(e,t){const r=a=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(a):t;return this._refinement((a,n)=>{const i=e(a),o=()=>n.addIssue({code:d.custom,...r(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof t=="function"?t(r,a):t),!1))}_refinement(e){return new j({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return A.create(this,this._def)}nullable(){return B.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return N.create(this,this._def)}promise(){return J.create(this,this._def)}or(e){return ee.create([this,e],this._def)}and(e){return te.create(this,e,this._def)}transform(e){return new j({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ie({...y(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new Je({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ve({...y(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return oe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Pe=/^c[^\s-]{8,}$/i,Me=/^[a-z][a-z0-9]*$/,$e=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ve=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Le=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ue="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let de;const De=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ze=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Be=s=>s.precision?s.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${s.precision}}Z$`):s.precision===0?s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):s.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function We(s,e){return!!((e==="v4"||!e)&&De.test(s)||(e==="v6"||!e)&&ze.test(s))}class E extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==l.string){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:l.string,received:n.parsedType}),v}const r=new R;let a;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){const i=e.data.length>n.value,o=e.data.length<n.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?h(a,{code:d.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):o&&h(a,{code:d.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Le.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"email",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")de||(de=new RegExp(Ue,"u")),de.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"emoji",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")Ve.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"uuid",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")Pe.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")Me.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid2",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")$e.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ulid",code:d.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),h(a,{validation:"url",code:d.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"regex",code:d.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?Be(n).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:d.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="ip"?We(e.data,n.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ip",code:d.invalid_string,message:n.message}),r.dirty()):x.assertNever(n);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(a=>e.test(a),{validation:t,code:d.invalid_string,...f.errToObj(r)})}_addCheck(e){return new E({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...f.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...f.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...f.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...f.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...f.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...f.errToObj(t)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new E({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}E.create=s=>{var e;return new E({checks:[],typeName:p.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};function He(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=t>r?t:r,n=parseInt(s.toFixed(a).replace(".","")),i=parseInt(e.toFixed(a).replace(".",""));return n%i/Math.pow(10,a)}class M extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==l.number){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:l.number,received:n.parsedType}),v}let r;const a=new R;for(const n of this._def.checks)n.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:d.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?He(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_finite,message:n.message}),a.dirty()):x.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,r,a){return new M({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:f.toString(a)}]})}_addCheck(e){return new M({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}M.create=s=>new M({checks:[],typeName:p.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class D extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==l.bigint){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:l.bigint,received:n.parsedType}),v}let r;const a=new R;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):x.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,r,a){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:f.toString(a)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=s=>{var e;return new D({checks:[],typeName:p.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};class q extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==l.boolean){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.boolean,received:r.parsedType}),v}return S(e.data)}}q.create=s=>new q({typeName:p.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class H extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==l.date){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_type,expected:l.date,received:n.parsedType}),v}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return h(n,{code:d.invalid_date}),v}const r=new R;let a;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:d.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):x.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}H.create=s=>new H({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:p.ZodDate,...y(s)});class he extends _{_parse(e){if(this._getType(e)!==l.symbol){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.symbol,received:r.parsedType}),v}return S(e.data)}}he.create=s=>new he({typeName:p.ZodSymbol,...y(s)});class K extends _{_parse(e){if(this._getType(e)!==l.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.undefined,received:r.parsedType}),v}return S(e.data)}}K.create=s=>new K({typeName:p.ZodUndefined,...y(s)});class F extends _{_parse(e){if(this._getType(e)!==l.null){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.null,received:r.parsedType}),v}return S(e.data)}}F.create=s=>new F({typeName:p.ZodNull,...y(s)});class fe extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}}fe.create=s=>new fe({typeName:p.ZodAny,...y(s)});class U extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}}U.create=s=>new U({typeName:p.ZodUnknown,...y(s)});class I extends _{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:l.never,received:t.parsedType}),v}}I.create=s=>new I({typeName:p.ZodNever,...y(s)});class pe extends _{_parse(e){if(this._getType(e)!==l.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.void,received:r.parsedType}),v}return S(e.data)}}pe.create=s=>new pe({typeName:p.ZodVoid,...y(s)});class N extends _{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==l.array)return h(t,{code:d.invalid_type,expected:l.array,received:t.parsedType}),v;if(a.exactLength!==null){const i=t.data.length>a.exactLength.value,o=t.data.length<a.exactLength.value;(i||o)&&(h(t,{code:i?d.too_big:d.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&t.data.length<a.minLength.value&&(h(t,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&t.data.length>a.maxLength.value&&(h(t,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>a.type._parseAsync(new O(t,i,t.path,o)))).then(i=>R.mergeArray(r,i));const n=[...t.data].map((i,o)=>a.type._parseSync(new O(t,i,t.path,o)));return R.mergeArray(r,n)}get element(){return this._def.type}min(e,t){return new N({...this._def,minLength:{value:e,message:f.toString(t)}})}max(e,t){return new N({...this._def,maxLength:{value:e,message:f.toString(t)}})}length(e,t){return new N({...this._def,exactLength:{value:e,message:f.toString(t)}})}nonempty(e){return this.min(1,e)}}N.create=(s,e)=>new N({type:s,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function L(s){if(s instanceof b){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=A.create(L(r))}return new b({...s._def,shape:()=>e})}else return s instanceof N?new N({...s._def,type:L(s.element)}):s instanceof A?A.create(L(s.unwrap())):s instanceof B?B.create(L(s.unwrap())):s instanceof Z?Z.create(s.items.map(e=>L(e))):s}class b extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==l.object){const u=this._getOrReturnCtx(e);return h(u,{code:d.invalid_type,expected:l.object,received:u.parsedType}),v}const{status:r,ctx:a}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof I&&this._def.unknownKeys==="strip"))for(const u in a.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const m=n[u],w=a.data[u];c.push({key:{status:"valid",value:u},value:m._parse(new O(a,w,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof I){const u=this._def.unknownKeys;if(u==="passthrough")for(const m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(u==="strict")o.length>0&&(h(a,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const m of o){const w=a.data[m];c.push({key:{status:"valid",value:m},value:u._parse(new O(a,w,a.path,m)),alwaysSet:m in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const m of c){const w=await m.key;u.push({key:w,value:await m.value,alwaysSet:m.alwaysSet})}return u}).then(u=>R.mergeObjectSync(r,u)):R.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var a,n,i,o;const c=(i=(n=(a=this._def).errorMap)===null||n===void 0?void 0:n.call(a,t,r).message)!==null&&i!==void 0?i:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=f.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new b({...this._def,shape:()=>t})}deepPartial(){return L(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?t[r]=a:t[r]=a.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let n=this.shape[r];for(;n instanceof A;)n=n._def.innerType;t[r]=n}}),new b({...this._def,shape:()=>t})}keyof(){return Ee(x.objectKeys(this.shape))}}b.create=(s,e)=>new b({shape:()=>s,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});b.strictCreate=(s,e)=>new b({shape:()=>s,unknownKeys:"strict",catchall:I.create(),typeName:p.ZodObject,...y(e)});b.lazycreate=(s,e)=>new b({shape:s,unknownKeys:"strip",catchall:I.create(),typeName:p.ZodObject,...y(e)});class ee extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function a(n){for(const o of n)if(o.result.status==="valid")return o.result;for(const o of n)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=n.map(o=>new C(o.ctx.common.issues));return h(t,{code:d.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(r.map(async n=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await n._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(a);{let n;const i=[];for(const c of r){const u={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!n&&(n={result:m,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(n)return t.common.issues.push(...n.ctx.common.issues),n.result;const o=i.map(c=>new C(c));return h(t,{code:d.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}ee.create=(s,e)=>new ee({options:s,typeName:p.ZodUnion,...y(e)});const Y=s=>s instanceof re?Y(s.schema):s instanceof j?Y(s.innerType()):s instanceof ae?[s.value]:s instanceof $?s.options:s instanceof ne?Object.keys(s.enum):s instanceof ie?Y(s._def.innerType):s instanceof K?[void 0]:s instanceof F?[null]:null;class xe extends _{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.object)return h(t,{code:d.invalid_type,expected:l.object,received:t.parsedType}),v;const r=this.discriminator,a=t.data[r],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const n of t){const i=Y(n.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,n)}}return new xe({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...y(r)})}}function me(s,e){const t=P(s),r=P(e);if(s===e)return{valid:!0,data:s};if(t===l.object&&r===l.object){const a=x.objectKeys(e),n=x.objectKeys(s).filter(o=>a.indexOf(o)!==-1),i={...s,...e};for(const o of n){const c=me(s[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===l.array&&r===l.array){if(s.length!==e.length)return{valid:!1};const a=[];for(let n=0;n<s.length;n++){const i=s[n],o=e[n],c=me(i,o);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return t===l.date&&r===l.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class te extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(n,i)=>{if(Ce(n)||Ce(i))return v;const o=me(n.value,i.value);return o.valid?((Ne(n)||Ne(i))&&t.dirty(),{status:t.value,value:o.data}):(h(r,{code:d.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,i])=>a(n,i)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}te.create=(s,e,t)=>new te({left:s,right:e,typeName:p.ZodIntersection,...y(t)});class Z extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.array)return h(r,{code:d.invalid_type,expected:l.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new O(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(n).then(i=>R.mergeArray(t,i)):R.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Z({...this._def,rest:e})}}Z.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:s,typeName:p.ZodTuple,rest:null,...y(e)})};class se extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.object)return h(r,{code:d.invalid_type,expected:l.object,received:r.parsedType}),v;const a=[],n=this._def.keyType,i=this._def.valueType;for(const o in r.data)a.push({key:n._parse(new O(r,o,r.path,o)),value:i._parse(new O(r,r.data[o],r.path,o))});return r.common.async?R.mergeObjectAsync(t,a):R.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof _?new se({keyType:e,valueType:t,typeName:p.ZodRecord,...y(r)}):new se({keyType:E.create(),valueType:e,typeName:p.ZodRecord,...y(t)})}}class ye extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.map)return h(r,{code:d.invalid_type,expected:l.map,received:r.parsedType}),v;const a=this._def.keyType,n=this._def.valueType,i=[...r.data.entries()].map(([o,c],u)=>({key:a._parse(new O(r,o,r.path,[u,"key"])),value:n._parse(new O(r,c,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,m=await c.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,m=c.value;if(u.status==="aborted"||m.status==="aborted")return v;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}}}}ye.create=(s,e,t)=>new ye({valueType:e,keyType:s,typeName:p.ZodMap,...y(t)});class z extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==l.set)return h(r,{code:d.invalid_type,expected:l.set,received:r.parsedType}),v;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(h(r,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(h(r,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function i(c){const u=new Set;for(const m of c){if(m.status==="aborted")return v;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((c,u)=>n._parse(new O(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new z({...this._def,minSize:{value:e,message:f.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:f.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(s,e)=>new z({valueType:s,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class W extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.function)return h(t,{code:d.invalid_type,expected:l.function,received:t.parsedType}),v;function r(o,c){return ue({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ce(),Q].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function a(o,c){return ue({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ce(),Q].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}const n={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof J){const o=this;return S(async function(...c){const u=new C([]),m=await o._def.args.parseAsync(c,n).catch(V=>{throw u.addIssue(r(c,V)),u}),w=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(w,n).catch(V=>{throw u.addIssue(a(w,V)),u})})}else{const o=this;return S(function(...c){const u=o._def.args.safeParse(c,n);if(!u.success)throw new C([r(c,u.error)]);const m=Reflect.apply(i,this,u.data),w=o._def.returns.safeParse(m,n);if(!w.success)throw new C([a(m,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new W({...this._def,args:Z.create(e).rest(U.create())})}returns(e){return new W({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new W({args:e||Z.create([]).rest(U.create()),returns:t||U.create(),typeName:p.ZodFunction,...y(r)})}}class re extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}re.create=(s,e)=>new re({getter:s,typeName:p.ZodLazy,...y(e)});class ae extends _{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}ae.create=(s,e)=>new ae({value:s,typeName:p.ZodLiteral,...y(e)});function Ee(s,e){return new $({values:s,typeName:p.ZodEnum,...y(e)})}class $ extends _{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:x.joinValues(r),received:t.parsedType,code:d.invalid_type}),v}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:d.invalid_enum_value,options:r}),v}return S(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return $.create(e)}exclude(e){return $.create(this.options.filter(t=>!e.includes(t)))}}$.create=Ee;class ne extends _{_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==l.string&&r.parsedType!==l.number){const a=x.objectValues(t);return h(r,{expected:x.joinValues(a),received:r.parsedType,code:d.invalid_type}),v}if(t.indexOf(e.data)===-1){const a=x.objectValues(t);return h(r,{received:r.data,code:d.invalid_enum_value,options:a}),v}return S(e.data)}get enum(){return this._def.values}}ne.create=(s,e)=>new ne({values:s,typeName:p.ZodNativeEnum,...y(e)});class J extends _{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.promise&&t.common.async===!1)return h(t,{code:d.invalid_type,expected:l.promise,received:t.parsedType}),v;const r=t.parsedType===l.promise?t.data:Promise.resolve(t.data);return S(r.then(a=>this._def.type.parseAsync(a,{path:t.path,errorMap:t.common.contextualErrorMap})))}}J.create=(s,e)=>new J({type:s,typeName:p.ZodPromise,...y(e)});class j extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:i=>{h(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){const i=a.transform(r.data,n);return r.common.issues.length?{status:"dirty",value:r.data}:r.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:r.path,parent:r})):this._def.schema._parseSync({data:i,path:r.path,parent:r})}if(a.type==="refinement"){const i=o=>{const c=a.refinement(o,n);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(a.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!X(i))return i;const o=a.transform(i.value,n);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>X(i)?Promise.resolve(a.transform(i.value,n)).then(o=>({status:t.value,value:o})):i);x.assertNever(a)}}j.create=(s,e,t)=>new j({schema:s,typeName:p.ZodEffects,effect:e,...y(t)});j.createWithPreprocess=(s,e,t)=>new j({schema:e,effect:{type:"preprocess",transform:s},typeName:p.ZodEffects,...y(t)});class A extends _{_parse(e){return this._getType(e)===l.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}A.create=(s,e)=>new A({innerType:s,typeName:p.ZodOptional,...y(e)});class B extends _{_parse(e){return this._getType(e)===l.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(s,e)=>new B({innerType:s,typeName:p.ZodNullable,...y(e)});class ie extends _{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===l.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ie.create=(s,e)=>new ie({innerType:s,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class ve extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return le(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ve.create=(s,e)=>new ve({innerType:s,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class _e extends _{_parse(e){if(this._getType(e)!==l.nan){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:l.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}_e.create=s=>new _e({typeName:p.ZodNaN,...y(s)});class Je extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class oe extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?v:n.status==="dirty"?(t.dirty(),Ie(n.value)):this._def.out._parseAsync({data:n.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,t){return new oe({in:e,out:t,typeName:p.ZodPipeline})}}class ge extends _{_parse(e){const t=this._def.innerType._parse(e);return X(t)&&(t.value=Object.freeze(t.value)),t}}ge.create=(s,e)=>new ge({innerType:s,typeName:p.ZodReadonly,...y(e)});b.lazycreate;var p;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(p||(p={}));E.create;M.create;_e.create;D.create;q.create;H.create;he.create;K.create;F.create;fe.create;U.create;I.create;pe.create;N.create;b.create;b.strictCreate;ee.create;xe.create;te.create;Z.create;se.create;ye.create;z.create;W.create;re.create;ae.create;$.create;ne.create;J.create;j.create;A.create;B.create;j.createWithPreprocess;oe.create;function Ge(s,e){var a,n,i,o;const t={},r=new URL(s.url).searchParams.keys();for(const c of r)((a=e.schemas)==null?void 0:a.queryParams).shape[c]instanceof M?t[c]=Number(new URL(s.url).searchParams.get(c)):((n=e.schemas)==null?void 0:n.queryParams).shape[c]instanceof q?t[c]=!!new URL(s.url).searchParams.get(c):t[c]=new URL(s.url).searchParams.get(c);return(o=(i=e.schemas)==null?void 0:i.queryParams)==null||o.parse(t),t}const Ye={id:"json",requestContentType:"application/json",responseContentType:"application/json",decodeRequest:async s=>{if(!(s.headers.get("content-type")||"").includes("application/json")){const r=await s.text();if(!r)return;try{return JSON.parse(r)}catch{return r}}const t=await s.text();if(t)return JSON.parse(t)},encodeResponse:async s=>({body:JSON.stringify(s),headers:{"content-type":"application/json"}})},G=(s,e)=>{const t=s.codec??Ye,r=i=>{const{stage:o,error:c}=i;if(o==="auth")return{status:403,body:{error:"Access denied",at:o},headers:{"content-type":t.responseContentType}};if(c instanceof C){const m=c;return{status:o==="payload_validation"?422:400,body:{error:m.message,issues:m.issues,at:o},headers:{"content-type":t.responseContentType}}}return{status:500,body:{error:c instanceof Error?c.message:"Internal error",at:o},headers:{"content-type":t.responseContentType}}},a=s.errorMapper??r;return async(i,o)=>{var be,we,Te,Re;let c,u=o==null?void 0:o.params,m;if(s.auth&&typeof s.auth=="function")try{const T=await s.auth(i);if(typeof T=="boolean"){if(!T){const g=a({stage:"auth",error:!1}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}}else if(!T.ok){const g={status:T.status??403,body:T.body??{error:"Access denied",at:"auth"},headers:T.headers},k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers??{},...k.headers??{}}})}}catch(T){const g=a({stage:"auth",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}try{(be=s.schemas)!=null&&be.urlArgs&&(u=s.schemas.urlArgs.parse(u))}catch(T){const g=a({stage:"url_params_validation",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}try{(we=s.schemas)!=null&&we.queryParams&&(c=Ge(i,s))}catch(T){const g=a({stage:"query_validation",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}try{(Te=s.schemas)!=null&&Te.payload&&(m=await t.decodeRequest(i),m=s.schemas.payload.parse(m))}catch(T){const g=a({stage:"payload_validation",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}let w;try{w=await e(i,c,u,m)}catch(T){const g=a({stage:"response_handler",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}if((Re=s.schemas)!=null&&Re.response&&!s.skipOutputValidation)try{s.schemas.response.parse(w)}catch(T){const g=a({stage:"response_validation",error:T}),k=await t.encodeResponse(g.body);return new Response(k.body,{status:g.status,headers:{...g.headers,...k.headers??{}}})}const ke=typeof w=="object"&&w!==null?w:{data:w},V=await t.encodeResponse(ke);return new Response(V.body,{status:200,headers:{...V.headers??{}}})}},Qe=s=>{var r,a;if(s.protocol&&typeof s.get=="function")return`${s.protocol}://${s.get("host")}${s.originalUrl||s.url}`;const e=(r=s.socket)!=null&&r.encrypted?"https":"http",t=((a=s.headers)==null?void 0:a.host)||"localhost";return`${e}://${t}${s.url||"/"}`},Xe=async s=>s.body===void 0||s.body===null?s.method==="GET"||s.method==="HEAD"?void 0:new Promise(e=>{const t=[];s.on("data",r=>t.push(r)),s.on("end",()=>{if(!t.length){e(void 0);return}const r=t.reduce((i,o)=>i+o.length,0),a=new Uint8Array(r);let n=0;t.forEach(i=>{a.set(i,n),n+=i.length}),e(a)}),s.on("error",()=>e(void 0))}):typeof s.body=="string"||s.body instanceof Uint8Array?s.body:JSON.stringify(s.body),Ze=async s=>{const e=await Xe(s);return new Request(Qe(s),{method:s.method||"GET",headers:s.headers,body:e})},qe=async(s,e)=>{s.statusCode=e.status,e.headers.forEach((a,n)=>{typeof s.setHeader=="function"&&s.setHeader(n,a)});const t=await e.arrayBuffer(),r=new Uint8Array(t);if(typeof s.send=="function"){s.send(r);return}typeof s.end=="function"&&s.end(r)},Ke=(s,e)=>{const t=G(s,e);return async(r,a)=>t(r,a)},je=(s,e)=>{const t=G(s,e);return async(r,a)=>{const n=await Ze(r),i=await t(n,{params:r.params});await qe(a,i)}},Fe=(s,e)=>{const t=G(s,e);return async(r,a)=>{const n=await Ze(r.raw||r),i=await t(n,{params:r.params});a.code(i.status),i.headers.forEach((c,u)=>{a.header(u,c)});const o=await i.arrayBuffer();a.send(new Uint8Array(o))}},et=(s,e)=>{const t=G(s,e);return async r=>{const a=typeof r.req.param=="function"?r.req.param():{};return t(r.req.raw,{params:a})}},tt=(s,e)=>je(s,e);exports.apiWrapper=G;exports.expressAdapter=je;exports.fastifyAdapter=Fe;exports.honoAdapter=et;exports.nestAdapter=tt;exports.nextAdapter=Ke;
2
+ //# sourceMappingURL=server.cjs.js.map