@drincs/pixi-vn-ink 0.11.2 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/chunk-I245ULLD.mjs +18 -0
- package/dist/{chunk-DPFJFU3S.mjs → chunk-M7O5Q75X.mjs} +3 -3
- package/dist/index.cjs +45 -45
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.mjs +1 -1
- package/dist/vite-listener.cjs +45 -45
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +3 -3
- package/dist/vite.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-RA5R2BQ3.mjs +0 -18
package/README.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/@drincs/pixi-vn-ink" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/v/@drincs/pixi-vn-ink?label=version" alt="npm version"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/@drincs/pixi-vn-ink" rel="noopener noreferrer nofollow"><img src="https://img.shields.io/npm/dm/@drincs/pixi-vn-ink" alt="npm downloads per month"></a>
|
|
8
|
+
<a target="_blank" href="https://www.jsdelivr.com/package/npm/@drincs/pixi-vn-ink" rel="noopener noreferrer nofollow"><img alt="jsDelivr hits (npm)" src="https://img.shields.io/jsdelivr/npm/hm/@drincs/pixi-vn-ink?logo=jsdeliver"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/@drincs/pixi-vn-ink" rel="noopener noreferrer nofollow"><img alt="NPM License" src="https://img.shields.io/npm/l/@drincs/pixi-vn-ink"></a>
|
|
10
|
+
<a target="_blank" href="https://discord.gg/E95FZWakzp" rel="noopener noreferrer nofollow"><img alt="Discord" src="https://img.shields.io/discord/1263071210011496501?color=7289da&label=discord"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
5
13
|
Pixi’VN gives you the ability to write your own narrative using ***ink***, a scripting language for writing interactive narrative.
|
|
6
14
|
|
|
7
15
|
The ***ink* + Pixi’VN integration**, exploits the [inkjs](https://github.com/inkle/inkjs) and [PixiVNJson](https://pixi-vn.web.app/advanced/pixi-vn-json) libraries, to parse ***ink* code** and generate a Json that can be interpreted by Pixi’VN. So Javascript/Typescript and ***ink*** share the same storage and canvas, and it is also possible to launch ***ink*** labels (or knots) from Javascript/Typescript and vice versa. This allows you to use the best of both languages. You can use ***ink*** to write the narration, while using Javascript/Typescript to create minigames or complex animations.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {a,c,b as b$1,e,d,f as f$1}from'./chunk-M7O5Q75X.mjs';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {RegisteredLabels,narration,LabelAbstract,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';import {canvas,VideoSprite,showVideo,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {sound}from'@drincs/pixi-vn/sound';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';var qt=Object.defineProperty,Yt=(e,t,u)=>t in e?qt(e,t,{enumerable:true,configurable:true,writable:true,value:u}):e[t]=u,Y=(e,t,u)=>Yt(e,typeof t!="symbol"?t+"":t,u),G;(e=>(e.log=(t,...u)=>console.log(`[Pixi\u2019VN Json] ${t}`,...u),e.warn=(t,...u)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...u),e.error=(t,...u)=>console.error(`[Pixi\u2019VN Json] ${t}`,...u),e.info=(t,...u)=>console.info(`[Pixi\u2019VN Json] ${t}`,...u)))(G||(G={}));var W=class N{static init(t){t.loadAssets&&(N._loadAssets=t.loadAssets),t.soundOperation&&(N._soundOperation=t.soundOperation),t.imageOperation&&(N._imageOperation=t.imageOperation),t.videoOperation&&(N._videoOperation=t.videoOperation),t.imageContainerOperation&&(N._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(N._textOperation=t.textOperation),t.canvasElementOperation&&(N._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(N._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(N._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(N._narrationOperation=t.narrationOperation),t.effectOperation&&(N._effectOperation=t.effectOperation),t.animateOperation&&(N._animateOperation=t.animateOperation),t.getLogichValue&&(N._getLogichValue=t.getLogichValue),t.getConditionalStep&&(N._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return N._loadAssets}static get soundOperation(){return N._soundOperation}static get imageOperation(){return N._imageOperation}static get videoOperation(){return N._videoOperation}static get textOperation(){return N._textOperation}static get imageContainerOperation(){return N._imageContainerOperation}static get canvasElementOperation(){return N._canvasElementOperation}static get setStorageValue(){return N._setStorageValue}static get setInitialStorageValue(){return N._setInitialStorageValue}static get narrationOperation(){return N._narrationOperation}static get effectOperation(){return N._effectOperation}static get animateOperation(){return N._animateOperation}static get getLogichValue(){return N._getLogichValue}static get getConditionalStep(){return N._getConditionalStep}};Y(W,"_loadAssets",()=>{}),Y(W,"_soundOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_imageOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_videoOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_imageContainerOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_textOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_canvasElementOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_setStorageValue",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_setInitialStorageValue",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_narrationOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_effectOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_animateOperation",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_getLogichValue",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(W,"_getConditionalStep",()=>{throw G.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var v=W;var Xt=Object.defineProperty,Qt=(e,t,u)=>t in e?Xt(e,t,{enumerable:true,configurable:true,writable:true,value:u}):e[t]=u,We=(e,t,u)=>Qt(e,typeof t!="symbol"?t+"":t,u);function Kt(e){let t="";return e.values.forEach(u=>{if(typeof u=="string")t+=u;else {let r=v.getLogichValue(u);t+=`${r}`;}}),t}var Ve=class T{static t(t){return Array.isArray(t)?t.map(u=>T.translate(`${u}`)):T.translate(`${t}`)}static set beforeToTranslate(t){T._beforeToTranslate=t;}static set translate(t){T._translate=t;}static get translate(){return t=>{let u=t;return T._beforeToTranslate&&(u=T._beforeToTranslate(u)),u=T._translate(u),T._afterToTranslate&&(u=T._afterToTranslate(u)),u}}static set afterToTranslate(t){T._afterToTranslate=t;}static addKey(t,u,r){let i=r.defaultValue||"empty_string";typeof u=="string"&&(u=[u]),Array.isArray(u)&&u.forEach(o=>{t[o]===void 0&&(i==="empty_string"?t[o]="":i==="copy_key"&&(T._beforeToTranslate?t[o]=T._beforeToTranslate(o):t[o]=o));});}static getConditionalsThenElse(t,u=[]){if(typeof t=="object"&&t&&"type"in t)if(t.type==="ifelse")t.then&&T.getConditionalsThenElse(t.then,u),t.else&&T.getConditionalsThenElse(t.else,u);else if(t.type==="stepswitch"){if(t.elements)if(Array.isArray(t.elements))t.elements.forEach(r=>{T.getConditionalsThenElse(r,u);});else if(t.elements.type==="ifelse"){let r=[];T.getConditionalsThenElse(t.elements,r),r.forEach(i=>{u.push(...i);});}else if(t.elements.type==="stepswitch"){let r=[];T.getConditionalsThenElse(t.elements,r),r.forEach(i=>{u.push(...i);});}else T.getConditionalsThenElse(t.elements,u);}else t.type==="resulttocombine"?(t.firstItem&&T.getConditionalsThenElse(t.firstItem,u),t.secondConditionalItem&&t.secondConditionalItem.forEach(r=>{T.getConditionalsThenElse(r,u);})):u.push(t);else t&&u.push(t);return u}static async generateJsonTranslation(t,u={},r={}){let{defaultValue:i="copy_key",operationStringConvert:o}=r,d=t.map(async E=>{if(E.choices){let p=[];Array.isArray(E.choices)?p=[E.choices]:p=T.getConditionalsThenElse(E.choices),p.forEach(g=>g.forEach(c=>{if("type"in c){let F=[];c.type==="ifelse"||c.type==="stepswitch"?T.getConditionalsThenElse(c,F):F=[c],F.map(h=>T.getConditionalsThenElse(h.text)).forEach(h=>{Array.isArray(h)&&h.forEach(y=>{Array.isArray(y)?y.forEach(x=>{typeof x=="string"?T.addKey(u,x,{defaultValue:i}):T.getConditionalsThenElse(x).forEach(A=>{Array.isArray(A)?A.forEach(m=>{typeof m=="string"&&T.addKey(u,m,{defaultValue:i});}):typeof A=="string"&&T.addKey(u,A,{defaultValue:i});});}):typeof y=="string"&&T.addKey(u,y,{defaultValue:i});});});}}));}if(E.dialogue){let p=[];Array.isArray(E.dialogue)?p=[E.dialogue]:p=T.getConditionalsThenElse(E.dialogue),p.forEach(g=>{if(typeof g=="string")T.addKey(u,g,{defaultValue:i});else if("text"in g){let c=T.getConditionalsThenElse(g.text);typeof c=="string"&&(c=[c]),c.forEach(F=>{typeof F=="string"?T.addKey(u,F,{defaultValue:i}):T.getConditionalsThenElse(F).forEach(h=>{typeof h=="string"?T.addKey(u,h,{defaultValue:i}):Array.isArray(h)&&h.forEach(y=>{typeof y=="string"?T.addKey(u,y,{defaultValue:i}):T.getConditionalsThenElse(y).forEach(x=>{typeof x=="string"&&T.addKey(u,x,{defaultValue:i});});});});});}});}if(E.operations)for(let p of E.operations){if(p.type==="operationtoconvert"&&o){let g=Kt(p),c=await o(g,E,{});if(!c)return;p=c;}p.type==="text"&&p.operationType==="show"&&T.addKey(u,p.text,{defaultValue:i});}E.conditionalStep&&T.getConditionalsThenElse(E.conditionalStep).forEach(p=>{Array.isArray(p)?T.generateJsonTranslation(p,u,r):T.generateJsonTranslation([p],u,r);});});return await Promise.all(d),u}};We(Ve,"_beforeToTranslate"),We(Ve,"_translate",e=>e),We(Ve,"_afterToTranslate");var Zt=Ve,H=Zt;var nu=Object.create,Ue=Object.defineProperty,ru=Object.getOwnPropertyDescriptor,iu=Object.getOwnPropertyNames,ou=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty,su=(e,t,u)=>t in e?Ue(e,t,{enumerable:true,configurable:true,writable:true,value:u}):e[t]=u,Et=(e=>typeof a<"u"?a:typeof Proxy<"u"?new Proxy(e,{get:(t,u)=>(typeof a<"u"?a:t)[u]}):e)(function(e){if(typeof a<"u")return a.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),lu=(e,t,u,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of iu(t))!au.call(e,i)&&i!==u&&Ue(e,i,{get:()=>t[i],enumerable:!(r=ru(t,i))||r.enumerable});return e},pu=(e,t,u)=>(u=e!=null?nu(ou(e)):{},lu(Ue(u,"default",{value:e,enumerable:true}),e)),Ge=(e,t,u)=>su(e,typeof t!="symbol"?t+"":t,u),Du=yt((e,t)=>{(function(u,r){typeof e=="object"?t.exports=e=r():typeof define=="function"&&define.amd?define([],r):u.CryptoJS=r();})(e,function(){var u=u||(function(r,i){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof Et=="function")try{o=Et("crypto");}catch{}var d=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},E=Object.create||(function(){function D(){}return function(n){var s;return D.prototype=n,s=new D,D.prototype=null,s}})(),p={},g=p.lib={},c=g.Base=(function(){return {extend:function(D){var n=E(this);return D&&n.mixIn(D),(!n.hasOwnProperty("init")||this.init===n.init)&&(n.init=function(){n.$super.init.apply(this,arguments);}),n.init.prototype=n,n.$super=this,n},create:function(){var D=this.extend();return D.init.apply(D,arguments),D},init:function(){},mixIn:function(D){for(var n in D)D.hasOwnProperty(n)&&(this[n]=D[n]);D.hasOwnProperty("toString")&&(this.toString=D.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),F=g.WordArray=c.extend({init:function(D,n){D=this.words=D||[],n!=i?this.sigBytes=n:this.sigBytes=D.length*4;},toString:function(D){return (D||y).stringify(this)},concat:function(D){var n=this.words,s=D.words,a=this.sigBytes,l=D.sigBytes;if(this.clamp(),a%4)for(var B=0;B<l;B++){var O=s[B>>>2]>>>24-B%4*8&255;n[a+B>>>2]|=O<<24-(a+B)%4*8;}else for(var L=0;L<l;L+=4)n[a+L>>>2]=s[L>>>2];return this.sigBytes+=l,this},clamp:function(){var D=this.words,n=this.sigBytes;D[n>>>2]&=4294967295<<32-n%4*8,D.length=r.ceil(n/4);},clone:function(){var D=c.clone.call(this);return D.words=this.words.slice(0),D},random:function(D){for(var n=[],s=0;s<D;s+=4)n.push(d());return new F.init(n,D)}}),h=p.enc={},y=h.Hex={stringify:function(D){for(var n=D.words,s=D.sigBytes,a=[],l=0;l<s;l++){var B=n[l>>>2]>>>24-l%4*8&255;a.push((B>>>4).toString(16)),a.push((B&15).toString(16));}return a.join("")},parse:function(D){for(var n=D.length,s=[],a=0;a<n;a+=2)s[a>>>3]|=parseInt(D.substr(a,2),16)<<24-a%8*4;return new F.init(s,n/2)}},x=h.Latin1={stringify:function(D){for(var n=D.words,s=D.sigBytes,a=[],l=0;l<s;l++){var B=n[l>>>2]>>>24-l%4*8&255;a.push(String.fromCharCode(B));}return a.join("")},parse:function(D){for(var n=D.length,s=[],a=0;a<n;a++)s[a>>>2]|=(D.charCodeAt(a)&255)<<24-a%4*8;return new F.init(s,n)}},A=h.Utf8={stringify:function(D){try{return decodeURIComponent(escape(x.stringify(D)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(D){return x.parse(unescape(encodeURIComponent(D)))}},m=g.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new F.init,this._nDataBytes=0;},_append:function(D){typeof D=="string"&&(D=A.parse(D)),this._data.concat(D),this._nDataBytes+=D.sigBytes;},_process:function(D){var n,s=this._data,a=s.words,l=s.sigBytes,B=this.blockSize,O=B*4,L=l/O;D?L=r.ceil(L):L=r.max((L|0)-this._minBufferSize,0);var $=L*B,J=r.min($*4,l);if($){for(var j=0;j<$;j+=B)this._doProcessBlock(a,j);n=a.splice(0,$),s.sigBytes-=J;}return new F.init(n,J)},clone:function(){var D=c.clone.call(this);return D._data=this._data.clone(),D},_minBufferSize:0});g.Hasher=m.extend({cfg:c.extend(),init:function(D){this.cfg=this.cfg.extend(D),this.reset();},reset:function(){m.reset.call(this),this._doReset();},update:function(D){return this._append(D),this._process(),this},finalize:function(D){D&&this._append(D);var n=this._doFinalize();return n},blockSize:16,_createHelper:function(D){return function(n,s){return new D.init(s).finalize(n)}},_createHmacHelper:function(D){return function(n,s){return new C.HMAC.init(D,s).finalize(n)}}});var C=p.algo={};return p})(Math);return u});}),cu=yt((e,t)=>{(function(u,r){typeof e=="object"?t.exports=e=r(Du()):typeof define=="function"&&define.amd?define(["./core"],r):r(u.CryptoJS);})(e,function(u){return (function(){var r=u,i=r.lib,o=i.WordArray,d=i.Hasher,E=r.algo,p=[],g=E.SHA1=d.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,F){for(var h=this._hash.words,y=h[0],x=h[1],A=h[2],m=h[3],C=h[4],D=0;D<80;D++){if(D<16)p[D]=c[F+D]|0;else {var n=p[D-3]^p[D-8]^p[D-14]^p[D-16];p[D]=n<<1|n>>>31;}var s=(y<<5|y>>>27)+C+p[D];D<20?s+=(x&A|~x&m)+1518500249:D<40?s+=(x^A^m)+1859775393:D<60?s+=(x&A|x&m|A&m)-1894007588:s+=(x^A^m)-899497514,C=m,m=A,A=x<<30|x>>>2,x=y,y=s;}h[0]=h[0]+y|0,h[1]=h[1]+x|0,h[2]=h[2]+A|0,h[3]=h[3]+m|0,h[4]=h[4]+C|0;},_doFinalize:function(){var c=this._data,F=c.words,h=this._nDataBytes*8,y=c.sigBytes*8;return F[y>>>5]|=128<<24-y%32,F[(y+64>>>9<<4)+14]=Math.floor(h/4294967296),F[(y+64>>>9<<4)+15]=h,c.sigBytes=F.length*4,this._process(),this._hash},clone:function(){var c=d.clone.call(this);return c._hash=this._hash.clone(),c}});r.SHA1=d._createHelper(g),r.HmacSHA1=d._createHmacHelper(g);})(),u.SHA1});}),de;(e=>(e.log=(t,...u)=>console.log(`[Pixi\u2019VN Json] ${t}`,...u),e.warn=(t,...u)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...u),e.error=(t,...u)=>console.error(`[Pixi\u2019VN Json] ${t}`,...u),e.info=(t,...u)=>console.info(`[Pixi\u2019VN Json] ${t}`,...u)))(de||(de={}));function fu(e){let t="";return e.values.forEach(u=>{if(typeof u=="string")t+=u;else {let r=v.getLogichValue(u);t+=`${r}`;}}),t}async function mt(e,t){let u=v.getLogichValue(e);if(u)switch(u.type){case "sound":v.soundOperation(u);break;case "assets":case "bundle":await v.loadAssets(u);break;case "image":await v.imageOperation(u);break;case "video":await v.videoOperation(u);break;case "imagecontainer":await v.imageContainerOperation(u);break;case "text":await v.textOperation(u);break;case "canvaselement":await v.canvasElementOperation(u);break;case "value":v.setStorageValue(u);break;case "operationtoconvert":if(t){let r=fu(u),i=await t(r);i&&await mt(i,t);}break;case "input":case "dialogue":v.narrationOperation(u);break;case "shake":await v.effectOperation(u);break;case "animate":case "animate-sequence":v.animateOperation(u);break}}function gu(e){let t=v.getLogichValue(e);t&&t.type==="value"&&t.storageOperationType==="set"&&(t.storageType==="storage"||t.storageType==="tempstorage")&&v.setInitialStorageValue(t);}async function qe(e,t={}){if(!Array.isArray(e))if(typeof e=="object"||typeof e=="string")e=[e];else {de.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let u=e.map(async i=>{if(typeof i=="string")try{i=JSON.parse(i);}catch(o){de.error("Error parsing imported Pixi'VN JSON",o),i={};}return i}),r=(await Promise.all(u)).map(async i=>{let o=[];if(i.initialOperations)for(let d of i.initialOperations)gu(d);if(i.labels){let d=i.labels;for(let E in d)try{let p=d[E],g=new hu(E,p,void 0,t);RegisteredLabels.add(g);}catch(p){de.error(`Error creating JSON label ${E}`,p);}}return Promise.all(o)});await Promise.all(r);}var du=pu(cu()),Ft="___param___",hu=class extends LabelAbstract{constructor(e,t,u,r={}){u||(u={}),u.onLoadingLabel=async()=>{for(let i of t){let o;if(typeof i=="function"?o=i():o=i,o=v.getConditionalStep(o),o.operations)try{let d=o.operations.map(E=>v.loadAssets(E));await Promise.all(d);}catch(d){de.error("The operation in the onLoadingLabel function of the label has an error:",d);}}},super(e,u),Ge(this,"_steps"),Ge(this,"operationStringConvert"),Ge(this,"skipEmptyDialogs",false),this._steps=t,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||false;}get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let t=this._steps[e];return this.stepConverter(t)}getStepSha(e){if(e<0||e>=this.steps.length)return;let t=this._steps[e];return (0, du.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let t="";if(Array.isArray(e)){let u=[];e.forEach(r=>{if(typeof r=="string")u.push(r);else if(r&&typeof r=="object"){let i=v.getLogichValue(r);i?(i&&!Array.isArray(i)&&typeof i=="object"&&(i=v.getLogichValue(i)||""),Array.isArray(i)?u=u.map(o=>`${o}`).concat(i):u.push(`${i}`)):u.push(`${r}`);}else u.push(`${r}`);}),t=u;}else {let u=v.getLogichValue(e);u&&!Array.isArray(u)&&typeof u=="object"&&(u=v.getLogichValue(u)),u&&Array.isArray(u)?t=u.map(r=>`${r}`):t=`${u}`;}return t}getDialogue(e){if(e==null)return;let t=v.getLogichValue(e);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:H.t(this.getDialogueText(t.text))}:H.t(this.getDialogueText(t))}getChoices(e){return v.getLogichValue(e)?.map(t=>v.getLogichValue(t)).filter(t=>t!==void 0)}stepConverter(e){return async t=>{let u=typeof e=="function"?e():e;u=createExportableElement(u),u=v.getConditionalStep(u);let r=this.operationStringConvert?h=>this.operationStringConvert(h,u,t):void 0,{operations:i=[]}=u;for(let h of i)await mt(h,r);let{labelToOpen:o=[]}=u,d=this.getChoices(u.choices),E=v.getLogichValue(u.glueEnabled),p=this.getDialogue(u.dialogue),g=[];Array.isArray(o)||(o=[o]),o.forEach(h=>{let y=v.getLogichValue(h);y&&g.push(y);});let c=v.getLogichValue(u.goNextStep),F=v.getLogichValue(u.end);if(d){let h=d.map(y=>{let x="";if(Array.isArray(y.text)){let A=[];y.text.forEach(m=>{if(typeof m=="string")A.push(H.t(m));else if(m&&typeof m=="object"){let C=v.getLogichValue(m);C&&!Array.isArray(C)&&typeof C=="object"&&(C=v.getLogichValue(C)||""),C&&(Array.isArray(C)?A=A.concat(H.t(C)):A.push(H.t(C)));}}),x=A;}else typeof y.text=="string"&&(x=H.t(y.text));return {label:y.label,text:x,props:y.props,type:y.type,oneTime:y.oneTime,onlyHaveNoChoice:y.onlyHaveNoChoice,autoSelect:y.autoSelect}});narration.choices=h;}else narration.choices=void 0;p!==void 0&&(narration.dialogue=p,this.skipEmptyDialogs&&typeof p=="string"&&(p===""||RegExp(/^\s+$/).test(p))&&(c=true)),E?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):E===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let h of g){let y=h.label;typeof y=="object"&&(y=v.getLogichValue(y)||"");let x=h.params?.map(A=>v.getLogichValue(A));t={...t,...h.props},h.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${Ft}${narration.openedLabels.length}`,x),await narration.call(y,t)):(storage.setTempVariable(`${Ft}${narration.openedLabels.length}`,x),await narration.call(y,t));}F==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):F==="label_end"&&narration.closeCurrentLabel(),c&&await narration.continue(t,{runNow:true});}}};var Xe="___param___";async function Ru(e){let t=v.getLogichValue(e);if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}var U;(e=>(e.log=(t,...u)=>console.log(`[Pixi\u2019VN Json] ${t}`,...u),e.warn=(t,...u)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...u),e.error=(t,...u)=>console.error(`[Pixi\u2019VN Json] ${t}`,...u),e.info=(t,...u)=>console.info(`[Pixi\u2019VN Json] ${t}`,...u)))(U||(U={}));async function Ne(e,t,u){switch(u.type){case "fade":await showWithFade(t.alias,e,u.props,u.priority);break;case "dissolve":await showWithDissolve(t.alias,e,u.props,u.priority);break;case "movein":case "moveout":await moveIn(t.alias,e,u.props,u.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,e,u.props,u.priority);break;case "pushin":case "pushout":await pushIn(t.alias,e,u.props,u.priority);break}}function xe(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Lu(e){switch(e.operationType){case "show":if(e.transition){let u=new ImageSprite(e.props,e.url||e.alias);await Ne(u,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):U.error(`Image with alias ${e.alias} not found.`);break;case "remove":xe(e);break}}async function ju(e){switch(e.operationType){case "show":if(e.transition){let i=new VideoSprite(e.props,e.url||e.alias);await Ne(i,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):U.error(`Video with alias ${e.alias} not found.`);break;case "remove":xe(e);break;case "pause":let u=canvas.find(e.alias);u?u.paused=true:U.error(`Video with alias ${e.alias} not found.`);break;case "resume":let r=canvas.find(e.alias);r?r.paused=false:U.error(`Video with alias ${e.alias} not found.`);break}}async function Iu(e){switch(e.operationType){case "show":if(e.transition){let u=new ImageContainer(e.props,e.urls);await Ne(u,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):U.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":xe(e);break}}async function $u(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=H.t(e.text),e.transition){let u=new Text(e.props);await Ne(u,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):U.error(`Text with alias ${e.alias} not found.`);break;case "remove":xe(e);break}}async function Hu(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&(t.memory={...t.memory,...e.props}):U.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){U.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":xe(e);break}}async function zu(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function Mu(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function Wu(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function Gu(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function Uu(e){let t=w(e.value),u;switch(t&&typeof t=="object"&&"type"in t?u=w(t):u=t,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,u);break;case "tempstorage":storage.setTempVariable(e.key,u);break;case "params":let r=storage.get(`${Xe}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=e.key&&(r[e.key]=u),storage.setTempVariable(`${Xe}${narration.openedLabels.length-1}`,r);break}}function qu(e){let t=w(e.value),u;switch(t&&typeof t=="object"&&"type"in t?u=w(t):u=t,e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:u};break}}function w(e){let t=en(e);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return Xu(t);case "arithmetic":case "arithmeticsingle":return Yu(t);case "compare":case "valueCondition":case "union":return Qu(t)}return t}function Yu(e){let t=w(e.leftValue);switch(e.type){case "arithmetic":let u=w(e.rightValue);switch(e.operator){case "*":return t*u;case "/":return t/u;case "+":return t+u;case "-":return t-u;case "%":return t%u;case "POW":return Math.pow(t,u);case "RANDOM":return narration.getRandomNumber(t,u)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(t);case "FLOOR":return Math.floor(t);case "FLOAT":return parseFloat(t)}break}}function Xu(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.get(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return w(e.operation);case "params":let t=storage.get(`${Xe}${narration.openedLabels.length-1}`)||[];if(t&&t.length>e.key)return t[e.key];U.warn("getValue params not found");return}return e}function Qu(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let t=w(e.leftValue),u=w(e.rightValue);switch(e.operator){case "==":return t===u;case "!=":return t!==u;case "<":return t<u;case "<=":return t<=u;case ">":return t>u;case ">=":return t>=u;case "CONTAINS":return t.toString().includes(u.toString())}break;case "valueCondition":return !!w(e.value);case "union":return Ku(e)}return !!e}function Ku(e){if(e.unionType==="not")return !w(e.condition);let t=e.unionType==="and";for(let u=0;u<e.conditions.length;u++)if(t=w(e.conditions[u])||false,e.unionType==="and"){if(!t)return false}else if(t)return true;return t}function Zu(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function en(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return tn(e);case "ifelse":return w(e.condition)?w(e.then):w(e.else);case "stepswitch":let t=w(e.elements)||[];if(t.length===0){U.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let u=Zu(0,t.length-1);return w(t[u]);case "loop":let r=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return r>t.length-1&&(r=r%t.length),w(t[r]);case "sequential":let i,o=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(i=w(t[t.length-1])),o>t.length-1?i:w(t[o]);case "sequentialrandom":let d=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(d==null&&e.end=="lastItem"){let E=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!E||!E?.usedRandomNumbers){U.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=E.usedRandomNumbers[`0-${t.length-1}`];return w(t[p[p.length-1]])}if(d==null){U.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return w(t[d])}}return e}function Qe(e){if(e.conditionalStep){let t=createExportableElement(w(e.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let u={...e,conditionalStep:void 0,...t};return Qe(u)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function tn(e){let t=e.firstItem,u=[];e.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(o=>{let d=w(o);u.push(d);});else {let o=w(i);u.push(o);}});let r=t?[t,...u]:u;if(r.length===0){U.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return H.t(r);if(typeof r[0]=="object"){let i=r,o,d=false,E=i.map((C,D)=>{C=Qe(C);let n=w(C.dialogue)||"";return D===0?(o=w(C.glueEnabled)||false,n):(typeof n=="object"&&"text"in n&&(n=n.character+": "+n.text),o===false&&d&&(n=`
|
|
2
|
+
|
|
3
|
+
`+n),n&&(d=true),o=w(C.glueEnabled)||false,n)}),p=w(E[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,c=E.flatMap(C=>{let D;C&&typeof C=="object"&&"text"in C?D=C.text:D=C;let n;return Array.isArray(D)?n=D.map(s=>{let a=w(s);return H.t(`${a}`)}):n=w(D)||"",H.t(n)}),F=i.find(C=>C.end),h=i.find(C=>C.choices),y=false,x=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),y=i[i.length-1].glueEnabled,x=i.reverse().find(C=>!(C.operations&&(!C.dialogue||!C.choices)))?.goNextStep);let A=i.find(C=>C.labelToOpen),m=[];return i.forEach(C=>{C.operations&&(m=[...m,...C.operations]);}),{dialogue:g?{character:g,text:c}:c,end:F?.end,choices:h?.choices,glueEnabled:y,goNextStep:x,labelToOpen:A?.labelToOpen,operations:m}}}function Ke({_getLogichValue:e=w}){v.init({animateOperation:Mu,canvasElementOperation:Hu,effectOperation:zu,imageContainerOperation:Iu,imageOperation:Lu,textOperation:$u,narrationOperation:Wu,loadAssets:Ru,soundOperation:Gu,videoOperation:ju,setStorageValue:Uu,setInitialStorageValue:qu,getLogichValue:e,getConditionalStep:Qe});}var un=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,nn=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,rn=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Ze={Space_Separator:un,ID_Start:nn,ID_Continue:rn},I={isSpaceSeparator(e){return typeof e=="string"&&Ze.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||Ze.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="\u200C"||e==="\u200D"||Ze.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}},tt,q,ne,Je,ae,Z,z,rt,be,on=function(t,u){tt=String(t),q="start",ne=[],Je=0,ae=1,Z=0,z=void 0,rt=void 0,be=void 0;do z=an(),pn[q]();while(z.type!=="eof");return typeof u=="function"?ut({"":be},"",u):be};function ut(e,t,u){let r=e[t];if(r!=null&&typeof r=="object")if(Array.isArray(r))for(let i=0;i<r.length;i++){let o=String(i),d=ut(r,o,u);d===void 0?delete r[o]:Object.defineProperty(r,o,{value:d,writable:true,enumerable:true,configurable:true});}else for(let i in r){let o=ut(r,i,u);o===void 0?delete r[i]:Object.defineProperty(r,i,{value:o,writable:true,enumerable:true,configurable:true});}return u.call(e,t,r)}var S,b,Be,ue,V;function an(){for(S="default",b="",Be=false,ue=1;;){V=re();let e=Bt[S]();if(e)return e}}function re(){if(tt[Je])return String.fromCodePoint(tt.codePointAt(Je))}function f(){let e=re();return e===`
|
|
4
|
+
`?(ae++,Z=0):e?Z+=e.length:Z++,e&&(Je+=e.length),e}var Bt={default(){switch(V){case " ":case "\v":case "\f":case " ":case "\xA0":case "\uFEFF":case `
|
|
5
|
+
`:case "\r":case "\u2028":case "\u2029":f();return;case "/":f(),S="comment";return;case void 0:return f(),k("eof")}if(I.isSpaceSeparator(V)){f();return}return Bt[q]()},comment(){switch(V){case "*":f(),S="multiLineComment";return;case "/":f(),S="singleLineComment";return}throw R(f())},multiLineComment(){switch(V){case "*":f(),S="multiLineCommentAsterisk";return;case void 0:throw R(f())}f();},multiLineCommentAsterisk(){switch(V){case "*":f();return;case "/":f(),S="default";return;case void 0:throw R(f())}f(),S="multiLineComment";},singleLineComment(){switch(V){case `
|
|
6
|
+
`:case "\r":case "\u2028":case "\u2029":f(),S="default";return;case void 0:return f(),k("eof")}f();},value(){switch(V){case "{":case "[":return k("punctuator",f());case "n":return f(),ce("ull"),k("null",null);case "t":return f(),ce("rue"),k("boolean",true);case "f":return f(),ce("alse"),k("boolean",false);case "-":case "+":f()==="-"&&(ue=-1),S="sign";return;case ".":b=f(),S="decimalPointLeading";return;case "0":b=f(),S="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":b=f(),S="decimalInteger";return;case "I":return f(),ce("nfinity"),k("numeric",1/0);case "N":return f(),ce("aN"),k("numeric",NaN);case '"':case "'":Be=f()==='"',b="",S="string";return}throw R(f())},identifierNameStartEscape(){if(V!=="u")throw R(f());f();let e=nt();switch(e){case "$":case "_":break;default:if(!I.isIdStartChar(e))throw xt();break}b+=e,S="identifierName";},identifierName(){switch(V){case "$":case "_":case "\u200C":case "\u200D":b+=f();return;case "\\":f(),S="identifierNameEscape";return}if(I.isIdContinueChar(V)){b+=f();return}return k("identifier",b)},identifierNameEscape(){if(V!=="u")throw R(f());f();let e=nt();switch(e){case "$":case "_":case "\u200C":case "\u200D":break;default:if(!I.isIdContinueChar(e))throw xt();break}b+=e,S="identifierName";},sign(){switch(V){case ".":b=f(),S="decimalPointLeading";return;case "0":b=f(),S="zero";return;case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":b=f(),S="decimalInteger";return;case "I":return f(),ce("nfinity"),k("numeric",ue*(1/0));case "N":return f(),ce("aN"),k("numeric",NaN)}throw R(f())},zero(){switch(V){case ".":b+=f(),S="decimalPoint";return;case "e":case "E":b+=f(),S="decimalExponent";return;case "x":case "X":b+=f(),S="hexadecimal";return}return k("numeric",ue*0)},decimalInteger(){switch(V){case ".":b+=f(),S="decimalPoint";return;case "e":case "E":b+=f(),S="decimalExponent";return}if(I.isDigit(V)){b+=f();return}return k("numeric",ue*Number(b))},decimalPointLeading(){if(I.isDigit(V)){b+=f(),S="decimalFraction";return}throw R(f())},decimalPoint(){switch(V){case "e":case "E":b+=f(),S="decimalExponent";return}if(I.isDigit(V)){b+=f(),S="decimalFraction";return}return k("numeric",ue*Number(b))},decimalFraction(){switch(V){case "e":case "E":b+=f(),S="decimalExponent";return}if(I.isDigit(V)){b+=f();return}return k("numeric",ue*Number(b))},decimalExponent(){switch(V){case "+":case "-":b+=f(),S="decimalExponentSign";return}if(I.isDigit(V)){b+=f(),S="decimalExponentInteger";return}throw R(f())},decimalExponentSign(){if(I.isDigit(V)){b+=f(),S="decimalExponentInteger";return}throw R(f())},decimalExponentInteger(){if(I.isDigit(V)){b+=f();return}return k("numeric",ue*Number(b))},hexadecimal(){if(I.isHexDigit(V)){b+=f(),S="hexadecimalInteger";return}throw R(f())},hexadecimalInteger(){if(I.isHexDigit(V)){b+=f();return}return k("numeric",ue*Number(b))},string(){switch(V){case "\\":f(),b+=sn();return;case '"':if(Be)return f(),k("string",b);b+=f();return;case "'":if(!Be)return f(),k("string",b);b+=f();return;case `
|
|
7
|
+
`:case "\r":throw R(f());case "\u2028":case "\u2029":Dn(V);break;case void 0:throw R(f())}b+=f();},start(){switch(V){case "{":case "[":return k("punctuator",f())}S="value";},beforePropertyName(){switch(V){case "$":case "_":b=f(),S="identifierName";return;case "\\":f(),S="identifierNameStartEscape";return;case "}":return k("punctuator",f());case '"':case "'":Be=f()==='"',S="string";return}if(I.isIdStartChar(V)){b+=f(),S="identifierName";return}throw R(f())},afterPropertyName(){if(V===":")return k("punctuator",f());throw R(f())},beforePropertyValue(){S="value";},afterPropertyValue(){switch(V){case ",":case "}":return k("punctuator",f())}throw R(f())},beforeArrayValue(){if(V==="]")return k("punctuator",f());S="value";},afterArrayValue(){switch(V){case ",":case "]":return k("punctuator",f())}throw R(f())},end(){throw R(f())}};function k(e,t){return {type:e,value:t,line:ae,column:Z}}function ce(e){for(let t of e){if(re()!==t)throw R(f());f();}}function sn(){switch(re()){case "b":return f(),"\b";case "f":return f(),"\f";case "n":return f(),`
|
|
8
|
+
`;case "r":return f(),"\r";case "t":return f()," ";case "v":return f(),"\v";case "0":if(f(),I.isDigit(re()))throw R(f());return "\0";case "x":return f(),ln();case "u":return f(),nt();case `
|
|
9
|
+
`:case "\u2028":case "\u2029":return f(),"";case "\r":return f(),re()===`
|
|
10
|
+
`&&f(),"";case "1":case "2":case "3":case "4":case "5":case "6":case "7":case "8":case "9":throw R(f());case void 0:throw R(f())}return f()}function ln(){let e="",t=re();if(!I.isHexDigit(t)||(e+=f(),t=re(),!I.isHexDigit(t)))throw R(f());return e+=f(),String.fromCodePoint(parseInt(e,16))}function nt(){let e="",t=4;for(;t-- >0;){let u=re();if(!I.isHexDigit(u))throw R(f());e+=f();}return String.fromCodePoint(parseInt(e,16))}var pn={start(){if(z.type==="eof")throw fe();et();},beforePropertyName(){switch(z.type){case "identifier":case "string":rt=z.value,q="afterPropertyName";return;case "punctuator":_e();return;case "eof":throw fe()}},afterPropertyName(){if(z.type==="eof")throw fe();q="beforePropertyValue";},beforePropertyValue(){if(z.type==="eof")throw fe();et();},beforeArrayValue(){if(z.type==="eof")throw fe();if(z.type==="punctuator"&&z.value==="]"){_e();return}et();},afterPropertyValue(){if(z.type==="eof")throw fe();switch(z.value){case ",":q="beforePropertyName";return;case "}":_e();}},afterArrayValue(){if(z.type==="eof")throw fe();switch(z.value){case ",":q="beforeArrayValue";return;case "]":_e();}},end(){}};function et(){let e;switch(z.type){case "punctuator":switch(z.value){case "{":e={};break;case "[":e=[];break}break;case "null":case "boolean":case "numeric":case "string":e=z.value;break}if(be===void 0)be=e;else {let t=ne[ne.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,rt,{value:e,writable:true,enumerable:true,configurable:true});}if(e!==null&&typeof e=="object")ne.push(e),Array.isArray(e)?q="beforeArrayValue":q="beforePropertyName";else {let t=ne[ne.length-1];t==null?q="end":Array.isArray(t)?q="afterArrayValue":q="afterPropertyValue";}}function _e(){ne.pop();let e=ne[ne.length-1];e==null?q="end":Array.isArray(e)?q="afterArrayValue":q="afterPropertyValue";}function R(e){return ke(e===void 0?`JSON5: invalid end of input at ${ae}:${Z}`:`JSON5: invalid character '${bt(e)}' at ${ae}:${Z}`)}function fe(){return ke(`JSON5: invalid end of input at ${ae}:${Z}`)}function xt(){return Z-=5,ke(`JSON5: invalid identifier character at ${ae}:${Z}`)}function Dn(e){console.warn(`JSON5: '${bt(e)}' in strings is not valid ECMAScript; consider escaping`);}function bt(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let u=e.charCodeAt(0).toString(16);return "\\x"+("00"+u).substring(u.length)}return e}function ke(e){let t=new SyntaxError(e);return t.lineNumber=ae,t.columnNumber=Z,t}var cn=function(t,u,r){let i=[],o="",d,E,p="",g;if(u!=null&&typeof u=="object"&&!Array.isArray(u)&&(r=u.space,g=u.quote,u=u.replacer),typeof u=="function")E=u;else if(Array.isArray(u)){d=[];for(let A of u){let m;typeof A=="string"?m=A:(typeof A=="number"||A instanceof String||A instanceof Number)&&(m=String(A)),m!==void 0&&d.indexOf(m)<0&&d.push(m);}}return r instanceof Number?r=Number(r):r instanceof String&&(r=String(r)),typeof r=="number"?r>0&&(r=Math.min(10,Math.floor(r)),p=" ".substr(0,r)):typeof r=="string"&&(p=r.substr(0,10)),c("",{"":t});function c(A,m){let C=m[A];switch(C!=null&&(typeof C.toJSON5=="function"?C=C.toJSON5(A):typeof C.toJSON=="function"&&(C=C.toJSON(A))),E&&(C=E.call(m,A,C)),C instanceof Number?C=Number(C):C instanceof String?C=String(C):C instanceof Boolean&&(C=C.valueOf()),C){case null:return "null";case true:return "true";case false:return "false"}if(typeof C=="string")return F(C);if(typeof C=="number")return String(C);if(typeof C=="object")return Array.isArray(C)?x(C):h(C)}function F(A){let m={"'":.1,'"':.2},C={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},D="";for(let s=0;s<A.length;s++){let a=A[s];switch(a){case "'":case '"':m[a]++,D+=a;continue;case "\0":if(I.isDigit(A[s+1])){D+="\\x00";continue}}if(C[a]){D+=C[a];continue}if(a<" "){let l=a.charCodeAt(0).toString(16);D+="\\x"+("00"+l).substring(l.length);continue}D+=a;}let n=g||Object.keys(m).reduce((s,a)=>m[s]<m[a]?s:a);return D=D.replace(new RegExp(n,"g"),C[n]),n+D+n}function h(A){if(i.indexOf(A)>=0)throw TypeError("Converting circular structure to JSON5");i.push(A);let m=o;o=o+p;let C=d||Object.keys(A),D=[];for(let s of C){let a=c(s,A);if(a!==void 0){let l=y(s)+":";p!==""&&(l+=" "),l+=a,D.push(l);}}let n;if(D.length===0)n="{}";else {let s;if(p==="")s=D.join(","),n="{"+s+"}";else {let a=`,
|
|
11
|
+
`+o;s=D.join(a),n=`{
|
|
12
|
+
`+o+s+`,
|
|
13
|
+
`+m+"}";}}return i.pop(),o=m,n}function y(A){if(A.length===0)return F(A);let m=String.fromCodePoint(A.codePointAt(0));if(!I.isIdStartChar(m))return F(A);for(let C=m.length;C<A.length;C++)if(!I.isIdContinueChar(String.fromCodePoint(A.codePointAt(C))))return F(A);return A}function x(A){if(i.indexOf(A)>=0)throw TypeError("Converting circular structure to JSON5");i.push(A);let m=o;o=o+p;let C=[];for(let n=0;n<A.length;n++){let s=c(String(n),A);C.push(s!==void 0?s:"null");}let D;if(C.length===0)D="[]";else if(p==="")D="["+C.join(",")+"]";else {let n=`,
|
|
14
|
+
`+o,s=C.join(n);D=`[
|
|
15
|
+
`+o+s+`,
|
|
16
|
+
`+m+"]";}return i.pop(),o=m,D}},fn={parse:on,stringify:cn},gn=fn,Re=gn;var Tt="\xA7SPACE\xA7",St="\xA7DOUBLE_QUOTES\xA7",vt="\xA7QUOTES\xA7",Vt="SPECIAL_\xA7QUOTES\xA7",wt="\xA7CURLY_BRACKETS1\xA7",Pt="\xA7CURLY_BRACKETS2\xA7",dn=["add","play","pause","resume","remove","volume"],he=class{};c(he,"handlers",[t=>false]);var Le;(D=>{async function e(n,s){let a=he.handlers;for(let l=0;l<a.length;l++)try{let B=await a[l](n,s,y);if(B===!0||typeof B=="string")return B}catch{}return false}function t(n){he.handlers.push(n);}D.add=t;function u(){he.handlers=[];}D.clear=u;async function r(n,s,a){try{n=n.replaceAll('\\"',St),n=n.replaceAll("\\'",vt),n=n.replaceAll("\\`",Vt),n=n.replaceAll("\\{",wt),n=n.replaceAll("\\}",Pt),n=n.replaceAll("{"," { "),n=n.replaceAll("}"," } "),n=n.replaceAll(wt,"{"),n=n.replaceAll(Pt,"}");let l=[],B,O="";for(let j=0;j<n.length;j++){let M=n[j];M==='"'||M==="'"||M==="`"?B===void 0?(l.push(O),O="",B=M,O+=M):B===M?(B=void 0,O+=M,l.push(O),O=""):O+=M:O+=M;}O!==""&&l.push(O),l.forEach((j,M)=>{M%2===1&&(l[M]=j.replaceAll(" ",Tt));}),n=l.join(""),l=n.split(" ").filter(j=>j!==""),l=l.map(j=>j.replaceAll(Tt," ").replaceAll(St,'"').replaceAll(vt,"'").replaceAll(Vt,"`"));let L=await e(l,a);if(L===!0)return;if(typeof L=="string")return L.startsWith("#")&&(L=L.substring(1)),D.run(L,s,a);let $=l.length>1?m(l[1]):"",J=l.length>0?m(l[0]):"";switch($){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return $==="video"&&(J==="pause"||J==="resume")?{type:"video",operationType:J,alias:m(l[2])}:i(l,$);case "sound":return p(l);case "input":if(J==="request"){let j={type:"input",operationType:"request"};if(l.length>2)try{let M=l.slice(2),ie=y(M);"type"in ie&&typeof ie.type=="string"&&(j.valueType=ie.type),"default"in ie&&(j.defaultValue=ie.default);}catch{}return j}break;case "assets":case "bundle":switch(J){case "load":case "lazyload":return {type:$,operationType:J,aliases:l.slice(2)}}break;default:if($)switch(J){case "call":case "jump":s.labelToOpen={label:$,type:J},s.goNextStep=void 0;return;case "shake":let j={};if(l.length>2)try{j=y(l.slice(2));}catch{}return {alias:$,type:J,props:j};case "animate":let ie={},ht={};if(l.length>2){let pe=l.slice(2),Me=[];if(pe.includes("options")){let Se=pe.indexOf("options");Me=pe.slice(Se+1),pe=pe.slice(0,Se);}try{ie=y(pe);}catch{}if(Me.length>0)try{ht=y(Me);}catch{}}return {alias:$,type:J,keyframes:ie,options:ht}}else switch(J){case "pause":return "dialogue"in s&&delete s.dialogue,"goNextStep"in s&&delete s.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":s.goNextStep=!0,s.glueEnabled=!1;return}}}catch(l){throw d.error("Error parsing ink hashtag-command",n),l}d.error("The operation is not valid",n);}D.run=r;function i(n,s){let a=m(n[0]),l=m(n[2]),B=x(n.slice(3));switch(a){case "show":switch(s){case "image":case "video":return o(s,l,B);case "imagecontainer":return E(s,l,B);case "text":return d$1(s,l,B);default:d.error("This show operation is not valid for this type of element",s);}case "edit":return {type:s,operationType:"edit",alias:l,props:A(B)};case "remove":let L={type:s,operationType:"remove",alias:l};if(B.length>1&&B[0]==="with"){let $=n[n.indexOf("with")+1],J=n.slice(n.indexOf("with")+2),j=c($,J);j!==void 0&&(L.transition=j);}return L;default:d.error("The operation type is not valid",a);}}function o(n,s,a){let l,B;return a.length%2===0?(l=s,B=a):(l=m(a[0]),B=a.slice(1)),g({type:n,operationType:"show",alias:s,url:l},B)}function d$1(n,s,a){let l,B;return a.length%2===0?(l=s,B=a):(l=m(a[0]),B=a.slice(1)),g({type:n,operationType:"show",alias:s,text:l},B)}function E(n,s,a){let l=[],B=a.findIndex(J=>J.startsWith("[")),O=a.findIndex(J=>J.endsWith("]"));if(B===-1||O===-1){d.error("Show imagecontainer must have a list of image ulrs",a);return}if(l=a.slice(B,O+1),l.length<2){d.error("Show imagecontainer must have a list of image ulrs",a);return}l[0]==="["?l.shift():l[0]=l[0].substring(1),l[l.length-1]==="]"?l.pop():l[l.length-1]=l[l.length-1].substring(0,l[l.length-1].length-1);let L={type:n,operationType:"show",alias:s,urls:l.map(J=>m(J))},$=a.slice(O+1);return g(L,$)}function p(n){let s=m(n[0]);if(!dn.includes(s))return;let a=m(n[2]);switch(s){case "play":let l={type:"sound",operationType:"play",alias:a};if(n.length>3){let J=h(n.slice(3));J!==void 0&&(l.props=J);}return l;case "pause":case "resume":return {type:"sound",operationType:s,alias:a};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:a};case "volume":let L=parseFloat(n[3]);return {type:"sound",operationType:"volume",alias:a,value:L}}}function g(n,s){if(s.length>0){if(s.includes("with")&&s.length>s.indexOf("with")+1){let a=s[s.indexOf("with")+1],l=s.slice(s.indexOf("with")+2);s=s.slice(0,s.indexOf("with"));let B=c(a,l);B!==void 0&&(n.transition=B);}if(s.length>0){let a=A(s);n.props=a;}}return n}function c(n,s){switch(n){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let a={type:n};if(s.length>0)try{let l=A(s);a.props=l;}catch{}return a}function h(n){try{return y(n)}catch{return}}function y(n){let s=x(n);return A(s)}function x(n){let s=[],a=0,l="";for(let B=0;B<n.length;B++){let O=n[B];O.startsWith("{")?(a++,l+=O):O.endsWith("}")&&a>0?(a--,l+=O,a===0&&(s.push(l),l="")):a>0?l+=O:s.push(O);}return s}function A(n){if(n.length===0)return {};if(n.length%2!==0)throw d.error("The props list must have a pair number of elements",n),new Error("The props list must have a pair number of elements");let s="{";n.forEach((a,l)=>{if(l%2===0)s+=`"${a}": `;else {switch(a){case "null":case "undefined":case "true":case "false":s+=`${a}`;break;default:C(a)?(a=m(a),s+=`"${a}"`):a.startsWith("{")&&a.endsWith("}")?s+=`${a}`:a.startsWith('"')&&a.endsWith('"')?s+=`${a}`:isNaN(parseFloat(a))?s+=`"${a}"`:s+=`${a}`;}l<n.length-1&&(s+=", ");}}),s+="}";try{return Re.parse(s)}catch(a){throw d.error("Error parsing ink json",s),a}}function m(n){return n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")||n.startsWith("`")&&n.endsWith("`")?n.substring(1,n.length-1):n}function C(n){return !!(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")||n.startsWith("`")&&n.endsWith("`"))}})(Le||(Le={}));var Ae=Le;function hn(e){Le.add(e);}var ge=class{};c(ge,"handlers",[]);var it;(r=>{function e(i){ge.handlers.push(i);}r.add=e;function t(){ge.handlers=[];}r.clear=t;function u(i,o,d=0){if(d>=ge.handlers.length)return o(i);let E=ge.handlers[d];return E(i,p=>u(p===void 0?i:p,o,d+1))}r.getLogichValue=u;})(it||(it={}));var je=it;var gt=b$1(e(),1);var Ie="global decl",se="___external_value___";function Te(e,t){if(e.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(e)&&(e=e.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!e.startsWith(".")))return e.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(e)&&e.includes("g-")){let r=e.split("g-");return ot(t)+"_|_"+"g-"+r[r.length-1]}let u=0;for(;new RegExp(/^\.\^.*$/).test(e);)u++,e=e.substring(2);if(u=u-1,new RegExp(/^\..*$/).test(e)&&t){let r=e.substring(1);return ot(t,u)+"_|_"+r.replaceAll(".","_|_")}return e.replaceAll(".","_|_")||ot(t,u).replaceAll(".","_|_")}function ot(e,t=0){let u=e.split("_|_");for(;u.length>1&&t>0;)u.pop()?.includes("g-")&&t--,t--;return u.join("_|_")}var Ot="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function te(e){return e.startsWith("^")&&(e=e.substring(1)),e=e.replaceAll("\\\\",Ot),e=e.replaceAll("\\n",`
|
|
17
|
+
`),e=e.replaceAll("\\t"," "),e=e.replaceAll(" "," "),e=e.replaceAll(Ot,"\\\\"),e}var Nt=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],_t=["+","-","/","*","%","POW","RANDOM"],Jt=["INT","FLOOR","FLOAT"],kt=["==",">","<",">=","<=","!=","CONTAINS"];function Ce(e,t,u){e=e.map(i=>{if(typeof i=="string"){if(i==="rnd")return "RANDOM";if(i==="?")return "CONTAINS"}return i});let r=[];return e.forEach(i=>{if(typeof i=="object"&&"CNT?"in i)if(new RegExp(/.*\.[0-9]\..*/).test(i["CNT?"])){let o=i["CNT?"].split("."),d$1=o.pop(),E=o.pop();if(E===void 0||d$1===void 0){d.error("Error parsing ink file: Conditional statement is not valid",e);return}let p=parseInt(E),g=o.join(".");if(g.includes("^.")){let F=g.split("."),h=F[F.length-1].replaceAll(".","_|_");F.pop(),g=F.join(".")+"."+h,d$1.includes("c-")&&(g=g+"_|_"+d$1);}else g=g.replaceAll(".","_|_");let c=Te(g,t);if(!c)return;r.push({type:"compare",leftValue:Rt(c),operator:">=",rightValue:{type:"value",value:p}});}else {let o=Te(i["CNT?"],t);if(!o)return;r.push(Rt(o));}else if(typeof i=="object"&&"VAR?"in i)r.push(Ee(i["VAR?"],u));else if(i==="&&"||i==="||"){if(r.length>=2){let o={type:"union",unionType:i==="&&"?"and":"or",conditions:[r[r.length-2],r[r.length-1]]};r.pop(),r.pop(),r.push(o);}}else if(i==="!")if(r.length===0)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let o={type:"union",unionType:"not",condition:r[r.length-1]};r[r.length-1]=o;}else if(i&&typeof i=="string"&&kt.includes(i))if(r.length<2)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let o={type:"compare",operator:i,rightValue:r[r.length-1],leftValue:r[r.length-2]};r.pop(),r.pop(),r.push(o);}else if(i&&typeof i=="string"&&_t.includes(i))if(r.length<2)d.error("Error parsing ink file: Conditional statement is not valid",e);else {let o={type:"arithmetic",operator:i,rightValue:r[r.length-1],leftValue:r[r.length-2]};r.pop(),r.pop(),r.push(o);}else if(i&&typeof i=="string"&&Jt.includes(i)){let o={type:"arithmeticsingle",operator:i,leftValue:r[r.length-1]};r.pop(),r.push(o);}else i&&typeof i=="string"?i.startsWith("^")&&r.push(te(i)):typeof i=="object"&&"^->"in i?i["^->"].includes("$r")||r.push(i["^->"]):r.push(i);}),r}function Rt(e){return {type:"value",storageType:"label",storageOperationType:"get",label:e}}function Lt(e,t,u){return Ce(e,t,u)}function Ee(e,t,u="storage"){let r=t.indexOf(e);return r>=0?{type:"value",storageType:"params",storageOperationType:"get",key:r}:{type:"value",storageOperationType:"get",storageType:u,key:e}}function at(e,t,u,r="storage"){let i=t.indexOf(e);return i>=0?{type:"value",storageType:"params",storageOperationType:"set",key:i,value:u}:{type:"value",storageOperationType:"set",storageType:r,key:e,value:u}}function st(e,t){return t||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(e)?"call":"jump"}function $e(e,t){t&&(typeof t=="string"?t.startsWith("^")&&e.push(te(t)):typeof t=="object"&&"type"in t&&t.type!=="value"&&e.push(t));}function lt(e,t,u,r,i={}){let{isNewLine:o=true,isHashtagScript:d=false,isThreads:E=false}=i;return Cn(e,t,u,r,{isNewLine:o,isHashtagScript:d,isThreads:E})}function Cn(e,t,u,r,i){if(!t)return;let{isNewLine:o,isHashtagScript:d=false,isThreads:E}=i;if(d)Array.isArray(t)&&t.length>0&&e.push({operations:[{type:"operationtoconvert",values:t}],goNextStep:true});else if(typeof t=="string"&&t.startsWith("^")||t&&typeof t=="object"&&"type"in t&&t.type=="value"&&t.storageOperationType==="get"){if(!o&&e.length>0){let p=e[e.length-1];!p.glueEnabled&&!p.operations&&(p.glueEnabled=true,p.labelToOpen||(p.goNextStep=true)),e[e.length-1]=p;}typeof t=="string"?e.push(En(te(t))):e.push({dialogue:t});}else if(typeof t=="string"){if(t==="end")e.push({end:"game_end"});else if(t==="done")e.push({end:"label_end",goNextStep:true});else if(t=="<>")if(e.length>0){let p=e[e.length-1];p.glueEnabled=true,p.labelToOpen||(p.goNextStep=true),e[e.length-1]=p;}else e.push({glueEnabled:true,goNextStep:false});}else if(typeof t=="object"){if("type"in t&&t.type!=="value"){if(!o&&e.length>0){let p=e[e.length-1];!p.glueEnabled&&!p.operations&&(p.glueEnabled=true,p.labelToOpen||(p.goNextStep=true)),e[e.length-1]=p;}e.push({conditionalStep:t});}else if("->"in t){let p=o?void 0:true;if(p&&u.includes("c-")&&e.length>0&&e[e.length-1]?.dialogue===void 0&&(p=void 0),!o&&e.length>0){let g=e[e.length-1];g.labelToOpen||(g.goNextStep=true),e[e.length-1]=g;}if(t.params&&t.params.length===0&&delete t.params,t.var)e.push({labelToOpen:{label:Ee(t["->"],r),type:E?"call":"jump",params:t.params},glueEnabled:p});else {let g=Te(t["->"],u);if(!g)return;e.push({labelToOpen:{label:g,type:st(g,E),params:t.params},glueEnabled:p});}}"type"in t&&t.type=="value"&&t.storageOperationType==="set"&&(typeof t.value=="string"&&t.value.startsWith("^")&&(t.value=te(t.value)),e.push({goNextStep:true,operations:[t]}));}}function En(e){let t;if(e.includes(": ")){let u=e.split(": "),r=u[0],i=u.slice(1).join(": ");RegisteredCharacters.get(r)&&(t=r,e=i);}return t?{dialogue:{character:t,text:e}}:{dialogue:e}}function pt(e,t,u,r=true,i=false){return Fn(e,t,u,r,i)}function Fn(e,t,u,r,i=false){t&&(typeof t=="string"&&t.startsWith("^")||t&&typeof t=="object"&&"type"in t&&t.type=="value"&&t.storageOperationType==="get"?typeof t=="string"?e.push(te(t)):e.push(t):typeof t=="object"&&"type"in t&&e.push(t));}function He(e,t,u){if(e.length===0){d.error("Error parsing ink file: Arithmetic statement is not valid",e);return}let r=Ce(e,t,u);if(r.length===1){let i=r[0];return i&&typeof i=="object"&&"type"in i?{type:"value",storageType:"logic",storageOperationType:"get",operation:i}:i}}function Fe(e,t,u,r="",i,o,d=void 0){let E=[],p="sequential",g=false,c=true;e.forEach(y=>{y==="%"&&(p="loop"),y==="seq"&&(p="random"),y==="MIN"&&(g=true);});let F=e[e.length-1];return Object.keys(F).forEach(y=>{let x=F[y];if(Array.isArray(x)&&x.length>3){x=x.slice(1,x.length-2);let A=[];le(x,r,i,A,t,t,u,ye,d,true,o),A.length===1?E.push(A[0]):E.push({type:"resulttocombine",combine:"cross",secondConditionalItem:A});}else Array.isArray(x)&&x.length===3&&(c=false);}),p==="sequential"?{type:"stepswitch",elements:E,choiceType:p,end:c?"lastItem":void 0,nestedId:d}:g&&p==="random"?{type:"stepswitch",elements:E,choiceType:"sequentialrandom",end:c?"lastItem":void 0,nestedId:d}:{type:"stepswitch",elements:E,choiceType:p}}function Dt(e="",t=""){let u=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t];return [...new Set([...u,...r])]}function ye(e,t,u,r,i){if(e.length>0){let o={};jt(e,o,i);for(let[d$1,E]of Object.entries(o)){let p=u+"_|_"+d$1,g={text:E.text.length===1?E.text[0]:E.text,label:p,props:{},type:st(p,false),oneTime:E.onetime};E.text.length===0&&(g.onlyHaveNoChoice=true,g.autoSelect=true),g.oneTime===false&&delete g.oneTime;let c=ct(g,E.conditions,i,u)||g,F=t[t.length-1];if(typeof F=="object"&&F&&"type"in F&&(F={conditionalStep:F}),t.length>0&&typeof F=="object"&&F&&"choices"in F&&F.choices){let h=F.choices;h&&Array.isArray(h)?h.push(c):d.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",E,h),F.choices=h.sort((y,x)=>{try{let A=y.label.split("."),m=A[A.length-1].replaceAll(".","_|_"),C=x.label.split("."),D=C[C.length-1].replaceAll(".","_|_");if(m.includes("c-")&&D.includes("c-")){let n=m.split("c-")[1],s=parseInt(n),a=D.split("c-")[1],l=parseInt(a);return s-l}}catch{}return 0});}else t.push({choices:[c]});E.preDialog&&(r.preDialog[p]={...E.preDialog});}}}function jt(e,t,u,r){let i=[],o="",d="",E=false,p=[];for(let g=0;g<e.length;g++){let c=e[g];if(typeof c=="string")c.startsWith("^")?i.push(te(c)):Nt.includes(c)&&p.push(c);else if(Array.isArray(c)&&c.includes("visit")){let F=Fe(c,$e,(h,y,x)=>{},r,{preDialog:{}},u);i.push(F);}else if(c&&typeof c=="object")if("*"in c&&typeof c["*"]&&typeof c["*"]=="string")c["*"].includes("c")&&(o="c"+c["*"].split("c")[1],c.flg&16&&(E=true));else if("s"in c&&c.s instanceof Array){let F=It(c.s),h=c.s.includes("<>");F&&(r&&t[r]?(t[r].preDialog={text:F,glue:h},t[r].text=Dt(F,t[r].text)):(i.push(F),d=F));}else "CNT?"in c&&p.push(c);else p.push(c);if(o){t[o]?t[o].text=Dt(i,t[o].text):t[o]={text:i,onetime:E,conditions:p},d&&(t[o].preDialog={text:d,glue:false});let F=e.slice(g+1);jt(F,t,u,o);return}}}function It(e){for(let t of e)if(typeof t=="string"){if(t.startsWith("^"))return te(t)}else if(t instanceof Array){let u=It(t);if(u)return u}}function ct(e,t,u,r,i){if(t.length===0)return;let o=Ce(t,r,u);if(o.length===1){let d={type:"ifelse",condition:o[0],then:e,else:i};return d.else||delete d.else,d}else if(o.length>1){let d={type:"ifelse",condition:{type:"union",unionType:"and",conditions:o},then:e,else:i};return d.else||delete d.else,d}}function $t(e,t,u,r,i,o,d$1=void 0){if(e.length===0){d.error("Error parsing ink file: Conditional statement is not valid",e);return}let E=[],p=[];if(e.forEach(F=>{Array.isArray(F)?p.push(F):typeof F=="string"&&F==="du"?i.du?E.push(i.du):i.du=E[E.length-1]:(typeof F!="string"||F!=="/ev")&&E.push(F);}),p.length===0){d.error("Error parsing ink file: Conditional statement is not valid",p);return}let g=ft(p[0],t,u,r+"_|_"+"then",i,o,`${d$1||""}then`),c;return p.length===2?c=ft(p[1],t,u,r+"_|_"+"else",i,o,`${d$1||""}else`):p.length>2&&(p.shift(),p.push("nop"),p=[{b:p}],c=ft(p,t,u,r+"_|_"+"else",i,o,`${d$1||""}else`)),i.du=void 0,ct(g,E,o,r,c)}function ft(e,t,u,r,i,o,d=void 0){let E=[];for(let g of e)typeof g=="object"&&"b"in g&&(g.b=g.b.filter(c=>c!==null&&!(typeof c=="object"&&"->"in c&&new RegExp(/.*\.[0-9]/).test(c["->"]))),le(g.b,r,i,E,t,t,u,ye,d,true,o));return E.length===1?E[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:E}}function le(e,t,u,r=[],i,o,d$1,E,p=void 0,g=true,c=[]){let F=false,h=[],y=false,x=false,A=false,m=[],C=[];if(u.preDialog[t]&&(g=false,i(r,"^"+u.preDialog[t].text,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),u.preDialog[t].glue&&i(r,"<>",t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),delete u.preDialog[t]),e.includes("visit")){let n=Fe(e,o,d$1,t,u,c,p);n&&(!g&&r.length>0&&i(r,"<>",t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),i(r,n,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}));return}let D=e[0];if(D&&typeof D=="object"&&"temp="in D){for(;e[0]&&typeof e[0]=="object"&&"temp="in e[0];)c.push(e[0]["temp="]),e.shift();c=c.reverse();}if(e.forEach((n,s)=>{if(x){if(typeof n=="string"&&n=="/#"){let a=[];le(C,t,u,a,pt,pt,d$1,E,p,g),i(r,a,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),x=false,C=[];}else C.push(n);return}else if(F)if(Array.isArray(n))h.push(n);else if(n&&typeof n=="object")if("CNT?"in n)s>0&&e[s-1]=="ev"?(y=true,m.push(n)):y?m.push(n):(h.push(n),g=false);else if("VAR="in n||"temp="in n){let a=at("VAR="in n?n["VAR="]:n["temp="],c,e[s-1],"VAR="in n?"storage":"tempstorage");if(a.value&&typeof a.value=="string"&&a.value=="/str"&&(a.value=e[s-2]),a.value&&typeof a.value=="object"&&"^->"in a.value&&(a.value=a.value["^->"]),h.length>1){let l=He(h,t,c);h=[],l&&typeof l=="object"&&"type"in l&&l.type=="value"&&"storageType"in l&&l.storageType=="logic"&&(a.value=l.operation);}(typeof a.key!="string"||!a.key.includes("$r"))&&(i(r,a,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=true);}else "VAR?"in n?h.push(n):"^->"in n&&(n["^->"].includes("$r")||h.push(n));else if(typeof n=="string"&&n=="/ev")y&&m.push(n),F=false,h.push(n);else if(typeof n=="string"&&n=="out"){if(h.length>0){let a=h[h.length-1];if(a&&typeof a=="object"&&"VAR?"in a){h.pop();let l=Ee(a["VAR?"],c,"storage");i(r,l,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A});}else {let l=[];for(;h.length>0&&h[h.length-1]!="/ev";)l.push(h.pop());l=l.reverse();let B=He(l,t,c);h=[],B&&typeof B=="object"&&"type"in B&&B.type=="value"&&"storageType"in B&&B.storageType=="logic"?i(r,{storageOperationType:"get",storageType:"logic",operation:B.operation,type:"value"},t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}):(i(r,"<>",t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),B=`^${B}`,i(r,B,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}));}g=false;}}else h.push(n);else if(typeof n=="string")if(n.startsWith("^"))i(r,n,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=false;else if(n=="ev")F=true;else if(n==`
|
|
18
|
+
`)g=true;else if(n=="done"||n=="end")i(r,n,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=false;else if(n=="<>")i(r,n,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=false;else if(n=="nop"&&y){let a=$t(m,o,d$1,t,u,c,p);a&&i(r,a,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),y=false,m=[];}else n=="#"?x=true:n=="thread"&&(A=true);else if(n instanceof Array)if(y)m.push(n);else if(n.length>1&&typeof n[n.length-2]=="object"&&n[n.length-2]&&"c"in n[n.length-2]&&typeof n[n.length-1]=="object"&&n[n.length-1]&&"b"in n[n.length-1]){h.pop();let a=[],l=[];for(;h.length>0&&h[h.length-1]!="/ev";)a.push(h.pop());m=[...m,...a.reverse()],y=true,l.push(n.pop()),l.push(n.pop()),m=[...m,...n],m.push(l);}else if(n.length>1&&typeof n[n.length-1]=="object"&&n[n.length-1]&&"#n"in n[n.length-1]){let a=n.pop();if(!a){d.error("Error parsing ink file: el is undefined");return}let l=a["#n"];delete a["#n"],n.push(a),i(r,{"->":t?t+"_|_"+l:l},t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),d$1({[l]:n},t,u);}else le(n,t,u,r,i,o,d$1,E,p,g,c);else if(n&&typeof n=="object")if("->"in n&&typeof n["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(n["->"])){let a=[];h.length>0&&(a=Lt(["ev",...h],t,c)),n.params=a,i(r,n,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=false;}else if("*"in n&&typeof n["*"]=="string")n["*"].includes("c")&&(h.push(n),g=false);else if("s"in n&&n.s instanceof Array)h.push(n),g=false;else if("CNT?"in n)h.push(n),g=false;else if("VAR="in n||"temp="in n){let a=[],l=at("VAR="in n?n["VAR="]:n["temp="],c,void 0,"VAR="in n?"storage":"tempstorage");if(l.key!=="$r"){for(h.pop(),h[h.length-1]=="/ev"&&h.pop();h.length>0&&h[h.length-1]!="/ev";)a.push(h.pop());a=a.reverse(),l.value=He(a,t,c),h=[],(l.value!==void 0||l.value!==null)&&i(r,l,t,c,{isNewLine:g,isHashtagScript:x,isThreads:A}),g=false;}}else d$1(n,t,u);}),E(h,r,t,u,c),t.includes("_|_")&&r.length==2){let n=r[0],s=r[1];n&&s&&typeof n=="object"&&"dialogue"in n&&typeof s=="object"&&"labelToOpen"in s&&n.dialogue==" "&&s.labelToOpen&&(r.shift(),delete s.glueEnabled,r[0]=s);}}function Ht(e){try{let t={};return zt(e,t),t}catch(t){d.error("Error parsing ink file",t);}}function zt(e,t,u={externalSwitch:void 0}){for(let r of e)if(r)if(r instanceof Array)if(r.includes("visit")){let i=Fe(r,$e,(o,d,E)=>{},"",{preDialog:{}},[]);i&&(u.externalSwitch=i);}else zt(r,t,u);else typeof r=="object"&&(r&&"VAR="in r&&u.externalSwitch&&(t[se]||(t[se]=[]),t[se].push({operations:[{type:"value",value:u.externalSwitch,key:r["VAR="],storageType:"storage",storageOperationType:"set"}]})),Mt(r,t));}function Mt(e,t,u="",r={preDialog:{}}){if(e!==null){for(let[i,o]of Object.entries(e))if(o instanceof Array){let d=[],E={},p=(u?u+"_|_":"")+i;le(o,p,r,d,lt,lt,(g,c,F)=>{Mt(g,E,c,F);},ye);for(let[g,c]of Object.entries(E))t[g]=c;d.length>0&&(t[p]=d);}}}function ze(e){let{json:t,labelToRemove:u,issues:r,initialVarsToRemove:i}=f$1(e);if(r.forEach(({message:d$1,type:E})=>{E===gt.ErrorType.Error?d.error("Ink compilation error: "+d$1):E===gt.ErrorType.Warning?d.warn("Ink compilation warning: "+d$1):d.info("Ink compilation info: "+d$1);}),!t){d.error("No JSON generated from ink file");return}let o;try{o=Re.parse(t);}catch{d.error("Error parsing ink file");return}return Wt(o,{labelToRemove:u,initialVarsToRemove:i})}function Wt(e,t={}){let{labelToRemove:u=[],initialVarsToRemove:r=[]}=t,i={};if(i.labels=Ht(e.root),i.labels&&Ie in i.labels){let o=i.labels[Ie];delete i.labels[Ie],o.forEach(d=>{d.operations&&(i.initialOperations=i.initialOperations?[...i.initialOperations,...d.operations]:[...d.operations]);});}if(i.labels&&se in i.labels){let o=i.labels[se];delete i.labels[se],o.forEach(d=>{d.operations&&(i.initialOperations=i.initialOperations?[...i.initialOperations,...d.operations]:[...d.operations]);});}return u.forEach(o=>{i.labels&&o in i.labels&&delete i.labels[o];}),r.forEach(o=>{i.initialOperations&&(i.initialOperations=i.initialOperations.filter(d=>!(d.type==="value"&&d.key===o)));}),i}async function yn(e){Array.isArray(e)||(e=[e]),Ke({_getLogichValue:je.getLogichValue});let t=e.map(async u=>{let r=ze(u);return r&&await qe(r,{operationStringConvert:Ae.run,skipEmptyDialogs:true}),u});return await Promise.all(t)}async function mn(e){return Ke({_getLogichValue:je.getLogichValue}),await qe(e,{operationStringConvert:Ae.run,skipEmptyDialogs:true})}function xn(e){H.afterToTranslate=t=>dt(t,e);}function Bn(e){H.beforeToTranslate=t=>dt(t,e);}function dt(e,t){let u=e.match(/\[([^\]]+)\]/);if(u){let r=u[1],i=t(r);return i&&(e=e.replaceAll(u[0],i)),dt(e,t)}return e}function bn(e){H.translate=e;}async function Tn(e,t={},u={}){let r=[];return e.labels&&Object.values(e.labels).forEach(i=>{r=r.concat(i);}),await H.generateJsonTranslation(r,t,{...u,operationStringConvert:Ae.run})}export{Ae as a,hn as b,je as c,ze as d,Wt as e,yn as f,mn as g,xn as h,Bn as i,bn as j,Tn as k};
|
|
@@ -16,7 +16,7 @@ var iu=Object.create;var Vr=Object.defineProperty;var ru=Object.getOwnPropertyDe
|
|
|
16
16
|
`),0),(n||this.isElse&&this.matchingEquality)&&this._contentContainer.InsertContent(qi.ControlCommand.PopEvaluatedValue(),0),e.AddToNamedContentOnly(this._contentContainer),this.returnDivert=new Zo.Divert,this._contentContainer.AddContent(this.returnDivert),e},this.GenerateRuntimeForContent=()=>this._innerWeave===null?new Yo.Container:this._innerWeave.rootContainer,t&&(this._innerWeave=new Jc.Weave(t),this.AddContent(this._innerWeave));}get typeName(){return "ConditionalSingleBranch"}ResolveReferences(t){if(!this._conditionalDivert||!this._contentContainer)throw new Error;this._conditionalDivert.targetPath=this._contentContainer.path,super.ResolveReferences(t);}};ji.ConditionalSingleBranch=na;});var tl=d(Mi=>{Object.defineProperty(Mi,"__esModule",{value:true});Mi.CustomFlags=void 0;var Qo;(function(o){o[o.ParsingString=1]="ParsingString",o[o.TagActive=2]="TagActive";})(Qo||(Mi.CustomFlags=Qo={}));});var el=d(Bi=>{Object.defineProperty(Bi,"__esModule",{value:true});Bi.DebugMetadata=void 0;var ia=class o{constructor(){this.startLineNumber=0,this.endLineNumber=0,this.startCharacterNumber=0,this.endCharacterNumber=0,this.fileName=null,this.sourceName=null;}Merge(t){let e=new o;return e.fileName=this.fileName,e.sourceName=this.sourceName,this.startLineNumber<t.startLineNumber?(e.startLineNumber=this.startLineNumber,e.startCharacterNumber=this.startCharacterNumber):this.startLineNumber>t.startLineNumber?(e.startLineNumber=t.startLineNumber,e.startCharacterNumber=t.startCharacterNumber):(e.startLineNumber=this.startLineNumber,e.startCharacterNumber=Math.min(this.startCharacterNumber,t.startCharacterNumber)),this.endLineNumber>t.endLineNumber?(e.endLineNumber=this.endLineNumber,e.endCharacterNumber=this.endCharacterNumber):this.endLineNumber<t.endLineNumber?(e.endLineNumber=t.endLineNumber,e.endCharacterNumber=t.endCharacterNumber):(e.endLineNumber=this.endLineNumber,e.endCharacterNumber=Math.max(this.endCharacterNumber,t.endCharacterNumber)),e}toString(){return this.fileName!==null?`line ${this.startLineNumber} of ${this.fileName}"`:"line "+this.startLineNumber}};Bi.DebugMetadata=ia;});var nl=d(Gi=>{Object.defineProperty(Gi,"__esModule",{value:true});Gi.ExternalDeclaration=void 0;var Xc=N(),ra=class extends Xc.ParsedObject{get name(){var t;return ((t=this.identifier)===null||t===void 0?void 0:t.name)||null}constructor(t,e){super(),this.identifier=t,this.argumentNames=e,this.GenerateRuntimeObject=()=>(this.story.AddExternal(this),null);}get typeName(){return "EXTERNAL"}toString(){var t;return `EXTERNAL ${(t=this.identifier)===null||t===void 0?void 0:t.name}`}};Gi.ExternalDeclaration=ra;});var il=d($i=>{Object.defineProperty($i,"__esModule",{value:true});$i.FlowDecl=void 0;var sa=class{constructor(t,e,n){this.name=t,this.args=e,this.isFunction=n;}};$i.FlowDecl=sa;});var oa=d(Ui=>{Object.defineProperty(Ui,"__esModule",{value:true});Ui.Wrap=void 0;var Yc=N(),aa=class extends Yc.ParsedObject{constructor(t){super(),this._objToWrap=t,this.GenerateRuntimeObject=()=>this._objToWrap;}};Ui.Wrap=aa;});var rl=d(Ki=>{Object.defineProperty(Ki,"__esModule",{value:true});Ki.Glue=void 0;var Zc=oa(),la=class extends Zc.Wrap{constructor(t){super(t);}get typeName(){return "Glue"}};Ki.Glue=la;});var Ji=d(Hi=>{Object.defineProperty(Hi,"__esModule",{value:true});Hi.Glue=void 0;var Qc=Q(),ua=class extends Qc.InkObject{toString(){return "Glue"}};Hi.Glue=ua;});var al=d(zi=>{Object.defineProperty(zi,"__esModule",{value:true});zi.IncDecExpression=void 0;var td=mi(),sl=ot(),ed=_t(),nd=St(),id=I(),rd=Rt(),sd=pe(),ad=Jt(),ha=class extends sl.Expression{constructor(t,e,n){super(),this.varIdentifier=t,this._runtimeAssignment=null,this.expression=null,this.GenerateIntoContainer=i=>{var a,r;i.AddContent(new sd.VariableReference(((a=this.varIdentifier)===null||a===void 0?void 0:a.name)||null)),this.expression?this.expression.GenerateIntoContainer(i):i.AddContent(new id.IntValue(1)),i.AddContent(nd.NativeFunctionCall.CallWithName(this.isInc?"+":"-")),this._runtimeAssignment=new rd.VariableAssignment(((r=this.varIdentifier)===null||r===void 0?void 0:r.name)||null,false),i.AddContent(this._runtimeAssignment);},this.toString=()=>{var i,a;return this.expression?`${(i=this.varIdentifier)===null||i===void 0?void 0:i.name}${this.isInc?" += ":" -= "}${this.expression}`:`${(a=this.varIdentifier)===null||a===void 0?void 0:a.name}`+(this.isInc?"++":"--")},e instanceof sl.Expression?(this.expression=e,this.AddContent(this.expression),this.isInc=!!n):this.isInc=e;}get typeName(){return "IncDecExpression"}ResolveReferences(t){var e;super.ResolveReferences(t);let n=t.ResolveVariableWithName(((e=this.varIdentifier)===null||e===void 0?void 0:e.name)||"",this);if(n.found||this.Error(`variable for ${this.incrementDecrementWord} could not be found: '${this.varIdentifier}' after searching: {this.descriptionOfScope}`),!this._runtimeAssignment)throw new Error;this._runtimeAssignment.isGlobal=n.isGlobal,!(this.parent instanceof ad.Weave)&&!(this.parent instanceof ed.FlowBase)&&!(this.parent instanceof td.ContentList)&&this.Error(`Can't use ${this.incrementDecrementWord} as sub-expression`);}get incrementDecrementWord(){return this.isInc?"increment":"decrement"}};zi.IncDecExpression=ha;});var da=d(Xi=>{Object.defineProperty(Xi,"__esModule",{value:true});Xi.IncludedFile=void 0;var od=N(),ca=class extends od.ParsedObject{constructor(t){super(),this.includedStory=t,this.GenerateRuntimeObject=()=>null;}get typeName(){return "IncludedFile"}};Xi.IncludedFile=ca;});var ol=d(Yi=>{Object.defineProperty(Yi,"__esModule",{value:true});Yi.InfixOperator=void 0;var fa=class{constructor(t,e,n){this.type=t,this.precedence=e,this.requireWhitespace=n,this.toString=()=>this.type;}};Yi.InfixOperator=fa;});var ma=d(Zi=>{Object.defineProperty(Zi,"__esModule",{value:true});Zi.Knot=void 0;var ld=_t(),ll=he(),pa=class extends ld.FlowBase{get flowLevel(){return ll.FlowLevel.Knot}constructor(t,e,n,i){super(t,e,n,i);}get typeName(){return this.isFunction?"Function":"Knot"}ResolveReferences(t){super.ResolveReferences(t);let e=this.story;for(let n in this.subFlowsByName){let i=e.ContentWithNameAtLevel(n,ll.FlowLevel.Knot,false);if(i){let a=this.subFlowsByName.get(n),r=`Stitch '${a?a.name:"NO STITCH FOUND"}' has the same name as a knot (on ${i.debugMetadata})`;this.Error(r,a);}}}};Zi.Knot=pa;});var ul=d(Qi=>{Object.defineProperty(Qi,"__esModule",{value:true});Qi.List=void 0;var ud=ot(),hd=et(),cd=et(),dd=I(),ga=class extends ud.Expression{constructor(t){super(),this.itemIdentifierList=t,this.GenerateIntoContainer=e=>{var n,i;let a=new hd.InkList;if(this.itemIdentifierList!=null)for(let r of this.itemIdentifierList){let s=((n=r?.name)===null||n===void 0?void 0:n.split("."))||[],l=null,u="";s.length>1?(l=s[0],u=s[1]):u=s[0];let h=this.story.ResolveListItem(l,u,this);if(h===null)l===null?this.Error(`Could not find list definition that contains item '${r}'`):this.Error(`Could not find list item ${r}`);else {if(h.parent==null){this.Error(`Could not find list definition for item ${r}`);return}l||(l=((i=h.parent.identifier)===null||i===void 0?void 0:i.name)||null);let c=new cd.InkListItem(l,h.name||null);a.has(c.serialized())?this.Warning(`Duplicate of item '${r}' in list.`):a.Add(c,h.seriesValue);}}e.AddContent(new dd.ListValue(a));};}get typeName(){return "List"}};Qi.List=ga;});var va=d(tr=>{Object.defineProperty(tr,"__esModule",{value:true});tr.ListElementDefinition=void 0;var fd=N(),pd=Tt(),Ca=class extends fd.ParsedObject{get fullName(){var t;let e=this.parent;if(e===null)throw new Error("Can't get full name without a parent list.");return `${(t=e.identifier)===null||t===void 0?void 0:t.name}.${this.name}`}get typeName(){return "ListElement"}get name(){var t;return ((t=this.indentifier)===null||t===void 0?void 0:t.name)||null}constructor(t,e,n=null){super(),this.indentifier=t,this.inInitialList=e,this.explicitValue=n,this.seriesValue=0,this.parent=null,this.GenerateRuntimeObject=()=>{throw new Error("Not implemented.")},this.toString=()=>this.fullName,this.parent=this.parent;}ResolveReferences(t){super.ResolveReferences(t),t.CheckForNamingCollisions(this,this.indentifier,pd.SymbolType.ListItem);}};tr.ListElementDefinition=Ca;});var Sa=d(er=>{Object.defineProperty(er,"__esModule",{value:true});er.StatementLevel=void 0;var hl;(function(o){o[o.InnerBlock=0]="InnerBlock",o[o.Stitch=1]="Stitch",o[o.Knot=2]="Knot",o[o.Top=3]="Top";})(hl||(er.StatementLevel=hl={}));});var _a=d(nr=>{Object.defineProperty(nr,"__esModule",{value:true});nr.Stitch=void 0;var md=_t(),gd=he(),ya=class extends md.FlowBase{get flowLevel(){return gd.FlowLevel.Stitch}constructor(t,e,n,i){super(t,e,n,i),this.baseToString=this.toString,this.toString=()=>`${this.parent!==null?this.parent+" > ":""}${this.baseToString()}`;}get typeName(){return "Stitch"}};nr.Stitch=ya;});var rr=d(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.Tag=void 0;var Cd=Q(),ba=class extends Cd.InkObject{constructor(t){super(),this.text=t.toString()||"";}toString(){return "# "+this.text}};ir.Tag=ba;});var wa=d(sr=>{Object.defineProperty(sr,"__esModule",{value:true});sr.Choice=void 0;var vd=Z(),Sd=B(),yd=Q(),Ea=class o extends yd.InkObject{constructor(){super(...arguments),this.text="",this.index=0,this.threadAtGeneration=null,this.sourcePath="",this.targetPath=null,this.isInvisibleDefault=false,this.tags=null,this.originalThreadIndex=0;}get pathStringOnChoice(){return this.targetPath===null?(0, Sd.throwNullException)("Choice.targetPath"):this.targetPath.toString()}set pathStringOnChoice(t){this.targetPath=new vd.Path(t);}Clone(){let t=new o;return t.text=this.text,t.sourcePath=this.sourcePath,t.index=this.index,t.targetPath=this.targetPath,t.originalThreadIndex=this.originalThreadIndex,t.isInvisibleDefault=this.isInvisibleDefault,this.threadAtGeneration!==null&&(t.threadAtGeneration=this.threadAtGeneration.Copy()),t}};sr.Choice=Ea;});var Oa=d(ar=>{Object.defineProperty(ar,"__esModule",{value:true});ar.ListDefinitionsOrigin=void 0;var _d=et(),bd=I(),Ed=B(),Pa=class{constructor(t){this._lists=new Map,this._allUnambiguousListValueCache=new Map;for(let e of t){this._lists.set(e.name,e);for(let[n,i]of e.items){let a=_d.InkListItem.fromSerializedKey(n),r=new bd.ListValue(a,i);if(!a.itemName)throw new Error("item.itemName is null or undefined.");this._allUnambiguousListValueCache.set(a.itemName,r),this._allUnambiguousListValueCache.set(a.fullName,r);}}}get lists(){let t=[];for(let[,e]of this._lists)t.push(e);return t}TryListGetDefinition(t,e){if(t===null)return {result:e,exists:false};let n=this._lists.get(t);return n?{result:n,exists:true}:{result:e,exists:false}}FindSingleItemListWithName(t){if(t===null)return (0, Ed.throwNullException)("name");let e=this._allUnambiguousListValueCache.get(t);return typeof e<"u"?e:null}};ar.ListDefinitionsOrigin=Pa;});var Ce=d(hr=>{Object.defineProperty(hr,"__esModule",{value:true});hr.JsonSerialisation=void 0;var or=F(),it=I(),cl=Ji(),b=G(),ge=Ut(),dl=yt(),fl=Mn(),xa=pe(),pl=Rt(),Ta=St(),ml=$t(),gl=rr(),wd=Z(),Cl=wa(),Pd=Xs(),Od=Oa(),lr=et(),k=P(),zt=B(),ur=class o{static JArrayToRuntimeObjList(t,e=false){let n=t.length;e&&n--;let i=[];for(let a=0;a<n;a++){let r=t[a],s=this.JTokenToRuntimeObject(r);if(s===null)return (0, zt.throwNullException)("runtimeObj");i.push(s);}return i}static WriteDictionaryRuntimeObjs(t,e){t.WriteObjectStart();for(let[n,i]of e)t.WritePropertyStart(n),this.WriteRuntimeObject(t,i),t.WritePropertyEnd();t.WriteObjectEnd();}static WriteListRuntimeObjs(t,e){t.WriteArrayStart();for(let n of e)this.WriteRuntimeObject(t,n);t.WriteArrayEnd();}static WriteIntDictionary(t,e){t.WriteObjectStart();for(let[n,i]of e)t.WriteIntProperty(n,i);t.WriteObjectEnd();}static WriteRuntimeObject(t,e){let n=(0, k.asOrNull)(e,or.Container);if(n){this.WriteRuntimeContainer(t,n);return}let i=(0, k.asOrNull)(e,dl.Divert);if(i){let C="->";i.isExternal?C="x()":i.pushesToStack&&(i.stackPushType==ge.PushPopType.Function?C="f()":i.stackPushType==ge.PushPopType.Tunnel&&(C="->t->"));let O;i.hasVariableTarget?O=i.variableDivertName:O=i.targetPathString,t.WriteObjectStart(),t.WriteProperty(C,O),i.hasVariableTarget&&t.WriteProperty("var",true),i.isConditional&&t.WriteProperty("c",true),i.externalArgs>0&&t.WriteIntProperty("exArgs",i.externalArgs),t.WriteObjectEnd();return}let a=(0, k.asOrNull)(e,fl.ChoicePoint);if(a){t.WriteObjectStart(),t.WriteProperty("*",a.pathStringOnChoice),t.WriteIntProperty("flg",a.flags),t.WriteObjectEnd();return}let r=(0, k.asOrNull)(e,it.BoolValue);if(r){t.WriteBool(r.value);return}let s=(0, k.asOrNull)(e,it.IntValue);if(s){t.WriteInt(s.value);return}let l=(0, k.asOrNull)(e,it.FloatValue);if(l){t.WriteFloat(l.value);return}let u=(0, k.asOrNull)(e,it.StringValue);if(u){u.isNewline?t.Write(`
|
|
17
17
|
`,false):(t.WriteStringStart(),t.WriteStringInner("^"),t.WriteStringInner(u.value),t.WriteStringEnd());return}let h=(0, k.asOrNull)(e,it.ListValue);if(h){this.WriteInkList(t,h);return}let c=(0, k.asOrNull)(e,it.DivertTargetValue);if(c){if(t.WriteObjectStart(),c.value===null)return (0, zt.throwNullException)("divTargetVal.value");t.WriteProperty("^->",c.value.componentsString),t.WriteObjectEnd();return}let f=(0, k.asOrNull)(e,it.VariablePointerValue);if(f){t.WriteObjectStart(),t.WriteProperty("^var",f.value),t.WriteIntProperty("ci",f.contextIndex),t.WriteObjectEnd();return}if((0, k.asOrNull)(e,cl.Glue)){t.Write("<>");return}let v=(0, k.asOrNull)(e,b.ControlCommand);if(v){t.Write(o._controlCommandNames[v.commandType]);return}let w=(0, k.asOrNull)(e,Ta.NativeFunctionCall);if(w){let C=w.name;C=="^"&&(C="L^"),t.Write(C);return}let H=(0, k.asOrNull)(e,xa.VariableReference);if(H){t.WriteObjectStart();let C=H.pathStringForCount;C!=null?t.WriteProperty("CNT?",C):t.WriteProperty("VAR?",H.name),t.WriteObjectEnd();return}let R=(0, k.asOrNull)(e,pl.VariableAssignment);if(R){t.WriteObjectStart();let C=R.isGlobal?"VAR=":"temp=";t.WriteProperty(C,R.variableName),R.isNewDeclaration||t.WriteProperty("re",true),t.WriteObjectEnd();return}if((0, k.asOrNull)(e,ml.Void)){t.Write("void");return}let st=(0, k.asOrNull)(e,gl.Tag);if(st){t.WriteObjectStart(),t.WriteProperty("#",st.text),t.WriteObjectEnd();return}let hn=(0, k.asOrNull)(e,Cl.Choice);if(hn){this.WriteChoice(t,hn);return}throw new Error("Failed to convert runtime object to Json token: "+e)}static JObjectToDictionaryRuntimeObjs(t){let e=new Map;for(let n in t)if(t.hasOwnProperty(n)){let i=this.JTokenToRuntimeObject(t[n]);if(i===null)return (0, zt.throwNullException)("inkObject");e.set(n,i);}return e}static JObjectToIntDictionary(t){let e=new Map;for(let n in t)t.hasOwnProperty(n)&&e.set(n,parseInt(t[n]));return e}static JTokenToRuntimeObject(t){if(typeof t=="number"&&!isNaN(t)||typeof t=="boolean")return it.Value.Create(t);if(typeof t=="string"){let e=t.toString(),n=/^([0-9]+.[0-9]+f)$/.exec(e);if(n)return new it.FloatValue(parseFloat(n[0]));let i=e[0];if(i=="^")return new it.StringValue(e.substring(1));if(i==`
|
|
18
18
|
`&&e.length==1)return new it.StringValue(`
|
|
19
|
-
`);if(e=="<>")return new cl.Glue;for(let a=0;a<o._controlCommandNames.length;++a){let r=o._controlCommandNames[a];if(e==r)return new b.ControlCommand(a)}if(e=="L^"&&(e="^"),Ta.NativeFunctionCall.CallExistsWithName(e))return Ta.NativeFunctionCall.CallWithName(e);if(e=="->->")return b.ControlCommand.PopTunnel();if(e=="~ret")return b.ControlCommand.PopFunction();if(e=="void")return new ml.Void}if(typeof t=="object"&&!Array.isArray(t)){let e=t,n;if(e["^->"])return n=e["^->"],new it.DivertTargetValue(new wd.Path(n.toString()));if(e["^var"]){n=e["^var"];let h=new it.VariablePointerValue(n.toString());return "ci"in e&&(n=e.ci,h.contextIndex=parseInt(n)),h}let i=false,a=false,r=ge.PushPopType.Function,s=false;if((n=e["->"])?i=true:(n=e["f()"])?(i=true,a=true,r=ge.PushPopType.Function):(n=e["->t->"])?(i=true,a=true,r=ge.PushPopType.Tunnel):(n=e["x()"])&&(i=true,s=true,a=false,r=ge.PushPopType.Function),i){let h=new dl.Divert;h.pushesToStack=a,h.stackPushType=r,h.isExternal=s;let c=n.toString();return (n=e.var)?h.variableDivertName=c:h.targetPathString=c,h.isConditional=!!e.c,s&&(n=e.exArgs)&&(h.externalArgs=parseInt(n)),h}if(n=e["*"]){let h=new fl.ChoicePoint;return h.pathStringOnChoice=n.toString(),(n=e.flg)&&(h.flags=parseInt(n)),h}if(n=e["VAR?"])return new xa.VariableReference(n.toString());if(n=e["CNT?"]){let h=new xa.VariableReference;return h.pathStringForCount=n.toString(),h}let l=false,u=false;if((n=e["VAR="])?(l=true,u=true):(n=e["temp="])&&(l=true,u=false),l){let h=n.toString(),c=!e.re,f=new pl.VariableAssignment(h,c);return f.isGlobal=u,f}if(e["#"]!==void 0)return n=e["#"],new gl.Tag(n.toString());if(n=e.list){let h=n,c=new lr.InkList;if(n=e.origins){let f=n;c.SetInitialOriginNames(f);}for(let f in h)if(h.hasOwnProperty(f)){let p=h[f],v=new lr.InkListItem(f),w=parseInt(p);c.Add(v,w);}return new it.ListValue(c)}if(e.originalChoicePath!=null)return this.JObjectToChoice(e)}if(Array.isArray(t))return this.JArrayToContainer(t);if(t==null)return null;throw new Error("Failed to convert token to runtime object: "+this.toJson(t,["parent"]))}static toJson(t,e,n){return JSON.stringify(t,(i,a)=>e?.some(r=>r===i)?void 0:a,n)}static WriteRuntimeContainer(t,e,n=false){if(t.WriteArrayStart(),e===null)return (0, zt.throwNullException)("container");for(let l of e.content)this.WriteRuntimeObject(t,l);let i=e.namedOnlyContent,a=e.countFlags,r=e.name!=null&&!n,s=i!=null||a>0||r;if(s&&t.WriteObjectStart(),i!=null)for(let[l,u]of i){let h=l,c=(0, k.asOrNull)(u,or.Container);t.WritePropertyStart(h),this.WriteRuntimeContainer(t,c,true),t.WritePropertyEnd();}a>0&&t.WriteIntProperty("#f",a),r&&t.WriteProperty("#n",e.name),s?t.WriteObjectEnd():t.WriteNull(),t.WriteArrayEnd();}static JArrayToContainer(t){let e=new or.Container;e.content=this.JArrayToRuntimeObjList(t,true);let n=t[t.length-1];if(n!=null){let i=new Map;for(let a in n)if(a=="#f")e.countFlags=parseInt(n[a]);else if(a=="#n")e.name=n[a].toString();else {let r=this.JTokenToRuntimeObject(n[a]),s=(0, k.asOrNull)(r,or.Container);s&&(s.name=a),i.set(a,r);}e.namedOnlyContent=i;}return e}static JObjectToChoice(t){let e=new Cl.Choice;return e.text=t.text.toString(),e.index=parseInt(t.index),e.sourcePath=t.originalChoicePath.toString(),e.originalThreadIndex=parseInt(t.originalThreadIndex),e.pathStringOnChoice=t.targetPath.toString(),e.tags=this.JArrayToTags(t),e}static JArrayToTags(t){return t.tags?t.tags:null}static WriteChoice(t,e){t.WriteObjectStart(),t.WriteProperty("text",e.text),t.WriteIntProperty("index",e.index),t.WriteProperty("originalChoicePath",e.sourcePath),t.WriteIntProperty("originalThreadIndex",e.originalThreadIndex),t.WriteProperty("targetPath",e.pathStringOnChoice),this.WriteChoiceTags(t,e),t.WriteObjectEnd();}static WriteChoiceTags(t,e){if(e.tags&&e.tags.length>0){t.WritePropertyStart("tags"),t.WriteArrayStart();for(let n of e.tags)t.Write(n);t.WriteArrayEnd(),t.WritePropertyEnd();}}static WriteInkList(t,e){let n=e.value;if(n===null)return (0, zt.throwNullException)("rawList");t.WriteObjectStart(),t.WritePropertyStart("list"),t.WriteObjectStart();for(let[i,a]of n){let r=lr.InkListItem.fromSerializedKey(i),s=a;if(r.itemName===null)return (0, zt.throwNullException)("item.itemName");t.WritePropertyNameStart(),t.WritePropertyNameInner(r.originName?r.originName:"?"),t.WritePropertyNameInner("."),t.WritePropertyNameInner(r.itemName),t.WritePropertyNameEnd(),t.Write(s),t.WritePropertyEnd();}if(t.WriteObjectEnd(),t.WritePropertyEnd(),n.Count==0&&n.originNames!=null&&n.originNames.length>0){t.WritePropertyStart("origins"),t.WriteArrayStart();for(let i of n.originNames)t.Write(i);t.WriteArrayEnd(),t.WritePropertyEnd();}t.WriteObjectEnd();}static ListDefinitionsToJToken(t){let e={};for(let n of t.lists){let i={};for(let[a,r]of n.items){let s=lr.InkListItem.fromSerializedKey(a);if(s.itemName===null)return (0, zt.throwNullException)("item.itemName");i[s.itemName]=r;}e[n.name]=i;}return e}static JTokenToListDefinitions(t){let e=t,n=[];for(let i in e)if(e.hasOwnProperty(i)){let a=i.toString(),r=e[i],s=new Map;for(let u in r)if(e.hasOwnProperty(i)){let h=r[u];s.set(u,parseInt(h));}let l=new Pd.ListDefinition(a,s);n.push(l);}return new Od.ListDefinitionsOrigin(n)}};hr.JsonSerialisation=ur;ur._controlCommandNames=(()=>{let o=[];o[b.ControlCommand.CommandType.EvalStart]="ev",o[b.ControlCommand.CommandType.EvalOutput]="out",o[b.ControlCommand.CommandType.EvalEnd]="/ev",o[b.ControlCommand.CommandType.Duplicate]="du",o[b.ControlCommand.CommandType.PopEvaluatedValue]="pop",o[b.ControlCommand.CommandType.PopFunction]="~ret",o[b.ControlCommand.CommandType.PopTunnel]="->->",o[b.ControlCommand.CommandType.BeginString]="str",o[b.ControlCommand.CommandType.EndString]="/str",o[b.ControlCommand.CommandType.NoOp]="nop",o[b.ControlCommand.CommandType.ChoiceCount]="choiceCnt",o[b.ControlCommand.CommandType.Turns]="turn",o[b.ControlCommand.CommandType.TurnsSince]="turns",o[b.ControlCommand.CommandType.ReadCount]="readc",o[b.ControlCommand.CommandType.Random]="rnd",o[b.ControlCommand.CommandType.SeedRandom]="srnd",o[b.ControlCommand.CommandType.VisitIndex]="visit",o[b.ControlCommand.CommandType.SequenceShuffleIndex]="seq",o[b.ControlCommand.CommandType.StartThread]="thread",o[b.ControlCommand.CommandType.Done]="done",o[b.ControlCommand.CommandType.End]="end",o[b.ControlCommand.CommandType.ListFromInt]="listInt",o[b.ControlCommand.CommandType.ListRange]="range",o[b.ControlCommand.CommandType.ListRandom]="lrnd",o[b.ControlCommand.CommandType.BeginTag]="#",o[b.ControlCommand.CommandType.EndTag]="/#";for(let t=0;t<b.ControlCommand.CommandType.TOTAL_VALUES;++t)if(o[t]==null)throw new Error("Control command not accounted for in serialisation");return o})();});var Aa=d(Xe=>{Object.defineProperty(Xe,"__esModule",{value:true});Xe.CallStack=void 0;var Na=Ut(),vl=Z(),xd=Ye(),Sl=Ce(),Td=I(),Nd=Bt(),Je=qe(),Id=Oe(),yl=se(),Ia=B(),ze=class o{get elements(){return this.callStack}get depth(){return this.elements.length}get currentElement(){let e=this._threads[this._threads.length-1].callstack;return e[e.length-1]}get currentElementIndex(){return this.callStack.length-1}get currentThread(){return this._threads[this._threads.length-1]}set currentThread(t){Id.Debug.Assert(this._threads.length==1,"Shouldn't be directly setting the current thread when we have a stack of them"),this._threads.length=0,this._threads.push(t);}get canPop(){return this.callStack.length>1}constructor(){if(this._threadCounter=0,this._startOfRoot=Je.Pointer.Null,arguments[0]instanceof xd.Story){let t=arguments[0];this._startOfRoot=Je.Pointer.StartOf(t.rootContentContainer),this.Reset();}else {let t=arguments[0];this._threads=[];for(let e of t._threads)this._threads.push(e.Copy());this._threadCounter=t._threadCounter,this._startOfRoot=t._startOfRoot.copy();}}Reset(){this._threads=[],this._threads.push(new o.Thread),this._threads[0].callstack.push(new o.Element(Na.PushPopType.Tunnel,this._startOfRoot));}SetJsonToken(t,e){this._threads.length=0;let n=t.threads;for(let i of n){let a=i,r=new o.Thread(a,e);this._threads.push(r);}this._threadCounter=parseInt(t.threadCounter),this._startOfRoot=Je.Pointer.StartOf(e.rootContentContainer);}WriteJson(t){t.WriteObject(e=>{e.WritePropertyStart("threads"),e.WriteArrayStart();for(let n of this._threads)n.WriteJson(e);e.WriteArrayEnd(),e.WritePropertyEnd(),e.WritePropertyStart("threadCounter"),e.WriteInt(this._threadCounter),e.WritePropertyEnd();});}PushThread(){let t=this.currentThread.Copy();this._threadCounter++,t.threadIndex=this._threadCounter,this._threads.push(t);}ForkThread(){let t=this.currentThread.Copy();return this._threadCounter++,t.threadIndex=this._threadCounter,t}PopThread(){if(this.canPopThread)this._threads.splice(this._threads.indexOf(this.currentThread),1);else throw new Error("Can't pop thread")}get canPopThread(){return this._threads.length>1&&!this.elementIsEvaluateFromGame}get elementIsEvaluateFromGame(){return this.currentElement.type==Na.PushPopType.FunctionEvaluationFromGame}Push(t,e=0,n=0){let i=new o.Element(t,this.currentElement.currentPointer,false);i.evaluationStackHeightWhenPushed=e,i.functionStartInOutputStream=n,this.callStack.push(i);}CanPop(t=null){return this.canPop?t==null?true:this.currentElement.type==t:false}Pop(t=null){if(this.CanPop(t)){this.callStack.pop();return}else throw new Error("Mismatched push/pop in Callstack")}GetTemporaryVariableWithName(t,e=-1){e==-1&&(e=this.currentElementIndex+1);let n=this.callStack[e-1],i=(0, yl.tryGetValueFromMap)(n.temporaryVariables,t,null);return i.exists?i.result:null}SetTemporaryVariable(t,e,n,i=-1){i==-1&&(i=this.currentElementIndex+1);let a=this.callStack[i-1];if(!n&&!a.temporaryVariables.get(t))throw new Error("Could not find temporary variable to set: "+t);let r=(0, yl.tryGetValueFromMap)(a.temporaryVariables,t,null);r.exists&&Td.ListValue.RetainListOriginsForAssignment(r.result,e),a.temporaryVariables.set(t,e);}ContextForVariableNamed(t){return this.currentElement.temporaryVariables.get(t)?this.currentElementIndex+1:0}ThreadWithIndex(t){let e=this._threads.filter(n=>{if(n.threadIndex==t)return n});return e.length>0?e[0]:null}get callStack(){return this.currentThread.callstack}get callStackTrace(){let t=new Nd.StringBuilder;for(let e=0;e<this._threads.length;e++){let n=this._threads[e],i=e==this._threads.length-1;t.AppendFormat(`=== THREAD {0}/{1} {2}===
|
|
19
|
+
`);if(e=="<>")return new cl.Glue;for(let a=0;a<o._controlCommandNames.length;++a){let r=o._controlCommandNames[a];if(e==r)return new b.ControlCommand(a)}if(e=="L^"&&(e="^"),Ta.NativeFunctionCall.CallExistsWithName(e))return Ta.NativeFunctionCall.CallWithName(e);if(e=="->->")return b.ControlCommand.PopTunnel();if(e=="~ret")return b.ControlCommand.PopFunction();if(e=="void")return new ml.Void}if(typeof t=="object"&&!Array.isArray(t)){let e=t,n;if(e["^->"])return n=e["^->"],new it.DivertTargetValue(new wd.Path(n.toString()));if(e["^var"]){n=e["^var"];let h=new it.VariablePointerValue(n.toString());return "ci"in e&&(n=e.ci,h.contextIndex=parseInt(n)),h}let i=false,a=false,r=ge.PushPopType.Function,s=false;if((n=e["->"])?i=true:(n=e["f()"])?(i=true,a=true,r=ge.PushPopType.Function):(n=e["->t->"])?(i=true,a=true,r=ge.PushPopType.Tunnel):(n=e["x()"])&&(i=true,s=true,a=false,r=ge.PushPopType.Function),i){let h=new dl.Divert;h.pushesToStack=a,h.stackPushType=r,h.isExternal=s;let c=n.toString();return (n=e.var)?h.variableDivertName=c:h.targetPathString=c,h.isConditional=!!e.c,s&&(n=e.exArgs)&&(h.externalArgs=parseInt(n)),h}if(n=e["*"]){let h=new fl.ChoicePoint;return h.pathStringOnChoice=n.toString(),(n=e.flg)&&(h.flags=parseInt(n)),h}if(n=e["VAR?"])return new xa.VariableReference(n.toString());if(n=e["CNT?"]){let h=new xa.VariableReference;return h.pathStringForCount=n.toString(),h}let l=false,u=false;if((n=e["VAR="])?(l=true,u=true):(n=e["temp="])&&(l=true,u=false),l){let h=n.toString(),c=!e.re,f=new pl.VariableAssignment(h,c);return f.isGlobal=u,f}if(e["#"]!==void 0)return n=e["#"],new gl.Tag(n.toString());if(n=e.list){let h=n,c=new lr.InkList;if(n=e.origins){let f=n;c.SetInitialOriginNames(f);}for(let f in h)if(h.hasOwnProperty(f)){let p=h[f],v=new lr.InkListItem(f),w=parseInt(p);c.Add(v,w);}return new it.ListValue(c)}if(e.originalChoicePath!=null)return this.JObjectToChoice(e)}if(Array.isArray(t))return this.JArrayToContainer(t);if(t==null)return null;throw new Error("Failed to convert token to runtime object: "+this.toJson(t,["parent"]))}static toJson(t,e,n){return JSON.stringify(t,(i,a)=>e?.some(r=>r===i)?void 0:a,n)}static WriteRuntimeContainer(t,e,n=false){if(t.WriteArrayStart(),e===null)return (0, zt.throwNullException)("container");for(let l of e.content)this.WriteRuntimeObject(t,l);let i=e.namedOnlyContent,a=e.countFlags,r=e.name!=null&&!n,s=i!=null||a>0||r;if(s&&t.WriteObjectStart(),i!=null)for(let[l,u]of i){let h=l,c=(0, k.asOrNull)(u,or.Container);t.WritePropertyStart(h),this.WriteRuntimeContainer(t,c,true),t.WritePropertyEnd();}a>0&&t.WriteIntProperty("#f",a),r&&t.WriteProperty("#n",e.name),s?t.WriteObjectEnd():t.WriteNull(),t.WriteArrayEnd();}static JArrayToContainer(t){let e=new or.Container;e.content=this.JArrayToRuntimeObjList(t,true);let n=t[t.length-1];if(n!=null){let i=new Map;for(let a in n)if(a=="#f")e.countFlags=parseInt(n[a]);else if(a=="#n")e.name=n[a].toString();else {let r=this.JTokenToRuntimeObject(n[a]),s=(0, k.asOrNull)(r,or.Container);s&&(s.name=a),i.set(a,r);}e.namedOnlyContent=i;}return e}static JObjectToChoice(t){let e=new Cl.Choice;return e.text=t.text.toString(),e.index=parseInt(t.index),e.sourcePath=t.originalChoicePath.toString(),e.originalThreadIndex=parseInt(t.originalThreadIndex),e.pathStringOnChoice=t.targetPath.toString(),e.tags=this.JArrayToTags(t),e.isInvisibleDefault=!!t.isInvisibleDefault,e}static JArrayToTags(t){return t.tags?t.tags:null}static WriteChoice(t,e){t.WriteObjectStart(),t.WriteProperty("text",e.text),t.WriteIntProperty("index",e.index),t.WriteProperty("originalChoicePath",e.sourcePath),t.WriteIntProperty("originalThreadIndex",e.originalThreadIndex),t.WriteProperty("targetPath",e.pathStringOnChoice),t.WriteProperty("isInvisibleDefault",e.isInvisibleDefault),this.WriteChoiceTags(t,e),t.WriteObjectEnd();}static WriteChoiceTags(t,e){if(e.tags&&e.tags.length>0){t.WritePropertyStart("tags"),t.WriteArrayStart();for(let n of e.tags)t.Write(n);t.WriteArrayEnd(),t.WritePropertyEnd();}}static WriteInkList(t,e){let n=e.value;if(n===null)return (0, zt.throwNullException)("rawList");t.WriteObjectStart(),t.WritePropertyStart("list"),t.WriteObjectStart();for(let[i,a]of n){let r=lr.InkListItem.fromSerializedKey(i),s=a;if(r.itemName===null)return (0, zt.throwNullException)("item.itemName");t.WritePropertyNameStart(),t.WritePropertyNameInner(r.originName?r.originName:"?"),t.WritePropertyNameInner("."),t.WritePropertyNameInner(r.itemName),t.WritePropertyNameEnd(),t.Write(s),t.WritePropertyEnd();}if(t.WriteObjectEnd(),t.WritePropertyEnd(),n.Count==0&&n.originNames!=null&&n.originNames.length>0){t.WritePropertyStart("origins"),t.WriteArrayStart();for(let i of n.originNames)t.Write(i);t.WriteArrayEnd(),t.WritePropertyEnd();}t.WriteObjectEnd();}static ListDefinitionsToJToken(t){let e={};for(let n of t.lists){let i={};for(let[a,r]of n.items){let s=lr.InkListItem.fromSerializedKey(a);if(s.itemName===null)return (0, zt.throwNullException)("item.itemName");i[s.itemName]=r;}e[n.name]=i;}return e}static JTokenToListDefinitions(t){let e=t,n=[];for(let i in e)if(e.hasOwnProperty(i)){let a=i.toString(),r=e[i],s=new Map;for(let u in r)if(e.hasOwnProperty(i)){let h=r[u];s.set(u,parseInt(h));}let l=new Pd.ListDefinition(a,s);n.push(l);}return new Od.ListDefinitionsOrigin(n)}};hr.JsonSerialisation=ur;ur._controlCommandNames=(()=>{let o=[];o[b.ControlCommand.CommandType.EvalStart]="ev",o[b.ControlCommand.CommandType.EvalOutput]="out",o[b.ControlCommand.CommandType.EvalEnd]="/ev",o[b.ControlCommand.CommandType.Duplicate]="du",o[b.ControlCommand.CommandType.PopEvaluatedValue]="pop",o[b.ControlCommand.CommandType.PopFunction]="~ret",o[b.ControlCommand.CommandType.PopTunnel]="->->",o[b.ControlCommand.CommandType.BeginString]="str",o[b.ControlCommand.CommandType.EndString]="/str",o[b.ControlCommand.CommandType.NoOp]="nop",o[b.ControlCommand.CommandType.ChoiceCount]="choiceCnt",o[b.ControlCommand.CommandType.Turns]="turn",o[b.ControlCommand.CommandType.TurnsSince]="turns",o[b.ControlCommand.CommandType.ReadCount]="readc",o[b.ControlCommand.CommandType.Random]="rnd",o[b.ControlCommand.CommandType.SeedRandom]="srnd",o[b.ControlCommand.CommandType.VisitIndex]="visit",o[b.ControlCommand.CommandType.SequenceShuffleIndex]="seq",o[b.ControlCommand.CommandType.StartThread]="thread",o[b.ControlCommand.CommandType.Done]="done",o[b.ControlCommand.CommandType.End]="end",o[b.ControlCommand.CommandType.ListFromInt]="listInt",o[b.ControlCommand.CommandType.ListRange]="range",o[b.ControlCommand.CommandType.ListRandom]="lrnd",o[b.ControlCommand.CommandType.BeginTag]="#",o[b.ControlCommand.CommandType.EndTag]="/#";for(let t=0;t<b.ControlCommand.CommandType.TOTAL_VALUES;++t)if(o[t]==null)throw new Error("Control command not accounted for in serialisation");return o})();});var Aa=d(Xe=>{Object.defineProperty(Xe,"__esModule",{value:true});Xe.CallStack=void 0;var Na=Ut(),vl=Z(),xd=Ye(),Sl=Ce(),Td=I(),Nd=Bt(),Je=qe(),Id=Oe(),yl=se(),Ia=B(),ze=class o{get elements(){return this.callStack}get depth(){return this.elements.length}get currentElement(){let e=this._threads[this._threads.length-1].callstack;return e[e.length-1]}get currentElementIndex(){return this.callStack.length-1}get currentThread(){return this._threads[this._threads.length-1]}set currentThread(t){Id.Debug.Assert(this._threads.length==1,"Shouldn't be directly setting the current thread when we have a stack of them"),this._threads.length=0,this._threads.push(t);}get canPop(){return this.callStack.length>1}constructor(){if(this._threadCounter=0,this._startOfRoot=Je.Pointer.Null,arguments[0]instanceof xd.Story){let t=arguments[0];this._startOfRoot=Je.Pointer.StartOf(t.rootContentContainer),this.Reset();}else {let t=arguments[0];this._threads=[];for(let e of t._threads)this._threads.push(e.Copy());this._threadCounter=t._threadCounter,this._startOfRoot=t._startOfRoot.copy();}}Reset(){this._threads=[],this._threads.push(new o.Thread),this._threads[0].callstack.push(new o.Element(Na.PushPopType.Tunnel,this._startOfRoot));}SetJsonToken(t,e){this._threads.length=0;let n=t.threads;for(let i of n){let a=i,r=new o.Thread(a,e);this._threads.push(r);}this._threadCounter=parseInt(t.threadCounter),this._startOfRoot=Je.Pointer.StartOf(e.rootContentContainer);}WriteJson(t){t.WriteObject(e=>{e.WritePropertyStart("threads"),e.WriteArrayStart();for(let n of this._threads)n.WriteJson(e);e.WriteArrayEnd(),e.WritePropertyEnd(),e.WritePropertyStart("threadCounter"),e.WriteInt(this._threadCounter),e.WritePropertyEnd();});}PushThread(){let t=this.currentThread.Copy();this._threadCounter++,t.threadIndex=this._threadCounter,this._threads.push(t);}ForkThread(){let t=this.currentThread.Copy();return this._threadCounter++,t.threadIndex=this._threadCounter,t}PopThread(){if(this.canPopThread)this._threads.splice(this._threads.indexOf(this.currentThread),1);else throw new Error("Can't pop thread")}get canPopThread(){return this._threads.length>1&&!this.elementIsEvaluateFromGame}get elementIsEvaluateFromGame(){return this.currentElement.type==Na.PushPopType.FunctionEvaluationFromGame}Push(t,e=0,n=0){let i=new o.Element(t,this.currentElement.currentPointer,false);i.evaluationStackHeightWhenPushed=e,i.functionStartInOutputStream=n,this.callStack.push(i);}CanPop(t=null){return this.canPop?t==null?true:this.currentElement.type==t:false}Pop(t=null){if(this.CanPop(t)){this.callStack.pop();return}else throw new Error("Mismatched push/pop in Callstack")}GetTemporaryVariableWithName(t,e=-1){e==-1&&(e=this.currentElementIndex+1);let n=this.callStack[e-1],i=(0, yl.tryGetValueFromMap)(n.temporaryVariables,t,null);return i.exists?i.result:null}SetTemporaryVariable(t,e,n,i=-1){i==-1&&(i=this.currentElementIndex+1);let a=this.callStack[i-1];if(!n&&!a.temporaryVariables.get(t))throw new Error("Could not find temporary variable to set: "+t);let r=(0, yl.tryGetValueFromMap)(a.temporaryVariables,t,null);r.exists&&Td.ListValue.RetainListOriginsForAssignment(r.result,e),a.temporaryVariables.set(t,e);}ContextForVariableNamed(t){return this.currentElement.temporaryVariables.get(t)?this.currentElementIndex+1:0}ThreadWithIndex(t){let e=this._threads.filter(n=>{if(n.threadIndex==t)return n});return e.length>0?e[0]:null}get callStack(){return this.currentThread.callstack}get callStackTrace(){let t=new Nd.StringBuilder;for(let e=0;e<this._threads.length;e++){let n=this._threads[e],i=e==this._threads.length-1;t.AppendFormat(`=== THREAD {0}/{1} {2}===
|
|
20
20
|
`,e+1,this._threads.length,i?"(current) ":"");for(let a=0;a<n.callstack.length;a++){n.callstack[a].type==Na.PushPopType.Function?t.Append(" [FUNCTION] "):t.Append(" [TUNNEL] ");let r=n.callstack[a].currentPointer;if(!r.isNull){if(t.Append("<SOMEWHERE IN "),r.container===null)return (0, Ia.throwNullException)("pointer.container");t.Append(r.container.path.toString()),t.AppendLine(">");}}}return t.toString()}};Xe.CallStack=ze;(function(o){class t{constructor(i,a,r=false){this.evaluationStackHeightWhenPushed=0,this.functionStartInOutputStream=0,this.currentPointer=a.copy(),this.inExpressionEvaluation=r,this.temporaryVariables=new Map,this.type=i;}Copy(){let i=new t(this.type,this.currentPointer,this.inExpressionEvaluation);return i.temporaryVariables=new Map(this.temporaryVariables),i.evaluationStackHeightWhenPushed=this.evaluationStackHeightWhenPushed,i.functionStartInOutputStream=this.functionStartInOutputStream,i}}o.Element=t;class e{constructor(){if(this.threadIndex=0,this.previousPointer=Je.Pointer.Null,this.callstack=[],arguments[0]&&arguments[1]){let i=arguments[0],a=arguments[1];this.threadIndex=parseInt(i.threadIndex);let r=i.callstack;for(let l of r){let u=l,h=parseInt(u.type),c=Je.Pointer.Null,f,p=u.cPath;if(typeof p<"u"){f=p.toString();let R=a.ContentAtPath(new vl.Path(f));if(c.container=R.container,c.index=parseInt(u.idx),R.obj==null)throw new Error("When loading state, internal story location couldn't be found: "+f+". Has the story changed since this save data was created?");R.approximate&&(c.container!==null?a.Warning("When loading state, exact internal story location couldn't be found: '"+f+"', so it was approximated to '"+c.container.path.toString()+"' to recover. Has the story changed since this save data was created?"):a.Warning("When loading state, exact internal story location couldn't be found: '"+f+"' and it may not be recoverable. Has the story changed since this save data was created?"));}let v=!!u.exp,w=new t(h,c,v),H=u.temp;typeof H<"u"?w.temporaryVariables=Sl.JsonSerialisation.JObjectToDictionaryRuntimeObjs(H):w.temporaryVariables.clear(),this.callstack.push(w);}let s=i.previousContentObject;if(typeof s<"u"){let l=new vl.Path(s.toString());this.previousPointer=a.PointerAtPath(l);}}}Copy(){let i=new e;i.threadIndex=this.threadIndex;for(let a of this.callstack)i.callstack.push(a.Copy());return i.previousPointer=this.previousPointer.copy(),i}WriteJson(i){i.WriteObjectStart(),i.WritePropertyStart("callstack"),i.WriteArrayStart();for(let a of this.callstack){if(i.WriteObjectStart(),!a.currentPointer.isNull){if(a.currentPointer.container===null)return (0, Ia.throwNullException)("el.currentPointer.container");i.WriteProperty("cPath",a.currentPointer.container.path.componentsString),i.WriteIntProperty("idx",a.currentPointer.index);}i.WriteProperty("exp",a.inExpressionEvaluation),i.WriteIntProperty("type",a.type),a.temporaryVariables.size>0&&(i.WritePropertyStart("temp"),Sl.JsonSerialisation.WriteDictionaryRuntimeObjs(i,a.temporaryVariables),i.WritePropertyEnd()),i.WriteObjectEnd();}if(i.WriteArrayEnd(),i.WritePropertyEnd(),i.WriteIntProperty("threadIndex",this.threadIndex),!this.previousPointer.isNull){let a=this.previousPointer.Resolve();if(a===null)return (0, Ia.throwNullException)("this.previousPointer.Resolve()");i.WriteProperty("previousContentObject",a.path.toString());}i.WriteObjectEnd();}}o.Thread=e;})(ze||(Xe.CallStack=ze={}));});var bl=d(dr=>{Object.defineProperty(dr,"__esModule",{value:true});dr.VariablesState=void 0;var M=I(),Ad=Te(),_l=Ce(),$=P(),Ze=se(),Dt=B();function Fd(){return class{}}var cr=class o extends Fd(){variableChangedEvent(t,e){for(let n of this.variableChangedEventCallbacks)n(t,e);}StartVariableObservation(){this._batchObservingVariableChanges=true,this._changedVariablesForBatchObs=new Set;}CompleteVariableObservation(){this._batchObservingVariableChanges=false;let t=new Map;if(this._changedVariablesForBatchObs!=null)for(let e of this._changedVariablesForBatchObs){let n=this._globalVariables.get(e);this.variableChangedEvent(e,n);}if(this.patch!=null)for(let e of this.patch.changedVariables){let n=this.patch.TryGetGlobal(e,null);n.exists&&t.set(e,n);}return this._changedVariablesForBatchObs=null,t}NotifyObservers(t){for(let[e,n]of t)this.variableChangedEvent(e,n);}get callStack(){return this._callStack}set callStack(t){this._callStack=t;}$(t,e){if(typeof e>"u"){let n=null;return this.patch!==null&&(n=this.patch.TryGetGlobal(t,null),n.exists)?n.result.valueObject:(n=this._globalVariables.get(t),typeof n>"u"&&(n=this._defaultGlobalVariables.get(t)),typeof n<"u"?n.valueObject:null)}else {if(typeof this._defaultGlobalVariables.get(t)>"u")throw new Ad.StoryException("Cannot assign to a variable ("+t+") that hasn't been declared in the story");let n=M.Value.Create(e);if(n==null)throw e==null?new Error("Cannot pass null to VariableState"):new Error("Invalid value passed to VariableState: "+e.toString());this.SetGlobal(t,n);}}constructor(t,e){super(),this.variableChangedEventCallbacks=[],this.patch=null,this._defaultGlobalVariables=new Map,this._changedVariablesForBatchObs=new Set,this._batchObservingVariableChanges=false,this._globalVariables=new Map,this._callStack=t,this._listDefsOrigin=e;try{return new Proxy(this,{get(i,a){return a in i?i[a]:i.$(a)},set(i,a,r){return a in i?i[a]=r:i.$(a,r),!0},ownKeys(i){return [...new Set([...i._defaultGlobalVariables.keys(),...i._globalVariables.keys()])]},getOwnPropertyDescriptor(i,a){return {enumerable:!0,configurable:!0,value:i.$(a)}}})}catch{}}ApplyPatch(){if(this.patch===null)return (0, Dt.throwNullException)("this.patch");for(let[t,e]of this.patch.globals)this._globalVariables.set(t,e);if(this._changedVariablesForBatchObs!==null)for(let t of this.patch.changedVariables)this._changedVariablesForBatchObs.add(t);this.patch=null;}SetJsonToken(t){this._globalVariables.clear();for(let[e,n]of this._defaultGlobalVariables){let i=t[e];if(typeof i<"u"){let a=_l.JsonSerialisation.JTokenToRuntimeObject(i);if(a===null)return (0, Dt.throwNullException)("tokenInkObject");this._globalVariables.set(e,a);}else this._globalVariables.set(e,n);}}WriteJson(t){t.WriteObjectStart();for(let[e,n]of this._globalVariables){let i=e,a=n;if(o.dontSaveDefaultValues&&this._defaultGlobalVariables.has(i)){let r=this._defaultGlobalVariables.get(i);if(this.RuntimeObjectsEqual(a,r))continue}t.WritePropertyStart(i),_l.JsonSerialisation.WriteRuntimeObject(t,a),t.WritePropertyEnd();}t.WriteObjectEnd();}RuntimeObjectsEqual(t,e){if(t===null)return (0, Dt.throwNullException)("obj1");if(e===null)return (0, Dt.throwNullException)("obj2");if(t.constructor!==e.constructor)return false;let n=(0, $.asOrNull)(t,M.BoolValue);if(n!==null)return n.value===(0, $.asOrThrows)(e,M.BoolValue).value;let i=(0, $.asOrNull)(t,M.IntValue);if(i!==null)return i.value===(0, $.asOrThrows)(e,M.IntValue).value;let a=(0, $.asOrNull)(t,M.FloatValue);if(a!==null)return a.value===(0, $.asOrThrows)(e,M.FloatValue).value;let r=(0, $.asOrNull)(t,M.Value),s=(0, $.asOrNull)(e,M.Value);if(r!==null&&s!==null)return (0, $.isEquatable)(r.valueObject)&&(0, $.isEquatable)(s.valueObject)?r.valueObject.Equals(s.valueObject):r.valueObject===s.valueObject;throw new Error("FastRoughDefinitelyEquals: Unsupported runtime object type: "+t.constructor.name)}GetVariableWithName(t,e=-1){let n=this.GetRawVariableWithName(t,e),i=(0, $.asOrNull)(n,M.VariablePointerValue);return i!==null&&(n=this.ValueAtVariablePointer(i)),n}TryGetDefaultVariableValue(t){let e=(0, Ze.tryGetValueFromMap)(this._defaultGlobalVariables,t,null);return e.exists?e.result:null}GlobalVariableExistsWithName(t){return this._globalVariables.has(t)||this._defaultGlobalVariables!==null&&this._defaultGlobalVariables.has(t)}GetRawVariableWithName(t,e){let n=null;if(e==0||e==-1){let i=null;if(this.patch!==null&&(i=this.patch.TryGetGlobal(t,null),i.exists)||(i=(0, Ze.tryGetValueFromMap)(this._globalVariables,t,null),i.exists)||this._defaultGlobalVariables!==null&&(i=(0, Ze.tryGetValueFromMap)(this._defaultGlobalVariables,t,null),i.exists))return i.result;if(this._listDefsOrigin===null)return (0, Dt.throwNullException)("VariablesState._listDefsOrigin");let a=this._listDefsOrigin.FindSingleItemListWithName(t);if(a)return a}return n=this._callStack.GetTemporaryVariableWithName(t,e),n}ValueAtVariablePointer(t){return this.GetVariableWithName(t.variableName,t.contextIndex)}Assign(t,e){let n=t.variableName;if(n===null)return (0, Dt.throwNullException)("name");let i=-1,a=false;if(t.isNewDeclaration?a=t.isGlobal:a=this.GlobalVariableExistsWithName(n),t.isNewDeclaration){let r=(0, $.asOrNull)(e,M.VariablePointerValue);r!==null&&(e=this.ResolveVariablePointer(r));}else {let r=null;do r=(0, $.asOrNull)(this.GetRawVariableWithName(n,i),M.VariablePointerValue),r!=null&&(n=r.variableName,i=r.contextIndex,a=i==0);while(r!=null)}a?this.SetGlobal(n,e):this._callStack.SetTemporaryVariable(n,e,t.isNewDeclaration,i);}SnapshotDefaultGlobals(){this._defaultGlobalVariables=new Map(this._globalVariables);}RetainListOriginsForAssignment(t,e){let n=(0, $.asOrThrows)(t,M.ListValue),i=(0, $.asOrThrows)(e,M.ListValue);n.value&&i.value&&i.value.Count==0&&i.value.SetInitialOriginNames(n.value.originNames);}SetGlobal(t,e){let n=null;if(this.patch===null&&(n=(0, Ze.tryGetValueFromMap)(this._globalVariables,t,null)),this.patch!==null&&(n=this.patch.TryGetGlobal(t,null),n.exists||(n=(0, Ze.tryGetValueFromMap)(this._globalVariables,t,null))),M.ListValue.RetainListOriginsForAssignment(n.result,e),t===null)return (0, Dt.throwNullException)("variableName");if(this.patch!==null?this.patch.SetGlobal(t,e):this._globalVariables.set(t,e),this.variableChangedEvent!==null&&n!==null&&e!==n.result)if(this._batchObservingVariableChanges){if(this._changedVariablesForBatchObs===null)return (0, Dt.throwNullException)("this._changedVariablesForBatchObs");this.patch!==null?this.patch.AddChangedVariable(t):this._changedVariablesForBatchObs!==null&&this._changedVariablesForBatchObs.add(t);}else this.variableChangedEvent(t,e);}ResolveVariablePointer(t){let e=t.contextIndex;e==-1&&(e=this.GetContextIndexOfVariableNamed(t.variableName));let n=this.GetRawVariableWithName(t.variableName,e),i=(0, $.asOrNull)(n,M.VariablePointerValue);return i??new M.VariablePointerValue(t.variableName,e)}GetContextIndexOfVariableNamed(t){return this.GlobalVariableExistsWithName(t)?0:this._callStack.currentElementIndex}ObserveVariableChange(t){this.variableChangedEventCallbacks.push(t);}};dr.VariablesState=cr;cr.dontSaveDefaultValues=true;});var ka=d(fr=>{Object.defineProperty(fr,"__esModule",{value:true});fr.PRNG=void 0;var Fa=class{constructor(t){this.seed=t%2147483647,this.seed<=0&&(this.seed+=2147483646);}next(){return this.seed=this.seed*48271%2147483647}nextFloat(){return (this.next()-1)/2147483646}};fr.PRNG=Fa;});var El=d(pr=>{Object.defineProperty(pr,"__esModule",{value:true});pr.StatePatch=void 0;var Ra=class{get globals(){return this._globals}get changedVariables(){return this._changedVariables}get visitCounts(){return this._visitCounts}get turnIndices(){return this._turnIndices}constructor(){if(this._changedVariables=new Set,this._visitCounts=new Map,this._turnIndices=new Map,arguments.length===1&&arguments[0]!==null){let t=arguments[0];this._globals=new Map(t._globals),this._changedVariables=new Set(t._changedVariables),this._visitCounts=new Map(t._visitCounts),this._turnIndices=new Map(t._turnIndices);}else this._globals=new Map,this._changedVariables=new Set,this._visitCounts=new Map,this._turnIndices=new Map;}TryGetGlobal(t,e){return t!==null&&this._globals.has(t)?{result:this._globals.get(t),exists:true}:{result:e,exists:false}}SetGlobal(t,e){this._globals.set(t,e);}AddChangedVariable(t){return this._changedVariables.add(t)}TryGetVisitCount(t,e){return this._visitCounts.has(t)?{result:this._visitCounts.get(t),exists:true}:{result:e,exists:false}}SetVisitCount(t,e){this._visitCounts.set(t,e);}SetTurnIndex(t,e){this._turnIndices.set(t,e);}TryGetTurnIndex(t,e){return this._turnIndices.has(t)?{result:this._turnIndices.get(t),exists:true}:{result:e,exists:false}}};pr.StatePatch=Ra;});var Va=d(tn=>{Object.defineProperty(tn,"__esModule",{value:true});tn.SimpleJson=void 0;var Qe=class o{static TextToDictionary(t){return new o.Reader(t).ToDictionary()}static TextToArray(t){return new o.Reader(t).ToArray()}};tn.SimpleJson=Qe;(function(o){class t{constructor(i){if(JSON.parse("0",(r,s,l)=>l!=null)){let r=(s,l,u)=>Number.isInteger(l)&&u.source.endsWith(".0")?u.source+"f":l;this._rootObject=JSON.parse(i,r);}else {let r=i.replace(/(,\s*)([0-9]+\.[0]+)([,]*)/g,'$1"$2f"$3');this._rootObject=JSON.parse(r);}}ToDictionary(){return this._rootObject}ToArray(){return this._rootObject}}o.Reader=t;class e{constructor(){this._currentPropertyName=null,this._currentString=null,this._stateStack=[],this._collectionStack=[],this._propertyNameStack=[],this._jsonObject=null;}WriteObject(i){this.WriteObjectStart(),i(this),this.WriteObjectEnd();}WriteObjectStart(){this.StartNewObject(true);let i={};if(this.state===o.Writer.State.Property){this.Assert(this.currentCollection!==null),this.Assert(this.currentPropertyName!==null);let a=this._propertyNameStack.pop();this.currentCollection[a]=i,this._collectionStack.push(i);}else this.state===o.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===o.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new o.Writer.StateElement(o.Writer.State.Object));}WriteObjectEnd(){this.Assert(this.state===o.Writer.State.Object),this._collectionStack.pop(),this._stateStack.pop();}WriteProperty(i,a){if(this.WritePropertyStart(i),arguments[1]instanceof Function){let r=arguments[1];r(this);}else {let r=arguments[1];this.Write(r);}this.WritePropertyEnd();}WriteIntProperty(i,a){this.WritePropertyStart(i),this.WriteInt(a),this.WritePropertyEnd();}WriteFloatProperty(i,a){this.WritePropertyStart(i),this.WriteFloat(a),this.WritePropertyEnd();}WritePropertyStart(i){this.Assert(this.state===o.Writer.State.Object),this._propertyNameStack.push(i),this.IncrementChildCount(),this._stateStack.push(new o.Writer.StateElement(o.Writer.State.Property));}WritePropertyEnd(){this.Assert(this.state===o.Writer.State.Property),this.Assert(this.childCount===1),this._stateStack.pop();}WritePropertyNameStart(){this.Assert(this.state===o.Writer.State.Object),this.IncrementChildCount(),this._currentPropertyName="",this._stateStack.push(new o.Writer.StateElement(o.Writer.State.Property)),this._stateStack.push(new o.Writer.StateElement(o.Writer.State.PropertyName));}WritePropertyNameEnd(){this.Assert(this.state===o.Writer.State.PropertyName),this.Assert(this._currentPropertyName!==null),this._propertyNameStack.push(this._currentPropertyName),this._currentPropertyName=null,this._stateStack.pop();}WritePropertyNameInner(i){this.Assert(this.state===o.Writer.State.PropertyName),this.Assert(this._currentPropertyName!==null),this._currentPropertyName+=i;}WriteArrayStart(){this.StartNewObject(true);let i=[];if(this.state===o.Writer.State.Property){this.Assert(this.currentCollection!==null),this.Assert(this.currentPropertyName!==null);let a=this._propertyNameStack.pop();this.currentCollection[a]=i,this._collectionStack.push(i);}else this.state===o.Writer.State.Array?(this.Assert(this.currentCollection!==null),this.currentCollection.push(i),this._collectionStack.push(i)):(this.Assert(this.state===o.Writer.State.None),this._jsonObject=i,this._collectionStack.push(i));this._stateStack.push(new o.Writer.StateElement(o.Writer.State.Array));}WriteArrayEnd(){this.Assert(this.state===o.Writer.State.Array),this._collectionStack.pop(),this._stateStack.pop();}Write(i,a=true){if(i===null){console.error("Warning: trying to write a null value");return}this.StartNewObject(false),this._addToCurrentObject(i);}WriteBool(i){i!==null&&(this.StartNewObject(false),this._addToCurrentObject(i));}WriteInt(i){i!==null&&(this.StartNewObject(false),this._addToCurrentObject(Math.floor(i)));}WriteFloat(i){i!==null&&(this.StartNewObject(false),i==Number.POSITIVE_INFINITY?this._addToCurrentObject(34e37):i==Number.NEGATIVE_INFINITY?this._addToCurrentObject(-34e37):isNaN(i)?this._addToCurrentObject(0):this._addToCurrentObject(i));}WriteNull(){this.StartNewObject(false),this._addToCurrentObject(null);}WriteStringStart(){this.StartNewObject(false),this._currentString="",this._stateStack.push(new o.Writer.StateElement(o.Writer.State.String));}WriteStringEnd(){this.Assert(this.state==o.Writer.State.String),this._stateStack.pop(),this._addToCurrentObject(this._currentString),this._currentString=null;}WriteStringInner(i,a=true){if(this.Assert(this.state===o.Writer.State.String),i===null){console.error("Warning: trying to write a null string");return}this._currentString+=i;}toString(){return this._jsonObject===null?"":JSON.stringify(this._jsonObject)}StartNewObject(i){i?this.Assert(this.state===o.Writer.State.None||this.state===o.Writer.State.Property||this.state===o.Writer.State.Array):this.Assert(this.state===o.Writer.State.Property||this.state===o.Writer.State.Array),this.state===o.Writer.State.Property&&this.Assert(this.childCount===0),(this.state===o.Writer.State.Array||this.state===o.Writer.State.Property)&&this.IncrementChildCount();}get state(){return this._stateStack.length>0?this._stateStack[this._stateStack.length-1].type:o.Writer.State.None}get childCount(){return this._stateStack.length>0?this._stateStack[this._stateStack.length-1].childCount:0}get currentCollection(){return this._collectionStack.length>0?this._collectionStack[this._collectionStack.length-1]:null}get currentPropertyName(){return this._propertyNameStack.length>0?this._propertyNameStack[this._propertyNameStack.length-1]:null}IncrementChildCount(){this.Assert(this._stateStack.length>0);let i=this._stateStack.pop();i.childCount++,this._stateStack.push(i);}Assert(i){if(!i)throw Error("Assert failed while writing JSON")}_addToCurrentObject(i){this.Assert(this.currentCollection!==null),this.state===o.Writer.State.Array?(this.Assert(Array.isArray(this.currentCollection)),this.currentCollection.push(i)):this.state===o.Writer.State.Property&&(this.Assert(!Array.isArray(this.currentCollection)),this.Assert(this.currentPropertyName!==null),this.currentCollection[this.currentPropertyName]=i,this._propertyNameStack.pop());}}o.Writer=e,(function(n){(function(r){r[r.None=0]="None",r[r.Object=1]="Object",r[r.Array=2]="Array",r[r.Property=3]="Property",r[r.PropertyName=4]="PropertyName",r[r.String=5]="String";})(n.State||(n.State={}));class a{constructor(s){this.type=o.Writer.State.None,this.childCount=0,this.type=s;}}n.StateElement=a;})(e=o.Writer||(o.Writer={}));})(Qe||(tn.SimpleJson=Qe={}));});var Pl=d(gr=>{Object.defineProperty(gr,"__esModule",{value:true});gr.Flow=void 0;var wl=Aa(),mr=Ce(),kd=B(),Wa=class{constructor(){let t=arguments[0],e=arguments[1];if(this.name=t,this.callStack=new wl.CallStack(e),arguments[2]){let n=arguments[2];this.callStack.SetJsonToken(n.callstack,e),this.outputStream=mr.JsonSerialisation.JArrayToRuntimeObjList(n.outputStream),this.currentChoices=mr.JsonSerialisation.JArrayToRuntimeObjList(n.currentChoices);let i=n.choiceThreads;typeof i<"u"&&this.LoadFlowChoiceThreads(i,e);}else this.outputStream=[],this.currentChoices=[];}WriteJson(t){t.WriteObjectStart(),t.WriteProperty("callstack",n=>this.callStack.WriteJson(n)),t.WriteProperty("outputStream",n=>mr.JsonSerialisation.WriteListRuntimeObjs(n,this.outputStream));let e=false;for(let n of this.currentChoices){if(n.threadAtGeneration===null)return (0, kd.throwNullException)("c.threadAtGeneration");n.originalThreadIndex=n.threadAtGeneration.threadIndex,this.callStack.ThreadWithIndex(n.originalThreadIndex)===null&&(e||(e=true,t.WritePropertyStart("choiceThreads"),t.WriteObjectStart()),t.WritePropertyStart(n.originalThreadIndex),n.threadAtGeneration.WriteJson(t),t.WritePropertyEnd());}e&&(t.WriteObjectEnd(),t.WritePropertyEnd()),t.WriteProperty("currentChoices",n=>{n.WriteArrayStart();for(let i of this.currentChoices)mr.JsonSerialisation.WriteChoice(n,i);n.WriteArrayEnd();}),t.WriteObjectEnd();}LoadFlowChoiceThreads(t,e){for(let n of this.currentChoices){let i=this.callStack.ThreadWithIndex(n.originalThreadIndex);if(i!==null)n.threadAtGeneration=i.Copy();else {let a=t[`${n.originalThreadIndex}`];n.threadAtGeneration=new wl.CallStack.Thread(a,e);}}}};gr.Flow=Wa;});var Tl=d(vr=>{Object.defineProperty(vr,"__esModule",{value:true});vr.StoryState=void 0;var Rd=Aa(),Vd=bl(),L=I(),Lt=Ut(),Wd=rr(),Da=Ji(),Ol=Z(),X=G(),La=Bt(),qt=Ce(),Dd=ka(),Ld=$t(),ve=qe(),en=se(),V=P(),qd=Oe(),ct=B(),jd=Ye(),Md=El(),xl=Va(),Cr=Pl(),Bd=et(),qa=class o{ToJson(t=false){let e=new xl.SimpleJson.Writer;return this.WriteJson(e),e.toString()}toJson(t=false){return this.ToJson(t)}LoadJson(t){let e=xl.SimpleJson.TextToDictionary(t);this.LoadJsonObj(e),this.onDidLoadState!==null&&this.onDidLoadState();}VisitCountAtPathString(t){let e;if(this._patch!==null){let n=this.story.ContentAtPath(new Ol.Path(t)).container;if(n===null)throw new Error("Content at path not found: "+t);if(e=this._patch.TryGetVisitCount(n,0),e.exists)return e.result}return e=(0, en.tryGetValueFromMap)(this._visitCounts,t,null),e.exists?e.result:0}VisitCountForContainer(t){if(t===null)return (0, ct.throwNullException)("container");if(!t.visitsShouldBeCounted)return this.story.Error("Read count for target ("+t.name+" - on "+t.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),0;if(this._patch!==null){let i=this._patch.TryGetVisitCount(t,0);if(i.exists)return i.result}let e=t.path.toString(),n=(0, en.tryGetValueFromMap)(this._visitCounts,e,null);return n.exists?n.result:0}IncrementVisitCountForContainer(t){if(this._patch!==null){let i=this.VisitCountForContainer(t);i++,this._patch.SetVisitCount(t,i);return}let e=t.path.toString(),n=(0, en.tryGetValueFromMap)(this._visitCounts,e,null);n.exists?this._visitCounts.set(e,n.result+1):this._visitCounts.set(e,1);}RecordTurnIndexVisitToContainer(t){if(this._patch!==null){this._patch.SetTurnIndex(t,this.currentTurnIndex);return}let e=t.path.toString();this._turnIndices.set(e,this.currentTurnIndex);}TurnsSinceForContainer(t){if(t.turnIndexShouldBeCounted||this.story.Error("TURNS_SINCE() for target ("+t.name+" - on "+t.debugMetadata+") unknown. The story may need to be compiled with countAllVisits flag (-c)."),this._patch!==null){let i=this._patch.TryGetTurnIndex(t,0);if(i.exists)return this.currentTurnIndex-i.result}let e=t.path.toString(),n=(0, en.tryGetValueFromMap)(this._turnIndices,e,0);return n.exists?this.currentTurnIndex-n.result:-1}get callstackDepth(){return this.callStack.depth}get outputStream(){return this._currentFlow.outputStream}get currentChoices(){return this.canContinue?[]:this._currentFlow.currentChoices}get generatedChoices(){return this._currentFlow.currentChoices}get currentErrors(){return this._currentErrors}get currentWarnings(){return this._currentWarnings}get variablesState(){return this._variablesState}set variablesState(t){this._variablesState=t;}get callStack(){return this._currentFlow.callStack}get evaluationStack(){return this._evaluationStack}get currentTurnIndex(){return this._currentTurnIndex}set currentTurnIndex(t){this._currentTurnIndex=t;}get currentPathString(){let t=this.currentPointer;return t.isNull?null:t.path===null?(0, ct.throwNullException)("pointer.path"):t.path.toString()}get previousPathString(){let t=this.previousPointer;return t.isNull?null:t.path===null?(0, ct.throwNullException)("previousPointer.path"):t.path.toString()}get currentPointer(){return this.callStack.currentElement.currentPointer.copy()}set currentPointer(t){this.callStack.currentElement.currentPointer=t.copy();}get previousPointer(){return this.callStack.currentThread.previousPointer.copy()}set previousPointer(t){this.callStack.currentThread.previousPointer=t.copy();}get canContinue(){return !this.currentPointer.isNull&&!this.hasError}get hasError(){return this.currentErrors!=null&&this.currentErrors.length>0}get hasWarning(){return this.currentWarnings!=null&&this.currentWarnings.length>0}get currentText(){if(this._outputStreamTextDirty){let t=new La.StringBuilder,e=false;for(let n of this.outputStream){let i=(0, V.asOrNull)(n,L.StringValue);if(!e&&i!==null)t.Append(i.value);else {let a=(0, V.asOrNull)(n,X.ControlCommand);a!==null&&(a.commandType==X.ControlCommand.CommandType.BeginTag?e=true:a.commandType==X.ControlCommand.CommandType.EndTag&&(e=false));}}this._currentText=this.CleanOutputWhitespace(t.toString()),this._outputStreamTextDirty=false;}return this._currentText}CleanOutputWhitespace(t){let e=new La.StringBuilder,n=-1,i=0;for(let a=0;a<t.length;a++){let r=t.charAt(a),s=r==" "||r==" ";s&&n==-1&&(n=a),s||(r!=`
|
|
21
21
|
`&&n>0&&n!=i&&e.Append(" "),n=-1),r==`
|
|
22
22
|
`&&(i=a+1),s||e.Append(r);}return e.toString()}get currentTags(){if(this._outputStreamTagsDirty){this._currentTags=[];let t=false,e=new La.StringBuilder;for(let n of this.outputStream){let i=(0, V.asOrNull)(n,X.ControlCommand);if(i!=null){if(i.commandType==X.ControlCommand.CommandType.BeginTag){if(t&&e.Length>0){let a=this.CleanOutputWhitespace(e.toString());this._currentTags.push(a),e.Clear();}t=true;}else if(i.commandType==X.ControlCommand.CommandType.EndTag){if(e.Length>0){let a=this.CleanOutputWhitespace(e.toString());this._currentTags.push(a),e.Clear();}t=false;}}else if(t){let a=(0, V.asOrNull)(n,L.StringValue);a!==null&&e.Append(a.value);}else {let a=(0, V.asOrNull)(n,Wd.Tag);a!=null&&a.text!=null&&a.text.length>0&&this._currentTags.push(a.text);}}if(e.Length>0){let n=this.CleanOutputWhitespace(e.toString());this._currentTags.push(n),e.Clear();}this._outputStreamTagsDirty=false;}return this._currentTags}get currentFlowName(){return this._currentFlow.name}get currentFlowIsDefaultFlow(){return this._currentFlow.name==this.kDefaultFlowName}get aliveFlowNames(){if(this._aliveFlowNamesDirty){if(this._aliveFlowNames=[],this._namedFlows!=null)for(let t of this._namedFlows.keys())t!=this.kDefaultFlowName&&this._aliveFlowNames.push(t);this._aliveFlowNamesDirty=false;}return this._aliveFlowNames}get inExpressionEvaluation(){return this.callStack.currentElement.inExpressionEvaluation}set inExpressionEvaluation(t){this.callStack.currentElement.inExpressionEvaluation=t;}constructor(t){this.kInkSaveStateVersion=10,this.kMinCompatibleLoadVersion=8,this.onDidLoadState=null,this._currentErrors=null,this._currentWarnings=null,this.divertedPointer=ve.Pointer.Null,this._currentTurnIndex=0,this.storySeed=0,this.previousRandom=0,this.didSafeExit=false,this._currentText=null,this._currentTags=null,this._outputStreamTextDirty=true,this._outputStreamTagsDirty=true,this._patch=null,this._aliveFlowNames=null,this._namedFlows=null,this.kDefaultFlowName="DEFAULT_FLOW",this._aliveFlowNamesDirty=true,this.story=t,this._currentFlow=new Cr.Flow(this.kDefaultFlowName,t),this.OutputStreamDirty(),this._aliveFlowNamesDirty=true,this._evaluationStack=[],this._variablesState=new Vd.VariablesState(this.callStack,t.listDefinitions),this._visitCounts=new Map,this._turnIndices=new Map,this.currentTurnIndex=-1;let e=new Date().getTime();this.storySeed=new Dd.PRNG(e).next()%100,this.previousRandom=0,this.GoToStart();}GoToStart(){this.callStack.currentElement.currentPointer=ve.Pointer.StartOf(this.story.mainContentContainer);}SwitchFlow_Internal(t){if(t===null)throw new Error("Must pass a non-null string to Story.SwitchFlow");if(this._namedFlows===null&&(this._namedFlows=new Map,this._namedFlows.set(this.kDefaultFlowName,this._currentFlow)),t===this._currentFlow.name)return;let e,n=(0, en.tryGetValueFromMap)(this._namedFlows,t,null);n.exists?e=n.result:(e=new Cr.Flow(t,this.story),this._namedFlows.set(t,e),this._aliveFlowNamesDirty=true),this._currentFlow=e,this.variablesState.callStack=this._currentFlow.callStack,this.OutputStreamDirty();}SwitchToDefaultFlow_Internal(){this._namedFlows!==null&&this.SwitchFlow_Internal(this.kDefaultFlowName);}RemoveFlow_Internal(t){if(t===null)throw new Error("Must pass a non-null string to Story.DestroyFlow");if(t===this.kDefaultFlowName)throw new Error("Cannot destroy default flow");if(this._currentFlow.name===t&&this.SwitchToDefaultFlow_Internal(),this._namedFlows===null)return (0, ct.throwNullException)("this._namedFlows");this._namedFlows.delete(t),this._aliveFlowNamesDirty=true;}CopyAndStartPatching(t){let e=new o(this.story);if(e._patch=new Md.StatePatch(this._patch),e._currentFlow.name=this._currentFlow.name,e._currentFlow.callStack=new Rd.CallStack(this._currentFlow.callStack),e._currentFlow.outputStream.push(...this._currentFlow.outputStream),e.OutputStreamDirty(),t)for(let n of this._currentFlow.currentChoices)e._currentFlow.currentChoices.push(n.Clone());else e._currentFlow.currentChoices.push(...this._currentFlow.currentChoices);if(this._namedFlows!==null){e._namedFlows=new Map;for(let[n,i]of this._namedFlows)e._namedFlows.set(n,i),e._aliveFlowNamesDirty=true;e._namedFlows.set(this._currentFlow.name,e._currentFlow);}return this.hasError&&(e._currentErrors=[],e._currentErrors.push(...this.currentErrors||[])),this.hasWarning&&(e._currentWarnings=[],e._currentWarnings.push(...this.currentWarnings||[])),e.variablesState=this.variablesState,e.variablesState.callStack=e.callStack,e.variablesState.patch=e._patch,e.evaluationStack.push(...this.evaluationStack),this.divertedPointer.isNull||(e.divertedPointer=this.divertedPointer.copy()),e.previousPointer=this.previousPointer.copy(),e._visitCounts=this._visitCounts,e._turnIndices=this._turnIndices,e.currentTurnIndex=this.currentTurnIndex,e.storySeed=this.storySeed,e.previousRandom=this.previousRandom,e.didSafeExit=this.didSafeExit,e}RestoreAfterPatch(){this.variablesState.callStack=this.callStack,this.variablesState.patch=this._patch;}ApplyAnyPatch(){if(this._patch!==null){this.variablesState.ApplyPatch();for(let[t,e]of this._patch.visitCounts)this.ApplyCountChanges(t,e,true);for(let[t,e]of this._patch.turnIndices)this.ApplyCountChanges(t,e,false);this._patch=null;}}ApplyCountChanges(t,e,n){(n?this._visitCounts:this._turnIndices).set(t.path.toString(),e);}WriteJson(t){if(t.WriteObjectStart(),t.WritePropertyStart("flows"),t.WriteObjectStart(),this._namedFlows!==null)for(let[e,n]of this._namedFlows)t.WriteProperty(e,i=>n.WriteJson(i));else t.WriteProperty(this._currentFlow.name,e=>this._currentFlow.WriteJson(e));if(t.WriteObjectEnd(),t.WritePropertyEnd(),t.WriteProperty("currentFlowName",this._currentFlow.name),t.WriteProperty("variablesState",e=>this.variablesState.WriteJson(e)),t.WriteProperty("evalStack",e=>qt.JsonSerialisation.WriteListRuntimeObjs(e,this.evaluationStack)),!this.divertedPointer.isNull){if(this.divertedPointer.path===null)return (0, ct.throwNullException)("divertedPointer");t.WriteProperty("currentDivertTarget",this.divertedPointer.path.componentsString);}t.WriteProperty("visitCounts",e=>qt.JsonSerialisation.WriteIntDictionary(e,this._visitCounts)),t.WriteProperty("turnIndices",e=>qt.JsonSerialisation.WriteIntDictionary(e,this._turnIndices)),t.WriteIntProperty("turnIdx",this.currentTurnIndex),t.WriteIntProperty("storySeed",this.storySeed),t.WriteIntProperty("previousRandom",this.previousRandom),t.WriteIntProperty("inkSaveVersion",this.kInkSaveStateVersion),t.WriteIntProperty("inkFormatVersion",jd.Story.inkVersionCurrent),t.WriteObjectEnd();}LoadJsonObj(t){let e=t,n=e.inkSaveVersion;if(n==null)throw new Error("ink save format incorrect, can't load.");if(parseInt(n)<this.kMinCompatibleLoadVersion)throw new Error("Ink save format isn't compatible with the current version (saw '"+n+"', but minimum is "+this.kMinCompatibleLoadVersion+"), so can't load.");let i=e.flows;if(i!=null){let r=i;Object.keys(r).length===1?this._namedFlows=null:this._namedFlows===null?this._namedFlows=new Map:this._namedFlows.clear();let s=Object.entries(r);for(let[l,u]of s){let h=l,c=u,f=new Cr.Flow(h,this.story,c);if(Object.keys(r).length===1)this._currentFlow=new Cr.Flow(h,this.story,c);else {if(this._namedFlows===null)return (0, ct.throwNullException)("this._namedFlows");this._namedFlows.set(h,f);}}if(this._namedFlows!=null&&this._namedFlows.size>1){let l=e.currentFlowName;this._currentFlow=this._namedFlows.get(l);}}else {this._namedFlows=null,this._currentFlow.name=this.kDefaultFlowName,this._currentFlow.callStack.SetJsonToken(e.callstackThreads,this.story),this._currentFlow.outputStream=qt.JsonSerialisation.JArrayToRuntimeObjList(e.outputStream),this._currentFlow.currentChoices=qt.JsonSerialisation.JArrayToRuntimeObjList(e.currentChoices);let r=e.choiceThreads;this._currentFlow.LoadFlowChoiceThreads(r,this.story);}this.OutputStreamDirty(),this._aliveFlowNamesDirty=true,this.variablesState.SetJsonToken(e.variablesState),this.variablesState.callStack=this._currentFlow.callStack,this._evaluationStack=qt.JsonSerialisation.JArrayToRuntimeObjList(e.evalStack);let a=e.currentDivertTarget;if(a!=null){let r=new Ol.Path(a.toString());this.divertedPointer=this.story.PointerAtPath(r);}this._visitCounts=qt.JsonSerialisation.JObjectToIntDictionary(e.visitCounts),this._turnIndices=qt.JsonSerialisation.JObjectToIntDictionary(e.turnIndices),this.currentTurnIndex=parseInt(e.turnIdx),this.storySeed=parseInt(e.storySeed),this.previousRandom=parseInt(e.previousRandom);}ResetErrors(){this._currentErrors=null,this._currentWarnings=null;}ResetOutput(t=null){this.outputStream.length=0,t!==null&&this.outputStream.push(...t),this.OutputStreamDirty();}PushToOutputStream(t){let e=(0, V.asOrNull)(t,L.StringValue);if(e!==null){let n=this.TrySplittingHeadTailWhitespace(e);if(n!==null){for(let i of n)this.PushToOutputStreamIndividual(i);this.OutputStreamDirty();return}}this.PushToOutputStreamIndividual(t),this.OutputStreamDirty();}PopFromOutputStream(t){this.outputStream.splice(this.outputStream.length-t,t),this.OutputStreamDirty();}TrySplittingHeadTailWhitespace(t){let e=t.value;if(e===null)return (0, ct.throwNullException)("single.value");let n=-1,i=-1;for(let h=0;h<e.length;h++){let c=e[h];if(c==`
|
|
@@ -31,8 +31,8 @@ var iu=Object.create;var Vr=Object.defineProperty;var ru=Object.getOwnPropertyDe
|
|
|
31
31
|
`));let R=new vf.Choice(h,f,p);return l&&(R.identifier=l),R.indentationDepth=s.length,R.hasWeaveStyleInlineBrackets=v,R.condition=u,R.onceOnly=r,R.isInvisibleDefault=H,R},this.ChoiceCondition=()=>{let r=this.Interleave(this.ChoiceSingleCondition,this.ChoiceConditionsSpace);return r===null?null:r.length===1?r[0]:new Ff.MultipleConditionExpression(r)},this.ChoiceConditionsSpace=()=>(this.Newline(),this.Whitespace(),Nt.ParseSuccess),this.ChoiceSingleCondition=()=>{if(this.ParseString("{")===null)return null;let r=this.Expect(this.Expression,"choice condition inside { }");return this.DisallowIncrement(r),this.Expect(this.String("}"),"closing '}' for choice condition"),r},this.Gather=()=>{let r=this.Parse(this.GatherDashes);if(r===null)return null;let s=Number(r),l=this.Parse(this.BracketedName),u=new Pf.Gather(l,s);return this.Newline(),u},this.GatherDashes=()=>{this.Whitespace();let r=0;for(;this.ParseDashNotArrow()!==null;)r+=1,this.Whitespace();return r===0?null:r},this.ParseDashNotArrow=()=>{let r=this.BeginRule();return this.ParseString("->")===null&&this.ParseSingleCharacter()==="-"?this.SucceedRule(r):this.FailRule(r)},this.BracketedName=()=>{if(this.ParseString("(")===null)return null;this.Whitespace();let r=this.Parse(this.IdentifierWithMetadata);return r===null?null:(this.Whitespace(),this.Expect(this.String(")"),"closing ')' for bracketed name"),r)},this.InnerConditionalContent=r=>{if(r===void 0){let c=this.Parse(this.ConditionExpression),f=this.Parse(()=>this.InnerConditionalContent(c));return f===null?null:f}let s,l=r!==null,u=this.Parse(this.Newline)===null;if(u&&!l)return null;if(u)s=this.InlineConditionalBranches();else {if(s=this.MultilineConditionalBranches(),s===null){if(r){let c=this.StatementsAtLevel(Y.StatementLevel.InnerBlock);if(c!==null){s=[new on.ConditionalSingleBranch(c)];let p=this.Parse(this.SingleMultilineCondition);p&&(p.isElse||(this.ErrorWithParsedObject("Expected an '- else:' clause here rather than an extra condition",p),p.isElse=true),s.push(p));}}if(s===null)return null}else if(s.length===1&&s[0].isElse&&r){let c=new on.ConditionalSingleBranch(null);c.isTrueBranch=true,s.unshift(c);}if(r){let c=false;for(let f=0;f<s.length;++f){let p=s[f],v=f===s.length-1;p.ownExpression?(p.matchingEquality=true,c=true):c&&v?(p.matchingEquality=true,p.isElse=true):!v&&s.length>2?this.ErrorWithParsedObject("Only final branch can be an 'else'. Did you miss a ':'?",p):f===0?p.isTrueBranch=true:p.isElse=true;}}else {for(let c=0;c<s.length;++c){let f=s[c],p=c===s.length-1;if(f.ownExpression===null)if(p)f.isElse=true;else if(f.isElse){let v=s[s.length-1];v.isElse?this.ErrorWithParsedObject("Multiple 'else' cases. Can have a maximum of one, at the end.",v):this.ErrorWithParsedObject("'else' case in conditional should always be the final one",f);}else this.ErrorWithParsedObject("Branch doesn't have condition. Are you missing a ':'? ",f);}s.length===1&&s[0].ownExpression===null&&this.ErrorWithParsedObject("Condition block with no conditions",s[0]);}}if(s===null)return null;for(let c of s)c.isInline=u;return new yf.Conditional(r,s)},this.InlineConditionalBranches=()=>{let r=this.Interleave(this.MixedTextAndLogic,this.Exclude(this.String("|")),null,false);if(r===null||r.length===0)return null;let s=[];if(r.length>2)this.Error("Expected one or two alternatives separated by '|' in inline conditional");else {let l=new on.ConditionalSingleBranch(r[0]);if(l.isTrueBranch=true,s.push(l),r.length>1){let u=new on.ConditionalSingleBranch(r[1]);u.isElse=true,s.push(u);}}return s},this.MultilineConditionalBranches=()=>{this.MultilineWhitespace();let r=this.OneOrMore(this.SingleMultilineCondition);return r===null?null:(this.MultilineWhitespace(),r)},this.SingleMultilineCondition=()=>{if(this.Whitespace(),this.ParseString("->")!==null||this.ParseString("-")===null)return null;this.Whitespace();let r=null,s=this.Parse(this.ElseExpression)!==null;s||(r=this.Parse(this.ConditionExpression));let l=this.StatementsAtLevel(Y.StatementLevel.InnerBlock);r===null&&l===null&&(this.Error("expected content for the conditional branch following '-'"),l=[new It.Text("")]),this.MultilineWhitespace();let u=new on.ConditionalSingleBranch(l);return u.ownExpression=r,u.isElse=s,u},this.ConditionExpression=()=>{let r=this.Parse(this.Expression);return r===null||(this.DisallowIncrement(r),this.Whitespace(),this.ParseString(":")===null)?null:r},this.ElseExpression=()=>this.ParseString("else")===null||(this.Whitespace(),this.ParseString(":")===null)?null:Nt.ParseSuccess,this._nonTextPauseCharacters=null,this._nonTextEndCharacters=null,this._notTextEndCharactersChoice=null,this._notTextEndCharactersString=null,this.TrimEndWhitespace=(r,s)=>{if(r.length>0){let l=r.length-1,u=r[l];if(u instanceof It.Text){let h=u;h.text=h.text.replace(new RegExp(/[ \t]+$/g),""),s?h.text+=" ":h.text.length===0&&(r.splice(l,1),this.TrimEndWhitespace(r,false));}}},this.LineOfMixedTextAndLogic=()=>{this.Parse(this.Whitespace);let r=this.Parse(this.MixedTextAndLogic);if(!r||!r.length)return null;let s=r[0];return s&&s.text&&s.text.startsWith("return")&&this.Warning("Do you need a '~' before 'return'? If not, perhaps use a glue: <> (since it's lowercase) or rewrite somehow?"),r.length===0?null:(r[r.length-1]instanceof Qt.Divert||this.TrimEndWhitespace(r,false),this.EndTagIfNecessary(r),r.length>0&&r[0]instanceof be.Tag&&r[0].isStart||r.push(new It.Text(`
|
|
32
32
|
`)),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),r)},this.MixedTextAndLogic=()=>{this.ParseObject(this.Spaced(this.String("~")))!==null&&this.Error("You shouldn't use a '~' here - tildas are for logic that's on its own line. To do inline logic, use { curly braces } instead");let s=this.Interleave(this.Optional(this.ContentText),this.Optional(this.InlineLogicOrGlueOrStartTag));if(!this._parsingChoice){let l=this.Parse(this.MultiDivert);l!==null&&(s===null&&(s=[]),this.EndTagIfNecessary(s),this.TrimEndWhitespace(s,true),s.push(...l));}return s||null},this.ContentText=()=>this.ContentTextAllowingEscapeChar(),this.ContentTextAllowingEscapeChar=()=>{let r=null;do{let s=this.Parse(this.ContentTextNoEscape),l=this.ParseString("\\")!==null;if(l||s!==null){if(r===null&&(r=""),s!==null&&(r+=String(s)),l){let u=this.ParseSingleCharacter();r+=u;}}else break}while(true);return r!==null?new It.Text(r):null},this.ContentTextNoEscape=()=>{this._nonTextPauseCharacters===null&&(this._nonTextPauseCharacters=new j.CharacterSet("-<")),this._nonTextEndCharacters===null&&(this._nonTextEndCharacters=new j.CharacterSet(`{}|
|
|
33
33
|
\r\\#`),this._notTextEndCharactersChoice=new j.CharacterSet(this._nonTextEndCharacters),this._notTextEndCharactersChoice.AddCharacters("[]"),this._notTextEndCharactersString=new j.CharacterSet(this._nonTextEndCharacters),this._notTextEndCharactersString.AddCharacters('"'));let r=()=>this.OneOf([this.ParseDivertArrow,this.ParseThreadArrow,this.EndOfLine,this.Glue]),s=null;this.parsingStringExpression?s=this._notTextEndCharactersString:this._parsingChoice?s=this._notTextEndCharactersChoice:s=this._nonTextEndCharacters;let l=this.ParseUntil(r,this._nonTextPauseCharacters,s);return l!==null?l:null},this.MultiDivert=()=>{this.Whitespace();let r=[],s=this.Parse(this.StartThread);if(s)return r=[s],r;let l=this.Interleave(this.ParseDivertArrowOrTunnelOnwards,this.DivertIdentifierWithArguments);if(!l)return null;r=[],this.EndTagIfNecessary(r);for(let u=0;u<l.length;++u)if(u%2===0){if(l[u]==="->->"){u===0||u===l.length-1||u===l.length-2||this.Error("Tunnel onwards '->->' must only come at the begining or the start of a divert");let f=new zl.TunnelOnwards;if(u<l.length-1){let p=(0, Mt.asOrNull)(l[u+1],Qt.Divert);f.divertAfter=p;}r.push(f);break}}else {let c=l[u];u<l.length-1&&(c.isTunnel=true),r.push(c);}if(r.length===0&&l.length===1){let u=new Qt.Divert(null);u.isEmpty=true,r.push(u),this._parsingChoice||this.Error("Empty diverts (->) are only valid on choices");}return r},this.StartThread=()=>{if(this.Whitespace(),this.ParseThreadArrow()===null)return null;this.Whitespace();let r=this.Expect(this.DivertIdentifierWithArguments,"target for new thread",()=>new Qt.Divert(null));return r.isThread=true,r},this.DivertIdentifierWithArguments=()=>{this.Whitespace();let r=this.Parse(this.DotSeparatedDivertPathComponents);if(!r)return null;this.Whitespace();let s=this.Parse(this.ExpressionFunctionCallArguments);this.Whitespace();let l=new kf.Path(r);return new Qt.Divert(l,s)},this.SingleDivert=()=>{let r=this.Parse(this.MultiDivert);if(!r||r.length!==1||r[0]instanceof zl.TunnelOnwards)return null;let l=r[0];return l.isTunnel?null:l},this.DotSeparatedDivertPathComponents=()=>this.Interleave(this.Spaced(this.IdentifierWithMetadata),this.Exclude(this.String("."))),this.ParseDivertArrowOrTunnelOnwards=()=>{let r=0;for(;this.ParseString("->")!==null;)r+=1;return r===0?null:r===1?"->":(r===2||this.Error("Unexpected number of arrows in divert. Should only have '->' or '->->'"),"->->")},this.ParseDivertArrow=()=>this.ParseString("->"),this.ParseThreadArrow=()=>this.ParseString("<-"),this._binaryOperators=[],this._maxBinaryOpLength=0,this.TempDeclarationOrAssignment=()=>{this.Whitespace();let r=this.ParseTempKeyword();this.Whitespace();let s=null;if(r?s=this.Expect(this.IdentifierWithMetadata,"variable name"):s=this.Parse(this.IdentifierWithMetadata),s===null)return null;this.Whitespace();let l=this.ParseString("+")!==null,u=this.ParseString("-")!==null;if(l&&u&&this.Error("Unexpected sequence '+-'"),this.ParseString("=")===null)return r&&this.Error("Expected '='"),null;let h=this.Expect(this.Expression,"value expression to be assigned");return l||u?new Ar.IncDecExpression(s,h,l):new Xa.VariableAssignment({variableIdentifier:s,assignedExpression:h,isTemporaryNewDeclaration:r})},this.DisallowIncrement=r=>{r instanceof Ar.IncDecExpression&&this.Error("Can't use increment/decrement here. It can only be used on a ~ line");},this.ParseTempKeyword=()=>{let r=this.BeginRule();return this.Parse(this.Identifier)==="temp"?(this.SucceedRule(r),true):(this.FailRule(r),false)},this.ReturnStatement=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="return")return null;this.Whitespace();let s=this.Parse(this.Expression);return new Kl.ReturnType(s)},this.Expression=(r=0)=>{this.Whitespace();let s=this.ExpressionUnary();if(s===null)return null;for(this.Whitespace();;){let l=this.BeginRule(),u=this.ParseInfixOperator();if(u!==null&&u.precedence>r){let h=`right side of '${u.type}' expression`,c=this.Expect(()=>this.ExpressionInfixRight(s,u),h);if(c===null)return this.FailRule(l),null;s=this.SucceedRule(l,c);continue}this.FailRule(l);break}return this.Whitespace(),s},this.ExpressionUnary=()=>{let r=this.Parse(this.ExpressionDivertTarget);if(r!==null)return r;let s=this.OneOf([this.String("-"),this.String("!")]);s===null&&(s=this.Parse(this.ExpressionNot)),this.Whitespace();let l=this.OneOf([this.ExpressionList,this.ExpressionParen,this.ExpressionFunctionCall,this.ExpressionVariableName,this.ExpressionLiteral]);if(l===null&&s!==null&&(l=this.ExpressionUnary()),l===null)return null;s!==null&&(l=Vf.UnaryExpression.WithInner(l,s)),this.Whitespace();let u=this.OneOf([this.String("++"),this.String("--")]);if(u!==null){let h=u==="++";if(!(l instanceof Ya.VariableReference))this.Error(`can only increment and decrement variables, but saw '${l}'.`);else {let c=l;l=new Ar.IncDecExpression(c.identifier,h);}}return l},this.ExpressionNot=()=>{let r=this.Identifier();return r==="not"?r:null},this.ExpressionLiteral=()=>this.OneOf([this.ExpressionFloat,this.ExpressionInt,this.ExpressionBool,this.ExpressionString]),this.ExpressionDivertTarget=()=>{this.Whitespace();let r=this.Parse(this.SingleDivert);return !r||r&&r.isThread?null:(this.Whitespace(),new za.DivertTarget(r))},this.ExpressionInt=()=>{let r=this.ParseInt();return r===null?null:new Ee.NumberExpression(r,"int")},this.ExpressionFloat=()=>{let r=this.ParseFloat();return r===null?null:new Ee.NumberExpression(r,"float")},this.ExpressionString=()=>{if(this.ParseString('"')===null)return null;this.parsingStringExpression=true;let s=this.Parse(this.MixedTextAndLogic);return this.Expect(this.String('"'),"close quote for string expression"),this.parsingStringExpression=false,s===null?s=[new It.Text("")]:s.find(l=>l instanceof Qt.Divert)&&this.Error("String expressions cannot contain diverts (->)"),new ln.StringExpression(s)},this.ExpressionBool=()=>{let r=this.Parse(this.Identifier);return r==="true"?new Ee.NumberExpression(true,"bool"):r==="false"?new Ee.NumberExpression(false,"bool"):null},this.ExpressionFunctionCall=()=>{let r=this.Parse(this.IdentifierWithMetadata);if(r===null)return null;this.Whitespace();let s=this.Parse(this.ExpressionFunctionCallArguments);return s===null?null:new Ir.FunctionCall(r,s)},this.ExpressionFunctionCallArguments=()=>{if(this.ParseString("(")===null)return null;let r=this.Exclude(this.String(",")),s=this.Interleave(this.Expression,r);return s===null&&(s=[]),this.Whitespace(),this.Expect(this.String(")"),"closing ')' for function call"),s},this.ExpressionVariableName=()=>{let r=this.Interleave(this.IdentifierWithMetadata,this.Exclude(this.Spaced(this.String("."))));return r===null||Jl.Story.IsReservedKeyword(r[0].name)?null:new Ya.VariableReference(r)},this.ExpressionParen=()=>{if(this.ParseString("(")===null)return null;let r=this.Parse(this.Expression);return r===null?null:(this.Whitespace(),this.Expect(this.String(")"),"closing parenthesis ')' for expression"),r)},this.ExpressionInfixRight=(r,s)=>{if(!r)return null;this.Whitespace();let l=this.Parse(()=>this.Expression(s.precedence));return l?new Cf.BinaryExpression(r,l,s.type):null},this.ParseInfixOperator=()=>{for(let r of this._binaryOperators){let s=this.BeginRule();if(this.ParseString(r.type)!==null){if(r.requireWhitespace&&this.Whitespace()===null){this.FailRule(s);continue}return this.SucceedRule(s,r)}this.FailRule(s);}return null},this.ExpressionList=()=>{if(this.Whitespace(),this.ParseString("(")===null)return null;this.Whitespace();let r=this.SeparatedList(this.ListMember,this.Spaced(this.String(",")));return this.Whitespace(),this.ParseString(")")===null?null:new $l.List(r)},this.ListMember=()=>{this.Whitespace();let r=this.Parse(this.IdentifierWithMetadata);if(r===null)return null;if(this.ParseString(".")!==null){let l=this.Expect(this.IdentifierWithMetadata,`element name within the set ${r}`);r.name+=`.${l?.name}`;}return this.Whitespace(),r},this.RegisterExpressionOperators=()=>{this.RegisterBinaryOperator("&&",1),this.RegisterBinaryOperator("||",1),this.RegisterBinaryOperator("and",1,true),this.RegisterBinaryOperator("or",1,true),this.RegisterBinaryOperator("==",2),this.RegisterBinaryOperator(">=",2),this.RegisterBinaryOperator("<=",2),this.RegisterBinaryOperator("<",2),this.RegisterBinaryOperator(">",2),this.RegisterBinaryOperator("!=",2),this.RegisterBinaryOperator("?",3),this.RegisterBinaryOperator("has",3,true),this.RegisterBinaryOperator("!?",3),this.RegisterBinaryOperator("hasnt",3,true),this.RegisterBinaryOperator("^",3),this.RegisterBinaryOperator("+",4),this.RegisterBinaryOperator("-",5),this.RegisterBinaryOperator("*",6),this.RegisterBinaryOperator("/",7),this.RegisterBinaryOperator("%",8),this.RegisterBinaryOperator("mod",8,true);},this.RegisterBinaryOperator=(r,s,l=false)=>{let u=new Tf.InfixOperator(r,s,l);this._binaryOperators.push(u),this._maxBinaryOpLength=Math.max(this._maxBinaryOpLength,r.length);},this._openFilenames=[],this.IncludeStatement=()=>{if(this.Whitespace(),this.ParseString("INCLUDE")===null)return null;this.Whitespace();let r=this.Expect(()=>this.ParseUntilCharactersFromString(`
|
|
34
|
-
\r`),"filename for include statement");r=r.replace(new RegExp(/[ \t]+$/g),"");let s=this.fileHandler.ResolveInkFilename(r);if(this.FilenameIsAlreadyOpen(s))return this.Error(`Recursive INCLUDE detected: '${s}' is already open.`),this.ParseUntilCharactersFromString(`\r
|
|
35
|
-
`),new Gl.IncludedFile(null);this.AddOpenFilename(s);let l=null,u="";try{u=this._rootParser.fileHandler.LoadInkFileContents(s);}catch(h){this.Error(`Failed to load: '${r}'.
|
|
34
|
+
\r`),"filename for include statement");r=r.replace(new RegExp(/[ \t]+$/g),"");let s=this.fileHandler.ResolveInkFilename(r,this._filename);if(this.FilenameIsAlreadyOpen(s))return this.Error(`Recursive INCLUDE detected: '${s}' is already open.`),this.ParseUntilCharactersFromString(`\r
|
|
35
|
+
`),new Gl.IncludedFile(null);this.AddOpenFilename(s);let l=null,u="";try{u=this._rootParser.fileHandler.LoadInkFileContents(s,this._filename);}catch(h){this.Error(`Failed to load: '${r}'.
|
|
36
36
|
Error:${h}`);}return u!=null&&(l=new o(u,r,this._externalErrorHandler,this._rootParser,this.fileHandler).ParseStory()),this.RemoveOpenFilename(s),new Gl.IncludedFile(l)},this.FilenameIsAlreadyOpen=r=>this._rootParser._openFilenames.includes(r),this.AddOpenFilename=r=>{this._rootParser._openFilenames.push(r);},this.RemoveOpenFilename=r=>{this._rootParser._openFilenames.splice(this._rootParser._openFilenames.indexOf(r),1);},this.KnotDefinition=()=>{let r=this.Parse(this.KnotDeclaration);if(r===null)return null;this.Expect(this.EndOfLine,"end of line after knot name definition",this.SkipToNextLine);let s=()=>this.StatementsAtLevel(Y.StatementLevel.Knot),l=this.Expect(s,"at least one line within the knot",this.KnotStitchNoContentRecoveryRule);return new Nf.Knot(r.name,l,r.args,r.isFunction)},this.KnotDeclaration=()=>{if(this.Whitespace(),this.KnotTitleEquals()===null)return null;this.Whitespace();let r=this.Parse(this.IdentifierWithMetadata),s,l=r?.name==="function";l?(this.Expect(this.Whitespace,"whitespace after the 'function' keyword"),s=this.Parse(this.IdentifierWithMetadata)):s=r,s===null&&(this.Error(`Expected the name of the ${l?"function":"knot"}`),s=new un.Identifier("")),this.Whitespace();let u=this.Parse(this.BracketedKnotDeclArguments);return this.Whitespace(),this.Parse(this.KnotTitleEquals),new Bl.FlowDecl(s,u,l)},this.KnotTitleEquals=()=>{let r=this.ParseCharactersFromString("=");return r===null||r.length<=1?null:r},this.StitchDefinition=()=>{let r=this.Parse(this.StitchDeclaration);if(r===null)return null;this.Expect(this.EndOfLine,"end of line after stitch name",this.SkipToNextLine);let s=()=>this.StatementsAtLevel(Y.StatementLevel.Stitch),l=this.Expect(s,"at least one line within the stitch",this.KnotStitchNoContentRecoveryRule);return new Rf.Stitch(r.name,l,r.args,r.isFunction)},this.StitchDeclaration=()=>{if(this.Whitespace(),this.ParseString("=")===null||this.ParseString("=")!==null)return null;this.Whitespace();let r=this.ParseString("function")!==null;r&&this.Whitespace();let s=this.Parse(this.IdentifierWithMetadata);if(s===null)return null;this.Whitespace();let l=this.Parse(this.BracketedKnotDeclArguments);return this.Whitespace(),new Bl.FlowDecl(s,l,r)},this.KnotStitchNoContentRecoveryRule=()=>(this.ParseUntil(this.KnotDeclaration,new j.CharacterSet("="),null),[new It.Text("<ERROR IN FLOW>")]),this.BracketedKnotDeclArguments=()=>{if(this.ParseString("(")===null)return null;let r=this.Interleave(this.Spaced(this.FlowDeclArgument),this.Exclude(this.String(",")));return this.Expect(this.String(")"),"closing ')' for parameter list"),r===null&&(r=[]),r},this.FlowDeclArgument=()=>{let r=this.Parse(this.IdentifierWithMetadata);this.Whitespace();let s=this.ParseDivertArrow();this.Whitespace();let l=this.Parse(this.IdentifierWithMetadata);if(r==null&&l===null)return null;let u=new mf.Argument;return s!==null&&(u.isDivertTarget=true),r!==null&&r.name==="ref"?(l===null&&this.Error("Expected an parameter name after 'ref'"),u.identifier=l,u.isByReference=true):(u.isDivertTarget?u.identifier=l:u.identifier=r,u.identifier===null&&this.Error("Expected an parameter name"),u.isByReference=false),u},this.ExternalDeclaration=()=>{this.Whitespace();let r=this.Parse(this.IdentifierWithMetadata);if(r===null||r.name!="EXTERNAL")return null;this.Whitespace();let s=this.Expect(this.IdentifierWithMetadata,"name of external function")||new un.Identifier("");this.Whitespace();let l=this.Expect(this.BracketedKnotDeclArguments,`declaration of arguments for EXTERNAL, even if empty, i.e. 'EXTERNAL ${s}()'`);l===null&&(l=[]);let u=l.map(h=>{var c;return (c=h.identifier)===null||c===void 0?void 0:c.name}).filter(Mt.filterUndef);return new wf.ExternalDeclaration(s,u)},this._identifierCharSet=null,this.LogicLine=()=>{if(this.Whitespace(),this.ParseString("~")===null)return null;this.Whitespace();let r=()=>this.OneOf([this.ReturnStatement,this.TempDeclarationOrAssignment,this.Expression]),s=this.Expect(r,"expression after '~'",this.SkipToNextLine);if(s===null)return new rt.ContentList;s instanceof Ef.Expression&&!(s instanceof Ir.FunctionCall||s instanceof Ar.IncDecExpression)&&this.Error(`Logic following a '~' can't be that type of expression. It can only be something like:
|
|
37
37
|
~ return
|
|
38
38
|
~ var x = blah
|