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