point-click-lib 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Point and Click core library
2
2
 
3
- Modelling and utility code library for point-and-click
3
+ code library containing the game-design schemas and parseing code for point-and-click
4
4
 
5
5
  ## Usage
6
6
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ta(a,e){return a+e}const aa=[{schemaVersion:3,changes:[{breaking:!1,description:"Designs have schemaVersion property"},{breaking:!1,description:"storyBoards array is required"}]},{schemaVersion:4,changes:[{breaking:!0,description:"Endings deprecated in favour of storyBoards. Any Endings have been converted to Storyboards."},{breaking:!1,description:"StoryBoards have end of game option."}]}];var b;(function(a){a.assertEqual=s=>{};function e(s){}a.assertIs=e;function t(s){throw new Error}a.assertNever=t,a.arrayToEnum=s=>{const r={};for(const i of s)r[i]=i;return r},a.getValidEnumValues=s=>{const r=a.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of r)i[o]=s[o];return a.objectValues(i)},a.objectValues=s=>a.objectKeys(s).map(function(r){return s[r]}),a.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const r=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&r.push(i);return r},a.find=(s,r)=>{for(const i of s)if(r(i))return i},a.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,r=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}a.joinValues=n,a.jsonStringifyReplacer=(s,r)=>typeof r=="bigint"?r.toString():r})(b||(b={}));var ht;(function(a){a.mergeShapes=(e,t)=>({...e,...t})})(ht||(ht={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=a=>{switch(typeof a){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(a)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(a)?h.array:a===null?h.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?h.promise:typeof Map<"u"&&a instanceof Map?h.map:typeof Set<"u"&&a instanceof Set?h.set:typeof Date<"u"&&a instanceof Date?h.date:h.object;default:return h.unknown}},d=b.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 V extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(r){return r.message},n={_errors:[]},s=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,f=0;for(;f<i.path.length;){const p=i.path[f];f===i.path.length-1?(o[p]=o[p]||{_errors:[]},o[p]._errors.push(t(i))):o[p]=o[p]||{_errors:[]},o=o[p],f++}}};return s(this),n}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)if(s.path.length>0){const r=s.path[0];t[r]=t[r]||[],t[r].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=a=>new V(a);const Me=(a,e)=>{let t;switch(a.code){case d.invalid_type:a.received===h.undefined?t="Required":t=`Expected ${a.expected}, received ${a.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(a.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(a.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(a.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(t=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?t=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?t=`Invalid input: must end with "${a.validation.endsWith}"`:b.assertNever(a.validation):a.validation!=="regex"?t=`Invalid ${a.validation}`:t="Invalid";break;case d.too_small:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:t="Invalid input";break;case d.too_big:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?t=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${a.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(a)}return{message:t}};let na=Me;function sa(){return na}const ra=a=>{const{data:e,path:t,errorMaps:n,issueData:s}=a,r=[...t,...s.path||[]],i={...s,path:r};if(s.message!==void 0)return{...s,path:r,message:s.message};let o="";const f=n.filter(p=>!!p).slice().reverse();for(const p of f)o=p(i,{data:e,defaultError:o}).message;return{...s,path:r,message:o}};function u(a,e){const t=sa(),n=ra({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,t,t===Me?void 0:Me].filter(s=>!!s)});a.common.issues.push(n)}class A{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const r=await s.key,i=await s.value;n.push({key:r,value:i})}return A.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:r,value:i}=s;if(r.status==="aborted"||i.status==="aborted")return v;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[r.value]=i.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),le=a=>({status:"dirty",value:a}),Z=a=>({status:"valid",value:a}),mt=a=>a.status==="aborted",ft=a=>a.status==="dirty",U=a=>a.status==="valid",_e=a=>typeof Promise<"u"&&a instanceof Promise;var m;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));class j{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const pt=(a,e)=>{if(U(e))return{success:!0,data:e.value};if(!a.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 V(a.common.issues);return this._error=t,this._error}}};function x(a){if(!a)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=a;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:f}=a;return i.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:f??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:f??t??o.defaultError}},description:s}}class S{get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(_e(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){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},s=this._parseSync({data:e,path:n.path,parent:n});return pt(n,s)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return U(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>U(n)?{value:n.value}:{issues:t.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:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(_e(s)?s:Promise.resolve(s));return pt(n,r)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,r)=>{const i=e(s),o=()=>r.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new J({schema:this,typeName:g.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:t=>this["~validate"](t)}}optional(){return B.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return Ce.create(this,this._def)}or(e){return Se.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new J({...x(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new We({...x(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new Oa({typeName:g.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ue({...x(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ye.create(this,e)}readonly(){return Ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ia=/^c[^\s-]{8,}$/i,oa=/^[0-9a-z]+$/,ca=/^[0-9A-HJKMNP-TV-Z]{26}$/i,da=/^[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,ua=/^[a-z0-9_-]{21}$/i,la=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ha=/^[-+]?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)?)??$/,ma=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Be;const pa=/^(?:(?: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])$/,ya=/^(?:(?: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])$/,ga=/^(([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]))$/,va=/^(([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])$/,_a=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xa=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Tt="((\\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])))",Sa=new RegExp(`^${Tt}$`);function It(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);const t=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function ka(a){return new RegExp(`^${It(a)}$`)}function ba(a){let e=`${Tt}T${It(a)}`;const t=[];return t.push(a.local?"Z?":"Z"),a.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ca(a,e){return!!((e==="v4"||!e)&&pa.test(a)||(e==="v6"||!e)&&ga.test(a))}function wa(a,e){if(!la.test(a))return!1;try{const[t]=a.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ta(a,e){return!!((e==="v4"||!e)&&ya.test(a)||(e==="v6"||!e)&&va.test(a))}class D extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.string,received:r.parsedType}),v}const n=new A;let s;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="max")e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?u(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&u(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")ma.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"email",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")Be||(Be=new RegExp(fa,"u")),Be.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"emoji",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")da.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"uuid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")ua.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"nanoid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")ia.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")oa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid2",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")ca.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ulid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),u(s,{validation:"url",code:d.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"regex",code:d.invalid_string,message:r.message}),n.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?ba(r).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?Sa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?ka(r).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?ha.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"duration",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?Ca(e.data,r.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ip",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="jwt"?wa(e.data,r.alg)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"jwt",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="cidr"?Ta(e.data,r.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cidr",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?_a.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="base64url"?xa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64url",code:d.invalid_string,message:r.message}),n.dirty()):b.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...m.errToObj(n)})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=a=>new D({checks:[],typeName:g.ZodString,coerce:a?.coerce??!1,...x(a)});function Ia(a,e){const t=(a.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,r=Number.parseInt(a.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return r%i/10**s}class G extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.number,received:r.parsedType}),v}let n;const s=new A;for(const r of this._def.checks)r.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:d.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="multipleOf"?Ia(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_finite,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}G.create=a=>new G({checks:[],typeName:g.ZodNumber,coerce:a?.coerce||!1,...x(a)});class me extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let n;const s=new A;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new me({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new me({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}me.create=a=>new me({checks:[],typeName:g.ZodBigInt,coerce:a?.coerce??!1,...x(a)});class Pe extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),v}return Z(e.data)}}Pe.create=a=>new Pe({typeName:g.ZodBoolean,coerce:a?.coerce||!1,...x(a)});class xe extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.date,received:r.parsedType}),v}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_date}),v}const n=new A;let s;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):b.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}xe.create=a=>new xe({checks:[],coerce:a?.coerce||!1,typeName:g.ZodDate,...x(a)});class yt extends S{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),v}return Z(e.data)}}yt.create=a=>new yt({typeName:g.ZodSymbol,...x(a)});class ze extends S{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),v}return Z(e.data)}}ze.create=a=>new ze({typeName:g.ZodUndefined,...x(a)});class gt extends S{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),v}return Z(e.data)}}gt.create=a=>new gt({typeName:g.ZodNull,...x(a)});class vt extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}}vt.create=a=>new vt({typeName:g.ZodAny,...x(a)});class _t extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}}_t.create=a=>new _t({typeName:g.ZodUnknown,...x(a)});class M extends S{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),v}}M.create=a=>new M({typeName:g.ZodNever,...x(a)});class xt extends S{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),v}return Z(e.data)}}xt.create=a=>new xt({typeName:g.ZodVoid,...x(a)});class q extends S{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return u(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),v;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(u(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(u(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(u(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new j(t,i,t.path,o)))).then(i=>A.mergeArray(n,i));const r=[...t.data].map((i,o)=>s.type._parseSync(new j(t,i,t.path,o)));return A.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new q({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new q({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new q({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}q.create=(a,e)=>new q({type:a,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...x(e)});function W(a){if(a instanceof O){const e={};for(const t in a.shape){const n=a.shape[t];e[t]=B.create(W(n))}return new O({...a._def,shape:()=>e})}else return a instanceof q?new q({...a._def,type:W(a.element)}):a instanceof B?B.create(W(a.unwrap())):a instanceof Y?Y.create(W(a.unwrap())):a instanceof L?L.create(a.items.map(e=>W(e))):a}class O extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const p=this._getOrReturnCtx(e);return u(p,{code:d.invalid_type,expected:h.object,received:p.parsedType}),v}const{status:n,ctx:s}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const p in s.data)i.includes(p)||o.push(p);const f=[];for(const p of i){const k=r[p],z=s.data[p];f.push({key:{status:"valid",value:p},value:k._parse(new j(s,z,s.path,p)),alwaysSet:p in s.data})}if(this._def.catchall instanceof M){const p=this._def.unknownKeys;if(p==="passthrough")for(const k of o)f.push({key:{status:"valid",value:k},value:{status:"valid",value:s.data[k]}});else if(p==="strict")o.length>0&&(u(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const k of o){const z=s.data[k];f.push({key:{status:"valid",value:k},value:p._parse(new j(s,z,s.path,k)),alwaysSet:k in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const p=[];for(const k of f){const z=await k.key,De=await k.value;p.push({key:z,value:De,alwaysSet:k.alwaysSet})}return p}).then(p=>A.mergeObjectSync(n,p)):A.mergeObjectSync(n,f)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new O({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{const s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend(e){return new O({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new O({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new O({...this._def,catchall:e})}pick(e){const t={};for(const n of b.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new O({...this._def,shape:()=>t})}omit(e){const t={};for(const n of b.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new O({...this._def,shape:()=>t})}deepPartial(){return W(this)}partial(e){const t={};for(const n of b.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new O({...this._def,shape:()=>t})}required(e){const t={};for(const n of b.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof B;)r=r._def.innerType;t[n]=r}return new O({...this._def,shape:()=>t})}keyof(){return Ot(b.objectKeys(this.shape))}}O.create=(a,e)=>new O({shape:()=>a,unknownKeys:"strip",catchall:M.create(),typeName:g.ZodObject,...x(e)});O.strictCreate=(a,e)=>new O({shape:()=>a,unknownKeys:"strict",catchall:M.create(),typeName:g.ZodObject,...x(e)});O.lazycreate=(a,e)=>new O({shape:a,unknownKeys:"strip",catchall:M.create(),typeName:g.ZodObject,...x(e)});class Se extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new V(o.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(n.map(async r=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let r;const i=[];for(const f of n){const p={...t,common:{...t.common,issues:[]},parent:null},k=f._parseSync({data:t.data,path:t.path,parent:p});if(k.status==="valid")return k;k.status==="dirty"&&!r&&(r={result:k,ctx:p}),p.common.issues.length&&i.push(p.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(f=>new V(f));return u(t,{code:d.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Se.create=(a,e)=>new Se({options:a,typeName:g.ZodUnion,...x(e)});function Le(a,e){const t=$(a),n=$(e);if(a===e)return{valid:!0,data:a};if(t===h.object&&n===h.object){const s=b.objectKeys(e),r=b.objectKeys(a).filter(o=>s.indexOf(o)!==-1),i={...a,...e};for(const o of r){const f=Le(a[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===h.array&&n===h.array){if(a.length!==e.length)return{valid:!1};const s=[];for(let r=0;r<a.length;r++){const i=a[r],o=e[r],f=Le(i,o);if(!f.valid)return{valid:!1};s.push(f.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+a==+e?{valid:!0,data:a}:{valid:!1}}class ke extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(r,i)=>{if(mt(r)||mt(i))return v;const o=Le(r.value,i.value);return o.valid?((ft(r)||ft(i))&&t.dirty(),{status:t.value,value:o.data}):(u(n,{code:d.invalid_intersection_types}),v)};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(([r,i])=>s(r,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ke.create=(a,e,t)=>new ke({left:a,right:e,typeName:g.ZodIntersection,...x(t)});class L extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return u(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return u(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(u(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new j(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>A.mergeArray(t,i)):A.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new L({...this._def,rest:e})}}L.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new L({items:a,typeName:g.ZodTuple,rest:null,...x(e)})};class be extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return u(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),v;const s=[],r=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:r._parse(new j(n,o,n.path,o)),value:i._parse(new j(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?A.mergeObjectAsync(t,s):A.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof S?new be({keyType:e,valueType:t,typeName:g.ZodRecord,...x(n)}):new be({keyType:D.create(),valueType:e,typeName:g.ZodRecord,...x(t)})}}class St extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return u(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),v;const s=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([o,f],p)=>({key:s._parse(new j(n,o,n.path,[p,"key"])),value:r._parse(new j(n,f,n.path,[p,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const p=await f.key,k=await f.value;if(p.status==="aborted"||k.status==="aborted")return v;(p.status==="dirty"||k.status==="dirty")&&t.dirty(),o.set(p.value,k.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const p=f.key,k=f.value;if(p.status==="aborted"||k.status==="aborted")return v;(p.status==="dirty"||k.status==="dirty")&&t.dirty(),o.set(p.value,k.value)}return{status:t.value,value:o}}}}St.create=(a,e,t)=>new St({valueType:e,keyType:a,typeName:g.ZodMap,...x(t)});class fe extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return u(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),v;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(u(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(u(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const r=this._def.valueType;function i(f){const p=new Set;for(const k of f){if(k.status==="aborted")return v;k.status==="dirty"&&t.dirty(),p.add(k.value)}return{status:t.value,value:p}}const o=[...n.data.values()].map((f,p)=>r._parse(new j(n,f,n.path,p)));return n.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new fe({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(a,e)=>new fe({valueType:a,minSize:null,maxSize:null,typeName:g.ZodSet,...x(e)});class kt extends S{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})}}kt.create=(a,e)=>new kt({getter:a,typeName:g.ZodLazy,...x(e)});class Fe extends S{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}Fe.create=(a,e)=>new Fe({value:a,typeName:g.ZodLiteral,...x(e)});function Ot(a,e){return new H({values:a,typeName:g.ZodEnum,...x(e)})}class H extends S{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return u(t,{expected:b.joinValues(n),received:t.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:n}),v}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return H.create(e,{...this._def,...t})}exclude(e,t=this._def){return H.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}H.create=Ot;class bt extends S{_parse(e){const t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const s=b.objectValues(t);return u(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=b.objectValues(t);return u(n,{received:n.data,code:d.invalid_enum_value,options:s}),v}return Z(e.data)}get enum(){return this._def.values}}bt.create=(a,e)=>new bt({values:a,typeName:g.ZodNativeEnum,...x(e)});class Ce extends S{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),v;const n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return Z(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(a,e)=>new Ce({type:a,typeName:g.ZodPromise,...x(e)});class J extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:i=>{u(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){const i=s.transform(n.data,r);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return v;const f=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return f.status==="aborted"?v:f.status==="dirty"||t.value==="dirty"?le(f.value):f});{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?le(o.value):o}}if(s.type==="refinement"){const i=o=>{const f=s.refinement(o,r);if(n.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!U(i))return v;const o=s.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>U(i)?Promise.resolve(s.transform(i.value,r)).then(o=>({status:t.value,value:o})):v);b.assertNever(s)}}J.create=(a,e,t)=>new J({schema:a,typeName:g.ZodEffects,effect:e,...x(t)});J.createWithPreprocess=(a,e,t)=>new J({schema:e,effect:{type:"preprocess",transform:a},typeName:g.ZodEffects,...x(t)});class B extends S{_parse(e){return this._getType(e)===h.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(a,e)=>new B({innerType:a,typeName:g.ZodOptional,...x(e)});class Y extends S{_parse(e){return this._getType(e)===h.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(a,e)=>new Y({innerType:a,typeName:g.ZodNullable,...x(e)});class We extends S{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}We.create=(a,e)=>new We({innerType:a,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class Ue extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return _e(s)?s.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ue.create=(a,e)=>new Ue({innerType:a,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class Ct extends S{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}}Ct.create=a=>new Ct({typeName:g.ZodNaN,...x(a)});class Oa extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ye extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?v:r.status==="dirty"?(t.dirty(),le(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ye({in:e,out:t,typeName:g.ZodPipeline})}}class Ge extends S{_parse(e){const t=this._def.innerType._parse(e),n=s=>(U(s)&&(s.value=Object.freeze(s.value)),s);return _e(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Ge.create=(a,e)=>new Ge({innerType:a,typeName:g.ZodReadonly,...x(e)});var g;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(g||(g={}));const c=D.create,y=G.create,C=Pe.create,Aa=ze.create;M.create;const R=q.create,l=O.create,Q=Se.create;ke.create;const Xe=L.create,P=be.create,w=Fe.create,E=H.create;Ce.create;const _=B.create;Y.create;const At=()=>C().optional(),X=E(["left","right","up","down"]),Ra=X.options,Te=l({type:c(),id:c(),name:_(c()),status:_(c())}),Rt=l({height:y(),width:y(),sprite:c().optional(),direction:_(X),filter:_(c())}),Nt=l({room:_(c()),x:y(),y:y()}),pe=l({imageId:c(),col:y().optional(),row:y().optional()}),I=l({text:c().array()}),Zt=l({x:y(),y:y()}),we=l({soundId:c(),volume:y().optional()}),Ie={_started:At(),narrative:I.optional(),startDirection:X.optional(),endDirection:X.optional(),endStatus:c().optional()},Na={_started:!0,narrative:!0,startDirection:!0,endDirection:!0,endStatus:!0,type:!0},Za=l({animation:_(c()),x:y(),y:y(),speed:_(y())}),Et=l({type:w("move"),roomId:c().optional(),pathIsSet:_(C()),doPendingInteractionWhenFinished:_(C()),steps:R(Za)}).extend(Ie),qt=l({type:w("goTo"),animation:_(c()),speed:_(y()),targetId:c()}).extend(Ie),jt=l({type:w("say"),animation:_(c()),text:c(),time:y()}).extend(Ie),Ea=l({animation:_(c()),duration:y(),timeElapsed:_(y()),reverse:_(C())}),Dt=l({type:w("act"),steps:R(Ea)}).extend(Ie),ye=Q([Et,Dt,jt,qt]),qa=ye.options.map(a=>a.shape.type.value),Oe=l({type:w("order"),actorId:c().optional(),orders:R(ye),replaceCurrentOrders:_(C()),narrative:I.optional()}),K=l({type:w("changeRoom"),roomId:c(),takePlayer:C(),x:_(y()),y:_(y()),narrative:I.optional()}),ee=l({type:w("inventory"),itemId:c(),actorId:c().optional(),addOrRemove:E(["ADD","REMOVE"]),narrative:I.optional()}),te=l({type:w("removeActor"),actorId:c(),narrative:I.optional()}),ae=l({type:w("changeStatus"),targetId:c(),targetType:E(["actor","item","hotspot"]),status:c(),narrative:I.optional()}),Ae=l({type:w("sequence"),sequence:c(),narrative:I.optional()}),ne=l({type:w("conversation"),conversationId:c(),end:_(C()),narrative:I.optional()}),se=l({type:w("conversationChoice"),on:C(),conversationId:c(),branchId:c(),choiceRef:c(),narrative:I.optional()}),re=l({type:w("teleportActor"),actorId:c(),roomId:_(c()),x:y(),y:y(),narrative:I.optional()}),F=l({type:w("toggleZone"),roomId:_(c()),on:C(),ref:c(),zoneType:E(["hotspot","obstacle","walkable"]),narrative:I.optional()}),ie=l({type:w("soundEffect"),sound:c(),volume:y().optional(),narrative:I.optional()}),oe=l({type:w("backgroundMusic"),sound:c().optional(),roomId:c().optional(),volume:y().optional(),narrative:I.optional()}),ce=l({type:w("ambientNoise"),sound:c().optional(),roomId:c().optional(),volume:y().optional(),narrative:I.optional()}),de=l({type:w("flag"),on:C(),flag:c(),narrative:I.optional()}),ue=l({type:w("storyBoardConsequence"),storyBoardId:c(),narrative:I.optional()}),ja=F.shape.zoneType.options,Vt=Q([Oe,K,ee,te,ae,Ae,ne,re,F,ie,oe,ce,de,se,ue]),Da=E(["conversation","sequence","changeStatus","backgroundMusic","ambientNoise","removeActor","inventory","changeRoom","order","teleportActor","toggleZone","soundEffect","flag","conversationChoice","storyBoardConsequence"]),Va=Da.options,$a={conversation:ne,sequence:Ae,changeStatus:ae,removeActor:te,inventory:ee,changeRoom:K,order:Oe,teleportActor:re,toggleZone:F,soundEffect:ie,flag:de,conversationChoice:se,backgroundMusic:oe,ambientNoise:ce,storyBoardConsequence:ue},Qe=Q([te,ae,ee,ne,re,F,ie,de,K,se,oe,ce,ue]),Ba=Qe.options.map(a=>a.shape.type.value),Re=l({verbId:c(),targetId:c(),roomId:c().optional(),itemId:c().optional(),targetStatus:c().optional(),mustReachFirst:C().optional(),consequences:R(Vt),flagsThatMustBeFalse:R(c()).optional(),flagsThatMustBeTrue:R(c()).optional(),requiredInventory:R(c()).optional()}),Ke=l({actorOrders:_(P(c(),ye.array())),immediateConsequences:_(Qe.array()),narrative:I.optional(),_started:At()}),ge=l({id:c(),description:c().optional(),stages:Ke.array()}),wt=l({conversationId:c().optional(),branchId:c().optional(),choiceRef:c().optional()}),et=l({ref:c().optional(),text:c(),sequence:c().optional(),nextBranch:_(c()),once:_(C()),disabled:_(C()),enablesChoices:R(wt).optional(),disablesChoices:R(wt).optional(),end:_(C()),choiceSequence:ge.optional()}),$t=l({choices:R(et)}),tt=l({id:c(),branches:P(c(),_($t)),currentBranch:_(c()),defaultBranch:c()}),at=l({id:c(),message:c(),imageId:c().optional(),imageWidth:y().optional()}),nt=l({type:w("ending"),endingId:c(),narrative:I.optional()}),Ma=Q([Oe,K,ee,te,ae,Ae,ne,re,F,ie,oe,ce,de,se,ue,nt]),Bt=Q([te,ae,ee,ne,re,F,ie,de,K,se,oe,ce,ue,nt]),st=Re.merge(l({consequences:R(Ma)})),Ne=ge.merge(l({stages:Ke.merge(l({immediateConsequences:_(Bt.array())})).array()})),Pa=et.merge(l({choiceSequence:Ne.optional()})),za=l({choices:R(Pa)}),rt=tt.merge(l({branches:P(c(),_(za))})),He=l({soundId:c(),frameIndex:y().optional(),volume:y().optional()}),La=P(c(),He.or(He.array()).or(Aa())),Ze=Te.merge(Nt).merge(Rt).merge(l({type:w("actor"),isPlayer:_(C()),noInteraction:_(C()),speed:_(y()),baseline:_(y()),dialogueColor:_(c()),soundEffectMap:La.optional(),walkToX:y().optional(),walkToY:y().optional(),defaultFrame:pe.optional(),statusFrames:P(pe).optional()})),Mt=l({value:C(),default:C(),description:c().optional()}),it=P(c(),Mt.optional()),ve=Te.extend({type:w("item"),actorId:c().optional()}).and(pe.partial());E(["rect","circle","polygon"]);const Fa=R(Xe([y(),y()])),Pt=l({type:c().optional(),x:y(),y:y(),path:_(c()),polygon:_(Fa),circle:_(y()),rect:_(Xe([y(),y()]))}),Je=Pt.merge(l({ref:c().optional(),disabled:C().optional()})),ot=Pt.merge(Te).merge(l({type:w("hotspot"),parallax:y(),walkToX:y().optional(),walkToY:y().optional()})),Wa=l({parallax:y(),imageId:c(),placement:l({x:y(),y:y(),width:y(),height:y()}).optional()}),Ua=R(Xe([y(),y()])),ct=l({id:c(),frameWidth:y(),frameHeight:y().optional(),width:y(),height:y(),background:Wa.array(),hotspots:ot.array().optional(),obstacleAreas:_(Je.array()),walkableAreas:_(Je.array()),scaling:_(Ua),backgroundColor:c().optional(),name:c().optional(),narrative:I.optional(),backgroundMusic:we.optional(),ambientNoise:we.optional()}),he=l({imageId:c(),row:y(),col:y()}),Ga=l({left:he.array().optional(),right:he.array().optional(),up:he.array().optional(),down:he.array().optional()}),dt=l({id:c(),defaultDirection:X,animations:P(c(),Ga)}),zt=E(["center","left","right"]),Lt=E(["center","top","bottom"]),Ha=l({x:zt,y:Lt,width:y().optional(),height:y().optional(),aspectRatio:Zt.optional()}),Ja=Ha.merge(l({image:pe})),Ft=l({title:c(),narrative:I,pictures:Ja.array(),backgroundColor:c(),color:c()}),Wt=E(["sound","buttons"]),Ut=E(["serif","sans-serif","monospace","cursive","fantasy","math"]),ut=l({id:c(),isEndOfGame:C().optional(),pages:Ft.array(),font:Ut.optional(),sound:we.optional(),progression:Wt.optional()}),Ee=l({id:c(),label:c(),preposition:c().optional(),isMoveVerb:C().optional(),isNotForItems:C().optional(),isLookVerb:C().optional(),requiresItem:C().optional(),defaultResponseNoItem:c().optional(),defaultResponseWithItem:c().optional(),defaultResponseCannotReach:c().optional()}),Ya=l({schemaVersion:y().optional(),rooms:ct.array(),items:ve.array(),actors:Ze.array(),interactions:st.array(),conversations:rt.array(),flagMap:it,currentRoomId:c(),id:c(),description:c().optional().describe("a short description of your game"),thumbnailAssetId:c().optional()}),Xa=l({verbs:Ee.array(),sequences:Ne.array(),sprites:dt.array(),endings:at.array(),openingSequenceId:c().optional(),openingStoryboardId:c().optional(),storyBoards:ut.array().optional()}),Gt=Ya.and(Xa).describe("The game schema"),qe=4,Ht=l({sequenceRunning:ge.optional(),currentStoryBoardId:c().optional(),actorOrders:P(c(),ye.array()),currentConversationId:c().optional(),pendingInteraction:Re.optional(),gameNotBegun:C()}),je=l({schemaVersion:w(qe),rooms:ct.array(),items:ve.array(),actors:Ze.array(),interactions:Re.array(),conversations:tt.array(),flagMap:it,currentRoomId:c(),id:c(),description:c().optional().describe("a short description of your game"),thumbnailAssetId:c().optional()}),lt=l({verbs:Ee.array(),sequences:ge.array(),sprites:dt.array(),openingSequenceId:c().optional(),openingStoryboardId:c().optional(),storyBoards:ut.array()}),Qa=je.and(Ht),Jt=je.and(lt).describe("The game schema"),Ka=E(["rooms","items","actors","conversations","sprites","sequences","verbs","storyBoards"]),en=je.merge(l({schemaVersion:w(3),interactions:st.array(),conversations:rt.array()})),tn=lt.merge(l({endings:at.array(),sequences:Ne.array()})),Yt=en.and(tn).describe("The game schema"),Xt=Q([Ze,ve,ot]),an=l({verb:Ee,target:Xt,item:_(ve)}),nn=a=>({...a,storyBoards:a.storyBoards??[],schemaVersion:3}),sn=a=>Qt(nn(a)),rn=(a,e)=>{const t=a.imageId?{x:"center",y:"center",width:a.imageWidth?a.imageWidth/16:20,height:a.imageWidth?a.imageWidth/16:20,image:{imageId:a.imageId}}:void 0;return{id:e??a.id,isEndOfGame:!0,pages:[{title:a.message,narrative:{text:[]},color:"#FFFFFF",backgroundColor:"#000000",pictures:t?[t]:[]}]}},on=(a,e)=>{const t=e.filter(s=>s.startsWith(a)),n=(s=1)=>{const r=`${a}_${s}`;return t.includes(r)?n(s+1):r};return n()},Qt=a=>{const{storyBoards:e,interactions:t,sequences:n,conversations:s}=a,r=e.map(T=>T.id),i={},o=a.endings.map(T=>{const N=r.includes(T.id)?on(T.id,r):void 0;return N&&r.push(N),i[T.id]=N??T.id,rn(T,N)}),f=T=>T.type!=="ending"?T:{type:"storyBoardConsequence",storyBoardId:i[T.endingId]??T.endingId,narrative:T.narrative},p=T=>({...T,stages:T.stages.map(N=>({...N,immediateConsequences:N.immediateConsequences?.map(f)}))}),k=T=>{const{branches:N}=T;for(let ea in N){const Ve=N[ea];Ve&&(Ve.choices=Ve.choices.map($e=>({...$e,choiceSequence:$e.choiceSequence?p($e.choiceSequence):void 0})))}return{...T,branches:N}},z=t.map(T=>({...T,consequences:T.consequences.map(f)})),De=n.map(p),Kt=s.map(k);return{...a,storyBoards:[...e,...o],interactions:z,sequences:De,conversations:Kt,schemaVersion:qe}},cn=a=>{const e=Jt.safeParse(a);if(e.success)return{success:!0,gameDesign:e.data,sourceVersion:qe,updated:!1};const t=Yt.safeParse(a);if(t.success)return{success:!0,gameDesign:Qt(t.data),sourceVersion:3,updated:!0};const n=Gt.safeParse(a);return n.success?{success:!0,gameDesign:sn(n.data),sourceVersion:2,updated:!0}:{success:!1,failureMessage:n.error.message}};exports.ActOrderSchema=Dt;exports.ActorDataSchema=Ze;exports.AmbientNoiseConsequenceSchema=ce;exports.AspectRatioSchema=Zt;exports.BackgroundMusicConsequenceSchema=oe;exports.BoardFontSchema=Ut;exports.BoardProgressionSchema=Wt;exports.ChangeRoomConsequenceSchema=K;exports.ChangeStatusConsequenceSchema=ae;exports.CommandSchema=an;exports.CommandTargetSchema=Xt;exports.ConsequenceSchema=Vt;exports.ConversationBranchSchema=$t;exports.ConversationChoiceConsequenceSchema=se;exports.ConversationChoiceSchema=et;exports.ConversationConsequenceSchema=ne;exports.ConversationSchema=tt;exports.ConversationSchemaWithDeprecatedConsequences=rt;exports.DB_VERSION=qe;exports.DirectionEnum=X;exports.EndingConsequenceSchema=nt;exports.EndingSchema=at;exports.FixedGameInfoSchema=lt;exports.FlagConsequenceSchema=de;exports.FlagMapSchema=it;exports.FlagSchema=Mt;exports.GameContentsDataSchema=je;exports.GameDataItemTypeEnum=Ka;exports.GameDataSchema=Qa;exports.GameDesignSchema=Jt;exports.GameHappeningsSchema=Ht;exports.GotoOrderSchema=qt;exports.HotspotZoneSchema=ot;exports.IdentSchema=Te;exports.ImmediateConsequenceSchema=Qe;exports.ImmediateConsequenceSchemaWithDeprecated=Bt;exports.InteractionSchema=Re;exports.InteractionSchemaWithDeprecatedConsequences=st;exports.InventoryConsequenceSchema=ee;exports.ItemDataSchema=ve;exports.MoveOrderSchema=Et;exports.NarrativeSchema=I;exports.OrderConsequenceSchema=Oe;exports.PositionSchema=Nt;exports.RemoveActorConsequenceSchema=te;exports.RoomDataSchema=ct;exports.SayOrderSchema=jt;exports.SequenceConsequenceSchema=Ae;exports.SequenceSchema=ge;exports.SequenceSchemaWithDeprecatedConsequences=Ne;exports.SoundEffectConsequenceSchema=ie;exports.SoundValueSchema=He;exports.SpriteDataSchema=dt;exports.SpriteFrameSchema=he;exports.SpriteParamsSchema=Rt;exports.StageSchema=Ke;exports.StaticFrameParamsSchema=pe;exports.StoryBoardConsequenceSchema=ue;exports.StoryBoardPageSchema=Ft;exports.StoryBoardSchema=ut;exports.TeleportActorConsequenceSchema=re;exports.ToggleZoneConsequenceSchema=F;exports.VerbSchema=Ee;exports.ZoneSchema=Je;exports.changeHistory=aa;exports.consequenceMap=$a;exports.consequenceTypes=Va;exports.directions=Ra;exports.immediateConsequenceTypes=Ba;exports.orderBaseOmits=Na;exports.orderSchema=ye;exports.orderTypes=qa;exports.parseAndUpgrade=cn;exports.soundInstanceSchema=we;exports.sum=ta;exports.v2GameDesignSchema=Gt;exports.v3GameDesignSchema=Yt;exports.xPlacement=zt;exports.yPlacement=Lt;exports.zoneTypes=ja;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const aa=[{schemaVersion:3,changes:[{breaking:!1,description:"Designs have schemaVersion property"},{breaking:!1,description:"storyBoards array is required"}]},{schemaVersion:4,changes:[{breaking:!0,description:"Endings deprecated in favour of storyBoards. Any Endings have been converted to Storyboards."},{breaking:!1,description:"StoryBoards have end of game option."}]}];var b;(function(a){a.assertEqual=s=>{};function e(s){}a.assertIs=e;function t(s){throw new Error}a.assertNever=t,a.arrayToEnum=s=>{const r={};for(const i of s)r[i]=i;return r},a.getValidEnumValues=s=>{const r=a.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of r)i[o]=s[o];return a.objectValues(i)},a.objectValues=s=>a.objectKeys(s).map(function(r){return s[r]}),a.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const r=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&r.push(i);return r},a.find=(s,r)=>{for(const i of s)if(r(i))return i},a.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,r=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}a.joinValues=n,a.jsonStringifyReplacer=(s,r)=>typeof r=="bigint"?r.toString():r})(b||(b={}));var mt;(function(a){a.mergeShapes=(e,t)=>({...e,...t})})(mt||(mt={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=a=>{switch(typeof a){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(a)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(a)?h.array:a===null?h.null:a.then&&typeof a.then=="function"&&a.catch&&typeof a.catch=="function"?h.promise:typeof Map<"u"&&a instanceof Map?h.map:typeof Set<"u"&&a instanceof Set?h.set:typeof Date<"u"&&a instanceof Date?h.date:h.object;default:return h.unknown}},d=b.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 V extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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(r){return r.message},n={_errors:[]},s=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,f=0;for(;f<i.path.length;){const p=i.path[f];f===i.path.length-1?(o[p]=o[p]||{_errors:[]},o[p]._errors.push(t(i))):o[p]=o[p]||{_errors:[]},o=o[p],f++}}};return s(this),n}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)if(s.path.length>0){const r=s.path[0];t[r]=t[r]||[],t[r].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=a=>new V(a);const Me=(a,e)=>{let t;switch(a.code){case d.invalid_type:a.received===h.undefined?t="Required":t=`Expected ${a.expected}, received ${a.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(a.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(a.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(a.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof a.validation=="object"?"includes"in a.validation?(t=`Invalid input: must include "${a.validation.includes}"`,typeof a.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${a.validation.position}`)):"startsWith"in a.validation?t=`Invalid input: must start with "${a.validation.startsWith}"`:"endsWith"in a.validation?t=`Invalid input: must end with "${a.validation.endsWith}"`:b.assertNever(a.validation):a.validation!=="regex"?t=`Invalid ${a.validation}`:t="Invalid";break;case d.too_small:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at least":"more than"} ${a.minimum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at least":"over"} ${a.minimum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="bigint"?t=`Number must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${a.minimum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly equal to ":a.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(a.minimum))}`:t="Invalid input";break;case d.too_big:a.type==="array"?t=`Array must contain ${a.exact?"exactly":a.inclusive?"at most":"less than"} ${a.maximum} element(s)`:a.type==="string"?t=`String must contain ${a.exact?"exactly":a.inclusive?"at most":"under"} ${a.maximum} character(s)`:a.type==="number"?t=`Number must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="bigint"?t=`BigInt must be ${a.exact?"exactly":a.inclusive?"less than or equal to":"less than"} ${a.maximum}`:a.type==="date"?t=`Date must be ${a.exact?"exactly":a.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(a.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${a.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(a)}return{message:t}};let na=Me;function sa(){return na}const ra=a=>{const{data:e,path:t,errorMaps:n,issueData:s}=a,r=[...t,...s.path||[]],i={...s,path:r};if(s.message!==void 0)return{...s,path:r,message:s.message};let o="";const f=n.filter(p=>!!p).slice().reverse();for(const p of f)o=p(i,{data:e,defaultError:o}).message;return{...s,path:r,message:o}};function u(a,e){const t=sa(),n=ra({issueData:e,data:a.data,path:a.path,errorMaps:[a.common.contextualErrorMap,a.schemaErrorMap,t,t===Me?void 0:Me].filter(s=>!!s)});a.common.issues.push(n)}class A{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const r=await s.key,i=await s.value;n.push({key:r,value:i})}return A.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:r,value:i}=s;if(r.status==="aborted"||i.status==="aborted")return v;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[r.value]=i.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),he=a=>({status:"dirty",value:a}),Z=a=>({status:"valid",value:a}),ft=a=>a.status==="aborted",pt=a=>a.status==="dirty",U=a=>a.status==="valid",xe=a=>typeof Promise<"u"&&a instanceof Promise;var m;(function(a){a.errToObj=e=>typeof e=="string"?{message:e}:e||{},a.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));class j{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const yt=(a,e)=>{if(U(e))return{success:!0,data:e.value};if(!a.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 V(a.common.issues);return this._error=t,this._error}}};function x(a){if(!a)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=a;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:f}=a;return i.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:f??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:f??t??o.defaultError}},description:s}}class S{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(xe(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){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parseSync({data:e,path:n.path,parent:n});return yt(n,s)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return U(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>U(n)?{value:n.value}:{issues:t.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:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(xe(s)?s:Promise.resolve(s));return yt(n,r)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,r)=>{const i=e(s),o=()=>r.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new J({schema:this,typeName:g.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:t=>this["~validate"](t)}}optional(){return $.create(this,this._def)}nullable(){return Y.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return we.create(this,this._def)}or(e){return ke.create([this,e],this._def)}and(e){return be.create(this,e,this._def)}transform(e){return new J({...x(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ue({...x(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new Oa({typeName:g.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ge({...x(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Xe.create(this,e)}readonly(){return He.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ia=/^c[^\s-]{8,}$/i,oa=/^[0-9a-z]+$/,ca=/^[0-9A-HJKMNP-TV-Z]{26}$/i,da=/^[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,ua=/^[a-z0-9_-]{21}$/i,la=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ha=/^[-+]?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)?)??$/,ma=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Be;const pa=/^(?:(?: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])$/,ya=/^(?:(?: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])$/,ga=/^(([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]))$/,va=/^(([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])$/,_a=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xa=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,It="((\\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])))",Sa=new RegExp(`^${It}$`);function Ot(a){let e="[0-5]\\d";a.precision?e=`${e}\\.\\d{${a.precision}}`:a.precision==null&&(e=`${e}(\\.\\d+)?`);const t=a.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function ka(a){return new RegExp(`^${Ot(a)}$`)}function ba(a){let e=`${It}T${Ot(a)}`;const t=[];return t.push(a.local?"Z?":"Z"),a.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ca(a,e){return!!((e==="v4"||!e)&&pa.test(a)||(e==="v6"||!e)&&ga.test(a))}function wa(a,e){if(!la.test(a))return!1;try{const[t]=a.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ta(a,e){return!!((e==="v4"||!e)&&ya.test(a)||(e==="v6"||!e)&&va.test(a))}class D extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.string,received:r.parsedType}),v}const n=new A;let s;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="max")e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?u(s,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&u(s,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")ma.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"email",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")Be||(Be=new RegExp(fa,"u")),Be.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"emoji",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")da.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"uuid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")ua.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"nanoid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")ia.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")oa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cuid2",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")ca.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ulid",code:d.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),u(s,{validation:"url",code:d.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"regex",code:d.invalid_string,message:r.message}),n.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?ba(r).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?Sa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?ka(r).test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:d.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?ha.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"duration",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?Ca(e.data,r.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"ip",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="jwt"?wa(e.data,r.alg)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"jwt",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="cidr"?Ta(e.data,r.version)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"cidr",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?_a.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64",code:d.invalid_string,message:r.message}),n.dirty()):r.kind==="base64url"?xa.test(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{validation:"base64url",code:d.invalid_string,message:r.message}),n.dirty()):b.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...m.errToObj(n)})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new D({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=a=>new D({checks:[],typeName:g.ZodString,coerce:a?.coerce??!1,...x(a)});function Ia(a,e){const t=(a.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,r=Number.parseInt(a.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return r%i/10**s}class G extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.number,received:r.parsedType}),v}let n;const s=new A;for(const r of this._def.checks)r.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:d.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="multipleOf"?Ia(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_finite,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new G({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}G.create=a=>new G({checks:[],typeName:g.ZodNumber,coerce:a?.coerce||!1,...x(a)});class fe extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let n;const s=new A;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),u(n,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,n,s){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:m.toString(s)}]})}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}fe.create=a=>new fe({checks:[],typeName:g.ZodBigInt,coerce:a?.coerce??!1,...x(a)});class ze extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),v}return Z(e.data)}}ze.create=a=>new ze({typeName:g.ZodBoolean,coerce:a?.coerce||!1,...x(a)});class Se extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_type,expected:h.date,received:r.parsedType}),v}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return u(r,{code:d.invalid_date}),v}const n=new A;let s;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(s=this._getOrReturnCtx(e,s),u(s,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):b.assertNever(r);return{status:n.value,value:new Date(e.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:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Se.create=a=>new Se({checks:[],coerce:a?.coerce||!1,typeName:g.ZodDate,...x(a)});class gt extends S{_parse(e){if(this._getType(e)!==h.symbol){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),v}return Z(e.data)}}gt.create=a=>new gt({typeName:g.ZodSymbol,...x(a)});class Le extends S{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),v}return Z(e.data)}}Le.create=a=>new Le({typeName:g.ZodUndefined,...x(a)});class vt extends S{_parse(e){if(this._getType(e)!==h.null){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),v}return Z(e.data)}}vt.create=a=>new vt({typeName:g.ZodNull,...x(a)});class _t extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return Z(e.data)}}_t.create=a=>new _t({typeName:g.ZodAny,...x(a)});class xt extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Z(e.data)}}xt.create=a=>new xt({typeName:g.ZodUnknown,...x(a)});class B extends S{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),v}}B.create=a=>new B({typeName:g.ZodNever,...x(a)});class St extends S{_parse(e){if(this._getType(e)!==h.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),v}return Z(e.data)}}St.create=a=>new St({typeName:g.ZodVoid,...x(a)});class q extends S{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==h.array)return u(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),v;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(u(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(u(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(u(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new j(t,i,t.path,o)))).then(i=>A.mergeArray(n,i));const r=[...t.data].map((i,o)=>s.type._parseSync(new j(t,i,t.path,o)));return A.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new q({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new q({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new q({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}q.create=(a,e)=>new q({type:a,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...x(e)});function W(a){if(a instanceof O){const e={};for(const t in a.shape){const n=a.shape[t];e[t]=$.create(W(n))}return new O({...a._def,shape:()=>e})}else return a instanceof q?new q({...a._def,type:W(a.element)}):a instanceof $?$.create(W(a.unwrap())):a instanceof Y?Y.create(W(a.unwrap())):a instanceof L?L.create(a.items.map(e=>W(e))):a}class O extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const p=this._getOrReturnCtx(e);return u(p,{code:d.invalid_type,expected:h.object,received:p.parsedType}),v}const{status:n,ctx:s}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const p in s.data)i.includes(p)||o.push(p);const f=[];for(const p of i){const k=r[p],z=s.data[p];f.push({key:{status:"valid",value:p},value:k._parse(new j(s,z,s.path,p)),alwaysSet:p in s.data})}if(this._def.catchall instanceof B){const p=this._def.unknownKeys;if(p==="passthrough")for(const k of o)f.push({key:{status:"valid",value:k},value:{status:"valid",value:s.data[k]}});else if(p==="strict")o.length>0&&(u(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const k of o){const z=s.data[k];f.push({key:{status:"valid",value:k},value:p._parse(new j(s,z,s.path,k)),alwaysSet:k in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const p=[];for(const k of f){const z=await k.key,Ve=await k.value;p.push({key:z,value:Ve,alwaysSet:k.alwaysSet})}return p}).then(p=>A.mergeObjectSync(n,p)):A.mergeObjectSync(n,f)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new O({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{const s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:m.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend(e){return new O({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new O({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new O({...this._def,catchall:e})}pick(e){const t={};for(const n of b.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new O({...this._def,shape:()=>t})}omit(e){const t={};for(const n of b.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new O({...this._def,shape:()=>t})}deepPartial(){return W(this)}partial(e){const t={};for(const n of b.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new O({...this._def,shape:()=>t})}required(e){const t={};for(const n of b.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof $;)r=r._def.innerType;t[n]=r}return new O({...this._def,shape:()=>t})}keyof(){return At(b.objectKeys(this.shape))}}O.create=(a,e)=>new O({shape:()=>a,unknownKeys:"strip",catchall:B.create(),typeName:g.ZodObject,...x(e)});O.strictCreate=(a,e)=>new O({shape:()=>a,unknownKeys:"strict",catchall:B.create(),typeName:g.ZodObject,...x(e)});O.lazycreate=(a,e)=>new O({shape:a,unknownKeys:"strip",catchall:B.create(),typeName:g.ZodObject,...x(e)});class ke extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new V(o.ctx.common.issues));return u(t,{code:d.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(n.map(async r=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let r;const i=[];for(const f of n){const p={...t,common:{...t.common,issues:[]},parent:null},k=f._parseSync({data:t.data,path:t.path,parent:p});if(k.status==="valid")return k;k.status==="dirty"&&!r&&(r={result:k,ctx:p}),p.common.issues.length&&i.push(p.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(f=>new V(f));return u(t,{code:d.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}ke.create=(a,e)=>new ke({options:a,typeName:g.ZodUnion,...x(e)});function Fe(a,e){const t=P(a),n=P(e);if(a===e)return{valid:!0,data:a};if(t===h.object&&n===h.object){const s=b.objectKeys(e),r=b.objectKeys(a).filter(o=>s.indexOf(o)!==-1),i={...a,...e};for(const o of r){const f=Fe(a[o],e[o]);if(!f.valid)return{valid:!1};i[o]=f.data}return{valid:!0,data:i}}else if(t===h.array&&n===h.array){if(a.length!==e.length)return{valid:!1};const s=[];for(let r=0;r<a.length;r++){const i=a[r],o=e[r],f=Fe(i,o);if(!f.valid)return{valid:!1};s.push(f.data)}return{valid:!0,data:s}}else return t===h.date&&n===h.date&&+a==+e?{valid:!0,data:a}:{valid:!1}}class be extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(r,i)=>{if(ft(r)||ft(i))return v;const o=Fe(r.value,i.value);return o.valid?((pt(r)||pt(i))&&t.dirty(),{status:t.value,value:o.data}):(u(n,{code:d.invalid_intersection_types}),v)};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(([r,i])=>s(r,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}be.create=(a,e,t)=>new be({left:a,right:e,typeName:g.ZodIntersection,...x(t)});class L extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return u(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return u(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(u(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...n.data].map((i,o)=>{const f=this._def.items[o]||this._def.rest;return f?f._parse(new j(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>A.mergeArray(t,i)):A.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new L({...this._def,rest:e})}}L.create=(a,e)=>{if(!Array.isArray(a))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new L({items:a,typeName:g.ZodTuple,rest:null,...x(e)})};class Ce extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return u(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),v;const s=[],r=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:r._parse(new j(n,o,n.path,o)),value:i._parse(new j(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?A.mergeObjectAsync(t,s):A.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof S?new Ce({keyType:e,valueType:t,typeName:g.ZodRecord,...x(n)}):new Ce({keyType:D.create(),valueType:e,typeName:g.ZodRecord,...x(t)})}}class kt extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return u(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),v;const s=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([o,f],p)=>({key:s._parse(new j(n,o,n.path,[p,"key"])),value:r._parse(new j(n,f,n.path,[p,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const f of i){const p=await f.key,k=await f.value;if(p.status==="aborted"||k.status==="aborted")return v;(p.status==="dirty"||k.status==="dirty")&&t.dirty(),o.set(p.value,k.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const f of i){const p=f.key,k=f.value;if(p.status==="aborted"||k.status==="aborted")return v;(p.status==="dirty"||k.status==="dirty")&&t.dirty(),o.set(p.value,k.value)}return{status:t.value,value:o}}}}kt.create=(a,e,t)=>new kt({valueType:e,keyType:a,typeName:g.ZodMap,...x(t)});class pe extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return u(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),v;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(u(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(u(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const r=this._def.valueType;function i(f){const p=new Set;for(const k of f){if(k.status==="aborted")return v;k.status==="dirty"&&t.dirty(),p.add(k.value)}return{status:t.value,value:p}}const o=[...n.data.values()].map((f,p)=>r._parse(new j(n,f,n.path,p)));return n.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new pe({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new pe({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}pe.create=(a,e)=>new pe({valueType:a,minSize:null,maxSize:null,typeName:g.ZodSet,...x(e)});class bt extends S{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})}}bt.create=(a,e)=>new bt({getter:a,typeName:g.ZodLazy,...x(e)});class We extends S{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}We.create=(a,e)=>new We({value:a,typeName:g.ZodLiteral,...x(e)});function At(a,e){return new H({values:a,typeName:g.ZodEnum,...x(e)})}class H extends S{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return u(t,{expected:b.joinValues(n),received:t.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return u(t,{received:t.data,code:d.invalid_enum_value,options:n}),v}return Z(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return H.create(e,{...this._def,...t})}exclude(e,t=this._def){return H.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}H.create=At;class Ct extends S{_parse(e){const t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){const s=b.objectValues(t);return u(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=b.objectValues(t);return u(n,{received:n.data,code:d.invalid_enum_value,options:s}),v}return Z(e.data)}get enum(){return this._def.values}}Ct.create=(a,e)=>new Ct({values:a,typeName:g.ZodNativeEnum,...x(e)});class we extends S{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return u(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),v;const n=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return Z(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}we.create=(a,e)=>new we({type:a,typeName:g.ZodPromise,...x(e)});class J extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:i=>{u(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){const i=s.transform(n.data,r);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return v;const f=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return f.status==="aborted"?v:f.status==="dirty"||t.value==="dirty"?he(f.value):f});{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?he(o.value):o}}if(s.type==="refinement"){const i=o=>{const f=s.refinement(o,r);if(n.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!U(i))return v;const o=s.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>U(i)?Promise.resolve(s.transform(i.value,r)).then(o=>({status:t.value,value:o})):v);b.assertNever(s)}}J.create=(a,e,t)=>new J({schema:a,typeName:g.ZodEffects,effect:e,...x(t)});J.createWithPreprocess=(a,e,t)=>new J({schema:e,effect:{type:"preprocess",transform:a},typeName:g.ZodEffects,...x(t)});class $ extends S{_parse(e){return this._getType(e)===h.undefined?Z(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$.create=(a,e)=>new $({innerType:a,typeName:g.ZodOptional,...x(e)});class Y extends S{_parse(e){return this._getType(e)===h.null?Z(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(a,e)=>new Y({innerType:a,typeName:g.ZodNullable,...x(e)});class Ue extends S{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ue.create=(a,e)=>new Ue({innerType:a,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class Ge extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return xe(s)?s.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ge.create=(a,e)=>new Ge({innerType:a,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class wt extends S{_parse(e){if(this._getType(e)!==h.nan){const n=this._getOrReturnCtx(e);return u(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}}wt.create=a=>new wt({typeName:g.ZodNaN,...x(a)});class Oa extends S{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Xe extends S{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?v:r.status==="dirty"?(t.dirty(),he(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xe({in:e,out:t,typeName:g.ZodPipeline})}}class He extends S{_parse(e){const t=this._def.innerType._parse(e),n=s=>(U(s)&&(s.value=Object.freeze(s.value)),s);return xe(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}He.create=(a,e)=>new He({innerType:a,typeName:g.ZodReadonly,...x(e)});var g;(function(a){a.ZodString="ZodString",a.ZodNumber="ZodNumber",a.ZodNaN="ZodNaN",a.ZodBigInt="ZodBigInt",a.ZodBoolean="ZodBoolean",a.ZodDate="ZodDate",a.ZodSymbol="ZodSymbol",a.ZodUndefined="ZodUndefined",a.ZodNull="ZodNull",a.ZodAny="ZodAny",a.ZodUnknown="ZodUnknown",a.ZodNever="ZodNever",a.ZodVoid="ZodVoid",a.ZodArray="ZodArray",a.ZodObject="ZodObject",a.ZodUnion="ZodUnion",a.ZodDiscriminatedUnion="ZodDiscriminatedUnion",a.ZodIntersection="ZodIntersection",a.ZodTuple="ZodTuple",a.ZodRecord="ZodRecord",a.ZodMap="ZodMap",a.ZodSet="ZodSet",a.ZodFunction="ZodFunction",a.ZodLazy="ZodLazy",a.ZodLiteral="ZodLiteral",a.ZodEnum="ZodEnum",a.ZodEffects="ZodEffects",a.ZodNativeEnum="ZodNativeEnum",a.ZodOptional="ZodOptional",a.ZodNullable="ZodNullable",a.ZodDefault="ZodDefault",a.ZodCatch="ZodCatch",a.ZodPromise="ZodPromise",a.ZodBranded="ZodBranded",a.ZodPipeline="ZodPipeline",a.ZodReadonly="ZodReadonly"})(g||(g={}));const c=D.create,y=G.create,w=ze.create,Aa=Le.create;B.create;const R=q.create,l=O.create,Q=ke.create;be.create;const Qe=L.create,M=Ce.create,C=We.create,E=H.create;we.create;const _=$.create;Y.create;const Rt=()=>w().optional(),X=E(["left","right","up","down"]),Ra=X.options,Ie=l({type:c(),id:c(),name:_(c()),status:_(c())}),Nt=l({height:y(),width:y(),sprite:c().optional(),direction:_(X),filter:_(c())}),Zt=l({room:_(c()),x:y(),y:y()}),ye=l({imageId:c(),col:y().optional(),row:y().optional()}),I=l({text:c().array()}),Et=l({x:y(),y:y()}),Te=l({soundId:c(),volume:y().optional()}),Oe={_started:Rt(),narrative:I.optional(),startDirection:X.optional(),endDirection:X.optional(),endStatus:c().optional()},Na={_started:!0,narrative:!0,startDirection:!0,endDirection:!0,endStatus:!0,type:!0},Za=l({animation:_(c()),x:y(),y:y(),speed:_(y())}),qt=l({type:C("move"),roomId:c().optional(),pathIsSet:_(w()),doPendingInteractionWhenFinished:_(w()),steps:R(Za)}).extend(Oe),jt=l({type:C("goTo"),animation:_(c()),speed:_(y()),targetId:c()}).extend(Oe),Dt=l({type:C("say"),animation:_(c()),text:c(),time:y()}).extend(Oe),Ea=l({animation:_(c()),duration:y(),timeElapsed:_(y()),reverse:_(w())}),Vt=l({type:C("act"),steps:R(Ea)}).extend(Oe),ge=Q([qt,Vt,Dt,jt]),qa=ge.options.map(a=>a.shape.type.value),Ae=l({type:C("order"),actorId:c().optional(),orders:R(ge),replaceCurrentOrders:_(w()),narrative:I.optional()}),K=l({type:C("changeRoom"),roomId:c(),takePlayer:w(),x:_(y()),y:_(y()),narrative:I.optional()}),ee=l({type:C("inventory"),itemId:c(),actorId:c().optional(),addOrRemove:E(["ADD","REMOVE"]),narrative:I.optional()}),te=l({type:C("removeActor"),actorId:c(),narrative:I.optional()}),ae=l({type:C("changeStatus"),targetId:c(),targetType:E(["actor","item","hotspot"]),status:c(),narrative:I.optional()}),Re=l({type:C("sequence"),sequence:c(),narrative:I.optional()}),ne=l({type:C("conversation"),conversationId:c(),end:_(w()),narrative:I.optional()}),se=l({type:C("conversationChoice"),on:w(),conversationId:c(),branchId:c(),choiceRef:c(),narrative:I.optional()}),re=l({type:C("teleportActor"),actorId:c(),roomId:_(c()),x:y(),y:y(),narrative:I.optional()}),F=l({type:C("toggleZone"),roomId:_(c()),on:w(),ref:c(),zoneType:E(["hotspot","obstacle","walkable"]),narrative:I.optional()}),ie=l({type:C("soundEffect"),sound:c(),volume:y().optional(),narrative:I.optional()}),oe=l({type:C("backgroundMusic"),sound:c().optional(),roomId:c().optional(),volume:y().optional(),narrative:I.optional()}),ce=l({type:C("ambientNoise"),sound:c().optional(),roomId:c().optional(),volume:y().optional(),narrative:I.optional()}),de=l({type:C("flag"),on:w(),flag:c(),narrative:I.optional()}),ue=l({type:C("storyBoardConsequence"),storyBoardId:c(),narrative:I.optional()}),le=l({type:C("changePlayerCharacterConsequence"),actorId:c(),narrative:I.optional()}),ja=F.shape.zoneType.options,Pt=Q([Ae,K,ee,te,ae,Re,ne,re,F,ie,oe,ce,de,se,ue,le]),Da=E(["conversation","sequence","changeStatus","backgroundMusic","ambientNoise","removeActor","inventory","changeRoom","order","teleportActor","toggleZone","soundEffect","flag","conversationChoice","storyBoardConsequence","changePlayerCharacterConsequence"]),Va=Da.options,Pa={conversation:ne,sequence:Re,changeStatus:ae,removeActor:te,inventory:ee,changeRoom:K,order:Ae,teleportActor:re,toggleZone:F,soundEffect:ie,flag:de,conversationChoice:se,backgroundMusic:oe,ambientNoise:ce,storyBoardConsequence:ue,changePlayerCharacterConsequence:le},Ke=Q([te,ae,ee,ne,re,F,ie,de,K,se,oe,ce,ue,le]),$a=Ke.options.map(a=>a.shape.type.value),Ne=l({verbId:c(),targetId:c(),roomId:c().optional(),itemId:c().optional(),targetStatus:c().optional(),mustReachFirst:w().optional(),consequences:R(Pt),flagsThatMustBeFalse:R(c()).optional(),flagsThatMustBeTrue:R(c()).optional(),requiredInventory:R(c()).optional()}),et=l({actorOrders:_(M(c(),ge.array())),immediateConsequences:_(Ke.array()),narrative:I.optional(),_started:Rt()}),ve=l({id:c(),description:c().optional(),stages:et.array()}),Tt=l({conversationId:c().optional(),branchId:c().optional(),choiceRef:c().optional()}),tt=l({ref:c().optional(),text:c(),sequence:c().optional(),nextBranch:_(c()),once:_(w()),disabled:_(w()),enablesChoices:R(Tt).optional(),disablesChoices:R(Tt).optional(),end:_(w()),choiceSequence:ve.optional()}),$t=l({choices:R(tt)}),at=l({id:c(),branches:M(c(),_($t)),currentBranch:_(c()),defaultBranch:c()}),nt=l({id:c(),message:c(),imageId:c().optional(),imageWidth:y().optional()}),st=l({type:C("ending"),endingId:c(),narrative:I.optional()}),Ba=Q([Ae,K,ee,te,ae,Re,ne,re,F,ie,oe,ce,de,se,ue,le,st]),Bt=Q([te,ae,ee,ne,re,F,ie,de,K,se,oe,ce,ue,le,st]),rt=Ne.merge(l({consequences:R(Ba)})),Ze=ve.merge(l({stages:et.merge(l({immediateConsequences:_(Bt.array())})).array()})),Ma=tt.merge(l({choiceSequence:Ze.optional()})),za=l({choices:R(Ma)}),it=at.merge(l({branches:M(c(),_(za))})),Je=l({soundId:c(),frameIndex:y().optional(),volume:y().optional()}),La=M(c(),Je.or(Je.array()).or(Aa())),Ee=Ie.merge(Zt).merge(Nt).merge(l({type:C("actor"),isPlayer:_(w()),noInteraction:_(w()),speed:_(y()),baseline:_(y()),dialogueColor:_(c()),soundEffectMap:La.optional(),walkToX:y().optional(),walkToY:y().optional(),defaultFrame:ye.optional(),statusFrames:M(ye).optional()})),Mt=l({value:w(),default:w(),description:c().optional()}),ot=M(c(),Mt.optional()),_e=Ie.extend({type:C("item"),actorId:c().optional()}).and(ye.partial());E(["rect","circle","polygon"]);const Fa=R(Qe([y(),y()])),zt=l({type:c().optional(),x:y(),y:y(),path:_(c()),polygon:_(Fa),circle:_(y()),rect:_(Qe([y(),y()]))}),Ye=zt.merge(l({ref:c().optional(),disabled:w().optional()})),ct=zt.merge(Ie).merge(l({type:C("hotspot"),parallax:y(),walkToX:y().optional(),walkToY:y().optional()})),Wa=l({parallax:y(),imageId:c(),placement:l({x:y(),y:y(),width:y(),height:y()}).optional()}),Ua=R(Qe([y(),y()])),dt=l({id:c(),frameWidth:y(),frameHeight:y().optional(),width:y(),height:y(),background:Wa.array(),hotspots:ct.array().optional(),obstacleAreas:_(Ye.array()),walkableAreas:_(Ye.array()),scaling:_(Ua),backgroundColor:c().optional(),name:c().optional(),narrative:I.optional(),backgroundMusic:Te.optional(),ambientNoise:Te.optional()}),me=l({imageId:c(),row:y(),col:y()}),Ga=l({left:me.array().optional(),right:me.array().optional(),up:me.array().optional(),down:me.array().optional()}),ut=l({id:c(),defaultDirection:X,animations:M(c(),Ga)}),Lt=E(["center","left","right"]),Ft=E(["center","top","bottom"]),Ha=l({x:Lt,y:Ft,width:y().optional(),height:y().optional(),aspectRatio:Et.optional()}),Ja=Ha.merge(l({image:ye})),Wt=l({title:c(),narrative:I,pictures:Ja.array(),backgroundColor:c(),color:c()}),Ut=E(["sound","buttons"]),Gt=E(["serif","sans-serif","monospace","cursive","fantasy","math"]),lt=l({id:c(),isEndOfGame:w().optional(),pages:Wt.array(),font:Gt.optional(),sound:Te.optional(),progression:Ut.optional()}),qe=l({id:c(),label:c(),preposition:c().optional(),isMoveVerb:w().optional(),isNotForItems:w().optional(),isLookVerb:w().optional(),requiresItem:w().optional(),defaultResponseNoItem:c().optional(),defaultResponseWithItem:c().optional(),defaultResponseCannotReach:c().optional()}),Ya=l({schemaVersion:y().optional(),rooms:dt.array(),items:_e.array(),actors:Ee.array(),interactions:rt.array(),conversations:it.array(),flagMap:ot,currentRoomId:c(),id:c(),description:c().optional().describe("a short description of your game"),thumbnailAssetId:c().optional()}),Xa=l({verbs:qe.array(),sequences:Ze.array(),sprites:ut.array(),endings:nt.array(),openingSequenceId:c().optional(),openingStoryboardId:c().optional(),storyBoards:lt.array().optional()}),Ht=Ya.and(Xa).describe("The game schema"),je=4,Jt=l({sequenceRunning:ve.optional(),currentStoryBoardId:c().optional(),actorOrders:M(c(),ge.array()),currentConversationId:c().optional(),pendingInteraction:Ne.optional(),gameNotBegun:w()}),De=l({schemaVersion:C(je),rooms:dt.array(),items:_e.array(),actors:Ee.array(),interactions:Ne.array(),conversations:at.array(),flagMap:ot,currentRoomId:c(),id:c(),description:c().optional().describe("a short description of your game"),thumbnailAssetId:c().optional()}),ht=l({verbs:qe.array(),sequences:ve.array(),sprites:ut.array(),openingSequenceId:c().optional(),openingStoryboardId:c().optional(),storyBoards:lt.array()}),Qa=De.and(Jt),Yt=De.and(ht).describe("The game schema"),Ka=E(["rooms","items","actors","conversations","sprites","sequences","verbs","storyBoards"]),en=De.merge(l({schemaVersion:C(3),interactions:rt.array(),conversations:it.array()})),tn=ht.merge(l({endings:nt.array(),sequences:Ze.array()})),Xt=en.and(tn).describe("The game schema"),Qt=Q([Ee,_e,ct]),an=l({verb:qe,target:Qt,item:_(_e)}),nn=a=>({...a,storyBoards:a.storyBoards??[],schemaVersion:3}),sn=a=>Kt(nn(a)),rn=(a,e)=>{const t=a.imageId?{x:"center",y:"center",width:a.imageWidth?a.imageWidth/16:20,height:a.imageWidth?a.imageWidth/16:20,image:{imageId:a.imageId}}:void 0;return{id:e??a.id,isEndOfGame:!0,pages:[{title:a.message,narrative:{text:[]},color:"#FFFFFF",backgroundColor:"#000000",pictures:t?[t]:[]}]}},on=(a,e)=>{const t=e.filter(s=>s.startsWith(a)),n=(s=1)=>{const r=`${a}_${s}`;return t.includes(r)?n(s+1):r};return n()},Kt=a=>{const{storyBoards:e,interactions:t,sequences:n,conversations:s}=a,r=e.map(T=>T.id),i={},o=a.endings.map(T=>{const N=r.includes(T.id)?on(T.id,r):void 0;return N&&r.push(N),i[T.id]=N??T.id,rn(T,N)}),f=T=>T.type!=="ending"?T:{type:"storyBoardConsequence",storyBoardId:i[T.endingId]??T.endingId,narrative:T.narrative},p=T=>({...T,stages:T.stages.map(N=>({...N,immediateConsequences:N.immediateConsequences?.map(f)}))}),k=T=>{const{branches:N}=T;for(let ta in N){const Pe=N[ta];Pe&&(Pe.choices=Pe.choices.map($e=>({...$e,choiceSequence:$e.choiceSequence?p($e.choiceSequence):void 0})))}return{...T,branches:N}},z=t.map(T=>({...T,consequences:T.consequences.map(f)})),Ve=n.map(p),ea=s.map(k);return{...a,storyBoards:[...e,...o],interactions:z,sequences:Ve,conversations:ea,schemaVersion:je}},cn=a=>{const e=Yt.safeParse(a);if(e.success)return{success:!0,gameDesign:e.data,sourceVersion:je,updated:!1};const t=Xt.safeParse(a);if(t.success)return{success:!0,gameDesign:Kt(t.data),sourceVersion:3,updated:!0};const n=Ht.safeParse(a);return n.success?{success:!0,gameDesign:sn(n.data),sourceVersion:2,updated:!0}:{success:!1,failureMessage:n.error.message}};exports.ActOrderSchema=Vt;exports.ActorDataSchema=Ee;exports.AmbientNoiseConsequenceSchema=ce;exports.AspectRatioSchema=Et;exports.BackgroundMusicConsequenceSchema=oe;exports.BoardFontSchema=Gt;exports.BoardProgressionSchema=Ut;exports.ChangePlayerCharacterConsequenceSchema=le;exports.ChangeRoomConsequenceSchema=K;exports.ChangeStatusConsequenceSchema=ae;exports.CommandSchema=an;exports.CommandTargetSchema=Qt;exports.ConsequenceSchema=Pt;exports.ConversationBranchSchema=$t;exports.ConversationChoiceConsequenceSchema=se;exports.ConversationChoiceSchema=tt;exports.ConversationConsequenceSchema=ne;exports.ConversationSchema=at;exports.ConversationSchemaWithDeprecatedConsequences=it;exports.DB_VERSION=je;exports.DirectionEnum=X;exports.EndingConsequenceSchema=st;exports.EndingSchema=nt;exports.FixedGameInfoSchema=ht;exports.FlagConsequenceSchema=de;exports.FlagMapSchema=ot;exports.FlagSchema=Mt;exports.GameContentsDataSchema=De;exports.GameDataItemTypeEnum=Ka;exports.GameDataSchema=Qa;exports.GameDesignSchema=Yt;exports.GameHappeningsSchema=Jt;exports.GotoOrderSchema=jt;exports.HotspotZoneSchema=ct;exports.IdentSchema=Ie;exports.ImmediateConsequenceSchema=Ke;exports.ImmediateConsequenceSchemaWithDeprecated=Bt;exports.InteractionSchema=Ne;exports.InteractionSchemaWithDeprecatedConsequences=rt;exports.InventoryConsequenceSchema=ee;exports.ItemDataSchema=_e;exports.MoveOrderSchema=qt;exports.NarrativeSchema=I;exports.OrderConsequenceSchema=Ae;exports.PositionSchema=Zt;exports.RemoveActorConsequenceSchema=te;exports.RoomDataSchema=dt;exports.SayOrderSchema=Dt;exports.SequenceConsequenceSchema=Re;exports.SequenceSchema=ve;exports.SequenceSchemaWithDeprecatedConsequences=Ze;exports.SoundEffectConsequenceSchema=ie;exports.SoundValueSchema=Je;exports.SpriteDataSchema=ut;exports.SpriteFrameSchema=me;exports.SpriteParamsSchema=Nt;exports.StageSchema=et;exports.StaticFrameParamsSchema=ye;exports.StoryBoardConsequenceSchema=ue;exports.StoryBoardPageSchema=Wt;exports.StoryBoardSchema=lt;exports.TeleportActorConsequenceSchema=re;exports.ToggleZoneConsequenceSchema=F;exports.VerbSchema=qe;exports.ZoneSchema=Ye;exports.changeHistory=aa;exports.consequenceMap=Pa;exports.consequenceTypes=Va;exports.directions=Ra;exports.immediateConsequenceTypes=$a;exports.orderBaseOmits=Na;exports.orderSchema=ge;exports.orderTypes=qa;exports.parseAndUpgrade=cn;exports.soundInstanceSchema=Te;exports.v2GameDesignSchema=Ht;exports.v3GameDesignSchema=Xt;exports.xPlacement=Lt;exports.yPlacement=Ft;exports.zoneTypes=ja;