@drincs/pixi-vn-ink
Version:
Pixi'VN gives you the ability to write your own narrative using Ink
4 lines • 284 kB
JavaScript
'use strict';var nu=Object.create;var io=Object.defineProperty;var iu=Object.getOwnPropertyDescriptor;var ru=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty;var f=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var ou=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ru(t))!au.call(o,i)&&i!==e&&io(o,i,{get:()=>t[i],enumerable:!(n=iu(t,i))||n.enumerable});return o};var ro=(o,t,e)=>(e=o!=null?nu(su(o)):{},ou(io(e,"default",{value:o,enumerable:true}),o));var Vr=f(dn=>{Object.defineProperty(dn,"__esModule",{value:true});dn.CompilerOptions=void 0;var Rr=class{constructor(t=null,e=[],n=false,i=null,s=null){this.sourceFilename=t,this.pluginNames=e,this.countAllVisits=n,this.errorHandler=i,this.fileHandler=s;}};dn.CompilerOptions=Rr;});var so=f(fn=>{Object.defineProperty(fn,"__esModule",{value:true});fn.DebugSourceRange=void 0;var Wr=class{constructor(t,e,n){this.length=t,this.debugMetadata=e,this.text=n;}};fn.DebugSourceRange=Wr;});var we=f(pn=>{Object.defineProperty(pn,"__esModule",{value:true});pn.ErrorType=void 0;var ao;(function(o){o[o.Author=0]="Author",o[o.Warning=1]="Warning",o[o.Error=2]="Error";})(ao||(pn.ErrorType=ao={}));});var oo=f(mn=>{Object.defineProperty(mn,"__esModule",{value:true});mn.Argument=void 0;var Dr=class{constructor(t=null,e=null,n=null){this.identifier=t,this.isByReference=e,this.isDivertTarget=n;}get typeName(){return "Argument"}};mn.Argument=Dr;});var P=f(L=>{Object.defineProperty(L,"__esModule",{value:true});L.filterUndef=L.isEquatable=L.nullIfUndefined=L.asINamedContentOrNull=L.asBooleanOrThrows=L.asNumberOrThrows=L.asOrThrows=L.asOrNull=void 0;function lu(o,t){return o instanceof t?lo(o):null}L.asOrNull=lu;function uu(o,t){if(o instanceof t)return lo(o);throw new Error(`${o} is not of type ${t}`)}L.asOrThrows=uu;function hu(o){if(typeof o=="number")return o;throw new Error(`${o} is not a number`)}L.asNumberOrThrows=hu;function cu(o){if(typeof o=="boolean")return o;throw new Error(`${o} is not a boolean`)}L.asBooleanOrThrows=cu;function du(o){return o.hasValidName&&o.name?o:null}L.asINamedContentOrNull=du;function fu(o){return typeof o>"u"?null:o}L.nullIfUndefined=fu;function pu(o){return typeof o=="object"&&typeof o.Equals=="function"}L.isEquatable=pu;function lo(o,t){return o}function mu(o){return o!=null}L.filterUndef=mu;});var N=f(gn=>{Object.defineProperty(gn,"__esModule",{value:true});gn.ParsedObject=void 0;var uo=P(),Lr=class{constructor(){this._alreadyHadError=false,this._alreadyHadWarning=false,this._debugMetadata=null,this._runtimeObject=null,this.content=[],this.parent=null,this.GetType=()=>this.typeName,this.AddContent=t=>{this.content===null&&(this.content=[]);let e=Array.isArray(t)?t:[t];for(let n of e)n.hasOwnProperty("parent")&&(n.parent=this),this.content.push(n);if(!Array.isArray(t))return t},this.InsertContent=(t,e)=>(this.content===null&&(this.content=[]),e.parent=this,this.content.splice(t,0,e),e),this.Find=t=>(e=null)=>{let n=(0, uo.asOrNull)(this,t);if(n!==null&&(e===null||e(n)===true))return n;if(this.content===null)return null;for(let i of this.content){let s=i.Find&&i.Find(t)(e);if(s)return s}return null},this.FindAll=t=>(e,n)=>{let i=Array.isArray(n)?n:[],s=(0, uo.asOrNull)(this,t);if(s!==null&&(!e||e(s)===true)&&i.push(s),this.content===null)return [];for(let r of this.content)r.FindAll&&r.FindAll(t)(e,i);return i},this.Warning=(t,e=null)=>{this.Error(t,e,true);};}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(t){this._debugMetadata=t;}get hasOwnDebugMetadata(){return !!this.debugMetadata}get typeName(){return "ParsedObject"}get story(){let t=this;for(;t.parent;)t=t.parent;return t}get runtimeObject(){return this._runtimeObject||(this._runtimeObject=this.GenerateRuntimeObject(),this._runtimeObject&&(this._runtimeObject.debugMetadata=this.debugMetadata)),this._runtimeObject}set runtimeObject(t){this._runtimeObject=t;}get runtimePath(){if(!this.runtimeObject.path)throw new Error;return this.runtimeObject.path}get containerForCounting(){return this.runtimeObject}get ancestry(){let t=[],e=this.parent;for(;e;)t.push(e),e=e.parent;return t=t.reverse(),t}ResolveReferences(t){if(this.content!==null)for(let e of this.content)e.ResolveReferences(t);}Error(t,e=null,n=false){if(e===null&&(e=this),!(e._alreadyHadError&&!n||e._alreadyHadWarning&&n)){if(this.parent)this.parent.Error(t,e,n);else throw new Error(`No parent object to send error to: ${t}`);n?e._alreadyHadWarning=true:e._alreadyHadError=true;}}};gn.ParsedObject=Lr;});var vn=f(Cn=>{Object.defineProperty(Cn,"__esModule",{value:true});Cn.AuthorWarning=void 0;var gu=N(),qr=class extends gu.ParsedObject{constructor(t){super(),this.warningMessage=t,this.GenerateRuntimeObject=()=>(this.Warning(this.warningMessage),null);}get typeName(){return "AuthorWarning"}};Cn.AuthorWarning=qr;});var Z=f(Pe=>{Object.defineProperty(Pe,"__esModule",{value:true});Pe.Path=void 0;var te=class o{constructor(){if(this._components=[],this._componentsString=null,this._isRelative=false,typeof arguments[0]=="string"){let t=arguments[0];this.componentsString=t;}else if(arguments[0]instanceof o.Component&&arguments[1]instanceof o){let t=arguments[0],e=arguments[1];this._components.push(t),this._components=this._components.concat(e._components);}else if(arguments[0]instanceof Array){let t=arguments[0],e=!!arguments[1];this._components=this._components.concat(t),this._isRelative=e;}}get isRelative(){return this._isRelative}get componentCount(){return this._components.length}get head(){return this._components.length>0?this._components[0]:null}get tail(){if(this._components.length>=2){let t=this._components.slice(1,this._components.length);return new o(t)}else return o.self}get length(){return this._components.length}get lastComponent(){let t=this._components.length-1;return t>=0?this._components[t]:null}get containsNamedComponent(){for(let t=0,e=this._components.length;t<e;t++)if(!this._components[t].isIndex)return true;return false}static get self(){let t=new o;return t._isRelative=true,t}GetComponent(t){return this._components[t]}PathByAppendingPath(t){let e=new o,n=0;for(let i=0;i<t._components.length&&t._components[i].isParent;++i)n++;for(let i=0;i<this._components.length-n;++i)e._components.push(this._components[i]);for(let i=n;i<t._components.length;++i)e._components.push(t._components[i]);return e}get componentsString(){return this._componentsString==null&&(this._componentsString=this._components.join("."),this.isRelative&&(this._componentsString="."+this._componentsString)),this._componentsString}set componentsString(t){if(this._components.length=0,this._componentsString=t,this._componentsString==null||this._componentsString=="")return;this._componentsString[0]=="."&&(this._isRelative=true,this._componentsString=this._componentsString.substring(1));let e=this._componentsString.split(".");for(let n of e)/^(\-|\+)?([0-9]+|Infinity)$/.test(n)?this._components.push(new o.Component(parseInt(n))):this._components.push(new o.Component(n));}toString(){return this.componentsString}Equals(t){if(t==null||t._components.length!=this._components.length||t.isRelative!=this.isRelative)return false;for(let e=0,n=t._components.length;e<n;e++)if(!t._components[e].Equals(this._components[e]))return false;return true}PathByAppendingComponent(t){let e=new o;return e._components.push(...this._components),e._components.push(t),e}};Pe.Path=te;te.parentId="^";(function(o){class t{constructor(n){this.index=-1,this.name=null,typeof n=="string"?this.name=n:this.index=n;}get isIndex(){return this.index>=0}get isParent(){return this.name==o.parentId}static ToParent(){return new t(o.parentId)}toString(){return this.isIndex?this.index.toString():this.name}Equals(n){return n!=null&&n.isIndex==this.isIndex?this.isIndex?this.index==n.index:this.name==n.name:false}}o.Component=t;})(te||(Pe.Path=te={}));});var Oe=f(Sn=>{Object.defineProperty(Sn,"__esModule",{value:true});Sn.Debug=void 0;var ho;(function(o){function t(n,i,s){e(n instanceof i,s);}o.AssertType=t;function e(n,i){if(!n)throw typeof i<"u"&&console.warn(i),console.trace&&console.trace(),new Error("")}o.Assert=e;})(ho||(Sn.Debug=ho={}));});var G=f(ee=>{Object.defineProperty(ee,"__esModule",{value:true});ee.throwNullException=ee.NullException=void 0;var yn=class extends Error{};ee.NullException=yn;function Cu(o){throw new yn(`${o} is null or undefined`)}ee.throwNullException=Cu;});var Q=f(bn=>{Object.defineProperty(bn,"__esModule",{value:true});bn.InkObject=void 0;var ne=Z(),xe=k(),jr=Oe(),ie=P(),_n=G(),Mr=class{constructor(){this.parent=null,this._debugMetadata=null,this._path=null;}get debugMetadata(){return this._debugMetadata===null&&this.parent?this.parent.debugMetadata:this._debugMetadata}set debugMetadata(t){this._debugMetadata=t;}get ownDebugMetadata(){return this._debugMetadata}DebugLineNumberOfPath(t){if(t===null)return null;let e=this.rootContentContainer;if(e){let n=e.ContentAtPath(t).obj;if(n){let i=n.debugMetadata;if(i!==null)return i.startLineNumber}}return null}get path(){if(this._path==null)if(this.parent==null)this._path=new ne.Path;else {let t=[],e=this,n=(0, ie.asOrNull)(e.parent,xe.Container);for(;n!==null;){let i=(0, ie.asINamedContentOrNull)(e);if(i!=null&&i.hasValidName){if(i.name===null)return (0, _n.throwNullException)("namedChild.name");t.unshift(new ne.Path.Component(i.name));}else t.unshift(new ne.Path.Component(n.content.indexOf(e)));e=n,n=(0, ie.asOrNull)(n.parent,xe.Container);}this._path=new ne.Path(t);}return this._path}ResolvePath(t){if(t===null)return (0, _n.throwNullException)("path");if(t.isRelative){let e=(0, ie.asOrNull)(this,xe.Container);return e===null&&(jr.Debug.Assert(this.parent!==null,"Can't resolve relative path because we don't have a parent"),e=(0, ie.asOrNull)(this.parent,xe.Container),jr.Debug.Assert(e!==null,"Expected parent to be a container"),jr.Debug.Assert(t.GetComponent(0).isParent),t=t.tail),e===null?(0, _n.throwNullException)("nearestContainer"):e.ContentAtPath(t)}else {let e=this.rootContentContainer;return e===null?(0, _n.throwNullException)("contentContainer"):e.ContentAtPath(t)}}ConvertPathToRelative(t){let e=this.path,n=Math.min(t.length,e.length),i=-1;for(let l=0;l<n;++l){let u=e.GetComponent(l),h=t.GetComponent(l);if(u.Equals(h))i=l;else break}if(i==-1)return t;let s=e.componentCount-1-i,r=[];for(let l=0;l<s;++l)r.push(ne.Path.Component.ToParent());for(let l=i+1;l<t.componentCount;++l)r.push(t.GetComponent(l));return new ne.Path(r,true)}CompactPathString(t){let e=null,n=null;return t.isRelative?(n=t.componentsString,e=this.path.PathByAppendingPath(t).componentsString):(n=this.ConvertPathToRelative(t).componentsString,e=t.componentsString),n.length<e.length?n:e}get rootContentContainer(){let t=this;for(;t.parent;)t=t.parent;return (0, ie.asOrNull)(t,xe.Container)}Copy(){throw Error("Not Implemented: Doesn't support copying")}SetChild(t,e,n){t[e]&&(t[e]=null),t[e]=n,t[e]&&(t[e].parent=this);}Equals(t){return t===this}};bn.InkObject=Mr;});var Bt=f(En=>{Object.defineProperty(En,"__esModule",{value:true});En.StringBuilder=void 0;var Br=class{constructor(t){t=typeof t<"u"?t.toString():"",this.string=t;}get Length(){return this.string.length}Append(t){t!==null&&(this.string+=t);}AppendLine(t){typeof t<"u"&&this.Append(t),this.string+=`
`;}AppendFormat(t,...e){this.string+=t.replace(/{(\d+)}/g,(n,i)=>typeof e[i]<"u"?e[i]:n);}toString(){return this.string}Clear(){this.string="";}};En.StringBuilder=Br;});var et=f(re=>{Object.defineProperty(re,"__esModule",{value:true});re.InkList=re.InkListItem=void 0;var mt=G(),vu=Bt(),tt=class o{constructor(){if(this.originName=null,this.itemName=null,typeof arguments[1]<"u"){let t=arguments[0],e=arguments[1];this.originName=t,this.itemName=e;}else if(arguments[0]){let e=arguments[0].toString().split(".");this.originName=e[0],this.itemName=e[1];}}static get Null(){return new o(null,null)}get isNull(){return this.originName==null&&this.itemName==null}get fullName(){return (this.originName!==null?this.originName:"?")+"."+this.itemName}toString(){return this.fullName}Equals(t){if(t instanceof o){let e=t;return e.itemName==this.itemName&&e.originName==this.originName}return false}copy(){return new o(this.originName,this.itemName)}serialized(){return JSON.stringify({originName:this.originName,itemName:this.itemName})}static fromSerializedKey(t){let e=JSON.parse(t);if(!o.isLikeInkListItem(e))return o.Null;let n=e;return new o(n.originName,n.itemName)}static isLikeInkListItem(t){return !(typeof t!="object"||!t.hasOwnProperty("originName")||!t.hasOwnProperty("itemName")||typeof t.originName!="string"&&typeof t.originName!==null||typeof t.itemName!="string"&&typeof t.itemName!==null)}};re.InkListItem=tt;var Gr=class o extends Map{constructor(){if(super(arguments[0]instanceof o?arguments[0]:[]),this.origins=null,this._originNames=[],arguments[0]instanceof o){let t=arguments[0],e=t.originNames;e!==null&&(this._originNames=e.slice()),t.origins!==null&&(this.origins=t.origins.slice());}else if(typeof arguments[0]=="string"){let t=arguments[0],e=arguments[1];if(this.SetInitialOriginName(t),e.listDefinitions===null)return (0, mt.throwNullException)("originStory.listDefinitions");let n=e.listDefinitions.TryListGetDefinition(t,null);if(n.exists){if(n.result===null)return (0, mt.throwNullException)("def.result");this.origins=[n.result];}else throw new Error("InkList origin could not be found in story when constructing new list: "+t)}else if(typeof arguments[0]=="object"&&arguments[0].hasOwnProperty("Key")&&arguments[0].hasOwnProperty("Value")){let t=arguments[0];this.Add(t.Key,t.Value);}}static FromString(t,e){var n;if(t==null||t=="")return new o;let i=(n=e.listDefinitions)===null||n===void 0?void 0:n.FindSingleItemListWithName(t);if(i)return i.value===null?(0, mt.throwNullException)("listValue.value"):new o(i.value);throw new Error("Could not find the InkListItem from the string '"+t+"' to create an InkList because it doesn't exist in the original list definition in ink.")}AddItem(t,e=null){if(t instanceof tt){let n=t;if(n.originName==null){this.AddItem(n.itemName);return}if(this.origins===null)return (0, mt.throwNullException)("this.origins");for(let i of this.origins)if(i.name==n.originName){let s=i.TryGetValueForItem(n,0);if(s.exists){this.Add(n,s.result);return}else throw new Error("Could not add the item "+n+" to this list because it doesn't exist in the original list definition in ink.")}throw new Error("Failed to add item to list because the item was from a new list definition that wasn't previously known to this list. Only items from previously known lists can be used, so that the int value can be found.")}else if(t!==null){let n=t,i=null;if(this.origins===null)return (0, mt.throwNullException)("this.origins");for(let s of this.origins){if(n===null)return (0, mt.throwNullException)("itemName");if(s.ContainsItemWithName(n)){if(i!=null)throw new Error("Could not add the item "+n+" to this list because it could come from either "+s.name+" or "+i.name);i=s;}}if(i==null){if(e==null)throw new Error("Could not add the item "+n+" to this list because it isn't known to any list definitions previously associated with this list.");{let s=o.FromString(n,e).orderedItems[0];this.Add(s.Key,s.Value);}}else {let s=new tt(i.name,n),r=i.ValueForItem(s);this.Add(s,r);}}}ContainsItemNamed(t){for(let[e]of this)if(tt.fromSerializedKey(e).itemName==t)return true;return false}ContainsKey(t){return this.has(t.serialized())}Add(t,e){let n=t.serialized();if(this.has(n))throw new Error(`The Map already contains an entry for ${t}`);this.set(n,e);}Remove(t){return this.delete(t.serialized())}get Count(){return this.size}get originOfMaxItem(){if(this.origins==null)return null;let t=this.maxItem.Key.originName,e=null;return this.origins.every(n=>n.name==t?(e=n,false):true),e}get originNames(){if(this.Count>0){this._originNames==null&&this.Count>0?this._originNames=[]:(this._originNames||(this._originNames=[]),this._originNames.length=0);for(let[t]of this){let e=tt.fromSerializedKey(t);if(e.originName===null)return (0, mt.throwNullException)("item.originName");this._originNames.push(e.originName);}}return this._originNames}SetInitialOriginName(t){this._originNames=[t];}SetInitialOriginNames(t){t==null?this._originNames=null:this._originNames=t.slice();}get maxItem(){let t={Key:tt.Null,Value:0};for(let[e,n]of this){let i=tt.fromSerializedKey(e);(t.Key.isNull||n>t.Value)&&(t={Key:i,Value:n});}return t}get minItem(){let t={Key:tt.Null,Value:0};for(let[e,n]of this){let i=tt.fromSerializedKey(e);(t.Key.isNull||n<t.Value)&&(t={Key:i,Value:n});}return t}get inverse(){let t=new o;if(this.origins!=null)for(let e of this.origins)for(let[n,i]of e.items){let s=tt.fromSerializedKey(n);this.ContainsKey(s)||t.Add(s,i);}return t}get all(){let t=new o;if(this.origins!=null)for(let e of this.origins)for(let[n,i]of e.items){let s=tt.fromSerializedKey(n);t.set(s.serialized(),i);}return t}Union(t){let e=new o(this);for(let[n,i]of t)e.set(n,i);return e}Intersect(t){let e=new o;for(let[n,i]of this)t.has(n)&&e.set(n,i);return e}HasIntersection(t){for(let[e]of this)if(t.has(e))return true;return false}Without(t){let e=new o(this);for(let[n]of t)e.delete(n);return e}Contains(t){if(typeof t=="string")return this.ContainsItemNamed(t);let e=t;if(e.size==0||this.size==0)return false;for(let[n]of e)if(!this.has(n))return false;return true}GreaterThan(t){return this.Count==0?false:t.Count==0?true:this.minItem.Value>t.maxItem.Value}GreaterThanOrEquals(t){return this.Count==0?false:t.Count==0?true:this.minItem.Value>=t.minItem.Value&&this.maxItem.Value>=t.maxItem.Value}LessThan(t){return t.Count==0?false:this.Count==0?true:this.maxItem.Value<t.minItem.Value}LessThanOrEquals(t){return t.Count==0?false:this.Count==0?true:this.maxItem.Value<=t.maxItem.Value&&this.minItem.Value<=t.minItem.Value}MaxAsList(){return this.Count>0?new o(this.maxItem):new o}MinAsList(){return this.Count>0?new o(this.minItem):new o}ListWithSubRange(t,e){if(this.Count==0)return new o;let n=this.orderedItems,i=0,s=Number.MAX_SAFE_INTEGER;Number.isInteger(t)?i=t:t instanceof o&&t.Count>0&&(i=t.minItem.Value),Number.isInteger(e)?s=e:e instanceof o&&e.Count>0&&(s=e.maxItem.Value);let r=new o;r.SetInitialOriginNames(this.originNames);for(let a of n)a.Value>=i&&a.Value<=s&&r.Add(a.Key,a.Value);return r}Equals(t){if(!(t instanceof o)||t.Count!=this.Count)return false;for(let[e]of this)if(!t.has(e))return false;return true}get orderedItems(){let t=new Array;for(let[e,n]of this){let i=tt.fromSerializedKey(e);t.push({Key:i,Value:n});}return t.sort((e,n)=>e.Key.originName===null?(0, mt.throwNullException)("x.Key.originName"):n.Key.originName===null?(0, mt.throwNullException)("y.Key.originName"):e.Value==n.Value?e.Key.originName.localeCompare(n.Key.originName):e.Value<n.Value?-1:e.Value>n.Value?1:0),t}get singleItem(){for(let t of this.orderedItems)return t.Key;return null}toString(){let t=this.orderedItems,e=new vu.StringBuilder;for(let n=0;n<t.length;n++){n>0&&e.Append(", ");let i=t[n].Key;if(i.itemName===null)return (0, mt.throwNullException)("item.itemName");e.Append(i.itemName);}return e.toString()}valueOf(){return NaN}};re.InkList=Gr;});var Te=f(wn=>{Object.defineProperty(wn,"__esModule",{value:true});wn.StoryException=void 0;var $r=class extends Error{constructor(t){super(t),this.useEndLineNumber=false,this.message=t,this.name="StoryException";}};wn.StoryException=$r;});var se=f(Ft=>{Object.defineProperty(Ft,"__esModule",{value:true});Ft.tryParseFloat=Ft.tryParseInt=Ft.tryGetValueFromMap=void 0;function Su(o,t,e){if(o===null)return {result:e,exists:false};let n=o.get(t);return typeof n>"u"?{result:e,exists:false}:{result:n,exists:true}}Ft.tryGetValueFromMap=Su;function yu(o,t=0){let e=parseInt(o);return Number.isNaN(e)?{result:t,exists:false}:{result:e,exists:true}}Ft.tryParseInt=yu;function _u(o,t=0){let e=parseFloat(o);return Number.isNaN(e)?{result:t,exists:false}:{result:e,exists:true}}Ft.tryParseFloat=_u;});var I=f(A=>{Object.defineProperty(A,"__esModule",{value:true});A.ValueType=A.ListValue=A.VariablePointerValue=A.DivertTargetValue=A.StringValue=A.FloatValue=A.IntValue=A.BoolValue=A.Value=A.AbstractValue=void 0;var co=Q(),fo=Z(),Gt=et(),bu=Te(),Ne=P(),po=se(),at=G(),Pn=class o extends co.InkObject{static Create(t,e){if(e){if(e===T.Int&&Number.isInteger(Number(t)))return new Ct(Number(t));if(e===T.Float&&!isNaN(t))return new vt(Number(t))}if(typeof t=="boolean")return new ae(!!t);if(typeof t=="string")return new xt(String(t));if(Number.isInteger(Number(t)))return new Ct(Number(t));if(isNaN(t)){if(t instanceof fo.Path)return new On((0, Ne.asOrThrows)(t,fo.Path));if(t instanceof Gt.InkList)return new xn((0, Ne.asOrThrows)(t,Gt.InkList))}else return new vt(Number(t));return null}Copy(){return (0, Ne.asOrThrows)(o.Create(this.valueObject),co.InkObject)}BadCastException(t){return new bu.StoryException("Can't cast "+this.valueObject+" from "+this.valueType+" to "+t)}};A.AbstractValue=Pn;var gt=class extends Pn{constructor(t){super(),this.value=t;}get valueObject(){return this.value}toString(){return this.value===null?(0, at.throwNullException)("Value.value"):this.value.toString()}};A.Value=gt;var ae=class extends gt{constructor(t){super(t||false);}get isTruthy(){return !!this.value}get valueType(){return T.Bool}Cast(t){if(this.value===null)return (0, at.throwNullException)("Value.value");if(t==this.valueType)return this;if(t==T.Int)return new Ct(this.value?1:0);if(t==T.Float)return new vt(this.value?1:0);if(t==T.String)return new xt(this.value?"true":"false");throw this.BadCastException(t)}toString(){return this.value?"true":"false"}};A.BoolValue=ae;var Ct=class extends gt{constructor(t){super(t||0);}get isTruthy(){return this.value!=0}get valueType(){return T.Int}Cast(t){if(this.value===null)return (0, at.throwNullException)("Value.value");if(t==this.valueType)return this;if(t==T.Bool)return new ae(this.value!==0);if(t==T.Float)return new vt(this.value);if(t==T.String)return new xt(""+this.value);throw this.BadCastException(t)}};A.IntValue=Ct;var vt=class extends gt{constructor(t){super(t||0);}get isTruthy(){return this.value!=0}get valueType(){return T.Float}Cast(t){if(this.value===null)return (0, at.throwNullException)("Value.value");if(t==this.valueType)return this;if(t==T.Bool)return new ae(this.value!==0);if(t==T.Int)return new Ct(this.value);if(t==T.String)return new xt(""+this.value);throw this.BadCastException(t)}};A.FloatValue=vt;var xt=class extends gt{constructor(t){if(super(t||""),this._isNewline=this.value==`
`,this._isInlineWhitespace=true,this.value===null)return (0, at.throwNullException)("Value.value");this.value.length>0&&this.value.split("").every(e=>e!=" "&&e!=" "?(this._isInlineWhitespace=false,false):true);}get valueType(){return T.String}get isTruthy(){return this.value===null?(0, at.throwNullException)("Value.value"):this.value.length>0}get isNewline(){return this._isNewline}get isInlineWhitespace(){return this._isInlineWhitespace}get isNonWhitespace(){return !this.isNewline&&!this.isInlineWhitespace}Cast(t){if(t==this.valueType)return this;if(t==T.Int){let e=(0, po.tryParseInt)(this.value);if(e.exists)return new Ct(e.result);throw this.BadCastException(t)}if(t==T.Float){let e=(0, po.tryParseFloat)(this.value);if(e.exists)return new vt(e.result);throw this.BadCastException(t)}throw this.BadCastException(t)}};A.StringValue=xt;var On=class extends gt{constructor(t=null){super(t);}get valueType(){return T.DivertTarget}get targetPath(){return this.value===null?(0, at.throwNullException)("Value.value"):this.value}set targetPath(t){this.value=t;}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a divert target")}Cast(t){if(t==this.valueType)return this;throw this.BadCastException(t)}toString(){return "DivertTargetValue("+this.targetPath+")"}};A.DivertTargetValue=On;var Ur=class o extends gt{constructor(t,e=-1){super(t),this._contextIndex=e;}get contextIndex(){return this._contextIndex}set contextIndex(t){this._contextIndex=t;}get variableName(){return this.value===null?(0, at.throwNullException)("Value.value"):this.value}set variableName(t){this.value=t;}get valueType(){return T.VariablePointer}get isTruthy(){throw new Error("Shouldn't be checking the truthiness of a variable pointer")}Cast(t){if(t==this.valueType)return this;throw this.BadCastException(t)}toString(){return "VariablePointerValue("+this.variableName+")"}Copy(){return new o(this.variableName,this.contextIndex)}};A.VariablePointerValue=Ur;var xn=class o extends gt{get isTruthy(){return this.value===null?(0, at.throwNullException)("this.value"):this.value.Count>0}get valueType(){return T.List}Cast(t){if(this.value===null)return (0, at.throwNullException)("Value.value");if(t==T.Int){let e=this.value.maxItem;return e.Key.isNull?new Ct(0):new Ct(e.Value)}else if(t==T.Float){let e=this.value.maxItem;return e.Key.isNull?new vt(0):new vt(e.Value)}else if(t==T.String){let e=this.value.maxItem;return e.Key.isNull?new xt(""):new xt(e.Key.toString())}if(t==this.valueType)return this;throw this.BadCastException(t)}constructor(t,e){super(null),!t&&!e?this.value=new Gt.InkList:t instanceof Gt.InkList?this.value=new Gt.InkList(t):t instanceof Gt.InkListItem&&typeof e=="number"&&(this.value=new Gt.InkList({Key:t,Value:e}));}static RetainListOriginsForAssignment(t,e){let n=(0, Ne.asOrNull)(t,o),i=(0, Ne.asOrNull)(e,o);if(i&&i.value===null)return (0, at.throwNullException)("newList.value");if(n&&n.value===null)return (0, at.throwNullException)("oldList.value");n&&i&&i.value.Count==0&&i.value.SetInitialOriginNames(n.value.originNames);}};A.ListValue=xn;var T;(function(o){o[o.Bool=-1]="Bool",o[o.Int=0]="Int",o[o.Float=1]="Float",o[o.List=2]="List",o[o.String=3]="String",o[o.DivertTarget=4]="DivertTarget",o[o.VariablePointer=5]="VariablePointer";})(T||(A.ValueType=T={}));});var mo=f(Tn=>{Object.defineProperty(Tn,"__esModule",{value:true});Tn.SearchResult=void 0;var Eu=k(),Kr=class o{constructor(){this.obj=null,this.approximate=false;}get correctObj(){return this.approximate?null:this.obj}get container(){return this.obj instanceof Eu.Container?this.obj:null}copy(){let t=new o;return t.obj=this.obj,t.approximate=this.approximate,t}};Tn.SearchResult=Kr;});var k=f(Ae=>{Object.defineProperty(Ae,"__esModule",{value:true});Ae.Container=void 0;var wu=I(),go=G(),Pu=Bt(),oe=Q(),Ou=mo(),Co=Z(),vo=Oe(),xu=se(),kt=P(),Ie=class o extends oe.InkObject{constructor(){super(...arguments),this.name=null,this._content=[],this.namedContent=new Map,this.visitsShouldBeCounted=false,this.turnIndexShouldBeCounted=false,this.countingAtStartOnly=false,this._pathToFirstLeafContent=null;}get hasValidName(){return this.name!=null&&this.name.length>0}get content(){return this._content}set content(t){this.AddContent(t);}get namedOnlyContent(){let t=new Map;for(let[e,n]of this.namedContent){let i=(0, kt.asOrThrows)(n,oe.InkObject);t.set(e,i);}for(let e of this.content){let n=(0, kt.asINamedContentOrNull)(e);n!=null&&n.hasValidName&&t.delete(n.name);}return t.size==0&&(t=null),t}set namedOnlyContent(t){let e=this.namedOnlyContent;if(e!=null)for(let[n]of e)this.namedContent.delete(n);if(t!=null)for(let[,n]of t){let i=(0, kt.asINamedContentOrNull)(n);i!=null&&this.AddToNamedContentOnly(i);}}get countFlags(){let t=0;return this.visitsShouldBeCounted&&(t|=o.CountFlags.Visits),this.turnIndexShouldBeCounted&&(t|=o.CountFlags.Turns),this.countingAtStartOnly&&(t|=o.CountFlags.CountStartOnly),t==o.CountFlags.CountStartOnly&&(t=0),t}set countFlags(t){let e=t;(e&o.CountFlags.Visits)>0&&(this.visitsShouldBeCounted=true),(e&o.CountFlags.Turns)>0&&(this.turnIndexShouldBeCounted=true),(e&o.CountFlags.CountStartOnly)>0&&(this.countingAtStartOnly=true);}get pathToFirstLeafContent(){return this._pathToFirstLeafContent==null&&(this._pathToFirstLeafContent=this.path.PathByAppendingPath(this.internalPathToFirstLeafContent)),this._pathToFirstLeafContent}get internalPathToFirstLeafContent(){let t=[],e=this;for(;e instanceof o;)e.content.length>0&&(t.push(new Co.Path.Component(0)),e=e.content[0]);return new Co.Path(t)}AddContent(t){if(t instanceof Array){let e=t;for(let n of e)this.AddContent(n);}else {let e=t;if(this._content.push(e),e.parent)throw new Error("content is already in "+e.parent);e.parent=this,this.TryAddNamedContent(e);}}TryAddNamedContent(t){let e=(0, kt.asINamedContentOrNull)(t);e!=null&&e.hasValidName&&this.AddToNamedContentOnly(e);}AddToNamedContentOnly(t){vo.Debug.AssertType(t,oe.InkObject,"Can only add Runtime.Objects to a Runtime.Container");let e=(0, kt.asOrThrows)(t,oe.InkObject);if(e.parent=this,t.name===null)return (0, go.throwNullException)("namedContentObj.name");this.namedContent.set(t.name,t);}ContentAtPath(t,e=0,n=-1){n==-1&&(n=t.length);let i=new Ou.SearchResult;i.approximate=false;let s=this,r=this;for(let a=e;a<n;++a){let l=t.GetComponent(a);if(s==null){i.approximate=true;break}let u=s.ContentWithPathComponent(l);if(u==null){i.approximate=true;break}let h=(0, kt.asOrNull)(u,o);if(a<n-1&&h==null){i.approximate=true;break}r=u,s=h;}return i.obj=r,i}InsertContent(t,e){if(this.content.splice(e,0,t),t.parent)throw new Error("content is already in "+t.parent);t.parent=this,this.TryAddNamedContent(t);}AddContentsOfContainer(t){this.content.push(...t.content);for(let e of t.content)e.parent=this,this.TryAddNamedContent(e);}ContentWithPathComponent(t){if(t.isIndex)return t.index>=0&&t.index<this.content.length?this.content[t.index]:null;if(t.isParent)return this.parent;{if(t.name===null)return (0, go.throwNullException)("component.name");let e=(0, xu.tryGetValueFromMap)(this.namedContent,t.name,null);return e.exists?(0, kt.asOrThrows)(e.result,oe.InkObject):null}}BuildStringOfHierarchy(){let t;if(arguments.length==0)return t=new Pu.StringBuilder,this.BuildStringOfHierarchy(t,0,null),t.toString();t=arguments[0];let e=arguments[1],n=arguments[2];function i(){for(let a=0;a<4*e;++a)t.Append(" ");}i(),t.Append("["),this.hasValidName&&t.AppendFormat(" ({0})",this.name),this==n&&t.Append(" <---"),t.AppendLine(),e++;for(let r=0;r<this.content.length;++r){let a=this.content[r];a instanceof o?a.BuildStringOfHierarchy(t,e,n):(i(),a instanceof wu.StringValue?(t.Append('"'),t.Append(a.toString().replace(`
`,"\\n")),t.Append('"')):t.Append(a.toString())),r!=this.content.length-1&&t.Append(","),!(a instanceof o)&&a==n&&t.Append(" <---"),t.AppendLine();}let s=new Map;for(let[r,a]of this.namedContent)this.content.indexOf((0, kt.asOrThrows)(a,oe.InkObject))>=0||s.set(r,a);if(s.size>0){i(),t.AppendLine("-- named: --");for(let[,r]of s)vo.Debug.AssertType(r,o,"Can only print out named Containers"),r.BuildStringOfHierarchy(t,e,n),t.AppendLine();}e--,i(),t.Append("]");}};Ae.Container=Ie;(function(o){(function(e){e[e.Start=0]="Start",e[e.Visits=1]="Visits",e[e.Turns=2]="Turns",e[e.CountStartOnly=4]="CountStartOnly";})(o.CountFlags||(o.CountFlags={}));})(Ie||(Ae.Container=Ie={}));});var $=f(ke=>{Object.defineProperty(ke,"__esModule",{value:true});ke.ControlCommand=void 0;var Tu=Q(),Fe=class o extends Tu.InkObject{get commandType(){return this._commandType}constructor(t=o.CommandType.NotSet){super(),this._commandType=t;}Copy(){return new o(this.commandType)}static EvalStart(){return new o(o.CommandType.EvalStart)}static EvalOutput(){return new o(o.CommandType.EvalOutput)}static EvalEnd(){return new o(o.CommandType.EvalEnd)}static Duplicate(){return new o(o.CommandType.Duplicate)}static PopEvaluatedValue(){return new o(o.CommandType.PopEvaluatedValue)}static PopFunction(){return new o(o.CommandType.PopFunction)}static PopTunnel(){return new o(o.CommandType.PopTunnel)}static BeginString(){return new o(o.CommandType.BeginString)}static EndString(){return new o(o.CommandType.EndString)}static NoOp(){return new o(o.CommandType.NoOp)}static ChoiceCount(){return new o(o.CommandType.ChoiceCount)}static Turns(){return new o(o.CommandType.Turns)}static TurnsSince(){return new o(o.CommandType.TurnsSince)}static ReadCount(){return new o(o.CommandType.ReadCount)}static Random(){return new o(o.CommandType.Random)}static SeedRandom(){return new o(o.CommandType.SeedRandom)}static VisitIndex(){return new o(o.CommandType.VisitIndex)}static SequenceShuffleIndex(){return new o(o.CommandType.SequenceShuffleIndex)}static StartThread(){return new o(o.CommandType.StartThread)}static Done(){return new o(o.CommandType.Done)}static End(){return new o(o.CommandType.End)}static ListFromInt(){return new o(o.CommandType.ListFromInt)}static ListRange(){return new o(o.CommandType.ListRange)}static ListRandom(){return new o(o.CommandType.ListRandom)}static BeginTag(){return new o(o.CommandType.BeginTag)}static EndTag(){return new o(o.CommandType.EndTag)}toString(){return "ControlCommand "+this.commandType.toString()}};ke.ControlCommand=Fe;(function(o){(function(e){e[e.NotSet=-1]="NotSet",e[e.EvalStart=0]="EvalStart",e[e.EvalOutput=1]="EvalOutput",e[e.EvalEnd=2]="EvalEnd",e[e.Duplicate=3]="Duplicate",e[e.PopEvaluatedValue=4]="PopEvaluatedValue",e[e.PopFunction=5]="PopFunction",e[e.PopTunnel=6]="PopTunnel",e[e.BeginString=7]="BeginString",e[e.EndString=8]="EndString",e[e.NoOp=9]="NoOp",e[e.ChoiceCount=10]="ChoiceCount",e[e.Turns=11]="Turns",e[e.TurnsSince=12]="TurnsSince",e[e.ReadCount=13]="ReadCount",e[e.Random=14]="Random",e[e.SeedRandom=15]="SeedRandom",e[e.VisitIndex=16]="VisitIndex",e[e.SequenceShuffleIndex=17]="SequenceShuffleIndex",e[e.StartThread=18]="StartThread",e[e.Done=19]="Done",e[e.End=20]="End",e[e.ListFromInt=21]="ListFromInt",e[e.ListRange=22]="ListRange",e[e.ListRandom=23]="ListRandom",e[e.BeginTag=24]="BeginTag",e[e.EndTag=25]="EndTag",e[e.TOTAL_VALUES=26]="TOTAL_VALUES";})(o.CommandType||(o.CommandType={}));})(Fe||(ke.ControlCommand=Fe={}));});var ot=f(Nn=>{Object.defineProperty(Nn,"__esModule",{value:true});Nn.Expression=void 0;var So=k(),Hr=$(),Nu=N(),Jr=class extends Nu.ParsedObject{constructor(){super(...arguments),this._prototypeRuntimeConstantExpression=null,this.outputWhenComplete=false,this.GenerateRuntimeObject=()=>{let t=new So.Container;return t.AddContent(Hr.ControlCommand.EvalStart()),this.GenerateIntoContainer(t),this.outputWhenComplete&&t.AddContent(Hr.ControlCommand.EvalOutput()),t.AddContent(Hr.ControlCommand.EvalEnd()),t},this.GenerateConstantIntoContainer=t=>{this._prototypeRuntimeConstantExpression===null&&(this._prototypeRuntimeConstantExpression=new So.Container,this.GenerateIntoContainer(this._prototypeRuntimeConstantExpression));for(let e of this._prototypeRuntimeConstantExpression.content){let n=e.Copy();n&&t.AddContent(n);}},this.toString=()=>"No string value in JavaScript.";}get typeName(){return "Expression"}Equals(t){return false}};Nn.Expression=Jr;});var $t=f(In=>{Object.defineProperty(In,"__esModule",{value:true});In.Void=void 0;var Iu=Q(),zr=class extends Iu.InkObject{toString(){return "Void"}};In.Void=zr;});var St=f(Fn=>{Object.defineProperty(Fn,"__esModule",{value:true});Fn.NativeFunctionCall=void 0;var m=I(),Re=Te(),Au=$t(),An=et(),Fu=Q(),lt=P(),nt=G(),_=class o extends Fu.InkObject{static CallWithName(t){return new o(t)}static CallExistsWithName(t){return this.GenerateNativeFunctionsIfNecessary(),this._nativeFunctions.get(t)}get name(){return this._name===null?(0, nt.throwNullException)("NativeFunctionCall._name"):this._name}set name(t){this._name=t,this._isPrototype||(o._nativeFunctions===null?(0, nt.throwNullException)("NativeFunctionCall._nativeFunctions"):this._prototype=o._nativeFunctions.get(this._name)||null);}get numberOfParameters(){return this._prototype?this._prototype.numberOfParameters:this._numberOfParameters}set numberOfParameters(t){this._numberOfParameters=t;}Call(t){if(this._prototype)return this._prototype.Call(t);if(this.numberOfParameters!=t.length)throw new Error("Unexpected number of parameters");let e=false;for(let s of t){if(s instanceof Au.Void)throw new Re.StoryException("Attempting to perform "+this.name+' on a void value. Did you forget to "return" a value from a function you called here?');s instanceof m.ListValue&&(e=true);}if(t.length==2&&e)return this.CallBinaryListOperation(t);let n=this.CoerceValuesToSingleType(t),i=n[0].valueType;return i==m.ValueType.Int?this.CallType(n):i==m.ValueType.Float?this.CallType(n):i==m.ValueType.String?this.CallType(n):i==m.ValueType.DivertTarget?this.CallType(n):i==m.ValueType.List?this.CallType(n):null}CallType(t){let e=(0, lt.asOrThrows)(t[0],m.Value),n=e.valueType,i=e,s=t.length;if(s==2||s==1){if(this._operationFuncs===null)return (0, nt.throwNullException)("NativeFunctionCall._operationFuncs");let r=this._operationFuncs.get(n);if(!r){let a=m.ValueType[n];throw new Re.StoryException("Cannot perform operation "+this.name+" on "+a)}if(s==2){let l=(0, lt.asOrThrows)(t[1],m.Value),u=r;if(i.value===null||l.value===null)return (0, nt.throwNullException)("NativeFunctionCall.Call BinaryOp values");let h=u(i.value,l.value);return m.Value.Create(h)}else {let a=r;if(i.value===null)return (0, nt.throwNullException)("NativeFunctionCall.Call UnaryOp value");let l=a(i.value);return this.name===o.Int?m.Value.Create(l,m.ValueType.Int):this.name===o.Float?m.Value.Create(l,m.ValueType.Float):m.Value.Create(l,e.valueType)}}else throw new Error("Unexpected number of parameters to NativeFunctionCall: "+t.length)}CallBinaryListOperation(t){if((this.name=="+"||this.name=="-")&&t[0]instanceof m.ListValue&&t[1]instanceof m.IntValue)return this.CallListIncrementOperation(t);let e=(0, lt.asOrThrows)(t[0],m.Value),n=(0, lt.asOrThrows)(t[1],m.Value);if((this.name=="&&"||this.name=="||")&&(e.valueType!=m.ValueType.List||n.valueType!=m.ValueType.List)){if(this._operationFuncs===null)return (0, nt.throwNullException)("NativeFunctionCall._operationFuncs");let i=this._operationFuncs.get(m.ValueType.Int);if(i===null)return (0, nt.throwNullException)("NativeFunctionCall.CallBinaryListOperation op");let s=(0, lt.asBooleanOrThrows)(i(e.isTruthy?1:0,n.isTruthy?1:0));return new m.BoolValue(s)}if(e.valueType==m.ValueType.List&&n.valueType==m.ValueType.List)return this.CallType([e,n]);throw new Re.StoryException("Can not call use "+this.name+" operation on "+m.ValueType[e.valueType]+" and "+m.ValueType[n.valueType])}CallListIncrementOperation(t){let e=(0, lt.asOrThrows)(t[0],m.ListValue),n=(0, lt.asOrThrows)(t[1],m.IntValue),i=new An.InkList;if(e.value===null)return (0, nt.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value");for(let[s,r]of e.value){let a=An.InkListItem.fromSerializedKey(s);if(this._operationFuncs===null)return (0, nt.throwNullException)("NativeFunctionCall._operationFuncs");let l=this._operationFuncs.get(m.ValueType.Int);if(n.value===null)return (0, nt.throwNullException)("NativeFunctionCall.CallListIncrementOperation intVal.value");let u=l(r,n.value),h=null;if(e.value.origins===null)return (0, nt.throwNullException)("NativeFunctionCall.CallListIncrementOperation listVal.value.origins");for(let c of e.value.origins)if(c.name==a.originName){h=c;break}if(h!=null){let c=h.TryGetItemWithValue(u,An.InkListItem.Null);c.exists&&i.Add(c.result,u);}}return new m.ListValue(i)}CoerceValuesToSingleType(t){let e=m.ValueType.Int,n=null;for(let s of t){let r=(0, lt.asOrThrows)(s,m.Value);r.valueType>e&&(e=r.valueType),r.valueType==m.ValueType.List&&(n=(0, lt.asOrNull)(r,m.ListValue));}let i=[];if(m.ValueType[e]==m.ValueType[m.ValueType.List])for(let s of t){let r=(0, lt.asOrThrows)(s,m.Value);if(r.valueType==m.ValueType.List)i.push(r);else if(r.valueType==m.ValueType.Int){let a=parseInt(r.valueObject);if(n=(0, lt.asOrThrows)(n,m.ListValue),n.value===null)return (0, nt.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType specialCaseList.value");let l=n.value.originOfMaxItem;if(l===null)return (0, nt.throwNullException)("NativeFunctionCall.CoerceValuesToSingleType list");let u=l.TryGetItemWithValue(a,An.InkListItem.Null);if(u.exists){let h=new m.ListValue(u.result,a);i.push(h);}else throw new Re.StoryException("Could not find List item with the value "+a+" in "+l.name)}else {let a=m.ValueType[r.valueType];throw new Re.StoryException("Cannot mix Lists and "+a+" values in this operation")}}else for(let s of t){let a=(0, lt.asOrThrows)(s,m.Value).Cast(e);i.push(a);}return i}constructor(){if(super(),this._name=null,this._numberOfParameters=0,this._prototype=null,this._isPrototype=false,this._operationFuncs=null,arguments.length===0)o.GenerateNativeFunctionsIfNecessary();else if(arguments.length===1){let t=arguments[0];o.GenerateNativeFunctionsIfNecessary(),this.name=t;}else if(arguments.length===2){let t=arguments[0],e=arguments[1];this._isPrototype=true,this.name=t,this.numberOfParameters=e;}}static Identity(t){return t}static GenerateNativeFunctionsIfNecessary(){if(this._nativeFunctions==null){this._nativeFunctions=new Map,this.AddIntBinaryOp(this.Add,(n,i)=>n+i),this.AddIntBinaryOp(this.Subtract,(n,i)=>n-i),this.AddIntBinaryOp(this.Multiply,(n,i)=>n*i),this.AddIntBinaryOp(this.Divide,(n,i)=>Math.floor(n/i)),this.AddIntBinaryOp(this.Mod,(n,i)=>n%i),this.AddIntUnaryOp(this.Negate,n=>-n),this.AddIntBinaryOp(this.Equal,(n,i)=>n==i),this.AddIntBinaryOp(this.Greater,(n,i)=>n>i),this.AddIntBinaryOp(this.Less,(n,i)=>n<i),this.AddIntBinaryOp(this.GreaterThanOrEquals,(n,i)=>n>=i),this.AddIntBinaryOp(this.LessThanOrEquals,(n,i)=>n<=i),this.AddIntBinaryOp(this.NotEquals,(n,i)=>n!=i),this.AddIntUnaryOp(this.Not,n=>n==0),this.AddIntBinaryOp(this.And,(n,i)=>n!=0&&i!=0),this.AddIntBinaryOp(this.Or,(n,i)=>n!=0||i!=0),this.AddIntBinaryOp(this.Max,(n,i)=>Math.max(n,i)),this.AddIntBinaryOp(this.Min,(n,i)=>Math.min(n,i)),this.AddIntBinaryOp(this.Pow,(n,i)=>Math.pow(n,i)),this.AddIntUnaryOp(this.Floor,o.Identity),this.AddIntUnaryOp(this.Ceiling,o.Identity),this.AddIntUnaryOp(this.Int,o.Identity),this.AddIntUnaryOp(this.Float,n=>n),this.AddFloatBinaryOp(this.Add,(n,i)=>n+i),this.AddFloatBinaryOp(this.Subtract,(n,i)=>n-i),this.AddFloatBinaryOp(this.Multiply,(n,i)=>n*i),this.AddFloatBinaryOp(this.Divide,(n,i)=>n/i),this.AddFloatBinaryOp(this.Mod,(n,i)=>n%i),this.AddFloatUnaryOp(this.Negate,n=>-n),this.AddFloatBinaryOp(this.Equal,(n,i)=>n==i),this.AddFloatBinaryOp(this.Greater,(n,i)=>n>i),this.AddFloatBinaryOp(this.Less,(n,i)=>n<i),this.AddFloatBinaryOp(this.GreaterThanOrEquals,(n,i)=>n>=i),this.AddFloatBinaryOp(this.LessThanOrEquals,(n,i)=>n<=i),this.AddFloatBinaryOp(this.NotEquals,(n,i)=>n!=i),this.AddFloatUnaryOp(this.Not,n=>n==0),this.AddFloatBinaryOp(this.And,(n,i)=>n!=0&&i!=0),this.AddFloatBinaryOp(this.Or,(n,i)=>n!=0||i!=0),this.AddFloatBinaryOp(this.Max,(n,i)=>Math.max(n,i)),this.AddFloatBinaryOp(this.Min,(n,i)=>Math.min(n,i)),this.AddFloatBinaryOp(this.Pow,(n,i)=>Math.pow(n,i)),this.AddFloatUnaryOp(this.Floor,n=>Math.floor(n)),this.AddFloatUnaryOp(this.Ceiling,n=>Math.ceil(n)),this.AddFloatUnaryOp(this.Int,n=>Math.floor(n)),this.AddFloatUnaryOp(this.Float,o.Identity),this.AddStringBinaryOp(this.Add,(n,i)=>n+i),this.AddStringBinaryOp(this.Equal,(n,i)=>n===i),this.AddStringBinaryOp(this.NotEquals,(n,i)=>n!==i),this.AddStringBinaryOp(this.Has,(n,i)=>n.includes(i)),this.AddStringBinaryOp(this.Hasnt,(n,i)=>!n.includes(i)),this.AddListBinaryOp(this.Add,(n,i)=>n.Union(i)),this.AddListBinaryOp(this.Subtract,(n,i)=>n.Without(i)),this.AddListBinaryOp(this.Has,(n,i)=>n.Contains(i)),this.AddListBinaryOp(this.Hasnt,(n,i)=>!n.Contains(i)),this.AddListBinaryOp(this.Intersect,(n,i)=>n.Intersect(i)),this.AddListBinaryOp(this.Equal,(n,i)=>n.Equals(i)),this.AddListBinaryOp(this.Greater,(n,i)=>n.GreaterThan(i)),this.AddListBinaryOp(this.Less,(n,i)=>n.LessThan(i)),this.AddListBinaryOp(this.GreaterThanOrEquals,(n,i)=>n.GreaterThanOrEquals(i)),this.AddListBinaryOp(this.LessThanOrEquals,(n,i)=>n.LessThanOrEquals(i)),this.AddListBinaryOp(this.NotEquals,(n,i)=>!n.Equals(i)),this.AddListBinaryOp(this.And,(n,i)=>n.Count>0&&i.Count>0),this.AddListBinaryOp(this.Or,(n,i)=>n.Count>0||i.Count>0),this.AddListUnaryOp(this.Not,n=>n.Count==0?1:0),this.AddListUnaryOp(this.Invert,n=>n.inverse),this.AddListUnaryOp(this.All,n=>n.all),this.AddListUnaryOp(this.ListMin,n=>n.MinAsList()),this.AddListUnaryOp(this.ListMax,n=>n.MaxAsList()),this.AddListUnaryOp(this.Count,n=>n.Count),this.AddListUnaryOp(this.ValueOfList,n=>n.maxItem.Value);let t=(n,i)=>n.Equals(i),e=(n,i)=>!n.Equals(i);this.AddOpToNativeFunc(this.Equal,2,m.ValueType.DivertTarget,t),this.AddOpToNativeFunc(this.NotEquals,2,m.ValueType.DivertTarget,e);}}AddOpFuncForType(t,e){this._operationFuncs==null&&(this._operationFuncs=new Map),this._operationFuncs.set(t,e);}static AddOpToNativeFunc(t,e,n,i){if(this._nativeFunctions===null)return (0, nt.throwNullException)("NativeFunctionCall._nativeFunctions");let s=this._nativeFunctions.get(t);s||(s=new o(t,e),this._nativeFunctions.set(t,s)),s.AddOpFuncForType(n,i);}static AddIntBinaryOp(t,e){this.AddOpToNativeFunc(t,2,m.ValueType.Int,e);}static AddIntUnaryOp(t,e){this.AddOpToNativeFunc(t,1,m.ValueType.Int,e);}static AddFloatBinaryOp(t,e){this.AddOpToNativeFunc(t,2,m.ValueType.Float,e);}static AddFloatUnaryOp(t,e){this.AddOpToNativeFunc(t,1,m.ValueType.Float,e);}static AddStringBinaryOp(t,e){this.AddOpToNativeFunc(t,2,m.ValueType.String,e);}static AddListBinaryOp(t,e){this.AddOpToNativeFunc(t,2,m.ValueType.List,e);}static AddListUnaryOp(t,e){this.AddOpToNativeFunc(t,1,m.ValueType.List,e);}toString(){return 'Native "'+this.name+'"'}};Fn.NativeFunctionCall=_;_.Add="+";_.Subtract="-";_.Divide="/";_.Multiply="*";_.Mod="%";_.Negate="_";_.Equal="==";_.Greater=">";_.Less="<";_.GreaterThanOrEquals=">=";_.LessThanOrEquals="<=";_.NotEquals="!=";_.Not="!";_.And="&&";_.Or="||";_.Min="MIN";_.Max="MAX";_.Pow="POW";_.Floor="FLOOR";_.Ceiling="CEILING";_.Int="INT";_.Float="FLOAT";_.Has="?";_.Hasnt="!?";_.Intersect="^";_.ListMin="LIST_MIN";_.ListMax="LIST_MAX";_.All="LIST_ALL";_.Count="LIST_COUNT";_.ValueOfList="LIST_VALUE";_.Invert="LIST_INVERT";_._nativeFunctions=null;});var Rn=f(kn=>{Object.defineProperty(kn,"__esModule",{value:true});kn.NumberExpression=void 0;var ku=ot(),Xr=I(),Ru=P(),Yr=class o extends ku.Expression{constructor(t,e){if(super(),this.isInt=()=>this.subtype=="int",this.isFloat=()=>this.subtype=="float",this.isBool=()=>this.subtype=="bool",this.GenerateIntoContainer=n=>{this.isInt()?n.AddContent(new Xr.IntValue(this.value)):this.isFloat()?n.AddContent(new Xr.FloatValue(this.value)):this.isBool()&&n.AddContent(new Xr.BoolValue(this.value));},this.toString=()=>String(this.value),typeof t=="number"&&!Number.isNaN(t)||typeof t=="boolean")this.value=t,this.subtype=e;else throw new Error("Unexpected object type in NumberExpression.")}get typeName(){return "Number"}Equals(t){let e=(0, Ru.asOrNull)(t,o);return e?e.subtype==this.subtype&&e.value==this.value:false}};kn.NumberExpression=Yr;});var Zr=f(Vn=>{Object.defineProperty(Vn,"__esModule",{value:true});Vn.UnaryExpression=void 0;var Vu=ot(),Wu=St(),le=Rn(),Du=P(),Ve=class extends Vu.Expression{get nativeNameForOp(){return this.op==="-"?"_":this.op==="not"?"!":this.op}constructor(t,e){super(),this.op=e,this.GenerateIntoContainer=n=>{this.innerExpression.GenerateIntoContainer(n),n.AddContent(Wu.NativeFunctionCall.CallWithName(this.nativeNameForOp));},this.toString=()=>this.nativeNameForOp+this.innerExpression,this.innerExpression=this.AddContent(t);}get typeName(){return "UnaryExpression"}};Vn.UnaryExpression=Ve;Ve.WithInner=(o,t)=>{let e=(0, Du.asOrNull)(o,le.NumberExpression);if(e){if(t==="-"){if(e.isInt())return new le.NumberExpression(-e.value,"int");if(e.isFloat())return new le.NumberExpression(-e.value,"float")}else if(t=="!"||t=="not"){if(e.isInt())return new le.NumberExpression(e.value==0,"bool");if(e.isFloat())return new le.NumberExpression(e.value==0,"bool");if(e.isBool())return new le.NumberExpression(!e.value,"bool")}throw new Error("Unexpected operation or number type")}return new Ve(o,t)};});var ts=f(Wn=>{Object.defineProperty(Wn,"__esModule",{value:true});Wn.BinaryExpression=void 0;var Lu=ot(),qu=St(),ju=Zr(),Mu=P(),Qr=class extends Lu.Expression{constructor(t,e,n){super(),this.opName=n,this.GenerateIntoContainer=i=>{this.leftExpression.GenerateIntoContainer(i),this.rightExpression.GenerateIntoContainer(i),this.opName=this.NativeNameForOp(this.opName),i.AddContent(qu.NativeFunctionCall.CallWithName(this.opName));},this.NativeNameForOp=i=>i==="and"?"&&":i==="or"?"||":i==="mod"?"%":i==="has"?"?":i==="hasnt"?"!?":i,this.toString=()=>`(${this.leftExpression} ${this.opName} ${this.rightExpression})`,this.leftExpression=this.AddContent(t),this.rightExpression=this.AddContent(e),this.opName=n;}get typeName(){return "BinaryExpression"}ResolveReferences(t){if(super.ResolveReferences(t),this.NativeNameForOp(this.opName)==="?"){let e=(0, Mu.asOrNull)(this.leftExpression,ju.UnaryExpression);e!==null&&(e.op==="not"||e.op==="!")&&this.Error(`Using 'not' or '!' here negates '${e.innerExpression}' rather than the result of the '?' or 'has' operator. You need to add parentheses around the (A ? B) expression.`);}}};Wn.BinaryExpression=Qr;});var De=f(Dn=>{Object.defineProperty(Dn,"__esModule",{value:true});Dn.CharacterSet=void 0;var We=class{constructor(t){this.set=new Set,this.Add=e=>this.set.add(e),this.AddRange=(e,n)=>{for(let i=e.charCodeAt(0);i<=n.charCodeAt(0);++i)this.Add(String.fromCharCode(i));return this},this.AddCharacters=e=>{if(typeof e=="string"||Array.isArray(e))for(let n of e)this.Add(n);else for(let n of e.set)this.Add(n);return this},t&&this.AddCharacters(t);}};Dn.CharacterSet=We;We.FromRange=(o,t)=>new We().AddRange(o,t);});var _o=f(Ln=>{Object.defineProperty(Ln,"__esModule",{value:true});Ln.CharacterRange=void 0;var yo=De(),Le=class{constructor(t,e,n=[]){if(this._start=t,this._end=e,this._correspondingCharSet=new yo.CharacterSet,this._excludes=new Set,this.ToCharacterSet=()=>{if(this._correspondingCharSet.set.size===0)for(let i=this.start.charCodeAt(0),s;i<=this.end.charCodeAt(0);i+=1)s=String.fromCharCode(i),this._excludes.has(s)||this._correspondingCharSet.AddCharacters(s);return this._correspondingCharSet},n instanceof yo.CharacterSet)this._excludes=n.set;else for(let