point-click-lib 0.0.7 → 0.0.9

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.
@@ -1 +1,20 @@
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("changePlayerCharacter"),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","changePlayerCharacter"]),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,changePlayerCharacter: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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qv=[{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 le;(function(s){s.assertEqual=u=>{};function r(u){}s.assertIs=r;function i(u){throw new Error}s.assertNever=i,s.arrayToEnum=u=>{const c={};for(const h of u)c[h]=h;return c},s.getValidEnumValues=u=>{const c=s.objectKeys(u).filter(g=>typeof u[u[g]]!="number"),h={};for(const g of c)h[g]=u[g];return s.objectValues(h)},s.objectValues=u=>s.objectKeys(u).map(function(c){return u[c]}),s.objectKeys=typeof Object.keys=="function"?u=>Object.keys(u):u=>{const c=[];for(const h in u)Object.prototype.hasOwnProperty.call(u,h)&&c.push(h);return c},s.find=(u,c)=>{for(const h of u)if(c(h))return h},s.isInteger=typeof Number.isInteger=="function"?u=>Number.isInteger(u):u=>typeof u=="number"&&Number.isFinite(u)&&Math.floor(u)===u;function o(u,c=" | "){return u.map(h=>typeof h=="string"?`'${h}'`:h).join(c)}s.joinValues=o,s.jsonStringifyReplacer=(u,c)=>typeof c=="bigint"?c.toString():c})(le||(le={}));var qa;(function(s){s.mergeShapes=(r,i)=>({...r,...i})})(qa||(qa={}));const B=le.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Bt=s=>{switch(typeof s){case"undefined":return B.undefined;case"string":return B.string;case"number":return Number.isNaN(s)?B.nan:B.number;case"boolean":return B.boolean;case"function":return B.function;case"bigint":return B.bigint;case"symbol":return B.symbol;case"object":return Array.isArray(s)?B.array:s===null?B.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?B.promise:typeof Map<"u"&&s instanceof Map?B.map:typeof Set<"u"&&s instanceof Set?B.set:typeof Date<"u"&&s instanceof Date?B.date:B.object;default:return B.unknown}},O=le.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"]),ey=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class et extends Error{get errors(){return this.issues}constructor(r){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const i=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,i):this.__proto__=i,this.name="ZodError",this.issues=r}format(r){const i=r||function(c){return c.message},o={_errors:[]},u=c=>{for(const h of c.issues)if(h.code==="invalid_union")h.unionErrors.map(u);else if(h.code==="invalid_return_type")u(h.returnTypeError);else if(h.code==="invalid_arguments")u(h.argumentsError);else if(h.path.length===0)o._errors.push(i(h));else{let g=o,m=0;for(;m<h.path.length;){const v=h.path[m];m===h.path.length-1?(g[v]=g[v]||{_errors:[]},g[v]._errors.push(i(h))):g[v]=g[v]||{_errors:[]},g=g[v],m++}}};return u(this),o}static assert(r){if(!(r instanceof et))throw new Error(`Not a ZodError: ${r}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(r=i=>i.message){const i={},o=[];for(const u of this.issues)if(u.path.length>0){const c=u.path[0];i[c]=i[c]||[],i[c].push(r(u))}else o.push(r(u));return{formErrors:o,fieldErrors:i}}get formErrors(){return this.flatten()}}et.create=s=>new et(s);const Bn=(s,r)=>{let i;switch(s.code){case O.invalid_type:s.received===B.undefined?i="Required":i=`Expected ${s.expected}, received ${s.received}`;break;case O.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(s.expected,le.jsonStringifyReplacer)}`;break;case O.unrecognized_keys:i=`Unrecognized key(s) in object: ${le.joinValues(s.keys,", ")}`;break;case O.invalid_union:i="Invalid input";break;case O.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${le.joinValues(s.options)}`;break;case O.invalid_enum_value:i=`Invalid enum value. Expected ${le.joinValues(s.options)}, received '${s.received}'`;break;case O.invalid_arguments:i="Invalid function arguments";break;case O.invalid_return_type:i="Invalid function return type";break;case O.invalid_date:i="Invalid date";break;case O.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(i=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(i=`${i} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?i=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?i=`Invalid input: must end with "${s.validation.endsWith}"`:le.assertNever(s.validation):s.validation!=="regex"?i=`Invalid ${s.validation}`:i="Invalid";break;case O.too_small:s.type==="array"?i=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?i=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?i=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?i=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?i=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:i="Invalid input";break;case O.too_big:s.type==="array"?i=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?i=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?i=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?i=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?i=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:i="Invalid input";break;case O.custom:i="Invalid input";break;case O.invalid_intersection_types:i="Intersection results could not be merged";break;case O.not_multiple_of:i=`Number must be a multiple of ${s.multipleOf}`;break;case O.not_finite:i="Number must be finite";break;default:i=r.defaultError,le.assertNever(s)}return{message:i}};let hl=Bn;function ty(s){hl=s}function $i(){return hl}const Vi=s=>{const{data:r,path:i,errorMaps:o,issueData:u}=s,c=[...i,...u.path||[]],h={...u,path:c};if(u.message!==void 0)return{...u,path:c,message:u.message};let g="";const m=o.filter(v=>!!v).slice().reverse();for(const v of m)g=v(h,{data:r,defaultError:g}).message;return{...u,path:c,message:g}},ny=[];function P(s,r){const i=$i(),o=Vi({issueData:r,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,i,i===Bn?void 0:Bn].filter(u=>!!u)});s.common.issues.push(o)}class De{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(r,i){const o=[];for(const u of i){if(u.status==="aborted")return X;u.status==="dirty"&&r.dirty(),o.push(u.value)}return{status:r.value,value:o}}static async mergeObjectAsync(r,i){const o=[];for(const u of i){const c=await u.key,h=await u.value;o.push({key:c,value:h})}return De.mergeObjectSync(r,o)}static mergeObjectSync(r,i){const o={};for(const u of i){const{key:c,value:h}=u;if(c.status==="aborted"||h.status==="aborted")return X;c.status==="dirty"&&r.dirty(),h.status==="dirty"&&r.dirty(),c.value!=="__proto__"&&(typeof h.value<"u"||u.alwaysSet)&&(o[c.value]=h.value)}return{status:r.value,value:o}}}const X=Object.freeze({status:"aborted"}),Pn=s=>({status:"dirty",value:s}),Ge=s=>({status:"valid",value:s}),Wa=s=>s.status==="aborted",Za=s=>s.status==="dirty",hn=s=>s.status==="valid",Er=s=>typeof Promise<"u"&&s instanceof Promise;var G;(function(s){s.errToObj=r=>typeof r=="string"?{message:r}:r||{},s.toString=r=>typeof r=="string"?r:r?.message})(G||(G={}));class It{constructor(r,i,o,u){this._cachedPath=[],this.parent=r,this.data=i,this._path=o,this._key=u}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 Gc=(s,r)=>{if(hn(r))return{success:!0,data:r.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const i=new et(s.common.issues);return this._error=i,this._error}}};function ee(s){if(!s)return{};const{errorMap:r,invalid_type_error:i,required_error:o,description:u}=s;if(r&&(i||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return r?{errorMap:r,description:u}:{errorMap:(h,g)=>{const{message:m}=s;return h.code==="invalid_enum_value"?{message:m??g.defaultError}:typeof g.data>"u"?{message:m??o??g.defaultError}:h.code!=="invalid_type"?{message:g.defaultError}:{message:m??i??g.defaultError}},description:u}}class se{get description(){return this._def.description}_getType(r){return Bt(r.data)}_getOrReturnCtx(r,i){return i||{common:r.parent.common,data:r.data,parsedType:Bt(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}_processInputParams(r){return{status:new De,ctx:{common:r.parent.common,data:r.data,parsedType:Bt(r.data),schemaErrorMap:this._def.errorMap,path:r.path,parent:r.parent}}}_parseSync(r){const i=this._parse(r);if(Er(i))throw new Error("Synchronous parse encountered promise.");return i}_parseAsync(r){const i=this._parse(r);return Promise.resolve(i)}parse(r,i){const o=this.safeParse(r,i);if(o.success)return o.data;throw o.error}safeParse(r,i){const o={common:{issues:[],async:i?.async??!1,contextualErrorMap:i?.errorMap},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Bt(r)},u=this._parseSync({data:r,path:o.path,parent:o});return Gc(o,u)}"~validate"(r){const i={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Bt(r)};if(!this["~standard"].async)try{const o=this._parseSync({data:r,path:[],parent:i});return hn(o)?{value:o.value}:{issues:i.common.issues}}catch(o){o?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),i.common={issues:[],async:!0}}return this._parseAsync({data:r,path:[],parent:i}).then(o=>hn(o)?{value:o.value}:{issues:i.common.issues})}async parseAsync(r,i){const o=await this.safeParseAsync(r,i);if(o.success)return o.data;throw o.error}async safeParseAsync(r,i){const o={common:{issues:[],contextualErrorMap:i?.errorMap,async:!0},path:i?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:r,parsedType:Bt(r)},u=this._parse({data:r,path:o.path,parent:o}),c=await(Er(u)?u:Promise.resolve(u));return Gc(o,c)}refine(r,i){const o=u=>typeof i=="string"||typeof i>"u"?{message:i}:typeof i=="function"?i(u):i;return this._refinement((u,c)=>{const h=r(u),g=()=>c.addIssue({code:O.custom,...o(u)});return typeof Promise<"u"&&h instanceof Promise?h.then(m=>m?!0:(g(),!1)):h?!0:(g(),!1)})}refinement(r,i){return this._refinement((o,u)=>r(o)?!0:(u.addIssue(typeof i=="function"?i(o,u):i),!1))}_refinement(r){return new vt({schema:this,typeName:K.ZodEffects,effect:{type:"refinement",refinement:r}})}superRefine(r){return this._refinement(r)}constructor(r){this.spa=this.safeParseAsync,this._def=r,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:i=>this["~validate"](i)}}optional(){return St.create(this,this._def)}nullable(){return Qt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _t.create(this)}promise(){return qn.create(this,this._def)}or(r){return Pr.create([this,r],this._def)}and(r){return Dr.create(this,r,this._def)}transform(r){return new vt({...ee(this._def),schema:this,typeName:K.ZodEffects,effect:{type:"transform",transform:r}})}default(r){const i=typeof r=="function"?r:()=>r;return new Zr({...ee(this._def),innerType:this,defaultValue:i,typeName:K.ZodDefault})}brand(){return new Va({typeName:K.ZodBranded,type:this,...ee(this._def)})}catch(r){const i=typeof r=="function"?r:()=>r;return new Gr({...ee(this._def),innerType:this,catchValue:i,typeName:K.ZodCatch})}describe(r){const i=this.constructor;return new i({...this._def,description:r})}pipe(r){return Vr.create(this,r)}readonly(){return Ur.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ry=/^c[^\s-]{8,}$/i,iy=/^[0-9a-z]+$/,sy=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ay=/^[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,oy=/^[a-z0-9_-]{21}$/i,uy=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,cy=/^[-+]?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)?)??$/,ly=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Na;const dy=/^(?:(?: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])$/,hy=/^(?:(?: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])$/,py=/^(([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]))$/,gy=/^(([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])$/,my=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_y=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,pl="((\\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])))",vy=new RegExp(`^${pl}$`);function gl(s){let r="[0-5]\\d";s.precision?r=`${r}\\.\\d{${s.precision}}`:s.precision==null&&(r=`${r}(\\.\\d+)?`);const i=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${r})${i}`}function yy(s){return new RegExp(`^${gl(s)}$`)}function ml(s){let r=`${pl}T${gl(s)}`;const i=[];return i.push(s.local?"Z?":"Z"),s.offset&&i.push("([+-]\\d{2}:?\\d{2})"),r=`${r}(${i.join("|")})`,new RegExp(`^${r}$`)}function xy(s,r){return!!((r==="v4"||!r)&&dy.test(s)||(r==="v6"||!r)&&py.test(s))}function wy(s,r){if(!uy.test(s))return!1;try{const[i]=s.split(".");if(!i)return!1;const o=i.replace(/-/g,"+").replace(/_/g,"/").padEnd(i.length+(4-i.length%4)%4,"="),u=JSON.parse(atob(o));return!(typeof u!="object"||u===null||"typ"in u&&u?.typ!=="JWT"||!u.alg||r&&u.alg!==r)}catch{return!1}}function by(s,r){return!!((r==="v4"||!r)&&hy.test(s)||(r==="v6"||!r)&&gy.test(s))}class mt extends se{_parse(r){if(this._def.coerce&&(r.data=String(r.data)),this._getType(r)!==B.string){const c=this._getOrReturnCtx(r);return P(c,{code:O.invalid_type,expected:B.string,received:c.parsedType}),X}const o=new De;let u;for(const c of this._def.checks)if(c.kind==="min")r.data.length<c.value&&(u=this._getOrReturnCtx(r,u),P(u,{code:O.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),o.dirty());else if(c.kind==="max")r.data.length>c.value&&(u=this._getOrReturnCtx(r,u),P(u,{code:O.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),o.dirty());else if(c.kind==="length"){const h=r.data.length>c.value,g=r.data.length<c.value;(h||g)&&(u=this._getOrReturnCtx(r,u),h?P(u,{code:O.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}):g&&P(u,{code:O.too_small,minimum:c.value,type:"string",inclusive:!0,exact:!0,message:c.message}),o.dirty())}else if(c.kind==="email")ly.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"email",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="emoji")Na||(Na=new RegExp(fy,"u")),Na.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"emoji",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="uuid")ay.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"uuid",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="nanoid")oy.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"nanoid",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="cuid")ry.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"cuid",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="cuid2")iy.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"cuid2",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="ulid")sy.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"ulid",code:O.invalid_string,message:c.message}),o.dirty());else if(c.kind==="url")try{new URL(r.data)}catch{u=this._getOrReturnCtx(r,u),P(u,{validation:"url",code:O.invalid_string,message:c.message}),o.dirty()}else c.kind==="regex"?(c.regex.lastIndex=0,c.regex.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"regex",code:O.invalid_string,message:c.message}),o.dirty())):c.kind==="trim"?r.data=r.data.trim():c.kind==="includes"?r.data.includes(c.value,c.position)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:{includes:c.value,position:c.position},message:c.message}),o.dirty()):c.kind==="toLowerCase"?r.data=r.data.toLowerCase():c.kind==="toUpperCase"?r.data=r.data.toUpperCase():c.kind==="startsWith"?r.data.startsWith(c.value)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:{startsWith:c.value},message:c.message}),o.dirty()):c.kind==="endsWith"?r.data.endsWith(c.value)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:{endsWith:c.value},message:c.message}),o.dirty()):c.kind==="datetime"?ml(c).test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:"datetime",message:c.message}),o.dirty()):c.kind==="date"?vy.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:"date",message:c.message}),o.dirty()):c.kind==="time"?yy(c).test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{code:O.invalid_string,validation:"time",message:c.message}),o.dirty()):c.kind==="duration"?cy.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"duration",code:O.invalid_string,message:c.message}),o.dirty()):c.kind==="ip"?xy(r.data,c.version)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"ip",code:O.invalid_string,message:c.message}),o.dirty()):c.kind==="jwt"?wy(r.data,c.alg)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"jwt",code:O.invalid_string,message:c.message}),o.dirty()):c.kind==="cidr"?by(r.data,c.version)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"cidr",code:O.invalid_string,message:c.message}),o.dirty()):c.kind==="base64"?my.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"base64",code:O.invalid_string,message:c.message}),o.dirty()):c.kind==="base64url"?_y.test(r.data)||(u=this._getOrReturnCtx(r,u),P(u,{validation:"base64url",code:O.invalid_string,message:c.message}),o.dirty()):le.assertNever(c);return{status:o.value,value:r.data}}_regex(r,i,o){return this.refinement(u=>r.test(u),{validation:i,code:O.invalid_string,...G.errToObj(o)})}_addCheck(r){return new mt({...this._def,checks:[...this._def.checks,r]})}email(r){return this._addCheck({kind:"email",...G.errToObj(r)})}url(r){return this._addCheck({kind:"url",...G.errToObj(r)})}emoji(r){return this._addCheck({kind:"emoji",...G.errToObj(r)})}uuid(r){return this._addCheck({kind:"uuid",...G.errToObj(r)})}nanoid(r){return this._addCheck({kind:"nanoid",...G.errToObj(r)})}cuid(r){return this._addCheck({kind:"cuid",...G.errToObj(r)})}cuid2(r){return this._addCheck({kind:"cuid2",...G.errToObj(r)})}ulid(r){return this._addCheck({kind:"ulid",...G.errToObj(r)})}base64(r){return this._addCheck({kind:"base64",...G.errToObj(r)})}base64url(r){return this._addCheck({kind:"base64url",...G.errToObj(r)})}jwt(r){return this._addCheck({kind:"jwt",...G.errToObj(r)})}ip(r){return this._addCheck({kind:"ip",...G.errToObj(r)})}cidr(r){return this._addCheck({kind:"cidr",...G.errToObj(r)})}datetime(r){return typeof r=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:r}):this._addCheck({kind:"datetime",precision:typeof r?.precision>"u"?null:r?.precision,offset:r?.offset??!1,local:r?.local??!1,...G.errToObj(r?.message)})}date(r){return this._addCheck({kind:"date",message:r})}time(r){return typeof r=="string"?this._addCheck({kind:"time",precision:null,message:r}):this._addCheck({kind:"time",precision:typeof r?.precision>"u"?null:r?.precision,...G.errToObj(r?.message)})}duration(r){return this._addCheck({kind:"duration",...G.errToObj(r)})}regex(r,i){return this._addCheck({kind:"regex",regex:r,...G.errToObj(i)})}includes(r,i){return this._addCheck({kind:"includes",value:r,position:i?.position,...G.errToObj(i?.message)})}startsWith(r,i){return this._addCheck({kind:"startsWith",value:r,...G.errToObj(i)})}endsWith(r,i){return this._addCheck({kind:"endsWith",value:r,...G.errToObj(i)})}min(r,i){return this._addCheck({kind:"min",value:r,...G.errToObj(i)})}max(r,i){return this._addCheck({kind:"max",value:r,...G.errToObj(i)})}length(r,i){return this._addCheck({kind:"length",value:r,...G.errToObj(i)})}nonempty(r){return this.min(1,G.errToObj(r))}trim(){return new mt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(r=>r.kind==="datetime")}get isDate(){return!!this._def.checks.find(r=>r.kind==="date")}get isTime(){return!!this._def.checks.find(r=>r.kind==="time")}get isDuration(){return!!this._def.checks.find(r=>r.kind==="duration")}get isEmail(){return!!this._def.checks.find(r=>r.kind==="email")}get isURL(){return!!this._def.checks.find(r=>r.kind==="url")}get isEmoji(){return!!this._def.checks.find(r=>r.kind==="emoji")}get isUUID(){return!!this._def.checks.find(r=>r.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(r=>r.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(r=>r.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(r=>r.kind==="cuid2")}get isULID(){return!!this._def.checks.find(r=>r.kind==="ulid")}get isIP(){return!!this._def.checks.find(r=>r.kind==="ip")}get isCIDR(){return!!this._def.checks.find(r=>r.kind==="cidr")}get isBase64(){return!!this._def.checks.find(r=>r.kind==="base64")}get isBase64url(){return!!this._def.checks.find(r=>r.kind==="base64url")}get minLength(){let r=null;for(const i of this._def.checks)i.kind==="min"&&(r===null||i.value>r)&&(r=i.value);return r}get maxLength(){let r=null;for(const i of this._def.checks)i.kind==="max"&&(r===null||i.value<r)&&(r=i.value);return r}}mt.create=s=>new mt({checks:[],typeName:K.ZodString,coerce:s?.coerce??!1,...ee(s)});function Sy(s,r){const i=(s.toString().split(".")[1]||"").length,o=(r.toString().split(".")[1]||"").length,u=i>o?i:o,c=Number.parseInt(s.toFixed(u).replace(".","")),h=Number.parseInt(r.toFixed(u).replace(".",""));return c%h/10**u}class Kt extends se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(r){if(this._def.coerce&&(r.data=Number(r.data)),this._getType(r)!==B.number){const c=this._getOrReturnCtx(r);return P(c,{code:O.invalid_type,expected:B.number,received:c.parsedType}),X}let o;const u=new De;for(const c of this._def.checks)c.kind==="int"?le.isInteger(r.data)||(o=this._getOrReturnCtx(r,o),P(o,{code:O.invalid_type,expected:"integer",received:"float",message:c.message}),u.dirty()):c.kind==="min"?(c.inclusive?r.data<c.value:r.data<=c.value)&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.too_small,minimum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),u.dirty()):c.kind==="max"?(c.inclusive?r.data>c.value:r.data>=c.value)&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),u.dirty()):c.kind==="multipleOf"?Sy(r.data,c.value)!==0&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.not_multiple_of,multipleOf:c.value,message:c.message}),u.dirty()):c.kind==="finite"?Number.isFinite(r.data)||(o=this._getOrReturnCtx(r,o),P(o,{code:O.not_finite,message:c.message}),u.dirty()):le.assertNever(c);return{status:u.value,value:r.data}}gte(r,i){return this.setLimit("min",r,!0,G.toString(i))}gt(r,i){return this.setLimit("min",r,!1,G.toString(i))}lte(r,i){return this.setLimit("max",r,!0,G.toString(i))}lt(r,i){return this.setLimit("max",r,!1,G.toString(i))}setLimit(r,i,o,u){return new Kt({...this._def,checks:[...this._def.checks,{kind:r,value:i,inclusive:o,message:G.toString(u)}]})}_addCheck(r){return new Kt({...this._def,checks:[...this._def.checks,r]})}int(r){return this._addCheck({kind:"int",message:G.toString(r)})}positive(r){return this._addCheck({kind:"min",value:0,inclusive:!1,message:G.toString(r)})}negative(r){return this._addCheck({kind:"max",value:0,inclusive:!1,message:G.toString(r)})}nonpositive(r){return this._addCheck({kind:"max",value:0,inclusive:!0,message:G.toString(r)})}nonnegative(r){return this._addCheck({kind:"min",value:0,inclusive:!0,message:G.toString(r)})}multipleOf(r,i){return this._addCheck({kind:"multipleOf",value:r,message:G.toString(i)})}finite(r){return this._addCheck({kind:"finite",message:G.toString(r)})}safe(r){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:G.toString(r)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:G.toString(r)})}get minValue(){let r=null;for(const i of this._def.checks)i.kind==="min"&&(r===null||i.value>r)&&(r=i.value);return r}get maxValue(){let r=null;for(const i of this._def.checks)i.kind==="max"&&(r===null||i.value<r)&&(r=i.value);return r}get isInt(){return!!this._def.checks.find(r=>r.kind==="int"||r.kind==="multipleOf"&&le.isInteger(r.value))}get isFinite(){let r=null,i=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(i===null||o.value>i)&&(i=o.value):o.kind==="max"&&(r===null||o.value<r)&&(r=o.value)}return Number.isFinite(i)&&Number.isFinite(r)}}Kt.create=s=>new Kt({checks:[],typeName:K.ZodNumber,coerce:s?.coerce||!1,...ee(s)});class Jt extends se{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(r){if(this._def.coerce)try{r.data=BigInt(r.data)}catch{return this._getInvalidInput(r)}if(this._getType(r)!==B.bigint)return this._getInvalidInput(r);let o;const u=new De;for(const c of this._def.checks)c.kind==="min"?(c.inclusive?r.data<c.value:r.data<=c.value)&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.too_small,type:"bigint",minimum:c.value,inclusive:c.inclusive,message:c.message}),u.dirty()):c.kind==="max"?(c.inclusive?r.data>c.value:r.data>=c.value)&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),u.dirty()):c.kind==="multipleOf"?r.data%c.value!==BigInt(0)&&(o=this._getOrReturnCtx(r,o),P(o,{code:O.not_multiple_of,multipleOf:c.value,message:c.message}),u.dirty()):le.assertNever(c);return{status:u.value,value:r.data}}_getInvalidInput(r){const i=this._getOrReturnCtx(r);return P(i,{code:O.invalid_type,expected:B.bigint,received:i.parsedType}),X}gte(r,i){return this.setLimit("min",r,!0,G.toString(i))}gt(r,i){return this.setLimit("min",r,!1,G.toString(i))}lte(r,i){return this.setLimit("max",r,!0,G.toString(i))}lt(r,i){return this.setLimit("max",r,!1,G.toString(i))}setLimit(r,i,o,u){return new Jt({...this._def,checks:[...this._def.checks,{kind:r,value:i,inclusive:o,message:G.toString(u)}]})}_addCheck(r){return new Jt({...this._def,checks:[...this._def.checks,r]})}positive(r){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:G.toString(r)})}negative(r){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:G.toString(r)})}nonpositive(r){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:G.toString(r)})}nonnegative(r){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:G.toString(r)})}multipleOf(r,i){return this._addCheck({kind:"multipleOf",value:r,message:G.toString(i)})}get minValue(){let r=null;for(const i of this._def.checks)i.kind==="min"&&(r===null||i.value>r)&&(r=i.value);return r}get maxValue(){let r=null;for(const i of this._def.checks)i.kind==="max"&&(r===null||i.value<r)&&(r=i.value);return r}}Jt.create=s=>new Jt({checks:[],typeName:K.ZodBigInt,coerce:s?.coerce??!1,...ee(s)});class Mr extends se{_parse(r){if(this._def.coerce&&(r.data=!!r.data),this._getType(r)!==B.boolean){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.boolean,received:o.parsedType}),X}return Ge(r.data)}}Mr.create=s=>new Mr({typeName:K.ZodBoolean,coerce:s?.coerce||!1,...ee(s)});class pn extends se{_parse(r){if(this._def.coerce&&(r.data=new Date(r.data)),this._getType(r)!==B.date){const c=this._getOrReturnCtx(r);return P(c,{code:O.invalid_type,expected:B.date,received:c.parsedType}),X}if(Number.isNaN(r.data.getTime())){const c=this._getOrReturnCtx(r);return P(c,{code:O.invalid_date}),X}const o=new De;let u;for(const c of this._def.checks)c.kind==="min"?r.data.getTime()<c.value&&(u=this._getOrReturnCtx(r,u),P(u,{code:O.too_small,message:c.message,inclusive:!0,exact:!1,minimum:c.value,type:"date"}),o.dirty()):c.kind==="max"?r.data.getTime()>c.value&&(u=this._getOrReturnCtx(r,u),P(u,{code:O.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),o.dirty()):le.assertNever(c);return{status:o.value,value:new Date(r.data.getTime())}}_addCheck(r){return new pn({...this._def,checks:[...this._def.checks,r]})}min(r,i){return this._addCheck({kind:"min",value:r.getTime(),message:G.toString(i)})}max(r,i){return this._addCheck({kind:"max",value:r.getTime(),message:G.toString(i)})}get minDate(){let r=null;for(const i of this._def.checks)i.kind==="min"&&(r===null||i.value>r)&&(r=i.value);return r!=null?new Date(r):null}get maxDate(){let r=null;for(const i of this._def.checks)i.kind==="max"&&(r===null||i.value<r)&&(r=i.value);return r!=null?new Date(r):null}}pn.create=s=>new pn({checks:[],coerce:s?.coerce||!1,typeName:K.ZodDate,...ee(s)});class Hi extends se{_parse(r){if(this._getType(r)!==B.symbol){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.symbol,received:o.parsedType}),X}return Ge(r.data)}}Hi.create=s=>new Hi({typeName:K.ZodSymbol,...ee(s)});class Lr extends se{_parse(r){if(this._getType(r)!==B.undefined){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.undefined,received:o.parsedType}),X}return Ge(r.data)}}Lr.create=s=>new Lr({typeName:K.ZodUndefined,...ee(s)});class Nr extends se{_parse(r){if(this._getType(r)!==B.null){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.null,received:o.parsedType}),X}return Ge(r.data)}}Nr.create=s=>new Nr({typeName:K.ZodNull,...ee(s)});class Fn extends se{constructor(){super(...arguments),this._any=!0}_parse(r){return Ge(r.data)}}Fn.create=s=>new Fn({typeName:K.ZodAny,...ee(s)});class dn extends se{constructor(){super(...arguments),this._unknown=!0}_parse(r){return Ge(r.data)}}dn.create=s=>new dn({typeName:K.ZodUnknown,...ee(s)});class Ft extends se{_parse(r){const i=this._getOrReturnCtx(r);return P(i,{code:O.invalid_type,expected:B.never,received:i.parsedType}),X}}Ft.create=s=>new Ft({typeName:K.ZodNever,...ee(s)});class zi extends se{_parse(r){if(this._getType(r)!==B.undefined){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.void,received:o.parsedType}),X}return Ge(r.data)}}zi.create=s=>new zi({typeName:K.ZodVoid,...ee(s)});class _t extends se{_parse(r){const{ctx:i,status:o}=this._processInputParams(r),u=this._def;if(i.parsedType!==B.array)return P(i,{code:O.invalid_type,expected:B.array,received:i.parsedType}),X;if(u.exactLength!==null){const h=i.data.length>u.exactLength.value,g=i.data.length<u.exactLength.value;(h||g)&&(P(i,{code:h?O.too_big:O.too_small,minimum:g?u.exactLength.value:void 0,maximum:h?u.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:u.exactLength.message}),o.dirty())}if(u.minLength!==null&&i.data.length<u.minLength.value&&(P(i,{code:O.too_small,minimum:u.minLength.value,type:"array",inclusive:!0,exact:!1,message:u.minLength.message}),o.dirty()),u.maxLength!==null&&i.data.length>u.maxLength.value&&(P(i,{code:O.too_big,maximum:u.maxLength.value,type:"array",inclusive:!0,exact:!1,message:u.maxLength.message}),o.dirty()),i.common.async)return Promise.all([...i.data].map((h,g)=>u.type._parseAsync(new It(i,h,i.path,g)))).then(h=>De.mergeArray(o,h));const c=[...i.data].map((h,g)=>u.type._parseSync(new It(i,h,i.path,g)));return De.mergeArray(o,c)}get element(){return this._def.type}min(r,i){return new _t({...this._def,minLength:{value:r,message:G.toString(i)}})}max(r,i){return new _t({...this._def,maxLength:{value:r,message:G.toString(i)}})}length(r,i){return new _t({...this._def,exactLength:{value:r,message:G.toString(i)}})}nonempty(r){return this.min(1,r)}}_t.create=(s,r)=>new _t({type:s,minLength:null,maxLength:null,exactLength:null,typeName:K.ZodArray,...ee(r)});function Nn(s){if(s instanceof be){const r={};for(const i in s.shape){const o=s.shape[i];r[i]=St.create(Nn(o))}return new be({...s._def,shape:()=>r})}else return s instanceof _t?new _t({...s._def,type:Nn(s.element)}):s instanceof St?St.create(Nn(s.unwrap())):s instanceof Qt?Qt.create(Nn(s.unwrap())):s instanceof Ct?Ct.create(s.items.map(r=>Nn(r))):s}class be extends se{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const r=this._def.shape(),i=le.objectKeys(r);return this._cached={shape:r,keys:i},this._cached}_parse(r){if(this._getType(r)!==B.object){const v=this._getOrReturnCtx(r);return P(v,{code:O.invalid_type,expected:B.object,received:v.parsedType}),X}const{status:o,ctx:u}=this._processInputParams(r),{shape:c,keys:h}=this._getCached(),g=[];if(!(this._def.catchall instanceof Ft&&this._def.unknownKeys==="strip"))for(const v in u.data)h.includes(v)||g.push(v);const m=[];for(const v of h){const w=c[v],R=u.data[v];m.push({key:{status:"valid",value:v},value:w._parse(new It(u,R,u.path,v)),alwaysSet:v in u.data})}if(this._def.catchall instanceof Ft){const v=this._def.unknownKeys;if(v==="passthrough")for(const w of g)m.push({key:{status:"valid",value:w},value:{status:"valid",value:u.data[w]}});else if(v==="strict")g.length>0&&(P(u,{code:O.unrecognized_keys,keys:g}),o.dirty());else if(v!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const v=this._def.catchall;for(const w of g){const R=u.data[w];m.push({key:{status:"valid",value:w},value:v._parse(new It(u,R,u.path,w)),alwaysSet:w in u.data})}}return u.common.async?Promise.resolve().then(async()=>{const v=[];for(const w of m){const R=await w.key,F=await w.value;v.push({key:R,value:F,alwaysSet:w.alwaysSet})}return v}).then(v=>De.mergeObjectSync(o,v)):De.mergeObjectSync(o,m)}get shape(){return this._def.shape()}strict(r){return G.errToObj,new be({...this._def,unknownKeys:"strict",...r!==void 0?{errorMap:(i,o)=>{const u=this._def.errorMap?.(i,o).message??o.defaultError;return i.code==="unrecognized_keys"?{message:G.errToObj(r).message??u}:{message:u}}}:{}})}strip(){return new be({...this._def,unknownKeys:"strip"})}passthrough(){return new be({...this._def,unknownKeys:"passthrough"})}extend(r){return new be({...this._def,shape:()=>({...this._def.shape(),...r})})}merge(r){return new be({unknownKeys:r._def.unknownKeys,catchall:r._def.catchall,shape:()=>({...this._def.shape(),...r._def.shape()}),typeName:K.ZodObject})}setKey(r,i){return this.augment({[r]:i})}catchall(r){return new be({...this._def,catchall:r})}pick(r){const i={};for(const o of le.objectKeys(r))r[o]&&this.shape[o]&&(i[o]=this.shape[o]);return new be({...this._def,shape:()=>i})}omit(r){const i={};for(const o of le.objectKeys(this.shape))r[o]||(i[o]=this.shape[o]);return new be({...this._def,shape:()=>i})}deepPartial(){return Nn(this)}partial(r){const i={};for(const o of le.objectKeys(this.shape)){const u=this.shape[o];r&&!r[o]?i[o]=u:i[o]=u.optional()}return new be({...this._def,shape:()=>i})}required(r){const i={};for(const o of le.objectKeys(this.shape))if(r&&!r[o])i[o]=this.shape[o];else{let c=this.shape[o];for(;c instanceof St;)c=c._def.innerType;i[o]=c}return new be({...this._def,shape:()=>i})}keyof(){return _l(le.objectKeys(this.shape))}}be.create=(s,r)=>new be({shape:()=>s,unknownKeys:"strip",catchall:Ft.create(),typeName:K.ZodObject,...ee(r)});be.strictCreate=(s,r)=>new be({shape:()=>s,unknownKeys:"strict",catchall:Ft.create(),typeName:K.ZodObject,...ee(r)});be.lazycreate=(s,r)=>new be({shape:s,unknownKeys:"strip",catchall:Ft.create(),typeName:K.ZodObject,...ee(r)});class Pr extends se{_parse(r){const{ctx:i}=this._processInputParams(r),o=this._def.options;function u(c){for(const g of c)if(g.result.status==="valid")return g.result;for(const g of c)if(g.result.status==="dirty")return i.common.issues.push(...g.ctx.common.issues),g.result;const h=c.map(g=>new et(g.ctx.common.issues));return P(i,{code:O.invalid_union,unionErrors:h}),X}if(i.common.async)return Promise.all(o.map(async c=>{const h={...i,common:{...i.common,issues:[]},parent:null};return{result:await c._parseAsync({data:i.data,path:i.path,parent:h}),ctx:h}})).then(u);{let c;const h=[];for(const m of o){const v={...i,common:{...i.common,issues:[]},parent:null},w=m._parseSync({data:i.data,path:i.path,parent:v});if(w.status==="valid")return w;w.status==="dirty"&&!c&&(c={result:w,ctx:v}),v.common.issues.length&&h.push(v.common.issues)}if(c)return i.common.issues.push(...c.ctx.common.issues),c.result;const g=h.map(m=>new et(m));return P(i,{code:O.invalid_union,unionErrors:g}),X}}get options(){return this._def.options}}Pr.create=(s,r)=>new Pr({options:s,typeName:K.ZodUnion,...ee(r)});const Dt=s=>s instanceof Fr?Dt(s.schema):s instanceof vt?Dt(s.innerType()):s instanceof qr?[s.value]:s instanceof jt?s.options:s instanceof Wr?le.objectValues(s.enum):s instanceof Zr?Dt(s._def.innerType):s instanceof Lr?[void 0]:s instanceof Nr?[null]:s instanceof St?[void 0,...Dt(s.unwrap())]:s instanceof Qt?[null,...Dt(s.unwrap())]:s instanceof Va||s instanceof Ur?Dt(s.unwrap()):s instanceof Gr?Dt(s._def.innerType):[];class Qi extends se{_parse(r){const{ctx:i}=this._processInputParams(r);if(i.parsedType!==B.object)return P(i,{code:O.invalid_type,expected:B.object,received:i.parsedType}),X;const o=this.discriminator,u=i.data[o],c=this.optionsMap.get(u);return c?i.common.async?c._parseAsync({data:i.data,path:i.path,parent:i}):c._parseSync({data:i.data,path:i.path,parent:i}):(P(i,{code:O.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),X)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(r,i,o){const u=new Map;for(const c of i){const h=Dt(c.shape[r]);if(!h.length)throw new Error(`A discriminator value for key \`${r}\` could not be extracted from all schema options`);for(const g of h){if(u.has(g))throw new Error(`Discriminator property ${String(r)} has duplicate value ${String(g)}`);u.set(g,c)}}return new Qi({typeName:K.ZodDiscriminatedUnion,discriminator:r,options:i,optionsMap:u,...ee(o)})}}function Ga(s,r){const i=Bt(s),o=Bt(r);if(s===r)return{valid:!0,data:s};if(i===B.object&&o===B.object){const u=le.objectKeys(r),c=le.objectKeys(s).filter(g=>u.indexOf(g)!==-1),h={...s,...r};for(const g of c){const m=Ga(s[g],r[g]);if(!m.valid)return{valid:!1};h[g]=m.data}return{valid:!0,data:h}}else if(i===B.array&&o===B.array){if(s.length!==r.length)return{valid:!1};const u=[];for(let c=0;c<s.length;c++){const h=s[c],g=r[c],m=Ga(h,g);if(!m.valid)return{valid:!1};u.push(m.data)}return{valid:!0,data:u}}else return i===B.date&&o===B.date&&+s==+r?{valid:!0,data:s}:{valid:!1}}class Dr extends se{_parse(r){const{status:i,ctx:o}=this._processInputParams(r),u=(c,h)=>{if(Wa(c)||Wa(h))return X;const g=Ga(c.value,h.value);return g.valid?((Za(c)||Za(h))&&i.dirty(),{status:i.value,value:g.data}):(P(o,{code:O.invalid_intersection_types}),X)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([c,h])=>u(c,h)):u(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}Dr.create=(s,r,i)=>new Dr({left:s,right:r,typeName:K.ZodIntersection,...ee(i)});class Ct extends se{_parse(r){const{status:i,ctx:o}=this._processInputParams(r);if(o.parsedType!==B.array)return P(o,{code:O.invalid_type,expected:B.array,received:o.parsedType}),X;if(o.data.length<this._def.items.length)return P(o,{code:O.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),X;!this._def.rest&&o.data.length>this._def.items.length&&(P(o,{code:O.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),i.dirty());const c=[...o.data].map((h,g)=>{const m=this._def.items[g]||this._def.rest;return m?m._parse(new It(o,h,o.path,g)):null}).filter(h=>!!h);return o.common.async?Promise.all(c).then(h=>De.mergeArray(i,h)):De.mergeArray(i,c)}get items(){return this._def.items}rest(r){return new Ct({...this._def,rest:r})}}Ct.create=(s,r)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ct({items:s,typeName:K.ZodTuple,rest:null,...ee(r)})};class Br extends se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:i,ctx:o}=this._processInputParams(r);if(o.parsedType!==B.object)return P(o,{code:O.invalid_type,expected:B.object,received:o.parsedType}),X;const u=[],c=this._def.keyType,h=this._def.valueType;for(const g in o.data)u.push({key:c._parse(new It(o,g,o.path,g)),value:h._parse(new It(o,o.data[g],o.path,g)),alwaysSet:g in o.data});return o.common.async?De.mergeObjectAsync(i,u):De.mergeObjectSync(i,u)}get element(){return this._def.valueType}static create(r,i,o){return i instanceof se?new Br({keyType:r,valueType:i,typeName:K.ZodRecord,...ee(o)}):new Br({keyType:mt.create(),valueType:r,typeName:K.ZodRecord,...ee(i)})}}class Yi extends se{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(r){const{status:i,ctx:o}=this._processInputParams(r);if(o.parsedType!==B.map)return P(o,{code:O.invalid_type,expected:B.map,received:o.parsedType}),X;const u=this._def.keyType,c=this._def.valueType,h=[...o.data.entries()].map(([g,m],v)=>({key:u._parse(new It(o,g,o.path,[v,"key"])),value:c._parse(new It(o,m,o.path,[v,"value"]))}));if(o.common.async){const g=new Map;return Promise.resolve().then(async()=>{for(const m of h){const v=await m.key,w=await m.value;if(v.status==="aborted"||w.status==="aborted")return X;(v.status==="dirty"||w.status==="dirty")&&i.dirty(),g.set(v.value,w.value)}return{status:i.value,value:g}})}else{const g=new Map;for(const m of h){const v=m.key,w=m.value;if(v.status==="aborted"||w.status==="aborted")return X;(v.status==="dirty"||w.status==="dirty")&&i.dirty(),g.set(v.value,w.value)}return{status:i.value,value:g}}}}Yi.create=(s,r,i)=>new Yi({valueType:r,keyType:s,typeName:K.ZodMap,...ee(i)});class gn extends se{_parse(r){const{status:i,ctx:o}=this._processInputParams(r);if(o.parsedType!==B.set)return P(o,{code:O.invalid_type,expected:B.set,received:o.parsedType}),X;const u=this._def;u.minSize!==null&&o.data.size<u.minSize.value&&(P(o,{code:O.too_small,minimum:u.minSize.value,type:"set",inclusive:!0,exact:!1,message:u.minSize.message}),i.dirty()),u.maxSize!==null&&o.data.size>u.maxSize.value&&(P(o,{code:O.too_big,maximum:u.maxSize.value,type:"set",inclusive:!0,exact:!1,message:u.maxSize.message}),i.dirty());const c=this._def.valueType;function h(m){const v=new Set;for(const w of m){if(w.status==="aborted")return X;w.status==="dirty"&&i.dirty(),v.add(w.value)}return{status:i.value,value:v}}const g=[...o.data.values()].map((m,v)=>c._parse(new It(o,m,o.path,v)));return o.common.async?Promise.all(g).then(m=>h(m)):h(g)}min(r,i){return new gn({...this._def,minSize:{value:r,message:G.toString(i)}})}max(r,i){return new gn({...this._def,maxSize:{value:r,message:G.toString(i)}})}size(r,i){return this.min(r,i).max(r,i)}nonempty(r){return this.min(1,r)}}gn.create=(s,r)=>new gn({valueType:s,minSize:null,maxSize:null,typeName:K.ZodSet,...ee(r)});class Dn extends se{constructor(){super(...arguments),this.validate=this.implement}_parse(r){const{ctx:i}=this._processInputParams(r);if(i.parsedType!==B.function)return P(i,{code:O.invalid_type,expected:B.function,received:i.parsedType}),X;function o(g,m){return Vi({data:g,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,$i(),Bn].filter(v=>!!v),issueData:{code:O.invalid_arguments,argumentsError:m}})}function u(g,m){return Vi({data:g,path:i.path,errorMaps:[i.common.contextualErrorMap,i.schemaErrorMap,$i(),Bn].filter(v=>!!v),issueData:{code:O.invalid_return_type,returnTypeError:m}})}const c={errorMap:i.common.contextualErrorMap},h=i.data;if(this._def.returns instanceof qn){const g=this;return Ge(async function(...m){const v=new et([]),w=await g._def.args.parseAsync(m,c).catch(W=>{throw v.addIssue(o(m,W)),v}),R=await Reflect.apply(h,this,w);return await g._def.returns._def.type.parseAsync(R,c).catch(W=>{throw v.addIssue(u(R,W)),v})})}else{const g=this;return Ge(function(...m){const v=g._def.args.safeParse(m,c);if(!v.success)throw new et([o(m,v.error)]);const w=Reflect.apply(h,this,v.data),R=g._def.returns.safeParse(w,c);if(!R.success)throw new et([u(w,R.error)]);return R.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...r){return new Dn({...this._def,args:Ct.create(r).rest(dn.create())})}returns(r){return new Dn({...this._def,returns:r})}implement(r){return this.parse(r)}strictImplement(r){return this.parse(r)}static create(r,i,o){return new Dn({args:r||Ct.create([]).rest(dn.create()),returns:i||dn.create(),typeName:K.ZodFunction,...ee(o)})}}class Fr extends se{get schema(){return this._def.getter()}_parse(r){const{ctx:i}=this._processInputParams(r);return this._def.getter()._parse({data:i.data,path:i.path,parent:i})}}Fr.create=(s,r)=>new Fr({getter:s,typeName:K.ZodLazy,...ee(r)});class qr extends se{_parse(r){if(r.data!==this._def.value){const i=this._getOrReturnCtx(r);return P(i,{received:i.data,code:O.invalid_literal,expected:this._def.value}),X}return{status:"valid",value:r.data}}get value(){return this._def.value}}qr.create=(s,r)=>new qr({value:s,typeName:K.ZodLiteral,...ee(r)});function _l(s,r){return new jt({values:s,typeName:K.ZodEnum,...ee(r)})}class jt extends se{_parse(r){if(typeof r.data!="string"){const i=this._getOrReturnCtx(r),o=this._def.values;return P(i,{expected:le.joinValues(o),received:i.parsedType,code:O.invalid_type}),X}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(r.data)){const i=this._getOrReturnCtx(r),o=this._def.values;return P(i,{received:i.data,code:O.invalid_enum_value,options:o}),X}return Ge(r.data)}get options(){return this._def.values}get enum(){const r={};for(const i of this._def.values)r[i]=i;return r}get Values(){const r={};for(const i of this._def.values)r[i]=i;return r}get Enum(){const r={};for(const i of this._def.values)r[i]=i;return r}extract(r,i=this._def){return jt.create(r,{...this._def,...i})}exclude(r,i=this._def){return jt.create(this.options.filter(o=>!r.includes(o)),{...this._def,...i})}}jt.create=_l;class Wr extends se{_parse(r){const i=le.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(r);if(o.parsedType!==B.string&&o.parsedType!==B.number){const u=le.objectValues(i);return P(o,{expected:le.joinValues(u),received:o.parsedType,code:O.invalid_type}),X}if(this._cache||(this._cache=new Set(le.getValidEnumValues(this._def.values))),!this._cache.has(r.data)){const u=le.objectValues(i);return P(o,{received:o.data,code:O.invalid_enum_value,options:u}),X}return Ge(r.data)}get enum(){return this._def.values}}Wr.create=(s,r)=>new Wr({values:s,typeName:K.ZodNativeEnum,...ee(r)});class qn extends se{unwrap(){return this._def.type}_parse(r){const{ctx:i}=this._processInputParams(r);if(i.parsedType!==B.promise&&i.common.async===!1)return P(i,{code:O.invalid_type,expected:B.promise,received:i.parsedType}),X;const o=i.parsedType===B.promise?i.data:Promise.resolve(i.data);return Ge(o.then(u=>this._def.type.parseAsync(u,{path:i.path,errorMap:i.common.contextualErrorMap})))}}qn.create=(s,r)=>new qn({type:s,typeName:K.ZodPromise,...ee(r)});class vt extends se{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===K.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(r){const{status:i,ctx:o}=this._processInputParams(r),u=this._def.effect||null,c={addIssue:h=>{P(o,h),h.fatal?i.abort():i.dirty()},get path(){return o.path}};if(c.addIssue=c.addIssue.bind(c),u.type==="preprocess"){const h=u.transform(o.data,c);if(o.common.async)return Promise.resolve(h).then(async g=>{if(i.value==="aborted")return X;const m=await this._def.schema._parseAsync({data:g,path:o.path,parent:o});return m.status==="aborted"?X:m.status==="dirty"||i.value==="dirty"?Pn(m.value):m});{if(i.value==="aborted")return X;const g=this._def.schema._parseSync({data:h,path:o.path,parent:o});return g.status==="aborted"?X:g.status==="dirty"||i.value==="dirty"?Pn(g.value):g}}if(u.type==="refinement"){const h=g=>{const m=u.refinement(g,c);if(o.common.async)return Promise.resolve(m);if(m instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return g};if(o.common.async===!1){const g=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return g.status==="aborted"?X:(g.status==="dirty"&&i.dirty(),h(g.value),{status:i.value,value:g.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(g=>g.status==="aborted"?X:(g.status==="dirty"&&i.dirty(),h(g.value).then(()=>({status:i.value,value:g.value}))))}if(u.type==="transform")if(o.common.async===!1){const h=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!hn(h))return X;const g=u.transform(h.value,c);if(g instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:i.value,value:g}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(h=>hn(h)?Promise.resolve(u.transform(h.value,c)).then(g=>({status:i.value,value:g})):X);le.assertNever(u)}}vt.create=(s,r,i)=>new vt({schema:s,typeName:K.ZodEffects,effect:r,...ee(i)});vt.createWithPreprocess=(s,r,i)=>new vt({schema:r,effect:{type:"preprocess",transform:s},typeName:K.ZodEffects,...ee(i)});class St extends se{_parse(r){return this._getType(r)===B.undefined?Ge(void 0):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}}St.create=(s,r)=>new St({innerType:s,typeName:K.ZodOptional,...ee(r)});class Qt extends se{_parse(r){return this._getType(r)===B.null?Ge(null):this._def.innerType._parse(r)}unwrap(){return this._def.innerType}}Qt.create=(s,r)=>new Qt({innerType:s,typeName:K.ZodNullable,...ee(r)});class Zr extends se{_parse(r){const{ctx:i}=this._processInputParams(r);let o=i.data;return i.parsedType===B.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:i.path,parent:i})}removeDefault(){return this._def.innerType}}Zr.create=(s,r)=>new Zr({innerType:s,typeName:K.ZodDefault,defaultValue:typeof r.default=="function"?r.default:()=>r.default,...ee(r)});class Gr extends se{_parse(r){const{ctx:i}=this._processInputParams(r),o={...i,common:{...i.common,issues:[]}},u=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Er(u)?u.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new et(o.common.issues)},input:o.data})})):{status:"valid",value:u.status==="valid"?u.value:this._def.catchValue({get error(){return new et(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}Gr.create=(s,r)=>new Gr({innerType:s,typeName:K.ZodCatch,catchValue:typeof r.catch=="function"?r.catch:()=>r.catch,...ee(r)});class Xi extends se{_parse(r){if(this._getType(r)!==B.nan){const o=this._getOrReturnCtx(r);return P(o,{code:O.invalid_type,expected:B.nan,received:o.parsedType}),X}return{status:"valid",value:r.data}}}Xi.create=s=>new Xi({typeName:K.ZodNaN,...ee(s)});const Iy=Symbol("zod_brand");class Va extends se{_parse(r){const{ctx:i}=this._processInputParams(r),o=i.data;return this._def.type._parse({data:o,path:i.path,parent:i})}unwrap(){return this._def.type}}class Vr extends se{_parse(r){const{status:i,ctx:o}=this._processInputParams(r);if(o.common.async)return(async()=>{const c=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return c.status==="aborted"?X:c.status==="dirty"?(i.dirty(),Pn(c.value)):this._def.out._parseAsync({data:c.value,path:o.path,parent:o})})();{const u=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return u.status==="aborted"?X:u.status==="dirty"?(i.dirty(),{status:"dirty",value:u.value}):this._def.out._parseSync({data:u.value,path:o.path,parent:o})}}static create(r,i){return new Vr({in:r,out:i,typeName:K.ZodPipeline})}}class Ur extends se{_parse(r){const i=this._def.innerType._parse(r),o=u=>(hn(u)&&(u.value=Object.freeze(u.value)),u);return Er(i)?i.then(u=>o(u)):o(i)}unwrap(){return this._def.innerType}}Ur.create=(s,r)=>new Ur({innerType:s,typeName:K.ZodReadonly,...ee(r)});function Uc(s,r){const i=typeof s=="function"?s(r):typeof s=="string"?{message:s}:s;return typeof i=="string"?{message:i}:i}function vl(s,r={},i){return s?Fn.create().superRefine((o,u)=>{const c=s(o);if(c instanceof Promise)return c.then(h=>{if(!h){const g=Uc(r,o),m=g.fatal??i??!0;u.addIssue({code:"custom",...g,fatal:m})}});if(!c){const h=Uc(r,o),g=h.fatal??i??!0;u.addIssue({code:"custom",...h,fatal:g})}}):Fn.create()}const Cy={object:be.lazycreate};var K;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(K||(K={}));const Ay=(s,r={message:`Input not instance of ${s.name}`})=>vl(i=>i instanceof s,r),A=mt.create,U=Kt.create,Ty=Xi.create,Ry=Jt.create,ve=Mr.create,ky=pn.create,Oy=Hi.create,yl=Lr.create,Ey=Nr.create,My=Fn.create,Ly=dn.create,Ny=Ft.create,Py=zi.create,Ze=_t.create,D=be.create,Dy=be.strictCreate,mn=Pr.create,By=Qi.create,Fy=Dr.create,es=Ct.create,qt=Br.create,qy=Yi.create,Wy=gn.create,Zy=Dn.create,Gy=Fr.create,ge=qr.create,ct=jt.create,Uy=Wr.create,$y=qn.create,$c=vt.create,J=St.create,Vy=Qt.create,Hy=vt.createWithPreprocess,zy=Vr.create,Yy=()=>A().optional(),Xy=()=>U().optional(),Ha=()=>ve().optional(),Ky={string:(s=>mt.create({...s,coerce:!0})),number:(s=>Kt.create({...s,coerce:!0})),boolean:(s=>Mr.create({...s,coerce:!0})),bigint:(s=>Jt.create({...s,coerce:!0})),date:(s=>pn.create({...s,coerce:!0}))},Jy=X,Pa=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Iy,DIRTY:Pn,EMPTY_PATH:ny,INVALID:X,NEVER:Jy,OK:Ge,ParseStatus:De,Schema:se,ZodAny:Fn,ZodArray:_t,ZodBigInt:Jt,ZodBoolean:Mr,ZodBranded:Va,ZodCatch:Gr,ZodDate:pn,ZodDefault:Zr,ZodDiscriminatedUnion:Qi,ZodEffects:vt,ZodEnum:jt,ZodError:et,get ZodFirstPartyTypeKind(){return K},ZodFunction:Dn,ZodIntersection:Dr,ZodIssueCode:O,ZodLazy:Fr,ZodLiteral:qr,ZodMap:Yi,ZodNaN:Xi,ZodNativeEnum:Wr,ZodNever:Ft,ZodNull:Nr,ZodNullable:Qt,ZodNumber:Kt,ZodObject:be,ZodOptional:St,ZodParsedType:B,ZodPipeline:Vr,ZodPromise:qn,ZodReadonly:Ur,ZodRecord:Br,ZodSchema:se,ZodSet:gn,ZodString:mt,ZodSymbol:Hi,ZodTransformer:vt,ZodTuple:Ct,ZodType:se,ZodUndefined:Lr,ZodUnion:Pr,ZodUnknown:dn,ZodVoid:zi,addIssueToContext:P,any:My,array:Ze,bigint:Ry,boolean:ve,coerce:Ky,custom:vl,date:ky,datetimeRegex:ml,defaultErrorMap:Bn,discriminatedUnion:By,effect:$c,enum:ct,function:Zy,getErrorMap:$i,getParsedType:Bt,instanceof:Ay,intersection:Fy,isAborted:Wa,isAsync:Er,isDirty:Za,isValid:hn,late:Cy,lazy:Gy,literal:ge,makeIssue:Vi,map:qy,nan:Ty,nativeEnum:Uy,never:Ny,null:Ey,nullable:Vy,number:U,object:D,get objectUtil(){return qa},oboolean:Ha,onumber:Xy,optional:J,ostring:Yy,pipeline:zy,preprocess:Hy,promise:$y,quotelessJson:ey,record:qt,set:Wy,setErrorMap:ty,strictObject:Dy,string:A,symbol:Oy,transformer:$c,tuple:es,undefined:yl,union:mn,unknown:Ly,get util(){return le},void:Py},Symbol.toStringTag,{value:"Module"})),Wn=ct(["left","right","up","down"]),jy=Wn.options,ts=D({type:A(),id:A(),name:J(A()),status:J(A())}),xl=D({height:U(),width:U(),sprite:A().optional(),direction:J(Wn),filter:J(A())}),wl=D({room:J(A()),x:U(),y:U()}),$r=D({imageId:A(),col:U().optional(),row:U().optional()}),Ie=D({text:A().array()}),bl=D({x:U(),y:U()}),Ki=D({soundId:A(),volume:U().optional()}),ns={_started:Ha(),narrative:Ie.optional(),startDirection:Wn.optional(),endDirection:Wn.optional(),endStatus:A().optional()},Qy={_started:!0,narrative:!0,startDirection:!0,endDirection:!0,endStatus:!0,type:!0},e0=D({animation:J(A()),x:U(),y:U(),speed:J(U())}),Sl=D({type:ge("move"),roomId:A().optional(),pathIsSet:J(ve()),doPendingInteractionWhenFinished:J(ve()),steps:Ze(e0)}).extend(ns),Il=D({type:ge("goTo"),animation:J(A()),speed:J(U()),targetId:A()}).extend(ns),Cl=D({type:ge("say"),animation:J(A()),text:A(),time:U()}).extend(ns),t0=D({animation:J(A()),duration:U(),timeElapsed:J(U()),reverse:J(ve())}),Al=D({type:ge("act"),steps:Ze(t0)}).extend(ns),Hr=mn([Sl,Al,Cl,Il]),n0=Hr.options.map(s=>s.shape.type.value),rs=D({type:ge("order"),actorId:A().optional(),orders:Ze(Hr),replaceCurrentOrders:J(ve()),narrative:Ie.optional()}),Zn=D({type:ge("changeRoom"),roomId:A(),takePlayer:ve(),x:J(U()),y:J(U()),narrative:Ie.optional()}),Gn=D({type:ge("inventory"),itemId:A(),actorId:A().optional(),addOrRemove:ct(["ADD","REMOVE"]),narrative:Ie.optional()}),Un=D({type:ge("removeActor"),actorId:A(),narrative:Ie.optional()}),$n=D({type:ge("changeStatus"),targetId:A(),targetType:ct(["actor","item","hotspot"]),status:A(),narrative:Ie.optional()}),is=D({type:ge("sequence"),sequence:A(),narrative:Ie.optional()}),Vn=D({type:ge("conversation"),conversationId:A(),end:J(ve()),narrative:Ie.optional()}),Hn=D({type:ge("conversationChoice"),on:ve(),conversationId:A(),branchId:A(),choiceRef:A(),narrative:Ie.optional()}),zn=D({type:ge("teleportActor"),actorId:A(),roomId:J(A()),x:U(),y:U(),narrative:Ie.optional()}),_n=D({type:ge("toggleZone"),roomId:J(A()),on:ve(),ref:A(),zoneType:ct(["hotspot","obstacle","walkable"]),narrative:Ie.optional()}),Yn=D({type:ge("soundEffect"),sound:A(),volume:U().optional(),narrative:Ie.optional()}),Xn=D({type:ge("backgroundMusic"),sound:A().optional(),roomId:A().optional(),volume:U().optional(),narrative:Ie.optional()}),Kn=D({type:ge("ambientNoise"),sound:A().optional(),roomId:A().optional(),volume:U().optional(),narrative:Ie.optional()}),Jn=D({type:ge("flag"),on:ve(),flag:A(),narrative:Ie.optional()}),jn=D({type:ge("storyBoardConsequence"),storyBoardId:A(),narrative:Ie.optional()}),Qn=D({type:ge("changePlayerCharacter"),actorId:A(),narrative:Ie.optional()}),r0=_n.shape.zoneType.options,Tl=mn([rs,Zn,Gn,Un,$n,is,Vn,zn,_n,Yn,Xn,Kn,Jn,Hn,jn,Qn]),i0=ct(["conversation","sequence","changeStatus","backgroundMusic","ambientNoise","removeActor","inventory","changeRoom","order","teleportActor","toggleZone","soundEffect","flag","conversationChoice","storyBoardConsequence","changePlayerCharacter"]),s0=i0.options,a0={conversation:Vn,sequence:is,changeStatus:$n,removeActor:Un,inventory:Gn,changeRoom:Zn,order:rs,teleportActor:zn,toggleZone:_n,soundEffect:Yn,flag:Jn,conversationChoice:Hn,backgroundMusic:Xn,ambientNoise:Kn,storyBoardConsequence:jn,changePlayerCharacter:Qn},za=mn([Un,$n,Gn,Vn,zn,_n,Yn,Jn,Zn,Hn,Xn,Kn,jn,Qn]),o0=za.options.map(s=>s.shape.type.value),ss=D({verbId:A(),targetId:A(),roomId:A().optional(),itemId:A().optional(),targetStatus:A().optional(),mustReachFirst:ve().optional(),consequences:Ze(Tl),flagsThatMustBeFalse:Ze(A()).optional(),flagsThatMustBeTrue:Ze(A()).optional(),requiredInventory:Ze(A()).optional()}),Ya=D({actorOrders:J(qt(A(),Hr.array())),immediateConsequences:J(za.array()),narrative:Ie.optional(),_started:Ha()}),zr=D({id:A(),description:A().optional(),stages:Ya.array()}),Vc=D({conversationId:A().optional(),branchId:A().optional(),choiceRef:A().optional()}),Xa=D({ref:A().optional(),text:A(),sequence:A().optional(),nextBranch:J(A()),once:J(ve()),disabled:J(ve()),enablesChoices:Ze(Vc).optional(),disablesChoices:Ze(Vc).optional(),end:J(ve()),choiceSequence:zr.optional()}),Rl=D({choices:Ze(Xa)}),Ka=D({id:A(),branches:qt(A(),J(Rl)),currentBranch:J(A()),defaultBranch:A()}),Ja=D({id:A(),message:A(),imageId:A().optional(),imageWidth:U().optional()}),ja=D({type:ge("ending"),endingId:A(),narrative:Ie.optional()}),u0=mn([rs,Zn,Gn,Un,$n,is,Vn,zn,_n,Yn,Xn,Kn,Jn,Hn,jn,Qn,ja]),kl=mn([Un,$n,Gn,Vn,zn,_n,Yn,Jn,Zn,Hn,Xn,Kn,jn,Qn,ja]),Qa=ss.merge(D({consequences:Ze(u0)})),as=zr.merge(D({stages:Ya.merge(D({immediateConsequences:J(kl.array())})).array()})),c0=Xa.merge(D({choiceSequence:as.optional()})),l0=D({choices:Ze(c0)}),eo=Ka.merge(D({branches:qt(A(),J(l0))})),Ua=D({soundId:A(),frameIndex:U().optional(),volume:U().optional()}),f0=qt(A(),Ua.or(Ua.array()).or(yl())),os=ts.merge(wl).merge(xl).merge(D({type:ge("actor"),isPlayer:J(ve()),noInteraction:J(ve()),speed:J(U()),baseline:J(U()),dialogueColor:J(A()),soundEffectMap:f0.optional(),walkToX:U().optional(),walkToY:U().optional(),defaultFrame:$r.optional(),statusFrames:qt($r).optional()})),Ol=D({value:ve(),default:ve(),description:A().optional()}),to=qt(A(),Ol.optional()),Yr=ts.extend({type:ge("item"),actorId:A().optional()}).and($r.partial());ct(["rect","circle","polygon"]);const d0=Ze(es([U(),U()])),El=D({type:A().optional(),x:U(),y:U(),path:J(A()),polygon:J(d0),circle:J(U()),rect:J(es([U(),U()]))}),$a=El.merge(D({ref:A().optional(),disabled:ve().optional()})),no=El.merge(ts).merge(D({type:ge("hotspot"),parallax:U(),walkToX:U().optional(),walkToY:U().optional()})),h0=D({parallax:U(),imageId:A(),placement:D({x:U(),y:U(),width:U(),height:U()}).optional()}),p0=Ze(es([U(),U()])),ro=D({id:A(),frameWidth:U(),frameHeight:U().optional(),width:U(),height:U(),background:h0.array(),hotspots:no.array().optional(),obstacleAreas:J($a.array()),walkableAreas:J($a.array()),scaling:J(p0),backgroundColor:A().optional(),name:A().optional(),narrative:Ie.optional(),backgroundMusic:Ki.optional(),ambientNoise:Ki.optional()}),kr=D({imageId:A(),row:U(),col:U()}),g0=D({left:kr.array().optional(),right:kr.array().optional(),up:kr.array().optional(),down:kr.array().optional()}),io=D({id:A(),defaultDirection:Wn,animations:qt(A(),g0)}),Ml=ct(["center","left","right"]),Ll=ct(["center","top","bottom"]),m0=D({x:Ml,y:Ll,width:U().optional(),height:U().optional(),aspectRatio:bl.optional()}),_0=m0.merge(D({image:$r})),Nl=D({title:A(),narrative:Ie,pictures:_0.array(),backgroundColor:A(),color:A()}),Pl=ct(["sound","buttons"]),Dl=ct(["serif","sans-serif","monospace","cursive","fantasy","math"]),so=D({id:A(),isEndOfGame:ve().optional(),pages:Nl.array(),font:Dl.optional(),sound:Ki.optional(),progression:Pl.optional()}),us=D({id:A(),label:A(),preposition:A().optional(),isMoveVerb:ve().optional(),isNotForItems:ve().optional(),isLookVerb:ve().optional(),requiresItem:ve().optional(),defaultResponseNoItem:A().optional(),defaultResponseWithItem:A().optional(),defaultResponseCannotReach:A().optional()}),v0=D({schemaVersion:U().optional(),rooms:ro.array(),items:Yr.array(),actors:os.array(),interactions:Qa.array(),conversations:eo.array(),flagMap:to,currentRoomId:A(),id:A(),description:A().optional().describe("a short description of your game"),thumbnailAssetId:A().optional()}),y0=D({verbs:us.array(),sequences:as.array(),sprites:io.array(),endings:Ja.array(),openingSequenceId:A().optional(),openingStoryboardId:A().optional(),storyBoards:so.array().optional()}),Bl=v0.and(y0).describe("The game schema"),Fl=Pa.union([Pa.literal(0),Pa.literal(1)]).array().array(),cs=4,ql=D({sequenceRunning:zr.optional(),currentStoryBoardId:A().optional(),actorOrders:qt(A(),Hr.array()),currentConversationId:A().optional(),pendingInteraction:ss.optional(),gameNotBegun:ve(),cellMatrix:Fl.optional(),viewAngleX:U(),viewAngleY:U()}),ls=D({schemaVersion:ge(cs),rooms:ro.array(),items:Yr.array(),actors:os.array(),interactions:ss.array(),conversations:Ka.array(),flagMap:to,currentRoomId:A(),id:A(),description:A().optional().describe("a short description of your game"),thumbnailAssetId:A().optional()}),ao=D({verbs:us.array(),sequences:zr.array(),sprites:io.array(),openingSequenceId:A().optional(),openingStoryboardId:A().optional(),storyBoards:so.array()}),x0=ls.and(ql),Wl=ls.and(ao).describe("The game schema"),w0=ct(["rooms","items","actors","conversations","sprites","sequences","verbs","storyBoards"]),b0=ls.merge(D({schemaVersion:ge(3),interactions:Qa.array(),conversations:eo.array()})),S0=ao.merge(D({endings:Ja.array(),sequences:as.array()})),Zl=b0.and(S0).describe("The game schema"),Gl=mn([os,Yr,no]),I0=D({verb:us,target:Gl,item:J(Yr)});var Gi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},fn={},Qe={},Hc;function oo(){return Hc||(Hc=1,Object.defineProperty(Qe,"__esModule",{value:!0}),Qe._extreme=Qe._DEG=Qe._360_DEG=Qe._90_DEG_RIGHT=Qe._90_DEG_LEFT=void 0,Qe._90_DEG_LEFT=Math.PI*.5,Qe._90_DEG_RIGHT=Math.PI*-.5,Qe._360_DEG=Math.PI*2,Qe._DEG=Math.PI/180,Qe._extreme=Math.pow(10,30)),Qe}var Da={},zc;function Ul(){return zc||(zc=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.expandRect=s.findRotationBetweenHeadings=s.findClosestAndDistance=s.doCircleIntersect=s.doRectsIntersect=s.isPointInsideRect=s.getDistance=s.translate=s.getHeadingFrom=s.getVectorFrom=s.normaliseHeading=s.getHeading=s.getXYVector=s.xy=void 0;const r=oo();function i(E,k){return E*Math.sin(k)}function o(E,k){return E*Math.cos(k)}const u=(E,k)=>({x:E,y:k});s.xy=u;function c(E,k){return{x:i(E,k),y:o(E,k)}}s.getXYVector=c;const h=E=>{const{x:k,y:me}=E;return k==0&&me==0?0:me==0&&k!=0?k<0?Math.PI*1.5:Math.PI*.5:k==0&&me!=0?me>0?0:Math.PI*1:me>0?Math.atan(k/me):Math.PI+Math.atan(k/me)};s.getHeading=h;const g=E=>{const k=E%r._360_DEG;return k>0?k:r._360_DEG+k};s.normaliseHeading=g;const m=(E,k)=>({x:k.x-E.x,y:k.y-E.y});s.getVectorFrom=m;const v=(E,k)=>(0,s.getHeading)((0,s.getVectorFrom)(E,k));s.getHeadingFrom=v;const w=(E,k)=>({x:E.x+k.x,y:E.y+k.y});s.translate=w;const R=(E,k)=>Math.sqrt(Math.pow(E.x-k.x,2)+Math.pow(E.y-k.y,2));s.getDistance=R;const F=(E,k)=>{const{top:me,left:Ce,bottom:Ee,right:er}=k;return!(E.y<=me||E.y>=Ee||E.x<=Ce||E.x>=er)};s.isPointInsideRect=F;const W=(E,k)=>E.bottom<=k.bottom&&E.top>=k.top||k.bottom<=E.bottom&&k.top>=E.top,M=(E,k)=>E.right<=k.right&&E.left>=k.left||k.right<=E.right&&k.left>=E.left,L=(E,k)=>(0,s.isPointInsideRect)({x:E.left,y:E.top},k)||(0,s.isPointInsideRect)({x:E.left,y:E.bottom},k)||(0,s.isPointInsideRect)({x:E.right,y:E.top},k)||(0,s.isPointInsideRect)({x:E.right,y:E.bottom},k)||(0,s.isPointInsideRect)({x:k.left,y:k.top},E)||(0,s.isPointInsideRect)({x:k.left,y:k.bottom},E)||(0,s.isPointInsideRect)({x:k.right,y:k.top},E)||(0,s.isPointInsideRect)({x:k.right,y:k.bottom},E)||M(E,k)&&W(E,k)||M(E,k)&&(E.top>=k.top&&E.top<=k.bottom||k.top>=E.top&&k.top<=E.bottom)||W(E,k)&&(E.left>=k.left&&E.left<=k.right||k.left>=E.left&&k.left<=E.right);s.doRectsIntersect=L;const V=(E,k)=>(0,s.getDistance)(E,k)<E.r+k.r;s.doCircleIntersect=V;const $=(E,k)=>{if(E.length===0)return{distance:1/0};const me=E.map(Ee=>({item:Ee,distance:(0,s.getDistance)(k,Ee)}));let[Ce]=me;return me.forEach(Ee=>{Ce.distance>Ee.distance&&(Ce=Ee)}),Ce};s.findClosestAndDistance=$;const te=(E,k)=>{const me=(0,s.normaliseHeading)(E),Ce=(0,s.normaliseHeading)(k);let Ee=Ce;return me-Ce>r._360_DEG/2?Ee=Ce+r._360_DEG:me-Ce<-r._360_DEG/2&&(Ee=Ce-r._360_DEG),Ee-me};s.findRotationBetweenHeadings=te;const re=(E,k)=>({top:E.top-k,bottom:E.bottom+k,left:E.left-k,right:E.right+k});s.expandRect=re})(Da)),Da}var Sr={},Yc;function C0(){if(Yc)return Sr;Yc=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.doesLineSegmentCrossCircleEdge=void 0;const s=Ul();function r(h,g){return(0,s.getDistance)(h,g)<=h.r}function i(h,g,m,v){return{x:(1-h)*m.x+h*v.x-g.x,y:(1-h)*m.y+h*v.y-g.y}}function o(h){return Math.pow(h.x,2)+Math.pow(h.y,2)}function u(h,g,m){const v={x:g.x-h.x,y:g.y-h.y},w={x:h.x-m.x,y:h.y-m.y},R=v.x*w.x+v.y*w.y,F=Math.pow(v.x,2)+Math.pow(v.y,2),W=-R/F;if(W>=0&&W<=1)return i(W,{x:0,y:0},h,g);const M=o(i(0,m,h,g)),L=o(i(1,m,h,g));return M<=L?h:g}function c(h,g){const m=r(g,h[0]),v=r(g,h[1]);return m&&v?!1:v!=m?!0:r(g,u(...h,g))}return Sr.doesLineSegmentCrossCircleEdge=c,Sr}var Ba={},Xc;function A0(){return Xc||(Xc=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.isPointInsidePolygon=s.isPointOnLineSegment=void 0;const r=oo();function i(m,v,w){return v.x<=Math.max(m.x,w.x)&&v.x>=Math.min(m.x,w.x)&&v.y<=Math.max(m.y,w.y)&&v.y>=Math.min(m.y,w.y)}var o;(function(m){m[m.Colinear=0]="Colinear",m[m.Clockwise=1]="Clockwise",m[m.Counterclockwise=2]="Counterclockwise"})(o||(o={}));function u(m,v,w){const R=(v.y-m.y)*(w.x-v.x)-(v.x-m.x)*(w.y-v.y);return R==0?o.Colinear:R>0?o.Clockwise:o.Counterclockwise}const c=(m,v)=>u(m,...v)===o.Colinear?i(v[0],m,v[1]):!1;s.isPointOnLineSegment=c;function h(m,v){const w=u(m[0],m[1],v[0]),R=u(m[0],m[1],v[1]),F=u(v[0],v[1],m[0]),W=u(v[0],v[1],m[1]);return!!(w!=R&&F!=W||w==0&&i(m[0],v[0],m[1])||R==0&&i(m[0],v[1],m[1])||F==0&&i(v[0],m[0],v[1])||W==0&&i(v[0],m[1],v[1]))}function g(m,v){if(v.length<3)return!1;const R={y:m.y,x:r._extreme},F=[m,R];let W=0,M,L;for(let $=0;$<v.length;$++)M=v[$],L=$+1>=v.length?v[0]:v[$+1],h(F,[M,L])&&W++;let V=0;return v.forEach($=>{(0,s.isPointOnLineSegment)($,F)&&V++}),(W-V)%2!==0}s.isPointInsidePolygon=g})(Ba)),Ba}var Kc;function T0(){return Kc||(Kc=1,(function(s){var r=fn&&fn.__createBinding||(Object.create?(function(o,u,c,h){h===void 0&&(h=c);var g=Object.getOwnPropertyDescriptor(u,c);(!g||("get"in g?!u.__esModule:g.writable||g.configurable))&&(g={enumerable:!0,get:function(){return u[c]}}),Object.defineProperty(o,h,g)}):(function(o,u,c,h){h===void 0&&(h=c),o[h]=u[c]})),i=fn&&fn.__exportStar||function(o,u){for(var c in o)c!=="default"&&!Object.prototype.hasOwnProperty.call(u,c)&&r(u,o,c)};Object.defineProperty(s,"__esModule",{value:!0}),i(oo(),s),i(Ul(),s),i(C0(),s),i(A0(),s)})(fn)),fn}var R0=T0();function k0(s,r){const{x:i,y:o,width:u,height:c}=r;return s.x>=i&&s.x<=i+u&&s.y>=o&&s.y<=o+c}function O0(s,r){const{x:i,y:o,radius:u}=r;return Math.sqrt((s.x-i)**2+(s.y-o)**2)<=u}function E0(s,r,i,o,u){const c={x:(r+.5)*i,y:(s-.5)*i},h=Jc(c,o);if(u){const g=Jc(c,u);return h||!g}return h}function Jc(s,r){const{polygons:i,rectangles:o,circles:u}=r;return i.some(c=>R0.isPointInsidePolygon(s,c))||o.some(c=>k0(s,c))||u.some(c=>O0(s,c))}function jc(s){return s.filter(r=>r.polygon).map(r=>{const{x:i,y:o,polygon:u=[]}=r;return u.map(c=>({x:i+c[0],y:o+c[1]}))})}function Qc(s){return s.filter(r=>r.rect).map(r=>{const{x:i,y:o,rect:u}=r,[c,h]=u;return{x:i,y:o-h,width:c,height:h}})}function el(s){return s.filter(r=>r.circle).map(r=>{const{x:i,y:o,circle:u}=r;return{x:i,y:o,radius:u}})}function uo(s,r){const{width:i,height:o,obstacleAreas:u=[],walkableAreas:c=[]}=s,h=c.length>0?{polygons:jc(c.filter(R=>!R.disabled)),rectangles:Qc(c.filter(R=>!R.disabled)),circles:el(c.filter(R=>!R.disabled))}:null,g={polygons:jc(u.filter(R=>!R.disabled)),rectangles:Qc(u.filter(R=>!R.disabled)),circles:el(u.filter(R=>!R.disabled))},m=Math.ceil(o/r),v=Math.ceil(i/r),w=[];for(let R=0;R<m;R++){const F=[];for(let W=0;W<v;W++)F.push(E0(m-R,W,r,g,h)?1:0);w.push(F)}return w}var Fa={},Ir={},Or={exports:{}};var M0=Or.exports,tl;function L0(){return tl||(tl=1,(function(s,r){(function(){var i,o="4.17.21",u=200,c="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",h="Expected a function",g="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",v=500,w="__lodash_placeholder__",R=1,F=2,W=4,M=1,L=2,V=1,$=2,te=4,re=8,E=16,k=32,me=64,Ce=128,Ee=256,er=512,rf=30,sf="...",af=800,of=16,co=1,uf=2,cf=3,en=1/0,Wt=9007199254740991,lf=17976931348623157e292,Xr=NaN,yt=4294967295,ff=yt-1,df=yt>>>1,hf=[["ary",Ce],["bind",V],["bindKey",$],["curry",re],["curryRight",E],["flip",er],["partial",k],["partialRight",me],["rearg",Ee]],vn="[object Arguments]",Kr="[object Array]",pf="[object AsyncFunction]",tr="[object Boolean]",nr="[object Date]",gf="[object DOMException]",Jr="[object Error]",jr="[object Function]",lo="[object GeneratorFunction]",lt="[object Map]",rr="[object Number]",mf="[object Null]",At="[object Object]",fo="[object Promise]",_f="[object Proxy]",ir="[object RegExp]",ft="[object Set]",sr="[object String]",Qr="[object Symbol]",vf="[object Undefined]",ar="[object WeakMap]",yf="[object WeakSet]",or="[object ArrayBuffer]",yn="[object DataView]",hs="[object Float32Array]",ps="[object Float64Array]",gs="[object Int8Array]",ms="[object Int16Array]",_s="[object Int32Array]",vs="[object Uint8Array]",ys="[object Uint8ClampedArray]",xs="[object Uint16Array]",ws="[object Uint32Array]",xf=/\b__p \+= '';/g,wf=/\b(__p \+=) '' \+/g,bf=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ho=/&(?:amp|lt|gt|quot|#39);/g,po=/[&<>"']/g,Sf=RegExp(ho.source),If=RegExp(po.source),Cf=/<%-([\s\S]+?)%>/g,Af=/<%([\s\S]+?)%>/g,go=/<%=([\s\S]+?)%>/g,Tf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Rf=/^\w*$/,kf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,bs=/[\\^$.*+?()[\]{}|]/g,Of=RegExp(bs.source),Ss=/^\s+/,Ef=/\s/,Mf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Lf=/\{\n\/\* \[wrapped with (.+)\] \*/,Nf=/,? & /,Pf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Df=/[()=,{}\[\]\/\s]/,Bf=/\\(\\)?/g,Ff=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,mo=/\w*$/,qf=/^[-+]0x[0-9a-f]+$/i,Wf=/^0b[01]+$/i,Zf=/^\[object .+?Constructor\]$/,Gf=/^0o[0-7]+$/i,Uf=/^(?:0|[1-9]\d*)$/,$f=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ei=/($^)/,Vf=/['\n\r\u2028\u2029\\]/g,ti="\\ud800-\\udfff",Hf="\\u0300-\\u036f",zf="\\ufe20-\\ufe2f",Yf="\\u20d0-\\u20ff",_o=Hf+zf+Yf,vo="\\u2700-\\u27bf",yo="a-z\\xdf-\\xf6\\xf8-\\xff",Xf="\\xac\\xb1\\xd7\\xf7",Kf="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Jf="\\u2000-\\u206f",jf=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xo="A-Z\\xc0-\\xd6\\xd8-\\xde",wo="\\ufe0e\\ufe0f",bo=Xf+Kf+Jf+jf,Is="['’]",Qf="["+ti+"]",So="["+bo+"]",ni="["+_o+"]",Io="\\d+",ed="["+vo+"]",Co="["+yo+"]",Ao="[^"+ti+bo+Io+vo+yo+xo+"]",Cs="\\ud83c[\\udffb-\\udfff]",td="(?:"+ni+"|"+Cs+")",To="[^"+ti+"]",As="(?:\\ud83c[\\udde6-\\uddff]){2}",Ts="[\\ud800-\\udbff][\\udc00-\\udfff]",xn="["+xo+"]",Ro="\\u200d",ko="(?:"+Co+"|"+Ao+")",nd="(?:"+xn+"|"+Ao+")",Oo="(?:"+Is+"(?:d|ll|m|re|s|t|ve))?",Eo="(?:"+Is+"(?:D|LL|M|RE|S|T|VE))?",Mo=td+"?",Lo="["+wo+"]?",rd="(?:"+Ro+"(?:"+[To,As,Ts].join("|")+")"+Lo+Mo+")*",id="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",sd="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",No=Lo+Mo+rd,ad="(?:"+[ed,As,Ts].join("|")+")"+No,od="(?:"+[To+ni+"?",ni,As,Ts,Qf].join("|")+")",ud=RegExp(Is,"g"),cd=RegExp(ni,"g"),Rs=RegExp(Cs+"(?="+Cs+")|"+od+No,"g"),ld=RegExp([xn+"?"+Co+"+"+Oo+"(?="+[So,xn,"$"].join("|")+")",nd+"+"+Eo+"(?="+[So,xn+ko,"$"].join("|")+")",xn+"?"+ko+"+"+Oo,xn+"+"+Eo,sd,id,Io,ad].join("|"),"g"),fd=RegExp("["+Ro+ti+_o+wo+"]"),dd=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hd=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],pd=-1,ye={};ye[hs]=ye[ps]=ye[gs]=ye[ms]=ye[_s]=ye[vs]=ye[ys]=ye[xs]=ye[ws]=!0,ye[vn]=ye[Kr]=ye[or]=ye[tr]=ye[yn]=ye[nr]=ye[Jr]=ye[jr]=ye[lt]=ye[rr]=ye[At]=ye[ir]=ye[ft]=ye[sr]=ye[ar]=!1;var _e={};_e[vn]=_e[Kr]=_e[or]=_e[yn]=_e[tr]=_e[nr]=_e[hs]=_e[ps]=_e[gs]=_e[ms]=_e[_s]=_e[lt]=_e[rr]=_e[At]=_e[ir]=_e[ft]=_e[sr]=_e[Qr]=_e[vs]=_e[ys]=_e[xs]=_e[ws]=!0,_e[Jr]=_e[jr]=_e[ar]=!1;var gd={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},md={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_d={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},vd={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},yd=parseFloat,xd=parseInt,Po=typeof Gi=="object"&&Gi&&Gi.Object===Object&&Gi,wd=typeof self=="object"&&self&&self.Object===Object&&self,Me=Po||wd||Function("return this")(),ks=r&&!r.nodeType&&r,tn=ks&&!0&&s&&!s.nodeType&&s,Do=tn&&tn.exports===ks,Os=Do&&Po.process,tt=(function(){try{var y=tn&&tn.require&&tn.require("util").types;return y||Os&&Os.binding&&Os.binding("util")}catch{}})(),Bo=tt&&tt.isArrayBuffer,Fo=tt&&tt.isDate,qo=tt&&tt.isMap,Wo=tt&&tt.isRegExp,Zo=tt&&tt.isSet,Go=tt&&tt.isTypedArray;function ze(y,S,b){switch(b.length){case 0:return y.call(S);case 1:return y.call(S,b[0]);case 2:return y.call(S,b[0],b[1]);case 3:return y.call(S,b[0],b[1],b[2])}return y.apply(S,b)}function bd(y,S,b,q){for(var j=-1,fe=y==null?0:y.length;++j<fe;){var Re=y[j];S(q,Re,b(Re),y)}return q}function nt(y,S){for(var b=-1,q=y==null?0:y.length;++b<q&&S(y[b],b,y)!==!1;);return y}function Sd(y,S){for(var b=y==null?0:y.length;b--&&S(y[b],b,y)!==!1;);return y}function Uo(y,S){for(var b=-1,q=y==null?0:y.length;++b<q;)if(!S(y[b],b,y))return!1;return!0}function Zt(y,S){for(var b=-1,q=y==null?0:y.length,j=0,fe=[];++b<q;){var Re=y[b];S(Re,b,y)&&(fe[j++]=Re)}return fe}function ri(y,S){var b=y==null?0:y.length;return!!b&&wn(y,S,0)>-1}function Es(y,S,b){for(var q=-1,j=y==null?0:y.length;++q<j;)if(b(S,y[q]))return!0;return!1}function xe(y,S){for(var b=-1,q=y==null?0:y.length,j=Array(q);++b<q;)j[b]=S(y[b],b,y);return j}function Gt(y,S){for(var b=-1,q=S.length,j=y.length;++b<q;)y[j+b]=S[b];return y}function Ms(y,S,b,q){var j=-1,fe=y==null?0:y.length;for(q&&fe&&(b=y[++j]);++j<fe;)b=S(b,y[j],j,y);return b}function Id(y,S,b,q){var j=y==null?0:y.length;for(q&&j&&(b=y[--j]);j--;)b=S(b,y[j],j,y);return b}function Ls(y,S){for(var b=-1,q=y==null?0:y.length;++b<q;)if(S(y[b],b,y))return!0;return!1}var Cd=Ns("length");function Ad(y){return y.split("")}function Td(y){return y.match(Pf)||[]}function $o(y,S,b){var q;return b(y,function(j,fe,Re){if(S(j,fe,Re))return q=fe,!1}),q}function ii(y,S,b,q){for(var j=y.length,fe=b+(q?1:-1);q?fe--:++fe<j;)if(S(y[fe],fe,y))return fe;return-1}function wn(y,S,b){return S===S?qd(y,S,b):ii(y,Vo,b)}function Rd(y,S,b,q){for(var j=b-1,fe=y.length;++j<fe;)if(q(y[j],S))return j;return-1}function Vo(y){return y!==y}function Ho(y,S){var b=y==null?0:y.length;return b?Ds(y,S)/b:Xr}function Ns(y){return function(S){return S==null?i:S[y]}}function Ps(y){return function(S){return y==null?i:y[S]}}function zo(y,S,b,q,j){return j(y,function(fe,Re,pe){b=q?(q=!1,fe):S(b,fe,Re,pe)}),b}function kd(y,S){var b=y.length;for(y.sort(S);b--;)y[b]=y[b].value;return y}function Ds(y,S){for(var b,q=-1,j=y.length;++q<j;){var fe=S(y[q]);fe!==i&&(b=b===i?fe:b+fe)}return b}function Bs(y,S){for(var b=-1,q=Array(y);++b<y;)q[b]=S(b);return q}function Od(y,S){return xe(S,function(b){return[b,y[b]]})}function Yo(y){return y&&y.slice(0,jo(y)+1).replace(Ss,"")}function Ye(y){return function(S){return y(S)}}function Fs(y,S){return xe(S,function(b){return y[b]})}function ur(y,S){return y.has(S)}function Xo(y,S){for(var b=-1,q=y.length;++b<q&&wn(S,y[b],0)>-1;);return b}function Ko(y,S){for(var b=y.length;b--&&wn(S,y[b],0)>-1;);return b}function Ed(y,S){for(var b=y.length,q=0;b--;)y[b]===S&&++q;return q}var Md=Ps(gd),Ld=Ps(md);function Nd(y){return"\\"+vd[y]}function Pd(y,S){return y==null?i:y[S]}function bn(y){return fd.test(y)}function Dd(y){return dd.test(y)}function Bd(y){for(var S,b=[];!(S=y.next()).done;)b.push(S.value);return b}function qs(y){var S=-1,b=Array(y.size);return y.forEach(function(q,j){b[++S]=[j,q]}),b}function Jo(y,S){return function(b){return y(S(b))}}function Ut(y,S){for(var b=-1,q=y.length,j=0,fe=[];++b<q;){var Re=y[b];(Re===S||Re===w)&&(y[b]=w,fe[j++]=b)}return fe}function si(y){var S=-1,b=Array(y.size);return y.forEach(function(q){b[++S]=q}),b}function Fd(y){var S=-1,b=Array(y.size);return y.forEach(function(q){b[++S]=[q,q]}),b}function qd(y,S,b){for(var q=b-1,j=y.length;++q<j;)if(y[q]===S)return q;return-1}function Wd(y,S,b){for(var q=b+1;q--;)if(y[q]===S)return q;return q}function Sn(y){return bn(y)?Gd(y):Cd(y)}function dt(y){return bn(y)?Ud(y):Ad(y)}function jo(y){for(var S=y.length;S--&&Ef.test(y.charAt(S)););return S}var Zd=Ps(_d);function Gd(y){for(var S=Rs.lastIndex=0;Rs.test(y);)++S;return S}function Ud(y){return y.match(Rs)||[]}function $d(y){return y.match(ld)||[]}var Vd=(function y(S){S=S==null?Me:In.defaults(Me.Object(),S,In.pick(Me,hd));var b=S.Array,q=S.Date,j=S.Error,fe=S.Function,Re=S.Math,pe=S.Object,Ws=S.RegExp,Hd=S.String,rt=S.TypeError,ai=b.prototype,zd=fe.prototype,Cn=pe.prototype,oi=S["__core-js_shared__"],ui=zd.toString,he=Cn.hasOwnProperty,Yd=0,Qo=(function(){var e=/[^.]+$/.exec(oi&&oi.keys&&oi.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""})(),ci=Cn.toString,Xd=ui.call(pe),Kd=Me._,Jd=Ws("^"+ui.call(he).replace(bs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),li=Do?S.Buffer:i,$t=S.Symbol,fi=S.Uint8Array,eu=li?li.allocUnsafe:i,di=Jo(pe.getPrototypeOf,pe),tu=pe.create,nu=Cn.propertyIsEnumerable,hi=ai.splice,ru=$t?$t.isConcatSpreadable:i,cr=$t?$t.iterator:i,nn=$t?$t.toStringTag:i,pi=(function(){try{var e=un(pe,"defineProperty");return e({},"",{}),e}catch{}})(),jd=S.clearTimeout!==Me.clearTimeout&&S.clearTimeout,Qd=q&&q.now!==Me.Date.now&&q.now,eh=S.setTimeout!==Me.setTimeout&&S.setTimeout,gi=Re.ceil,mi=Re.floor,Zs=pe.getOwnPropertySymbols,th=li?li.isBuffer:i,iu=S.isFinite,nh=ai.join,rh=Jo(pe.keys,pe),ke=Re.max,Ne=Re.min,ih=q.now,sh=S.parseInt,su=Re.random,ah=ai.reverse,Gs=un(S,"DataView"),lr=un(S,"Map"),Us=un(S,"Promise"),An=un(S,"Set"),fr=un(S,"WeakMap"),dr=un(pe,"create"),_i=fr&&new fr,Tn={},oh=cn(Gs),uh=cn(lr),ch=cn(Us),lh=cn(An),fh=cn(fr),vi=$t?$t.prototype:i,hr=vi?vi.valueOf:i,au=vi?vi.toString:i;function f(e){if(Se(e)&&!Q(e)&&!(e instanceof ue)){if(e instanceof it)return e;if(he.call(e,"__wrapped__"))return oc(e)}return new it(e)}var Rn=(function(){function e(){}return function(t){if(!we(t))return{};if(tu)return tu(t);e.prototype=t;var n=new e;return e.prototype=i,n}})();function yi(){}function it(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}f.templateSettings={escape:Cf,evaluate:Af,interpolate:go,variable:"",imports:{_:f}},f.prototype=yi.prototype,f.prototype.constructor=f,it.prototype=Rn(yi.prototype),it.prototype.constructor=it;function ue(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=yt,this.__views__=[]}function dh(){var e=new ue(this.__wrapped__);return e.__actions__=Ue(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ue(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ue(this.__views__),e}function hh(){if(this.__filtered__){var e=new ue(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function ph(){var e=this.__wrapped__.value(),t=this.__dir__,n=Q(e),a=t<0,l=n?e.length:0,d=Ap(0,l,this.__views__),p=d.start,_=d.end,x=_-p,I=a?_:p-1,C=this.__iteratees__,T=C.length,N=0,Z=Ne(x,this.__takeCount__);if(!n||!a&&l==x&&Z==x)return Ou(e,this.__actions__);var z=[];e:for(;x--&&N<Z;){I+=t;for(var ie=-1,Y=e[I];++ie<T;){var oe=C[ie],ce=oe.iteratee,Je=oe.type,qe=ce(Y);if(Je==uf)Y=qe;else if(!qe){if(Je==co)continue e;break e}}z[N++]=Y}return z}ue.prototype=Rn(yi.prototype),ue.prototype.constructor=ue;function rn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var a=e[t];this.set(a[0],a[1])}}function gh(){this.__data__=dr?dr(null):{},this.size=0}function mh(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function _h(e){var t=this.__data__;if(dr){var n=t[e];return n===m?i:n}return he.call(t,e)?t[e]:i}function vh(e){var t=this.__data__;return dr?t[e]!==i:he.call(t,e)}function yh(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=dr&&t===i?m:t,this}rn.prototype.clear=gh,rn.prototype.delete=mh,rn.prototype.get=_h,rn.prototype.has=vh,rn.prototype.set=yh;function Tt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var a=e[t];this.set(a[0],a[1])}}function xh(){this.__data__=[],this.size=0}function wh(e){var t=this.__data__,n=xi(t,e);if(n<0)return!1;var a=t.length-1;return n==a?t.pop():hi.call(t,n,1),--this.size,!0}function bh(e){var t=this.__data__,n=xi(t,e);return n<0?i:t[n][1]}function Sh(e){return xi(this.__data__,e)>-1}function Ih(e,t){var n=this.__data__,a=xi(n,e);return a<0?(++this.size,n.push([e,t])):n[a][1]=t,this}Tt.prototype.clear=xh,Tt.prototype.delete=wh,Tt.prototype.get=bh,Tt.prototype.has=Sh,Tt.prototype.set=Ih;function Rt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var a=e[t];this.set(a[0],a[1])}}function Ch(){this.size=0,this.__data__={hash:new rn,map:new(lr||Tt),string:new rn}}function Ah(e){var t=Mi(this,e).delete(e);return this.size-=t?1:0,t}function Th(e){return Mi(this,e).get(e)}function Rh(e){return Mi(this,e).has(e)}function kh(e,t){var n=Mi(this,e),a=n.size;return n.set(e,t),this.size+=n.size==a?0:1,this}Rt.prototype.clear=Ch,Rt.prototype.delete=Ah,Rt.prototype.get=Th,Rt.prototype.has=Rh,Rt.prototype.set=kh;function sn(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new Rt;++t<n;)this.add(e[t])}function Oh(e){return this.__data__.set(e,m),this}function Eh(e){return this.__data__.has(e)}sn.prototype.add=sn.prototype.push=Oh,sn.prototype.has=Eh;function ht(e){var t=this.__data__=new Tt(e);this.size=t.size}function Mh(){this.__data__=new Tt,this.size=0}function Lh(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Nh(e){return this.__data__.get(e)}function Ph(e){return this.__data__.has(e)}function Dh(e,t){var n=this.__data__;if(n instanceof Tt){var a=n.__data__;if(!lr||a.length<u-1)return a.push([e,t]),this.size=++n.size,this;n=this.__data__=new Rt(a)}return n.set(e,t),this.size=n.size,this}ht.prototype.clear=Mh,ht.prototype.delete=Lh,ht.prototype.get=Nh,ht.prototype.has=Ph,ht.prototype.set=Dh;function ou(e,t){var n=Q(e),a=!n&&ln(e),l=!n&&!a&&Xt(e),d=!n&&!a&&!l&&Mn(e),p=n||a||l||d,_=p?Bs(e.length,Hd):[],x=_.length;for(var I in e)(t||he.call(e,I))&&!(p&&(I=="length"||l&&(I=="offset"||I=="parent")||d&&(I=="buffer"||I=="byteLength"||I=="byteOffset")||Mt(I,x)))&&_.push(I);return _}function uu(e){var t=e.length;return t?e[ea(0,t-1)]:i}function Bh(e,t){return Li(Ue(e),an(t,0,e.length))}function Fh(e){return Li(Ue(e))}function $s(e,t,n){(n!==i&&!pt(e[t],n)||n===i&&!(t in e))&&kt(e,t,n)}function pr(e,t,n){var a=e[t];(!(he.call(e,t)&&pt(a,n))||n===i&&!(t in e))&&kt(e,t,n)}function xi(e,t){for(var n=e.length;n--;)if(pt(e[n][0],t))return n;return-1}function qh(e,t,n,a){return Vt(e,function(l,d,p){t(a,l,n(l),p)}),a}function cu(e,t){return e&&wt(t,Oe(t),e)}function Wh(e,t){return e&&wt(t,Ve(t),e)}function kt(e,t,n){t=="__proto__"&&pi?pi(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Vs(e,t){for(var n=-1,a=t.length,l=b(a),d=e==null;++n<a;)l[n]=d?i:Ca(e,t[n]);return l}function an(e,t,n){return e===e&&(n!==i&&(e=e<=n?e:n),t!==i&&(e=e>=t?e:t)),e}function st(e,t,n,a,l,d){var p,_=t&R,x=t&F,I=t&W;if(n&&(p=l?n(e,a,l,d):n(e)),p!==i)return p;if(!we(e))return e;var C=Q(e);if(C){if(p=Rp(e),!_)return Ue(e,p)}else{var T=Pe(e),N=T==jr||T==lo;if(Xt(e))return Lu(e,_);if(T==At||T==vn||N&&!l){if(p=x||N?{}:ju(e),!_)return x?_p(e,Wh(p,e)):mp(e,cu(p,e))}else{if(!_e[T])return l?e:{};p=kp(e,T,_)}}d||(d=new ht);var Z=d.get(e);if(Z)return Z;d.set(e,p),Tc(e)?e.forEach(function(Y){p.add(st(Y,t,n,Y,e,d))}):Cc(e)&&e.forEach(function(Y,oe){p.set(oe,st(Y,t,n,oe,e,d))});var z=I?x?fa:la:x?Ve:Oe,ie=C?i:z(e);return nt(ie||e,function(Y,oe){ie&&(oe=Y,Y=e[oe]),pr(p,oe,st(Y,t,n,oe,e,d))}),p}function Zh(e){var t=Oe(e);return function(n){return lu(n,e,t)}}function lu(e,t,n){var a=n.length;if(e==null)return!a;for(e=pe(e);a--;){var l=n[a],d=t[l],p=e[l];if(p===i&&!(l in e)||!d(p))return!1}return!0}function fu(e,t,n){if(typeof e!="function")throw new rt(h);return wr(function(){e.apply(i,n)},t)}function gr(e,t,n,a){var l=-1,d=ri,p=!0,_=e.length,x=[],I=t.length;if(!_)return x;n&&(t=xe(t,Ye(n))),a?(d=Es,p=!1):t.length>=u&&(d=ur,p=!1,t=new sn(t));e:for(;++l<_;){var C=e[l],T=n==null?C:n(C);if(C=a||C!==0?C:0,p&&T===T){for(var N=I;N--;)if(t[N]===T)continue e;x.push(C)}else d(t,T,a)||x.push(C)}return x}var Vt=Fu(xt),du=Fu(zs,!0);function Gh(e,t){var n=!0;return Vt(e,function(a,l,d){return n=!!t(a,l,d),n}),n}function wi(e,t,n){for(var a=-1,l=e.length;++a<l;){var d=e[a],p=t(d);if(p!=null&&(_===i?p===p&&!Ke(p):n(p,_)))var _=p,x=d}return x}function Uh(e,t,n,a){var l=e.length;for(n=ne(n),n<0&&(n=-n>l?0:l+n),a=a===i||a>l?l:ne(a),a<0&&(a+=l),a=n>a?0:kc(a);n<a;)e[n++]=t;return e}function hu(e,t){var n=[];return Vt(e,function(a,l,d){t(a,l,d)&&n.push(a)}),n}function Le(e,t,n,a,l){var d=-1,p=e.length;for(n||(n=Ep),l||(l=[]);++d<p;){var _=e[d];t>0&&n(_)?t>1?Le(_,t-1,n,a,l):Gt(l,_):a||(l[l.length]=_)}return l}var Hs=qu(),pu=qu(!0);function xt(e,t){return e&&Hs(e,t,Oe)}function zs(e,t){return e&&pu(e,t,Oe)}function bi(e,t){return Zt(t,function(n){return Lt(e[n])})}function on(e,t){t=zt(t,e);for(var n=0,a=t.length;e!=null&&n<a;)e=e[bt(t[n++])];return n&&n==a?e:i}function gu(e,t,n){var a=t(e);return Q(e)?a:Gt(a,n(e))}function Be(e){return e==null?e===i?vf:mf:nn&&nn in pe(e)?Cp(e):Fp(e)}function Ys(e,t){return e>t}function $h(e,t){return e!=null&&he.call(e,t)}function Vh(e,t){return e!=null&&t in pe(e)}function Hh(e,t,n){return e>=Ne(t,n)&&e<ke(t,n)}function Xs(e,t,n){for(var a=n?Es:ri,l=e[0].length,d=e.length,p=d,_=b(d),x=1/0,I=[];p--;){var C=e[p];p&&t&&(C=xe(C,Ye(t))),x=Ne(C.length,x),_[p]=!n&&(t||l>=120&&C.length>=120)?new sn(p&&C):i}C=e[0];var T=-1,N=_[0];e:for(;++T<l&&I.length<x;){var Z=C[T],z=t?t(Z):Z;if(Z=n||Z!==0?Z:0,!(N?ur(N,z):a(I,z,n))){for(p=d;--p;){var ie=_[p];if(!(ie?ur(ie,z):a(e[p],z,n)))continue e}N&&N.push(z),I.push(Z)}}return I}function zh(e,t,n,a){return xt(e,function(l,d,p){t(a,n(l),d,p)}),a}function mr(e,t,n){t=zt(t,e),e=nc(e,t);var a=e==null?e:e[bt(ot(t))];return a==null?i:ze(a,e,n)}function mu(e){return Se(e)&&Be(e)==vn}function Yh(e){return Se(e)&&Be(e)==or}function Xh(e){return Se(e)&&Be(e)==nr}function _r(e,t,n,a,l){return e===t?!0:e==null||t==null||!Se(e)&&!Se(t)?e!==e&&t!==t:Kh(e,t,n,a,_r,l)}function Kh(e,t,n,a,l,d){var p=Q(e),_=Q(t),x=p?Kr:Pe(e),I=_?Kr:Pe(t);x=x==vn?At:x,I=I==vn?At:I;var C=x==At,T=I==At,N=x==I;if(N&&Xt(e)){if(!Xt(t))return!1;p=!0,C=!1}if(N&&!C)return d||(d=new ht),p||Mn(e)?Xu(e,t,n,a,l,d):Sp(e,t,x,n,a,l,d);if(!(n&M)){var Z=C&&he.call(e,"__wrapped__"),z=T&&he.call(t,"__wrapped__");if(Z||z){var ie=Z?e.value():e,Y=z?t.value():t;return d||(d=new ht),l(ie,Y,n,a,d)}}return N?(d||(d=new ht),Ip(e,t,n,a,l,d)):!1}function Jh(e){return Se(e)&&Pe(e)==lt}function Ks(e,t,n,a){var l=n.length,d=l,p=!a;if(e==null)return!d;for(e=pe(e);l--;){var _=n[l];if(p&&_[2]?_[1]!==e[_[0]]:!(_[0]in e))return!1}for(;++l<d;){_=n[l];var x=_[0],I=e[x],C=_[1];if(p&&_[2]){if(I===i&&!(x in e))return!1}else{var T=new ht;if(a)var N=a(I,C,x,e,t,T);if(!(N===i?_r(C,I,M|L,a,T):N))return!1}}return!0}function _u(e){if(!we(e)||Lp(e))return!1;var t=Lt(e)?Jd:Zf;return t.test(cn(e))}function jh(e){return Se(e)&&Be(e)==ir}function Qh(e){return Se(e)&&Pe(e)==ft}function ep(e){return Se(e)&&qi(e.length)&&!!ye[Be(e)]}function vu(e){return typeof e=="function"?e:e==null?He:typeof e=="object"?Q(e)?wu(e[0],e[1]):xu(e):Wc(e)}function Js(e){if(!xr(e))return rh(e);var t=[];for(var n in pe(e))he.call(e,n)&&n!="constructor"&&t.push(n);return t}function tp(e){if(!we(e))return Bp(e);var t=xr(e),n=[];for(var a in e)a=="constructor"&&(t||!he.call(e,a))||n.push(a);return n}function js(e,t){return e<t}function yu(e,t){var n=-1,a=$e(e)?b(e.length):[];return Vt(e,function(l,d,p){a[++n]=t(l,d,p)}),a}function xu(e){var t=ha(e);return t.length==1&&t[0][2]?ec(t[0][0],t[0][1]):function(n){return n===e||Ks(n,e,t)}}function wu(e,t){return ga(e)&&Qu(t)?ec(bt(e),t):function(n){var a=Ca(n,e);return a===i&&a===t?Aa(n,e):_r(t,a,M|L)}}function Si(e,t,n,a,l){e!==t&&Hs(t,function(d,p){if(l||(l=new ht),we(d))np(e,t,p,n,Si,a,l);else{var _=a?a(_a(e,p),d,p+"",e,t,l):i;_===i&&(_=d),$s(e,p,_)}},Ve)}function np(e,t,n,a,l,d,p){var _=_a(e,n),x=_a(t,n),I=p.get(x);if(I){$s(e,n,I);return}var C=d?d(_,x,n+"",e,t,p):i,T=C===i;if(T){var N=Q(x),Z=!N&&Xt(x),z=!N&&!Z&&Mn(x);C=x,N||Z||z?Q(_)?C=_:Ae(_)?C=Ue(_):Z?(T=!1,C=Lu(x,!0)):z?(T=!1,C=Nu(x,!0)):C=[]:br(x)||ln(x)?(C=_,ln(_)?C=Oc(_):(!we(_)||Lt(_))&&(C=ju(x))):T=!1}T&&(p.set(x,C),l(C,x,a,d,p),p.delete(x)),$s(e,n,C)}function bu(e,t){var n=e.length;if(n)return t+=t<0?n:0,Mt(t,n)?e[t]:i}function Su(e,t,n){t.length?t=xe(t,function(d){return Q(d)?function(p){return on(p,d.length===1?d[0]:d)}:d}):t=[He];var a=-1;t=xe(t,Ye(H()));var l=yu(e,function(d,p,_){var x=xe(t,function(I){return I(d)});return{criteria:x,index:++a,value:d}});return kd(l,function(d,p){return gp(d,p,n)})}function rp(e,t){return Iu(e,t,function(n,a){return Aa(e,a)})}function Iu(e,t,n){for(var a=-1,l=t.length,d={};++a<l;){var p=t[a],_=on(e,p);n(_,p)&&vr(d,zt(p,e),_)}return d}function ip(e){return function(t){return on(t,e)}}function Qs(e,t,n,a){var l=a?Rd:wn,d=-1,p=t.length,_=e;for(e===t&&(t=Ue(t)),n&&(_=xe(e,Ye(n)));++d<p;)for(var x=0,I=t[d],C=n?n(I):I;(x=l(_,C,x,a))>-1;)_!==e&&hi.call(_,x,1),hi.call(e,x,1);return e}function Cu(e,t){for(var n=e?t.length:0,a=n-1;n--;){var l=t[n];if(n==a||l!==d){var d=l;Mt(l)?hi.call(e,l,1):ra(e,l)}}return e}function ea(e,t){return e+mi(su()*(t-e+1))}function sp(e,t,n,a){for(var l=-1,d=ke(gi((t-e)/(n||1)),0),p=b(d);d--;)p[a?d:++l]=e,e+=n;return p}function ta(e,t){var n="";if(!e||t<1||t>Wt)return n;do t%2&&(n+=e),t=mi(t/2),t&&(e+=e);while(t);return n}function ae(e,t){return va(tc(e,t,He),e+"")}function ap(e){return uu(Ln(e))}function op(e,t){var n=Ln(e);return Li(n,an(t,0,n.length))}function vr(e,t,n,a){if(!we(e))return e;t=zt(t,e);for(var l=-1,d=t.length,p=d-1,_=e;_!=null&&++l<d;){var x=bt(t[l]),I=n;if(x==="__proto__"||x==="constructor"||x==="prototype")return e;if(l!=p){var C=_[x];I=a?a(C,x,_):i,I===i&&(I=we(C)?C:Mt(t[l+1])?[]:{})}pr(_,x,I),_=_[x]}return e}var Au=_i?function(e,t){return _i.set(e,t),e}:He,up=pi?function(e,t){return pi(e,"toString",{configurable:!0,enumerable:!1,value:Ra(t),writable:!0})}:He;function cp(e){return Li(Ln(e))}function at(e,t,n){var a=-1,l=e.length;t<0&&(t=-t>l?0:l+t),n=n>l?l:n,n<0&&(n+=l),l=t>n?0:n-t>>>0,t>>>=0;for(var d=b(l);++a<l;)d[a]=e[a+t];return d}function lp(e,t){var n;return Vt(e,function(a,l,d){return n=t(a,l,d),!n}),!!n}function Ii(e,t,n){var a=0,l=e==null?a:e.length;if(typeof t=="number"&&t===t&&l<=df){for(;a<l;){var d=a+l>>>1,p=e[d];p!==null&&!Ke(p)&&(n?p<=t:p<t)?a=d+1:l=d}return l}return na(e,t,He,n)}function na(e,t,n,a){var l=0,d=e==null?0:e.length;if(d===0)return 0;t=n(t);for(var p=t!==t,_=t===null,x=Ke(t),I=t===i;l<d;){var C=mi((l+d)/2),T=n(e[C]),N=T!==i,Z=T===null,z=T===T,ie=Ke(T);if(p)var Y=a||z;else I?Y=z&&(a||N):_?Y=z&&N&&(a||!Z):x?Y=z&&N&&!Z&&(a||!ie):Z||ie?Y=!1:Y=a?T<=t:T<t;Y?l=C+1:d=C}return Ne(d,ff)}function Tu(e,t){for(var n=-1,a=e.length,l=0,d=[];++n<a;){var p=e[n],_=t?t(p):p;if(!n||!pt(_,x)){var x=_;d[l++]=p===0?0:p}}return d}function Ru(e){return typeof e=="number"?e:Ke(e)?Xr:+e}function Xe(e){if(typeof e=="string")return e;if(Q(e))return xe(e,Xe)+"";if(Ke(e))return au?au.call(e):"";var t=e+"";return t=="0"&&1/e==-en?"-0":t}function Ht(e,t,n){var a=-1,l=ri,d=e.length,p=!0,_=[],x=_;if(n)p=!1,l=Es;else if(d>=u){var I=t?null:wp(e);if(I)return si(I);p=!1,l=ur,x=new sn}else x=t?[]:_;e:for(;++a<d;){var C=e[a],T=t?t(C):C;if(C=n||C!==0?C:0,p&&T===T){for(var N=x.length;N--;)if(x[N]===T)continue e;t&&x.push(T),_.push(C)}else l(x,T,n)||(x!==_&&x.push(T),_.push(C))}return _}function ra(e,t){return t=zt(t,e),e=nc(e,t),e==null||delete e[bt(ot(t))]}function ku(e,t,n,a){return vr(e,t,n(on(e,t)),a)}function Ci(e,t,n,a){for(var l=e.length,d=a?l:-1;(a?d--:++d<l)&&t(e[d],d,e););return n?at(e,a?0:d,a?d+1:l):at(e,a?d+1:0,a?l:d)}function Ou(e,t){var n=e;return n instanceof ue&&(n=n.value()),Ms(t,function(a,l){return l.func.apply(l.thisArg,Gt([a],l.args))},n)}function ia(e,t,n){var a=e.length;if(a<2)return a?Ht(e[0]):[];for(var l=-1,d=b(a);++l<a;)for(var p=e[l],_=-1;++_<a;)_!=l&&(d[l]=gr(d[l]||p,e[_],t,n));return Ht(Le(d,1),t,n)}function Eu(e,t,n){for(var a=-1,l=e.length,d=t.length,p={};++a<l;){var _=a<d?t[a]:i;n(p,e[a],_)}return p}function sa(e){return Ae(e)?e:[]}function aa(e){return typeof e=="function"?e:He}function zt(e,t){return Q(e)?e:ga(e,t)?[e]:ac(de(e))}var fp=ae;function Yt(e,t,n){var a=e.length;return n=n===i?a:n,!t&&n>=a?e:at(e,t,n)}var Mu=jd||function(e){return Me.clearTimeout(e)};function Lu(e,t){if(t)return e.slice();var n=e.length,a=eu?eu(n):new e.constructor(n);return e.copy(a),a}function oa(e){var t=new e.constructor(e.byteLength);return new fi(t).set(new fi(e)),t}function dp(e,t){var n=t?oa(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function hp(e){var t=new e.constructor(e.source,mo.exec(e));return t.lastIndex=e.lastIndex,t}function pp(e){return hr?pe(hr.call(e)):{}}function Nu(e,t){var n=t?oa(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Pu(e,t){if(e!==t){var n=e!==i,a=e===null,l=e===e,d=Ke(e),p=t!==i,_=t===null,x=t===t,I=Ke(t);if(!_&&!I&&!d&&e>t||d&&p&&x&&!_&&!I||a&&p&&x||!n&&x||!l)return 1;if(!a&&!d&&!I&&e<t||I&&n&&l&&!a&&!d||_&&n&&l||!p&&l||!x)return-1}return 0}function gp(e,t,n){for(var a=-1,l=e.criteria,d=t.criteria,p=l.length,_=n.length;++a<p;){var x=Pu(l[a],d[a]);if(x){if(a>=_)return x;var I=n[a];return x*(I=="desc"?-1:1)}}return e.index-t.index}function Du(e,t,n,a){for(var l=-1,d=e.length,p=n.length,_=-1,x=t.length,I=ke(d-p,0),C=b(x+I),T=!a;++_<x;)C[_]=t[_];for(;++l<p;)(T||l<d)&&(C[n[l]]=e[l]);for(;I--;)C[_++]=e[l++];return C}function Bu(e,t,n,a){for(var l=-1,d=e.length,p=-1,_=n.length,x=-1,I=t.length,C=ke(d-_,0),T=b(C+I),N=!a;++l<C;)T[l]=e[l];for(var Z=l;++x<I;)T[Z+x]=t[x];for(;++p<_;)(N||l<d)&&(T[Z+n[p]]=e[l++]);return T}function Ue(e,t){var n=-1,a=e.length;for(t||(t=b(a));++n<a;)t[n]=e[n];return t}function wt(e,t,n,a){var l=!n;n||(n={});for(var d=-1,p=t.length;++d<p;){var _=t[d],x=a?a(n[_],e[_],_,n,e):i;x===i&&(x=e[_]),l?kt(n,_,x):pr(n,_,x)}return n}function mp(e,t){return wt(e,pa(e),t)}function _p(e,t){return wt(e,Ku(e),t)}function Ai(e,t){return function(n,a){var l=Q(n)?bd:qh,d=t?t():{};return l(n,e,H(a,2),d)}}function kn(e){return ae(function(t,n){var a=-1,l=n.length,d=l>1?n[l-1]:i,p=l>2?n[2]:i;for(d=e.length>3&&typeof d=="function"?(l--,d):i,p&&Fe(n[0],n[1],p)&&(d=l<3?i:d,l=1),t=pe(t);++a<l;){var _=n[a];_&&e(t,_,a,d)}return t})}function Fu(e,t){return function(n,a){if(n==null)return n;if(!$e(n))return e(n,a);for(var l=n.length,d=t?l:-1,p=pe(n);(t?d--:++d<l)&&a(p[d],d,p)!==!1;);return n}}function qu(e){return function(t,n,a){for(var l=-1,d=pe(t),p=a(t),_=p.length;_--;){var x=p[e?_:++l];if(n(d[x],x,d)===!1)break}return t}}function vp(e,t,n){var a=t&V,l=yr(e);function d(){var p=this&&this!==Me&&this instanceof d?l:e;return p.apply(a?n:this,arguments)}return d}function Wu(e){return function(t){t=de(t);var n=bn(t)?dt(t):i,a=n?n[0]:t.charAt(0),l=n?Yt(n,1).join(""):t.slice(1);return a[e]()+l}}function On(e){return function(t){return Ms(Fc(Bc(t).replace(ud,"")),e,"")}}function yr(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var n=Rn(e.prototype),a=e.apply(n,t);return we(a)?a:n}}function yp(e,t,n){var a=yr(e);function l(){for(var d=arguments.length,p=b(d),_=d,x=En(l);_--;)p[_]=arguments[_];var I=d<3&&p[0]!==x&&p[d-1]!==x?[]:Ut(p,x);if(d-=I.length,d<n)return Vu(e,t,Ti,l.placeholder,i,p,I,i,i,n-d);var C=this&&this!==Me&&this instanceof l?a:e;return ze(C,this,p)}return l}function Zu(e){return function(t,n,a){var l=pe(t);if(!$e(t)){var d=H(n,3);t=Oe(t),n=function(_){return d(l[_],_,l)}}var p=e(t,n,a);return p>-1?l[d?t[p]:p]:i}}function Gu(e){return Et(function(t){var n=t.length,a=n,l=it.prototype.thru;for(e&&t.reverse();a--;){var d=t[a];if(typeof d!="function")throw new rt(h);if(l&&!p&&Ei(d)=="wrapper")var p=new it([],!0)}for(a=p?a:n;++a<n;){d=t[a];var _=Ei(d),x=_=="wrapper"?da(d):i;x&&ma(x[0])&&x[1]==(Ce|re|k|Ee)&&!x[4].length&&x[9]==1?p=p[Ei(x[0])].apply(p,x[3]):p=d.length==1&&ma(d)?p[_]():p.thru(d)}return function(){var I=arguments,C=I[0];if(p&&I.length==1&&Q(C))return p.plant(C).value();for(var T=0,N=n?t[T].apply(this,I):C;++T<n;)N=t[T].call(this,N);return N}})}function Ti(e,t,n,a,l,d,p,_,x,I){var C=t&Ce,T=t&V,N=t&$,Z=t&(re|E),z=t&er,ie=N?i:yr(e);function Y(){for(var oe=arguments.length,ce=b(oe),Je=oe;Je--;)ce[Je]=arguments[Je];if(Z)var qe=En(Y),je=Ed(ce,qe);if(a&&(ce=Du(ce,a,l,Z)),d&&(ce=Bu(ce,d,p,Z)),oe-=je,Z&&oe<I){var Te=Ut(ce,qe);return Vu(e,t,Ti,Y.placeholder,n,ce,Te,_,x,I-oe)}var gt=T?n:this,Pt=N?gt[e]:e;return oe=ce.length,_?ce=qp(ce,_):z&&oe>1&&ce.reverse(),C&&x<oe&&(ce.length=x),this&&this!==Me&&this instanceof Y&&(Pt=ie||yr(Pt)),Pt.apply(gt,ce)}return Y}function Uu(e,t){return function(n,a){return zh(n,e,t(a),{})}}function Ri(e,t){return function(n,a){var l;if(n===i&&a===i)return t;if(n!==i&&(l=n),a!==i){if(l===i)return a;typeof n=="string"||typeof a=="string"?(n=Xe(n),a=Xe(a)):(n=Ru(n),a=Ru(a)),l=e(n,a)}return l}}function ua(e){return Et(function(t){return t=xe(t,Ye(H())),ae(function(n){var a=this;return e(t,function(l){return ze(l,a,n)})})})}function ki(e,t){t=t===i?" ":Xe(t);var n=t.length;if(n<2)return n?ta(t,e):t;var a=ta(t,gi(e/Sn(t)));return bn(t)?Yt(dt(a),0,e).join(""):a.slice(0,e)}function xp(e,t,n,a){var l=t&V,d=yr(e);function p(){for(var _=-1,x=arguments.length,I=-1,C=a.length,T=b(C+x),N=this&&this!==Me&&this instanceof p?d:e;++I<C;)T[I]=a[I];for(;x--;)T[I++]=arguments[++_];return ze(N,l?n:this,T)}return p}function $u(e){return function(t,n,a){return a&&typeof a!="number"&&Fe(t,n,a)&&(n=a=i),t=Nt(t),n===i?(n=t,t=0):n=Nt(n),a=a===i?t<n?1:-1:Nt(a),sp(t,n,a,e)}}function Oi(e){return function(t,n){return typeof t=="string"&&typeof n=="string"||(t=ut(t),n=ut(n)),e(t,n)}}function Vu(e,t,n,a,l,d,p,_,x,I){var C=t&re,T=C?p:i,N=C?i:p,Z=C?d:i,z=C?i:d;t|=C?k:me,t&=~(C?me:k),t&te||(t&=-4);var ie=[e,t,l,Z,T,z,N,_,x,I],Y=n.apply(i,ie);return ma(e)&&rc(Y,ie),Y.placeholder=a,ic(Y,e,t)}function ca(e){var t=Re[e];return function(n,a){if(n=ut(n),a=a==null?0:Ne(ne(a),292),a&&iu(n)){var l=(de(n)+"e").split("e"),d=t(l[0]+"e"+(+l[1]+a));return l=(de(d)+"e").split("e"),+(l[0]+"e"+(+l[1]-a))}return t(n)}}var wp=An&&1/si(new An([,-0]))[1]==en?function(e){return new An(e)}:Ea;function Hu(e){return function(t){var n=Pe(t);return n==lt?qs(t):n==ft?Fd(t):Od(t,e(t))}}function Ot(e,t,n,a,l,d,p,_){var x=t&$;if(!x&&typeof e!="function")throw new rt(h);var I=a?a.length:0;if(I||(t&=-97,a=l=i),p=p===i?p:ke(ne(p),0),_=_===i?_:ne(_),I-=l?l.length:0,t&me){var C=a,T=l;a=l=i}var N=x?i:da(e),Z=[e,t,n,a,l,C,T,d,p,_];if(N&&Dp(Z,N),e=Z[0],t=Z[1],n=Z[2],a=Z[3],l=Z[4],_=Z[9]=Z[9]===i?x?0:e.length:ke(Z[9]-I,0),!_&&t&(re|E)&&(t&=-25),!t||t==V)var z=vp(e,t,n);else t==re||t==E?z=yp(e,t,_):(t==k||t==(V|k))&&!l.length?z=xp(e,t,n,a):z=Ti.apply(i,Z);var ie=N?Au:rc;return ic(ie(z,Z),e,t)}function zu(e,t,n,a){return e===i||pt(e,Cn[n])&&!he.call(a,n)?t:e}function Yu(e,t,n,a,l,d){return we(e)&&we(t)&&(d.set(t,e),Si(e,t,i,Yu,d),d.delete(t)),e}function bp(e){return br(e)?i:e}function Xu(e,t,n,a,l,d){var p=n&M,_=e.length,x=t.length;if(_!=x&&!(p&&x>_))return!1;var I=d.get(e),C=d.get(t);if(I&&C)return I==t&&C==e;var T=-1,N=!0,Z=n&L?new sn:i;for(d.set(e,t),d.set(t,e);++T<_;){var z=e[T],ie=t[T];if(a)var Y=p?a(ie,z,T,t,e,d):a(z,ie,T,e,t,d);if(Y!==i){if(Y)continue;N=!1;break}if(Z){if(!Ls(t,function(oe,ce){if(!ur(Z,ce)&&(z===oe||l(z,oe,n,a,d)))return Z.push(ce)})){N=!1;break}}else if(!(z===ie||l(z,ie,n,a,d))){N=!1;break}}return d.delete(e),d.delete(t),N}function Sp(e,t,n,a,l,d,p){switch(n){case yn:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case or:return!(e.byteLength!=t.byteLength||!d(new fi(e),new fi(t)));case tr:case nr:case rr:return pt(+e,+t);case Jr:return e.name==t.name&&e.message==t.message;case ir:case sr:return e==t+"";case lt:var _=qs;case ft:var x=a&M;if(_||(_=si),e.size!=t.size&&!x)return!1;var I=p.get(e);if(I)return I==t;a|=L,p.set(e,t);var C=Xu(_(e),_(t),a,l,d,p);return p.delete(e),C;case Qr:if(hr)return hr.call(e)==hr.call(t)}return!1}function Ip(e,t,n,a,l,d){var p=n&M,_=la(e),x=_.length,I=la(t),C=I.length;if(x!=C&&!p)return!1;for(var T=x;T--;){var N=_[T];if(!(p?N in t:he.call(t,N)))return!1}var Z=d.get(e),z=d.get(t);if(Z&&z)return Z==t&&z==e;var ie=!0;d.set(e,t),d.set(t,e);for(var Y=p;++T<x;){N=_[T];var oe=e[N],ce=t[N];if(a)var Je=p?a(ce,oe,N,t,e,d):a(oe,ce,N,e,t,d);if(!(Je===i?oe===ce||l(oe,ce,n,a,d):Je)){ie=!1;break}Y||(Y=N=="constructor")}if(ie&&!Y){var qe=e.constructor,je=t.constructor;qe!=je&&"constructor"in e&&"constructor"in t&&!(typeof qe=="function"&&qe instanceof qe&&typeof je=="function"&&je instanceof je)&&(ie=!1)}return d.delete(e),d.delete(t),ie}function Et(e){return va(tc(e,i,lc),e+"")}function la(e){return gu(e,Oe,pa)}function fa(e){return gu(e,Ve,Ku)}var da=_i?function(e){return _i.get(e)}:Ea;function Ei(e){for(var t=e.name+"",n=Tn[t],a=he.call(Tn,t)?n.length:0;a--;){var l=n[a],d=l.func;if(d==null||d==e)return l.name}return t}function En(e){var t=he.call(f,"placeholder")?f:e;return t.placeholder}function H(){var e=f.iteratee||ka;return e=e===ka?vu:e,arguments.length?e(arguments[0],arguments[1]):e}function Mi(e,t){var n=e.__data__;return Mp(t)?n[typeof t=="string"?"string":"hash"]:n.map}function ha(e){for(var t=Oe(e),n=t.length;n--;){var a=t[n],l=e[a];t[n]=[a,l,Qu(l)]}return t}function un(e,t){var n=Pd(e,t);return _u(n)?n:i}function Cp(e){var t=he.call(e,nn),n=e[nn];try{e[nn]=i;var a=!0}catch{}var l=ci.call(e);return a&&(t?e[nn]=n:delete e[nn]),l}var pa=Zs?function(e){return e==null?[]:(e=pe(e),Zt(Zs(e),function(t){return nu.call(e,t)}))}:Ma,Ku=Zs?function(e){for(var t=[];e;)Gt(t,pa(e)),e=di(e);return t}:Ma,Pe=Be;(Gs&&Pe(new Gs(new ArrayBuffer(1)))!=yn||lr&&Pe(new lr)!=lt||Us&&Pe(Us.resolve())!=fo||An&&Pe(new An)!=ft||fr&&Pe(new fr)!=ar)&&(Pe=function(e){var t=Be(e),n=t==At?e.constructor:i,a=n?cn(n):"";if(a)switch(a){case oh:return yn;case uh:return lt;case ch:return fo;case lh:return ft;case fh:return ar}return t});function Ap(e,t,n){for(var a=-1,l=n.length;++a<l;){var d=n[a],p=d.size;switch(d.type){case"drop":e+=p;break;case"dropRight":t-=p;break;case"take":t=Ne(t,e+p);break;case"takeRight":e=ke(e,t-p);break}}return{start:e,end:t}}function Tp(e){var t=e.match(Lf);return t?t[1].split(Nf):[]}function Ju(e,t,n){t=zt(t,e);for(var a=-1,l=t.length,d=!1;++a<l;){var p=bt(t[a]);if(!(d=e!=null&&n(e,p)))break;e=e[p]}return d||++a!=l?d:(l=e==null?0:e.length,!!l&&qi(l)&&Mt(p,l)&&(Q(e)||ln(e)))}function Rp(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&he.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function ju(e){return typeof e.constructor=="function"&&!xr(e)?Rn(di(e)):{}}function kp(e,t,n){var a=e.constructor;switch(t){case or:return oa(e);case tr:case nr:return new a(+e);case yn:return dp(e,n);case hs:case ps:case gs:case ms:case _s:case vs:case ys:case xs:case ws:return Nu(e,n);case lt:return new a;case rr:case sr:return new a(e);case ir:return hp(e);case ft:return new a;case Qr:return pp(e)}}function Op(e,t){var n=t.length;if(!n)return e;var a=n-1;return t[a]=(n>1?"& ":"")+t[a],t=t.join(n>2?", ":" "),e.replace(Mf,`{
2
+ /* [wrapped with `+t+`] */
3
+ `)}function Ep(e){return Q(e)||ln(e)||!!(ru&&e&&e[ru])}function Mt(e,t){var n=typeof e;return t=t??Wt,!!t&&(n=="number"||n!="symbol"&&Uf.test(e))&&e>-1&&e%1==0&&e<t}function Fe(e,t,n){if(!we(n))return!1;var a=typeof t;return(a=="number"?$e(n)&&Mt(t,n.length):a=="string"&&t in n)?pt(n[t],e):!1}function ga(e,t){if(Q(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ke(e)?!0:Rf.test(e)||!Tf.test(e)||t!=null&&e in pe(t)}function Mp(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function ma(e){var t=Ei(e),n=f[t];if(typeof n!="function"||!(t in ue.prototype))return!1;if(e===n)return!0;var a=da(n);return!!a&&e===a[0]}function Lp(e){return!!Qo&&Qo in e}var Np=oi?Lt:La;function xr(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Cn;return e===n}function Qu(e){return e===e&&!we(e)}function ec(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==i||e in pe(n))}}function Pp(e){var t=Bi(e,function(a){return n.size===v&&n.clear(),a}),n=t.cache;return t}function Dp(e,t){var n=e[1],a=t[1],l=n|a,d=l<(V|$|Ce),p=a==Ce&&n==re||a==Ce&&n==Ee&&e[7].length<=t[8]||a==(Ce|Ee)&&t[7].length<=t[8]&&n==re;if(!(d||p))return e;a&V&&(e[2]=t[2],l|=n&V?0:te);var _=t[3];if(_){var x=e[3];e[3]=x?Du(x,_,t[4]):_,e[4]=x?Ut(e[3],w):t[4]}return _=t[5],_&&(x=e[5],e[5]=x?Bu(x,_,t[6]):_,e[6]=x?Ut(e[5],w):t[6]),_=t[7],_&&(e[7]=_),a&Ce&&(e[8]=e[8]==null?t[8]:Ne(e[8],t[8])),e[9]==null&&(e[9]=t[9]),e[0]=t[0],e[1]=l,e}function Bp(e){var t=[];if(e!=null)for(var n in pe(e))t.push(n);return t}function Fp(e){return ci.call(e)}function tc(e,t,n){return t=ke(t===i?e.length-1:t,0),function(){for(var a=arguments,l=-1,d=ke(a.length-t,0),p=b(d);++l<d;)p[l]=a[t+l];l=-1;for(var _=b(t+1);++l<t;)_[l]=a[l];return _[t]=n(p),ze(e,this,_)}}function nc(e,t){return t.length<2?e:on(e,at(t,0,-1))}function qp(e,t){for(var n=e.length,a=Ne(t.length,n),l=Ue(e);a--;){var d=t[a];e[a]=Mt(d,n)?l[d]:i}return e}function _a(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}var rc=sc(Au),wr=eh||function(e,t){return Me.setTimeout(e,t)},va=sc(up);function ic(e,t,n){var a=t+"";return va(e,Op(a,Wp(Tp(a),n)))}function sc(e){var t=0,n=0;return function(){var a=ih(),l=of-(a-n);if(n=a,l>0){if(++t>=af)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Li(e,t){var n=-1,a=e.length,l=a-1;for(t=t===i?a:t;++n<t;){var d=ea(n,l),p=e[d];e[d]=e[n],e[n]=p}return e.length=t,e}var ac=Pp(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(kf,function(n,a,l,d){t.push(l?d.replace(Bf,"$1"):a||n)}),t});function bt(e){if(typeof e=="string"||Ke(e))return e;var t=e+"";return t=="0"&&1/e==-en?"-0":t}function cn(e){if(e!=null){try{return ui.call(e)}catch{}try{return e+""}catch{}}return""}function Wp(e,t){return nt(hf,function(n){var a="_."+n[0];t&n[1]&&!ri(e,a)&&e.push(a)}),e.sort()}function oc(e){if(e instanceof ue)return e.clone();var t=new it(e.__wrapped__,e.__chain__);return t.__actions__=Ue(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}function Zp(e,t,n){(n?Fe(e,t,n):t===i)?t=1:t=ke(ne(t),0);var a=e==null?0:e.length;if(!a||t<1)return[];for(var l=0,d=0,p=b(gi(a/t));l<a;)p[d++]=at(e,l,l+=t);return p}function Gp(e){for(var t=-1,n=e==null?0:e.length,a=0,l=[];++t<n;){var d=e[t];d&&(l[a++]=d)}return l}function Up(){var e=arguments.length;if(!e)return[];for(var t=b(e-1),n=arguments[0],a=e;a--;)t[a-1]=arguments[a];return Gt(Q(n)?Ue(n):[n],Le(t,1))}var $p=ae(function(e,t){return Ae(e)?gr(e,Le(t,1,Ae,!0)):[]}),Vp=ae(function(e,t){var n=ot(t);return Ae(n)&&(n=i),Ae(e)?gr(e,Le(t,1,Ae,!0),H(n,2)):[]}),Hp=ae(function(e,t){var n=ot(t);return Ae(n)&&(n=i),Ae(e)?gr(e,Le(t,1,Ae,!0),i,n):[]});function zp(e,t,n){var a=e==null?0:e.length;return a?(t=n||t===i?1:ne(t),at(e,t<0?0:t,a)):[]}function Yp(e,t,n){var a=e==null?0:e.length;return a?(t=n||t===i?1:ne(t),t=a-t,at(e,0,t<0?0:t)):[]}function Xp(e,t){return e&&e.length?Ci(e,H(t,3),!0,!0):[]}function Kp(e,t){return e&&e.length?Ci(e,H(t,3),!0):[]}function Jp(e,t,n,a){var l=e==null?0:e.length;return l?(n&&typeof n!="number"&&Fe(e,t,n)&&(n=0,a=l),Uh(e,t,n,a)):[]}function uc(e,t,n){var a=e==null?0:e.length;if(!a)return-1;var l=n==null?0:ne(n);return l<0&&(l=ke(a+l,0)),ii(e,H(t,3),l)}function cc(e,t,n){var a=e==null?0:e.length;if(!a)return-1;var l=a-1;return n!==i&&(l=ne(n),l=n<0?ke(a+l,0):Ne(l,a-1)),ii(e,H(t,3),l,!0)}function lc(e){var t=e==null?0:e.length;return t?Le(e,1):[]}function jp(e){var t=e==null?0:e.length;return t?Le(e,en):[]}function Qp(e,t){var n=e==null?0:e.length;return n?(t=t===i?1:ne(t),Le(e,t)):[]}function eg(e){for(var t=-1,n=e==null?0:e.length,a={};++t<n;){var l=e[t];a[l[0]]=l[1]}return a}function fc(e){return e&&e.length?e[0]:i}function tg(e,t,n){var a=e==null?0:e.length;if(!a)return-1;var l=n==null?0:ne(n);return l<0&&(l=ke(a+l,0)),wn(e,t,l)}function ng(e){var t=e==null?0:e.length;return t?at(e,0,-1):[]}var rg=ae(function(e){var t=xe(e,sa);return t.length&&t[0]===e[0]?Xs(t):[]}),ig=ae(function(e){var t=ot(e),n=xe(e,sa);return t===ot(n)?t=i:n.pop(),n.length&&n[0]===e[0]?Xs(n,H(t,2)):[]}),sg=ae(function(e){var t=ot(e),n=xe(e,sa);return t=typeof t=="function"?t:i,t&&n.pop(),n.length&&n[0]===e[0]?Xs(n,i,t):[]});function ag(e,t){return e==null?"":nh.call(e,t)}function ot(e){var t=e==null?0:e.length;return t?e[t-1]:i}function og(e,t,n){var a=e==null?0:e.length;if(!a)return-1;var l=a;return n!==i&&(l=ne(n),l=l<0?ke(a+l,0):Ne(l,a-1)),t===t?Wd(e,t,l):ii(e,Vo,l,!0)}function ug(e,t){return e&&e.length?bu(e,ne(t)):i}var cg=ae(dc);function dc(e,t){return e&&e.length&&t&&t.length?Qs(e,t):e}function lg(e,t,n){return e&&e.length&&t&&t.length?Qs(e,t,H(n,2)):e}function fg(e,t,n){return e&&e.length&&t&&t.length?Qs(e,t,i,n):e}var dg=Et(function(e,t){var n=e==null?0:e.length,a=Vs(e,t);return Cu(e,xe(t,function(l){return Mt(l,n)?+l:l}).sort(Pu)),a});function hg(e,t){var n=[];if(!(e&&e.length))return n;var a=-1,l=[],d=e.length;for(t=H(t,3);++a<d;){var p=e[a];t(p,a,e)&&(n.push(p),l.push(a))}return Cu(e,l),n}function ya(e){return e==null?e:ah.call(e)}function pg(e,t,n){var a=e==null?0:e.length;return a?(n&&typeof n!="number"&&Fe(e,t,n)?(t=0,n=a):(t=t==null?0:ne(t),n=n===i?a:ne(n)),at(e,t,n)):[]}function gg(e,t){return Ii(e,t)}function mg(e,t,n){return na(e,t,H(n,2))}function _g(e,t){var n=e==null?0:e.length;if(n){var a=Ii(e,t);if(a<n&&pt(e[a],t))return a}return-1}function vg(e,t){return Ii(e,t,!0)}function yg(e,t,n){return na(e,t,H(n,2),!0)}function xg(e,t){var n=e==null?0:e.length;if(n){var a=Ii(e,t,!0)-1;if(pt(e[a],t))return a}return-1}function wg(e){return e&&e.length?Tu(e):[]}function bg(e,t){return e&&e.length?Tu(e,H(t,2)):[]}function Sg(e){var t=e==null?0:e.length;return t?at(e,1,t):[]}function Ig(e,t,n){return e&&e.length?(t=n||t===i?1:ne(t),at(e,0,t<0?0:t)):[]}function Cg(e,t,n){var a=e==null?0:e.length;return a?(t=n||t===i?1:ne(t),t=a-t,at(e,t<0?0:t,a)):[]}function Ag(e,t){return e&&e.length?Ci(e,H(t,3),!1,!0):[]}function Tg(e,t){return e&&e.length?Ci(e,H(t,3)):[]}var Rg=ae(function(e){return Ht(Le(e,1,Ae,!0))}),kg=ae(function(e){var t=ot(e);return Ae(t)&&(t=i),Ht(Le(e,1,Ae,!0),H(t,2))}),Og=ae(function(e){var t=ot(e);return t=typeof t=="function"?t:i,Ht(Le(e,1,Ae,!0),i,t)});function Eg(e){return e&&e.length?Ht(e):[]}function Mg(e,t){return e&&e.length?Ht(e,H(t,2)):[]}function Lg(e,t){return t=typeof t=="function"?t:i,e&&e.length?Ht(e,i,t):[]}function xa(e){if(!(e&&e.length))return[];var t=0;return e=Zt(e,function(n){if(Ae(n))return t=ke(n.length,t),!0}),Bs(t,function(n){return xe(e,Ns(n))})}function hc(e,t){if(!(e&&e.length))return[];var n=xa(e);return t==null?n:xe(n,function(a){return ze(t,i,a)})}var Ng=ae(function(e,t){return Ae(e)?gr(e,t):[]}),Pg=ae(function(e){return ia(Zt(e,Ae))}),Dg=ae(function(e){var t=ot(e);return Ae(t)&&(t=i),ia(Zt(e,Ae),H(t,2))}),Bg=ae(function(e){var t=ot(e);return t=typeof t=="function"?t:i,ia(Zt(e,Ae),i,t)}),Fg=ae(xa);function qg(e,t){return Eu(e||[],t||[],pr)}function Wg(e,t){return Eu(e||[],t||[],vr)}var Zg=ae(function(e){var t=e.length,n=t>1?e[t-1]:i;return n=typeof n=="function"?(e.pop(),n):i,hc(e,n)});function pc(e){var t=f(e);return t.__chain__=!0,t}function Gg(e,t){return t(e),e}function Ni(e,t){return t(e)}var Ug=Et(function(e){var t=e.length,n=t?e[0]:0,a=this.__wrapped__,l=function(d){return Vs(d,e)};return t>1||this.__actions__.length||!(a instanceof ue)||!Mt(n)?this.thru(l):(a=a.slice(n,+n+(t?1:0)),a.__actions__.push({func:Ni,args:[l],thisArg:i}),new it(a,this.__chain__).thru(function(d){return t&&!d.length&&d.push(i),d}))});function $g(){return pc(this)}function Vg(){return new it(this.value(),this.__chain__)}function Hg(){this.__values__===i&&(this.__values__=Rc(this.value()));var e=this.__index__>=this.__values__.length,t=e?i:this.__values__[this.__index__++];return{done:e,value:t}}function zg(){return this}function Yg(e){for(var t,n=this;n instanceof yi;){var a=oc(n);a.__index__=0,a.__values__=i,t?l.__wrapped__=a:t=a;var l=a;n=n.__wrapped__}return l.__wrapped__=e,t}function Xg(){var e=this.__wrapped__;if(e instanceof ue){var t=e;return this.__actions__.length&&(t=new ue(this)),t=t.reverse(),t.__actions__.push({func:Ni,args:[ya],thisArg:i}),new it(t,this.__chain__)}return this.thru(ya)}function Kg(){return Ou(this.__wrapped__,this.__actions__)}var Jg=Ai(function(e,t,n){he.call(e,n)?++e[n]:kt(e,n,1)});function jg(e,t,n){var a=Q(e)?Uo:Gh;return n&&Fe(e,t,n)&&(t=i),a(e,H(t,3))}function Qg(e,t){var n=Q(e)?Zt:hu;return n(e,H(t,3))}var em=Zu(uc),tm=Zu(cc);function nm(e,t){return Le(Pi(e,t),1)}function rm(e,t){return Le(Pi(e,t),en)}function im(e,t,n){return n=n===i?1:ne(n),Le(Pi(e,t),n)}function gc(e,t){var n=Q(e)?nt:Vt;return n(e,H(t,3))}function mc(e,t){var n=Q(e)?Sd:du;return n(e,H(t,3))}var sm=Ai(function(e,t,n){he.call(e,n)?e[n].push(t):kt(e,n,[t])});function am(e,t,n,a){e=$e(e)?e:Ln(e),n=n&&!a?ne(n):0;var l=e.length;return n<0&&(n=ke(l+n,0)),Wi(e)?n<=l&&e.indexOf(t,n)>-1:!!l&&wn(e,t,n)>-1}var om=ae(function(e,t,n){var a=-1,l=typeof t=="function",d=$e(e)?b(e.length):[];return Vt(e,function(p){d[++a]=l?ze(t,p,n):mr(p,t,n)}),d}),um=Ai(function(e,t,n){kt(e,n,t)});function Pi(e,t){var n=Q(e)?xe:yu;return n(e,H(t,3))}function cm(e,t,n,a){return e==null?[]:(Q(t)||(t=t==null?[]:[t]),n=a?i:n,Q(n)||(n=n==null?[]:[n]),Su(e,t,n))}var lm=Ai(function(e,t,n){e[n?0:1].push(t)},function(){return[[],[]]});function fm(e,t,n){var a=Q(e)?Ms:zo,l=arguments.length<3;return a(e,H(t,4),n,l,Vt)}function dm(e,t,n){var a=Q(e)?Id:zo,l=arguments.length<3;return a(e,H(t,4),n,l,du)}function hm(e,t){var n=Q(e)?Zt:hu;return n(e,Fi(H(t,3)))}function pm(e){var t=Q(e)?uu:ap;return t(e)}function gm(e,t,n){(n?Fe(e,t,n):t===i)?t=1:t=ne(t);var a=Q(e)?Bh:op;return a(e,t)}function mm(e){var t=Q(e)?Fh:cp;return t(e)}function _m(e){if(e==null)return 0;if($e(e))return Wi(e)?Sn(e):e.length;var t=Pe(e);return t==lt||t==ft?e.size:Js(e).length}function vm(e,t,n){var a=Q(e)?Ls:lp;return n&&Fe(e,t,n)&&(t=i),a(e,H(t,3))}var ym=ae(function(e,t){if(e==null)return[];var n=t.length;return n>1&&Fe(e,t[0],t[1])?t=[]:n>2&&Fe(t[0],t[1],t[2])&&(t=[t[0]]),Su(e,Le(t,1),[])}),Di=Qd||function(){return Me.Date.now()};function xm(e,t){if(typeof t!="function")throw new rt(h);return e=ne(e),function(){if(--e<1)return t.apply(this,arguments)}}function _c(e,t,n){return t=n?i:t,t=e&&t==null?e.length:t,Ot(e,Ce,i,i,i,i,t)}function vc(e,t){var n;if(typeof t!="function")throw new rt(h);return e=ne(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var wa=ae(function(e,t,n){var a=V;if(n.length){var l=Ut(n,En(wa));a|=k}return Ot(e,a,t,n,l)}),yc=ae(function(e,t,n){var a=V|$;if(n.length){var l=Ut(n,En(yc));a|=k}return Ot(t,a,e,n,l)});function xc(e,t,n){t=n?i:t;var a=Ot(e,re,i,i,i,i,i,t);return a.placeholder=xc.placeholder,a}function wc(e,t,n){t=n?i:t;var a=Ot(e,E,i,i,i,i,i,t);return a.placeholder=wc.placeholder,a}function bc(e,t,n){var a,l,d,p,_,x,I=0,C=!1,T=!1,N=!0;if(typeof e!="function")throw new rt(h);t=ut(t)||0,we(n)&&(C=!!n.leading,T="maxWait"in n,d=T?ke(ut(n.maxWait)||0,t):d,N="trailing"in n?!!n.trailing:N);function Z(Te){var gt=a,Pt=l;return a=l=i,I=Te,p=e.apply(Pt,gt),p}function z(Te){return I=Te,_=wr(oe,t),C?Z(Te):p}function ie(Te){var gt=Te-x,Pt=Te-I,Zc=t-gt;return T?Ne(Zc,d-Pt):Zc}function Y(Te){var gt=Te-x,Pt=Te-I;return x===i||gt>=t||gt<0||T&&Pt>=d}function oe(){var Te=Di();if(Y(Te))return ce(Te);_=wr(oe,ie(Te))}function ce(Te){return _=i,N&&a?Z(Te):(a=l=i,p)}function Je(){_!==i&&Mu(_),I=0,a=x=l=_=i}function qe(){return _===i?p:ce(Di())}function je(){var Te=Di(),gt=Y(Te);if(a=arguments,l=this,x=Te,gt){if(_===i)return z(x);if(T)return Mu(_),_=wr(oe,t),Z(x)}return _===i&&(_=wr(oe,t)),p}return je.cancel=Je,je.flush=qe,je}var wm=ae(function(e,t){return fu(e,1,t)}),bm=ae(function(e,t,n){return fu(e,ut(t)||0,n)});function Sm(e){return Ot(e,er)}function Bi(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new rt(h);var n=function(){var a=arguments,l=t?t.apply(this,a):a[0],d=n.cache;if(d.has(l))return d.get(l);var p=e.apply(this,a);return n.cache=d.set(l,p)||d,p};return n.cache=new(Bi.Cache||Rt),n}Bi.Cache=Rt;function Fi(e){if(typeof e!="function")throw new rt(h);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}function Im(e){return vc(2,e)}var Cm=fp(function(e,t){t=t.length==1&&Q(t[0])?xe(t[0],Ye(H())):xe(Le(t,1),Ye(H()));var n=t.length;return ae(function(a){for(var l=-1,d=Ne(a.length,n);++l<d;)a[l]=t[l].call(this,a[l]);return ze(e,this,a)})}),ba=ae(function(e,t){var n=Ut(t,En(ba));return Ot(e,k,i,t,n)}),Sc=ae(function(e,t){var n=Ut(t,En(Sc));return Ot(e,me,i,t,n)}),Am=Et(function(e,t){return Ot(e,Ee,i,i,i,t)});function Tm(e,t){if(typeof e!="function")throw new rt(h);return t=t===i?t:ne(t),ae(e,t)}function Rm(e,t){if(typeof e!="function")throw new rt(h);return t=t==null?0:ke(ne(t),0),ae(function(n){var a=n[t],l=Yt(n,0,t);return a&&Gt(l,a),ze(e,this,l)})}function km(e,t,n){var a=!0,l=!0;if(typeof e!="function")throw new rt(h);return we(n)&&(a="leading"in n?!!n.leading:a,l="trailing"in n?!!n.trailing:l),bc(e,t,{leading:a,maxWait:t,trailing:l})}function Om(e){return _c(e,1)}function Em(e,t){return ba(aa(t),e)}function Mm(){if(!arguments.length)return[];var e=arguments[0];return Q(e)?e:[e]}function Lm(e){return st(e,W)}function Nm(e,t){return t=typeof t=="function"?t:i,st(e,W,t)}function Pm(e){return st(e,R|W)}function Dm(e,t){return t=typeof t=="function"?t:i,st(e,R|W,t)}function Bm(e,t){return t==null||lu(e,t,Oe(t))}function pt(e,t){return e===t||e!==e&&t!==t}var Fm=Oi(Ys),qm=Oi(function(e,t){return e>=t}),ln=mu((function(){return arguments})())?mu:function(e){return Se(e)&&he.call(e,"callee")&&!nu.call(e,"callee")},Q=b.isArray,Wm=Bo?Ye(Bo):Yh;function $e(e){return e!=null&&qi(e.length)&&!Lt(e)}function Ae(e){return Se(e)&&$e(e)}function Zm(e){return e===!0||e===!1||Se(e)&&Be(e)==tr}var Xt=th||La,Gm=Fo?Ye(Fo):Xh;function Um(e){return Se(e)&&e.nodeType===1&&!br(e)}function $m(e){if(e==null)return!0;if($e(e)&&(Q(e)||typeof e=="string"||typeof e.splice=="function"||Xt(e)||Mn(e)||ln(e)))return!e.length;var t=Pe(e);if(t==lt||t==ft)return!e.size;if(xr(e))return!Js(e).length;for(var n in e)if(he.call(e,n))return!1;return!0}function Vm(e,t){return _r(e,t)}function Hm(e,t,n){n=typeof n=="function"?n:i;var a=n?n(e,t):i;return a===i?_r(e,t,i,n):!!a}function Sa(e){if(!Se(e))return!1;var t=Be(e);return t==Jr||t==gf||typeof e.message=="string"&&typeof e.name=="string"&&!br(e)}function zm(e){return typeof e=="number"&&iu(e)}function Lt(e){if(!we(e))return!1;var t=Be(e);return t==jr||t==lo||t==pf||t==_f}function Ic(e){return typeof e=="number"&&e==ne(e)}function qi(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Wt}function we(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function Se(e){return e!=null&&typeof e=="object"}var Cc=qo?Ye(qo):Jh;function Ym(e,t){return e===t||Ks(e,t,ha(t))}function Xm(e,t,n){return n=typeof n=="function"?n:i,Ks(e,t,ha(t),n)}function Km(e){return Ac(e)&&e!=+e}function Jm(e){if(Np(e))throw new j(c);return _u(e)}function jm(e){return e===null}function Qm(e){return e==null}function Ac(e){return typeof e=="number"||Se(e)&&Be(e)==rr}function br(e){if(!Se(e)||Be(e)!=At)return!1;var t=di(e);if(t===null)return!0;var n=he.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&ui.call(n)==Xd}var Ia=Wo?Ye(Wo):jh;function e_(e){return Ic(e)&&e>=-Wt&&e<=Wt}var Tc=Zo?Ye(Zo):Qh;function Wi(e){return typeof e=="string"||!Q(e)&&Se(e)&&Be(e)==sr}function Ke(e){return typeof e=="symbol"||Se(e)&&Be(e)==Qr}var Mn=Go?Ye(Go):ep;function t_(e){return e===i}function n_(e){return Se(e)&&Pe(e)==ar}function r_(e){return Se(e)&&Be(e)==yf}var i_=Oi(js),s_=Oi(function(e,t){return e<=t});function Rc(e){if(!e)return[];if($e(e))return Wi(e)?dt(e):Ue(e);if(cr&&e[cr])return Bd(e[cr]());var t=Pe(e),n=t==lt?qs:t==ft?si:Ln;return n(e)}function Nt(e){if(!e)return e===0?e:0;if(e=ut(e),e===en||e===-en){var t=e<0?-1:1;return t*lf}return e===e?e:0}function ne(e){var t=Nt(e),n=t%1;return t===t?n?t-n:t:0}function kc(e){return e?an(ne(e),0,yt):0}function ut(e){if(typeof e=="number")return e;if(Ke(e))return Xr;if(we(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=we(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Yo(e);var n=Wf.test(e);return n||Gf.test(e)?xd(e.slice(2),n?2:8):qf.test(e)?Xr:+e}function Oc(e){return wt(e,Ve(e))}function a_(e){return e?an(ne(e),-Wt,Wt):e===0?e:0}function de(e){return e==null?"":Xe(e)}var o_=kn(function(e,t){if(xr(t)||$e(t)){wt(t,Oe(t),e);return}for(var n in t)he.call(t,n)&&pr(e,n,t[n])}),Ec=kn(function(e,t){wt(t,Ve(t),e)}),Zi=kn(function(e,t,n,a){wt(t,Ve(t),e,a)}),u_=kn(function(e,t,n,a){wt(t,Oe(t),e,a)}),c_=Et(Vs);function l_(e,t){var n=Rn(e);return t==null?n:cu(n,t)}var f_=ae(function(e,t){e=pe(e);var n=-1,a=t.length,l=a>2?t[2]:i;for(l&&Fe(t[0],t[1],l)&&(a=1);++n<a;)for(var d=t[n],p=Ve(d),_=-1,x=p.length;++_<x;){var I=p[_],C=e[I];(C===i||pt(C,Cn[I])&&!he.call(e,I))&&(e[I]=d[I])}return e}),d_=ae(function(e){return e.push(i,Yu),ze(Mc,i,e)});function h_(e,t){return $o(e,H(t,3),xt)}function p_(e,t){return $o(e,H(t,3),zs)}function g_(e,t){return e==null?e:Hs(e,H(t,3),Ve)}function m_(e,t){return e==null?e:pu(e,H(t,3),Ve)}function __(e,t){return e&&xt(e,H(t,3))}function v_(e,t){return e&&zs(e,H(t,3))}function y_(e){return e==null?[]:bi(e,Oe(e))}function x_(e){return e==null?[]:bi(e,Ve(e))}function Ca(e,t,n){var a=e==null?i:on(e,t);return a===i?n:a}function w_(e,t){return e!=null&&Ju(e,t,$h)}function Aa(e,t){return e!=null&&Ju(e,t,Vh)}var b_=Uu(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=ci.call(t)),e[t]=n},Ra(He)),S_=Uu(function(e,t,n){t!=null&&typeof t.toString!="function"&&(t=ci.call(t)),he.call(e,t)?e[t].push(n):e[t]=[n]},H),I_=ae(mr);function Oe(e){return $e(e)?ou(e):Js(e)}function Ve(e){return $e(e)?ou(e,!0):tp(e)}function C_(e,t){var n={};return t=H(t,3),xt(e,function(a,l,d){kt(n,t(a,l,d),a)}),n}function A_(e,t){var n={};return t=H(t,3),xt(e,function(a,l,d){kt(n,l,t(a,l,d))}),n}var T_=kn(function(e,t,n){Si(e,t,n)}),Mc=kn(function(e,t,n,a){Si(e,t,n,a)}),R_=Et(function(e,t){var n={};if(e==null)return n;var a=!1;t=xe(t,function(d){return d=zt(d,e),a||(a=d.length>1),d}),wt(e,fa(e),n),a&&(n=st(n,R|F|W,bp));for(var l=t.length;l--;)ra(n,t[l]);return n});function k_(e,t){return Lc(e,Fi(H(t)))}var O_=Et(function(e,t){return e==null?{}:rp(e,t)});function Lc(e,t){if(e==null)return{};var n=xe(fa(e),function(a){return[a]});return t=H(t),Iu(e,n,function(a,l){return t(a,l[0])})}function E_(e,t,n){t=zt(t,e);var a=-1,l=t.length;for(l||(l=1,e=i);++a<l;){var d=e==null?i:e[bt(t[a])];d===i&&(a=l,d=n),e=Lt(d)?d.call(e):d}return e}function M_(e,t,n){return e==null?e:vr(e,t,n)}function L_(e,t,n,a){return a=typeof a=="function"?a:i,e==null?e:vr(e,t,n,a)}var Nc=Hu(Oe),Pc=Hu(Ve);function N_(e,t,n){var a=Q(e),l=a||Xt(e)||Mn(e);if(t=H(t,4),n==null){var d=e&&e.constructor;l?n=a?new d:[]:we(e)?n=Lt(d)?Rn(di(e)):{}:n={}}return(l?nt:xt)(e,function(p,_,x){return t(n,p,_,x)}),n}function P_(e,t){return e==null?!0:ra(e,t)}function D_(e,t,n){return e==null?e:ku(e,t,aa(n))}function B_(e,t,n,a){return a=typeof a=="function"?a:i,e==null?e:ku(e,t,aa(n),a)}function Ln(e){return e==null?[]:Fs(e,Oe(e))}function F_(e){return e==null?[]:Fs(e,Ve(e))}function q_(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=ut(n),n=n===n?n:0),t!==i&&(t=ut(t),t=t===t?t:0),an(ut(e),t,n)}function W_(e,t,n){return t=Nt(t),n===i?(n=t,t=0):n=Nt(n),e=ut(e),Hh(e,t,n)}function Z_(e,t,n){if(n&&typeof n!="boolean"&&Fe(e,t,n)&&(t=n=i),n===i&&(typeof t=="boolean"?(n=t,t=i):typeof e=="boolean"&&(n=e,e=i)),e===i&&t===i?(e=0,t=1):(e=Nt(e),t===i?(t=e,e=0):t=Nt(t)),e>t){var a=e;e=t,t=a}if(n||e%1||t%1){var l=su();return Ne(e+l*(t-e+yd("1e-"+((l+"").length-1))),t)}return ea(e,t)}var G_=On(function(e,t,n){return t=t.toLowerCase(),e+(n?Dc(t):t)});function Dc(e){return Ta(de(e).toLowerCase())}function Bc(e){return e=de(e),e&&e.replace($f,Md).replace(cd,"")}function U_(e,t,n){e=de(e),t=Xe(t);var a=e.length;n=n===i?a:an(ne(n),0,a);var l=n;return n-=t.length,n>=0&&e.slice(n,l)==t}function $_(e){return e=de(e),e&&If.test(e)?e.replace(po,Ld):e}function V_(e){return e=de(e),e&&Of.test(e)?e.replace(bs,"\\$&"):e}var H_=On(function(e,t,n){return e+(n?"-":"")+t.toLowerCase()}),z_=On(function(e,t,n){return e+(n?" ":"")+t.toLowerCase()}),Y_=Wu("toLowerCase");function X_(e,t,n){e=de(e),t=ne(t);var a=t?Sn(e):0;if(!t||a>=t)return e;var l=(t-a)/2;return ki(mi(l),n)+e+ki(gi(l),n)}function K_(e,t,n){e=de(e),t=ne(t);var a=t?Sn(e):0;return t&&a<t?e+ki(t-a,n):e}function J_(e,t,n){e=de(e),t=ne(t);var a=t?Sn(e):0;return t&&a<t?ki(t-a,n)+e:e}function j_(e,t,n){return n||t==null?t=0:t&&(t=+t),sh(de(e).replace(Ss,""),t||0)}function Q_(e,t,n){return(n?Fe(e,t,n):t===i)?t=1:t=ne(t),ta(de(e),t)}function ev(){var e=arguments,t=de(e[0]);return e.length<3?t:t.replace(e[1],e[2])}var tv=On(function(e,t,n){return e+(n?"_":"")+t.toLowerCase()});function nv(e,t,n){return n&&typeof n!="number"&&Fe(e,t,n)&&(t=n=i),n=n===i?yt:n>>>0,n?(e=de(e),e&&(typeof t=="string"||t!=null&&!Ia(t))&&(t=Xe(t),!t&&bn(e))?Yt(dt(e),0,n):e.split(t,n)):[]}var rv=On(function(e,t,n){return e+(n?" ":"")+Ta(t)});function iv(e,t,n){return e=de(e),n=n==null?0:an(ne(n),0,e.length),t=Xe(t),e.slice(n,n+t.length)==t}function sv(e,t,n){var a=f.templateSettings;n&&Fe(e,t,n)&&(t=i),e=de(e),t=Zi({},t,a,zu);var l=Zi({},t.imports,a.imports,zu),d=Oe(l),p=Fs(l,d),_,x,I=0,C=t.interpolate||ei,T="__p += '",N=Ws((t.escape||ei).source+"|"+C.source+"|"+(C===go?Ff:ei).source+"|"+(t.evaluate||ei).source+"|$","g"),Z="//# sourceURL="+(he.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++pd+"]")+`
4
+ `;e.replace(N,function(Y,oe,ce,Je,qe,je){return ce||(ce=Je),T+=e.slice(I,je).replace(Vf,Nd),oe&&(_=!0,T+=`' +
5
+ __e(`+oe+`) +
6
+ '`),qe&&(x=!0,T+=`';
7
+ `+qe+`;
8
+ __p += '`),ce&&(T+=`' +
9
+ ((__t = (`+ce+`)) == null ? '' : __t) +
10
+ '`),I=je+Y.length,Y}),T+=`';
11
+ `;var z=he.call(t,"variable")&&t.variable;if(!z)T=`with (obj) {
12
+ `+T+`
13
+ }
14
+ `;else if(Df.test(z))throw new j(g);T=(x?T.replace(xf,""):T).replace(wf,"$1").replace(bf,"$1;"),T="function("+(z||"obj")+`) {
15
+ `+(z?"":`obj || (obj = {});
16
+ `)+"var __t, __p = ''"+(_?", __e = _.escape":"")+(x?`, __j = Array.prototype.join;
17
+ function print() { __p += __j.call(arguments, '') }
18
+ `:`;
19
+ `)+T+`return __p
20
+ }`;var ie=qc(function(){return fe(d,Z+"return "+T).apply(i,p)});if(ie.source=T,Sa(ie))throw ie;return ie}function av(e){return de(e).toLowerCase()}function ov(e){return de(e).toUpperCase()}function uv(e,t,n){if(e=de(e),e&&(n||t===i))return Yo(e);if(!e||!(t=Xe(t)))return e;var a=dt(e),l=dt(t),d=Xo(a,l),p=Ko(a,l)+1;return Yt(a,d,p).join("")}function cv(e,t,n){if(e=de(e),e&&(n||t===i))return e.slice(0,jo(e)+1);if(!e||!(t=Xe(t)))return e;var a=dt(e),l=Ko(a,dt(t))+1;return Yt(a,0,l).join("")}function lv(e,t,n){if(e=de(e),e&&(n||t===i))return e.replace(Ss,"");if(!e||!(t=Xe(t)))return e;var a=dt(e),l=Xo(a,dt(t));return Yt(a,l).join("")}function fv(e,t){var n=rf,a=sf;if(we(t)){var l="separator"in t?t.separator:l;n="length"in t?ne(t.length):n,a="omission"in t?Xe(t.omission):a}e=de(e);var d=e.length;if(bn(e)){var p=dt(e);d=p.length}if(n>=d)return e;var _=n-Sn(a);if(_<1)return a;var x=p?Yt(p,0,_).join(""):e.slice(0,_);if(l===i)return x+a;if(p&&(_+=x.length-_),Ia(l)){if(e.slice(_).search(l)){var I,C=x;for(l.global||(l=Ws(l.source,de(mo.exec(l))+"g")),l.lastIndex=0;I=l.exec(C);)var T=I.index;x=x.slice(0,T===i?_:T)}}else if(e.indexOf(Xe(l),_)!=_){var N=x.lastIndexOf(l);N>-1&&(x=x.slice(0,N))}return x+a}function dv(e){return e=de(e),e&&Sf.test(e)?e.replace(ho,Zd):e}var hv=On(function(e,t,n){return e+(n?" ":"")+t.toUpperCase()}),Ta=Wu("toUpperCase");function Fc(e,t,n){return e=de(e),t=n?i:t,t===i?Dd(e)?$d(e):Td(e):e.match(t)||[]}var qc=ae(function(e,t){try{return ze(e,i,t)}catch(n){return Sa(n)?n:new j(n)}}),pv=Et(function(e,t){return nt(t,function(n){n=bt(n),kt(e,n,wa(e[n],e))}),e});function gv(e){var t=e==null?0:e.length,n=H();return e=t?xe(e,function(a){if(typeof a[1]!="function")throw new rt(h);return[n(a[0]),a[1]]}):[],ae(function(a){for(var l=-1;++l<t;){var d=e[l];if(ze(d[0],this,a))return ze(d[1],this,a)}})}function mv(e){return Zh(st(e,R))}function Ra(e){return function(){return e}}function _v(e,t){return e==null||e!==e?t:e}var vv=Gu(),yv=Gu(!0);function He(e){return e}function ka(e){return vu(typeof e=="function"?e:st(e,R))}function xv(e){return xu(st(e,R))}function wv(e,t){return wu(e,st(t,R))}var bv=ae(function(e,t){return function(n){return mr(n,e,t)}}),Sv=ae(function(e,t){return function(n){return mr(e,n,t)}});function Oa(e,t,n){var a=Oe(t),l=bi(t,a);n==null&&!(we(t)&&(l.length||!a.length))&&(n=t,t=e,e=this,l=bi(t,Oe(t)));var d=!(we(n)&&"chain"in n)||!!n.chain,p=Lt(e);return nt(l,function(_){var x=t[_];e[_]=x,p&&(e.prototype[_]=function(){var I=this.__chain__;if(d||I){var C=e(this.__wrapped__),T=C.__actions__=Ue(this.__actions__);return T.push({func:x,args:arguments,thisArg:e}),C.__chain__=I,C}return x.apply(e,Gt([this.value()],arguments))})}),e}function Iv(){return Me._===this&&(Me._=Kd),this}function Ea(){}function Cv(e){return e=ne(e),ae(function(t){return bu(t,e)})}var Av=ua(xe),Tv=ua(Uo),Rv=ua(Ls);function Wc(e){return ga(e)?Ns(bt(e)):ip(e)}function kv(e){return function(t){return e==null?i:on(e,t)}}var Ov=$u(),Ev=$u(!0);function Ma(){return[]}function La(){return!1}function Mv(){return{}}function Lv(){return""}function Nv(){return!0}function Pv(e,t){if(e=ne(e),e<1||e>Wt)return[];var n=yt,a=Ne(e,yt);t=H(t),e-=yt;for(var l=Bs(a,t);++n<e;)t(n);return l}function Dv(e){return Q(e)?xe(e,bt):Ke(e)?[e]:Ue(ac(de(e)))}function Bv(e){var t=++Yd;return de(e)+t}var Fv=Ri(function(e,t){return e+t},0),qv=ca("ceil"),Wv=Ri(function(e,t){return e/t},1),Zv=ca("floor");function Gv(e){return e&&e.length?wi(e,He,Ys):i}function Uv(e,t){return e&&e.length?wi(e,H(t,2),Ys):i}function $v(e){return Ho(e,He)}function Vv(e,t){return Ho(e,H(t,2))}function Hv(e){return e&&e.length?wi(e,He,js):i}function zv(e,t){return e&&e.length?wi(e,H(t,2),js):i}var Yv=Ri(function(e,t){return e*t},1),Xv=ca("round"),Kv=Ri(function(e,t){return e-t},0);function Jv(e){return e&&e.length?Ds(e,He):0}function jv(e,t){return e&&e.length?Ds(e,H(t,2)):0}return f.after=xm,f.ary=_c,f.assign=o_,f.assignIn=Ec,f.assignInWith=Zi,f.assignWith=u_,f.at=c_,f.before=vc,f.bind=wa,f.bindAll=pv,f.bindKey=yc,f.castArray=Mm,f.chain=pc,f.chunk=Zp,f.compact=Gp,f.concat=Up,f.cond=gv,f.conforms=mv,f.constant=Ra,f.countBy=Jg,f.create=l_,f.curry=xc,f.curryRight=wc,f.debounce=bc,f.defaults=f_,f.defaultsDeep=d_,f.defer=wm,f.delay=bm,f.difference=$p,f.differenceBy=Vp,f.differenceWith=Hp,f.drop=zp,f.dropRight=Yp,f.dropRightWhile=Xp,f.dropWhile=Kp,f.fill=Jp,f.filter=Qg,f.flatMap=nm,f.flatMapDeep=rm,f.flatMapDepth=im,f.flatten=lc,f.flattenDeep=jp,f.flattenDepth=Qp,f.flip=Sm,f.flow=vv,f.flowRight=yv,f.fromPairs=eg,f.functions=y_,f.functionsIn=x_,f.groupBy=sm,f.initial=ng,f.intersection=rg,f.intersectionBy=ig,f.intersectionWith=sg,f.invert=b_,f.invertBy=S_,f.invokeMap=om,f.iteratee=ka,f.keyBy=um,f.keys=Oe,f.keysIn=Ve,f.map=Pi,f.mapKeys=C_,f.mapValues=A_,f.matches=xv,f.matchesProperty=wv,f.memoize=Bi,f.merge=T_,f.mergeWith=Mc,f.method=bv,f.methodOf=Sv,f.mixin=Oa,f.negate=Fi,f.nthArg=Cv,f.omit=R_,f.omitBy=k_,f.once=Im,f.orderBy=cm,f.over=Av,f.overArgs=Cm,f.overEvery=Tv,f.overSome=Rv,f.partial=ba,f.partialRight=Sc,f.partition=lm,f.pick=O_,f.pickBy=Lc,f.property=Wc,f.propertyOf=kv,f.pull=cg,f.pullAll=dc,f.pullAllBy=lg,f.pullAllWith=fg,f.pullAt=dg,f.range=Ov,f.rangeRight=Ev,f.rearg=Am,f.reject=hm,f.remove=hg,f.rest=Tm,f.reverse=ya,f.sampleSize=gm,f.set=M_,f.setWith=L_,f.shuffle=mm,f.slice=pg,f.sortBy=ym,f.sortedUniq=wg,f.sortedUniqBy=bg,f.split=nv,f.spread=Rm,f.tail=Sg,f.take=Ig,f.takeRight=Cg,f.takeRightWhile=Ag,f.takeWhile=Tg,f.tap=Gg,f.throttle=km,f.thru=Ni,f.toArray=Rc,f.toPairs=Nc,f.toPairsIn=Pc,f.toPath=Dv,f.toPlainObject=Oc,f.transform=N_,f.unary=Om,f.union=Rg,f.unionBy=kg,f.unionWith=Og,f.uniq=Eg,f.uniqBy=Mg,f.uniqWith=Lg,f.unset=P_,f.unzip=xa,f.unzipWith=hc,f.update=D_,f.updateWith=B_,f.values=Ln,f.valuesIn=F_,f.without=Ng,f.words=Fc,f.wrap=Em,f.xor=Pg,f.xorBy=Dg,f.xorWith=Bg,f.zip=Fg,f.zipObject=qg,f.zipObjectDeep=Wg,f.zipWith=Zg,f.entries=Nc,f.entriesIn=Pc,f.extend=Ec,f.extendWith=Zi,Oa(f,f),f.add=Fv,f.attempt=qc,f.camelCase=G_,f.capitalize=Dc,f.ceil=qv,f.clamp=q_,f.clone=Lm,f.cloneDeep=Pm,f.cloneDeepWith=Dm,f.cloneWith=Nm,f.conformsTo=Bm,f.deburr=Bc,f.defaultTo=_v,f.divide=Wv,f.endsWith=U_,f.eq=pt,f.escape=$_,f.escapeRegExp=V_,f.every=jg,f.find=em,f.findIndex=uc,f.findKey=h_,f.findLast=tm,f.findLastIndex=cc,f.findLastKey=p_,f.floor=Zv,f.forEach=gc,f.forEachRight=mc,f.forIn=g_,f.forInRight=m_,f.forOwn=__,f.forOwnRight=v_,f.get=Ca,f.gt=Fm,f.gte=qm,f.has=w_,f.hasIn=Aa,f.head=fc,f.identity=He,f.includes=am,f.indexOf=tg,f.inRange=W_,f.invoke=I_,f.isArguments=ln,f.isArray=Q,f.isArrayBuffer=Wm,f.isArrayLike=$e,f.isArrayLikeObject=Ae,f.isBoolean=Zm,f.isBuffer=Xt,f.isDate=Gm,f.isElement=Um,f.isEmpty=$m,f.isEqual=Vm,f.isEqualWith=Hm,f.isError=Sa,f.isFinite=zm,f.isFunction=Lt,f.isInteger=Ic,f.isLength=qi,f.isMap=Cc,f.isMatch=Ym,f.isMatchWith=Xm,f.isNaN=Km,f.isNative=Jm,f.isNil=Qm,f.isNull=jm,f.isNumber=Ac,f.isObject=we,f.isObjectLike=Se,f.isPlainObject=br,f.isRegExp=Ia,f.isSafeInteger=e_,f.isSet=Tc,f.isString=Wi,f.isSymbol=Ke,f.isTypedArray=Mn,f.isUndefined=t_,f.isWeakMap=n_,f.isWeakSet=r_,f.join=ag,f.kebabCase=H_,f.last=ot,f.lastIndexOf=og,f.lowerCase=z_,f.lowerFirst=Y_,f.lt=i_,f.lte=s_,f.max=Gv,f.maxBy=Uv,f.mean=$v,f.meanBy=Vv,f.min=Hv,f.minBy=zv,f.stubArray=Ma,f.stubFalse=La,f.stubObject=Mv,f.stubString=Lv,f.stubTrue=Nv,f.multiply=Yv,f.nth=ug,f.noConflict=Iv,f.noop=Ea,f.now=Di,f.pad=X_,f.padEnd=K_,f.padStart=J_,f.parseInt=j_,f.random=Z_,f.reduce=fm,f.reduceRight=dm,f.repeat=Q_,f.replace=ev,f.result=E_,f.round=Xv,f.runInContext=y,f.sample=pm,f.size=_m,f.snakeCase=tv,f.some=vm,f.sortedIndex=gg,f.sortedIndexBy=mg,f.sortedIndexOf=_g,f.sortedLastIndex=vg,f.sortedLastIndexBy=yg,f.sortedLastIndexOf=xg,f.startCase=rv,f.startsWith=iv,f.subtract=Kv,f.sum=Jv,f.sumBy=jv,f.template=sv,f.times=Pv,f.toFinite=Nt,f.toInteger=ne,f.toLength=kc,f.toLower=av,f.toNumber=ut,f.toSafeInteger=a_,f.toString=de,f.toUpper=ov,f.trim=uv,f.trimEnd=cv,f.trimStart=lv,f.truncate=fv,f.unescape=dv,f.uniqueId=Bv,f.upperCase=hv,f.upperFirst=Ta,f.each=gc,f.eachRight=mc,f.first=fc,Oa(f,(function(){var e={};return xt(f,function(t,n){he.call(f.prototype,n)||(e[n]=t)}),e})(),{chain:!1}),f.VERSION=o,nt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){f[e].placeholder=f}),nt(["drop","take"],function(e,t){ue.prototype[e]=function(n){n=n===i?1:ke(ne(n),0);var a=this.__filtered__&&!t?new ue(this):this.clone();return a.__filtered__?a.__takeCount__=Ne(n,a.__takeCount__):a.__views__.push({size:Ne(n,yt),type:e+(a.__dir__<0?"Right":"")}),a},ue.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),nt(["filter","map","takeWhile"],function(e,t){var n=t+1,a=n==co||n==cf;ue.prototype[e]=function(l){var d=this.clone();return d.__iteratees__.push({iteratee:H(l,3),type:n}),d.__filtered__=d.__filtered__||a,d}}),nt(["head","last"],function(e,t){var n="take"+(t?"Right":"");ue.prototype[e]=function(){return this[n](1).value()[0]}}),nt(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");ue.prototype[e]=function(){return this.__filtered__?new ue(this):this[n](1)}}),ue.prototype.compact=function(){return this.filter(He)},ue.prototype.find=function(e){return this.filter(e).head()},ue.prototype.findLast=function(e){return this.reverse().find(e)},ue.prototype.invokeMap=ae(function(e,t){return typeof e=="function"?new ue(this):this.map(function(n){return mr(n,e,t)})}),ue.prototype.reject=function(e){return this.filter(Fi(H(e)))},ue.prototype.slice=function(e,t){e=ne(e);var n=this;return n.__filtered__&&(e>0||t<0)?new ue(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(t=ne(t),n=t<0?n.dropRight(-t):n.take(t-e)),n)},ue.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ue.prototype.toArray=function(){return this.take(yt)},xt(ue.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),a=/^(?:head|last)$/.test(t),l=f[a?"take"+(t=="last"?"Right":""):t],d=a||/^find/.test(t);l&&(f.prototype[t]=function(){var p=this.__wrapped__,_=a?[1]:arguments,x=p instanceof ue,I=_[0],C=x||Q(p),T=function(oe){var ce=l.apply(f,Gt([oe],_));return a&&N?ce[0]:ce};C&&n&&typeof I=="function"&&I.length!=1&&(x=C=!1);var N=this.__chain__,Z=!!this.__actions__.length,z=d&&!N,ie=x&&!Z;if(!d&&C){p=ie?p:new ue(this);var Y=e.apply(p,_);return Y.__actions__.push({func:Ni,args:[T],thisArg:i}),new it(Y,N)}return z&&ie?e.apply(this,_):(Y=this.thru(T),z?a?Y.value()[0]:Y.value():Y)})}),nt(["pop","push","shift","sort","splice","unshift"],function(e){var t=ai[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",a=/^(?:pop|shift)$/.test(e);f.prototype[e]=function(){var l=arguments;if(a&&!this.__chain__){var d=this.value();return t.apply(Q(d)?d:[],l)}return this[n](function(p){return t.apply(Q(p)?p:[],l)})}}),xt(ue.prototype,function(e,t){var n=f[t];if(n){var a=n.name+"";he.call(Tn,a)||(Tn[a]=[]),Tn[a].push({name:t,func:n})}}),Tn[Ti(i,$).name]=[{name:"wrapper",func:i}],ue.prototype.clone=dh,ue.prototype.reverse=hh,ue.prototype.value=ph,f.prototype.at=Ug,f.prototype.chain=$g,f.prototype.commit=Vg,f.prototype.next=Hg,f.prototype.plant=Yg,f.prototype.reverse=Xg,f.prototype.toJSON=f.prototype.valueOf=f.prototype.value=Kg,f.prototype.first=f.prototype.head,cr&&(f.prototype[cr]=zg),f}),In=Vd();tn?((tn.exports=In)._=In,ks._=In):Me._=In}).call(M0)})(Or,Or.exports)),Or.exports}var Cr={},nl;function N0(){if(nl)return Cr;nl=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.backtrace=void 0;function s(r,i,o){const u=[];let c=o?r:r.getParent();for(;c.getParent();)u.push([c.position.x,c.position.y]),c=c.getParent();return i&&u.push([c.position.x,c.position.y]),u.reverse()}return Cr.backtrace=s,Cr}var Ar={},rl;function P0(){if(rl)return Ar;rl=1,Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.calculateHeuristic=void 0;function s(r,i,o,u){const c=Math.abs(o.x-i.x),h=Math.abs(o.y-i.y);switch(r){case"Manhatten":case"Manhattan":return(c+h)*u;case"Euclidean":return Math.sqrt(c*c+h*h)*u;case"Chebyshev":return Math.max(c,h)*u;case"Octile":return(c+h-.58*Math.min(c,h))*u}}return Ar.calculateHeuristic=s,Ar}var Tr={},Rr={},il;function D0(){if(il)return Rr;il=1,Object.defineProperty(Rr,"__esModule",{value:!0}),Rr.Node=void 0;class s{constructor(i){this.id=i.id,this.position=i.position,this.hValue=0,this.gValue=0,this.fValue=0,this.parentNode=void 0,this.isOnClosedList=!1,this.isOnOpenList=!1,this.isWalkable=i.walkable||!0}calculateFValue(){this.fValue=this.gValue+this.hValue}setGValue(i){this.gValue=i,this.calculateFValue()}setHValue(i){this.hValue=i,this.calculateFValue()}setFGHValuesToZero(){this.fValue=this.gValue=this.hValue=0}getFValue(){return this.fValue}getGValue(){return this.gValue}getHValue(){return this.hValue}getParent(){return this.parentNode}getIsOnClosedList(){return this.isOnClosedList}getIsOnOpenList(){return this.isOnOpenList}getIsWalkable(){return this.isWalkable}setParent(i){this.parentNode=i}setIsOnClosedList(i){this.isOnClosedList=i}setIsOnOpenList(i){this.isOnOpenList=i}setIsWalkable(i){this.isWalkable=i}}return Rr.Node=s,Rr}var sl;function $l(){if(sl)return Tr;sl=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.Grid=void 0;const s=D0();class r{constructor(o){o.width&&o.height?(this.width=o.width,this.height=o.height,this.numberOfFields=this.width*this.height):o.matrix&&(this.width=o.matrix[0].length,this.height=o.matrix.length,this.numberOfFields=this.width*this.height),this.gridNodes=this.buildGridWithNodes(o.matrix||void 0,this.width,this.height,o.densityOfObstacles||0)}buildGridWithNodes(o,u,c,h){const g=[];let m=0;for(let v=0;v<c;v++){g[v]=[];for(let w=0;w<u;w++)g[v][w]=new s.Node({id:m,position:{x:w,y:v}}),m++}if(o===void 0){for(let v=0;v<c;v++)for(let w=0;w<u;w++)Math.floor(Math.random()*10)+1>10-h?g[v][w].setIsWalkable(!1):g[v][w].setIsWalkable(!0);return g}for(let v=0;v<c;v++)for(let w=0;w<u;w++)g[v][w].setIsWalkable(!o[v][w]);return g}getNodeAt(o){return this.gridNodes[o.y][o.x]}isWalkableAt(o){return this.gridNodes[o.y][o.x].getIsWalkable()}isOnTheGrid(o){return o.x>=0&&o.x<this.width&&o.y>=0&&o.y<this.height}getSurroundingNodes(o,u){const c=[],h=o.x-1,g=o.x+1,m=o.y-1,v=o.y+1;for(let w=m;w<=v;w++)for(let R=h;R<=g;R++)(R!==o.x||w!==o.y)&&this.isOnTheGrid({x:R,y:w})&&this.isWalkableAt({x:R,y:w})&&(u||R==o.x||w==o.y)&&c.push(this.getNodeAt({x:R,y:w}));return c}setGrid(o){this.gridNodes=o}resetGrid(){for(let o=0;o<this.gridNodes.length;o++)for(let u=0;u<this.gridNodes[o].length;u++)this.gridNodes[o][u].setIsOnClosedList(!1),this.gridNodes[o][u].setIsOnOpenList(!1),this.gridNodes[o][u].setParent(void 0),this.gridNodes[o][u].setFGHValuesToZero()}getGridNodes(){return this.gridNodes}clone(){const o=[];let u=0;for(let c=0;c<this.height;c++){o[c]=[];for(let h=0;h<this.width;h++)o[c][h]=new s.Node({id:u,position:{x:h,y:c},walkable:this.gridNodes[c][h].getIsWalkable()}),u++}return o}}return Tr.Grid=r,Tr}var al;function B0(){if(al)return Ir;al=1,Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.AStarFinder=void 0;const s=L0(),r=N0(),i=P0(),o=$l();class u{constructor(h){this.grid=new o.Grid({width:h.grid.width,height:h.grid.height,matrix:h.grid.matrix||void 0,densityOfObstacles:h.grid.densityOfObstacles||0}),this.closedList=[],this.openList=[],this.diagonalAllowed=h.diagonalAllowed!==void 0?h.diagonalAllowed:!0,this.heuristic=h.heuristic?h.heuristic:"Manhattan",this.includeStartNode=h.includeStartNode!==void 0?h.includeStartNode:!0,this.includeEndNode=h.includeEndNode!==void 0?h.includeEndNode:!0,this.allowPathAsCloseAsPossible=h.allowPathAsCloseAsPossible||!1,this.weight=h.weight||1}findPath(h,g){this.closedList=[],this.openList=[],this.grid.resetGrid();const m=this.grid.getNodeAt(h),v=this.grid.getNodeAt(g);if(!this.grid.isWalkableAt(g)||!this.grid.isWalkableAt(h))return[];m.setIsOnOpenList(!0),this.openList.push(m);for(let w=0;w<this.grid.height;w++)for(let R=0;R<this.grid.width;R++){let F=this.grid.getNodeAt({x:R,y:w});this.grid.isWalkableAt({x:R,y:w})?F.setHValue((0,i.calculateHeuristic)(this.heuristic,F.position,v.position,this.weight)):(F.setFGHValuesToZero(),F.setIsOnClosedList(!0),this.closedList.push(F))}for(;this.openList.length!==0;){const w=(0,s.minBy)(this.openList,F=>F.getFValue());if(w.setIsOnOpenList(!1),(0,s.remove)(this.openList,w),w.setIsOnClosedList(!0),this.closedList.push(w),w===v)return(0,r.backtrace)(v,this.includeStartNode,this.includeEndNode);const R=this.grid.getSurroundingNodes(w.position,this.diagonalAllowed);for(let F in R){const W=R[F];if(W.getIsOnClosedList())continue;const M=w.getGValue()+(W.position.x!==w.position.x||W.position.y==w.position.y?this.weight:this.weight*1.41421);(!W.getIsOnOpenList()||M<W.getGValue())&&(W.setGValue(M),W.setParent(w),W.getIsOnOpenList()?W.setParent(w):(W.setIsOnOpenList(!0),this.openList.push(W)))}}return this.allowPathAsCloseAsPossible?(0,r.backtrace)(this.closedList[this.closedList.length-1],this.includeStartNode,!1):[]}setHeuristic(h){this.heuristic=h}setWeight(h){this.weight=h}getGridClone(){return this.grid.clone()}getGrid(){return this.grid}}return Ir.AStarFinder=u,Ir}var ol;function F0(){return ol||(ol=1,(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.Grid=s.AStarFinder=void 0;var r=B0();Object.defineProperty(s,"AStarFinder",{enumerable:!0,get:function(){return r.AStarFinder}});var i=$l();Object.defineProperty(s,"Grid",{enumerable:!0,get:function(){return i.Grid}})})(Fa)),Fa}var q0=F0();const W0=s=>s.map(r=>r.map(i=>i)).reverse(),ul=(s,r)=>s.x>=r[0].length||s.y>=r.length||s.x<0||s.y<0;function fs(s,r,i,o){const u=F=>({x:Math.floor(F.x/o),y:Math.floor(F.y/o)}),c=F=>({x:(F[0]+.5)*o,y:(F[1]+.5)*o}),h=W0(i),g=u(s),m=u(r);if(ul(g,h))return[];if(ul(m,h))return[];const w=new q0.AStarFinder({grid:{matrix:h}}).findPath(g,m);return w.length===0?[]:w.map(c)}const Z0=200,G0=5,Vl={say:"talk",move:"walk",goTo:"walk",wait:"default",act:"default"};function We(s,r){if(s)return r.find(i=>i.id===s)}function Hl(s,r=1,i=0){return Math.max(Math.min(s,r),i)}const U0=s=>(r,i,o,u)=>{const{rooms:c,actors:h}=r,g=c.find(w=>w.id===i);if(!g)return;const m=h.find(w=>w.isPlayer),v=uo(g,s.cellSize);return o&&m&&(m.room=g.id,u&&(m.x=u.x,m.y=u.y)),{currentRoomId:g.id,cellMatrix:v,actors:h}},Ji=(s,r,i,o)=>{const{actorOrders:u}=s,c=structuredClone(i);o?u[r]=c:u[r]?u[r].push(...c):u[r]=c},ji=(s,r,i)=>{const{reportCurrentConversation:o,reportConsequence:u}=i,{actors:c,items:h,rooms:g,currentRoomId:m}=s,v=c.find(M=>M.isPlayer),w=M=>M?c.find(L=>L.id===M):v,R=g.find(M=>M.id===m);let F=!1,W=!1;return M=>{switch(M.type){case"order":{const{actorId:L,orders:V}=M,$=w(L);if(!$)break;Ji(s,$.id,V,M.replaceCurrentOrders),F=!0,W=$.room!==m;break}case"changeRoom":{const{roomId:L,takePlayer:V,x:$,y:te}=M,re=typeof $=="number"&&typeof te=="number"?{x:$,y:te}:void 0,E=U0(r)(s,L,V,re);if(!E)break;Object.assign(s,E),F=!0;break}case"inventory":{const{actorId:L,itemId:V,addOrRemove:$}=M,te=w(L),re=h.find(E=>E.id===V);if(!te||!re)break;$==="ADD"?(re.actorId=te.id,F=!0):re.actorId===te.id&&(re.actorId=void 0,F=!0),W=te&&te.room!==m;break}case"removeActor":{const{actorId:L}=M,V=c.find($=>$.id===L);if(!V)break;F=!0,W=V.room!==m,V.room=void 0;break}case"teleportActor":{const{actorId:L,roomId:V,x:$,y:te}=M,re=c.find(E=>E.id===L);if(!re)break;W=!re.isPlayer&&re.room!==m&&V!==m,re.room=V||re.room,re.x=$,re.y=te,F=!0;break}case"changeStatus":{const{targetId:L,targetType:V,status:$}=M;let te;switch(V){case"actor":te=c.find(re=>re.id===L),W=te?.room!==m;break;case"item":te=h.find(re=>re.id===L);break;case"hotspot":te=R?.hotspots?.find(re=>re.id===L);break}if(!te)break;te.status=$,F=!0;break}case"sequence":{const{sequence:L}=M,V=We(L,r.sequences);if(!V){console.warn(`No such sequence ${L}`);break}const $=structuredClone(V);s.sequenceRunning?(s.sequenceRunning.id=[s.sequenceRunning.id,$.id].join(),s.sequenceRunning.stages.push(...$.stages)):s.sequenceRunning=$,F=!0;break}case"conversation":{const{conversationId:L,end:V}=M;if(!s.conversations.find(te=>te.id===L)){console.warn(`No such conversation ${L}`);break}s.currentConversationId=V?void 0:L,F=!0,o?.();break}case"toggleZone":{const{roomId:L,ref:V,on:$,zoneType:te}=M,re=We(L,s.rooms);if(!re)break;W=re.id!==m;const E=te==="obstacle"?re.obstacleAreas:te==="walkable"?re.walkableAreas:void 0;if(!E)break;const k=E.find(me=>me.ref===V);if(!k)break;k.disabled=!$,R?.id===re.id&&(s.cellMatrix=uo(re,r.cellSize)),F=!0;break}case"soundEffect":{const{sound:L,volume:V}=M;F=!!r.playSound?.(L,V);break}case"flag":{const{flag:L,on:V}=M,$=s.flagMap[L];if(!$){console.warn(`No such flag ${L}`);break}$.value=V,F=!0;break}case"conversationChoice":{const{conversationId:L,choiceRef:V,branchId:$,on:te}=M,k=We(L,s.conversations)?.branches[$]?.choices.find(me=>me.ref===V);if(!k){console.warn("no such conversation choice:",L,$,V);break}F=!0,k.disabled=!te;break}case"backgroundMusic":{const{sound:L,volume:V,roomId:$}=M,te=We($,s.rooms);if(!te){console.warn("no such room",$);break}te.backgroundMusic=L?{soundId:L,volume:V}:void 0;break}case"ambientNoise":{const{sound:L,volume:V,roomId:$}=M,te=We($,s.rooms);if(!te){console.warn("no such room",$);break}te.ambientNoise=L?{soundId:L,volume:V}:void 0;break}case"storyBoardConsequence":{const{storyBoardId:L}=M;We(L,r.storyBoards)?s.currentStoryBoardId=L:console.warn("no such storyBoard",L);break}case"changePlayerCharacter":{const{actorId:L}=M,V=We(L,s.actors);if(!V){console.warn(console.warn("no such actor",L));break}const $=s.actors.find(te=>te.isPlayer);$&&($.isPlayer=!1),V.isPlayer=!0}default:{console.warn("unsupported conseqeunce!",M);break}}u?.(M,F,W)}};function $0(s,r=!1,i=1){if(r){s.steps.splice(0,s.steps.length);return}const[o]=s.steps;o&&(typeof o.timeElapsed>"u"&&(o.timeElapsed=0),o.timeElapsed+=i,o.timeElapsed>=o.duration&&s.steps.shift())}function V0(s,r){if(!s)return[];const i=r?s.animations[r]:s.animations[Vl.move]??{};return Object.keys(i)}function H0(s,r,i){const o=r.x-s.x,u=r.y-s.y,c=o<0?"left":"right",h=u<0?"down":"up",g=Math.abs(o)<Math.abs(u),m=g?h:c;return i.includes(m)?m:g?c:h}function z0(s,r,i,o,u=1){if(s.roomId&&s.roomId!==r.room&&(console.warn(`${r.id} is in ${r.room??"[NOWHERE]"}, not ${s.roomId} - cancelling order`),s.steps.splice(0,s.steps.length)),o){const M=s.steps[s.steps.length-1];M&&(r.x=M.x,r.y=M.y,s.steps.splice(0,s.steps.length));return}const{x:c,y:h,speed:g=1}=r,[m]=s.steps;if(!m)return;const{speed:v=1}=m,w=g*v*u;let R=c,F=h;if(c!==m.x){const M=Math.min(w,Math.abs(c-m.x)),L=c<m.x?1:-1;R=c+M*L}if(h!==m.y){const M=Math.min(w,Math.abs(h-m.y)),L=h<m.y?1:-1;F=h+M*L}m.x==R&&m.y==F&&s.steps.shift();const W=V0(i,m.animation);r.x=R,r.y=F,r.direction=H0({x:c,y:h},{x:R,y:F},W)}function Y0(s,r=!1,i=1){if(r){s.time=0;return}s.time-=i}const Ui={ITEM:"$ITEM",TARGET:"$TARGET",VERB:"$VERB"},zl=(s,r=!1)=>{const{verb:i,target:o,item:u}=s;return r?u?`${i.label} ${u.name??u.id} ${i.preposition??"with"} ${o.name??o.id}`:`${i.label} ${o.name??o.id}`:u?`${i.id} ${u.id} ${i.preposition} ${o.id}`:`${i.id} ${o.id}`};function Yl(s,r){const{verb:i,item:o,target:u}=s,{defaultResponseCannotReach:c,defaultResponseNoItem:h,defaultResponseWithItem:g}=i,m=r?c:o?g:h;if(m){let w=m;return w=w.replace(Ui.TARGET,u.name||u.id),w=w.replace(Ui.ITEM,o?.name||o?.id||""),w=w.replace(Ui.VERB,i.label),w}return r?`I can't reach the ${u.name||u.id}`:o?`I can't ${i.label} the ${o.name||o.id} ${i.preposition} the ${u.name||u.id}`:`Nothing happens when I ${i.label} the ${u.name||u.id}`}function cl(s,r,i){return r.map(u=>{const c=i[u];if(!c){console.warn(`Invalid flag id: "${u}"`);return}return c.value===s}).includes(!1)}function X0(s,r){const i=r.actors.find(o=>o.isPlayer);return r.items.some(o=>o.actorId!==i?.id&&s.includes(o.id))}function Xl(s,r,i,o){const{verb:u,item:c,target:h}=s,{flagMap:g}=o;return i.find(m=>{const v=m.verbId===u.id&&m.targetId===h.id&&(!m.roomId||m?.roomId===r?.id)&&(!m.itemId&&!c||m?.itemId==c?.id)&&(!m.targetStatus||m.targetStatus==h.status);return!v||m.flagsThatMustBeTrue&&cl(!0,m.flagsThatMustBeTrue,g)||m.flagsThatMustBeFalse&&cl(!1,m.flagsThatMustBeFalse,g)||m.requiredInventory&&X0(m.requiredInventory,o)?!1:v})}function Kl(s,r,i=!1){const{targetId:o,roomId:u}=s;if(!o)return;const{rooms:c,actors:h,items:g}=r,m=u?We(u,c):void 0,w=(m?[m]:u?[]:c).flatMap(R=>R.hotspots||[]);return We(o,i?[...h,...w]:[...h,...g,...w])}function K0(s,r){const{frameWidth:i,width:o}=r;return i+s*(o-i)}function J0(s,r){const{height:i,frameHeight:o=i}=r;return o+s*(i-o)}function ds(s,r){switch(s.type){case"actor":{const{x:i,y:o,walkToX:u=0,walkToY:c=0}=s;return{x:i+u,y:o+c}}case"hotspot":{const{x:i,y:o,walkToX:u,walkToY:c,parallax:h}=s,{frameWidth:g,frameHeight:m,height:v}=r;let w;if(typeof u>"u"){const W=(K0(h,r)-g)/2;w=i+W}else w=u;let R;if(typeof c>"u"){const W=(J0(h,r)-(m??v))/2;R=o+W}else R=c;return{x:w,y:R}}}}function Jl(s,r){const{width:i}=r,o=2*(s-i/2)/i;return Hl(-o*2,1,-1)}function jl(s,r){const{height:i}=r,o=2*(s-i/2)/i;return Hl(o*2,1,-1)}const ll=()=>({type:"move",pathIsSet:!1,steps:[]});function j0(s,r){const{targetId:i,speed:o,animation:u}=s,{currentRoomId:c,rooms:h}=r,g=We(c,h);if(!g)return console.warn("failed to room for makeMoveOrderFromGoto ",s),ll();const m=Kl({targetId:i,roomId:c},r,!0);return!m||m?.type==="item"?(console.warn("failed to find target to makeMoveOrderFromGoto ",s),ll()):{type:"move",pathIsSet:!1,steps:[{...ds(m,g),speed:o,animation:u}],narrative:{text:[]}}}function Q0(s,r,i,o){const{steps:u}=o;let c={x:s.x,y:s.y};const h=u.flatMap(g=>{const m=fs(c,g,r,i);return m.forEach(v=>{v.animation=g.animation,v.speed=g.speed}),m.length===0?(console.warn("failed to findPathBetweenSteps"),c={x:g.x,y:g.y}):c=m[m.length-1],m});o.pathIsSet=!0,o.steps=h}function ex(s,r,i,o,u,c,h,g=!1,m=1){switch(s.type){case"move":s.pathIsSet||Q0(r,i,o,s),z0(s,r,h,g,m);break;case"say":Y0(s,g,m);break;case"act":$0(s,g,m);break;case"goTo":{const v=j0(s,u);c.shift(),c.unshift(v);break}}}const tx=s=>{switch(s.type){case"move":case"act":return s.steps.length===0;case"say":return s.time<=0;case"goTo":return!1}},Ql=(s,r)=>(i,o,u,c)=>{const{orderSpeed:h=1,instantMode:g=!1}=s,{cellMatrix:m=[]}=i,v=We(o.sprite,s.sprites);if(!u||u.length===0)return;const[w]=u;w._started||(r.reportOrder(w,o),w.startDirection&&(o.direction=w.startDirection),w._started=!0),ex(w,o,m,s.cellSize,i,u,v,g,h),tx(w)&&(w.endDirection&&(o.direction=w.endDirection),w.endStatus&&(o.status=w.endStatus),u.shift(),w.type==="move"&&w.doPendingInteractionWhenFinished&&c?.())};function nx(s,r){const i=r.map(c=>c.id);Object.keys(s).filter(c=>!i.includes(c)).forEach(c=>{console.warn(`invalid id in stage: ${c}`),delete s[c]}),Object.keys(s).filter(c=>s[c].length===0).forEach(c=>{delete s[c]})}const ef=(s,r,i)=>o=>{const{reportStage:u,reportCurrentConversation:c}=r,{actors:h,sequenceRunning:g}=o;if(!g)return{};const[m]=g.stages;if(!m)return{};m._started||(m._started=!0,i(`starting next stage in sequence ${g.id}`),u?.(m));const{actorOrders:v={}}=m;if(nx(v,h),h.forEach(F=>Ql(s,r)(o,F,v[F.id])),m.immediateConsequences){const F=ji(o,s,r);m.immediateConsequences.forEach(W=>{console.log(`executing: ${W.type}`),F(W)}),delete m.immediateConsequences}Object.keys(v).length===0&&g.stages.shift();const[R]=g.stages;return!R&&o.currentConversationId&&c(),o.sequenceRunning=g.stages.length===0?void 0:g,o};function fl(s,r,i,o,u){const{actors:c,rooms:h,currentRoomId:g}=s,m=c.find(w=>w.isPlayer),v=We(g,h);if(!m||!v)return s;if(i.verb.isMoveVerb&&(i.target.type==="actor"||i.target.type==="hotspot")){const w=ds(i.target,v);u?.(`walk to point is ${w.x}, ${w.y}`,"pathfinding"),Ji(s,m.id,[{type:"move",steps:[{...w}]}])}else{const w=Yl(i,o);Ji(s,m.id,[{type:"say",text:w,time:r}])}return s}const tf=s=>`(${s.consequences?.map(r=>r.type).join()})`;function rx(s,r,i){return{type:"order",actorId:s.id,replaceCurrentOrders:!0,orders:[{type:"move",doPendingInteractionWhenFinished:!0,steps:[{x:r.x,y:r.y}],narrative:i?{text:[`making your way to ${i}...`]}:void 0}]}}const ix=(s,r,i)=>(o,u)=>{const{currentRoomId:c,rooms:h,actors:g,cellMatrix:m=[]}=o,v=We(c,h);if(!v)return o;const w=g.find(M=>M.isPlayer),R=Xl(u,v,o.interactions,o),F=R&&(u.verb.isMoveVerb||R.mustReachFirst),W=zl(u);if(r.reportCommand?.(u),R&&F&&u.target.type!=="item"){i?.(`[${W}]: (pending interaction at [${u.target.x}, ${u.target.y}])`,"command");const M=ds(u.target,v);w&&(fs(w,M,m,s.cellSize).length>0?(o.pendingInteraction=R,ji(o,s,r)(rx(w,M,s.instantMode?void 0:u.target.name??u.target.id))):(i?.(`cannot reach [${M.x}, ${M.y}] from [${w.x},${w.y}]`,"pathfinding"),fl(o,s.defaultTalkTime,u,!0,i)))}else if(R){i?.(`[${W}]: ${tf(R)}`,"command");const M=ji(o,s,r);R.consequences.forEach(M)}else i?.(`[${W}]: (no match)`,"command"),fl(o,s.defaultTalkTime,u,!1,i);return o},sx=(s,r,i)=>o=>{const u=ji(o,s,r);return o.pendingInteraction?.consequences.forEach(u),o.pendingInteraction&&i?.(`Pending interaction: ${tf(o.pendingInteraction)}`,"command"),o.pendingInteraction=void 0,o};function ax(s,r,i){let{choiceRef:o,branchId:u,conversationId:c}=s;if(!o){console.warn(`missing choiceRef for findChoiceFromRefSet in conversation ${i.id}`);return}c||(c=i.id),u||(u=i.currentBranch||i.defaultBranch);const h=r.find(v=>v.id===c);if(!h){console.warn(`invalid conversationId "${c}" for findChoiceFromRefSet in conversation ${i.id}`);return}const g=h.branches[u];if(!g){console.warn(`invalid branchId "${c}/${u}" for findChoiceFromRefSet in conversation ${i.id}`);return}const m=g.choices.find(v=>v.ref===o);if(!m){console.warn(`invalid choiceRef "${c}/${u}/${o}" for findChoiceFromRefSet in conversation ${i.id}`);return}return m}function dl(s,r,i,o){return r.forEach(u=>{const c=ax(u,i,o);c&&(c.disabled=s)}),i}function ox(s,r,i){const o={id:"",stages:[{actorOrders:{}}]},u=i.actors.find(h=>h.isPlayer);if(!u)return o;const{actorOrders:c}=o.stages[0];return c&&(c[u.id]=[{type:"say",text:s.text,time:r}]),o}const ux=({sequences:s,defaultTalkTime:r},i)=>(o,u)=>{const{conversations:c,currentConversationId:h=""}=o,g=c.find(w=>w.id===h);if(!g)return o;u.once&&(u.disabled=!0),u.enablesChoices&&dl(!1,u.enablesChoices,c,g),u.disablesChoices&&dl(!0,u.disablesChoices,c,g),u.nextBranch&&g?.branches[u.nextBranch]&&(g.currentBranch=u.nextBranch);const m=We(u.sequence,s)??u.choiceSequence;u.sequence&&!m&&i(`invalid sequenceId "${u.sequence}" in conversation "${h}"`);const v=m?structuredClone(m):ox(u,r,o);return u.end&&v.stages.push({immediateConsequences:[{type:"conversation",end:!0,conversationId:h}]}),o.sequenceRunning=v,o},cx=(s,r)=>(i,o,u,c=!1,h=!1)=>{const{cellMatrix:g,actors:m}=i,v=m.find(F=>F.id===u);if(!v||!g)return{};const w=h?[o]:fs({x:v.x,y:v.y},o,g,s.cellSize),R={type:"move",steps:w,pathIsSet:!0};return r?.(`move: [${v.x}, ${v.y}] -> [${o.x},${o.y}], steps:${w.length}`,"order"),Ji(i,v.id,[R],!c),{actors:m}},lx=(s,r,i)=>o=>{let u=!1;return o.actors.forEach(c=>{Ql(s,r)(o,c,o.actorOrders[c.id],()=>{u=!0})}),u&&sx(s,r,i)(o),o},fx=(s,r,i)=>o=>{o.sequenceRunning?ef(s,r,i)(o):lx(s,r,i)(o);const u=o.actors.find(h=>h.isPlayer),c=We(o.currentRoomId,o.rooms);u&&c&&(o.viewAngleX=Jl(u.x,c),o.viewAngleY=jl(u.y,c))},dx=s=>({...s,storyBoards:s.storyBoards??[],schemaVersion:3}),hx=s=>nf(dx(s)),px=(s,r)=>{const i=s.imageId?{x:"center",y:"center",width:s.imageWidth?s.imageWidth/16:20,height:s.imageWidth?s.imageWidth/16:20,image:{imageId:s.imageId}}:void 0;return{id:r??s.id,isEndOfGame:!0,pages:[{title:s.message,narrative:{text:[]},color:"#FFFFFF",backgroundColor:"#000000",pictures:i?[i]:[]}]}},gx=(s,r)=>{const i=r.filter(u=>u.startsWith(s)),o=(u=1)=>{const c=`${s}_${u}`;return i.includes(c)?o(u+1):c};return o()},nf=s=>{const{storyBoards:r,interactions:i,sequences:o,conversations:u}=s,c=r.map(M=>M.id),h={},g=s.endings.map(M=>{const L=c.includes(M.id)?gx(M.id,c):void 0;return L&&c.push(L),h[M.id]=L??M.id,px(M,L)}),m=M=>M.type!=="ending"?M:{type:"storyBoardConsequence",storyBoardId:h[M.endingId]??M.endingId,narrative:M.narrative},v=M=>({...M,stages:M.stages.map(L=>({...L,immediateConsequences:L.immediateConsequences?.map(m)}))}),w=M=>{const{branches:L}=M;for(let V in L){const $=L[V];$&&($.choices=$.choices.map(te=>({...te,choiceSequence:te.choiceSequence?v(te.choiceSequence):void 0})))}return{...M,branches:L}},R=i.map(M=>({...M,consequences:M.consequences.map(m)})),F=o.map(v),W=u.map(w);return{...s,storyBoards:[...r,...g],interactions:R,sequences:F,conversations:W,schemaVersion:cs}},mx=s=>{const r=Wl.safeParse(s);if(r.success)return{success:!0,gameDesign:r.data,sourceVersion:cs,updated:!1};const i=Zl.safeParse(s);if(i.success)return{success:!0,gameDesign:nf(i.data),sourceVersion:3,updated:!0};const o=Bl.safeParse(s);return o.success?{success:!0,gameDesign:hx(o.data),sourceVersion:2,updated:!0}:{success:!1,failureMessage:o.error.message}};exports.ActOrderSchema=Al;exports.ActorDataSchema=os;exports.AmbientNoiseConsequenceSchema=Kn;exports.AspectRatioSchema=bl;exports.BackgroundMusicConsequenceSchema=Xn;exports.BoardFontSchema=Dl;exports.BoardProgressionSchema=Pl;exports.CELL_SIZE=G0;exports.ChangePlayerCharacterConsequenceSchema=Qn;exports.ChangeRoomConsequenceSchema=Zn;exports.ChangeStatusConsequenceSchema=$n;exports.CommandSchema=I0;exports.CommandTargetSchema=Gl;exports.ConsequenceSchema=Tl;exports.ConversationBranchSchema=Rl;exports.ConversationChoiceConsequenceSchema=Hn;exports.ConversationChoiceSchema=Xa;exports.ConversationConsequenceSchema=Vn;exports.ConversationSchema=Ka;exports.ConversationSchemaWithDeprecatedConsequences=eo;exports.DB_VERSION=cs;exports.DEFAULT_ANIMATION=Vl;exports.DEFAULT_TALK_TIME=Z0;exports.DirectionEnum=Wn;exports.EndingConsequenceSchema=ja;exports.EndingSchema=Ja;exports.FixedGameInfoSchema=ao;exports.FlagConsequenceSchema=Jn;exports.FlagMapSchema=to;exports.FlagSchema=Ol;exports.GameContentsDataSchema=ls;exports.GameDataItemTypeEnum=w0;exports.GameDataSchema=x0;exports.GameDesignSchema=Wl;exports.GameHappeningsSchema=ql;exports.GotoOrderSchema=Il;exports.HotspotZoneSchema=no;exports.IdentSchema=ts;exports.ImmediateConsequenceSchema=za;exports.ImmediateConsequenceSchemaWithDeprecated=kl;exports.InteractionSchema=ss;exports.InteractionSchemaWithDeprecatedConsequences=Qa;exports.InventoryConsequenceSchema=Gn;exports.ItemDataSchema=Yr;exports.MoveOrderSchema=Sl;exports.NarrativeSchema=Ie;exports.OrderConsequenceSchema=rs;exports.PositionSchema=wl;exports.RemoveActorConsequenceSchema=Un;exports.RoomDataSchema=ro;exports.SayOrderSchema=Cl;exports.SequenceConsequenceSchema=is;exports.SequenceSchema=zr;exports.SequenceSchemaWithDeprecatedConsequences=as;exports.SoundEffectConsequenceSchema=Yn;exports.SoundValueSchema=Ua;exports.SpriteDataSchema=io;exports.SpriteFrameSchema=kr;exports.SpriteParamsSchema=xl;exports.StageSchema=Ya;exports.StaticFrameParamsSchema=$r;exports.StoryBoardConsequenceSchema=jn;exports.StoryBoardPageSchema=Nl;exports.StoryBoardSchema=so;exports.TeleportActorConsequenceSchema=zn;exports.ToggleZoneConsequenceSchema=_n;exports.VerbSchema=us;exports.ZoneSchema=$a;exports.advanceTimeOneStep=fx;exports.cellMatrixSchema=Fl;exports.changeHistory=Qv;exports.consequenceMap=a0;exports.consequenceTypes=s0;exports.continueSequence=ef;exports.describeCommand=zl;exports.directions=jy;exports.findPath=fs;exports.findTarget=Kl;exports.generateCellMatrix=uo;exports.getDefaultResponseText=Yl;exports.getTargetPoint=ds;exports.getViewAngleXCenteredOn=Jl;exports.getViewAngleYCenteredOn=jl;exports.handleConversationChoice=ux;exports.immediateConsequenceTypes=o0;exports.issueMoveOrder=cx;exports.makeCommandHandler=ix;exports.matchInteraction=Xl;exports.orderBaseOmits=Qy;exports.orderSchema=Hr;exports.orderTypes=n0;exports.parseAndUpgrade=mx;exports.soundInstanceSchema=Ki;exports.v2GameDesignSchema=Bl;exports.v3GameDesignSchema=Zl;exports.wildCard=Ui;exports.xPlacement=Ml;exports.yPlacement=Ll;exports.zoneTypes=r0;