directus-extension-api-docs
Version:
directus extension for swagger interface and openapi including custom endpoints definitions // custom endpoint validations middleware based on openapi
1 lines • 65.5 kB
JavaScript
"use strict";var e,t;!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(e||(e={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(t||(t={}));const s=e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),a=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},n=e.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 r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,e.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];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))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}r.create=e=>new r(e);const i=(t,a)=>{let r;switch(t.code){case n.invalid_type:r=t.received===s.undefined?"Required":`Expected ${t.expected}, received ${t.received}`;break;case n.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,e.jsonStringifyReplacer)}`;break;case n.unrecognized_keys:r=`Unrecognized key(s) in object: ${e.joinValues(t.keys,", ")}`;break;case n.invalid_union:r="Invalid input";break;case n.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${e.joinValues(t.options)}`;break;case n.invalid_enum_value:r=`Invalid enum value. Expected ${e.joinValues(t.options)}, received '${t.received}'`;break;case n.invalid_arguments:r="Invalid function arguments";break;case n.invalid_return_type:r="Invalid function return type";break;case n.invalid_date:r="Invalid date";break;case n.invalid_string:"object"==typeof t.validation?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,"number"==typeof t.validation.position&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:e.assertNever(t.validation):r="regex"!==t.validation?`Invalid ${t.validation}`:"Invalid";break;case n.too_small:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:"date"===t.type?`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:"Invalid input";break;case n.too_big:r="array"===t.type?`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:"string"===t.type?`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:"number"===t.type?`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"bigint"===t.type?`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:"date"===t.type?`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:"Invalid input";break;case n.custom:r="Invalid input";break;case n.invalid_intersection_types:r="Intersection results could not be merged";break;case n.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case n.not_finite:r="Number must be finite";break;default:r=a.defaultError,e.assertNever(t)}return{message:r}};let o=i;function d(){return o}const c=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter(e=>!!e).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function u(e,t){const s=d(),a=c({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===i?void 0:i].filter(e=>!!e)});e.common.issues.push(a)}class l{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return l.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return h;if("aborted"===n.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,y=e=>"dirty"===e.status,g=e=>"valid"===e.status,v=e=>"undefined"!=typeof Promise&&e instanceof Promise;function _(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function b(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var k,x,w;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(k||(k={}));class Z{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,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 T=(e,t)=>{if(g(t))return{success:!0,data:t.value};if(!e.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 r(e.common.issues);return this._error=t,this._error}}};function O(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:null!=o?o:n.defaultError}:void 0===n.data?{message:null!==(r=null!=o?o:a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=null!=o?o:s)&&void 0!==i?i:n.defaultError}},description:n}}class j{get description(){return this._def.description}_getType(e){return a(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l,ctx:{common:e.parent.common,data:e.data,parsedType:a(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(v(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:null!==(s=null==t?void 0:t.async)&&void 0!==s&&s,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},r=this._parseSync({data:e,path:n.path,parent:n});return T(n,r)}"~validate"(e){var t,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:n});return g(t)?{value:t.value}:{issues:n.common.issues}}catch(e){(null===(s=null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.toLowerCase())||void 0===s?void 0:s.includes("encountered"))&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(e=>g(e)?{value:e.value}:{issues:n.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:a(e)},n=this._parse({data:e,path:s.path,parent:s}),r=await(v(n)?n:Promise.resolve(n));return T(s,r)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,a)=>{const r=e(t),i=()=>a.addIssue({code:n.custom,...s(t)});return"undefined"!=typeof Promise&&r instanceof Promise?r.then(e=>!!e||(i(),!1)):!!r||(i(),!1)})}refinement(e,t){return this._refinement((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1))}_refinement(e){return new Ce({schema:this,typeName:Ve.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ne.create(this,this._def)}nullable(){return Ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ue.create(this)}promise(){return Se.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return ge.create(this,e,this._def)}transform(e){return new Ce({...O(this._def),schema:this,typeName:Ve.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ee({...O(this._def),innerType:this,defaultValue:t,typeName:Ve.ZodDefault})}brand(){return new $e({typeName:Ve.ZodBranded,type:this,...O(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ie({...O(this._def),innerType:this,catchValue:t,typeName:Ve.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const S=/^c[^\s-]{8,}$/i,C=/^[0-9a-z]+$/,N=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A=/^[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,E=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,P=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,R=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let $;const M=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,F=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,D=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,L=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,z=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,U="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",K=new RegExp(`^${U}$`);function q(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function B(e){return new RegExp(`^${q(e)}$`)}function W(e){let t=`${U}T${q(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function J(e,t){return!("v4"!==t&&t||!M.test(e))||!("v6"!==t&&t||!D.test(e))}function H(e,t){if(!I.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&(!(!n.typ||!n.alg)&&(!t||n.alg===t))}catch(e){return!1}}function Y(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!L.test(e))}class G extends j{_parse(t){this._def.coerce&&(t.data=String(t.data));if(this._getType(t)!==s.string){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.string,received:e.parsedType}),h}const a=new l;let r;for(const s of this._def.checks)if("min"===s.kind)t.data.length<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("max"===s.kind)t.data.length>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if("length"===s.kind){const e=t.data.length>s.value,i=t.data.length<s.value;(e||i)&&(r=this._getOrReturnCtx(t,r),e?u(r,{code:n.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&u(r,{code:n.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if("email"===s.kind)R.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"email",code:n.invalid_string,message:s.message}),a.dirty());else if("emoji"===s.kind)$||($=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),$.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"emoji",code:n.invalid_string,message:s.message}),a.dirty());else if("uuid"===s.kind)A.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"uuid",code:n.invalid_string,message:s.message}),a.dirty());else if("nanoid"===s.kind)E.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"nanoid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid"===s.kind)S.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid",code:n.invalid_string,message:s.message}),a.dirty());else if("cuid2"===s.kind)C.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cuid2",code:n.invalid_string,message:s.message}),a.dirty());else if("ulid"===s.kind)N.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"ulid",code:n.invalid_string,message:s.message}),a.dirty());else if("url"===s.kind)try{new URL(t.data)}catch(e){r=this._getOrReturnCtx(t,r),u(r,{validation:"url",code:n.invalid_string,message:s.message}),a.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0;s.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"regex",code:n.invalid_string,message:s.message}),a.dirty())}else if("trim"===s.kind)t.data=t.data.trim();else if("includes"===s.kind)t.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty());else if("toLowerCase"===s.kind)t.data=t.data.toLowerCase();else if("toUpperCase"===s.kind)t.data=t.data.toUpperCase();else if("startsWith"===s.kind)t.data.startsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty());else if("endsWith"===s.kind)t.data.endsWith(s.value)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty());else if("datetime"===s.kind){W(s).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"datetime",message:s.message}),a.dirty())}else if("date"===s.kind){K.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"date",message:s.message}),a.dirty())}else if("time"===s.kind){B(s).test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{code:n.invalid_string,validation:"time",message:s.message}),a.dirty())}else"duration"===s.kind?P.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"duration",code:n.invalid_string,message:s.message}),a.dirty()):"ip"===s.kind?J(t.data,s.version)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"ip",code:n.invalid_string,message:s.message}),a.dirty()):"jwt"===s.kind?H(t.data,s.alg)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"jwt",code:n.invalid_string,message:s.message}),a.dirty()):"cidr"===s.kind?Y(t.data,s.version)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"cidr",code:n.invalid_string,message:s.message}),a.dirty()):"base64"===s.kind?z.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64",code:n.invalid_string,message:s.message}),a.dirty()):"base64url"===s.kind?V.test(t.data)||(r=this._getOrReturnCtx(t,r),u(r,{validation:"base64url",code:n.invalid_string,message:s.message}),a.dirty()):e.assertNever(s);return{status:a.value,value:t.data}}_regex(e,t,s){return this.refinement(t=>e.test(t),{validation:t,code:n.invalid_string,...k.errToObj(s)})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...k.errToObj(e)})}url(e){return this._addCheck({kind:"url",...k.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...k.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...k.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...k.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...k.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...k.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...k.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...k.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...k.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...k.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(s=null==e?void 0:e.local)&&void 0!==s&&s,...k.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...k.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...k.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function X(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}G.create=e=>{var t;return new G({checks:[],typeName:Ve.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class Q extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){this._def.coerce&&(t.data=Number(t.data));if(this._getType(t)!==s.number){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.number,received:e.parsedType}),h}let a;const r=new l;for(const s of this._def.checks)if("int"===s.kind)e.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty());else if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty())}else"multipleOf"===s.kind?0!==X(t.data,s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):"finite"===s.kind?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_finite,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:k.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:k.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:k.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:k.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(t=>"int"===t.kind||"multipleOf"===t.kind&&e.isInteger(t.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=e=>new Q({checks:[],typeName:Ve.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class ee extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch(e){return this._getInvalidInput(t)}if(this._getType(t)!==s.bigint)return this._getInvalidInput(t);let a;const r=new l;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?t.data<s.value:t.data<=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else if("max"===s.kind){(s.inclusive?t.data>s.value:t.data>=s.value)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else"multipleOf"===s.kind?t.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),u(a,{code:n.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):e.assertNever(s);return{status:r.value,value:t.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,k.toString(t))}gt(e,t){return this.setLimit("min",e,!1,k.toString(t))}lte(e,t){return this.setLimit("max",e,!0,k.toString(t))}lt(e,t){return this.setLimit("max",e,!1,k.toString(t))}setLimit(e,t,s,a){return new ee({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:k.toString(a)}]})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:k.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}ee.create=e=>{var t;return new ee({checks:[],typeName:Ve.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...O(e)})};class te extends j{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.boolean,received:t.parsedType}),h}return m(e.data)}}te.create=e=>new te({typeName:Ve.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...O(e)});class se extends j{_parse(t){this._def.coerce&&(t.data=new Date(t.data));if(this._getType(t)!==s.date){const e=this._getOrReturnCtx(t);return u(e,{code:n.invalid_type,expected:s.date,received:e.parsedType}),h}if(isNaN(t.data.getTime())){return u(this._getOrReturnCtx(t),{code:n.invalid_date}),h}const a=new l;let r;for(const s of this._def.checks)"min"===s.kind?t.data.getTime()<s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):"max"===s.kind?t.data.getTime()>s.value&&(r=this._getOrReturnCtx(t,r),u(r,{code:n.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):e.assertNever(s);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(e){return new se({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}se.create=e=>new se({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ve.ZodDate,...O(e)});class ae extends j{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.symbol,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Ve.ZodSymbol,...O(e)});class ne extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.undefined,received:t.parsedType}),h}return m(e.data)}}ne.create=e=>new ne({typeName:Ve.ZodUndefined,...O(e)});class re extends j{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.null,received:t.parsedType}),h}return m(e.data)}}re.create=e=>new re({typeName:Ve.ZodNull,...O(e)});class ie extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ie.create=e=>new ie({typeName:Ve.ZodAny,...O(e)});class oe extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}oe.create=e=>new oe({typeName:Ve.ZodUnknown,...O(e)});class de extends j{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.never,received:t.parsedType}),h}}de.create=e=>new de({typeName:Ve.ZodNever,...O(e)});class ce extends j{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.void,received:t.parsedType}),h}return m(e.data)}}ce.create=e=>new ce({typeName:Ve.ZodVoid,...O(e)});class ue extends j{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==s.array)return u(t,{code:n.invalid_type,expected:s.array,received:t.parsedType}),h;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,s=t.data.length<r.exactLength.value;(e||s)&&(u(t,{code:e?n.too_big:n.too_small,minimum:s?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(u(t,{code:n.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(u(t,{code:n.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((e,s)=>r.type._parseAsync(new Z(t,e,t.path,s)))).then(e=>l.mergeArray(a,e));const i=[...t.data].map((e,s)=>r.type._parseSync(new Z(t,e,t.path,s)));return l.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new ue({...this._def,minLength:{value:e,message:k.toString(t)}})}max(e,t){return new ue({...this._def,maxLength:{value:e,message:k.toString(t)}})}length(e,t){return new ue({...this._def,exactLength:{value:e,message:k.toString(t)}})}nonempty(e){return this.min(1,e)}}function le(e){if(e instanceof he){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Ne.create(le(a))}return new he({...e._def,shape:()=>t})}return e instanceof ue?new ue({...e._def,type:le(e.element)}):e instanceof Ne?Ne.create(le(e.unwrap())):e instanceof Ae?Ae.create(le(e.unwrap())):e instanceof ve?ve.create(e.items.map(e=>le(e))):e}ue.create=(e,t)=>new ue({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ve.ZodArray,...O(t)});class he extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const t=this._def.shape(),s=e.objectKeys(t);return this._cached={shape:t,keys:s}}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof de&&"strip"===this._def.unknownKeys))for(const e in a.data)i.includes(e)||o.push(e);const d=[];for(const e of i){const t=r[e],s=a.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new Z(a,s,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof de){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(u(a,{code:n.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const s=a.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new Z(a,s,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e}).then(e=>l.mergeObjectSync(t,e)):l.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return k.errToObj,new he({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=k.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new he({...this._def,unknownKeys:"strip"})}passthrough(){return new he({...this._def,unknownKeys:"passthrough"})}extend(e){return new he({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new he({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ve.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new he({...this._def,catchall:e})}pick(t){const s={};return e.objectKeys(t).forEach(e=>{t[e]&&this.shape[e]&&(s[e]=this.shape[e])}),new he({...this._def,shape:()=>s})}omit(t){const s={};return e.objectKeys(this.shape).forEach(e=>{t[e]||(s[e]=this.shape[e])}),new he({...this._def,shape:()=>s})}deepPartial(){return le(this)}partial(t){const s={};return e.objectKeys(this.shape).forEach(e=>{const a=this.shape[e];t&&!t[e]?s[e]=a:s[e]=a.optional()}),new he({...this._def,shape:()=>s})}required(t){const s={};return e.objectKeys(this.shape).forEach(e=>{if(t&&!t[e])s[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ne;)t=t._def.innerType;s[e]=t}}),new he({...this._def,shape:()=>s})}keyof(){return Te(e.objectKeys(this.shape))}}he.create=(e,t)=>new he({shape:()=>e,unknownKeys:"strip",catchall:de.create(),typeName:Ve.ZodObject,...O(t)}),he.strictCreate=(e,t)=>new he({shape:()=>e,unknownKeys:"strict",catchall:de.create(),typeName:Ve.ZodObject,...O(t)}),he.lazycreate=(e,t)=>new he({shape:e,unknownKeys:"strip",catchall:de.create(),typeName:Ve.ZodObject,...O(t)});class pe extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map(async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map(e=>new r(e.ctx.common.issues));return u(t,{code:n.invalid_union,unionErrors:s}),h});{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const i=a.map(e=>new r(e));return u(t,{code:n.invalid_union,unionErrors:i}),h}}get options(){return this._def.options}}pe.create=(e,t)=>new pe({options:e,typeName:Ve.ZodUnion,...O(t)});const me=t=>t instanceof we?me(t.schema):t instanceof Ce?me(t.innerType()):t instanceof Ze?[t.value]:t instanceof Oe?t.options:t instanceof je?e.objectValues(t.enum):t instanceof Ee?me(t._def.innerType):t instanceof ne?[void 0]:t instanceof re?[null]:t instanceof Ne?[void 0,...me(t.unwrap())]:t instanceof Ae?[null,...me(t.unwrap())]:t instanceof $e||t instanceof Fe?me(t.unwrap()):t instanceof Ie?me(t._def.innerType):[];class fe extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return u(t,{code:n.invalid_type,expected:s.object,received:t.parsedType}),h;const a=this.discriminator,r=t.data[a],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:n.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=me(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new fe({typeName:Ve.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...O(s)})}}function ye(t,n){const r=a(t),i=a(n);if(t===n)return{valid:!0,data:t};if(r===s.object&&i===s.object){const s=e.objectKeys(n),a=e.objectKeys(t).filter(e=>-1!==s.indexOf(e)),r={...t,...n};for(const e of a){const s=ye(t[e],n[e]);if(!s.valid)return{valid:!1};r[e]=s.data}return{valid:!0,data:r}}if(r===s.array&&i===s.array){if(t.length!==n.length)return{valid:!1};const e=[];for(let s=0;s<t.length;s++){const a=ye(t[s],n[s]);if(!a.valid)return{valid:!1};e.push(a.data)}return{valid:!0,data:e}}return r===s.date&&i===s.date&&+t===+n?{valid:!0,data:t}:{valid:!1}}class ge extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const r=ye(e.value,a.value);return r.valid?((y(e)||y(a))&&t.dirty(),{status:t.value,value:r.data}):(u(s,{code:n.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([e,t])=>a(e,t)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ge.create=(e,t,s)=>new ge({left:e,right:t,typeName:Ve.ZodIntersection,...O(s)});class ve extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.array)return u(a,{code:n.invalid_type,expected:s.array,received:a.parsedType}),h;if(a.data.length<this._def.items.length)return u(a,{code:n.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&a.data.length>this._def.items.length&&(u(a,{code:n.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map((e,t)=>{const s=this._def.items[t]||this._def.rest;return s?s._parse(new Z(a,e,a.path,t)):null}).filter(e=>!!e);return a.common.async?Promise.all(r).then(e=>l.mergeArray(t,e)):l.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new ve({...this._def,rest:e})}}ve.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ve({items:e,typeName:Ve.ZodTuple,rest:null,...O(t)})};class _e extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.object)return u(a,{code:n.invalid_type,expected:s.object,received:a.parsedType}),h;const r=[],i=this._def.keyType,o=this._def.valueType;for(const e in a.data)r.push({key:i._parse(new Z(a,e,a.path,e)),value:o._parse(new Z(a,a.data[e],a.path,e)),alwaysSet:e in a.data});return a.common.async?l.mergeObjectAsync(t,r):l.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return new _e(t instanceof j?{keyType:e,valueType:t,typeName:Ve.ZodRecord,...O(s)}:{keyType:G.create(),valueType:e,typeName:Ve.ZodRecord,...O(t)})}}class be extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.map)return u(a,{code:n.invalid_type,expected:s.map,received:a.parsedType}),h;const r=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([e,t],s)=>({key:r._parse(new Z(a,e,a.path,[s,"key"])),value:i._parse(new Z(a,t,a.path,[s,"value"]))}));if(a.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const s of o){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}})}{const e=new Map;for(const s of o){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}be.create=(e,t,s)=>new be({valueType:t,keyType:e,typeName:Ve.ZodMap,...O(s)});class ke extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==s.set)return u(a,{code:n.invalid_type,expected:s.set,received:a.parsedType}),h;const r=this._def;null!==r.minSize&&a.data.size<r.minSize.value&&(u(a,{code:n.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),null!==r.maxSize&&a.data.size>r.maxSize.value&&(u(a,{code:n.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function o(e){const s=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...a.data.values()].map((e,t)=>i._parse(new Z(a,e,a.path,t)));return a.common.async?Promise.all(d).then(e=>o(e)):o(d)}min(e,t){return new ke({...this._def,minSize:{value:e,message:k.toString(t)}})}max(e,t){return new ke({...this._def,maxSize:{value:e,message:k.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ke.create=(e,t)=>new ke({valueType:e,minSize:null,maxSize:null,typeName:Ve.ZodSet,...O(t)});class xe extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.function)return u(t,{code:n.invalid_type,expected:s.function,received:t.parsedType}),h;function a(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter(e=>!!e),issueData:{code:n.invalid_arguments,argumentsError:s}})}function o(e,s){return c({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,d(),i].filter(e=>!!e),issueData:{code:n.invalid_return_type,returnTypeError:s}})}const l={errorMap:t.common.contextualErrorMap},p=t.data;if(this._def.returns instanceof Se){const e=this;return m(async function(...t){const s=new r([]),n=await e._def.args.parseAsync(t,l).catch(e=>{throw s.addIssue(a(t,e)),s}),i=await Reflect.apply(p,this,n);return await e._def.returns._def.type.parseAsync(i,l).catch(e=>{throw s.addIssue(o(i,e)),s})})}{const e=this;return m(function(...t){const s=e._def.args.safeParse(t,l);if(!s.success)throw new r([a(t,s.error)]);const n=Reflect.apply(p,this,s.data),i=e._def.returns.safeParse(n,l);if(!i.success)throw new r([o(n,i.error)]);return i.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new xe({...this._def,args:ve.create(e).rest(oe.create())})}returns(e){return new xe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new xe({args:e||ve.create([]).rest(oe.create()),returns:t||oe.create(),typeName:Ve.ZodFunction,...O(s)})}}class we extends j{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})}}we.create=(e,t)=>new we({getter:e,typeName:Ve.ZodLazy,...O(t)});class Ze extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:n.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get v